Skip to content

Commit

Permalink
New bitfield types in proto (#2915)
Browse files Browse the repository at this point in the history
* Cast bytes to correct bitfield, failing tests now though

* Add forked gogo/protobuf until gogo/protobuf#582

* remove newline
  • Loading branch information
prestonvanloon authored and terencechain committed Jul 6, 2019
1 parent 2b82863 commit bd8425b
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 211 deletions.
15 changes: 15 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -1102,3 +1102,18 @@ go_repository(
commit = "29f32d820d112dbd66e58492a6ffb7cc3106312b",
importpath = "gopkg.in/d4l3k/messagediff.v1",
)

go_repository(
name = "com_github_prysmaticlabs_go_bitfield",
commit = "66dcdec9762a9f5935d9466b18f4bee852d1b091",
importpath = "github.com/prysmaticlabs/go-bitfield",
)

go_repository(
name = "com_github_gogo_protobuf",
commit = "c91f1861c28312f505e13bd3e1c90d2088a670c7",
importpath = "github.com/gogo/protobuf",
# Using fork until https://github.com/gogo/protobuf/pull/582 is merged.
remote = "https://github.com/prestonvanloon/protobuf.git",
vcs = "git",
)
5 changes: 3 additions & 2 deletions proto/beacon/p2p/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

go_proto_library(
name = "v1_go_proto",
compiler = "//:proto_compiler",
importpath = "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1",
proto = ":v1_proto",
visibility = ["//visibility:public"],
deps = [
"//proto/common:common_go_proto",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
],
compiler = "//:proto_compiler",
)

go_library(
Expand All @@ -28,8 +29,8 @@ proto_library(
],
visibility = ["//visibility:public"],
deps = [
"//proto/common:common_proto",
"@com_google_protobuf//:timestamp_proto",
"@gogo_special_proto//github.com/gogo/protobuf/gogoproto",
"//proto/common:common_proto",
],
)
5 changes: 3 additions & 2 deletions proto/beacon/p2p/v1/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

402 changes: 204 additions & 198 deletions proto/beacon/p2p/v1/types.pb.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions proto/beacon/p2p/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ message BeaconState {
repeated Crosslink current_crosslinks = 8002 [(gogoproto.moretags) = "ssz-size:\"1024\""];

// Finality [9001-10000]
// Spec type [4]Bitvector which means this would be a fixed size of 1 byte.
bytes justification_bits = 9001 [(gogoproto.moretags) = "ssz-size:\"1\""];
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
bytes justification_bits = 9001 [(gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
Checkpoint previous_justified_checkpoint = 9002;
Checkpoint current_justified_checkpoint = 9003;
Checkpoint finalized_checkpoint = 9004;
Expand All @@ -60,7 +60,7 @@ message Fork {
message PendingAttestation {
// Bitfield representation of validator indices that have voted exactly
// the same vote and have been aggregated into this attestation.
bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"4096\""];
bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"4096\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];
AttestationData data = 2;
// The difference of when attestation gets created and get included on chain.
uint64 inclusion_delay = 3;
Expand All @@ -73,7 +73,7 @@ message Attestation {
// Bitfield representation of validator indices that have voted exactly
// the same vote and have been aggregated into this attestation.
// Spec type: Bitlist[4096]
bytes aggregation_bits = 2 [(gogoproto.moretags) = "ssz-max:\"4096\""];
bytes aggregation_bits = 2 [(gogoproto.moretags) = "ssz-max:\"4096\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];
// Challengeable bit (SSZ-bool, 1 byte) for the custody of crosslink data. Not used in phase 0.
bytes custody_bits = 3 [(gogoproto.moretags) = "ssz-max:\"4096\""];
// 96 byte BLS aggregate signature.
Expand Down Expand Up @@ -211,7 +211,7 @@ message BeaconBlockBody {

message SlashableAttestation {
repeated uint64 validator_indices = 1;
bytes custody_bits = 2 [(gogoproto.moretags) = "ssz-size:\"4096\""];
bytes custody_bits = 2 [(gogoproto.moretags) = "ssz-size:\"4096\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];;
AttestationData data = 3;
bytes signature = 4 [(gogoproto.moretags) = "ssz-size:\"96\""];
}
Expand Down
5 changes: 3 additions & 2 deletions proto/beacon/rpc/v1/services.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion proto/beacon/rpc/v1_gateway/services.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion proto/sharding/p2p/v1/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd8425b

Please sign in to comment.