diff --git a/WORKSPACE b/WORKSPACE index 255dd0b8fc..3b0dbb7f83 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -128,9 +128,8 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "386335fc3b055fad37088bd821929ff684bc00bb1a74e044e4b377ebd6e88fce", - # File names are normally too long, see: https://github.com/ethereum/eth2.0-spec-tests/issues/15 - url = "https://prysmaticlabs.com/uploads/v0.8.3_general_spectests.tar.gz", + sha256 = "5c5b65a961b5e7251435efc9548648b45142a07993ad3e100850c240cb76e9af", + url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.9.0/general.tar.gz", ) http_archive( @@ -145,8 +144,8 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "7ab89a364796e3f8a9af84750c241e9c9e2170a34c1a4e160fdfa2cee5b03fb7", - url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.8.3/minimal.tar.gz", + sha256 = "3b5f0168af4331d09da52bebc26609def9d11be3e6c784ce7c3df3596617808d", + url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.9.0/minimal.tar.gz", ) http_archive( @@ -161,8 +160,8 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "6274e3b77f393faf7b17cef10e93244c16316d3b7ae9c6b844501b12f432a7c3", - url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.8.3/mainnet.tar.gz", + sha256 = "f3ff68508dfe9696f23506daf0ca895cda955e30398741e00cffa33a01b0565c", + url = "https://github.com/ethereum/eth2.0-spec-tests/releases/download/v0.9.0/mainnet.tar.gz", ) http_archive( @@ -1202,7 +1201,7 @@ go_repository( go_repository( name = "com_github_prysmaticlabs_ethereumapis", - commit = "1205871db17ccc2fb824fc6dfa40d01c48fb6a7e", + commit = "c7f1fd03716c94dcc287a0d35905ed35b8a0afe1", importpath = "github.com/prysmaticlabs/ethereumapis", ) @@ -1259,3 +1258,94 @@ go_repository( sum = "h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs=", version = "v0.0.0-20191002040644-a1355ae1e2c3", ) + +go_repository( + name = "com_github_naoina_toml", + importpath = "github.com/naoina/toml", + sum = "h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=", + version = "v0.1.1", +) + +go_repository( + name = "com_github_elastic_gosigar", + importpath = "github.com/elastic/gosigar", + sum = "h1:GzPQ+78RaAb4J63unidA/JavQRKrB6s8IOzN6Ib59jo=", + version = "v0.10.5", +) + +go_repository( + name = "in_gopkg_urfave_cli_v1", + importpath = "gopkg.in/urfave/cli.v1", + sum = "h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=", + version = "v1.20.0", +) + +go_repository( + name = "com_github_naoina_go_stringutil", + importpath = "github.com/naoina/go-stringutil", + sum = "h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=", + version = "v0.1.0", +) + +go_repository( + name = "com_github_influxdata_influxdb", + importpath = "github.com/influxdata/influxdb", + sum = "h1:uSeBTNO4rBkbp1Be5FKRsAmglM9nlx25TzVQRQt1An4=", + version = "v1.7.9", +) + +go_repository( + name = "com_github_robertkrimen_otto", + importpath = "github.com/robertkrimen/otto", + sum = "h1:1VUlQbCfkoSGv7qP7Y+ro3ap1P1pPZxgdGVqiTVy5C4=", + version = "v0.0.0-20180617131154-15f95af6e78d", +) + +go_repository( + name = "com_github_peterh_liner", + importpath = "github.com/peterh/liner", + sum = "h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=", + version = "v1.1.0", +) + +go_repository( + name = "com_github_graph_gophers_graphql_go", + importpath = "github.com/graph-gophers/graphql-go", + sum = "h1:HwRCZlPXN00r58jaIPE11HXn7EvhheQrE+Cxw0vkrH0=", + version = "v0.0.0-20191031232829-adde0d0f76a3", +) + +go_repository( + name = "com_github_rjeczalik_notify", + importpath = "github.com/rjeczalik/notify", + sum = "h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=", + version = "v0.9.2", +) + +go_repository( + name = "com_github_mohae_deepcopy", + importpath = "github.com/mohae/deepcopy", + sum = "h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=", + version = "v0.0.0-20170929034955-c48cc78d4826", +) + +go_repository( + name = "in_gopkg_olebedev_go_duktape_v3", + importpath = "gopkg.in/olebedev/go-duktape.v3", + sum = "h1:uuol9OUzSvZntY1v963NAbVd7A+PHLMz1FlCe3Lorcs=", + version = "v3.0.0-20190709231704-1e4459ed25ff", +) + +go_repository( + name = "in_gopkg_sourcemap_v1", + importpath = "gopkg.in/sourcemap.v1", + sum = "h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=", + version = "v1.0.5", +) + +go_repository( + name = "com_github_fatih_color", + importpath = "github.com/fatih/color", + sum = "h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=", + version = "v1.7.0", +) diff --git a/beacon-chain/archiver/BUILD.bazel b/beacon-chain/archiver/BUILD.bazel index 74c659afa7..5a4335425e 100644 --- a/beacon-chain/archiver/BUILD.bazel +++ b/beacon-chain/archiver/BUILD.bazel @@ -13,6 +13,7 @@ go_library( "//beacon-chain/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index 1feb69b7cb..8761e1a7e0 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -12,6 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" ) @@ -68,27 +69,23 @@ func (s *Service) Status() error { // We archive committee information pertaining to the head state's epoch. func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.BeaconState) error { currentEpoch := helpers.SlotToEpoch(headState.Slot) - committeeCount, err := helpers.CommitteeCount(headState, currentEpoch) + committeeCount, err := helpers.CommitteeCountAtSlot(headState, helpers.StartSlot(currentEpoch)) if err != nil { return errors.Wrap(err, "could not get committee count") } - seed, err := helpers.Seed(headState, currentEpoch) + proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { return errors.Wrap(err, "could not generate seed") } - startShard, err := helpers.StartShard(headState, currentEpoch) + attesterSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { - return errors.Wrap(err, "could not get start shard") - } - proposerIndex, err := helpers.BeaconProposerIndex(headState) - if err != nil { - return errors.Wrap(err, "could not get beacon proposer index") + return errors.Wrap(err, "could not generate seed") } + info := ðpb.ArchivedCommitteeInfo{ - Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, - ProposerIndex: proposerIndex, + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, } if err := s.beaconDB.SaveArchivedCommitteeInfo(ctx, currentEpoch, info); err != nil { return errors.Wrap(err, "could not archive committee info") diff --git a/beacon-chain/archiver/service_test.go b/beacon-chain/archiver/service_test.go index 23cbc5ab09..66f5080e32 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -128,27 +128,22 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { triggerNewHeadEvent(t, svc, [32]byte{}) currentEpoch := helpers.CurrentEpoch(headState) - startShard, err := helpers.StartShard(headState, currentEpoch) + committeeCount, err := helpers.CommitteeCountAtSlot(headState, helpers.StartSlot(currentEpoch)) if err != nil { t.Fatal(err) } - committeeCount, err := helpers.CommitteeCount(headState, currentEpoch) + proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(headState, currentEpoch) - if err != nil { - t.Fatal(err) - } - propIdx, err := helpers.BeaconProposerIndex(headState) + attesterSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } wanted := ðpb.ArchivedCommitteeInfo{ - Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, - ProposerIndex: propIdx, + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, } retrieved, err := svc.beaconDB.ArchivedCommitteeInfo(svc.ctx, helpers.CurrentEpoch(headState)) @@ -251,14 +246,7 @@ func setupState(t *testing.T, validatorCount uint64) *pb.BeaconState { balances[i] = params.BeaconConfig().MaxEffectiveBalance } - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 0}, Target: ðpb.Checkpoint{}}}} - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } + atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} // We initialize a head state that has attestations from participated // validators in a simulated fashion. @@ -269,9 +257,6 @@ func setupState(t *testing.T, validatorCount uint64) *pb.BeaconState { BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, diff --git a/beacon-chain/blockchain/forkchoice/process_attestation.go b/beacon-chain/blockchain/forkchoice/process_attestation.go index 9f6c477cda..f594e326e2 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation.go @@ -89,7 +89,7 @@ func (s *Store) OnAttestation(ctx context.Context, a *ethpb.Attestation) (uint64 } // Verify attestations can only affect the fork choice of subsequent slots. - if err := s.verifyAttSlotTime(ctx, baseState, a.Data); err != nil { + if err := helpers.VerifySlotTime(baseState.GenesisTime, a.Data.Slot+1); err != nil { return 0, err } @@ -185,12 +185,7 @@ func (s *Store) waitForAttInclDelay(ctx context.Context, a *ethpb.Attestation, t ctx, span := trace.StartSpan(ctx, "beacon-chain.forkchoice.waitForAttInclDelay") defer span.End() - slot, err := helpers.AttestationDataSlot(targetState, a.Data) - if err != nil { - return errors.Wrap(err, "could not get attestation slot") - } - - nextSlot := slot + 1 + nextSlot := a.Data.Slot + 1 duration := time.Duration(nextSlot*params.BeaconConfig().SecondsPerSlot) * time.Second timeToInclude := time.Unix(int64(targetState.GenesisTime), 0).Add(duration) @@ -210,7 +205,6 @@ func (s *Store) aggregateAttestation(ctx context.Context, att *ethpb.Attestation if err != nil { return err } - if a, ok := s.attsQueue[root]; ok { a, err := helpers.AggregateAttestation(a, att) if err != nil { @@ -223,15 +217,6 @@ func (s *Store) aggregateAttestation(ctx context.Context, att *ethpb.Attestation return nil } -// verifyAttSlotTime validates input attestation is not from the future. -func (s *Store) verifyAttSlotTime(ctx context.Context, baseState *pb.BeaconState, d *ethpb.AttestationData) error { - aSlot, err := helpers.AttestationDataSlot(baseState, d) - if err != nil { - return errors.Wrap(err, "could not get attestation slot") - } - return helpers.VerifySlotTime(baseState.GenesisTime, aSlot+1) -} - // verifyAttestation validates input attestation is valid. func (s *Store) verifyAttestation(ctx context.Context, baseState *pb.BeaconState, a *ethpb.Attestation) (*ethpb.IndexedAttestation, error) { indexedAtt, err := blocks.ConvertToIndexed(ctx, baseState, a) diff --git a/beacon-chain/blockchain/forkchoice/process_attestation_test.go b/beacon-chain/blockchain/forkchoice/process_attestation_test.go index a4fc02c5f9..b5208e127c 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation_test.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation_test.go @@ -55,8 +55,7 @@ func TestStore_OnAttestation(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }, BlkWithValidStateRoot); err != nil { t.Fatal(err) } @@ -118,30 +117,19 @@ func TestStore_SaveCheckpointState(t *testing.T) { store := NewForkChoiceService(ctx, db) - crosslinks := make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount) - for i := 0; i < len(crosslinks); i++ { - crosslinks[i] = ðpb.Crosslink{ - ParentRoot: make([]byte, 32), - DataRoot: make([]byte, 32), - } - } s := &pb.BeaconState{ Fork: &pb.Fork{ Epoch: 0, CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - StateRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - LatestBlockHeader: ðpb.BeaconBlockHeader{}, - JustificationBits: []byte{0}, - CurrentJustifiedCheckpoint: ðpb.Checkpoint{}, - CurrentCrosslinks: crosslinks, - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - FinalizedCheckpoint: ðpb.Checkpoint{}, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + StateRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), + LatestBlockHeader: ðpb.BeaconBlockHeader{}, + JustificationBits: []byte{0}, + Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), + FinalizedCheckpoint: ðpb.Checkpoint{}, } if err := store.GenesisStore(ctx, ðpb.Checkpoint{}, ðpb.Checkpoint{}); err != nil { t.Fatal(err) @@ -210,7 +198,7 @@ func TestStore_AggregateAttestation(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, } - domain := helpers.Domain(f, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(f, 0, params.BeaconConfig().DomainBeaconAttester) sig := privKeys[0].Sign([]byte{}, domain) store := &Store{attsQueue: make(map[[32]byte]*ethpb.Attestation)} diff --git a/beacon-chain/blockchain/forkchoice/process_block.go b/beacon-chain/blockchain/forkchoice/process_block.go index c4fda088de..ae10cf49a9 100644 --- a/beacon-chain/blockchain/forkchoice/process_block.go +++ b/beacon-chain/blockchain/forkchoice/process_block.go @@ -73,7 +73,6 @@ func (s *Store) OnBlock(ctx context.Context, b *ethpb.BeaconBlock) error { "slot": b.Slot, "root": fmt.Sprintf("0x%s...", hex.EncodeToString(root[:])[:8]), }).Info("Executing state transition on block") - postState, err := state.ExecuteStateTransition(ctx, preState, b) if err != nil { return errors.Wrap(err, "could not execute state transition") @@ -215,6 +214,13 @@ func (s *Store) OnBlockNoVerifyStateTransition(ctx context.Context, b *ethpb.Bea // Epoch boundary bookkeeping such as logging epoch summaries. if helpers.IsEpochStart(postState.Slot) { reportEpochMetrics(postState) + + // Update committee shuffled indices at the end of every epoch + if featureconfig.Get().EnableNewCache { + if err := helpers.UpdateCommitteeCache(postState); err != nil { + return err + } + } } return nil @@ -281,6 +287,9 @@ func (s *Store) updateBlockAttestationVote(ctx context.Context, att *ethpb.Attes if err != nil { return errors.Wrap(err, "could not get state for attestation tgt root") } + if baseState == nil { + return errors.New("no state found in db with attestation tgt root") + } indexedAtt, err := blocks.ConvertToIndexed(ctx, baseState, att) if err != nil { return errors.Wrap(err, "could not convert attestation to indexed attestation") diff --git a/beacon-chain/blockchain/forkchoice/process_block_test.go b/beacon-chain/blockchain/forkchoice/process_block_test.go index a67d339b6c..38f1fe1242 100644 --- a/beacon-chain/blockchain/forkchoice/process_block_test.go +++ b/beacon-chain/blockchain/forkchoice/process_block_test.go @@ -133,7 +133,7 @@ func TestStore_UpdateBlockAttestationVote(t *testing.T) { params.UseMinimalConfig() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -144,10 +144,6 @@ func TestStore_UpdateBlockAttestationVote(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: params.BeaconConfig().ZeroHash[:]}, Target: ðpb.Checkpoint{Epoch: 0, Root: r[:]}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: []byte{255}, CustodyBits: []byte{255}, @@ -187,7 +183,7 @@ func TestStore_UpdateBlockAttestationsVote(t *testing.T) { params.UseMinimalConfig() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -201,10 +197,6 @@ func TestStore_UpdateBlockAttestationsVote(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: params.BeaconConfig().ZeroHash[:]}, Target: ðpb.Checkpoint{Epoch: 0, Root: r[:]}, - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - StartEpoch: 0, - }, }, AggregationBits: []byte{255}, CustodyBits: []byte{255}, diff --git a/beacon-chain/blockchain/receive_attestation_test.go b/beacon-chain/blockchain/receive_attestation_test.go index d6c96cd963..7b7fe22468 100644 --- a/beacon-chain/blockchain/receive_attestation_test.go +++ b/beacon-chain/blockchain/receive_attestation_test.go @@ -35,8 +35,7 @@ func TestReceiveAttestation_ProcessCorrectly(t *testing.T) { } a := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Root: root[:]}, - Crosslink: ðpb.Crosslink{}, + Target: ðpb.Checkpoint{Root: root[:]}, }} if err := chainService.ReceiveAttestation(ctx, a); err != nil { t.Fatal(err) @@ -70,8 +69,7 @@ func TestReceiveAttestation_SameHead(t *testing.T) { } a := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Root: root[:]}, - Crosslink: ðpb.Crosslink{}, + Target: ðpb.Checkpoint{Root: root[:]}, }} if err := chainService.ReceiveAttestation(ctx, a); err != nil { t.Fatal(err) @@ -104,8 +102,7 @@ func TestReceiveAttestationNoPubsub_ProcessCorrectly(t *testing.T) { } a := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Root: root[:]}, - Crosslink: ðpb.Crosslink{}, + Target: ðpb.Checkpoint{Root: root[:]}, }} if err := chainService.ReceiveAttestationNoPubsub(ctx, a); err != nil { t.Fatal(err) diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 3fdfa12bfa..3af34bac89 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -5,6 +5,7 @@ import ( "context" "encoding/hex" + "github.com/gogo/protobuf/proto" "github.com/pkg/errors" "github.com/prysmaticlabs/go-ssz" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" @@ -61,14 +62,15 @@ func (s *Service) ReceiveBlock(ctx context.Context, block *ethpb.BeaconBlock) er func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconBlock) error { ctx, span := trace.StartSpan(ctx, "beacon-chain.blockchain.ReceiveBlockNoPubsub") defer span.End() + blockCopy := proto.Clone(block).(*ethpb.BeaconBlock) // Apply state transition on the new block. - if err := s.forkChoiceStore.OnBlock(ctx, block); err != nil { + if err := s.forkChoiceStore.OnBlock(ctx, blockCopy); err != nil { err := errors.Wrap(err, "could not process block from fork choice service") traceutil.AnnotateError(span, err) return err } - root, err := ssz.SigningRoot(block) + root, err := ssz.SigningRoot(blockCopy) if err != nil { return errors.Wrap(err, "could not get signing root on received block") } @@ -91,18 +93,18 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconB } // Remove block's contained deposits, attestations, and other operations from persistent storage. - if err := s.cleanupBlockOperations(ctx, block); err != nil { + if err := s.cleanupBlockOperations(ctx, blockCopy); err != nil { return errors.Wrap(err, "could not clean up block deposits, attestations, and other operations") } // Reports on block and fork choice metrics. - s.reportSlotMetrics(block.Slot) + s.reportSlotMetrics(blockCopy.Slot) // Log if block is a competing block. - isCompetingBlock(root[:], block.Slot, headRoot, headBlk.Slot) + isCompetingBlock(root[:], blockCopy.Slot, headRoot, headBlk.Slot) // Log state transition data. - logStateTransitionData(block, root[:]) + logStateTransitionData(blockCopy, root[:]) processedBlkNoPubsub.Inc() @@ -118,34 +120,35 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconB func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.BeaconBlock) error { ctx, span := trace.StartSpan(ctx, "beacon-chain.blockchain.ReceiveBlockNoForkchoice") defer span.End() + blockCopy := proto.Clone(block).(*ethpb.BeaconBlock) // Apply state transition on the incoming newly received block. - if err := s.forkChoiceStore.OnBlock(ctx, block); err != nil { + if err := s.forkChoiceStore.OnBlock(ctx, blockCopy); err != nil { err := errors.Wrap(err, "could not process block from fork choice service") traceutil.AnnotateError(span, err) return err } - root, err := ssz.SigningRoot(block) + root, err := ssz.SigningRoot(blockCopy) if err != nil { return errors.Wrap(err, "could not get signing root on received block") } if !bytes.Equal(root[:], s.HeadRoot()) { - if err := s.saveHead(ctx, block, root); err != nil { + if err := s.saveHead(ctx, blockCopy, root); err != nil { return errors.Wrap(err, "could not save head") } } // Remove block's contained deposits, attestations, and other operations from persistent storage. - if err := s.cleanupBlockOperations(ctx, block); err != nil { + if err := s.cleanupBlockOperations(ctx, blockCopy); err != nil { return errors.Wrap(err, "could not clean up block deposits, attestations, and other operations") } // Reports on block and fork choice metrics. - s.reportSlotMetrics(block.Slot) + s.reportSlotMetrics(blockCopy.Slot) // Log state transition data. - logStateTransitionData(block, root[:]) + logStateTransitionData(blockCopy, root[:]) // We write the latest saved head root to a feed for consumption by other services. s.headUpdatedFeed.Send(root) @@ -159,32 +162,33 @@ func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *eth func (s *Service) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.BeaconBlock) error { ctx, span := trace.StartSpan(ctx, "beacon-chain.blockchain.ReceiveBlockNoVerify") defer span.End() + blockCopy := proto.Clone(block).(*ethpb.BeaconBlock) - // Apply state transition on the incoming newly received block without verifying its BLS contents. - if err := s.forkChoiceStore.OnBlockNoVerifyStateTransition(ctx, block); err != nil { - return errors.Wrap(err, "could not process block from fork choice service") + // Apply state transition on the incoming newly received blockCopy without verifying its BLS contents. + if err := s.forkChoiceStore.OnBlockNoVerifyStateTransition(ctx, blockCopy); err != nil { + return errors.Wrap(err, "could not process blockCopy from fork choice service") } - root, err := ssz.SigningRoot(block) + root, err := ssz.SigningRoot(blockCopy) if err != nil { - return errors.Wrap(err, "could not get signing root on received block") + return errors.Wrap(err, "could not get signing root on received blockCopy") } if !bytes.Equal(root[:], s.HeadRoot()) { - if err := s.saveHead(ctx, block, root); err != nil { + if err := s.saveHead(ctx, blockCopy, root); err != nil { err := errors.Wrap(err, "could not save head") traceutil.AnnotateError(span, err) return err } } - // Reports on block and fork choice metrics. - s.reportSlotMetrics(block.Slot) + // Reports on blockCopy and fork choice metrics. + s.reportSlotMetrics(blockCopy.Slot) // Log state transition data. log.WithFields(logrus.Fields{ - "slot": block.Slot, - "attestations": len(block.Body.Attestations), - "deposits": len(block.Body.Deposits), + "slot": blockCopy.Slot, + "attestations": len(blockCopy.Body.Attestations), + "deposits": len(blockCopy.Body.Deposits), }).Debug("Finished applying state transition") // We write the latest saved head root to a feed for consumption by other services. diff --git a/beacon-chain/blockchain/receive_block_test.go b/beacon-chain/blockchain/receive_block_test.go index 27544c09ba..03201981a5 100644 --- a/beacon-chain/blockchain/receive_block_test.go +++ b/beacon-chain/blockchain/receive_block_test.go @@ -24,16 +24,16 @@ func TestReceiveBlock_ProcessCorrectly(t *testing.T) { chainService := setupBeaconChain(t, db) deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } + beaconState.Eth1Data.BlockHash = nil beaconState.Eth1DepositIndex = 100 stateRoot, err := ssz.HashTreeRoot(beaconState) if err != nil { t.Fatal(err) } - genesis := b.NewGenesisBlock(stateRoot[:]) bodyRoot, err := ssz.HashTreeRoot(genesis.Body) if err != nil { @@ -188,7 +188,7 @@ func TestReceiveBlockNoPubsubForkchoice_ProcessCorrectly(t *testing.T) { chainService := setupBeaconChain(t, db) deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/cache/BUILD.bazel b/beacon-chain/cache/BUILD.bazel index 4c33da840c..1ec8954ba2 100644 --- a/beacon-chain/cache/BUILD.bazel +++ b/beacon-chain/cache/BUILD.bazel @@ -10,7 +10,6 @@ go_library( "committee.go", "common.go", "eth1_data.go", - "shuffled_indices.go", ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/cache", visibility = ["//beacon-chain:__subpackages__"], @@ -41,7 +40,6 @@ go_test( "committee_test.go", "eth1_data_test.go", "feature_flag_test.go", - "shuffled_indices_test.go", ], embed = [":go_default_library"], race = "on", diff --git a/beacon-chain/cache/attestation_data.go b/beacon-chain/cache/attestation_data.go index 5529c3f631..8b20295b31 100644 --- a/beacon-chain/cache/attestation_data.go +++ b/beacon-chain/cache/attestation_data.go @@ -181,7 +181,7 @@ func wrapperToKey(i interface{}) (string, error) { } func reqToKey(req *pb.AttestationRequest) (string, error) { - return fmt.Sprintf("%d-%d", req.Shard, req.Slot), nil + return fmt.Sprintf("%d-%d", req.CommitteeIndex, req.Slot), nil } type attestationReqResWrapper struct { diff --git a/beacon-chain/cache/attestation_data_test.go b/beacon-chain/cache/attestation_data_test.go index c17e3eb017..ad6d84034b 100644 --- a/beacon-chain/cache/attestation_data_test.go +++ b/beacon-chain/cache/attestation_data_test.go @@ -15,8 +15,8 @@ func TestAttestationCache_RoundTrip(t *testing.T) { c := cache.NewAttestationCache() req := &pb.AttestationRequest{ - Shard: 0, - Slot: 1, + CommitteeIndex: 0, + Slot: 1, } response, err := c.Get(ctx, req) diff --git a/beacon-chain/cache/committee.go b/beacon-chain/cache/committee.go index ed17b81c61..4339fbcc70 100644 --- a/beacon-chain/cache/committee.go +++ b/beacon-chain/cache/committee.go @@ -34,15 +34,14 @@ var ( }) ) -// Committee defines the committee per epoch and shard. +// Committee defines the committee per epoch and index. type Committee struct { - StartShard uint64 CommitteeCount uint64 Epoch uint64 Committee []uint64 } -// CommitteeCache is a struct with 1 queue for looking up shuffled indices list by epoch and shard. +// CommitteeCache is a struct with 1 queue for looking up shuffled indices list by epoch and committee index. type CommitteeCache struct { CommitteeCache *cache.FIFO lock sync.RWMutex @@ -65,15 +64,17 @@ func NewCommitteeCache() *CommitteeCache { } } -// ShuffledIndices fetches the shuffled indices by epoch and shard. Every list of indices -// represent one committee. Returns true if the list exists with epoch and shard. Otherwise returns false, nil. -func (c *CommitteeCache) ShuffledIndices(epoch uint64, shard uint64) ([]uint64, error) { +// ShuffledIndices fetches the shuffled indices by slot and committee index. Every list of indices +// represent one committee. Returns true if the list exists with slot and committee index. Otherwise returns false, nil. +func (c *CommitteeCache) ShuffledIndices(slot uint64, index uint64) ([]uint64, error) { if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { return nil, nil } c.lock.RLock() defer c.lock.RUnlock() - obj, exists, err := c.CommitteeCache.GetByKey(strconv.Itoa(int(epoch))) + + epoch := int(slot / params.BeaconConfig().SlotsPerEpoch) + obj, exists, err := c.CommitteeCache.GetByKey(strconv.Itoa(epoch)) if err != nil { return nil, err } @@ -90,8 +91,13 @@ func (c *CommitteeCache) ShuffledIndices(epoch uint64, shard uint64) ([]uint64, return nil, ErrNotCommittee } - start, end := startEndIndices(item, shard) + committeeCountPerSlot := uint64(1) + if item.CommitteeCount/params.BeaconConfig().SlotsPerEpoch > 1 { + committeeCountPerSlot = item.CommitteeCount / params.BeaconConfig().SlotsPerEpoch + } + indexOffSet := index + (slot%params.BeaconConfig().SlotsPerEpoch)*committeeCountPerSlot + start, end := startEndIndices(item, indexOffSet) return item.Committee[start:end], nil } @@ -149,13 +155,14 @@ func (c *CommitteeCache) EpochInCache(wantedEpoch uint64) (bool, error) { return false, nil } -// CommitteeCount returns the total number of committees in a given epoch as stored in cache. -func (c *CommitteeCache) CommitteeCount(epoch uint64) (uint64, bool, error) { +// CommitteeCountPerSlot returns the number of committees in a given slot as stored in cache. +func (c *CommitteeCache) CommitteeCountPerSlot(slot uint64) (uint64, bool, error) { if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { return 0, false, nil } c.lock.RLock() defer c.lock.RUnlock() + epoch := int(slot / params.BeaconConfig().SlotsPerEpoch) obj, exists, err := c.CommitteeCache.GetByKey(strconv.Itoa(int(epoch))) if err != nil { return 0, false, err @@ -173,34 +180,7 @@ func (c *CommitteeCache) CommitteeCount(epoch uint64) (uint64, bool, error) { return 0, false, ErrNotCommittee } - return item.CommitteeCount, true, nil -} - -// StartShard returns the start shard number in a given epoch as stored in cache. -func (c *CommitteeCache) StartShard(epoch uint64) (uint64, bool, error) { - if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { - return 0, false, nil - } - c.lock.RLock() - defer c.lock.RUnlock() - obj, exists, err := c.CommitteeCache.GetByKey(strconv.Itoa(int(epoch))) - if err != nil { - return 0, false, err - } - - if exists { - CommitteeCacheHit.Inc() - } else { - CommitteeCacheMiss.Inc() - return 0, false, nil - } - - item, ok := obj.(*Committee) - if !ok { - return 0, false, ErrNotCommittee - } - - return item.StartShard, true, nil + return item.CommitteeCount / params.BeaconConfig().SlotsPerEpoch, true, nil } // ActiveIndices returns the active indices of a given epoch stored in cache. @@ -231,12 +211,10 @@ func (c *CommitteeCache) ActiveIndices(epoch uint64) ([]uint64, error) { return item.Committee, nil } -func startEndIndices(c *Committee, wantedShard uint64) (uint64, uint64) { - shardCount := params.BeaconConfig().ShardCount - currentShard := (wantedShard + shardCount - c.StartShard) % shardCount +func startEndIndices(c *Committee, index uint64) (uint64, uint64) { validatorCount := uint64(len(c.Committee)) - start := sliceutil.SplitOffset(validatorCount, c.CommitteeCount, currentShard) - end := sliceutil.SplitOffset(validatorCount, c.CommitteeCount, currentShard+1) + start := sliceutil.SplitOffset(validatorCount, c.CommitteeCount, index) + end := sliceutil.SplitOffset(validatorCount, c.CommitteeCount, index+1) return start, end } diff --git a/beacon-chain/cache/committee_test.go b/beacon-chain/cache/committee_test.go index 0f9778f81b..2bdbfee69c 100644 --- a/beacon-chain/cache/committee_test.go +++ b/beacon-chain/cache/committee_test.go @@ -4,6 +4,8 @@ import ( "reflect" "strconv" "testing" + + "github.com/prysmaticlabs/prysm/shared/params" ) func TestCommitteeKeyFn_OK(t *testing.T) { @@ -36,12 +38,11 @@ func TestCommitteeCache_CommitteesByEpoch(t *testing.T) { Epoch: 1, Committee: []uint64{1, 2, 3, 4, 5, 6}, CommitteeCount: 3, - StartShard: 1, } - epoch := uint64(1) - startShard := uint64(1) - indices, err := cache.ShuffledIndices(epoch, startShard) + slot := uint64(item.Epoch * params.BeaconConfig().SlotsPerEpoch) + committeeIndex := uint64(1) + indices, err := cache.ShuffledIndices(slot, committeeIndex) if err != nil { t.Fatal(err) } @@ -52,12 +53,13 @@ func TestCommitteeCache_CommitteesByEpoch(t *testing.T) { if err := cache.AddCommitteeShuffledList(item); err != nil { t.Fatal(err) } - wantedShard := uint64(2) - indices, err = cache.ShuffledIndices(epoch, wantedShard) + wantedIndex := uint64(0) + indices, err = cache.ShuffledIndices(slot, wantedIndex) if err != nil { t.Fatal(err) } - start, end := startEndIndices(item, wantedShard) + + start, end := startEndIndices(item, wantedIndex) if !reflect.DeepEqual(indices, item.Committee[start:end]) { t.Errorf( "Expected fetched active indices to be %v, got %v", @@ -143,68 +145,6 @@ func TestCommitteeCache_EpochInCache(t *testing.T) { } } -func TestCommitteeCache_CommitteesCount(t *testing.T) { - cache := NewCommitteeCache() - - committeeCount := uint64(3) - epoch := uint64(10) - item := &Committee{Epoch: epoch, CommitteeCount: committeeCount} - - _, exists, err := cache.CommitteeCount(1) - if err != nil { - t.Fatal(err) - } - if exists { - t.Error("Expected committee count not to exist in empty cache") - } - - if err := cache.AddCommitteeShuffledList(item); err != nil { - t.Fatal(err) - } - - count, exists, err := cache.CommitteeCount(epoch) - if err != nil { - t.Fatal(err) - } - if !exists { - t.Error("Expected committee count to be in cache") - } - if count != committeeCount { - t.Errorf("wanted: %d, got: %d", committeeCount, count) - } -} - -func TestCommitteeCache_ShardCount(t *testing.T) { - cache := NewCommitteeCache() - - startShard := uint64(7) - epoch := uint64(3) - item := &Committee{Epoch: epoch, StartShard: startShard} - - _, exists, err := cache.StartShard(1) - if err != nil { - t.Fatal(err) - } - if exists { - t.Error("Expected start shard not to exist in empty cache") - } - - if err := cache.AddCommitteeShuffledList(item); err != nil { - t.Fatal(err) - } - - shard, exists, err := cache.StartShard(epoch) - if err != nil { - t.Fatal(err) - } - if !exists { - t.Error("Expected start shard to be in cache") - } - if shard != startShard { - t.Errorf("wanted: %d, got: %d", startShard, shard) - } -} - func TestCommitteeCache_ActiveIndices(t *testing.T) { cache := NewCommitteeCache() diff --git a/beacon-chain/cache/shuffled_indices.go b/beacon-chain/cache/shuffled_indices.go deleted file mode 100644 index 7fb531458e..0000000000 --- a/beacon-chain/cache/shuffled_indices.go +++ /dev/null @@ -1,106 +0,0 @@ -package cache - -import ( - "errors" - "strconv" - "sync" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" - "github.com/prysmaticlabs/prysm/shared/featureconfig" - "k8s.io/client-go/tools/cache" -) - -var ( - // ErrNotValidatorListInfo will be returned when a cache object is not a pointer to - // a ValidatorList struct. - ErrNotValidatorListInfo = errors.New("object is not a shuffled validator list") - - // maxShuffledListSize defines the max number of shuffled list can cache. - maxShuffledListSize = 1000 - - // Metrics. - shuffledIndicesCacheMiss = promauto.NewCounter(prometheus.CounterOpts{ - Name: "shuffled_validators_cache_miss", - Help: "The number of shuffled validators requests that aren't present in the cache.", - }) - shuffledIndicesCacheHit = promauto.NewCounter(prometheus.CounterOpts{ - Name: "shuffled_validators_cache_hit", - Help: "The number of shuffled validators requests that are present in the cache.", - }) -) - -// IndicesByIndexSeed defines the shuffled validator indices per randao seed. -type IndicesByIndexSeed struct { - Index uint64 - Seed []byte - ShuffledIndices []uint64 -} - -// ShuffledIndicesCache is a struct with 1 queue for looking up shuffled validators by seed. -type ShuffledIndicesCache struct { - shuffledIndicesCache *cache.FIFO - lock sync.RWMutex -} - -// slotKeyFn takes the randao seed as the key for the shuffled validators of a given epoch. -func shuffleKeyFn(obj interface{}) (string, error) { - sInfo, ok := obj.(*IndicesByIndexSeed) - if !ok { - return "", ErrNotValidatorListInfo - } - - return string(sInfo.Seed) + strconv.Itoa(int(sInfo.Index)), nil -} - -// NewShuffledIndicesCache creates a new shuffled validators cache for storing/accessing shuffled validator indices -func NewShuffledIndicesCache() *ShuffledIndicesCache { - return &ShuffledIndicesCache{ - shuffledIndicesCache: cache.NewFIFO(shuffleKeyFn), - } -} - -// IndicesByIndexSeed fetches IndicesByIndexSeed by epoch and seed. Returns true with a -// reference to the ShuffledIndicesInEpoch info, if exists. Otherwise returns false, nil. -func (c *ShuffledIndicesCache) IndicesByIndexSeed(index uint64, seed []byte) ([]uint64, error) { - if !featureconfig.Get().EnableShuffledIndexCache { - return nil, nil - } - c.lock.RLock() - defer c.lock.RUnlock() - key := string(seed) + strconv.Itoa(int(index)) - obj, exists, err := c.shuffledIndicesCache.GetByKey(key) - if err != nil { - return nil, err - } - - if exists { - shuffledIndicesCacheHit.Inc() - } else { - shuffledIndicesCacheMiss.Inc() - return nil, nil - } - - cInfo, ok := obj.(*IndicesByIndexSeed) - if !ok { - return nil, ErrNotValidatorListInfo - } - - return cInfo.ShuffledIndices, nil -} - -// AddShuffledValidatorList adds IndicesByIndexSeed object to the cache. This method also trims the least -// recently added IndicesByIndexSeed object if the cache size has ready the max cache size limit. -func (c *ShuffledIndicesCache) AddShuffledValidatorList(shuffledIndices *IndicesByIndexSeed) error { - if !featureconfig.Get().EnableShuffledIndexCache { - return nil - } - c.lock.Lock() - defer c.lock.Unlock() - if err := c.shuffledIndicesCache.AddIfNotPresent(shuffledIndices); err != nil { - return err - } - - trim(c.shuffledIndicesCache, maxShuffledListSize) - return nil -} diff --git a/beacon-chain/cache/shuffled_indices_test.go b/beacon-chain/cache/shuffled_indices_test.go deleted file mode 100644 index da2b6fe720..0000000000 --- a/beacon-chain/cache/shuffled_indices_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package cache - -import ( - "reflect" - "strconv" - "testing" - - "github.com/prysmaticlabs/prysm/shared/featureconfig" -) - -func init() { - fc := featureconfig.Get() - fc.EnableShuffledIndexCache = true - featureconfig.Init(fc) -} - -func TestShuffleKeyFn_OK(t *testing.T) { - sInfo := &IndicesByIndexSeed{ - Index: 999, - Seed: []byte{'A'}, - ShuffledIndices: []uint64{1, 2, 3, 4, 5}, - } - - key, err := shuffleKeyFn(sInfo) - if err != nil { - t.Fatal(err) - } - if key != string(sInfo.Seed)+strconv.Itoa(int(sInfo.Index)) { - t.Errorf("Incorrect hash key: %s, expected %s", key, string(sInfo.Seed)+strconv.Itoa(int(sInfo.Index))) - } -} - -func TestShuffleKeyFn_InvalidObj(t *testing.T) { - _, err := shuffleKeyFn("bad") - if err != ErrNotValidatorListInfo { - t.Errorf("Expected error %v, got %v", ErrNotValidatorListInfo, err) - } -} - -func TestShuffledIndicesCache_ShuffledIndicesBySeed2(t *testing.T) { - cache := NewShuffledIndicesCache() - - sInfo := &IndicesByIndexSeed{ - Index: 99, - Seed: []byte{'A'}, - ShuffledIndices: []uint64{1, 2, 3, 4}, - } - - shuffledIndices, err := cache.IndicesByIndexSeed(sInfo.Index, sInfo.Seed) - if err != nil { - t.Fatal(err) - } - if shuffledIndices != nil { - t.Error("Expected shuffled indices not to exist in empty cache") - } - - if err := cache.AddShuffledValidatorList(sInfo); err != nil { - t.Fatal(err) - } - shuffledIndices, err = cache.IndicesByIndexSeed(sInfo.Index, sInfo.Seed) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(shuffledIndices, sInfo.ShuffledIndices) { - t.Errorf( - "Expected fetched info committee to be %v, got %v", - sInfo.ShuffledIndices, - shuffledIndices, - ) - } -} - -func TestShuffledIndices_MaxSize(t *testing.T) { - cache := NewShuffledIndicesCache() - - for i := uint64(0); i < 1001; i++ { - sInfo := &IndicesByIndexSeed{ - Index: i, - Seed: []byte{byte(i)}, - } - if err := cache.AddShuffledValidatorList(sInfo); err != nil { - t.Fatal(err) - } - } - - if len(cache.shuffledIndicesCache.ListKeys()) != maxShuffledListSize { - t.Errorf( - "Expected hash cache key size to be %d, got %d", - maxShuffledListSize, - len(cache.shuffledIndicesCache.ListKeys()), - ) - } -} diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 7c5fbb1025..fa7594cea0 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -50,7 +50,6 @@ go_test( "//proto/eth/v1alpha1:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/hashutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/trieutil:go_default_library", diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index 5f7dbe5b31..ab05a6741c 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -161,7 +161,7 @@ func ProcessBlockHeader( ) (*pb.BeaconState, error) { beaconState, err := ProcessBlockHeaderNoVerify(beaconState, block) if err != nil { - return nil, errors.Wrap(err, "could not process block header") + return nil, err } idx, err := helpers.BeaconProposerIndex(beaconState) @@ -320,8 +320,8 @@ func ProcessRandaoNoVerify( // Process ``ProposerSlashing`` operation. // """ // proposer = state.validator_registry[proposer_slashing.proposer_index] -// # Verify that the epoch is the same -// assert slot_to_epoch(proposer_slashing.header_1.slot) == slot_to_epoch(proposer_slashing.header_2.slot) +// # Verify slots match +// assert proposer_slashing.header_1.slot == proposer_slashing.header_2.slot // # But the headers are different // assert proposer_slashing.header_1 != proposer_slashing.header_2 // # Check proposer is slashable @@ -356,12 +356,10 @@ func VerifyProposerSlashing( beaconState *pb.BeaconState, slashing *ethpb.ProposerSlashing, ) error { - headerEpoch1 := helpers.SlotToEpoch(slashing.Header_1.Slot) - headerEpoch2 := helpers.SlotToEpoch(slashing.Header_2.Slot) proposer := beaconState.Validators[slashing.ProposerIndex] - if headerEpoch1 != headerEpoch2 { - return fmt.Errorf("mismatched header epochs, received %d == %d", headerEpoch1, headerEpoch2) + if slashing.Header_1.Slot != slashing.Header_2.Slot { + return fmt.Errorf("mismatched header slots, received %d == %d", slashing.Header_1.Slot, slashing.Header_2.Slot) } if proto.Equal(slashing.Header_1, slashing.Header_2) { return errors.New("expected slashing headers to differ") @@ -370,7 +368,7 @@ func VerifyProposerSlashing( return fmt.Errorf("validator with key %#x is not slashable", proposer.PublicKey) } // Using headerEpoch1 here because both of the headers should have the same epoch. - domain := helpers.Domain(beaconState.Fork, headerEpoch1, params.BeaconConfig().DomainBeaconProposer) + domain := helpers.Domain(beaconState.Fork, helpers.StartSlot(slashing.Header_1.Slot), params.BeaconConfig().DomainBeaconProposer) headers := append([]*ethpb.BeaconBlockHeader{slashing.Header_1}, slashing.Header_2) for _, header := range headers { if err := verifySigningRoot(header, proposer.PublicKey, header.Signature, domain); err != nil { @@ -508,40 +506,27 @@ func ProcessAttestationsNoVerify(ctx context.Context, beaconState *pb.BeaconStat // // Spec pseudocode definition: // def process_attestation(state: BeaconState, attestation: Attestation) -> None: -// """ -// Process ``Attestation`` operation. -// """ // data = attestation.data -// assert data.crosslink.shard < SHARD_COUNT +// assert data.index < get_committee_count_at_slot(state, data.slot) // assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state)) +// assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot <= data.slot + SLOTS_PER_EPOCH // -// attestation_slot = get_attestation_data_slot(state, data) -// assert attestation_slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot <= attestation_slot + SLOTS_PER_EPOCH -// -// committee = get_crosslink_committee(state, data.target.epoch, data.crosslink.shard) +// committee = get_beacon_committee(state, data.slot, data.index) // assert len(attestation.aggregation_bits) == len(attestation.custody_bits) == len(committee) // // pending_attestation = PendingAttestation( // data=data, -// aggregation_bitfield=attestation.aggregation_bitfield, -// inclusion_delay=state.slot - attestation_slot, +// aggregation_bits=attestation.aggregation_bits, +// inclusion_delay=state.slot - data.slot, // proposer_index=get_beacon_proposer_index(state), // ) // -// if data.target_epoch == get_current_epoch(state): -// assert data.source == state.current_justified_checkpoint -// parent_crosslink = state.current_crosslinks[data.crosslink.shard] -// state.current_epoch_attestations.append(pending_attestation) +// if data.target.epoch == get_current_epoch(state): +// assert data.source == state.current_justified_checkpoint +// state.current_epoch_attestations.append(pending_attestation) // else: -// assert data.source == state.previous_justified_checkpoint -// parent_crosslink = state.previous_crosslinks[data.crosslink.shard] -// state.previous_epoch_attestations.append(pending_attestation) -// -// # Check crosslink against expected parent crosslink -// assert data.crosslink.parent_root == hash_tree_root(parent_crosslink) -// assert data.crosslink.start_epoch == parent_crosslink.end_epoch -// assert data.crosslink.end_epoch == min(data.target.epoch, parent_crosslink.end_epoch + MAX_EPOCHS_PER_CROSSLINK) -// assert data.crosslink.data_root == Bytes32() # [to be removed in phase 1] +// assert data.source == state.previous_justified_checkpoint +// state.previous_epoch_attestations.append(pending_attestation) // // # Check signature // assert is_valid_indexed_attestation(state, get_indexed_attestation(state, attestation)) @@ -560,15 +545,6 @@ func ProcessAttestationNoVerify(ctx context.Context, beaconState *pb.BeaconState defer span.End() data := att.Data - - if data.Crosslink.Shard > params.BeaconConfig().ShardCount { - return nil, fmt.Errorf( - "expected crosslink shard %d to be less than SHARD_COUNT %d", - data.Crosslink.Shard, - params.BeaconConfig().ShardCount, - ) - } - if data.Target.Epoch != helpers.PrevEpoch(beaconState) && data.Target.Epoch != helpers.CurrentEpoch(beaconState) { return nil, fmt.Errorf( "expected target epoch (%d) to be the previous epoch (%d) or the current epoch (%d)", @@ -578,16 +554,13 @@ func ProcessAttestationNoVerify(ctx context.Context, beaconState *pb.BeaconState ) } - attestationSlot, err := helpers.AttestationDataSlot(beaconState, data) - if err != nil { - return nil, errors.Wrap(err, "could not get attestation slot") - } - minInclusionCheck := attestationSlot+params.BeaconConfig().MinAttestationInclusionDelay <= beaconState.Slot - epochInclusionCheck := beaconState.Slot <= attestationSlot+params.BeaconConfig().SlotsPerEpoch + s := att.Data.Slot + minInclusionCheck := s+params.BeaconConfig().MinAttestationInclusionDelay <= beaconState.Slot + epochInclusionCheck := beaconState.Slot <= s+params.BeaconConfig().SlotsPerEpoch if !minInclusionCheck { return nil, fmt.Errorf( "attestation slot %d + inclusion delay %d > state slot %d", - attestationSlot, + s, params.BeaconConfig().MinAttestationInclusionDelay, beaconState.Slot, ) @@ -596,7 +569,7 @@ func ProcessAttestationNoVerify(ctx context.Context, beaconState *pb.BeaconState return nil, fmt.Errorf( "state slot %d > attestation slot %d + SLOTS_PER_EPOCH %d", beaconState.Slot, - attestationSlot, + s, params.BeaconConfig().SlotsPerEpoch, ) } @@ -612,34 +585,22 @@ func ProcessAttestationNoVerify(ctx context.Context, beaconState *pb.BeaconState pendingAtt := &pb.PendingAttestation{ Data: data, AggregationBits: att.AggregationBits, - InclusionDelay: beaconState.Slot - attestationSlot, + InclusionDelay: beaconState.Slot - s, ProposerIndex: proposerIndex, } var ffgSourceEpoch uint64 var ffgSourceRoot []byte var ffgTargetEpoch uint64 - var parentCrosslink *ethpb.Crosslink if data.Target.Epoch == helpers.CurrentEpoch(beaconState) { ffgSourceEpoch = beaconState.CurrentJustifiedCheckpoint.Epoch ffgSourceRoot = beaconState.CurrentJustifiedCheckpoint.Root ffgTargetEpoch = helpers.CurrentEpoch(beaconState) - crosslinkShard := data.Crosslink.Shard - if int(crosslinkShard) >= len(beaconState.CurrentCrosslinks) { - return nil, fmt.Errorf("invalid shard given in attestation: %d", crosslinkShard) - } - - parentCrosslink = beaconState.CurrentCrosslinks[crosslinkShard] beaconState.CurrentEpochAttestations = append(beaconState.CurrentEpochAttestations, pendingAtt) } else { ffgSourceEpoch = beaconState.PreviousJustifiedCheckpoint.Epoch ffgSourceRoot = beaconState.PreviousJustifiedCheckpoint.Root ffgTargetEpoch = helpers.PrevEpoch(beaconState) - crosslinkShard := data.Crosslink.Shard - if int(crosslinkShard) >= len(beaconState.PreviousCrosslinks) { - return nil, fmt.Errorf("invalid shard given in attestation: %d", crosslinkShard) - } - parentCrosslink = beaconState.PreviousCrosslinks[crosslinkShard] beaconState.PreviousEpochAttestations = append(beaconState.PreviousEpochAttestations, pendingAtt) } if data.Source.Epoch != ffgSourceEpoch { @@ -651,34 +612,7 @@ func ProcessAttestationNoVerify(ctx context.Context, beaconState *pb.BeaconState if data.Target.Epoch != ffgTargetEpoch { return nil, fmt.Errorf("expected target epoch %d, received %d", ffgTargetEpoch, data.Target.Epoch) } - endEpoch := parentCrosslink.EndEpoch + params.BeaconConfig().MaxEpochsPerCrosslink - if data.Target.Epoch < endEpoch { - endEpoch = data.Target.Epoch - } - if data.Crosslink.StartEpoch != parentCrosslink.EndEpoch { - return nil, fmt.Errorf("expected crosslink start epoch %d, received %d", - parentCrosslink.EndEpoch, data.Crosslink.StartEpoch) - } - if data.Crosslink.EndEpoch != endEpoch { - return nil, fmt.Errorf("expected crosslink end epoch %d, received %d", - endEpoch, data.Crosslink.EndEpoch) - } - crosslinkParentRoot, err := ssz.HashTreeRoot(parentCrosslink) - if err != nil { - return nil, errors.Wrap(err, "could not tree hash parent crosslink") - } - if !bytes.Equal(data.Crosslink.ParentRoot, crosslinkParentRoot[:]) { - return nil, fmt.Errorf( - "mismatched parent crosslink root, expected %#x, received %#x", - crosslinkParentRoot, - data.Crosslink.ParentRoot, - ) - } - // To be removed in Phase 1 - if !bytes.Equal(data.Crosslink.DataRoot, params.BeaconConfig().ZeroHash[:]) { - return nil, fmt.Errorf("expected data root %#x == ZERO_HASH", data.Crosslink.DataRoot) - } return beaconState, nil } @@ -708,6 +642,7 @@ func ConvertToIndexed(ctx context.Context, state *pb.BeaconState, attestation *e if err != nil { return nil, errors.Wrap(err, "could not get attesting indices") } + cb1i, err := helpers.AttestingIndices(state, attestation.Data, attestation.CustodyBits) if err != nil { return nil, err @@ -816,7 +751,7 @@ func VerifyIndexedAttestation(ctx context.Context, beaconState *pb.BeaconState, return fmt.Errorf("custody Bit1 indices are not sorted, got %v", custodyBit1Indices) } - domain := helpers.Domain(beaconState.Fork, indexedAtt.Data.Target.Epoch, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, indexedAtt.Data.Target.Epoch, params.BeaconConfig().DomainBeaconAttester) var pubkeys []*bls.PublicKey if len(custodyBit0Indices) > 0 { pubkey, err := bls.PublicKeyFromBytes(beaconState.Validators[custodyBit0Indices[0]].PublicKey) @@ -1121,130 +1056,6 @@ func VerifyExit(beaconState *pb.BeaconState, exit *ethpb.VoluntaryExit) error { return nil } -// ProcessTransfers is one of the operations performed -// on each processed beacon block to determine transfers between beacon chain balances. -// -// Spec pseudocode definition: -// def process_transfer(state: BeaconState, transfer: Transfer) -> None: -// """ -// Process ``Transfer`` operation. -// """ -// # Verify the balance the covers amount and fee (with overflow protection) -// assert state.balances[transfer.sender] >= max(transfer.amount + transfer.fee, transfer.amount, transfer.fee) -// # A transfer is valid in only one slot -// assert state.slot == transfer.slot -// # SenderIndex must satisfy at least one of the following conditions in the parenthesis: -// assert ( -// # * Has not been activated -// state.validator_registry[transfer.sender].activation_eligibility_epoch == FAR_FUTURE_EPOCH or -// # * Is withdrawable -// get_current_epoch(state) >= state.validator_registry[transfer.sender].withdrawable_epoch or -// # * Balance after transfer is more than the effective balance threshold -// transfer.amount + transfer.fee + MAX_EFFECTIVE_BALANCE <= state.balances[transfer.sender] -// ) -// # Verify that the pubkey is valid -// assert ( -// state.validator_registry[transfer.sender].withdrawal_credentials == -// int_to_bytes(BLS_WITHDRAWAL_PREFIX, length=1) + hash(transfer.pubkey)[1:] -// ) -// # Verify that the signature is valid -// assert bls_verify(transfer.pubkey, signing_root(transfer), transfer.signature, get_domain(state, DOMAIN_TRANSFER)) -// # Process the transfer -// decrease_balance(state, transfer.sender, transfer.amount + transfer.fee) -// increase_balance(state, transfer.recipient, transfer.amount) -// increase_balance(state, get_beacon_proposer_index(state), transfer.fee) -// # Verify balances are not dust -// assert not (0 < state.balances[transfer.sender] < MIN_DEPOSIT_AMOUNT) -// assert not (0 < state.balances[transfer.recipient] < MIN_DEPOSIT_AMOUNT) -func ProcessTransfers( - beaconState *pb.BeaconState, - body *ethpb.BeaconBlockBody, -) (*pb.BeaconState, error) { - transfers := body.Transfers - - for idx, transfer := range transfers { - if err := verifyTransfer(beaconState, transfer); err != nil { - return nil, errors.Wrapf(err, "could not verify transfer %d", idx) - } - // Process the transfer between accounts. - beaconState = helpers.DecreaseBalance(beaconState, transfer.SenderIndex, transfer.Amount+transfer.Fee) - beaconState = helpers.IncreaseBalance(beaconState, transfer.RecipientIndex, transfer.Amount) - proposerIndex, err := helpers.BeaconProposerIndex(beaconState) - if err != nil { - return nil, errors.Wrap(err, "could not determine beacon proposer index") - } - beaconState = helpers.IncreaseBalance(beaconState, proposerIndex, transfer.Fee) - - // Finally, we verify balances will not go below the mininum. - if beaconState.Balances[transfer.SenderIndex] < params.BeaconConfig().MinDepositAmount && - 0 < beaconState.Balances[transfer.SenderIndex] { - return nil, fmt.Errorf( - "sender balance below critical level: %v", - beaconState.Balances[transfer.SenderIndex], - ) - } - if beaconState.Balances[transfer.RecipientIndex] < params.BeaconConfig().MinDepositAmount && - 0 < beaconState.Balances[transfer.RecipientIndex] { - return nil, fmt.Errorf( - "recipient balance below critical level: %v", - beaconState.Balances[transfer.RecipientIndex], - ) - } - } - return beaconState, nil -} - -func verifyTransfer(beaconState *pb.BeaconState, transfer *ethpb.Transfer) error { - if transfer.SenderIndex > uint64(len(beaconState.Validators)) { - return errors.New("transfer sender index out of bounds in validator registry") - } - - maxVal := transfer.Fee - if transfer.Amount > maxVal { - maxVal = transfer.Amount - } - if transfer.Amount+transfer.Fee > maxVal { - maxVal = transfer.Amount + transfer.Fee - } - sender := beaconState.Validators[transfer.SenderIndex] - senderBalance := beaconState.Balances[transfer.SenderIndex] - // Verify the balance the covers amount and fee (with overflow protection). - if senderBalance < maxVal { - return fmt.Errorf("expected sender balance %d >= %d", senderBalance, maxVal) - } - // A transfer is valid in only one slot. - if beaconState.Slot != transfer.Slot { - return fmt.Errorf("expected beacon state slot %d == transfer slot %d", beaconState.Slot, transfer.Slot) - } - - // Sender must be not yet eligible for activation, withdrawn, or transfer balance over MAX_EFFECTIVE_BALANCE. - senderNotActivationEligible := sender.ActivationEligibilityEpoch == params.BeaconConfig().FarFutureEpoch - senderNotWithdrawn := helpers.CurrentEpoch(beaconState) >= sender.WithdrawableEpoch - underMaxTransfer := transfer.Amount+transfer.Fee+params.BeaconConfig().MaxEffectiveBalance <= senderBalance - - if !(senderNotActivationEligible || senderNotWithdrawn || underMaxTransfer) { - return fmt.Errorf( - "expected activation eligiblity: false or withdrawn: false or over max transfer: false, received %v %v %v", - senderNotActivationEligible, - senderNotWithdrawn, - underMaxTransfer, - ) - } - // Verify that the pubkey is valid. - buf := []byte{params.BeaconConfig().BLSWithdrawalPrefixByte} - hashed := hashutil.Hash(transfer.SenderWithdrawalPublicKey) - buf = append(buf, hashed[:][1:]...) - if !bytes.Equal(sender.WithdrawalCredentials, buf) { - return fmt.Errorf("invalid public key, expected %v, received %v", buf, sender.WithdrawalCredentials) - } - - domain := helpers.Domain(beaconState.Fork, helpers.CurrentEpoch(beaconState), params.BeaconConfig().DomainTransfer) - if err := verifySigningRoot(transfer, transfer.SenderWithdrawalPublicKey, transfer.Signature, domain); err != nil { - return errors.Wrap(err, "could not verify transfer signature") - } - return nil -} - // ClearEth1DataVoteCache clears the eth1 data vote count cache. func ClearEth1DataVoteCache() { eth1DataCache = cache.NewEth1DataVoteCache() diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 2b7ef5deb2..3f7b3dedc1 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -23,7 +23,6 @@ import ( ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/trieutil" @@ -36,12 +35,8 @@ func init() { } func TestProcessBlockHeader_WrongProposerSig(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Error(err) } @@ -81,10 +76,6 @@ func TestProcessBlockHeader_WrongProposerSig(t *testing.T) { } func TestProcessBlockHeader_DifferentSlots(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -101,8 +92,7 @@ func TestProcessBlockHeader_DifferentSlots(t *testing.T) { PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } lbhsr, err := ssz.HashTreeRoot(state.LatestBlockHeader) @@ -134,10 +124,6 @@ func TestProcessBlockHeader_DifferentSlots(t *testing.T) { } func TestProcessBlockHeader_PreviousBlockRootNotSignedRoot(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -154,8 +140,7 @@ func TestProcessBlockHeader_PreviousBlockRootNotSignedRoot(t *testing.T) { PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } currentEpoch := helpers.CurrentEpoch(state) @@ -183,10 +168,6 @@ func TestProcessBlockHeader_PreviousBlockRootNotSignedRoot(t *testing.T) { } func TestProcessBlockHeader_SlashedProposer(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -203,8 +184,7 @@ func TestProcessBlockHeader_SlashedProposer(t *testing.T) { PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } parentRoot, err := ssz.SigningRoot(state.LatestBlockHeader) @@ -238,10 +218,6 @@ func TestProcessBlockHeader_SlashedProposer(t *testing.T) { func TestProcessBlockHeader_OK(t *testing.T) { helpers.ClearAllCaches() - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Fatalf("SlotsPerEpoch should be 64 for these tests to pass") - } - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -258,8 +234,7 @@ func TestProcessBlockHeader_OK(t *testing.T) { PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } latestBlockSignedRoot, err := ssz.SigningRoot(state.LatestBlockHeader) @@ -320,7 +295,7 @@ func TestProcessRandao_IncorrectProposerFailsVerification(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -353,7 +328,7 @@ func TestProcessRandao_IncorrectProposerFailsVerification(t *testing.T) { func TestProcessRandao_SignatureVerifiesAndUpdatesLatestStateMixes(t *testing.T) { deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -421,7 +396,7 @@ func TestProcessEth1Data_SetsCorrectly(t *testing.T) { ) } } -func TestProcessProposerSlashings_UnmatchedHeaderEpochs(t *testing.T) { +func TestProcessProposerSlashings_UnmatchedHeaderSlots(t *testing.T) { registry := make([]*ethpb.Validator, 2) currentSlot := uint64(0) slashings := []*ethpb.ProposerSlashing{ @@ -445,7 +420,7 @@ func TestProcessProposerSlashings_UnmatchedHeaderEpochs(t *testing.T) { ProposerSlashings: slashings, }, } - want := "mismatched header epochs" + want := "mismatched header slots" if _, err := blocks.ProcessProposerSlashings(context.Background(), beaconState, block.Body); !strings.Contains(err.Error(), want) { t.Errorf("Expected %s, received %v", want, err) } @@ -527,7 +502,6 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) { func TestProcessProposerSlashings_AppliesCorrectStatus(t *testing.T) { // We test the case when data is correct and verify the validator // registry has been updated. - helpers.ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 100) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -553,9 +527,8 @@ func TestProcessProposerSlashings_AppliesCorrectStatus(t *testing.T) { PreviousVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, }, - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } domain := helpers.Domain( @@ -643,18 +616,12 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, }, Attestation_2: ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 1}, - Crosslink: ðpb.Crosslink{ - Shard: 3, - }, }, }, }, @@ -685,9 +652,6 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1, 2}, CustodyBit_1Indices: []uint64{0, 1, 2}, @@ -696,9 +660,6 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1, 2}, CustodyBit_1Indices: []uint64{0, 1, 2}, @@ -729,9 +690,6 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: make([]uint64, params.BeaconConfig().MaxValidatorsPerCommittee+1), }, @@ -739,9 +697,6 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: make([]uint64, params.BeaconConfig().MaxValidatorsPerCommittee+1), }, @@ -758,7 +713,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) { deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) for _, vv := range beaconState.Validators { vv.WithdrawableEpoch = 1 * params.BeaconConfig().SlotsPerEpoch } @@ -767,9 +722,6 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } @@ -781,7 +733,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) { if err != nil { t.Error(err) } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sig0 := privKeys[0].Sign(hashTreeRoot[:], domain) sig1 := privKeys[1].Sign(hashTreeRoot[:], domain) aggregateSig := bls.AggregateSignatures([]*bls.Signature{sig0, sig1}) @@ -791,9 +743,6 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } @@ -851,9 +800,7 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) { { Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, + Slot: 5, }, }, } @@ -863,19 +810,14 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) { }, } deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) - if err != nil { - t.Fatal(err) - } - - attestationSlot, err := helpers.AttestationDataSlot(beaconState, attestations[0].Data) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } want := fmt.Sprintf( "attestation slot %d + inclusion delay %d > state slot %d", - attestationSlot, + attestations[0].Data.Slot, params.BeaconConfig().MinAttestationInclusionDelay, beaconState.Slot, ) @@ -891,13 +833,7 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { att := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, - }, - } + Target: ðpb.Checkpoint{Epoch: 0}}} block := ðpb.BeaconBlock{ Body: ðpb.BeaconBlockBody{ @@ -905,17 +841,12 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { }, } deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } helpers.ClearAllCaches() beaconState.Slot += params.BeaconConfig().SlotsPerEpoch*4 + params.BeaconConfig().MinAttestationInclusionDelay - beaconState.PreviousCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - }, - } beaconState.PreviousJustifiedCheckpoint.Root = []byte("hello-world") beaconState.PreviousEpochAttestations = []*pb.PendingAttestation{} @@ -933,17 +864,13 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) { helpers.ClearAllCaches() - aggBits := bitfield.NewBitlist(1) - custodyBits := bitfield.NewBitlist(1) + aggBits := bitfield.NewBitlist(3) + custodyBits := bitfield.NewBitlist(3) attestations := []*ethpb.Attestation{ { Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Epoch: 0}, Source: ðpb.Checkpoint{Epoch: 1}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: aggBits, CustodyBits: custodyBits, @@ -955,16 +882,11 @@ func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) { }, } deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} @@ -994,22 +916,20 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - aggBits := bitfield.NewBitlist(1) + aggBits := bitfield.NewBitlist(3) aggBits.SetBitAt(0, true) - custodyBits := bitfield.NewBitlist(1) + custodyBits := bitfield.NewBitlist(3) attestations := []*ethpb.Attestation{ { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 1}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, + Slot: 1, }, AggregationBits: aggBits, CustodyBits: custodyBits, @@ -1023,11 +943,6 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { helpers.ClearAllCaches() beaconState.Slot += params.BeaconConfig().SlotsPerEpoch + params.BeaconConfig().MinAttestationInclusionDelay - beaconState.PreviousCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - }, - } beaconState.PreviousJustifiedCheckpoint.Root = []byte("hello-world") beaconState.PreviousEpochAttestations = []*pb.PendingAttestation{} @@ -1055,86 +970,20 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { } } -func TestProcessAttestations_CrosslinkMismatches(t *testing.T) { - helpers.ClearAllCaches() - - aggBits := bitfield.NewBitlist(1) - aggBits.SetBitAt(0, true) - custodyBits := bitfield.NewBitlist(1) - attestations := []*ethpb.Attestation{ - { - Data: ðpb.AttestationData{ - Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, - }, - AggregationBits: aggBits, - CustodyBits: custodyBits, - }, - } - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Attestations: attestations, - }, - } - deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) - if err != nil { - t.Fatal(err) - } - beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } - beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") - beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - - want := "mismatched parent crosslink root" - if _, err := blocks.ProcessAttestations(context.Background(), beaconState, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } - - block.Body.Attestations[0].Data.Crosslink.StartEpoch = 0 - if _, err := blocks.ProcessAttestations(context.Background(), beaconState, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - block.Body.Attestations[0].Data.Crosslink.ParentRoot = encoded[:] - block.Body.Attestations[0].Data.Crosslink.DataRoot = encoded[:] - - want = fmt.Sprintf("expected data root %#x == ZERO_HASH", encoded) - if _, err := blocks.ProcessAttestations(context.Background(), beaconState, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } -} - func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - aggBits := bitfield.NewBitlist(2) - custodyBits := bitfield.NewBitlist(2) + aggBits := bitfield.NewBitlist(4) + custodyBits := bitfield.NewBitlist(4) att := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, - }, + Target: ðpb.Checkpoint{Epoch: 0}}, AggregationBits: aggBits, CustodyBits: custodyBits, } @@ -1146,67 +995,39 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } + beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - block.Body.Attestations[0].Data.Crosslink.ParentRoot = encoded[:] - block.Body.Attestations[0].Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - - expected := "failed to verify aggregation bitfield: wanted participants bitfield length 1, got: 2" + expected := "failed to verify aggregation bitfield: wanted participants bitfield length 3, got: 4" _, err = blocks.ProcessAttestations(context.Background(), beaconState, block.Body) if !strings.Contains(err.Error(), expected) { - t.Errorf("Expected error checking aggregation and custody bit length, received: %v", err) + t.Errorf("Did not receive wanted error") } } func TestProcessAttestations_OK(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - aggBits := bitfield.NewBitlist(1) + aggBits := bitfield.NewBitlist(3) aggBits.SetBitAt(0, true) - custodyBits := bitfield.NewBitlist(1) + custodyBits := bitfield.NewBitlist(3) att := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: aggBits, CustodyBits: custodyBits, } - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att.Data.Crosslink.ParentRoot = encoded[:] - att.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] attestingIndices, err := helpers.AttestingIndices(beaconState, att.Data, att.AggregationBits) if err != nil { @@ -1220,7 +1041,7 @@ func TestProcessAttestations_OK(t *testing.T) { if err != nil { t.Error(err) } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sigs := make([]*bls.Signature, len(attestingIndices)) for i, indice := range attestingIndices { sig := privKeys[indice].Sign(hashTreeRoot[:], domain) @@ -1244,19 +1065,15 @@ func TestProcessAttestations_OK(t *testing.T) { func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 300) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) data := ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, } aggBits1 := bitfield.NewBitlist(4) aggBits1.SetBitAt(0, true) @@ -1269,15 +1086,8 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { CustodyBits: custodyBits1, } - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{{Shard: 0, StartEpoch: 0}} beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att1.Data.Crosslink.ParentRoot = encoded[:] - att1.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] attestingIndices1, err := helpers.AttestingIndices(beaconState, att1.Data, att1.AggregationBits) if err != nil { @@ -1309,9 +1119,6 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { CustodyBits: custodyBits2, } - att2.Data.Crosslink.ParentRoot = encoded[:] - att2.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - attestingIndices2, err := helpers.AttestingIndices(beaconState, att2.Data, att2.AggregationBits) if err != nil { t.Fatal(err) @@ -1339,39 +1146,28 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 300) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) data := ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, } - aggBits1 := bitfield.NewBitlist(4) + aggBits1 := bitfield.NewBitlist(9) aggBits1.SetBitAt(0, true) aggBits1.SetBitAt(1, true) - custodyBits1 := bitfield.NewBitlist(4) + custodyBits1 := bitfield.NewBitlist(9) att1 := ðpb.Attestation{ Data: data, AggregationBits: aggBits1, CustodyBits: custodyBits1, } - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{{Shard: 0, StartEpoch: 0}} beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att1.Data.Crosslink.ParentRoot = encoded[:] - att1.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] attestingIndices1, err := helpers.AttestingIndices(beaconState, att1.Data, att1.AggregationBits) if err != nil { @@ -1392,19 +1188,16 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { } att1.Signature = bls.AggregateSignatures(sigs).Marshal()[:] - aggBits2 := bitfield.NewBitlist(4) + aggBits2 := bitfield.NewBitlist(9) aggBits2.SetBitAt(2, true) aggBits2.SetBitAt(3, true) - custodyBits2 := bitfield.NewBitlist(4) + custodyBits2 := bitfield.NewBitlist(9) att2 := ðpb.Attestation{ Data: data, AggregationBits: aggBits2, CustodyBits: custodyBits2, } - att2.Data.Crosslink.ParentRoot = encoded[:] - att2.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - attestingIndices2, err := helpers.AttestingIndices(beaconState, att2.Data, att2.AggregationBits) if err != nil { t.Fatal(err) @@ -1445,22 +1238,18 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) { // Attestation with an empty signature helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - aggBits := bitfield.NewBitlist(1) + aggBits := bitfield.NewBitlist(3) aggBits.SetBitAt(1, true) - custodyBits := bitfield.NewBitlist(1) + custodyBits := bitfield.NewBitlist(3) att := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: aggBits, CustodyBits: custodyBits, @@ -1470,22 +1259,9 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) { att.Signature = zeroSig[:] beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att.Data.Crosslink.ParentRoot = encoded[:] - att.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - if _, err := blocks.ProcessAttestationNoVerify(context.TODO(), beaconState, att); err != nil { t.Errorf("Unexpected error: %v", err) } @@ -1493,9 +1269,6 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) { func TestConvertToIndexed_OK(t *testing.T) { helpers.ClearAllCaches() - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } validators := make([]*ethpb.Validator, 2*params.BeaconConfig().SlotsPerEpoch) for i := 0; i < len(validators); i++ { @@ -1505,10 +1278,9 @@ func TestConvertToIndexed_OK(t *testing.T) { } state := &pb.BeaconState{ - Slot: 5, - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slot: 5, + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } tests := []struct { aggregationBitfield bitfield.Bitlist @@ -1519,20 +1291,20 @@ func TestConvertToIndexed_OK(t *testing.T) { { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x05}, - wantedCustodyBit0Indices: []uint64{71}, - wantedCustodyBit1Indices: []uint64{127}, + wantedCustodyBit0Indices: []uint64{4}, + wantedCustodyBit1Indices: []uint64{30}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x06}, - wantedCustodyBit0Indices: []uint64{127}, - wantedCustodyBit1Indices: []uint64{71}, + wantedCustodyBit0Indices: []uint64{30}, + wantedCustodyBit1Indices: []uint64{4}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x07}, wantedCustodyBit0Indices: []uint64{}, - wantedCustodyBit1Indices: []uint64{71, 127}, + wantedCustodyBit1Indices: []uint64{4, 30}, }, } @@ -1541,9 +1313,6 @@ func TestConvertToIndexed_OK(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 3, - }, }, } for _, tt := range tests { @@ -1571,10 +1340,8 @@ func TestConvertToIndexed_OK(t *testing.T) { func TestVerifyIndexedAttestation_OK(t *testing.T) { helpers.ClearAllCaches() - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - numOfValidators := 2 * params.BeaconConfig().SlotsPerEpoch + + numOfValidators := 4 * params.BeaconConfig().SlotsPerEpoch validators := make([]*ethpb.Validator, numOfValidators) _, _, keys := testutil.SetupInitialDeposits(t, numOfValidators) for i := 0; i < len(validators); i++ { @@ -1592,8 +1359,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } tests := []struct { attestation *ethpb.IndexedAttestation @@ -1640,7 +1406,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { CustodyBit: false, } - domain := helpers.Domain(state.Fork, tt.attestation.Data.Target.Epoch, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(state.Fork, tt.attestation.Data.Target.Epoch, params.BeaconConfig().DomainBeaconAttester) root, err := ssz.HashTreeRoot(attDataAndCustodyBit) if err != nil { @@ -2102,203 +1868,3 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) { helpers.DelayedActivationExitEpoch(state.Slot/params.BeaconConfig().SlotsPerEpoch), newRegistry[0].ExitEpoch) } } - -func TestProcessBeaconTransfers_NotEnoughSenderIndexBalance(t *testing.T) { - registry := []*ethpb.Validator{ - { - ActivationEligibilityEpoch: params.BeaconConfig().FarFutureEpoch, - }, - } - balances := []uint64{params.BeaconConfig().MaxEffectiveBalance} - state := &pb.BeaconState{ - Validators: registry, - Balances: balances, - } - transfers := []*ethpb.Transfer{ - { - Fee: params.BeaconConfig().MaxEffectiveBalance, - Amount: params.BeaconConfig().MaxEffectiveBalance, - }, - } - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Transfers: transfers, - }, - } - want := fmt.Sprintf( - "expected sender balance %d >= %d", - balances[0], - transfers[0].Fee+transfers[0].Amount, - ) - if _, err := blocks.ProcessTransfers(state, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } -} - -func TestProcessBeaconTransfers_FailsVerification(t *testing.T) { - testConfig := params.BeaconConfig() - testConfig.MaxTransfers = 1 - params.OverrideBeaconConfig(testConfig) - registry := []*ethpb.Validator{ - { - ActivationEligibilityEpoch: params.BeaconConfig().FarFutureEpoch, - }, - { - ActivationEligibilityEpoch: params.BeaconConfig().FarFutureEpoch, - }, - } - balances := []uint64{params.BeaconConfig().MaxEffectiveBalance} - state := &pb.BeaconState{ - Slot: 0, - Validators: registry, - Balances: balances, - } - transfers := []*ethpb.Transfer{ - { - Fee: params.BeaconConfig().MaxEffectiveBalance + 1, - }, - } - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Transfers: transfers, - }, - } - want := fmt.Sprintf( - "expected sender balance %d >= %d", - balances[0], - transfers[0].Fee, - ) - if _, err := blocks.ProcessTransfers(state, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } - - block.Body.Transfers = []*ethpb.Transfer{ - { - Fee: params.BeaconConfig().MinDepositAmount, - Slot: state.Slot + 1, - }, - } - want = fmt.Sprintf( - "expected beacon state slot %d == transfer slot %d", - state.Slot, - block.Body.Transfers[0].Slot, - ) - if _, err := blocks.ProcessTransfers(state, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } - - state.Validators[0].WithdrawableEpoch = params.BeaconConfig().FarFutureEpoch - state.Validators[0].ActivationEligibilityEpoch = 0 - state.Balances[0] = params.BeaconConfig().MinDepositAmount + params.BeaconConfig().MaxEffectiveBalance - block.Body.Transfers = []*ethpb.Transfer{ - { - Fee: params.BeaconConfig().MinDepositAmount, - Amount: params.BeaconConfig().MaxEffectiveBalance, - Slot: state.Slot, - }, - } - want = "over max transfer" - if _, err := blocks.ProcessTransfers(state, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } - - state.Validators[0].WithdrawableEpoch = 0 - state.Validators[0].ActivationEligibilityEpoch = params.BeaconConfig().FarFutureEpoch - buf := []byte{params.BeaconConfig().BLSWithdrawalPrefixByte} - pubKey := []byte("B") - hashed := hashutil.Hash(pubKey) - buf = append(buf, hashed[:]...) - state.Validators[0].WithdrawalCredentials = buf - block.Body.Transfers = []*ethpb.Transfer{ - { - Fee: params.BeaconConfig().MinDepositAmount, - Amount: params.BeaconConfig().MinDepositAmount, - Slot: state.Slot, - SenderWithdrawalPublicKey: []byte("A"), - }, - } - want = "invalid public key" - if _, err := blocks.ProcessTransfers(state, block.Body); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } -} - -func TestProcessBeaconTransfers_OK(t *testing.T) { - helpers.ClearShuffledValidatorCache() - testConfig := params.BeaconConfig() - testConfig.MaxTransfers = 1 - params.OverrideBeaconConfig(testConfig) - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount/32) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ActivationEpoch: 0, - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - Slashed: false, - WithdrawableEpoch: 0, - } - } - validatorBalances := make([]uint64, len(validators)) - for i := 0; i < len(validatorBalances); i++ { - validatorBalances[i] = params.BeaconConfig().MaxEffectiveBalance - } - - state := &pb.BeaconState{ - Validators: validators, - Slot: 0, - Balances: validatorBalances, - Fork: &pb.Fork{ - CurrentVersion: params.BeaconConfig().GenesisForkVersion, - PreviousVersion: params.BeaconConfig().GenesisForkVersion, - }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - - transfer := ðpb.Transfer{ - SenderIndex: 0, - RecipientIndex: 1, - Fee: params.BeaconConfig().MinDepositAmount, - Amount: params.BeaconConfig().MinDepositAmount, - Slot: state.Slot, - } - - priv, err := bls.RandKey(rand.Reader) - if err != nil { - t.Fatal(err) - } - pubKey := priv.PublicKey().Marshal()[:] - transfer.SenderWithdrawalPublicKey = pubKey - state.Validators[transfer.SenderIndex].PublicKey = pubKey - signingRoot, err := ssz.SigningRoot(transfer) - if err != nil { - t.Fatalf("Failed to get signing root of block: %v", err) - } - epoch := helpers.CurrentEpoch(state) - dt := helpers.Domain(state.Fork, epoch, params.BeaconConfig().DomainTransfer) - transferSig := priv.Sign(signingRoot[:], dt) - transfer.Signature = transferSig.Marshal()[:] - - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Transfers: []*ethpb.Transfer{transfer}, - }, - } - buf := []byte{params.BeaconConfig().BLSWithdrawalPrefixByte} - hashed := hashutil.Hash(pubKey) - buf = append(buf, hashed[:][1:]...) - state.Validators[0].WithdrawalCredentials = buf - state.Validators[0].ActivationEligibilityEpoch = params.BeaconConfig().FarFutureEpoch - newState, err := blocks.ProcessTransfers(state, block.Body) - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - expectedRecipientIndex := params.BeaconConfig().MaxEffectiveBalance + block.Body.Transfers[0].Amount - if newState.Balances[1] != expectedRecipientIndex { - t.Errorf("Expected recipient balance %d, received %d", newState.Balances[1], expectedRecipientIndex) - } - expectedSenderIndex := params.BeaconConfig().MaxEffectiveBalance - block.Body.Transfers[0].Amount - block.Body.Transfers[0].Fee - if newState.Balances[0] != expectedSenderIndex { - t.Errorf("Expected sender balance %d, received %d", newState.Balances[0], expectedSenderIndex) - } -} diff --git a/beacon-chain/core/blocks/spectest/block_processing_test.go b/beacon-chain/core/blocks/spectest/block_processing_test.go index 105a4fa774..ea9bd84f4f 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_test.go @@ -60,6 +60,9 @@ func runBlockProcessingTest(t *testing.T, config string) { t.Fatalf("Failed to unmarshal: %v", err) } beaconState, transitionError = state.ExecuteStateTransition(context.Background(), beaconState, block) + if transitionError != nil { + break + } } // If the post.ssz is not present, it means the test should fail on our end. @@ -73,7 +76,7 @@ func runBlockProcessingTest(t *testing.T, config string) { if postSSZExists { if transitionError != nil { - t.Fatalf("Unexpected error: %v", transitionError) + t.Errorf("Unexpected error: %v", transitionError) } postBeaconStateFile, err := ioutil.ReadFile(postSSZFilepath) diff --git a/beacon-chain/core/epoch/BUILD.bazel b/beacon-chain/core/epoch/BUILD.bazel index d82cdc372f..bb290cd121 100644 --- a/beacon-chain/core/epoch/BUILD.bazel +++ b/beacon-chain/core/epoch/BUILD.bazel @@ -15,7 +15,6 @@ go_library( "//proto/eth/v1alpha1:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", - "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", ], diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 74e6bb081a..6ecd9cc8e6 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -9,7 +9,6 @@ import ( "fmt" "sort" - "github.com/gogo/protobuf/proto" "github.com/pkg/errors" "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" @@ -79,16 +78,9 @@ func MatchAttestations(state *pb.BeaconState, epoch uint64) (*MatchedAttestation if bytes.Equal(srcAtt.Data.Target.Root, targetRoot) { tgtAtts = append(tgtAtts, srcAtt) } - - // If the block root at slot matches attestation's block root at slot, - // then we know this attestation has correctly voted for head. - slot, err := helpers.AttestationDataSlot(state, srcAtt.Data) + headRoot, err := helpers.BlockRootAtSlot(state, srcAtt.Data.Slot) if err != nil { - return nil, errors.Wrap(err, "could not get attestation slot") - } - headRoot, err := helpers.BlockRootAtSlot(state, slot) - if err != nil { - return nil, errors.Wrapf(err, "could not get block root for slot %d", slot) + return nil, errors.Wrapf(err, "could not get block root for slot %d", srcAtt.Data.Slot) } if bytes.Equal(srcAtt.Data.BeaconBlockRoot, headRoot) { headAtts = append(headAtts, srcAtt) @@ -229,54 +221,6 @@ func ProcessJustificationAndFinalization(state *pb.BeaconState, prevAttestedBal return state, nil } -// ProcessCrosslinks processes crosslink and finds the crosslink -// with enough state to make it canonical in state. -// -// Spec pseudocode definition: -// def process_crosslinks(state: BeaconState) -> None: -// state.previous_crosslinks = [c for c in state.current_crosslinks] -// for epoch in (get_previous_epoch(state), get_current_epoch(state)): -// for offset in range(get_epoch_committee_count(state, epoch)): -// shard = (get_epoch_start_shard(state, epoch) + offset) % SHARD_COUNT -// crosslink_committee = get_crosslink_committee(state, epoch, shard) -// winning_crosslink, attesting_indices = get_winning_crosslink_and_attesting_indices(state, epoch, shard) -// if 3 * get_total_balance(state, attesting_indices) >= 2 * get_total_balance(state, crosslink_committee): -// state.current_crosslinks[shard] = winning_crosslink -func ProcessCrosslinks(state *pb.BeaconState) (*pb.BeaconState, error) { - copy(state.PreviousCrosslinks, state.CurrentCrosslinks) - epochs := []uint64{helpers.PrevEpoch(state), helpers.CurrentEpoch(state)} - for _, e := range epochs { - count, err := helpers.CommitteeCount(state, e) - if err != nil { - return nil, errors.Wrap(err, "could not get epoch committee count") - } - startShard, err := helpers.StartShard(state, e) - if err != nil { - return nil, errors.Wrap(err, "could not get epoch start shards") - } - for offset := uint64(0); offset < count; offset++ { - shard := (startShard + offset) % params.BeaconConfig().ShardCount - committee, err := helpers.CrosslinkCommittee(state, e, shard) - if err != nil { - return nil, errors.Wrap(err, "could not get crosslink committee") - } - crosslink, indices, err := WinningCrosslink(state, shard, e) - if err != nil { - return nil, errors.Wrap(err, "could not get winning crosslink") - } - attestedBalance := helpers.TotalBalance(state, indices) - totalBalance := helpers.TotalBalance(state, committee) - - // In order for a crosslink to get included in state, the attesting balance needs to - // be greater than 2/3 of the total balance. - if 3*attestedBalance >= 2*totalBalance { - state.CurrentCrosslinks[shard] = crosslink - } - } - } - return state, nil -} - // ProcessRewardsAndPenalties processes the rewards and penalties of individual validator. // // Spec pseudocode definition: @@ -298,14 +242,10 @@ func ProcessRewardsAndPenalties(state *pb.BeaconState) (*pb.BeaconState, error) if err != nil { return nil, errors.Wrap(err, "could not get attestation delta") } - clRewards, clPenalties, err := crosslinkDelta(state) - if err != nil { - return nil, errors.Wrapf(err, "could not get crosslink delta") - } for i := 0; i < len(state.Validators); i++ { - state = helpers.IncreaseBalance(state, uint64(i), attsRewards[i]+clRewards[i]) - state = helpers.DecreaseBalance(state, uint64(i), attsPenalties[i]+clPenalties[i]) + state = helpers.IncreaseBalance(state, uint64(i), attsRewards[i]) + state = helpers.DecreaseBalance(state, uint64(i), attsPenalties[i]) } return state, nil } @@ -490,30 +430,6 @@ func ProcessFinalUpdates(state *pb.BeaconState) (*pb.BeaconState, error) { } } - // Set active index root. - // index_epoch = Epoch(next_epoch + ACTIVATION_EXIT_DELAY) - // index_root_position = index_epoch % EPOCHS_PER_HISTORICAL_VECTOR - // indices_list = List[ValidatorIndex, VALIDATOR_REGISTRY_LIMIT](get_active_validator_indices(state, index_epoch)) - // state.active_index_roots[index_root_position] = hash_tree_root(indices_list) - activationDelay := params.BeaconConfig().ActivationExitDelay - idxRootPosition := (nextEpoch + activationDelay) % params.BeaconConfig().EpochsPerHistoricalVector - activeIndices, err := helpers.ActiveValidatorIndices(state, nextEpoch+activationDelay) - if err != nil { - return nil, errors.Wrap(err, "could not get active indices") - } - idxRoot, err := ssz.HashTreeRootWithCapacity(activeIndices, uint64(1099511627776)) - if err != nil { - return nil, errors.Wrap(err, "could not tree hash active indices") - } - state.ActiveIndexRoots[idxRootPosition] = idxRoot[:] - - commRootPosition := nextEpoch % params.BeaconConfig().EpochsPerHistoricalVector - comRoot, err := helpers.CompactCommitteesRoot(state, nextEpoch) - if err != nil { - return nil, errors.Wrap(err, "could not get compact committee root") - } - state.CompactCommitteesRoots[commRootPosition] = comRoot[:] - // Set total slashed balances. slashedExitLength := params.BeaconConfig().EpochsPerSlashingsVector state.Slashings[nextEpoch%slashedExitLength] = 0 @@ -537,13 +453,6 @@ func ProcessFinalUpdates(state *pb.BeaconState) (*pb.BeaconState, error) { state.HistoricalRoots = append(state.HistoricalRoots, batchRoot[:]) } - // Update start shard. - delta, err := helpers.ShardDelta(state, currentEpoch) - if err != nil { - return nil, errors.Wrap(err, "could not get shard delta") - } - state.StartShard = (state.StartShard + delta) % params.BeaconConfig().ShardCount - // Rotate current and previous epoch attestations. state.PreviousEpochAttestations = state.CurrentEpochAttestations state.CurrentEpochAttestations = []*pb.PendingAttestation{} @@ -591,93 +500,6 @@ func unslashedAttestingIndices(state *pb.BeaconState, atts []*pb.PendingAttestat return setIndices, nil } -// WinningCrosslink returns the most staked balance-wise crosslink of a given shard and epoch. -// It also returns the attesting inaidces of the winning cross link. -// -// Spec pseudocode definition: -// def get_winning_crosslink_and_attesting_indices(state: BeaconState, -// epoch: Epoch, -// shard: Shard) -> Tuple[Crosslink, List[ValidatorIndex]]: -// attestations = [a for a in get_matching_source_attestations(state, epoch) if a.data.crosslink.shard == shard] -// crosslinks = list(filter( -// lambda c: hash_tree_root(state.current_crosslinks[shard]) in (c.parent_root, hash_tree_root(c)), -// [a.data.crosslink for a in attestations] -// )) -// # Winning crosslink has the crosslink data root with the most balance voting for it (ties broken lexicographically) -// winning_crosslink = max(crosslinks, key=lambda c: ( -// get_attesting_balance(state, [a for a in attestations if a.data.crosslink == c]), c.data_root -// ), default=Crosslink()) -// winning_attestations = [a for a in attestations if a.data.crosslink == winning_crosslink] -// return winning_crosslink, get_unslashed_attesting_indices(state, winning_attestations) -func WinningCrosslink(state *pb.BeaconState, shard uint64, epoch uint64) (*ethpb.Crosslink, []uint64, error) { - var shardAtts []*pb.PendingAttestation - matchedAtts, err := MatchAttestations(state, epoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get matching attestations") - } - - // Filter out source attestations by shard. - for _, att := range matchedAtts.source { - if att.Data.Crosslink.Shard == shard { - shardAtts = append(shardAtts, att) - } - } - var candidateCrosslinks []*ethpb.Crosslink - // Filter out shard crosslinks with correct current or previous crosslink data. - for _, a := range shardAtts { - stateCrosslink := state.CurrentCrosslinks[shard] - stateCrosslinkRoot, err := ssz.HashTreeRoot(stateCrosslink) - if err != nil { - return nil, nil, errors.Wrap(err, "could not hash tree root crosslink from state") - } - attCrosslinkRoot, err := ssz.HashTreeRoot(a.Data.Crosslink) - if err != nil { - return nil, nil, errors.Wrap(err, "could not hash tree root crosslink from attestation") - } - currCrosslinkMatches := bytes.Equal(stateCrosslinkRoot[:], attCrosslinkRoot[:]) - prevCrosslinkMatches := bytes.Equal(stateCrosslinkRoot[:], a.Data.Crosslink.ParentRoot) - if currCrosslinkMatches || prevCrosslinkMatches { - candidateCrosslinks = append(candidateCrosslinks, a.Data.Crosslink) - } - } - - if len(candidateCrosslinks) == 0 { - return ðpb.Crosslink{ - DataRoot: params.BeaconConfig().ZeroHash[:], - ParentRoot: params.BeaconConfig().ZeroHash[:], - }, nil, nil - } - var crosslinkAtts []*pb.PendingAttestation - var winnerBalance uint64 - var winnerCrosslink *ethpb.Crosslink - // Out of the existing shard crosslinks, pick the one that has the - // most balance staked. - crosslinkAtts = attsForCrosslink(candidateCrosslinks[0], shardAtts) - winnerBalance, err = AttestingBalance(state, crosslinkAtts) - if err != nil { - return nil, nil, err - } - - winnerCrosslink = candidateCrosslinks[0] - for _, c := range candidateCrosslinks { - crosslinkAtts = attsForCrosslink(c, shardAtts) - attestingBalance, err := AttestingBalance(state, crosslinkAtts) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get crosslink's attesting balance") - } - if attestingBalance > winnerBalance { - winnerCrosslink = c - } - } - - crosslinkIndices, err := unslashedAttestingIndices(state, attsForCrosslink(winnerCrosslink, shardAtts)) - if err != nil { - return nil, nil, errors.New("could not get crosslink indices") - } - - return winnerCrosslink, crosslinkIndices, nil -} - // BaseReward takes state and validator index and calculate // individual validator's base reward quotient. // @@ -742,11 +564,7 @@ func BaseReward(state *pb.BeaconState, index uint64) (uint64, error) { // proposer_reward = Gwei(get_base_reward(state, index) // PROPOSER_REWARD_QUOTIENT) // rewards[attestation.proposer_index] += proposer_reward // max_attester_reward = get_base_reward(state, index) - proposer_reward -// rewards[index] += Gwei( -// max_attester_reward -// * (SLOTS_PER_EPOCH + MIN_ATTESTATION_INCLUSION_DELAY - attestation.inclusion_delay) -// // SLOTS_PER_EPOCH -// ) +// rewards[index] += Gwei(max_attester_reward // attestation.inclusion_delay) // // # Inactivity penalty // finality_delay = previous_epoch - state.finalized_checkpoint.epoch @@ -845,8 +663,6 @@ func attestationDelta(state *pb.BeaconState) ([]uint64, []uint64, error) { } for i, a := range attestersVotedSource { - slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch - baseReward, err := BaseReward(state, i) if err != nil { return nil, nil, errors.Wrap(err, "could not get proposer reward") @@ -854,7 +670,7 @@ func attestationDelta(state *pb.BeaconState) ([]uint64, []uint64, error) { proposerReward := baseReward / params.BeaconConfig().ProposerRewardQuotient rewards[a.ProposerIndex] += proposerReward attesterReward := baseReward - proposerReward - rewards[i] += attesterReward * (slotsPerEpoch + params.BeaconConfig().MinAttestationInclusionDelay - a.InclusionDelay) / slotsPerEpoch + rewards[i] += attesterReward / a.InclusionDelay } // Apply penalties for quadratic leaks. @@ -882,88 +698,6 @@ func attestationDelta(state *pb.BeaconState) ([]uint64, []uint64, error) { } } } - return rewards, penalties, nil -} - -// crosslinkDelta calculates the rewards and penalties of individual -// validator for submitting the correct crosslink. -// Individual rewards and penalties are returned in list. -// -// Note: we calculated adjusted quotient outside of base reward because it's too inefficient -// to repeat the same calculation for every validator versus just doing it once. -// -// Spec pseudocode definition: -// def get_crosslink_deltas(state: BeaconState) -> Tuple[List[Gwei], List[Gwei]]: -// rewards = [0 for index in range(len(state.validator_registry))] -// penalties = [0 for index in range(len(state.validator_registry))] -// epoch = get_previous_epoch(state) -// for offset in range(get_epoch_committee_count(state, epoch)): -// shard = (get_epoch_start_shard(state, epoch) + offset) % SHARD_COUNT -// crosslink_committee = get_crosslink_committee(state, epoch, shard) -// winning_crosslink, attesting_indices = get_winning_crosslink_and_attesting_indices(state, epoch, shard) -// attesting_balance = get_total_balance(state, attesting_indices) -// committee_balance = get_total_balance(state, crosslink_committee) -// for index in crosslink_committee: -// base_reward = get_base_reward(state, index) -// if index in attesting_indices: -// rewards[index] += base_reward * attesting_balance // committee_balance -// else: -// penalties[index] += base_reward -// return rewards, penalties -func crosslinkDelta(state *pb.BeaconState) ([]uint64, []uint64, error) { - rewards := make([]uint64, len(state.Validators)) - penalties := make([]uint64, len(state.Validators)) - epoch := helpers.PrevEpoch(state) - count, err := helpers.CommitteeCount(state, epoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get epoch committee count") - } - startShard, err := helpers.StartShard(state, epoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get epoch start shard") - } - for i := uint64(0); i < count; i++ { - shard := (startShard + i) % params.BeaconConfig().ShardCount - committee, err := helpers.CrosslinkCommittee(state, epoch, shard) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get crosslink's committee") - } - _, attestingIndices, err := WinningCrosslink(state, shard, epoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get winning crosslink") - } - - attested := make(map[uint64]bool) - // Construct a map to look up validators that voted for crosslink. - for _, index := range attestingIndices { - attested[index] = true - } - committeeBalance := helpers.TotalBalance(state, committee) - attestingBalance := helpers.TotalBalance(state, attestingIndices) - - for _, index := range committee { - base, err := BaseReward(state, index) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get base reward") - } - if _, ok := attested[index]; ok { - rewards[index] += base * attestingBalance / committeeBalance - } else { - penalties[index] += base - } - } - } return rewards, penalties, nil } - -// attsForCrosslink returns the attestations of the input crosslink. -func attsForCrosslink(crosslink *ethpb.Crosslink, atts []*pb.PendingAttestation) []*pb.PendingAttestation { - var crosslinkAtts []*pb.PendingAttestation - for _, a := range atts { - if proto.Equal(a.Data.Crosslink, crosslink) { - crosslinkAtts = append(crosslinkAtts, a) - } - } - return crosslinkAtts -} diff --git a/beacon-chain/core/epoch/epoch_processing_test.go b/beacon-chain/core/epoch/epoch_processing_test.go index 517ee5f29e..5c5ce0729b 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -2,7 +2,6 @@ package epoch import ( "bytes" - "fmt" "reflect" "strings" "testing" @@ -16,8 +15,6 @@ import ( ) func init() { - helpers.ClearShuffledValidatorCache() - // TODO(2312): remove this and use the mainnet count. c := params.BeaconConfig() c.MinGenesisActiveValidatorCount = 16384 @@ -31,9 +28,6 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - }, }, AggregationBits: bitfield.Bitlist{0xFF, 0xFF, 0xFF}, } @@ -48,9 +42,8 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } indices, err := unslashedAttestingIndices(state, atts) @@ -83,9 +76,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{}, - }, + Target: ðpb.Checkpoint{Epoch: 0}}, AggregationBits: bitfield.Bitlist{0xFF, 0xFF, 0xFF}, } } @@ -99,9 +90,8 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } indices, err := unslashedAttestingIndices(state, atts) @@ -124,11 +114,9 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, + Slot: uint64(i), }, AggregationBits: bitfield.Bitlist{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01}, @@ -146,11 +134,11 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { balances[i] = params.BeaconConfig().MaxEffectiveBalance } state := &pb.BeaconState{ - Slot: 0, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - Validators: validators, - Balances: balances, + Slot: 2, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + + Validators: validators, + Balances: balances, } balance, err := AttestingBalance(state, atts) @@ -172,20 +160,20 @@ func TestMatchAttestations_PrevEpoch(t *testing.T) { // The correct vote for target is '1' // The correct vote for head is '2' prevAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{}}}, // source - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{3}}}}, // source - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{}}}, // source, head - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{4}, Target: ðpb.Checkpoint{}}}, // source - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target, head - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, // source, head + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, // source + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{3}}}}, // source + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{}}}, // source, head + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{4}, Target: ðpb.Checkpoint{}}}, // source + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target, head + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // source, target + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, // source, head } currentAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + e + 1}, Target: ðpb.Checkpoint{}}}, // none - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + e + 1}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none } blockRoots := make([][]byte, 128) @@ -198,7 +186,6 @@ func TestMatchAttestations_PrevEpoch(t *testing.T) { PreviousEpochAttestations: prevAtts, BlockRoots: blockRoots, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } mAtts, err := MatchAttestations(state, 0) @@ -207,35 +194,36 @@ func TestMatchAttestations_PrevEpoch(t *testing.T) { } wantedSrcAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{3}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{4}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{3}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{4}, Target: ðpb.Checkpoint{}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, } if !reflect.DeepEqual(mAtts.source, wantedSrcAtts) { t.Error("source attestations don't match") } wantedTgtAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, } if !reflect.DeepEqual(mAtts.Target, wantedTgtAtts) { t.Error("target attestations don't match") } wantedHeadAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, } + if !reflect.DeepEqual(mAtts.head, wantedHeadAtts) { t.Error("head attestations don't match") } @@ -247,20 +235,20 @@ func TestMatchAttestations_CurrentEpoch(t *testing.T) { s := uint64(0) // slot // The correct epoch for source is the first epoch - // The correct vote for target is '65' - // The correct vote for head is '66' + // The correct vote for target is '33' + // The correct vote for head is '34' prevAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{}}}, // none - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{5}, Target: ðpb.Checkpoint{Root: []byte{1}}}}, // none + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{2}, Target: ðpb.Checkpoint{Root: []byte{6}}}}, // none } currentAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{}}}, // source - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, // source, target, head - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, // source, target - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, // source, head + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, // source + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, // source, target, head + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, // source, target + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, // source, head } blockRoots := make([][]byte, 128) @@ -280,26 +268,26 @@ func TestMatchAttestations_CurrentEpoch(t *testing.T) { } wantedSrcAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, } if !reflect.DeepEqual(mAtts.source, wantedSrcAtts) { t.Error("source attestations don't match") } wantedTgtAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, + {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{69}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, } if !reflect.DeepEqual(mAtts.Target, wantedTgtAtts) { t.Error("target attestations don't match") } wantedHeadAtts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{65}}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{Shard: s + 1}, BeaconBlockRoot: []byte{66}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{33}}}}, + {Data: ðpb.AttestationData{Slot: 33, Source: ðpb.Checkpoint{}, BeaconBlockRoot: []byte{34}, Target: ðpb.Checkpoint{Root: []byte{68}}}}, } if !reflect.DeepEqual(mAtts.head, wantedHeadAtts) { t.Error("head attestations don't match") @@ -313,245 +301,6 @@ func TestMatchAttestations_EpochOutOfBound(t *testing.T) { } } -func TestAttsForCrosslink_CanGetAttestations(t *testing.T) { - c := ðpb.Crosslink{ - DataRoot: []byte{'B'}, - } - atts := []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'A'}}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'B'}}, Target: ðpb.Checkpoint{}}}, // Selected - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'C'}}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'B'}}, Target: ðpb.Checkpoint{}}}} // Selected - - if !reflect.DeepEqual(attsForCrosslink(c, atts), []*pb.PendingAttestation{ - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'B'}}, Target: ðpb.Checkpoint{}}}, - {Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, Crosslink: ðpb.Crosslink{DataRoot: []byte{'B'}}, Target: ðpb.Checkpoint{}}}}) { - t.Error("Incorrect attestations for crosslink") - } -} - -func TestWinningCrosslink_CantGetMatchingAtts(t *testing.T) { - wanted := fmt.Sprintf("could not get matching attestations: input epoch: %d != current epoch: %d or previous epoch: %d", - 100, 0, 0) - _, _, err := WinningCrosslink(&pb.BeaconState{Slot: 0}, 0, 100) - if err.Error() != wanted { - t.Fatal(err) - } -} - -func TestWinningCrosslink_ReturnGenesisCrosslink(t *testing.T) { - e := params.BeaconConfig().SlotsPerEpoch - gs := uint64(0) // genesis slot - ge := uint64(0) // genesis epoch - - state := &pb.BeaconState{ - Slot: gs + e + 2, - PreviousEpochAttestations: []*pb.PendingAttestation{}, - BlockRoots: make([][]byte, 128), - CurrentCrosslinks: []*ethpb.Crosslink{{StartEpoch: ge}}, - } - - gCrosslink := ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: params.BeaconConfig().ZeroHash[:], - ParentRoot: params.BeaconConfig().ZeroHash[:], - } - - crosslink, indices, err := WinningCrosslink(state, 0, ge) - if err != nil { - t.Fatal(err) - } - if len(indices) != 0 { - t.Errorf("genesis crosslink indices is not 0, got: %d", len(indices)) - } - if !reflect.DeepEqual(crosslink, gCrosslink) { - t.Errorf("Did not get genesis crosslink, got: %v", crosslink) - } -} - -func TestWinningCrosslink_CanGetWinningRoot(t *testing.T) { - helpers.ClearAllCaches() - e := params.BeaconConfig().SlotsPerEpoch - gs := uint64(0) // genesis slot - ge := uint64(0) // genesis epoch - - atts := []*pb.PendingAttestation{ - { - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 1, - DataRoot: []byte{'A'}, - }, - Target: ðpb.Checkpoint{}, - Source: ðpb.Checkpoint{}, - }, - }, - { - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 1, - DataRoot: []byte{'B'}, // Winner - }, - Target: ðpb.Checkpoint{}, - Source: ðpb.Checkpoint{}, - }, - }, - { - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 1, - DataRoot: []byte{'C'}, - }, - Target: ðpb.Checkpoint{}, - Source: ðpb.Checkpoint{}, - }, - }, - } - - blockRoots := make([][]byte, 128) - for i := 0; i < len(blockRoots); i++ { - blockRoots[i] = []byte{byte(i + 1)} - } - - crosslinks := make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount) - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks[i] = ðpb.Crosslink{ - StartEpoch: ge, - Shard: 1, - DataRoot: []byte{'B'}, - } - } - state := &pb.BeaconState{ - Slot: gs + e + 2, - PreviousEpochAttestations: atts, - BlockRoots: blockRoots, - CurrentCrosslinks: crosslinks, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - - winner, indices, err := WinningCrosslink(state, 1, ge) - if err != nil { - t.Fatal(err) - } - if len(indices) != 0 { - t.Errorf("genesis crosslink indices is not 0, got: %d", len(indices)) - } - want := ðpb.Crosslink{StartEpoch: ge, Shard: 1, DataRoot: []byte{'B'}} - if !reflect.DeepEqual(winner, want) { - t.Errorf("Did not get wanted crosslink, got: %v, want %v", winner, want) - } -} - -func TestProcessCrosslinks_NoUpdate(t *testing.T) { - helpers.ClearAllCaches() - - validatorCount := 128 - validators := make([]*ethpb.Validator, validatorCount) - balances := make([]uint64, validatorCount) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, - } - balances[i] = params.BeaconConfig().MaxEffectiveBalance - } - blockRoots := make([][]byte, 128) - for i := 0; i < len(blockRoots); i++ { - blockRoots[i] = []byte{byte(i + 1)} - } - - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } - state := &pb.BeaconState{ - Slot: params.BeaconConfig().SlotsPerEpoch + 1, - Validators: validators, - Balances: balances, - BlockRoots: blockRoots, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, - } - newState, err := ProcessCrosslinks(state) - if err != nil { - t.Fatal(err) - } - - wanted := ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - } - // Since there has been no attestation, crosslink stayed the same. - if !reflect.DeepEqual(wanted, newState.CurrentCrosslinks[0]) { - t.Errorf("Did not get correct crosslink back") - } -} - -func TestProcessCrosslinks_SuccessfulUpdate(t *testing.T) { - e := params.BeaconConfig().SlotsPerEpoch - gs := uint64(0) // genesis slot - ge := uint64(0) // genesis epoch - - validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount/8) - balances := make([]uint64, params.BeaconConfig().MinGenesisActiveValidatorCount/8) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, - } - balances[i] = params.BeaconConfig().MaxEffectiveBalance - } - blockRoots := make([][]byte, 128) - for i := 0; i < len(blockRoots); i++ { - blockRoots[i] = []byte{byte(i + 1)} - } - - crosslinks := make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount) - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks[i] = ðpb.Crosslink{ - StartEpoch: ge, - DataRoot: []byte{'B'}, - } - } - var atts []*pb.PendingAttestation - startShard := uint64(960) - for s := uint64(0); s < params.BeaconConfig().SlotsPerEpoch; s++ { - atts = append(atts, &pb.PendingAttestation{ - Data: ðpb.AttestationData{Source: ðpb.Checkpoint{}, - Crosslink: ðpb.Crosslink{ - Shard: startShard + s, - DataRoot: []byte{'B'}, - }, - Target: ðpb.Checkpoint{Epoch: 0}, - }, - AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01}, - }) - } - state := &pb.BeaconState{ - Slot: gs + e + 2, - Validators: validators, - PreviousEpochAttestations: atts, - Balances: balances, - BlockRoots: blockRoots, - CurrentCrosslinks: crosslinks, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - newState, err := ProcessCrosslinks(state) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(crosslinks[0], newState.CurrentCrosslinks[0]) { - t.Errorf("Crosslink is not the same") - } -} - func TestBaseReward_AccurateRewards(t *testing.T) { helpers.ClearAllCaches() @@ -560,10 +309,10 @@ func TestBaseReward_AccurateRewards(t *testing.T) { b uint64 c uint64 }{ - {params.BeaconConfig().MinDepositAmount, params.BeaconConfig().MinDepositAmount, 404781}, - {30 * 1e9, 30 * 1e9, 2217026}, - {params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance, 2289739}, - {40 * 1e9, params.BeaconConfig().MaxEffectiveBalance, 2289739}, + {params.BeaconConfig().MinDepositAmount, params.BeaconConfig().MinDepositAmount, 505976}, + {30 * 1e9, 30 * 1e9, 2771282}, + {params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance, 2862174}, + {40 * 1e9, params.BeaconConfig().MaxEffectiveBalance, 2862174}, } for _, tt := range tests { helpers.ClearAllCaches() @@ -669,9 +418,9 @@ func TestProcessJustificationAndFinalization_ConsecutiveEpochs(t *testing.T) { if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.CurrentJustifiedCheckpoint.Epoch != 2 { t.Errorf("Wanted justified epoch: %d, got: %d", @@ -718,9 +467,9 @@ func TestProcessJustificationAndFinalization_JustifyCurrentEpoch(t *testing.T) { if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.CurrentJustifiedCheckpoint.Epoch != 2 { t.Errorf("Wanted justified epoch: %d, got: %d", @@ -767,9 +516,9 @@ func TestProcessJustificationAndFinalization_JustifyPrevEpoch(t *testing.T) { if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.PreviousJustifiedCheckpoint.Epoch != 0 { t.Errorf("Wanted previous justified epoch: %d, got: %d", @@ -913,17 +662,6 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { t.Errorf("effective balance incorrectly updated, got %d", s.Validators[0].EffectiveBalance) } - // Verify start shard is correctly updated. - if newS.StartShard != 64 { - t.Errorf("start shard incorrectly updated, got %d", 64) - } - - // Verify latest active index root is correctly updated in the right position. - pos := (ne + params.BeaconConfig().ActivationExitDelay) % params.BeaconConfig().EpochsPerHistoricalVector - if bytes.Equal(newS.ActiveIndexRoots[pos], params.BeaconConfig().ZeroHash[:]) { - t.Error("latest active index roots still zero hashes") - } - // Verify slashed balances correctly updated. if newS.Slashings[ce] != newS.Slashings[ne] { t.Errorf("wanted slashed balance %d, got %d", @@ -946,39 +684,12 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { } } -func TestCrosslinkDelta_NoOneAttested(t *testing.T) { - e := params.BeaconConfig().SlotsPerEpoch - - validatorCount := uint64(128) - state := buildState(e+2, validatorCount) - - rewards, penalties, err := crosslinkDelta(state) - if err != nil { - t.Fatal(err) - } - for i := uint64(0); i < validatorCount; i++ { - // Since no one attested, all the validators should gain 0 reward - if rewards[i] != 0 { - t.Errorf("Wanted reward balance 0, got %d", rewards[i]) - } - // Since no one attested, all the validators should get penalized the same - base, err := BaseReward(state, i) - if err != nil { - t.Fatal(err) - } - if penalties[i] != base { - t.Errorf("Wanted penalty balance %d, got %d", - base, penalties[i]) - } - } -} - func TestProcessRegistryUpdates_NoRotation(t *testing.T) { state := &pb.BeaconState{ Slot: 5 * params.BeaconConfig().SlotsPerEpoch, Validators: []*ethpb.Validator{ - {ExitEpoch: params.BeaconConfig().ActivationExitDelay}, - {ExitEpoch: params.BeaconConfig().ActivationExitDelay}, + {ExitEpoch: params.BeaconConfig().MaxSeedLookhead}, + {ExitEpoch: params.BeaconConfig().MaxSeedLookhead}, }, Balances: []uint64{ params.BeaconConfig().MaxEffectiveBalance, @@ -991,88 +702,13 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) { t.Fatal(err) } for i, validator := range newState.Validators { - if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay { + if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead { t.Errorf("Could not update registry %d, wanted exit slot %d got %d", - i, params.BeaconConfig().ActivationExitDelay, validator.ExitEpoch) + i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch) } } } -func TestCrosslinkDelta_SomeAttested(t *testing.T) { - helpers.ClearAllCaches() - e := params.BeaconConfig().SlotsPerEpoch - helpers.ClearShuffledValidatorCache() - state := buildState(e+2, params.BeaconConfig().MinGenesisActiveValidatorCount/8) - startShard := uint64(960) - atts := make([]*pb.PendingAttestation, 2) - for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, - Target: ðpb.Checkpoint{}, - Source: ðpb.Checkpoint{}, - }, - InclusionDelay: uint64(i + 100), - AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01}, - } - } - state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, Shard: startShard, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, Shard: startShard + 1, - } - - rewards, penalties, err := crosslinkDelta(state) - if err != nil { - t.Fatal(err) - } - - attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958} - for _, i := range attestedIndices { - // Since all these validators attested, they should get the same rewards. - want := uint64(12649) - if rewards[i] != want { - t.Errorf("Wanted reward balance %d, got %d", want, rewards[i]) - } - // Since all these validators attested, they shouldn't get penalized. - if penalties[i] != 0 { - t.Errorf("Wanted penalty balance 0, got %d", penalties[i]) - } - } - - nonAttestedIndices := []uint64{12, 23, 45, 79} - for _, i := range nonAttestedIndices { - base, err := BaseReward(state, i) - if err != nil { - t.Errorf("Could not get base reward: %v", err) - } - wanted := base - // Since all these validators did not attest, they shouldn't get rewarded. - if rewards[i] != 0 { - t.Errorf("Wanted reward balance 0, got %d", rewards[i]) - } - // Base penalties for not attesting. - if penalties[i] != wanted { - t.Errorf("Wanted penalty balance %d, got %d", wanted, penalties[i]) - } - } -} - -func TestCrosslinkDelta_CantGetWinningCrosslink(t *testing.T) { - state := buildState(0, 1) - - _, _, err := crosslinkDelta(state) - wanted := "could not get winning crosslink: could not get matching attestations" - if !strings.Contains(err.Error(), wanted) { - t.Fatalf("Got: %v, want: %v", err.Error(), wanted) - } -} - func TestAttestationDelta_CantGetBlockRoot(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch @@ -1105,10 +741,6 @@ func TestAttestationDelta_NoOneAttested(t *testing.T) { for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -1145,15 +777,10 @@ func TestAttestationDelta_SomeAttested(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount / 8 state := buildState(e+2, validatorCount) - startShard := uint64(960) atts := make([]*pb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -1162,18 +789,11 @@ func TestAttestationDelta_SomeAttested(t *testing.T) { } } state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } rewards, penalties, err := attestationDelta(state) if err != nil { t.Fatal(err) } - attestedBalance, err := AttestingBalance(state, atts) if err != nil { t.Error(err) @@ -1183,18 +803,20 @@ func TestAttestationDelta_SomeAttested(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{100, 106, 196, 641, 654, 1606} for _, i := range attestedIndices { base, err := BaseReward(state, i) if err != nil { t.Errorf("Could not get base reward: %v", err) } + // Base rewards for getting source right wanted := 3 * (base * attestedBalance / totalBalance) // Base rewards for proposer and attesters working together getting attestation - // on chain in the fatest manner + // on chain in the fastest manner proposerReward := base / params.BeaconConfig().ProposerRewardQuotient - wanted += (base - proposerReward) * params.BeaconConfig().MinAttestationInclusionDelay + wanted += (base - proposerReward) / params.BeaconConfig().MinAttestationInclusionDelay + if rewards[i] != wanted { t.Errorf("Wanted reward balance %d, got %d", wanted, rewards[i]) } @@ -1227,15 +849,10 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount / 8 state := buildState(e+4, validatorCount) - startShard := uint64(960) atts := make([]*pb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -1245,18 +862,11 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) { } state.PreviousEpochAttestations = atts state.FinalizedCheckpoint.Epoch = 0 - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } rewards, penalties, err := attestationDelta(state) if err != nil { t.Fatal(err) } - attestedBalance, err := AttestingBalance(state, atts) if err != nil { t.Error(err) @@ -1266,7 +876,7 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{100, 106, 196, 641, 654, 1606} for _, i := range attestedIndices { base, err := BaseReward(state, i) if err != nil { @@ -1346,10 +956,10 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) { state := &pb.BeaconState{ Slot: 5 * params.BeaconConfig().SlotsPerEpoch, Validators: []*ethpb.Validator{ - {ExitEpoch: params.BeaconConfig().ActivationExitDelay, - ActivationEpoch: 5 + params.BeaconConfig().ActivationExitDelay + 1}, - {ExitEpoch: params.BeaconConfig().ActivationExitDelay, - ActivationEpoch: 5 + params.BeaconConfig().ActivationExitDelay + 1}, + {ExitEpoch: params.BeaconConfig().MaxSeedLookhead, + ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1}, + {ExitEpoch: params.BeaconConfig().MaxSeedLookhead, + ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1}, }, FinalizedCheckpoint: ðpb.Checkpoint{}, } @@ -1358,9 +968,9 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) { t.Error(err) } for i, validator := range newState.Validators { - if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay { + if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead { t.Errorf("Could not update registry %d, wanted exit slot %d got %d", - i, params.BeaconConfig().ActivationExitDelay, validator.ExitEpoch) + i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch) } } } @@ -1385,9 +995,9 @@ func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) { t.Error(err) } for i, validator := range newState.Validators { - if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay+1 { + if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead+1 { t.Errorf("Could not update registry %d, wanted exit slot %d got %d", - i, params.BeaconConfig().ActivationExitDelay+1, validator.ExitEpoch) + i, params.BeaconConfig().MaxSeedLookhead+1, validator.ExitEpoch) } } } @@ -1424,7 +1034,7 @@ func TestProcessRegistryUpdates_CanExits(t *testing.T) { } func TestProcessRewardsAndPenalties_GenesisEpoch(t *testing.T) { - state := &pb.BeaconState{Slot: params.BeaconConfig().SlotsPerEpoch - 1, StartShard: 999} + state := &pb.BeaconState{Slot: params.BeaconConfig().SlotsPerEpoch - 1} newState, err := ProcessRewardsAndPenalties(state) if err != nil { t.Fatal(err) @@ -1439,15 +1049,10 @@ func TestProcessRewardsAndPenalties_SomeAttested(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount / 8 state := buildState(e+2, validatorCount) - startShard := uint64(960) atts := make([]*pb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -1456,26 +1061,17 @@ func TestProcessRewardsAndPenalties_SomeAttested(t *testing.T) { } } state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+2] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } state, err := ProcessRewardsAndPenalties(state) if err != nil { t.Fatal(err) } - wanted := uint64(31999949392) + wanted := uint64(31999873505) if state.Balances[0] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[0]) } - wanted = uint64(31999995452) + wanted = uint64(31999810265) if state.Balances[4] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[1]) @@ -1512,10 +1108,7 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState { Slot: slot, Balances: validatorBalances, Validators: validators, - CurrentCrosslinks: make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount), RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerSlashingsVector), Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10), FinalizedCheckpoint: ðpb.Checkpoint{}, diff --git a/beacon-chain/core/epoch/participation_test.go b/beacon-chain/core/epoch/participation_test.go index bf7e04fe0e..7ac2a09d6c 100644 --- a/beacon-chain/core/epoch/participation_test.go +++ b/beacon-chain/core/epoch/participation_test.go @@ -27,14 +27,7 @@ func TestComputeValidatorParticipation(t *testing.T) { balances[i] = params.BeaconConfig().MaxEffectiveBalance } - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 0}, Target: ðpb.Checkpoint{}}}} - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } + atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} s := &pb.BeaconState{ Slot: e*params.BeaconConfig().SlotsPerEpoch + 1, @@ -43,9 +36,6 @@ func TestComputeValidatorParticipation(t *testing.T) { BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index a25903867c..dc5e76c11c 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -13,7 +13,6 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute", visibility = ["//beacon-chain:__subpackages__"], deps = [ - "//beacon-chain/core/epoch:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index 7e032ec22a..eb2348f0e7 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -40,13 +40,7 @@ func ProcessAttestations( if err != nil { return nil, nil, err } - // Get attestation slot to find lowest inclusion delayed attestation for each attested validators. - aSlot, err := helpers.AttestationDataSlot(state, a.Data) - if err != nil { - return nil, nil, err - - } - vp = UpdateValidator(vp, v, indices, a, aSlot) + vp = UpdateValidator(vp, v, indices, a, a.Data.Slot) } bp = UpdateBalance(vp, bp) @@ -112,11 +106,7 @@ func SameTarget(state *pb.BeaconState, a *pb.PendingAttestation, e uint64) (bool // SameHead returns true if attestation `a` attested to the same block by attestation slot in state. func SameHead(state *pb.BeaconState, a *pb.PendingAttestation) (bool, error) { - aSlot, err := helpers.AttestationDataSlot(state, a.Data) - if err != nil { - return false, err - } - r, err := helpers.BlockRootAtSlot(state, aSlot) + r, err := helpers.BlockRootAtSlot(state, a.Data.Slot) if err != nil { return false, err } diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index f5803d7f53..164c5c9716 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -75,20 +75,15 @@ func TestUpdateBalance(t *testing.T) { func TestSameHead(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } beaconState.Slot = 1 att := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{Shard: 0}}} - attSlot, err := helpers.AttestationDataSlot(beaconState, att.Data) - if err != nil { - t.Fatal(err) - } + Target: ðpb.Checkpoint{Epoch: 0}}} r := []byte{'A'} - beaconState.BlockRoots[attSlot] = r + beaconState.BlockRoots[0] = r att.Data.BeaconBlockRoot = r same, err := precompute.SameHead(beaconState, &pb.PendingAttestation{Data: att.Data}) if err != nil { @@ -109,20 +104,15 @@ func TestSameHead(t *testing.T) { func TestSameTarget(t *testing.T) { deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } beaconState.Slot = 1 att := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{Shard: 0}}} - attSlot, err := helpers.AttestationDataSlot(beaconState, att.Data) - if err != nil { - t.Fatal(err) - } + Target: ðpb.Checkpoint{Epoch: 0}}} r := []byte{'A'} - beaconState.BlockRoots[attSlot] = r + beaconState.BlockRoots[0] = r att.Data.Target.Root = r same, err := precompute.SameTarget(beaconState, &pb.PendingAttestation{Data: att.Data}, 0) if err != nil { @@ -143,20 +133,15 @@ func TestSameTarget(t *testing.T) { func TestAttestedPrevEpoch(t *testing.T) { deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } beaconState.Slot = params.BeaconConfig().SlotsPerEpoch att := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{Shard: 960}}} - attSlot, err := helpers.AttestationDataSlot(beaconState, att.Data) - if err != nil { - t.Fatal(err) - } + Target: ðpb.Checkpoint{Epoch: 0}}} r := []byte{'A'} - beaconState.BlockRoots[attSlot] = r + beaconState.BlockRoots[0] = r att.Data.Target.Root = r att.Data.BeaconBlockRoot = r votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &pb.PendingAttestation{Data: att.Data}) @@ -176,20 +161,15 @@ func TestAttestedPrevEpoch(t *testing.T) { func TestAttestedCurrentEpoch(t *testing.T) { deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } beaconState.Slot = params.BeaconConfig().SlotsPerEpoch + 1 att := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 1}, - Crosslink: ðpb.Crosslink{}}} - attSlot, err := helpers.AttestationDataSlot(beaconState, att.Data) - if err != nil { - t.Fatal(err) - } + Target: ðpb.Checkpoint{Epoch: 1}}} r := []byte{'A'} - beaconState.BlockRoots[attSlot] = r + beaconState.BlockRoots[params.BeaconConfig().SlotsPerEpoch] = r att.Data.Target.Root = r att.Data.BeaconBlockRoot = r votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &pb.PendingAttestation{Data: att.Data}) @@ -212,7 +192,7 @@ func TestProcessAttestations(t *testing.T) { validators := uint64(64) deposits, _, _ := testutil.SetupInitialDeposits(t, validators) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -220,11 +200,11 @@ func TestProcessAttestations(t *testing.T) { bf := []byte{0xff} att1 := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{Shard: 960}}, AggregationBits: bf} + Target: ðpb.Checkpoint{Epoch: 0}}, + AggregationBits: bf} att2 := ðpb.Attestation{Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{Shard: 961}}, AggregationBits: bf} + Target: ðpb.Checkpoint{Epoch: 0}}, + AggregationBits: bf} beaconState.BlockRoots[0] = []byte{'A'} att1.Data.Target.Root = []byte{'A'} att1.Data.BeaconBlockRoot = []byte{'A'} diff --git a/beacon-chain/core/epoch/precompute/justification_finalization_test.go b/beacon-chain/core/epoch/precompute/justification_finalization_test.go index a17078ed51..bf36f9a209 100644 --- a/beacon-chain/core/epoch/precompute/justification_finalization_test.go +++ b/beacon-chain/core/epoch/precompute/justification_finalization_test.go @@ -40,9 +40,9 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.CurrentJustifiedCheckpoint.Epoch != 2 { t.Errorf("Wanted justified epoch: %d, got: %d", @@ -90,9 +90,9 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.CurrentJustifiedCheckpoint.Epoch != 2 { t.Errorf("Wanted justified epoch: %d, got: %d", @@ -139,9 +139,9 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi if err != nil { t.Fatal(err) } - if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(128)}) { + if !bytes.Equal(newState.CurrentJustifiedCheckpoint.Root, []byte{byte(64)}) { t.Errorf("Wanted current justified root: %v, got: %v", - []byte{byte(128)}, newState.CurrentJustifiedCheckpoint.Root) + []byte{byte(64)}, newState.CurrentJustifiedCheckpoint.Root) } if newState.PreviousJustifiedCheckpoint.Epoch != 0 { t.Errorf("Wanted previous justified epoch: %d, got: %d", diff --git a/beacon-chain/core/epoch/precompute/reward_penalty.go b/beacon-chain/core/epoch/precompute/reward_penalty.go index ef111faa10..16ff60bb66 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty.go @@ -2,7 +2,6 @@ package precompute import ( "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared/mathutil" @@ -30,14 +29,9 @@ func ProcessRewardsAndPenaltiesPrecompute(state *pb.BeaconState, bp *Balance, vp if err != nil { return nil, errors.Wrap(err, "could not get attestation delta") } - clRewards, clPenalties, err := crosslinkDeltaPreCompute(state, bp, vp) - if err != nil { - return nil, errors.Wrapf(err, "could not get crosslink delta") - } - for i := 0; i < len(state.Validators); i++ { - state = helpers.IncreaseBalance(state, uint64(i), attsRewards[i]+clRewards[i]+proposerRewards[i]) - state = helpers.DecreaseBalance(state, uint64(i), attsPenalties[i]+clPenalties[i]) + state = helpers.IncreaseBalance(state, uint64(i), attsRewards[i]+proposerRewards[i]) + state = helpers.DecreaseBalance(state, uint64(i), attsPenalties[i]) } return state, nil } @@ -70,8 +64,7 @@ func attestationDelta(state *pb.BeaconState, bp *Balance, v *Validator) (uint64, r += br * bp.PrevEpochAttesters / bp.CurrentEpoch proposerReward := br / params.BeaconConfig().ProposerRewardQuotient maxAtteserReward := br - proposerReward - slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch - r += maxAtteserReward * (slotsPerEpoch + params.BeaconConfig().MinAttestationInclusionDelay - v.InclusionDistance) / slotsPerEpoch + r += maxAtteserReward / v.InclusionDistance } else { p += br } @@ -118,48 +111,3 @@ func proposerDeltaPrecompute(state *pb.BeaconState, bp *Balance, vp []*Validator } return rewards, nil } - -// This computes the rewards and penalties differences for individual validators based on the -// crosslink records. -func crosslinkDeltaPreCompute(state *pb.BeaconState, bp *Balance, vp []*Validator) ([]uint64, []uint64, error) { - rewards := make([]uint64, len(state.Validators)) - penalties := make([]uint64, len(state.Validators)) - prevEpoch := helpers.PrevEpoch(state) - count, err := helpers.CommitteeCount(state, prevEpoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get epoch committee count") - } - startShard, err := helpers.StartShard(state, prevEpoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get epoch start shard") - } - for i := uint64(0); i < count; i++ { - shard := (startShard + i) % params.BeaconConfig().ShardCount - committee, err := helpers.CrosslinkCommittee(state, prevEpoch, shard) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get crosslink's committee") - } - _, attestingIndices, err := epoch.WinningCrosslink(state, shard, prevEpoch) - if err != nil { - return nil, nil, errors.Wrap(err, "could not get winning crosslink") - } - - attested := make(map[uint64]bool) - // Construct a map to look up validators that voted for crosslink. - for _, index := range attestingIndices { - attested[index] = true - } - committeeBalance := helpers.TotalBalance(state, committee) - attestingBalance := helpers.TotalBalance(state, attestingIndices) - - for _, index := range committee { - base := vp[index].CurrentEpochEffectiveBalance * params.BeaconConfig().BaseRewardFactor / mathutil.IntegerSquareRoot(bp.CurrentEpoch) / params.BeaconConfig().BaseRewardsPerEpoch - if _, ok := attested[index]; ok { - rewards[index] += base * attestingBalance / committeeBalance - } else { - penalties[index] += base - } - } - } - return rewards, penalties, nil -} diff --git a/beacon-chain/core/epoch/precompute/reward_penalty_test.go b/beacon-chain/core/epoch/precompute/reward_penalty_test.go index ead3c5d267..d442cc1f52 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -17,15 +17,10 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) state := buildState(e+3, validatorCount) - startShard := uint64(960) atts := make([]*pb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -34,15 +29,6 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { } } state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+2] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } vp, bp := New(context.Background(), state) vp, bp, err := ProcessAttestations(context.Background(), state, vp, bp) @@ -56,14 +42,14 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { } // Indices that voted everything except for head, lost a bit money - wanted := uint64(31999995452) + wanted := uint64(31999810265) if state.Balances[4] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[4]) } // Indices that did not vote, lost more money - wanted = uint64(31999949392) + wanted = uint64(31999873505) if state.Balances[0] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[0]) @@ -75,15 +61,10 @@ func TestAttestationDeltaPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) state := buildState(e+2, validatorCount) - startShard := uint64(960) atts := make([]*pb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { atts[i] = &pb.PendingAttestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, }, @@ -92,12 +73,6 @@ func TestAttestationDeltaPrecompute(t *testing.T) { } } state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, - } vp, bp := New(context.Background(), state) vp, bp, err := ProcessAttestations(context.Background(), state, vp, bp) @@ -118,7 +93,7 @@ func TestAttestationDeltaPrecompute(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{100, 106, 196, 641, 654, 1606} for _, i := range attestedIndices { base, err := epoch.BaseReward(state, i) if err != nil { @@ -157,78 +132,6 @@ func TestAttestationDeltaPrecompute(t *testing.T) { } } -func TestCrosslinkDeltaPrecompute(t *testing.T) { - helpers.ClearAllCaches() - e := params.BeaconConfig().SlotsPerEpoch - helpers.ClearShuffledValidatorCache() - validatorCount := uint64(2048) - state := buildState(e+2, validatorCount) - startShard := uint64(960) - atts := make([]*pb.PendingAttestation, 2) - for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: startShard + uint64(i), - DataRoot: []byte{'A'}, - }, - Target: ðpb.Checkpoint{}, - Source: ðpb.Checkpoint{}, - }, - InclusionDelay: uint64(i + 100), - AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01}, - } - } - state.PreviousEpochAttestations = atts - state.CurrentCrosslinks[startShard] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, Shard: startShard, - } - state.CurrentCrosslinks[startShard+1] = ðpb.Crosslink{ - DataRoot: []byte{'A'}, Shard: startShard + 1, - } - - vp, bp := New(context.Background(), state) - vp, bp, err := ProcessAttestations(context.Background(), state, vp, bp) - if err != nil { - t.Fatal(err) - } - - rewards, penalties, err := crosslinkDeltaPreCompute(state, bp, vp) - if err != nil { - t.Fatal(err) - } - - attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958} - for _, i := range attestedIndices { - // Since all these validators attested, they should get the same rewards. - want := uint64(12649) - if rewards[i] != want { - t.Errorf("Wanted reward balance %d, got %d", want, rewards[i]) - } - // Since all these validators attested, they shouldn't get penalized. - if penalties[i] != 0 { - t.Errorf("Wanted penalty balance 0, got %d", penalties[i]) - } - } - - nonAttestedIndices := []uint64{12, 23, 45, 79} - for _, i := range nonAttestedIndices { - base, err := epoch.BaseReward(state, i) - if err != nil { - t.Errorf("Could not get base reward: %v", err) - } - wanted := base - // Since all these validators did not attest, they shouldn't get rewarded. - if rewards[i] != 0 { - t.Errorf("Wanted reward balance 0, got %d", rewards[i]) - } - // Base penalties for not attesting. - if penalties[i] != wanted { - t.Errorf("Wanted penalty balance %d, got %d", wanted, penalties[i]) - } - } -} - func buildState(slot uint64, validatorCount uint64) *pb.BeaconState { validators := make([]*ethpb.Validator, validatorCount) for i := 0; i < len(validators); i++ { @@ -259,10 +162,7 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState { Slot: slot, Balances: validatorBalances, Validators: validators, - CurrentCrosslinks: make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount), RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerSlashingsVector), Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10), FinalizedCheckpoint: ðpb.Checkpoint{}, diff --git a/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go b/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go deleted file mode 100644 index f9f7acde0b..0000000000 --- a/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package spectest - -import ( - "testing" -) - -func TestCrosslinksProcessingMainnet(t *testing.T) { - runCrosslinkProcessingTests(t, "mainnet") -} diff --git a/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go b/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go deleted file mode 100644 index f52b4da01e..0000000000 --- a/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package spectest - -import ( - "testing" -) - -func TestCrosslinksProcessingMinimal(t *testing.T) { - runCrosslinkProcessingTests(t, "minimal") -} diff --git a/beacon-chain/core/epoch/spectest/crosslink_test.go b/beacon-chain/core/epoch/spectest/crosslink_test.go deleted file mode 100644 index cf072f39e2..0000000000 --- a/beacon-chain/core/epoch/spectest/crosslink_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package spectest - -import ( - "path" - "testing" - - "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/shared/params/spectest" - "github.com/prysmaticlabs/prysm/shared/testutil" -) - -func runCrosslinkProcessingTests(t *testing.T, config string) { - if err := spectest.SetConfig(config); err != nil { - t.Fatal(err) - } - - testFolders, testsFolderPath := testutil.TestFolders(t, config, "epoch_processing/crosslinks/pyspec_tests") - for _, folder := range testFolders { - t.Run(folder.Name(), func(t *testing.T) { - folderPath := path.Join(testsFolderPath, folder.Name()) - testutil.RunEpochOperationTest(t, folderPath, processCrosslinksWrapper) - }) - } -} - -func processCrosslinksWrapper(t *testing.T, state *pb.BeaconState) (*pb.BeaconState, error) { - state, err := epoch.ProcessCrosslinks(state) - if err != nil { - t.Fatalf("could not process crosslinks: %v", err) - } - return state, nil -} diff --git a/beacon-chain/core/epoch/spectest/justification_and_finalization_minimal_test.go b/beacon-chain/core/epoch/spectest/justification_and_finalization_minimal_test.go index 992821791f..57775ffc13 100644 --- a/beacon-chain/core/epoch/spectest/justification_and_finalization_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/justification_and_finalization_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestJustificationAndFinalizationMinimal(t *testing.T) { - t.Skip("Fails for could not get target atts current epoch") runJustificationAndFinalizationTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go b/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go index 2df30f929b..d09f080ae5 100644 --- a/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go +++ b/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go @@ -1,7 +1,9 @@ package spectest import ( + "bytes" "context" + "fmt" "path" "testing" @@ -32,19 +34,19 @@ func runJustificationAndFinalizationTests(t *testing.T, config string) { // This is a subset of state.ProcessEpoch. The spec test defines input data for // `justification_and_finalization` only. func processJustificationAndFinalizationWrapper(t *testing.T, state *pb.BeaconState) (*pb.BeaconState, error) { - prevEpochAtts, err := epoch.MatchAttestations(state, helpers.PrevEpoch(state)) + prevEpochAtts, err := targetAtts(state, helpers.PrevEpoch(state)) if err != nil { t.Fatalf("could not get target atts prev epoch %d: %v", helpers.PrevEpoch(state), err) } - currentEpochAtts, err := epoch.MatchAttestations(state, helpers.CurrentEpoch(state)) + currentEpochAtts, err := targetAtts(state, helpers.CurrentEpoch(state)) if err != nil { t.Fatalf("could not get target atts current epoch %d: %v", helpers.CurrentEpoch(state), err) } - prevEpochAttestedBalance, err := epoch.AttestingBalance(state, prevEpochAtts.Target) + prevEpochAttestedBalance, err := epoch.AttestingBalance(state, prevEpochAtts) if err != nil { t.Fatalf("could not get attesting balance prev epoch: %v", err) } - currentEpochAttestedBalance, err := epoch.AttestingBalance(state, currentEpochAtts.Target) + currentEpochAttestedBalance, err := epoch.AttestingBalance(state, currentEpochAtts) if err != nil { t.Fatalf("could not get attesting balance current epoch: %v", err) } @@ -72,3 +74,36 @@ func processJustificationAndFinalizationPrecomputeWrapper(t *testing.T, state *p return state, nil } + +func targetAtts(state *pb.BeaconState, epoch uint64) ([]*pb.PendingAttestation, error) { + currentEpoch := helpers.CurrentEpoch(state) + previousEpoch := helpers.PrevEpoch(state) + + // Input epoch for matching the source attestations has to be within range + // of current epoch & previous epoch. + if epoch != currentEpoch && epoch != previousEpoch { + return nil, fmt.Errorf("input epoch: %d != current epoch: %d or previous epoch: %d", + epoch, currentEpoch, previousEpoch) + } + + // Decide if the source attestations are coming from current or previous epoch. + var srcAtts []*pb.PendingAttestation + if epoch == currentEpoch { + srcAtts = state.CurrentEpochAttestations + } else { + srcAtts = state.PreviousEpochAttestations + } + targetRoot, err := helpers.BlockRoot(state, epoch) + if err != nil { + return nil, err + } + + tgtAtts := make([]*pb.PendingAttestation, 0, len(srcAtts)) + for _, srcAtt := range srcAtts { + if bytes.Equal(srcAtt.Data.Target.Root, targetRoot) { + tgtAtts = append(tgtAtts, srcAtt) + } + } + + return tgtAtts, nil +} diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index b8fe0ab078..2e5e19e02c 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -34,9 +34,6 @@ go_library( "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", - "@com_github_prysmaticlabs_go_ssz//:go_default_library", - "@org_golang_google_grpc//codes:go_default_library", - "@org_golang_google_grpc//status:go_default_library", ], ) @@ -56,7 +53,6 @@ go_test( embed = [":go_default_library"], shard_count = 2, deps = [ - "//beacon-chain/core/state:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/bls:go_default_library", @@ -64,11 +60,8 @@ go_test( "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", - "//shared/testutil:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", - "@org_golang_google_grpc//codes:go_default_library", - "@org_golang_google_grpc//status:go_default_library", ], ) diff --git a/beacon-chain/core/helpers/attestation.go b/beacon-chain/core/helpers/attestation.go index 246a8fc24f..175cade62b 100644 --- a/beacon-chain/core/helpers/attestation.go +++ b/beacon-chain/core/helpers/attestation.go @@ -3,11 +3,8 @@ package helpers import ( "github.com/gogo/protobuf/proto" "github.com/pkg/errors" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" - - "github.com/prysmaticlabs/prysm/shared/params" ) var ( @@ -22,39 +19,6 @@ var ( ErrAttestationAggregationBitsOverlap = errors.New("overlapping aggregation bits") ) -// AttestationDataSlot returns current slot of AttestationData for given state -// -// Spec pseudocode definition: -// def get_attestation_data_slot(state: BeaconState, data: AttestationData) -> Slot: -// """ -// Return the slot corresponding to the attestation ``data``. -// """ -// committee_count = get_committee_count(state, data.target.epoch) -// offset = (data.crosslink.shard + SHARD_COUNT - get_start_shard(state, data.target.epoch)) % SHARD_COUNT -// return Slot(compute_start_slot_of_epoch(data.target.epoch) + offset // (committee_count // SLOTS_PER_EPOCH)) -func AttestationDataSlot(state *pb.BeaconState, data *ethpb.AttestationData) (uint64, error) { - if state == nil { - return 0, ErrAttestationDataSlotNilState - } - if data == nil { - return 0, ErrAttestationDataSlotNilData - } - - committeeCount, err := CommitteeCount(state, data.Target.Epoch) - if err != nil { - return 0, err - } - - epochStartShardNumber, err := StartShard(state, data.Target.Epoch) - if err != nil { // This should never happen if CommitteeCount was successful - return 0, errors.Wrap(err, "could not determine epoch start shard") - } - offset := (data.Crosslink.Shard + params.BeaconConfig().ShardCount - - epochStartShardNumber) % params.BeaconConfig().ShardCount - - return StartSlot(data.Target.Epoch) + (offset / (committeeCount / params.BeaconConfig().SlotsPerEpoch)), nil -} - // AggregateAttestations such that the minimal number of attestations are returned. // Note: this is currently a naive implementation to the order of O(n^2). func AggregateAttestations(atts []*ethpb.Attestation) ([]*ethpb.Attestation, error) { diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index eafdf8689d..675a7f573b 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -9,88 +9,10 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - "github.com/prysmaticlabs/prysm/beacon-chain/core/state" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" - "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/testutil" ) -func TestAttestationDataSlot_OK(t *testing.T) { - deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) - if err != nil { - t.Fatal(err) - } - offset := uint64(0) - committeeCount, _ := helpers.CommitteeCount(beaconState, 0) - expect := offset / (committeeCount / params.BeaconConfig().SlotsPerEpoch) - attSlot, err := helpers.AttestationDataSlot(beaconState, ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, - }) - if err != nil { - t.Fatal(err) - } - if attSlot != expect { - t.Errorf("Expected %d, received %d", expect, attSlot) - } -} - -func TestAttestationDataSlot_ReturnsErrorWithNilState(t *testing.T) { - s, err := helpers.AttestationDataSlot(nil /*state*/, ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, - }) - if err != helpers.ErrAttestationDataSlotNilState { - t.Errorf("Expected an error, but received %v", err) - t.Logf("attestation slot=%v", s) - } -} - -func TestAttestationDataSlot_ReturnsErrorWithNilData(t *testing.T) { - s, err := helpers.AttestationDataSlot(&pb.BeaconState{}, nil /*data*/) - if err != helpers.ErrAttestationDataSlotNilData { - t.Errorf("Expected an error, but received %v", err) - t.Logf("attestation slot=%v", s) - } -} - -func TestAttestationDataSlot_ReturnsErrorWithErroneousTargetEpoch(t *testing.T) { - deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) - if err != nil { - t.Fatal(err) - } - s, err := helpers.AttestationDataSlot(beaconState, ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 1<<63 - 1 /* Far future epoch */}, - }) - if err == nil { - t.Error("Expected an error, but received nil") - t.Logf("attestation slot=%v", s) - } -} - -func TestAttestationDataSlot_ReturnsErrorWhenTargetEpochLessThanCurrentEpoch(t *testing.T) { - deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) - if err != nil { - t.Fatal(err) - } - s, err := helpers.AttestationDataSlot(beaconState, ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 2}, - }) - if err == nil { - t.Error("Expected an error, but received nil") - t.Logf("attestation slot=%v", s) - } -} - func TestAggregateAttestation(t *testing.T) { tests := []struct { a1 *ethpb.Attestation @@ -164,11 +86,11 @@ func TestAggregateAttestations(t *testing.T) { { name: "two attestations with no overlap", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000001, 0b1}, - bitfield.Bitlist{0b00000010, 0b1}, + {0b00000001, 0b1}, + {0b00000010, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000011, 0b1}, + {0b00000011, 0b1}, }, }, { @@ -188,57 +110,57 @@ func TestAggregateAttestations(t *testing.T) { { name: "two attestations with overlap", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000101, 0b1}, - bitfield.Bitlist{0b00000110, 0b1}, + {0b00000101, 0b1}, + {0b00000110, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000101, 0b1}, - bitfield.Bitlist{0b00000110, 0b1}, + {0b00000101, 0b1}, + {0b00000110, 0b1}, }, }, { name: "some attestations overlap", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00001001, 0b1}, - bitfield.Bitlist{0b00010110, 0b1}, - bitfield.Bitlist{0b00001010, 0b1}, - bitfield.Bitlist{0b00110001, 0b1}, + {0b00001001, 0b1}, + {0b00010110, 0b1}, + {0b00001010, 0b1}, + {0b00110001, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00111011, 0b1}, - bitfield.Bitlist{0b00011111, 0b1}, + {0b00111011, 0b1}, + {0b00011111, 0b1}, }, }, { name: "some attestations produce duplicates which are removed", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000101, 0b1}, - bitfield.Bitlist{0b00000110, 0b1}, - bitfield.Bitlist{0b00001010, 0b1}, - bitfield.Bitlist{0b00001001, 0b1}, + {0b00000101, 0b1}, + {0b00000110, 0b1}, + {0b00001010, 0b1}, + {0b00001001, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00001111, 0b1}, // both 0&1 and 2&3 produce this bitlist + {0b00001111, 0b1}, // both 0&1 and 2&3 produce this bitlist }, }, { name: "two attestations where one is fully contained within the other", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000001, 0b1}, - bitfield.Bitlist{0b00000011, 0b1}, + {0b00000001, 0b1}, + {0b00000011, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000011, 0b1}, + {0b00000011, 0b1}, }, }, { name: "two attestations where one is fully contained within the other reversed", inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000011, 0b1}, - bitfield.Bitlist{0b00000001, 0b1}, + {0b00000011, 0b1}, + {0b00000001, 0b1}, }, want: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000011, 0b1}, + {0b00000011, 0b1}, }, }, } diff --git a/beacon-chain/core/helpers/cache.go b/beacon-chain/core/helpers/cache.go index 62fd284856..ffa6276784 100644 --- a/beacon-chain/core/helpers/cache.go +++ b/beacon-chain/core/helpers/cache.go @@ -4,11 +4,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/cache" ) -// ClearShuffledValidatorCache clears the shuffled indices cache from scratch. -func ClearShuffledValidatorCache() { - shuffledIndicesCache = cache.NewShuffledIndicesCache() -} - // ClearActiveCountCache restarts the active validator count cache from scratch. func ClearActiveCountCache() { activeCountCache = cache.NewActiveCountCache() @@ -28,5 +23,4 @@ func ActiveIndicesKeys() []string { func ClearAllCaches() { ClearActiveIndicesCache() ClearActiveCountCache() - ClearShuffledValidatorCache() } diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index 20fdf0608e..7516ff51e5 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -6,82 +6,64 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/cache" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) -var shuffledIndicesCache = cache.NewShuffledIndicesCache() var committeeCache = cache.NewCommitteeCache() -// CommitteeCount returns the number of crosslink committees of an epoch. +// CommitteeCountAtSlot returns the number of crosslink committees of a slot. // // Spec pseudocode definition: -// def get_committee_count(state: BeaconState, epoch: Epoch) -> uint64: +// def get_committee_count_at_slot(state: BeaconState, slot: Slot) -> uint64: // """ -// Return the number of committees at ``epoch``. +// Return the number of committees at ``slot``. // """ -// committees_per_slot = max(1, min( -// SHARD_COUNT // SLOTS_PER_EPOCH, +// epoch = compute_epoch_at_slot(slot) +// return max(1, min( +// MAX_COMMITTEES_PER_SLOT, // len(get_active_validator_indices(state, epoch)) // SLOTS_PER_EPOCH // TARGET_COMMITTEE_SIZE, // )) -// return committees_per_slot * SLOTS_PER_EPOCH -func CommitteeCount(state *pb.BeaconState, epoch uint64) (uint64, error) { - if featureconfig.Get().EnableNewCache { - count, exists, err := committeeCache.CommitteeCount(epoch) - if err != nil { - return 0, errors.Wrap(err, "could not interface with committee cache") - } - if exists { - return count, nil - } - } - - minCommitteePerSlot := uint64(1) - // Max committee count per slot will be 0 when shard count is less than epoch length, this - // covers the special case to ensure there's always 1 max committee count per slot. - var committeeSizesPerSlot = minCommitteePerSlot - if params.BeaconConfig().ShardCount/params.BeaconConfig().SlotsPerEpoch > minCommitteePerSlot { - committeeSizesPerSlot = params.BeaconConfig().ShardCount / params.BeaconConfig().SlotsPerEpoch - } +func CommitteeCountAtSlot(state *pb.BeaconState, slot uint64) (uint64, error) { + epoch := SlotToEpoch(slot) count, err := ActiveValidatorCount(state, epoch) if err != nil { return 0, errors.Wrap(err, "could not get active count") } - - var currCommitteePerSlot = count / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize - - if currCommitteePerSlot > committeeSizesPerSlot { - return committeeSizesPerSlot * params.BeaconConfig().SlotsPerEpoch, nil + var committeePerSlot = count / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize + if committeePerSlot > params.BeaconConfig().MaxCommitteesPerSlot { + return params.BeaconConfig().MaxCommitteesPerSlot, nil } - if currCommitteePerSlot < 1 { - return minCommitteePerSlot * params.BeaconConfig().SlotsPerEpoch, nil + if committeePerSlot == 0 { + return 1, nil } - return currCommitteePerSlot * params.BeaconConfig().SlotsPerEpoch, nil + return committeePerSlot, nil } -// CrosslinkCommittee returns the crosslink committee of a given epoch. +// BeaconCommittee returns the crosslink committee of a given epoch. // // Spec pseudocode definition: -// def get_crosslink_committee(state: BeaconState, epoch: Epoch, shard: Shard) -> Sequence[ValidatorIndex]: +// def get_beacon_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]: // """ -// Return the crosslink committee at ``epoch`` for ``shard``. +// Return the beacon committee at ``slot`` for ``index``. // """ +// epoch = compute_epoch_at_slot(slot) +// committees_per_slot = get_committee_count_at_slot(state, slot) +// epoch_offset = index + (slot % SLOTS_PER_EPOCH) * committees_per_slot // return compute_committee( // indices=get_active_validator_indices(state, epoch), -// seed=get_seed(state, epoch), -// index=(shard + SHARD_COUNT - get_start_shard(state, epoch)) % SHARD_COUNT, -// count=get_committee_count(state, epoch), +// seed=get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), +// index=epoch_offset, +// count=committees_per_slot * SLOTS_PER_EPOCH, // ) -func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]uint64, error) { +func BeaconCommittee(state *pb.BeaconState, slot uint64, index uint64) ([]uint64, error) { + epoch := SlotToEpoch(slot) if featureconfig.Get().EnableNewCache { - indices, err := committeeCache.ShuffledIndices(epoch, shard) + indices, err := committeeCache.ShuffledIndices(slot, index) if err != nil { return nil, errors.Wrap(err, "could not interface with committee cache") } @@ -90,7 +72,14 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui } } - seed, err := Seed(state, epoch) + committeesPerSlot, err := CommitteeCountAtSlot(state, slot) + if err != nil { + return nil, errors.Wrap(err, "could not get committee count at slot") + } + epochOffset := index + (slot%params.BeaconConfig().SlotsPerEpoch)*committeesPerSlot + count := committeesPerSlot * params.BeaconConfig().SlotsPerEpoch + + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { return nil, errors.Wrap(err, "could not get seed") } @@ -99,20 +88,7 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui if err != nil { return nil, errors.Wrap(err, "could not get active indices") } - - startShard, err := StartShard(state, epoch) - if err != nil { - return nil, errors.Wrap(err, "could not get start shard") - } - - shardCount := params.BeaconConfig().ShardCount - currentShard := (shard + shardCount - startShard) % shardCount - committeeCount, err := CommitteeCount(state, epoch) - if err != nil { - return nil, errors.Wrap(err, "could not get committee count") - } - - return ComputeCommittee(indices, seed, currentShard, committeeCount) + return ComputeCommittee(indices, seed, epochOffset, count) } // ComputeCommittee returns the requested shuffled committee out of the total committees using @@ -130,40 +106,25 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui // end = (len(indices) * (index + 1)) // count // return [indices[compute_shuffled_index(ValidatorIndex(i), len(indices), seed)] for i in range(start, end) func ComputeCommittee( - validatorIndices []uint64, + indices []uint64, seed [32]byte, - indexShard uint64, - totalCommittees uint64, + index uint64, + count uint64, ) ([]uint64, error) { - validatorCount := uint64(len(validatorIndices)) - start := sliceutil.SplitOffset(validatorCount, totalCommittees, indexShard) - end := sliceutil.SplitOffset(validatorCount, totalCommittees, indexShard+1) + validatorCount := uint64(len(indices)) + start := sliceutil.SplitOffset(validatorCount, count, index) + end := sliceutil.SplitOffset(validatorCount, count, index+1) - // Use cached shuffled indices list if we have seen the seed before. - cachedShuffledList, err := shuffledIndicesCache.IndicesByIndexSeed(indexShard, seed[:]) - if err != nil { - return nil, err - } - if cachedShuffledList != nil { - return cachedShuffledList, nil - } - - // Save the shuffled indices in cache, this is only needed once per epoch or once per new shard index. + // Save the shuffled indices in cache, this is only needed once per epoch or once per new committee index. shuffledIndices := make([]uint64, end-start) for i := start; i < end; i++ { permutedIndex, err := ShuffledIndex(i, validatorCount, seed) if err != nil { return []uint64{}, errors.Wrapf(err, "could not get shuffled index at index %d", i) } - shuffledIndices[i-start] = validatorIndices[permutedIndex] - } - if err := shuffledIndicesCache.AddShuffledValidatorList(&cache.IndicesByIndexSeed{ - Index: indexShard, - Seed: seed[:], - ShuffledIndices: shuffledIndices, - }); err != nil { - return []uint64{}, errors.Wrap(err, "could not add shuffled indices list to cache") + shuffledIndices[i-start] = indices[permutedIndex] } + return shuffledIndices, nil } @@ -176,10 +137,10 @@ func ComputeCommittee( // """ // Return the set of attesting indices corresponding to ``data`` and ``bits``. // """ -// committee = get_crosslink_committee(state, data.target.epoch, data.crosslink.shard) +// committee = get_beacon_committee(state, data.slot, data.index) // return set(index for i, index in enumerate(committee) if bits[i]) func AttestingIndices(state *pb.BeaconState, data *ethpb.AttestationData, bf bitfield.Bitfield) ([]uint64, error) { - committee, err := CrosslinkCommittee(state, data.Target.Epoch, data.Crosslink.Shard) + committee, err := BeaconCommittee(state, data.Slot, data.Index) if err != nil { return nil, errors.Wrap(err, "could not get committee") } @@ -197,6 +158,77 @@ func AttestingIndices(state *pb.BeaconState, data *ethpb.AttestationData, bf bit return indices, nil } +// CommitteeAssignment is used to query committee assignment from +// current and previous epoch. +// +// Spec pseudocode definition: +// def get_committee_assignment(state: BeaconState, +// epoch: Epoch, +// validator_index: ValidatorIndex +// ) -> Optional[Tuple[Sequence[ValidatorIndex], CommitteeIndex, Slot]]: +// """ +// Return the committee assignment in the ``epoch`` for ``validator_index``. +// ``assignment`` returned is a tuple of the following form: +// * ``assignment[0]`` is the list of validators in the committee +// * ``assignment[1]`` is the index to which the committee is assigned +// * ``assignment[2]`` is the slot at which the committee is assigned +// Return None if no assignment. +// """ +// next_epoch = get_current_epoch(state) + 1 +// assert epoch <= next_epoch +// +// start_slot = compute_start_slot_at_epoch(epoch) +// for slot in range(start_slot, start_slot + SLOTS_PER_EPOCH): +// for index in range(get_committee_count_at_slot(state, Slot(slot))): +// committee = get_beacon_committee(state, Slot(slot), CommitteeIndex(index)) +// if validator_index in committee: +// return committee, CommitteeIndex(index), Slot(slot) +// return None +func CommitteeAssignment( + state *pb.BeaconState, + epoch uint64, + validatorIndex uint64, +) ([]uint64, uint64, uint64, uint64, error) { + + if epoch > NextEpoch(state) { + return nil, 0, 0, 0, fmt.Errorf( + "epoch %d can't be greater than next epoch %d", + epoch, NextEpoch(state)) + } + + // Track which slot has which proposer. + startSlot := StartSlot(epoch) + proposerIndexToSlot := make(map[uint64]uint64) + for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { + state.Slot = slot + i, err := BeaconProposerIndex(state) + if err != nil { + return nil, 0, 0, 0, errors.Wrapf(err, "could not check proposer at slot %d", state.Slot) + } + proposerIndexToSlot[i] = slot + } + + for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { + countAtSlot, err := CommitteeCountAtSlot(state, slot) + if err != nil { + return nil, 0, 0, 0, errors.Wrapf(err, "could not get committee count at slot %d", slot) + } + for i := uint64(0); i < countAtSlot; i++ { + committee, err := BeaconCommittee(state, slot, i) + if err != nil { + return nil, 0, 0, 0, errors.Wrapf(err, "could not get crosslink committee at slot %d", slot) + } + for _, v := range committee { + if validatorIndex == v { + proposerSlot, _ := proposerIndexToSlot[v] + return committee, i, slot, proposerSlot, nil + } + } + } + } + return []uint64{}, 0, 0, 0, fmt.Errorf("validator with index %d not found in assignments", validatorIndex) +} + // VerifyBitfieldLength verifies that a bitfield length matches the given committee size. func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { if bf.Len() != committeeSize { @@ -208,182 +240,16 @@ func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { return nil } -// CommitteeAssignment is used to query committee assignment from -// current and previous epoch. -// -// Spec pseudocode definition: -// def get_committee_assignment(state: BeaconState, -// epoch: Epoch, -// validator_index: ValidatorIndex) -> Optional[Tuple[Sequence[ValidatorIndex], Shard, Slot]]: -// """ -// Return the committee assignment in the ``epoch`` for ``validator_index``. -// ``assignment`` returned is a tuple of the following form: -// * ``assignment[0]`` is the list of validators in the committee -// * ``assignment[1]`` is the shard to which the committee is assigned -// * ``assignment[2]`` is the slot at which the committee is assigned -// Return None if no assignment. -// """ -// next_epoch = get_current_epoch(state) + 1 -// assert epoch <= next_epoch -// -// committees_per_slot = get_committee_count(state, epoch) // SLOTS_PER_EPOCH -// start_slot = compute_start_slot_of_epoch(epoch) -// for slot in range(start_slot, start_slot + SLOTS_PER_EPOCH): -// offset = committees_per_slot * (slot % SLOTS_PER_EPOCH) -// slot_start_shard = (get_start_shard(state, epoch) + offset) % SHARD_COUNT -// for i in range(committees_per_slot): -// shard = Shard((slot_start_shard + i) % SHARD_COUNT) -// committee = get_crosslink_committee(state, epoch, shard) -// if validator_index in committee: -// return committee, shard, Slot(slot) -// return None -func CommitteeAssignment( - state *pb.BeaconState, - epoch uint64, - validatorIndex uint64) ([]uint64, uint64, uint64, bool, error) { - - if epoch > NextEpoch(state) { - return nil, 0, 0, false, fmt.Errorf( - "epoch %d can't be greater than next epoch %d", - epoch, NextEpoch(state)) - } - - committeeCount, err := CommitteeCount(state, epoch) - if err != nil { - return nil, 0, 0, false, errors.Wrap(err, "could not get committee count") - } - committeesPerSlot := committeeCount / params.BeaconConfig().SlotsPerEpoch - - epochStartShard, err := StartShard(state, epoch) - if err != nil { - return nil, 0, 0, false, fmt.Errorf( - "could not get epoch start shard: %v", err) - } - startSlot := StartSlot(epoch) - for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { - offset := committeesPerSlot * (slot % params.BeaconConfig().SlotsPerEpoch) - slotStatShard := (epochStartShard + offset) % params.BeaconConfig().ShardCount - for i := uint64(0); i < committeesPerSlot; i++ { - shard := (slotStatShard + i) % params.BeaconConfig().ShardCount - committee, err := CrosslinkCommittee(state, epoch, shard) - if err != nil { - return nil, 0, 0, false, fmt.Errorf( - "could not get crosslink committee: %v", err) - } - for _, index := range committee { - if validatorIndex == index { - state.Slot = slot - proposerIndex, err := BeaconProposerIndex(state) - if err != nil { - return nil, 0, 0, false, fmt.Errorf( - "could not check proposer index: %v", err) - } - isProposer := proposerIndex == validatorIndex - return committee, shard, slot, isProposer, nil - } - } - } - } - - return []uint64{}, 0, 0, false, status.Error(codes.NotFound, "validator not found in assignments") -} - -// ShardDelta returns the minimum number of shards get processed in one epoch. -// -// Note: if you already have the committee count, -// use shardDeltaFromCommitteeCount as CommitteeCount (specifically -// ActiveValidatorCount) iterates over the entire validator set. -// -// Spec pseudocode definition: -// def get_shard_delta(state: BeaconState, epoch: Epoch) -> uint64: -// """ -// Return the number of shards to increment ``state.start_shard`` at ``epoch``. -// """ -// return min(get_committee_count(state, epoch), SHARD_COUNT - SHARD_COUNT // SLOTS_PER_EPOCH) -func ShardDelta(beaconState *pb.BeaconState, epoch uint64) (uint64, error) { - committeeCount, err := CommitteeCount(beaconState, epoch) - if err != nil { - return 0, errors.Wrap(err, "could not get committee count") - } - return shardDeltaFromCommitteeCount(committeeCount), nil -} - -// shardDeltaFromCommitteeCount returns the number of shards that get processed -// in one epoch. This method is the inner logic of ShardDelta. -// Returns the minimum of the committeeCount and maximum shard delta which is -// defined as SHARD_COUNT - SHARD_COUNT // SLOTS_PER_EPOCH. -func shardDeltaFromCommitteeCount(committeeCount uint64) uint64 { - shardCount := params.BeaconConfig().ShardCount - maxShardDelta := shardCount - shardCount/params.BeaconConfig().SlotsPerEpoch - if committeeCount < maxShardDelta { - return committeeCount - } - return maxShardDelta -} - -// StartShard returns the start shard used to process crosslink -// of a given epoch. The start shard is cached using epoch as key, -// it gets rewritten where there's a reorg or a new finalized block. -// -// Spec pseudocode definition: -// def get_start_shard(state: BeaconState, epoch: Epoch) -> Shard: -// """ -// Return the start shard of the 0th committee at ``epoch``. -// """ -// assert epoch <= get_current_epoch(state) + 1 -// check_epoch = Epoch(get_current_epoch(state) + 1) -// shard = Shard((state.start_shard + get_shard_delta(state, get_current_epoch(state))) % SHARD_COUNT) -// while check_epoch > epoch: -// check_epoch -= Epoch(1) -// shard = Shard((shard + SHARD_COUNT - get_shard_delta(state, check_epoch)) % SHARD_COUNT) -// return shard -func StartShard(state *pb.BeaconState, epoch uint64) (uint64, error) { - if featureconfig.Get().EnableNewCache { - startShard, exists, err := committeeCache.StartShard(epoch) - if err != nil { - return 0, errors.Wrap(err, "could not interface with committee cache") - } - if exists { - return startShard, nil - } - } - - currentEpoch := CurrentEpoch(state) - checkEpoch := currentEpoch + 1 - - if epoch > checkEpoch { - return 0, fmt.Errorf("epoch %d can't be greater than %d", - epoch, checkEpoch) - } - - delta, err := ShardDelta(state, currentEpoch) - if err != nil { - return 0, errors.Wrap(err, "could not get shard delta") - } - - startShard := (state.StartShard + delta) % params.BeaconConfig().ShardCount - for checkEpoch > epoch { - checkEpoch-- - d, err := ShardDelta(state, checkEpoch) - if err != nil { - return 0, errors.Wrap(err, "could not get shard delta") - } - startShard = (startShard + params.BeaconConfig().ShardCount - d) % params.BeaconConfig().ShardCount - } - - return startShard, nil -} - // VerifyAttestationBitfieldLengths verifies that an attestations aggregation and custody bitfields are // a valid length matching the size of the committee. func VerifyAttestationBitfieldLengths(bState *pb.BeaconState, att *ethpb.Attestation) error { - committee, err := CrosslinkCommittee(bState, att.Data.Target.Epoch, att.Data.Crosslink.Shard) + committee, err := BeaconCommittee(bState, att.Data.Slot, att.Data.Index) if err != nil { - return errors.Wrap(err, "could not retrieve crosslink committees") + return errors.Wrap(err, "could not retrieve beacon committees") } if committee == nil { - return errors.New("no committee exist for shard in the attestation") + return errors.New("no committee exist for this attestation") } if err := VerifyBitfieldLength(att.AggregationBits, uint64(len(committee))); err != nil { @@ -395,95 +261,10 @@ func VerifyAttestationBitfieldLengths(bState *pb.BeaconState, att *ethpb.Attesta return nil } -// CompactCommitteesRoot returns the index root of a given epoch. -// -// Spec pseudocode definition: -// def get_compact_committees_root(state: BeaconState, epoch: Epoch) -> Hash: -// """ -// Return the compact committee root at ``epoch``. -// """ -// committees = [CompactCommittee() for _ in range(SHARD_COUNT)] -// start_shard = get_epoch_start_shard(state, epoch) -// for committee_number in range(get_epoch_committee_count(state, epoch)): -// shard = Shard((start_shard + committee_number) % SHARD_COUNT) -// for index in get_crosslink_committee(state, epoch, shard): -// validator = state.validators[index] -// committees[shard].pubkeys.append(validator.pubkey) -// compact_balance = validator.effective_balance // EFFECTIVE_BALANCE_INCREMENT -// # `index` (top 6 bytes) + `slashed` (16th bit) + `compact_balance` (bottom 15 bits) -// compact_validator = uint64((index << 16) + (validator.slashed << 15) + compact_balance) -// committees[shard].compact_validators.append(compact_validator) -// return hash_tree_root(Vector[CompactCommittee, SHARD_COUNT](committees)) -func CompactCommitteesRoot(state *pb.BeaconState, epoch uint64) ([32]byte, error) { - shardCount := params.BeaconConfig().ShardCount - switch shardCount { - case 1024: - compactCommArray := [1024]*pb.CompactCommittee{} - for i := range compactCommArray { - compactCommArray[i] = &pb.CompactCommittee{} - } - comCount, err := CommitteeCount(state, epoch) - if err != nil { - return [32]byte{}, err - } - startShard, err := StartShard(state, epoch) - if err != nil { - return [32]byte{}, err - } - - for i := uint64(0); i < comCount; i++ { - shard := (startShard + i) % shardCount - crossComm, err := CrosslinkCommittee(state, epoch, shard) - if err != nil { - return [32]byte{}, err - } - - for _, index := range crossComm { - validator := state.Validators[index] - compactCommArray[shard].Pubkeys = append(compactCommArray[shard].Pubkeys, validator.PublicKey) - compactValidator := compressValidator(validator, index) - compactCommArray[shard].CompactValidators = append(compactCommArray[shard].CompactValidators, compactValidator) - } - } - return ssz.HashTreeRoot(compactCommArray) - case 8: - compactCommArray := [8]*pb.CompactCommittee{} - for i := range compactCommArray { - compactCommArray[i] = &pb.CompactCommittee{} - } - comCount, err := CommitteeCount(state, epoch) - if err != nil { - return [32]byte{}, err - } - startShard, err := StartShard(state, epoch) - if err != nil { - return [32]byte{}, err - } - for i := uint64(0); i < comCount; i++ { - shard := (startShard + i) % shardCount - crossComm, err := CrosslinkCommittee(state, epoch, shard) - if err != nil { - return [32]byte{}, err - } - - for _, index := range crossComm { - validator := state.Validators[index] - compactCommArray[shard].Pubkeys = append(compactCommArray[shard].Pubkeys, validator.PublicKey) - compactValidator := compressValidator(validator, index) - compactCommArray[shard].CompactValidators = append(compactCommArray[shard].CompactValidators, compactValidator) - } - } - return ssz.HashTreeRoot(compactCommArray) - default: - return [32]byte{}, fmt.Errorf("expected minimal or mainnet config shard count, received %d", shardCount) - } - -} - // ShuffledIndices uses input beacon state and returns the shuffled indices of the input epoch, // the shuffled indices then can be used to break up into committees. func ShuffledIndices(state *pb.BeaconState, epoch uint64) ([]uint64, error) { - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { return nil, errors.Wrapf(err, "could not get seed for epoch %d", epoch) } @@ -507,7 +288,7 @@ func ShuffledIndices(state *pb.BeaconState, epoch uint64) ([]uint64, error) { } // UpdateCommitteeCache gets called at the beginning of every epoch to cache the committee shuffled indices -// list with start shard and epoch number. It caches the shuffled indices for current epoch and next epoch. +// list with committee index and epoch number. It caches the shuffled indices for current epoch and next epoch. func UpdateCommitteeCache(state *pb.BeaconState) error { currentEpoch := CurrentEpoch(state) for _, epoch := range []uint64{currentEpoch, currentEpoch + 1} { @@ -515,42 +296,17 @@ func UpdateCommitteeCache(state *pb.BeaconState) error { if err != nil { return err } - startShard, err := StartShard(state, epoch) - if err != nil { - return err - } - committeeCount, err := CommitteeCount(state, epoch) + count, err := CommitteeCountAtSlot(state, epoch*params.BeaconConfig().SlotsPerEpoch) if err != nil { return err } if err := committeeCache.AddCommitteeShuffledList(&cache.Committee{ Epoch: epoch, Committee: committees, - StartShard: startShard, - CommitteeCount: committeeCount, + CommitteeCount: count * params.BeaconConfig().SlotsPerEpoch, }); err != nil { return err } } return nil } - -// compressValidator compacts all the validator data such as validator index, slashing info and balance -// into a single uint64 field. -// -// Spec reference: -// # `index` (top 6 bytes) + `slashed` (16th bit) + `compact_balance` (bottom 15 bits) -// compact_validator = uint64((index << 16) + (validator.slashed << 15) + compact_balance) -func compressValidator(validator *ethpb.Validator, idx uint64) uint64 { - compactBalance := validator.EffectiveBalance / params.BeaconConfig().EffectiveBalanceIncrement - // index (top 6 bytes) + slashed (16th bit) + compact_balance (bottom 15 bits) - compactIndex := idx << 16 - var slashedBit uint64 - if validator.Slashed { - slashedBit = 1 << 15 - } - // Clear all bits except last 15. - compactBalance &= 0x7FFF // 0b01111111 0b11111111 - compactValidator := compactIndex | slashedBit | compactBalance - return compactValidator -} diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index e4da4d18e4..78cdcc6f71 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -7,115 +7,14 @@ import ( "testing" "github.com/prysmaticlabs/go-bitfield" + pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) -func TestEpochCommitteeCount_OK(t *testing.T) { - // this defines the # of validators required to have 1 committee - // per slot for epoch length. - validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize - tests := []struct { - validatorCount uint64 - committeeCount uint64 - }{ - {0, params.BeaconConfig().SlotsPerEpoch}, - {1000, params.BeaconConfig().SlotsPerEpoch}, - {2 * validatorsPerEpoch, 2 * params.BeaconConfig().SlotsPerEpoch}, - {5 * validatorsPerEpoch, 5 * params.BeaconConfig().SlotsPerEpoch}, - {16 * validatorsPerEpoch, 16 * params.BeaconConfig().SlotsPerEpoch}, - {32 * validatorsPerEpoch, 16 * params.BeaconConfig().SlotsPerEpoch}, - } - for _, test := range tests { - ClearAllCaches() - vals := make([]*ethpb.Validator, test.validatorCount) - for i := 0; i < len(vals); i++ { - vals[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - s := &pb.BeaconState{ - Validators: vals, - } - count, err := CommitteeCount(s, 1) - if err != nil { - t.Fatal(err) - } - if test.committeeCount != count { - t.Errorf("wanted: %d, got: %d", - test.committeeCount, count) - } - } -} - -func TestEpochCommitteeCount_LessShardsThanEpoch(t *testing.T) { - validatorCount := uint64(8) - productionConfig := params.BeaconConfig() - testConfig := ¶ms.BeaconChainConfig{ - ShardCount: 1, - SlotsPerEpoch: 4, - TargetCommitteeSize: 2, - } - params.OverrideBeaconConfig(testConfig) - vals := make([]*ethpb.Validator, validatorCount) - for i := 0; i < len(vals); i++ { - vals[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - s := &pb.BeaconState{ - Validators: vals, - } - count, err := CommitteeCount(s, 1) - if err != nil { - t.Fatal(err) - } - if count != validatorCount/testConfig.TargetCommitteeSize { - t.Errorf("wanted: %d, got: %d", - validatorCount/testConfig.TargetCommitteeSize, count) - } - params.OverrideBeaconConfig(productionConfig) -} - -func TestShardDelta_Ok(t *testing.T) { - minShardDelta := params.BeaconConfig().ShardCount - - params.BeaconConfig().ShardCount/params.BeaconConfig().SlotsPerEpoch - tests := []struct { - validatorCount uint64 - shardCount uint64 - }{ - {0, params.BeaconConfig().SlotsPerEpoch}, // Empty minimum shards - {1000, params.BeaconConfig().SlotsPerEpoch}, // 1000 Validators minimum shards, - {100000, 768 /*len(active_validators) // TARGET_COMMITTEE_SIZE*/}, - {500000, minShardDelta}, // 5 Mil, above shard delta - } - for _, test := range tests { - ClearAllCaches() - vals := make([]*ethpb.Validator, test.validatorCount) - for i := 0; i < len(vals); i++ { - vals[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - s := &pb.BeaconState{ - Validators: vals, - } - delta, err := ShardDelta(s, 1) - if err != nil { - t.Fatal(err) - } - if test.shardCount != delta { - t.Errorf("wanted: %d, got: %d", - test.shardCount, delta) - } - } -} - func TestComputeCommittee_WithoutCache(t *testing.T) { // Create 10 committees committeeCount := uint64(10) @@ -129,10 +28,9 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { } state := &pb.BeaconState{ - Validators: validators, - Slot: 200, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + Slot: 200, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -140,7 +38,7 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { if err != nil { t.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } @@ -149,88 +47,34 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { t.Errorf("could not compute committee: %v", err) } - // Test shuffled indices are correct for shard 5 committee - shard := uint64(5) - committee5, err := ComputeCommittee(indices, seed, shard, committeeCount) + // Test shuffled indices are correct for index 5 committee + index := uint64(5) + committee5, err := ComputeCommittee(indices, seed, index, committeeCount) if err != nil { t.Errorf("could not compute committee: %v", err) } - start := sliceutil.SplitOffset(validatorCount, committeeCount, shard) - end := sliceutil.SplitOffset(validatorCount, committeeCount, shard+1) + start := sliceutil.SplitOffset(validatorCount, committeeCount, index) + end := sliceutil.SplitOffset(validatorCount, committeeCount, index+1) if !reflect.DeepEqual(committees[start:end], committee5) { t.Error("committee has different shuffled indices") } - // Test shuffled indices are correct for shard 9 committee - shard = uint64(9) - committee9, err := ComputeCommittee(indices, seed, shard, committeeCount) + // Test shuffled indices are correct for index 9 committee + index = uint64(9) + committee9, err := ComputeCommittee(indices, seed, index, committeeCount) if err != nil { t.Errorf("could not compute committee: %v", err) } - start = sliceutil.SplitOffset(validatorCount, committeeCount, shard) - end = sliceutil.SplitOffset(validatorCount, committeeCount, shard+1) + start = sliceutil.SplitOffset(validatorCount, committeeCount, index) + end = sliceutil.SplitOffset(validatorCount, committeeCount, index+1) if !reflect.DeepEqual(committees[start:end], committee9) { t.Error("committee has different shuffled indices") } } -func TestComputeCommittee_WithCache(t *testing.T) { - fc := featureconfig.Get() - fc.EnableShuffledIndexCache = true - featureconfig.Init(fc) - defer featureconfig.Init(nil) - - // Create 10 committees - committeeCount := uint64(10) - validatorCount := committeeCount * params.BeaconConfig().TargetCommitteeSize - validators := make([]*ethpb.Validator, validatorCount) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - - state := &pb.BeaconState{ - Validators: validators, - Slot: 200, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - - epoch := CurrentEpoch(state) - indices, err := ActiveValidatorIndices(state, epoch) - if err != nil { - t.Fatal(err) - } - seed, err := Seed(state, epoch) - if err != nil { - t.Fatal(err) - } - - // Test shuffled indices are correct for shard 3 committee - shard := uint64(3) - committee3, err := ComputeCommittee(indices, seed, shard, committeeCount) - if err != nil { - t.Errorf("could not compute committee: %v", err) - } - - cachedIndices, err := shuffledIndicesCache.IndicesByIndexSeed(shard, seed[:]) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(cachedIndices, committee3) { - t.Error("committee has different shuffled indices") - } -} - func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - committeeSize := uint64(16) validators := make([]*ethpb.Validator, committeeSize*params.BeaconConfig().SlotsPerEpoch) for i := 0; i < len(validators); i++ { @@ -240,46 +84,39 @@ func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slot: params.BeaconConfig().SlotsPerEpoch, + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } attestationData := ðpb.AttestationData{} tests := []struct { attestationSlot uint64 - stateSlot uint64 bitfield bitfield.Bitlist wanted []uint64 }{ { attestationSlot: 3, - stateSlot: 5, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{219, 476}, + wanted: []uint64{355, 416}, }, { attestationSlot: 2, - stateSlot: 10, bitfield: bitfield.Bitlist{0x05}, - wanted: []uint64{123}, + wanted: []uint64{447}, }, { attestationSlot: 11, - stateSlot: 10, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{880, 757}, + wanted: []uint64{67, 508}, }, } for _, tt := range tests { ClearAllCaches() - state.Slot = tt.stateSlot - attestationData.Crosslink = ðpb.Crosslink{ - Shard: tt.attestationSlot, - } attestationData.Target = ðpb.Checkpoint{Epoch: 0} + attestationData.Slot = tt.attestationSlot result, err := AttestingIndices(state, attestationData, tt.bitfield) if err != nil { @@ -297,9 +134,6 @@ func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { } func TestAttestationParticipants_EmptyBitfield(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } ClearAllCaches() validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) @@ -310,11 +144,10 @@ func TestAttestationParticipants_EmptyBitfield(t *testing.T) { } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } - attestationData := ðpb.AttestationData{Crosslink: ðpb.Crosslink{}, Target: ðpb.Checkpoint{}} + attestationData := ðpb.AttestationData{Target: ðpb.Checkpoint{}} indices, err := AttestingIndices(state, attestationData, bitfield.NewBitlist(128)) if err != nil { @@ -341,7 +174,7 @@ func TestVerifyBitfieldLength_OK(t *testing.T) { } func TestCommitteeAssignment_CanRetrieve(t *testing.T) { - // Initialize test with 128 validators, each slot and each shard gets 2 validators. + // Initialize test with 128 validators, each slot and each index gets 2 validators. validators := make([]*ethpb.Validator, 2*params.BeaconConfig().SlotsPerEpoch) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -349,269 +182,106 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { } } state := &pb.BeaconState{ - Validators: validators, - Slot: params.BeaconConfig().SlotsPerEpoch, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + Slot: params.BeaconConfig().SlotsPerEpoch, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } tests := []struct { - index uint64 - slot uint64 - committee []uint64 - shard uint64 - isProposer bool + index uint64 + slot uint64 + committee []uint64 + committeeIndex uint64 + isProposer bool + proposerSlot uint64 }{ { - index: 0, - slot: 146, - committee: []uint64{0, 3}, - shard: 82, - isProposer: true, + index: 0, + slot: 92, + committee: []uint64{46, 0}, + committeeIndex: 0, + isProposer: false, }, { - index: 105, - slot: 160, - committee: []uint64{105, 20}, - shard: 32, - isProposer: true, + index: 1, + slot: 70, + committee: []uint64{1, 58}, + committeeIndex: 0, + isProposer: true, + proposerSlot: 91, }, { - index: 0, - slot: 146, - committee: []uint64{0, 3}, - shard: 18, - isProposer: true, - }, - { - index: 11, - slot: 135, - committee: []uint64{119, 11}, - shard: 7, - isProposer: false, + index: 11, + slot: 64, + committee: []uint64{30, 11}, + committeeIndex: 0, + isProposer: false, }, } for i, tt := range tests { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { ClearAllCaches() - committee, shard, slot, isProposer, err := CommitteeAssignment(state, tt.slot/params.BeaconConfig().SlotsPerEpoch, tt.index) + committee, committeeIndex, slot, proposerSlot, err := CommitteeAssignment(state, tt.slot/params.BeaconConfig().SlotsPerEpoch, tt.index) if err != nil { t.Fatalf("failed to execute NextEpochCommitteeAssignment: %v", err) } - if shard != tt.shard { - t.Errorf("wanted shard %d, got shard %d for validator index %d", - tt.shard, shard, tt.index) + if committeeIndex != tt.committeeIndex { + t.Errorf("wanted committeeIndex %d, got committeeIndex %d for validator index %d", + tt.committeeIndex, committeeIndex, tt.index) } if slot != tt.slot { t.Errorf("wanted slot %d, got slot %d for validator index %d", tt.slot, slot, tt.index) } - if isProposer != tt.isProposer { - t.Errorf("wanted isProposer %v, got isProposer %v for validator index %d", - tt.isProposer, isProposer, tt.index) + if proposerSlot != tt.proposerSlot { + t.Errorf("wanted proposer slot %d, got proposer slot %d for validator index %d", + tt.proposerSlot, proposerSlot, tt.index) } if !reflect.DeepEqual(committee, tt.committee) { t.Errorf("wanted committee %v, got committee %v for validator index %d", tt.committee, committee, tt.index) } + if proposerSlot != tt.proposerSlot { + t.Errorf("wanted proposer slot slot %d, got slot %d for validator index %d", + tt.slot, slot, tt.index) + } }) } } -func TestCommitteeAssignment_EveryValidatorShouldPropose(t *testing.T) { - // Initialize 64 validators with 64 slots per epoch. Every validator - // in the epoch should be a proposer. - validators := make([]*ethpb.Validator, params.BeaconConfig().SlotsPerEpoch) +func TestCommitteeAssignment_CantFindValidator(t *testing.T) { + validators := make([]*ethpb.Validator, 1) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } state := &pb.BeaconState{ - Validators: validators, - Slot: params.BeaconConfig().SlotsPerEpoch, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + Slot: params.BeaconConfig().SlotsPerEpoch, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } - ClearAllCaches() - for i := 0; i < len(validators); i++ { - _, _, _, isProposer, err := CommitteeAssignment(state, state.Slot/params.BeaconConfig().SlotsPerEpoch, uint64(i)) - if err != nil { - t.Fatal(err) - } - if !isProposer { - t.Errorf("validator %d should be a proposer", i) - } - } -} - -func TestCommitteeAssignment_CantFindValidator(t *testing.T) { - state := &pb.BeaconState{ - Slot: params.BeaconConfig().SlotsPerEpoch, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } index := uint64(10000) _, _, _, _, err := CommitteeAssignment(state, 1, index) - statusErr, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - if statusErr.Code() != codes.NotFound { - t.Errorf("Unexpected error: %v", err) - } -} - -func TestShardDelta_OK(t *testing.T) { - validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize - min := params.BeaconConfig().ShardCount - params.BeaconConfig().ShardCount/params.BeaconConfig().SlotsPerEpoch - tests := []struct { - validatorCount uint64 - shardDelta uint64 - }{ - {0, params.BeaconConfig().SlotsPerEpoch}, - {1000, params.BeaconConfig().SlotsPerEpoch}, - {2 * validatorsPerEpoch, 2 * params.BeaconConfig().SlotsPerEpoch}, - {5 * validatorsPerEpoch, 5 * params.BeaconConfig().SlotsPerEpoch}, - {16 * validatorsPerEpoch, min}, - {32 * validatorsPerEpoch, min}, - } - for _, test := range tests { - ClearAllCaches() - validators := make([]*ethpb.Validator, test.validatorCount) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - state := &pb.BeaconState{Validators: validators} - delta, err := ShardDelta(state, 0) - if err != nil { - t.Fatal(err) - } - if test.shardDelta != delta { - t.Errorf("wanted: %d, got: %d", - test.shardDelta, delta) - } - } -} - -func TestEpochStartShard_EpochOutOfBound(t *testing.T) { - _, err := StartShard(&pb.BeaconState{}, 2) - want := "epoch 2 can't be greater than 1" - if err.Error() != want { - t.Fatalf("Did not generate correct error. Want: %s, got: %s", - err.Error(), want) - } -} - -func TestEpochStartShard_AccurateShard(t *testing.T) { - validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize - tests := []struct { - validatorCount uint64 - startShard uint64 - }{ - {0, 676}, - {1000, 676}, - {2 * validatorsPerEpoch, 228}, - {5 * validatorsPerEpoch, 932}, - {16 * validatorsPerEpoch, 212}, - {32 * validatorsPerEpoch, 212}, - } - for _, test := range tests { - ClearAllCaches() - validators := make([]*ethpb.Validator, test.validatorCount) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - state := &pb.BeaconState{Validators: validators, StartShard: 100, Slot: 500} - startShard, err := StartShard(state, 0) - if err != nil { - t.Fatal(err) - } - if test.startShard != startShard { - t.Errorf("wanted: %d, got: %d", test.startShard, startShard) - } - } -} - -func TestEpochStartShard_MixedActivationValidators(t *testing.T) { - validatorsPerEpoch := params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().TargetCommitteeSize - tests := []struct { - validatorCount uint64 - startShard uint64 - }{ - {0 * validatorsPerEpoch, 960}, - {1 * validatorsPerEpoch, 960}, - {2 * validatorsPerEpoch, 960}, - {3 * validatorsPerEpoch, 960}, - {4 * validatorsPerEpoch, 896}, - } - for _, test := range tests { - ClearAllCaches() - vs := make([]*ethpb.Validator, test.validatorCount) - // Build validator list with the following ratio: - // 10% activated in epoch 0 - // 20% activated in epoch 1 - // 40% activated in epoch 2 - // 30% activated in epoch 3 - // The validator set is broken up in buckets like this such that the - // shard delta between epochs will be different and we can test the - // inner logic of determining the start shard. - for i := uint64(1); i <= test.validatorCount; i++ { - // Determine activation bucket - bkt := i % 10 - activationEpoch := uint64(0) // zeroth epoch 10% - if bkt > 2 && bkt <= 4 { // first epoch 20% - activationEpoch = 1 - } else if bkt > 4 && bkt <= 7 { // second epoch 40% - activationEpoch = 2 - } else { // Remaining 30% in the third epoch. - activationEpoch = 3 - } - - vs[i-1] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - ActivationEpoch: activationEpoch, - } - } - s := &pb.BeaconState{ - Validators: vs, - Slot: params.BeaconConfig().SlotsPerEpoch * 3, - } - startShard, err := StartShard(s, 2 /*epoch*/) - if err != nil { - t.Fatal(err) - } - if test.startShard != startShard { - t.Errorf("wanted: %d, got: %d", test.startShard, startShard) - } - + if err != nil && !strings.Contains(err.Error(), "not found in assignments") { + t.Errorf("Wanted 'not found in assignments', received %v", err) } } func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - validators := make([]*ethpb.Validator, 2*params.BeaconConfig().SlotsPerEpoch) activeRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ ExitEpoch: params.BeaconConfig().FarFutureEpoch, } - activeRoots[i] = []byte{'A'} } state := &pb.BeaconState{ - Validators: validators, - ActiveIndexRoots: activeRoots, - RandaoMixes: activeRoots, + Validators: validators, + RandaoMixes: activeRoots, } tests := []struct { @@ -625,9 +295,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0x05}, CustodyBits: bitfield.Bitlist{0x05}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, + Index: 5, Target: ðpb.Checkpoint{}, }, }, @@ -639,9 +307,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0x06}, CustodyBits: bitfield.Bitlist{0x06}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 10, - }, + Index: 10, Target: ðpb.Checkpoint{}, }, }, @@ -652,9 +318,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0x06}, CustodyBits: bitfield.Bitlist{0x06}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 20, - }, + Index: 20, Target: ðpb.Checkpoint{}, }, }, @@ -665,9 +329,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0x06}, CustodyBits: bitfield.Bitlist{0x10}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 20, - }, + Index: 20, Target: ðpb.Checkpoint{}, }, }, @@ -680,9 +342,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0xFF, 0xC0, 0x01}, CustodyBits: bitfield.Bitlist{0xFF, 0xC0, 0x01}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, + Index: 5, Target: ðpb.Checkpoint{}, }, }, @@ -694,9 +354,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { AggregationBits: bitfield.Bitlist{0xFF, 0x01}, CustodyBits: bitfield.Bitlist{0xFF, 0x01}, Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 20, - }, + Index: 20, Target: ðpb.Checkpoint{}, }, }, @@ -727,33 +385,6 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { } } -func TestCompactCommitteesRoot_OK(t *testing.T) { - ClearAllCaches() - // Create 10 committees - committeeCount := uint64(10) - validatorCount := committeeCount * params.BeaconConfig().TargetCommitteeSize - validators := make([]*ethpb.Validator, validatorCount) - activeRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) - for i := 0; i < len(validators); i++ { - validators[i] = ðpb.Validator{ - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - } - activeRoots[i] = []byte{'A'} - } - - state := &pb.BeaconState{ - Slot: 196, - Validators: validators, - ActiveIndexRoots: activeRoots, - RandaoMixes: activeRoots, - } - - _, err := CompactCommitteesRoot(state, 1) - if err != nil { - t.Fatalf("Could not get compact root %v", err) - } -} - func TestShuffledIndices_ShuffleRightLength(t *testing.T) { ClearAllCaches() @@ -767,9 +398,8 @@ func TestShuffledIndices_ShuffleRightLength(t *testing.T) { indices[i] = uint64(i) } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } // Test for current epoch shuffledIndices, err := ShuffledIndices(state, 0) @@ -816,9 +446,8 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { indices[i] = uint64(i) } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } if err := UpdateCommitteeCache(state); err != nil { @@ -832,8 +461,8 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { t.Error("Did not save correct epoch lengths") } epoch := uint64(1) - shard := uint64(512) - indices, err = committeeCache.ShuffledIndices(epoch, shard) + idx := uint64(1) + indices, err = committeeCache.ShuffledIndices(epoch, idx) if err != nil { t.Fatal(err) } @@ -842,62 +471,7 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { } } -func TestCompressValidator(t *testing.T) { - tests := []struct { - validator *ethpb.Validator - idx uint64 - want uint64 - }{ - { - validator: ðpb.Validator{ - EffectiveBalance: 32e9, - Slashed: true, - }, - idx: 128, - want: 8421408, // (128 << 16) + (1 << 15) + (32e9 / (2**0 * 10**9)) - }, - { - validator: ðpb.Validator{ - EffectiveBalance: 32e9, - Slashed: false, - }, - idx: 128, - want: 8388640, // (128 << 16) + (0 << 15) + (32e9 / (2**0 * 10**9)) - }, - { - validator: ðpb.Validator{ - EffectiveBalance: 33e9, - Slashed: false, - }, - idx: 128, - want: 8388641, // (128 << 16) + (0 << 15) + (33e9 / (2**0 * 10**9)) - }, - { - validator: ðpb.Validator{ - EffectiveBalance: 33e9, - Slashed: false, - }, - idx: 129, - want: 8454177, // (129 << 16) + (0 << 15) + (33e9 / (2**0 * 10**9)) - }, - } - - for _, tt := range tests { - got := compressValidator(tt.validator, tt.idx) - if got != tt.want { - t.Errorf( - "compressValidator({%v}, %d) = %d, wanted %d", - tt.validator, - tt.idx, - got, - tt.want, - ) - } - } -} - func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 300000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -905,9 +479,8 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -915,20 +488,20 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { if err != nil { b.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { b.Fatal(err) } - shard := uint64(3) - _, err = ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + index := uint64(3) + _, err = ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } b.ResetTimer() for n := 0; n < b.N; n++ { - _, err := ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + _, err := ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } @@ -936,7 +509,6 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { } func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 3000000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -944,9 +516,8 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -954,20 +525,20 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { if err != nil { b.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { b.Fatal(err) } - shard := uint64(3) - _, err = ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + index := uint64(3) + _, err = ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } b.ResetTimer() for n := 0; n < b.N; n++ { - _, err := ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + _, err := ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } @@ -975,7 +546,6 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { } func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 128000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -983,9 +553,8 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -993,29 +562,28 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { if err != nil { b.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { b.Fatal(err) } i := uint64(0) - shard := uint64(0) + index := uint64(0) b.ResetTimer() for n := 0; n < b.N; n++ { i++ - _, err := ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + _, err := ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } if i < params.BeaconConfig().TargetCommitteeSize { - shard = (shard + 1) % params.BeaconConfig().ShardCount + index = (index + 1) % params.BeaconConfig().MaxCommitteesPerSlot i = 0 } } } func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 1000000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -1023,9 +591,8 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -1033,29 +600,28 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { if err != nil { b.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { b.Fatal(err) } i := uint64(0) - shard := uint64(0) + index := uint64(0) b.ResetTimer() for n := 0; n < b.N; n++ { i++ - _, err := ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + _, err := ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } if i < params.BeaconConfig().TargetCommitteeSize { - shard = (shard + 1) % params.BeaconConfig().ShardCount + index = (index + 1) % params.BeaconConfig().MaxCommitteesPerSlot i = 0 } } } func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 4000000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -1063,9 +629,8 @@ func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { } } state := &pb.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := CurrentEpoch(state) @@ -1073,22 +638,22 @@ func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { if err != nil { b.Fatal(err) } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { b.Fatal(err) } i := uint64(0) - shard := uint64(0) + index := uint64(0) b.ResetTimer() for n := 0; n < b.N; n++ { i++ - _, err := ComputeCommittee(indices, seed, shard, params.BeaconConfig().ShardCount) + _, err := ComputeCommittee(indices, seed, index, params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { panic(err) } if i < params.BeaconConfig().TargetCommitteeSize { - shard = (shard + 1) % params.BeaconConfig().ShardCount + index = (index + 1) % params.BeaconConfig().MaxCommitteesPerSlot i = 0 } } diff --git a/beacon-chain/core/helpers/randao.go b/beacon-chain/core/helpers/randao.go index 4d05ce2bba..bfff18cb2a 100644 --- a/beacon-chain/core/helpers/randao.go +++ b/beacon-chain/core/helpers/randao.go @@ -15,54 +15,28 @@ var ErrInvalidStateLatestActiveIndexRoots = errors.New("state does not have corr // Seed returns the randao seed used for shuffling of a given epoch. // // Spec pseudocode definition: -// def get_seed(state: BeaconState, epoch: Epoch) -> Hash: +// def get_seed(state: BeaconState, epoch: Epoch, domain_type: DomainType) -> Hash: // """ // Return the seed at ``epoch``. // """ -// mix = get_randao_mix(state, Epoch(epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1)) #Avoid underflow -// active_index_root = state.active_index_roots[epoch % EPOCHS_PER_HISTORICAL_VECTOR] -// return hash(mix + active_index_root + int_to_bytes(epoch, length=32)) -func Seed(state *pb.BeaconState, epoch uint64) ([32]byte, error) { +// mix = get_randao_mix(state, Epoch(epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1)) # Avoid underflow +// return hash(domain_type + int_to_bytes(epoch, length=8) + mix) +func Seed(state *pb.BeaconState, epoch uint64, domain []byte) ([32]byte, error) { // See https://github.com/ethereum/eth2.0-specs/pull/1296 for // rationale on why offset has to look down by 1. lookAheadEpoch := epoch + params.BeaconConfig().EpochsPerHistoricalVector - params.BeaconConfig().MinSeedLookahead - 1 - // Check that the state has the correct latest active index roots or - // randao mix may panic for index out of bounds. - if uint64(len(state.ActiveIndexRoots)) != params.BeaconConfig().EpochsPerHistoricalVector { - return [32]byte{}, ErrInvalidStateLatestActiveIndexRoots - } randaoMix := RandaoMix(state, lookAheadEpoch) - indexRoot := ActiveIndexRoot(state, epoch) + seed := append(domain, bytesutil.Bytes8(epoch)...) + seed = append(seed, randaoMix...) - th := append(randaoMix, indexRoot...) - th = append(th, bytesutil.Bytes32(epoch)...) - - seed32 := hashutil.Hash(th) + seed32 := hashutil.Hash(seed) return seed32, nil } -// ActiveIndexRoot returns the index root of a given epoch. -// -// Spec pseudocode definition: -// def get_active_index_root(state: BeaconState, -// epoch: Epoch) -> Bytes32: -// """ -// Return the index root at a recent ``epoch``. -// ``epoch`` expected to be between -// (current_epoch - LATEST_ACTIVE_INDEX_ROOTS_LENGTH + ACTIVATION_EXIT_DELAY, current_epoch + ACTIVATION_EXIT_DELAY]. -// """ -// return state.latest_active_index_roots[epoch % LATEST_ACTIVE_INDEX_ROOTS_LENGTH] -func ActiveIndexRoot(state *pb.BeaconState, epoch uint64) []byte { - newRootLength := len(state.ActiveIndexRoots[epoch%params.BeaconConfig().EpochsPerHistoricalVector]) - newRoot := make([]byte, newRootLength) - copy(newRoot, state.ActiveIndexRoots[epoch%params.BeaconConfig().EpochsPerHistoricalVector]) - return newRoot -} - // RandaoMix returns the randao mix (xor'ed seed) // of a given slot. It is used to shuffle validators. // diff --git a/beacon-chain/core/helpers/randao_test.go b/beacon-chain/core/helpers/randao_test.go index c0a71237a5..f816e338fb 100644 --- a/beacon-chain/core/helpers/randao_test.go +++ b/beacon-chain/core/helpers/randao_test.go @@ -87,86 +87,8 @@ func TestRandaoMix_CopyOK(t *testing.T) { } } -func TestActiveIndexRoot_OK(t *testing.T) { - - activeIndexRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) - for i := 0; i < len(activeIndexRoots); i++ { - intInBytes := make([]byte, 32) - binary.LittleEndian.PutUint64(intInBytes, uint64(i)) - activeIndexRoots[i] = intInBytes - } - state := &pb.BeaconState{ActiveIndexRoots: activeIndexRoots} - tests := []struct { - epoch uint64 - }{ - { - epoch: 34, - }, - { - epoch: 3444, - }, - { - epoch: 999999, - }, - } - for _, test := range tests { - state.Slot = (test.epoch) * params.BeaconConfig().SlotsPerEpoch - for i := 0; i <= int(params.BeaconConfig().ActivationExitDelay); i++ { - indexRoot := ActiveIndexRoot(state, test.epoch+uint64(i)) - - if !bytes.Equal(activeIndexRoots[(test.epoch+uint64(i))%params.BeaconConfig().EpochsPerHistoricalVector], indexRoot) { - t.Errorf("Incorrect index root. Wanted: %#x, got: %#x", - activeIndexRoots[(test.epoch+uint64(i))%params.BeaconConfig().EpochsPerHistoricalVector], indexRoot) - } - } - - } -} - -func TestActiveIndexRoot_CopyOK(t *testing.T) { - ClearAllCaches() - conf := params.BeaconConfig() - conf.EpochsPerHistoricalVector = 100 - params.OverrideBeaconConfig(conf) - activeIndexRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) - for i := 0; i < len(activeIndexRoots); i++ { - intInBytes := make([]byte, 32) - binary.LittleEndian.PutUint64(intInBytes, uint64(i)) - activeIndexRoots[i] = intInBytes - } - state := &pb.BeaconState{ActiveIndexRoots: activeIndexRoots} - tests := []struct { - epoch uint64 - }{ - { - epoch: 34, - }, - } - for _, test := range tests { - state.Slot = (test.epoch) * params.BeaconConfig().SlotsPerEpoch - indexRoot := ActiveIndexRoot(state, test.epoch) - uniqueNumber := params.BeaconConfig().EpochsPerHistoricalVector + 1000 - binary.LittleEndian.PutUint64(indexRoot, uniqueNumber) - - for _, root := range activeIndexRoots { - rootNum := bytesutil.FromBytes8(root) - if rootNum == uniqueNumber { - t.Fatalf("two distinct slices which have different representations in memory still contain"+ - "the same value: %d", rootNum) - } - } - } -} - func TestGenerateSeed_OK(t *testing.T) { ClearAllCaches() - - activeIndexRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) - for i := 0; i < len(activeIndexRoots); i++ { - intInBytes := make([]byte, 32) - binary.LittleEndian.PutUint64(intInBytes, uint64(i)) - activeIndexRoots[i] = intInBytes - } randaoMixes := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) for i := 0; i < len(randaoMixes); i++ { intInBytes := make([]byte, 32) @@ -175,17 +97,16 @@ func TestGenerateSeed_OK(t *testing.T) { } slot := 10 * params.BeaconConfig().MinSeedLookahead * params.BeaconConfig().SlotsPerEpoch state := &pb.BeaconState{ - ActiveIndexRoots: activeIndexRoots, - RandaoMixes: randaoMixes, - Slot: slot} + RandaoMixes: randaoMixes, + Slot: slot} - got, err := Seed(state, 10) + got, err := Seed(state, 10, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } - wanted := [32]byte{141, 205, 112, 76, 60, 173, 127, 10, 1, 214, 151, 41, 69, 40, 108, 88, 247, - 210, 88, 5, 150, 112, 64, 93, 208, 110, 194, 137, 234, 180, 40, 245} + wanted := [32]byte{102, 82, 23, 40, 226, 79, 171, 11, 203, 23, 175, 7, 88, 202, 80, + 103, 68, 126, 195, 143, 190, 249, 210, 85, 138, 196, 158, 208, 11, 18, 136, 23} if got != wanted { t.Errorf("Incorrect generated seeds. Got: %v, wanted: %v", got, wanted) diff --git a/beacon-chain/core/helpers/shuffle.go b/beacon-chain/core/helpers/shuffle.go index 21da641b79..4f71b25a2b 100644 --- a/beacon-chain/core/helpers/shuffle.go +++ b/beacon-chain/core/helpers/shuffle.go @@ -35,15 +35,16 @@ func SplitIndices(l []uint64, n uint64) [][]uint64 { // constant between iterations instead of reallocating it each iteration as in the spec. This implementation is based // on the original implementation from protolambda, https://github.com/protolambda/eth2-shuffle func ShuffledIndex(index uint64, indexCount uint64, seed [32]byte) (uint64, error) { - return innerShuffledIndex(index, indexCount, seed, true /* shuffle */) + return ComputeShuffledIndex(index, indexCount, seed, true /* shuffle */) } // UnShuffledIndex returns the inverse of ShuffledIndex. This implementation is based // on the original implementation from protolambda, https://github.com/protolambda/eth2-shuffle func UnShuffledIndex(index uint64, indexCount uint64, seed [32]byte) (uint64, error) { - return innerShuffledIndex(index, indexCount, seed, false /* un-shuffle */) + return ComputeShuffledIndex(index, indexCount, seed, false /* un-shuffle */) } +// ComputeShuffledIndex returns the shuffled validator index corresponding to seed and index count. // Spec pseudocode definition: // def compute_shuffled_index(index: ValidatorIndex, index_count: uint64, seed: Hash) -> ValidatorIndex: // """ @@ -63,7 +64,7 @@ func UnShuffledIndex(index uint64, indexCount uint64, seed [32]byte) (uint64, er // index = flip if bit else index // // return ValidatorIndex(index) -func innerShuffledIndex(index uint64, indexCount uint64, seed [32]byte, shuffle bool) (uint64, error) { +func ComputeShuffledIndex(index uint64, indexCount uint64, seed [32]byte, shuffle bool) (uint64, error) { if params.BeaconConfig().ShuffleRoundCount == 0 { return index, nil } diff --git a/beacon-chain/core/helpers/slot_epoch_test.go b/beacon-chain/core/helpers/slot_epoch_test.go index 03767b4bb5..2a1bdc853b 100644 --- a/beacon-chain/core/helpers/slot_epoch_test.go +++ b/beacon-chain/core/helpers/slot_epoch_test.go @@ -13,10 +13,10 @@ func TestSlotToEpoch_OK(t *testing.T) { epoch uint64 }{ {slot: 0, epoch: 0}, - {slot: 50, epoch: 0}, - {slot: 64, epoch: 1}, - {slot: 128, epoch: 2}, - {slot: 200, epoch: 3}, + {slot: 50, epoch: 1}, + {slot: 64, epoch: 2}, + {slot: 128, epoch: 4}, + {slot: 200, epoch: 6}, } for _, tt := range tests { if tt.epoch != SlotToEpoch(tt.slot) { @@ -31,10 +31,10 @@ func TestCurrentEpoch_OK(t *testing.T) { epoch uint64 }{ {slot: 0, epoch: 0}, - {slot: 50, epoch: 0}, - {slot: 64, epoch: 1}, - {slot: 128, epoch: 2}, - {slot: 200, epoch: 3}, + {slot: 50, epoch: 1}, + {slot: 64, epoch: 2}, + {slot: 128, epoch: 4}, + {slot: 200, epoch: 6}, } for _, tt := range tests { state := &pb.BeaconState{Slot: tt.slot} @@ -67,7 +67,7 @@ func TestNextEpoch_OK(t *testing.T) { epoch uint64 }{ {slot: 0, epoch: 0/params.BeaconConfig().SlotsPerEpoch + 1}, - {slot: 50, epoch: 0/params.BeaconConfig().SlotsPerEpoch + 1}, + {slot: 50, epoch: 0/params.BeaconConfig().SlotsPerEpoch + 2}, {slot: 64, epoch: 64/params.BeaconConfig().SlotsPerEpoch + 1}, {slot: 128, epoch: 128/params.BeaconConfig().SlotsPerEpoch + 1}, {slot: 200, epoch: 200/params.BeaconConfig().SlotsPerEpoch + 1}, diff --git a/beacon-chain/core/helpers/validators.go b/beacon-chain/core/helpers/validators.go index e3c619b7ab..7fc396b9df 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -1,8 +1,6 @@ package helpers import ( - "fmt" - "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/cache" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" @@ -135,7 +133,7 @@ func ActiveValidatorCount(state *pb.BeaconState, epoch uint64) (uint64, error) { // """ // return Epoch(epoch + 1 + ACTIVATION_EXIT_DELAY) func DelayedActivationExitEpoch(epoch uint64) uint64 { - return epoch + 1 + params.BeaconConfig().ActivationExitDelay + return epoch + 1 + params.BeaconConfig().MaxSeedLookhead } // ValidatorChurnLimit returns the number of validators that are allowed to @@ -168,59 +166,57 @@ func ValidatorChurnLimit(state *pb.BeaconState) (uint64, error) { // Return the beacon proposer index at the current slot. // """ // epoch = get_current_epoch(state) -// committees_per_slot = get_committee_count(state, epoch) // SLOTS_PER_EPOCH -// offset = committees_per_slot * (state.slot % SLOTS_PER_EPOCH) -// shard = Shard((get_start_shard(state, epoch) + offset) % SHARD_COUNT) -// first_committee = get_crosslink_committee(state, epoch, shard) +// seed = hash(get_seed(state, epoch, DOMAIN_BEACON_PROPOSER) + int_to_bytes(state.slot, length=8)) +// indices = get_active_validator_indices(state, epoch) +// return compute_proposer_index(state, indices, seed) +func BeaconProposerIndex(state *pb.BeaconState) (uint64, error) { + e := CurrentEpoch(state) + + seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconProposer) + if err != nil { + return 0, errors.Wrap(err, "could not generate seed") + } + + seedWithSlot := append(seed[:], bytesutil.Bytes8(state.Slot)...) + seedWithSlotHash := hashutil.Hash(seedWithSlot) + + indices, err := ActiveValidatorIndices(state, e) + if err != nil { + return 0, errors.Wrap(err, "could not get active indices") + } + + return ComputeProposerIndex(state, indices, seedWithSlotHash) +} + +// ComputeProposerIndex returns the index sampled by effective balance, which is used to calculate proposer. +// +// Spec pseudocode definition: +// def compute_proposer_index(state: BeaconState, indices: Sequence[ValidatorIndex], seed: Hash) -> ValidatorIndex: +// """ +// Return from ``indices`` a random index sampled by effective balance. +// """ +// assert len(indices) > 0 // MAX_RANDOM_BYTE = 2**8 - 1 -// seed = get_seed(state, epoch) // i = 0 // while True: -// candidate_index = first_committee[(epoch + i) % len(first_committee)] +// candidate_index = indices[compute_shuffled_index(ValidatorIndex(i % len(indices)), len(indices), seed)] // random_byte = hash(seed + int_to_bytes(i // 32, length=8))[i % 32] // effective_balance = state.validators[candidate_index].effective_balance // if effective_balance * MAX_RANDOM_BYTE >= MAX_EFFECTIVE_BALANCE * random_byte: // return ValidatorIndex(candidate_index) // i += 1 -func BeaconProposerIndex(state *pb.BeaconState) (uint64, error) { - // Calculate the offset for slot and shard - e := CurrentEpoch(state) - committeeCount, err := CommitteeCount(state, e) - if err != nil { - return 0, err +func ComputeProposerIndex(state *pb.BeaconState, indices []uint64, seed [32]byte) (uint64, error) { + length := uint64(len(indices)) + if length == 0 { + return 0, errors.New("empty indices list") } - committesPerSlot := committeeCount / params.BeaconConfig().SlotsPerEpoch - offSet := committesPerSlot * (state.Slot % params.BeaconConfig().SlotsPerEpoch) - - // Calculate which shards get assigned given the epoch start shard - // and the offset - startShard, err := StartShard(state, e) - if err != nil { - return 0, errors.Wrap(err, "could not get start shard") - } - shard := (startShard + offSet) % params.BeaconConfig().ShardCount - - // Use the first committee of the given slot and shard - // to select proposer - firstCommittee, err := CrosslinkCommittee(state, e, shard) - if err != nil { - return 0, errors.Wrap(err, "could not get first committee") - } - if len(firstCommittee) == 0 { - return 0, fmt.Errorf("empty first committee at slot %d", state.Slot) - } - - // Use the generated seed to select proposer from the first committee maxRandomByte := uint64(1<<8 - 1) - seed, err := Seed(state, e) - if err != nil { - return 0, errors.Wrap(err, "could not generate seed") - } - // Looping through the committee to select proposer that has enough - // effective balance. for i := uint64(0); ; i++ { - candidateIndex := firstCommittee[(e+i)%uint64(len(firstCommittee))] + candidateIndex, err := ComputeShuffledIndex(i%length, length, seed, true) + if err != nil { + return 0, err + } b := append(seed[:], bytesutil.Bytes8(i/32)...) randomByte := hashutil.Hash(b)[i%32] effectiveBal := state.Validators[candidateIndex].EffectiveBalance diff --git a/beacon-chain/core/helpers/validators_test.go b/beacon-chain/core/helpers/validators_test.go index 514f49685e..2c19860dbb 100644 --- a/beacon-chain/core/helpers/validators_test.go +++ b/beacon-chain/core/helpers/validators_test.go @@ -1,7 +1,6 @@ package helpers import ( - "fmt" "testing" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" @@ -31,10 +30,6 @@ func TestIsActiveValidator_OK(t *testing.T) { } func TestIsSlashableValidator_Active(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - activeValidator := ðpb.Validator{ WithdrawableEpoch: params.BeaconConfig().FarFutureEpoch, } @@ -46,10 +41,6 @@ func TestIsSlashableValidator_Active(t *testing.T) { } func TestIsSlashableValidator_BeforeWithdrawable(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - beforeWithdrawableValidator := ðpb.Validator{ WithdrawableEpoch: 5, } @@ -61,10 +52,6 @@ func TestIsSlashableValidator_BeforeWithdrawable(t *testing.T) { } func TestIsSlashableValidator_Inactive(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - inactiveValidator := ðpb.Validator{ ActivationEpoch: 5, WithdrawableEpoch: params.BeaconConfig().FarFutureEpoch, @@ -77,10 +64,6 @@ func TestIsSlashableValidator_Inactive(t *testing.T) { } func TestIsSlashableValidator_AfterWithdrawable(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - afterWithdrawableValidator := ðpb.Validator{ WithdrawableEpoch: 3, } @@ -92,9 +75,6 @@ func TestIsSlashableValidator_AfterWithdrawable(t *testing.T) { } func TestIsSlashableValidator_SlashedWithdrawalble(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } slashedValidator := ðpb.Validator{ Slashed: true, ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -108,10 +88,6 @@ func TestIsSlashableValidator_SlashedWithdrawalble(t *testing.T) { } func TestIsSlashableValidator_Slashed(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - slashedValidator2 := ðpb.Validator{ Slashed: true, ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -125,10 +101,6 @@ func TestIsSlashableValidator_Slashed(t *testing.T) { } func TestIsSlashableValidator_InactiveSlashed(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - slashedValidator2 := ðpb.Validator{ Slashed: true, ActivationEpoch: 4, @@ -144,11 +116,6 @@ func TestIsSlashableValidator_InactiveSlashed(t *testing.T) { func TestBeaconProposerIndex_OK(t *testing.T) { ClearAllCaches() - - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - c := params.BeaconConfig() c.MinGenesisActiveValidatorCount = 16384 params.OverrideBeaconConfig(c) @@ -160,10 +127,9 @@ func TestBeaconProposerIndex_OK(t *testing.T) { } state := &pb.BeaconState{ - Validators: validators, - Slot: 0, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + Slot: 0, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } tests := []struct { @@ -172,23 +138,23 @@ func TestBeaconProposerIndex_OK(t *testing.T) { }{ { slot: 1, - index: 254, + index: 505, }, { slot: 5, - index: 391, + index: 798, }, { slot: 19, - index: 204, + index: 1956, }, { slot: 30, - index: 1051, + index: 991, }, { slot: 43, - index: 1047, + index: 1751, }, } @@ -209,24 +175,10 @@ func TestBeaconProposerIndex_OK(t *testing.T) { } } -func TestBeaconProposerIndex_EmptyCommittee(t *testing.T) { - ClearAllCaches() - beaconState := &pb.BeaconState{ - Slot: 0, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - _, err := BeaconProposerIndex(beaconState) - expected := fmt.Sprintf("empty first committee at slot %d", 0) - if err.Error() != expected { - t.Errorf("Unexpected error. got=%v want=%s", err, expected) - } -} - func TestDelayedActivationExitEpoch_OK(t *testing.T) { epoch := uint64(9999) got := DelayedActivationExitEpoch(epoch) - wanted := epoch + 1 + params.BeaconConfig().ActivationExitDelay + wanted := epoch + 1 + params.BeaconConfig().MaxSeedLookhead if wanted != got { t.Errorf("Wanted: %d, received: %d", wanted, got) } @@ -252,10 +204,9 @@ func TestChurnLimit_OK(t *testing.T) { } beaconState := &pb.BeaconState{ - Slot: 1, - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slot: 1, + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } resultChurn, err := ValidatorChurnLimit(beaconState) if err != nil { diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index 70eb7ba1e0..39a5dddc06 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -25,7 +25,6 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/hashutil:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", "//shared/traceutil:go_default_library", @@ -66,23 +65,3 @@ go_test( "@com_github_sirupsen_logrus//:go_default_library", ], ) - -# Requires ssz=minimal -# gazelle:exclude minimal_config_consensus_test.go -go_test( - name = "go_minimal_test", - size = "small", - srcs = ["minimal_config_consensus_test.go"], - data = glob(["testdata/minimal/**/*.ssz"]), - embed = [":go_default_library"], - tags = [ - "manual", - "minimal", - ], - deps = [ - "//proto/beacon/p2p/v1:go_default_library", - "//proto/eth/v1alpha1:go_default_library", - "@com_github_prysmaticlabs_go_ssz//:go_default_library", - "@in_gopkg_d4l3k_messagediff_v1//:go_default_library", - ], -) diff --git a/beacon-chain/core/state/minimal_config_consensus_test.go b/beacon-chain/core/state/minimal_config_consensus_test.go deleted file mode 100644 index 07cc160860..0000000000 --- a/beacon-chain/core/state/minimal_config_consensus_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package state - -import ( - "context" - "io/ioutil" - "testing" - - "github.com/prysmaticlabs/go-ssz" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/params" - "gopkg.in/d4l3k/messagediff.v1" -) - -func TestConsensusBugs(t *testing.T) { - tests := []struct { - name string - blockPath string - preStatePath string - postStatePath string - }{ - { - // This scenario produced a consensus issue between ZCLI, and Artemis. - // The test expects that running a state transition with 0_block 0_prestate would - // output 0_poststate. - // - // Assert ExecuteStateTransition(ctx, 0_block, 0_prestate) == 0_poststate - // - // https://github.com/djrtwo/interop-test-cases/tree/master/tests/artemis_16_crosslinks_and_balances - name: "ZcliArtemisCrosslinks", - blockPath: "testdata/minimal/artemis_crosslink/block.ssz", - preStatePath: "testdata/minimal/artemis_crosslink/pre.ssz", - postStatePath: "testdata/minimal/artemis_crosslink/post.ssz", - }, - { - // This scenario produced a consensus issue when running Prysm with Trinity. - // The test expects that running a state transition with 0_block 0_prestate would - // output 0_poststate. - // - // Assert ExecuteStateTransition(ctx, 0_block, 0_prestate) == 0_poststate - // - // https://github.com/djrtwo/interop-test-cases/tree/master/tests/prysm_16_duplicate_attestation_rewards - name: "TrinityPrysmDuplicateRewards", - blockPath: "testdata/minimal/duplicate_rewards/block.ssz", - preStatePath: "testdata/minimal/duplicate_rewards/pre.ssz", - postStatePath: "testdata/minimal/duplicate_rewards/post.ssz", - }, - { - // This scenario produced a consensus issue between Trinity, ZCLI, and Lighthouse. - // The test expects that running a state transition with 0_block 0_prestate would - // output 0_poststate. - // - // Assert ExecuteStateTransition(ctx, 0_block, 0_prestate) == 0_poststate - // - // https://github.com/djrtwo/interop-test-cases/tree/master/tests/night_one_16_crosslinks - name: "ZcliTrinityLighthouseCrosslinks", - blockPath: "testdata/minimal/crosslink_mismatch/block.ssz", - preStatePath: "testdata/minimal/crosslink_mismatch/pre.ssz", - postStatePath: "testdata/minimal/crosslink_mismatch/post.ssz", - }, - } - for _, test := range tests { - t.Run(test.name, func(tt *testing.T) { - block := ðpb.BeaconBlock{} - pre := &pb.BeaconState{} - post := &pb.BeaconState{} - - params.UseMinimalConfig() - - loadSszOrDie(t, test.blockPath, block) - loadSszOrDie(t, test.preStatePath, pre) - loadSszOrDie(t, test.postStatePath, post) - - result, err := ExecuteStateTransition(context.Background(), pre, block) - if err != nil { - t.Logf("Could not process state transition %v", err) - } - if !ssz.DeepEqual(result, post) { - diff, _ := messagediff.PrettyDiff(result, post) - t.Log(diff) - t.Fatal("Resulting state is not equal to expected post state") - } - }) - } -} - -func loadSszOrDie(t *testing.T, filepath string, dst interface{}) { - b, err := ioutil.ReadFile(filepath) - if err != nil { - t.Fatal(err) - } - if err := ssz.Unmarshal(b, dst); err != nil { - t.Fatal(err) - } -} diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index e9de909866..b0a7b34302 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/go-ssz" b "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/mathutil" @@ -26,6 +25,7 @@ import ( // genesis_time=eth1_timestamp - eth1_timestamp % SECONDS_PER_DAY + 2 * SECONDS_PER_DAY, // eth1_data=Eth1Data(block_hash=eth1_block_hash, deposit_count=len(deposits)), // latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), +// randao_mixes=[eth1_block_hash] * EPOCHS_PER_HISTORICAL_VECTOR, # Seed RANDAO with Eth1 entropy // ) // // # Process deposits @@ -52,9 +52,15 @@ import ( // state.compact_committees_roots[index] = committee_root // return state func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data *ethpb.Eth1Data) (*pb.BeaconState, error) { + if eth1Data == nil { + return nil, errors.New("no eth1data provided for genesis state") + } + randaoMixes := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) for i := 0; i < len(randaoMixes); i++ { - randaoMixes[i] = make([]byte, 32) + h := make([]byte, 32) + copy(h, eth1Data.BlockHash) + randaoMixes[i] = h } zeroHash := params.BeaconConfig().ZeroHash[:] @@ -64,16 +70,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data activeIndexRoots[i] = zeroHash } - compactRoots := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) - - crosslinks := make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount) - for i := 0; i < len(crosslinks); i++ { - crosslinks[i] = ðpb.Crosslink{ - ParentRoot: make([]byte, 32), - DataRoot: make([]byte, 32), - } - } - blockRoots := make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot) for i := 0; i < len(blockRoots); i++ { blockRoots[i] = zeroHash @@ -86,10 +82,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector) - if eth1Data == nil { - return nil, errors.New("no eth1data provided for genesis state") - } - eth1Data.DepositCount = uint64(len(deposits)) state := &pb.BeaconState{ @@ -125,11 +117,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data Root: params.BeaconConfig().ZeroHash[:], }, - // Recent state. - CurrentCrosslinks: crosslinks, - PreviousCrosslinks: crosslinks, - ActiveIndexRoots: activeIndexRoots, - CompactCommitteesRoots: compactRoots, HistoricalRoots: [][]byte{}, BlockRoots: blockRoots, StateRoots: stateRoots, @@ -197,23 +184,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data } } - // Populate latest_active_index_roots - activeIndices, err := helpers.ActiveValidatorIndices(state, 0) - if err != nil { - return nil, errors.Wrap(err, "could not get active validator indices") - } - genesisActiveIndexRoot, err := ssz.HashTreeRootWithCapacity(activeIndices, params.BeaconConfig().ValidatorRegistryLimit) - if err != nil { - return nil, errors.Wrap(err, "could not hash tree root active indices") - } - genesisCompactCommRoot, err := helpers.CompactCommitteesRoot(state, 0) - if err != nil { - return nil, errors.Wrap(err, "could not get compact committee root") - } - for i := uint64(0); i < params.BeaconConfig().EpochsPerHistoricalVector; i++ { - state.ActiveIndexRoots[i] = genesisActiveIndexRoot[:] - state.CompactCommitteesRoots[i] = genesisCompactCommRoot[:] - } return state, nil } diff --git a/beacon-chain/core/state/state_test.go b/beacon-chain/core/state/state_test.go index f362bbc844..2b7c078790 100644 --- a/beacon-chain/core/state/state_test.go +++ b/beacon-chain/core/state/state_test.go @@ -5,7 +5,6 @@ import ( "reflect" "testing" - "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" @@ -16,10 +15,6 @@ import ( ) func TestGenesisBeaconState_OK(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - genesisEpochNumber := uint64(0) if !bytes.Equal(params.BeaconConfig().GenesisForkVersion, []byte{0, 0, 0, 0}) { @@ -36,11 +31,6 @@ func TestGenesisBeaconState_OK(t *testing.T) { } latestRandaoMixesLength := int(params.BeaconConfig().EpochsPerHistoricalVector) - if params.BeaconConfig().ShardCount != 1024 { - t.Error("ShardCount should be 1024 for these tests to pass") - } - shardCount := int(params.BeaconConfig().ShardCount) - if params.BeaconConfig().HistoricalRootsLimit != 16777216 { t.Error("HistoricalRootsLimit should be 16777216 for these tests to pass") } @@ -54,11 +44,7 @@ func TestGenesisBeaconState_OK(t *testing.T) { genesisTime := uint64(99999) deposits, _, _ := testutil.SetupInitialDeposits(t, uint64(depositsForChainStart)) eth1Data := testutil.GenerateEth1Data(t, deposits) - newState, err := state.GenesisBeaconState( - deposits, - genesisTime, - eth1Data, - ) + newState, err := state.GenesisBeaconState(deposits, genesisTime, eth1Data) if err != nil { t.Fatalf("could not execute GenesisBeaconState: %v", err) } @@ -93,7 +79,7 @@ func TestGenesisBeaconState_OK(t *testing.T) { if len(newState.RandaoMixes) != latestRandaoMixesLength { t.Error("Length of RandaoMixes was not correctly initialized") } - if !bytes.Equal(newState.RandaoMixes[0], make([]byte, 32)) { + if !bytes.Equal(newState.RandaoMixes[0], eth1Data.BlockHash) { t.Error("RandaoMixes was not correctly initialized") } @@ -112,12 +98,6 @@ func TestGenesisBeaconState_OK(t *testing.T) { } // Recent state checks. - if len(newState.CurrentCrosslinks) != shardCount { - t.Error("Length of CurrentCrosslinks was not correctly initialized") - } - if len(newState.PreviousCrosslinks) != shardCount { - t.Error("Length of PreviousCrosslinks was not correctly initialized") - } if !reflect.DeepEqual(newState.Slashings, make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)) { t.Error("Slashings was not correctly initialized") } @@ -128,32 +108,11 @@ func TestGenesisBeaconState_OK(t *testing.T) { t.Error("PreviousEpochAttestations was not correctly initialized") } - activeValidators, _ := helpers.ActiveValidatorIndices(newState, 0) - genesisActiveIndexRoot, err := ssz.HashTreeRootWithCapacity(activeValidators, params.BeaconConfig().ValidatorRegistryLimit) - if err != nil { - t.Errorf("could not hash tree root: %v", err) - } - if !bytes.Equal(newState.ActiveIndexRoots[0], genesisActiveIndexRoot[:]) { - t.Errorf( - "Expected index roots to be the tree hash root of active validator indices, received %#x", - newState.ActiveIndexRoots[0], - ) - } - if !bytes.Equal(newState.ActiveIndexRoots[0], genesisActiveIndexRoot[:]) { - t.Errorf( - "Expected index roots to be the tree hash root of active validator indices, received %#x", - newState.ActiveIndexRoots[0], - ) - } - zeroHash := params.BeaconConfig().ZeroHash[:] // History root checks. if !bytes.Equal(newState.StateRoots[0], zeroHash) { t.Error("StateRoots was not correctly initialized") } - if bytes.Equal(newState.ActiveIndexRoots[0], zeroHash) || bytes.Equal(newState.ActiveIndexRoots[0], []byte{}) { - t.Error("ActiveIndexRoots was not correctly initialized") - } if !bytes.Equal(newState.BlockRoots[0], zeroHash) { t.Error("BlockRoots was not correctly initialized") } @@ -170,11 +129,11 @@ func TestGenesisBeaconState_OK(t *testing.T) { func TestGenesisState_HashEquality(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - state1, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state1, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Error(err) } - state2, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state2, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Error(err) } diff --git a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/block.ssz b/beacon-chain/core/state/testdata/minimal/artemis_crosslink/block.ssz deleted file mode 100644 index f38616caa2..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/block.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/post.ssz b/beacon-chain/core/state/testdata/minimal/artemis_crosslink/post.ssz deleted file mode 100644 index 9198471a2d..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/post.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/pre.ssz b/beacon-chain/core/state/testdata/minimal/artemis_crosslink/pre.ssz deleted file mode 100644 index f57be45aff..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/artemis_crosslink/pre.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/block.ssz b/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/block.ssz deleted file mode 100644 index 8a271f0d0b..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/block.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/post.ssz b/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/post.ssz deleted file mode 100644 index c478aacd3f..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/post.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/pre.ssz b/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/pre.ssz deleted file mode 100644 index 4f4b6b6dd5..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/crosslink_mismatch/pre.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/block.ssz b/beacon-chain/core/state/testdata/minimal/duplicate_rewards/block.ssz deleted file mode 100644 index 9192771ec2..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/block.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/post.ssz b/beacon-chain/core/state/testdata/minimal/duplicate_rewards/post.ssz deleted file mode 100755 index 0e0e0eebef..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/post.ssz and /dev/null differ diff --git a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/pre.ssz b/beacon-chain/core/state/testdata/minimal/duplicate_rewards/pre.ssz deleted file mode 100644 index f6dc272317..0000000000 Binary files a/beacon-chain/core/state/testdata/minimal/duplicate_rewards/pre.ssz and /dev/null differ diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index a03c58037e..005473dc88 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -19,7 +19,6 @@ import ( pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -62,7 +61,7 @@ func ExecuteStateTransition( if block != nil { state, err = ProcessBlock(ctx, state, block) if err != nil { - return nil, errors.Wrap(err, "could not process block") + return nil, errors.Wrapf(err, "could not process block in slot %d", block.Slot) } } @@ -445,19 +444,6 @@ func ProcessOperations( return nil, errors.Wrap(err, "could not verify operation lengths") } - // Verify that there are no duplicate transfers - transferSet := make(map[[32]byte]bool) - for _, transfer := range body.Transfers { - h, err := hashutil.HashProto(transfer) - if err != nil { - return nil, errors.Wrap(err, "could not hash transfer") - } - if transferSet[h] { - return nil, fmt.Errorf("duplicate transfer: %v", transfer) - } - transferSet[h] = true - } - state, err := b.ProcessProposerSlashings(ctx, state, body) if err != nil { return nil, errors.Wrap(err, "could not process block proposer slashings") @@ -478,10 +464,6 @@ func ProcessOperations( if err != nil { return nil, errors.Wrap(err, "could not process validator exits") } - state, err = b.ProcessTransfers(state, body) - if err != nil { - return nil, errors.Wrap(err, "could not process block transfers") - } return state, nil } @@ -522,19 +504,6 @@ func processOperationsNoVerify( return nil, errors.Wrap(err, "could not verify operation lengths") } - // Verify that there are no duplicate transfers - transferSet := make(map[[32]byte]bool) - for _, transfer := range body.Transfers { - h, err := hashutil.HashProto(transfer) - if err != nil { - return nil, errors.Wrap(err, "could not hash transfer") - } - if transferSet[h] { - return nil, fmt.Errorf("duplicate transfer: %v", transfer) - } - transferSet[h] = true - } - state, err := b.ProcessProposerSlashings(ctx, state, body) if err != nil { return nil, errors.Wrap(err, "could not process block proposer slashings") @@ -555,10 +524,6 @@ func processOperationsNoVerify( if err != nil { return nil, errors.Wrap(err, "could not process validator exits") } - state, err = b.ProcessTransfers(state, body) - if err != nil { - return nil, errors.Wrap(err, "could not process block transfers") - } return state, nil } @@ -596,14 +561,6 @@ func verifyOperationLengths(state *pb.BeaconState, body *ethpb.BeaconBlockBody) ) } - if uint64(len(body.Transfers)) > params.BeaconConfig().MaxTransfers { - return fmt.Errorf( - "number of transfers (%d) in block body exceeds allowed threshold of %d", - len(body.Transfers), - params.BeaconConfig().MaxTransfers, - ) - } - if state.Eth1DepositIndex > state.Eth1Data.DepositCount { return fmt.Errorf("expected state.deposit_index %d <= eth1data.deposit_count %d", state.Eth1DepositIndex, state.Eth1Data.DepositCount) } @@ -670,11 +627,6 @@ func ProcessEpoch(ctx context.Context, state *pb.BeaconState) (*pb.BeaconState, return nil, errors.Wrap(err, "could not process justification") } - state, err = e.ProcessCrosslinks(state) - if err != nil { - return nil, errors.Wrap(err, "could not process crosslink") - } - state, err = e.ProcessRewardsAndPenalties(state) if err != nil { return nil, errors.Wrap(err, "could not process rewards and penalties") @@ -715,11 +667,6 @@ func ProcessEpochPrecompute(ctx context.Context, state *pb.BeaconState) (*pb.Bea return nil, errors.Wrap(err, "could not process justification") } - state, err = e.ProcessCrosslinks(state) - if err != nil { - return nil, errors.Wrap(err, "could not process crosslink") - } - state, err = precompute.ProcessRewardsAndPenaltiesPrecompute(state, bp, vp) if err != nil { return nil, errors.Wrap(err, "could not process rewards and penalties") diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index 7b417cc6d8..65908745de 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -40,7 +40,7 @@ func TestExecuteStateTransition_IncorrectSlot(t *testing.T) { func TestExecuteStateTransition_FullProcess(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -54,7 +54,6 @@ func TestExecuteStateTransition_FullProcess(t *testing.T) { beaconState.Eth1DataVotes = []*ethpb.Eth1Data{eth1Data} oldMix := beaconState.RandaoMixes[1] - oldStartShard := beaconState.StartShard parentRoot, err := ssz.SigningRoot(beaconState.LatestBlockHeader) if err != nil { t.Error(err) @@ -93,23 +92,19 @@ func TestExecuteStateTransition_FullProcess(t *testing.T) { t.Error(err) } - if beaconState.Slot != 64 { + if beaconState.Slot != params.BeaconConfig().SlotsPerEpoch { t.Errorf("Unexpected Slot number, expected: 64, received: %d", beaconState.Slot) } if bytes.Equal(beaconState.RandaoMixes[1], oldMix) { t.Errorf("Did not expect new and old randao mix to equal, %#x == %#x", beaconState.RandaoMixes[0], oldMix) } - - if beaconState.StartShard == oldStartShard { - t.Errorf("Did not expect new and old start shard to equal, %#x == %#x", beaconState.StartShard, oldStartShard) - } } func TestProcessBlock_IncorrectProposerSlashing(t *testing.T) { helpers.ClearAllCaches() - deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + deposits, _, privKeys := testutil.SetupInitialDeposits(t, 34) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -164,7 +159,7 @@ func TestProcessBlock_IncorrectProposerSlashing(t *testing.T) { func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -208,9 +203,6 @@ func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } @@ -222,7 +214,7 @@ func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { if err != nil { t.Error(err) } - domain = helpers.Domain(beaconState.Fork, currentEpoch, params.BeaconConfig().DomainAttestation) + domain = helpers.Domain(beaconState.Fork, currentEpoch, params.BeaconConfig().DomainBeaconAttester) sig0 := privKeys[0].Sign(hashTreeRoot[:], domain) sig1 := privKeys[1].Sign(hashTreeRoot[:], domain) aggregateSig := bls.AggregateSignatures([]*bls.Signature{sig0, sig1}) @@ -232,9 +224,6 @@ func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } @@ -260,8 +249,7 @@ func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { att := ðpb.Attestation{ Data: ðpb.AttestationData{ - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{}, + Target: ðpb.Checkpoint{Epoch: 0}, }, AggregationBits: bitfield.NewBitlist(0), CustodyBits: bitfield.NewBitlist(0), @@ -315,7 +303,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -339,18 +327,14 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }}, + }, CustodyBit_0Indices: []uint64{0, 1}, }, Attestation_2: ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }}, + }, CustodyBit_0Indices: []uint64{0, 1}, }, }, @@ -360,19 +344,10 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { blockRoots = append(blockRoots, []byte{byte(i)}) } beaconState.BlockRoots = blockRoots - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - DataRoot: []byte{1}, - }, - } blockAtt := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01}, CustodyBits: bitfield.Bitlist{0x00, 0x00, 0x00, 0x00, 0x01}, @@ -412,29 +387,16 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { }, } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - block.Body.Attestations[0].Data.Crosslink.ParentRoot = encoded[:] - block.Body.Attestations[0].Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] if _, err := state.ProcessBlock(context.Background(), beaconState, block); err == nil { t.Error("Expected err, received nil") } } func TestProcessBlock_PassesProcessingConditions(t *testing.T) { - deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + deposits, _, privKeys := testutil.SetupInitialDeposits(t, 32) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -449,19 +411,8 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { BodyRoot: bodyRoot[:], } beaconState.Slashings = make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector) - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: helpers.SlotToEpoch(beaconState.Slot), - DataRoot: []byte{1}, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } proposerSlashIdx := uint64(3) slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch @@ -506,11 +457,7 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { att1 := ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte{'A'}}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, - }, + Target: ðpb.Checkpoint{Epoch: 0}}, CustodyBit_0Indices: []uint64{0, 1}, } dataAndCustodyBit := &pb.AttestationDataAndCustodyBit{ @@ -521,7 +468,7 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { if err != nil { t.Error(err) } - domain = helpers.Domain(beaconState.Fork, currentEpoch, params.BeaconConfig().DomainAttestation) + domain = helpers.Domain(beaconState.Fork, currentEpoch, params.BeaconConfig().DomainBeaconAttester) sig0 := privKeys[0].Sign(hashTreeRoot[:], domain) sig1 := privKeys[1].Sign(hashTreeRoot[:], domain) aggregateSig := bls.AggregateSignatures([]*bls.Signature{sig0, sig1}) @@ -530,11 +477,7 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { att2 := ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte{'B'}}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, - }, + Target: ðpb.Checkpoint{Epoch: 0}}, CustodyBit_0Indices: []uint64{0, 1}, } dataAndCustodyBit = &pb.AttestationDataAndCustodyBit{ @@ -568,18 +511,12 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { custodyBits := bitfield.NewBitlist(1) blockAtt := ðpb.Attestation{ Data: ðpb.AttestationData{ + Slot: beaconState.Slot - 1, Target: ðpb.Checkpoint{Epoch: helpers.SlotToEpoch(beaconState.Slot)}, Source: ðpb.Checkpoint{ Epoch: 0, Root: []byte("hello-world"), - }, - Crosslink: ðpb.Crosslink{ - Shard: 0, - EndEpoch: 64, - DataRoot: params.BeaconConfig().ZeroHash[:], - ParentRoot: encoded[:], - }, - }, + }}, AggregationBits: aggBits, CustodyBits: custodyBits, } @@ -674,12 +611,11 @@ func TestProcessEpoch_CantGetTgtAttsPrevEpoch(t *testing.T) { func TestProcessEpoch_CantGetTgtAttsCurrEpoch(t *testing.T) { epoch := uint64(1) - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 100}}}} + atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{}}} _, err := state.ProcessEpoch(context.Background(), &pb.BeaconState{ Slot: epoch * params.BeaconConfig().SlotsPerEpoch, BlockRoots: make([][]byte, 128), RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), CurrentEpochAttestations: atts}) if !strings.Contains(err.Error(), "could not get target atts current epoch") { t.Fatal("Did not receive wanted error") @@ -690,22 +626,12 @@ func TestProcessEpoch_CanProcess(t *testing.T) { helpers.ClearAllCaches() epoch := uint64(1) - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 0}, Target: ðpb.Checkpoint{}}}} - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } + atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} newState, err := state.ProcessEpoch(context.Background(), &pb.BeaconState{ Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, @@ -725,22 +651,13 @@ func TestProcessEpochPrecompute_CanProcess(t *testing.T) { helpers.ClearAllCaches() epoch := uint64(1) - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 0}, Target: ðpb.Checkpoint{}}}} - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } + atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} + newState, err := state.ProcessEpochPrecompute(context.Background(), &pb.BeaconState{ Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, @@ -758,9 +675,8 @@ func TestProcessEpochPrecompute_CanProcess(t *testing.T) { func TestProcessEpoch_NotPanicOnEmptyActiveValidatorIndices(t *testing.T) { newState := &pb.BeaconState{ - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().SlotsPerEpoch), + Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), + RandaoMixes: make([][]byte, params.BeaconConfig().SlotsPerEpoch), } state.ProcessEpoch(context.Background(), newState) @@ -773,7 +689,7 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { epoch := uint64(1) validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount * 4 - shardCount := validatorCount / params.BeaconConfig().TargetCommitteeSize + comitteeCount := validatorCount / params.BeaconConfig().TargetCommitteeSize validators := make([]*ethpb.Validator, validatorCount) balances := make([]uint64, validatorCount) @@ -786,44 +702,29 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { } var atts []*pb.PendingAttestation - for i := uint64(0); i < shardCount; i++ { + for i := uint64(0); i < comitteeCount; i++ { atts = append(atts, &pb.PendingAttestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: i, - }, - }, + Data: ðpb.AttestationData{}, AggregationBits: []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, InclusionDelay: 1, }) } - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } - s := &pb.BeaconState{ Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, Validators: validators, Balances: balances, - StartShard: 512, FinalizedCheckpoint: ðpb.Checkpoint{}, BlockRoots: make([][]byte, 254), Slashings: []uint64{0, 1e9, 0}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, PreviousEpochAttestations: atts, } // Precache the shuffled indices - for i := uint64(0); i < shardCount; i++ { - if _, err := helpers.CrosslinkCommittee(s, 0, i); err != nil { + for i := uint64(0); i < comitteeCount; i++ { + if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } } @@ -840,11 +741,9 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { logrus.SetLevel(logrus.PanicLevel) helpers.ClearAllCaches() - testConfig := params.BeaconConfig() - testConfig.MaxTransfers = 1 validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount * 4 - shardCount := validatorCount / params.BeaconConfig().TargetCommitteeSize + committeeCount := validatorCount / params.BeaconConfig().TargetCommitteeSize validators := make([]*ethpb.Validator, validatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -864,14 +763,6 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { randaoMixes[i] = params.BeaconConfig().ZeroHash[:] } - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } - s := &pb.BeaconState{ Slot: 20, LatestBlockHeader: ðpb.BeaconBlockHeader{}, @@ -880,7 +771,6 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { Validators: validators, Balances: validatorBalances, Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), CurrentJustifiedCheckpoint: ðpb.Checkpoint{ Root: []byte("hello-world"), }, @@ -888,7 +778,6 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, - CurrentCrosslinks: crosslinks, } // Set up proposer slashing object for block @@ -910,19 +799,11 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { attesterSlashings := []*ethpb.AttesterSlashing{ { Attestation_1: ðpb.IndexedAttestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, - }, + Data: ðpb.AttestationData{}, CustodyBit_0Indices: []uint64{2, 3}, }, Attestation_2: ðpb.IndexedAttestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, - }, + Data: ðpb.AttestationData{}, CustodyBit_0Indices: []uint64{2, 3}, }, }, @@ -965,40 +846,17 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { domain := helpers.Domain(s.Fork, 0, params.BeaconConfig().DomainRandao) epochSignature := priv.Sign(buf, domain) - // Set up transfer object for block - transfers := []*ethpb.Transfer{ - { - Slot: s.Slot, - SenderIndex: 3, - RecipientIndex: 4, - Fee: params.BeaconConfig().MinDepositAmount, - Amount: params.BeaconConfig().MinDepositAmount, - SenderWithdrawalPublicKey: []byte("A"), - }, - } buf = []byte{params.BeaconConfig().BLSWithdrawalPrefixByte} pubKey := []byte("A") hashed := hashutil.Hash(pubKey) buf = append(buf, hashed[:]...) s.Validators[3].WithdrawalCredentials = buf - // Set up attestations obj for block. - encoded, err := ssz.HashTreeRoot(s.CurrentCrosslinks[0]) - if err != nil { - b.Fatal(err) - } - attestations := make([]*ethpb.Attestation, 128) for i := 0; i < len(attestations); i++ { attestations[i] = ðpb.Attestation{ Data: ðpb.AttestationData{ - Source: ðpb.Checkpoint{Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - ParentRoot: encoded[:], - DataRoot: params.BeaconConfig().ZeroHash[:], - }, - }, + Source: ðpb.Checkpoint{Root: []byte("hello-world")}}, AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x01}, CustodyBits: bitfield.NewBitlist(0), @@ -1016,13 +874,12 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { Attestations: attestations, ProposerSlashings: proposerSlashings, AttesterSlashings: attesterSlashings, - Transfers: transfers, }, } // Precache the shuffled indices - for i := uint64(0); i < shardCount; i++ { - if _, err := helpers.CrosslinkCommittee(s, 0, i); err != nil { + for i := uint64(0); i < committeeCount; i++ { + if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } } @@ -1047,7 +904,7 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { // Default at 256 validators, can raise this number with faster BLS. validatorCount := uint64(256) deposits, _, privKeys := testutil.SetupInitialDeposits(t, validatorCount) - s, _ := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + s, _ := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) s.Slot = params.BeaconConfig().SlotsPerEpoch bitCount := validatorCount / params.BeaconConfig().SlotsPerEpoch @@ -1056,21 +913,13 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { for i := uint64(1); i < bitCount; i++ { aggBits.SetBitAt(i, true) } - atts := make([]*ethpb.Attestation, 64) - crosslinkRoot, _ := ssz.HashTreeRoot(s.CurrentCrosslinks[0]) + atts := make([]*ethpb.Attestation, 1) for i := 0; i < len(atts); i++ { att := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: params.BeaconConfig().ZeroHash[:]}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: uint64(i + 960), - StartEpoch: 0, - ParentRoot: crosslinkRoot[:], - DataRoot: params.BeaconConfig().ZeroHash[:], - }, - }, + Target: ðpb.Checkpoint{Epoch: 0}}, AggregationBits: aggBits, CustodyBits: custodyBits, } @@ -1082,7 +931,8 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { Data: att.Data, CustodyBit: false, } - domain := helpers.Domain(s.Fork, 0, params.BeaconConfig().DomainAttestation) + + domain := helpers.Domain(s.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sigs := make([]*bls.Signature, len(attestingIndices)) for i, indice := range attestingIndices { hashTreeRoot, err := ssz.HashTreeRoot(dataAndCustodyBit) @@ -1120,10 +970,6 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { } func TestCanProcessEpoch_TrueOnEpochs(t *testing.T) { - if params.BeaconConfig().SlotsPerEpoch != 64 { - t.Errorf("SlotsPerEpoch should be 64 for these tests to pass") - } - tests := []struct { slot uint64 canProcessEpoch bool @@ -1216,24 +1062,6 @@ func TestProcessOperations_OverMaxAttestations(t *testing.T) { } } -func TestProcessOperations_OverMaxTransfers(t *testing.T) { - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Transfers: make([]*ethpb.Transfer, params.BeaconConfig().MaxTransfers+1), - }, - } - - want := fmt.Sprintf("number of transfers (%d) in block body exceeds allowed threshold of %d", - len(block.Body.Transfers), params.BeaconConfig().MaxTransfers) - if _, err := state.ProcessOperations( - context.Background(), - &pb.BeaconState{}, - block.Body, - ); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } -} - func TestProcessOperation_OverMaxVoluntaryExits(t *testing.T) { maxExits := params.BeaconConfig().MaxVoluntaryExits block := ðpb.BeaconBlock{ @@ -1274,37 +1102,3 @@ func TestProcessOperations_IncorrectDeposits(t *testing.T) { t.Errorf("Expected %s, received %v", want, err) } } - -func TestProcessOperation_DuplicateTransfer(t *testing.T) { - testConfig := params.BeaconConfig() - testConfig.MaxTransfers = 2 - transfers := []*ethpb.Transfer{ - { - Amount: 1, - }, - { - Amount: 1, - }, - } - registry := []*ethpb.Validator{} - s := &pb.BeaconState{ - Validators: registry, - Eth1Data: ðpb.Eth1Data{DepositCount: 100}, - Eth1DepositIndex: 98, - } - block := ðpb.BeaconBlock{ - Body: ðpb.BeaconBlockBody{ - Transfers: transfers, - Deposits: []*ethpb.Deposit{{}, {}}, - }, - } - - want := "duplicate transfer" - if _, err := state.ProcessOperations( - context.Background(), - s, - block.Body, - ); !strings.Contains(err.Error(), want) { - t.Errorf("Expected %s, received %v", want, err) - } -} diff --git a/beacon-chain/core/validators/validator_test.go b/beacon-chain/core/validators/validator_test.go index 9251d9ead1..6c58f1bf66 100644 --- a/beacon-chain/core/validators/validator_test.go +++ b/beacon-chain/core/validators/validator_test.go @@ -113,12 +113,12 @@ func TestSlashValidator_OK(t *testing.T) { } bState := &pb.BeaconState{ - Validators: registry, - Slot: 0, - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - Balances: balances, + Validators: registry, + Slot: 0, + Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + + Balances: balances, } slashedIdx := uint64(2) diff --git a/beacon-chain/db/filters/filter.go b/beacon-chain/db/filters/filter.go index 0ecd6d21c5..985061d0df 100644 --- a/beacon-chain/db/filters/filter.go +++ b/beacon-chain/db/filters/filter.go @@ -3,15 +3,13 @@ // For example, one can specify a filter query for data by start epoch + end epoch + shard // for attestations, build a filter as follows, and respond to it accordingly: // -// f := filters.NewFilter().SetStartEpoch(3).SetEndEpoch(5).SetShard(5) +// f := filters.NewFilter().SetStartEpoch(3).SetEndEpoch(5) // for k, v := range f.Filters() { // switch k { // case filters.StartEpoch: // // Verify data matches filter criteria... // case filters.EndEpoch: // // Verify data matches filter criteria... -// case filters.Shard: -// // Verify data matches filter criteria... // } // } package filters @@ -31,18 +29,16 @@ const ( StartEpoch FilterType = 3 // EndEpoch is used for range filters of objects by their epoch (inclusive). EndEpoch FilterType = 4 - // Shard is used for filtering data by shard index. - Shard FilterType = 5 // HeadBlockRoot defines a filter for the head block root attribute of objects. - HeadBlockRoot FilterType = 6 + HeadBlockRoot FilterType = 5 // SourceEpoch defines a filter for the source epoch attribute of objects. - SourceEpoch FilterType = 7 + SourceEpoch FilterType = 6 // SourceRoot defines a filter for the source root attribute of objects. - SourceRoot FilterType = 8 + SourceRoot FilterType = 7 // TargetEpoch defines a filter for the target epoch attribute of objects. - TargetEpoch FilterType = 9 + TargetEpoch FilterType = 8 // TargetRoot defines a filter for the target root attribute of objects. - TargetRoot FilterType = 10 + TargetRoot FilterType = 9 ) // QueryFilter defines a generic interface for type-asserting @@ -125,9 +121,3 @@ func (q *QueryFilter) SetEndEpoch(val uint64) *QueryFilter { q.queries[EndEpoch] = val return q } - -// SetShard enabled filtering by the Shard attribute of an object. -func (q *QueryFilter) SetShard(val uint64) *QueryFilter { - q.queries[Shard] = val - return q -} diff --git a/beacon-chain/db/filters/filter_test.go b/beacon-chain/db/filters/filter_test.go index 72e2598c8a..53c69ecfb7 100644 --- a/beacon-chain/db/filters/filter_test.go +++ b/beacon-chain/db/filters/filter_test.go @@ -8,11 +8,11 @@ func TestQueryFilter_ChainsCorrectly(t *testing.T) { f := NewFilter(). SetStartSlot(2). SetEndSlot(4). - SetParentRoot([]byte{3, 4, 5}). - SetShard(0) + SetParentRoot([]byte{3, 4, 5}) + filterSet := f.Filters() - if len(filterSet) != 4 { - t.Errorf("Expected 4 filters to have been set, received %d", len(filterSet)) + if len(filterSet) != 3 { + t.Errorf("Expected 3 filters to have been set, received %d", len(filterSet)) } for k, v := range filterSet { switch k { @@ -22,8 +22,6 @@ func TestQueryFilter_ChainsCorrectly(t *testing.T) { t.Log(v.(uint64)) case ParentRoot: t.Log(v.([]byte)) - case Shard: - t.Log(v.(uint64)) default: t.Log("Unknown filter type") } diff --git a/beacon-chain/db/kv/archive_test.go b/beacon-chain/db/kv/archive_test.go index e883b9b639..e995fed486 100644 --- a/beacon-chain/db/kv/archive_test.go +++ b/beacon-chain/db/kv/archive_test.go @@ -67,13 +67,6 @@ func TestStore_ArchivedActiveValidatorChanges(t *testing.T) { Epoch: 5, Root: someRoot[:], }, - Crosslink: ðpb.Crosslink{ - Shard: 3, - ParentRoot: someRoot[:], - StartEpoch: 3, - EndEpoch: 4, - DataRoot: someRoot[:], - }, }, }, Attestation_2: ðpb.IndexedAttestation{ @@ -87,13 +80,6 @@ func TestStore_ArchivedActiveValidatorChanges(t *testing.T) { Epoch: 5, Root: someRoot[:], }, - Crosslink: ðpb.Crosslink{ - Shard: 3, - ParentRoot: someRoot[:], - StartEpoch: 3, - EndEpoch: 4, - DataRoot: someRoot[:], - }, }, }, }, @@ -118,8 +104,8 @@ func TestStore_ArchivedCommitteeInfo(t *testing.T) { ctx := context.Background() someSeed := [32]byte{1, 2, 3} info := ðpb.ArchivedCommitteeInfo{ - Seed: someSeed[:], - StartShard: 10, + ProposerSeed: someSeed[:], + AttesterSeed: someSeed[:], CommitteeCount: 4096, } epoch := uint64(10) diff --git a/beacon-chain/db/kv/attestations_test.go b/beacon-chain/db/kv/attestations_test.go index 52b5e77f05..6089b45387 100644 --- a/beacon-chain/db/kv/attestations_test.go +++ b/beacon-chain/db/kv/attestations_test.go @@ -19,14 +19,7 @@ func TestStore_AttestationCRUD(t *testing.T) { db := setupDB(t) defer teardownDB(t, db) att := ðpb.Attestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - ParentRoot: []byte("parent"), - StartEpoch: 1, - EndEpoch: 2, - }, - }, + Data: ðpb.AttestationData{Slot: 10}, AggregationBits: bitfield.Bitlist{0b00000001, 0b1}, CustodyBits: bitfield.NewBitlist(8), } @@ -76,12 +69,7 @@ func TestStore_AttestationsBatchDelete(t *testing.T) { totalAtts[i] = ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("head"), - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - ParentRoot: []byte("parent"), - StartEpoch: 1, - EndEpoch: 2, - }, + Slot: uint64(i), }, AggregationBits: bitfield.Bitlist{0b00000001, 0b1}, CustodyBits: bitfield.NewBitlist(8), @@ -116,7 +104,7 @@ func TestStore_AttestationsBatchDelete(t *testing.T) { t.Fatal(err) } sort.Slice(retrieved, func(i, j int) bool { - return retrieved[i].Data.Crosslink.Shard < retrieved[j].Data.Crosslink.Shard + return retrieved[i].Data.Slot < retrieved[j].Data.Slot }) if !reflect.DeepEqual(retrieved, oddAtts) { t.Errorf("Wanted %v, received %v", oddAtts, retrieved) @@ -130,14 +118,7 @@ func TestStore_BoltDontPanic(t *testing.T) { for i := 0; i <= 100; i++ { att := ðpb.Attestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - ParentRoot: []byte("parent"), - StartEpoch: uint64(i + 1), - EndEpoch: 2, - }, - }, + Data: ðpb.AttestationData{Slot: uint64(i)}, AggregationBits: bitfield.Bitlist{0b11}, } ctx := context.Background() @@ -162,14 +143,7 @@ func TestStore_BoltDontPanic(t *testing.T) { wg.Add(1) go func() { att := ðpb.Attestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - ParentRoot: []byte("parent"), - StartEpoch: uint64(startEpoch), - EndEpoch: 2, - }, - }, + Data: ðpb.AttestationData{Slot: uint64(startEpoch)}, AggregationBits: bitfield.Bitlist{0b11}, } ctx := context.Background() @@ -292,14 +266,7 @@ func TestStore_Attestations_FiltersCorrectly(t *testing.T) { } func TestStore_Attestations_BitfieldLogic(t *testing.T) { - commonData := ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: 5, - ParentRoot: []byte("parent"), - StartEpoch: 1, - EndEpoch: 2, - }, - } + commonData := ðpb.AttestationData{Slot: 10} tests := []struct { name string diff --git a/beacon-chain/db/kv/slashings_test.go b/beacon-chain/db/kv/slashings_test.go index 777b60059e..e4bdbe20a5 100644 --- a/beacon-chain/db/kv/slashings_test.go +++ b/beacon-chain/db/kv/slashings_test.go @@ -56,17 +56,13 @@ func TestStore_AttesterSlashing_CRUD(t *testing.T) { Attestation_1: ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: make([]byte, 32), - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, + Slot: 5, }, }, Attestation_2: ðpb.IndexedAttestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: make([]byte, 32), - Crosslink: ðpb.Crosslink{ - Shard: 7, - }, + Slot: 7, }, }, } diff --git a/beacon-chain/gateway/gateway.go b/beacon-chain/gateway/gateway.go index ef09dfee95..640cc43587 100644 --- a/beacon-chain/gateway/gateway.go +++ b/beacon-chain/gateway/gateway.go @@ -46,6 +46,7 @@ func (g *Gateway) Start() { } g.conn = conn + gwmux := gwruntime.NewServeMux(gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.JSONPb{OrigName: false})) for _, f := range []func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error{ ethpb.RegisterNodeHandler, diff --git a/beacon-chain/operations/attestation_test.go b/beacon-chain/operations/attestation_test.go index 8c05679339..463cae1c87 100644 --- a/beacon-chain/operations/attestation_test.go +++ b/beacon-chain/operations/attestation_test.go @@ -30,7 +30,7 @@ func TestHandleAttestation_Saves_NewAttestation(t *testing.T) { }) deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -40,10 +40,6 @@ func TestHandleAttestation_Saves_NewAttestation(t *testing.T) { BeaconBlockRoot: []byte("block-root"), Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01}, CustodyBits: bitfield.Bitlist{0x00, 0x00, 0x00, 0x00, 0x01}, @@ -57,7 +53,7 @@ func TestHandleAttestation_Saves_NewAttestation(t *testing.T) { Data: att.Data, CustodyBit: false, } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sigs := make([]*bls.Signature, len(attestingIndices)) for i, indice := range attestingIndices { hashTreeRoot, err := ssz.HashTreeRoot(dataAndCustodyBit) @@ -69,12 +65,6 @@ func TestHandleAttestation_Saves_NewAttestation(t *testing.T) { } att.Signature = bls.AggregateSignatures(sigs).Marshal()[:] - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} @@ -95,12 +85,6 @@ func TestHandleAttestation_Saves_NewAttestation(t *testing.T) { t.Fatal(err) } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att.Data.Crosslink.ParentRoot = encoded[:] - att.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] if err := service.HandleAttestation(context.Background(), att); err != nil { t.Error(err) @@ -120,10 +104,6 @@ func TestHandleAttestation_Aggregates_LargeNumValidators(t *testing.T) { data := ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 1, - StartEpoch: 0, - }, } dataAndCustodyBit := &pb.AttestationDataAndCustodyBit{ Data: data, @@ -140,7 +120,7 @@ func TestHandleAttestation_Aggregates_LargeNumValidators(t *testing.T) { // We setup the genesis state with 256 validators. deposits, _, privKeys := testutil.SetupInitialDeposits(t, 256) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -164,7 +144,7 @@ func TestHandleAttestation_Aggregates_LargeNumValidators(t *testing.T) { } // Next up, we compute the committee for the attestation we're testing. - committee, err := helpers.CrosslinkCommittee(beaconState, att.Data.Target.Epoch, att.Data.Crosslink.Shard) + committee, err := helpers.BeaconCommittee(beaconState, att.Data.Slot, att.Data.Index) if err != nil { t.Error(err) } @@ -173,7 +153,7 @@ func TestHandleAttestation_Aggregates_LargeNumValidators(t *testing.T) { t.Error(err) } totalAggBits := bitfield.NewBitlist(uint64(len(committee))) - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) // For every single member of the committee, we sign the attestation data and handle // the attestation through the operations service, which will perform basic aggregation @@ -229,40 +209,22 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) service.attestationPool = make(map[[32]byte]*dbpb.AttestationContainer) deposits, _, privKeys := testutil.SetupInitialDeposits(t, 200) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} att1 := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, - Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, CustodyBits: bitfield.Bitlist{0x00, 0x00, 0x00, 0x00, 0x01}, } - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att1.Data.Crosslink.ParentRoot = encoded[:] - att1.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - - committee, err := helpers.CrosslinkCommittee(beaconState, att1.Data.Target.Epoch, att1.Data.Crosslink.Shard) + committee, err := helpers.BeaconCommittee(beaconState, att1.Data.Slot, att1.Data.Index) if err != nil { t.Error(err) } @@ -278,17 +240,13 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) if err != nil { t.Error(err) } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) att1.Signature = privKeys[committee[0]].Sign(hashTreeRoot[:], domain).Marshal() att2 := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, CustodyBits: bitfield.Bitlist{0x00, 0x00, 0x00, 0x00, 0x01}, } @@ -296,18 +254,12 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) aggregationBits.SetBitAt(1, true) att2.AggregationBits = aggregationBits - att2.Data.Crosslink.ParentRoot = encoded[:] - att2.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] att2.Signature = privKeys[committee[1]].Sign(hashTreeRoot[:], domain).Marshal() att3 := ðpb.Attestation{ Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, CustodyBits: bitfield.Bitlist{0x00, 0x00, 0x00, 0x00, 0x01}, } @@ -316,8 +268,6 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) aggregationBits.SetBitAt(1, true) att3.AggregationBits = aggregationBits - att3.Data.Crosslink.ParentRoot = encoded[:] - att3.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] att3Sig1 := privKeys[committee[0]].Sign(hashTreeRoot[:], domain) att3Sig2 := privKeys[committee[1]].Sign(hashTreeRoot[:], domain) aggregatedSig := bls.AggregateSignatures([]*bls.Signature{att3Sig1, att3Sig2}).Marshal() @@ -403,8 +353,8 @@ func TestRetrieveAttestations_OK(t *testing.T) { service := NewService(context.Background(), &Config{BeaconDB: beaconDB}) service.attestationPool = make(map[[32]byte]*dbpb.AttestationContainer) - deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{}) + deposits, _, privKeys := testutil.SetupInitialDeposits(t, 32) + beaconState, err := state.GenesisBeaconState(deposits, uint64(0), ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -416,10 +366,6 @@ func TestRetrieveAttestations_OK(t *testing.T) { Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0, Root: params.BeaconConfig().ZeroHash[:]}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - StartEpoch: 0, - }, }, AggregationBits: aggBits, CustodyBits: custodyBits, @@ -432,7 +378,7 @@ func TestRetrieveAttestations_OK(t *testing.T) { Data: att.Data, CustodyBit: false, } - domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sigs := make([]*bls.Signature, len(attestingIndices)) zeroSig := [96]byte{} @@ -447,23 +393,11 @@ func TestRetrieveAttestations_OK(t *testing.T) { } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - StartEpoch: 0, - }, - } + att.Signature = bls.AggregateSignatures(sigs).Marshal()[:] beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} - encoded, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[0]) - if err != nil { - t.Fatal(err) - } - att.Data.Crosslink.ParentRoot = encoded[:] - att.Data.Crosslink.DataRoot = params.BeaconConfig().ZeroHash[:] - r, _ := ssz.HashTreeRoot(att.Data) service.attestationPool[r] = dbpb.NewContainerFromAttestations([]*ethpb.Attestation{att}) @@ -475,7 +409,7 @@ func TestRetrieveAttestations_OK(t *testing.T) { t.Fatal(err) } // Test we can retrieve attestations from slot1 - slot61. - attestations, err := service.AttestationPool(context.Background(), 64) + attestations, err := service.AttestationPool(context.Background(), 1) if err != nil { t.Fatalf("Could not retrieve attestations: %v", err) } @@ -495,9 +429,7 @@ func TestRetrieveAttestations_PruneInvalidAtts(t *testing.T) { for i := 0; i < len(origAttestations); i++ { origAttestations[i] = ðpb.Attestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - }, + Slot: uint64(i), Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}, }, @@ -513,10 +445,7 @@ func TestRetrieveAttestations_PruneInvalidAtts(t *testing.T) { t.Fatal(err) } if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{ - Slot: 200, - CurrentCrosslinks: []*ethpb.Crosslink{{ - StartEpoch: 2, - DataRoot: params.BeaconConfig().ZeroHash[:]}}}, headBlockRoot); err != nil { + Slot: 200}, headBlockRoot); err != nil { t.Fatal(err) } attestations, err := service.AttestationPool(context.Background(), 200) @@ -547,9 +476,7 @@ func TestRemoveProcessedAttestations_Ok(t *testing.T) { for i := 0; i < len(attestations); i++ { attestations[i] = ðpb.Attestation{ Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - }, + Slot: uint64(i), Source: ðpb.Checkpoint{}, Target: ðpb.Checkpoint{}, }, @@ -563,11 +490,7 @@ func TestRemoveProcessedAttestations_Ok(t *testing.T) { if err := beaconDB.SaveHeadBlockRoot(context.Background(), headBlockRoot); err != nil { t.Fatal(err) } - if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{ - Slot: 15, - CurrentCrosslinks: []*ethpb.Crosslink{{ - StartEpoch: 0, - DataRoot: params.BeaconConfig().ZeroHash[:]}}}, headBlockRoot); err != nil { + if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{Slot: 15}, headBlockRoot); err != nil { t.Fatal(err) } diff --git a/beacon-chain/operations/block.go b/beacon-chain/operations/block.go index ae34009161..7f92e96c4a 100644 --- a/beacon-chain/operations/block.go +++ b/beacon-chain/operations/block.go @@ -41,8 +41,8 @@ func (s *Service) handleProcessedBlock(ctx context.Context, message proto.Messag log.WithFields(logrus.Fields{ "index": i, "root": fmt.Sprintf("%#x", root), - "aggregation_bits": fmt.Sprintf("%8b", att.AggregationBits.Bytes()), - "shard": att.Data.Crosslink.Shard, + "aggregation_bits": fmt.Sprintf("%08b", att.AggregationBits.Bytes()), + "committeeIndex": att.Data.Index, }).Debug("block attestation") } return nil diff --git a/beacon-chain/operations/block_test.go b/beacon-chain/operations/block_test.go index 00325e92c2..52b637cb8f 100644 --- a/beacon-chain/operations/block_test.go +++ b/beacon-chain/operations/block_test.go @@ -8,7 +8,6 @@ import ( dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/params" ) func TestReceiveBlkRemoveOps_Ok(t *testing.T) { @@ -19,13 +18,9 @@ func TestReceiveBlkRemoveOps_Ok(t *testing.T) { attestations := make([]*ethpb.Attestation, 10) for i := 0; i < len(attestations); i++ { attestations[i] = ðpb.Attestation{ - Data: ðpb.AttestationData{ - Crosslink: ðpb.Crosslink{ - Shard: uint64(i), - }, + Data: ðpb.AttestationData{Slot: uint64(i), Source: ðpb.Checkpoint{}, - Target: ðpb.Checkpoint{}, - }, + Target: ðpb.Checkpoint{}}, AggregationBits: bitfield.Bitlist{0b11}, } if err := s.beaconDB.SaveAttestation(context.Background(), attestations[i]); err != nil { @@ -37,11 +32,7 @@ func TestReceiveBlkRemoveOps_Ok(t *testing.T) { if err := beaconDB.SaveHeadBlockRoot(context.Background(), headBlockRoot); err != nil { t.Fatal(err) } - if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{ - Slot: 15, - CurrentCrosslinks: []*ethpb.Crosslink{{ - StartEpoch: 0, - DataRoot: params.BeaconConfig().ZeroHash[:]}}}, headBlockRoot); err != nil { + if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{Slot: 15}, headBlockRoot); err != nil { t.Fatal(err) } diff --git a/beacon-chain/operations/recent_att_multi_map_test.go b/beacon-chain/operations/recent_att_multi_map_test.go index f88a404632..db2574337d 100644 --- a/beacon-chain/operations/recent_att_multi_map_test.go +++ b/beacon-chain/operations/recent_att_multi_map_test.go @@ -17,15 +17,15 @@ func TestRecentAttestationMultiMap_Contains(t *testing.T) { }{ { inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00000001, 0b1}, - bitfield.Bitlist{0b00000010, 0b1}, + {0b00000001, 0b1}, + {0b00000010, 0b1}, }, contains: bitfield.Bitlist{0b00000001, 0b1}, want: true, }, { inputs: []bitfield.Bitlist{ - bitfield.Bitlist{0b00111000, 0b1}, - bitfield.Bitlist{0b00000011, 0b1}, + {0b00111000, 0b1}, + {0b00000011, 0b1}, }, contains: bitfield.Bitlist{0b00000100, 0b1}, want: false, diff --git a/beacon-chain/p2p/encoder/BUILD.bazel b/beacon-chain/p2p/encoder/BUILD.bazel index bb6865b1e0..bd38107582 100644 --- a/beacon-chain/p2p/encoder/BUILD.bazel +++ b/beacon-chain/p2p/encoder/BUILD.bazel @@ -27,7 +27,6 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//proto/eth/v1alpha1:go_default_library", "//proto/testing:go_default_library", "@com_github_gogo_protobuf//proto:go_default_library", ], diff --git a/beacon-chain/p2p/encoder/ssz_test.go b/beacon-chain/p2p/encoder/ssz_test.go index d6d05743f5..ffaa100835 100644 --- a/beacon-chain/p2p/encoder/ssz_test.go +++ b/beacon-chain/p2p/encoder/ssz_test.go @@ -8,7 +8,6 @@ import ( "github.com/gogo/protobuf/proto" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" testpb "github.com/prysmaticlabs/prysm/proto/testing" ) @@ -64,16 +63,6 @@ func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) { } } -// Regression test to see that a block array response received from Sigma Prime's lighthouse would decode. -func TestLighthouseBeaconBlockResponse(t *testing.T) { - b := []byte{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 224, 0, 0, 0, 224, 0, 0, 0, 224, 0, 0, 0, 224, 0, 0, 0, 224, 0, 0, 0} - decoded := make([]ethpb.BeaconBlock, 0) - e := &encoder.SszNetworkEncoder{UseSnappyCompression: false} - if err := e.Decode(b, &decoded); err != nil { - t.Fatal(err) - } -} - func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) { buf := new(bytes.Buffer) msg := &testpb.TestSimpleMessage{ diff --git a/beacon-chain/powchain/log_processing_test.go b/beacon-chain/powchain/log_processing_test.go index da3fbfdce1..9a814d4534 100644 --- a/beacon-chain/powchain/log_processing_test.go +++ b/beacon-chain/powchain/log_processing_test.go @@ -48,12 +48,12 @@ func TestProcessDepositLog_OK(t *testing.T) { } testAcc.Backend.Commit() - deposits, _, _ := testutil.SetupInitialDeposits(t, 1) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, 1) data := deposits[0].Data testAcc.TxOpts.Value = contracts.Amount32Eth() testAcc.TxOpts.GasLimit = 1000000 - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } @@ -111,17 +111,17 @@ func TestProcessDepositLog_InsertsPendingDeposit(t *testing.T) { testAcc.Backend.Commit() - deposits, _, _ := testutil.SetupInitialDeposits(t, 1) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, 1) data := deposits[0].Data testAcc.TxOpts.Value = contracts.Amount32Eth() testAcc.TxOpts.GasLimit = 1000000 - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } @@ -173,12 +173,12 @@ func TestUnpackDepositLogData_OK(t *testing.T) { t.Fatalf("Could not init from contract: %v", err) } - deposits, _, _ := testutil.SetupInitialDeposits(t, 1) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, 1) data := deposits[0].Data testAcc.TxOpts.Value = contracts.Amount32Eth() testAcc.TxOpts.GasLimit = 1000000 - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } testAcc.Backend.Commit() @@ -245,7 +245,7 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) { testAcc.Backend.Commit() testAcc.Backend.AdjustTime(time.Duration(int64(time.Now().Nanosecond()))) - deposits, _, _ := testutil.SetupInitialDeposits(t, 1) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, 1) data := deposits[0].Data testAcc.TxOpts.Value = contracts.Amount32Eth() @@ -256,7 +256,7 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) { // is 2**14 for i := 0; i < depositsReqForChainStart; i++ { testAcc.TxOpts.Value = contracts.Amount32Eth() - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } @@ -313,7 +313,7 @@ func TestProcessETH2GenesisLog(t *testing.T) { testAcc.Backend.Commit() testAcc.Backend.AdjustTime(time.Duration(int64(time.Now().Nanosecond()))) - deposits, _, _ := testutil.SetupInitialDeposits(t, uint64(depositsReqForChainStart)) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, uint64(depositsReqForChainStart)) // 64 Validators are used as size required for beacon-chain to start. This number // is defined in the deposit contract as the number required for the testnet. The actual number @@ -322,7 +322,7 @@ func TestProcessETH2GenesisLog(t *testing.T) { data := deposits[i].Data testAcc.TxOpts.Value = contracts.Amount32Eth() testAcc.TxOpts.GasLimit = 1000000 - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[i]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } @@ -340,6 +340,13 @@ func TestProcessETH2GenesisLog(t *testing.T) { t.Fatalf("Unable to retrieve logs %v", err) } + if len(logs) != depositsReqForChainStart { + t.Fatalf( + "Did not receive enough logs, received %d, wanted %d", + len(logs), + depositsReqForChainStart, + ) + } genesisTimeChan := make(chan time.Time, 1) sub := web3Service.chainStartFeed.Subscribe(genesisTimeChan) defer sub.Unsubscribe() @@ -355,7 +362,7 @@ func TestProcessETH2GenesisLog(t *testing.T) { cachedDeposits := web3Service.ChainStartDeposits() if len(cachedDeposits) != depositsReqForChainStart { - t.Errorf( + t.Fatalf( "Did not cache the chain start deposits correctly, received %d, wanted %d", len(cachedDeposits), depositsReqForChainStart, @@ -399,13 +406,13 @@ func TestWeb3ServiceProcessDepositLog_RequestMissedDeposits(t *testing.T) { testAcc.Backend.Commit() testAcc.Backend.AdjustTime(time.Duration(int64(time.Now().Nanosecond()))) depositsWanted := 10 - deposits, _, _ := testutil.SetupInitialDeposits(t, uint64(depositsWanted)) + deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, uint64(depositsWanted)) for i := 0; i < depositsWanted; i++ { data := deposits[i].Data testAcc.TxOpts.Value = contracts.Amount32Eth() testAcc.TxOpts.GasLimit = 1000000 - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[i]); err != nil { t.Fatalf("Could not deposit to deposit contract %v", err) } @@ -423,6 +430,14 @@ func TestWeb3ServiceProcessDepositLog_RequestMissedDeposits(t *testing.T) { t.Fatalf("Unable to retrieve logs %v", err) } + if len(logs) != depositsWanted { + t.Fatalf( + "Did not receive enough logs, received %d, wanted %d", + len(logs), + depositsReqForChainStart, + ) + } + logsToBeProcessed := append(logs[:depositsWanted-3], logs[depositsWanted-2:]...) // we purposely miss processing the middle two logs so that the service, re-requests them for _, log := range logsToBeProcessed { diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index 1d495ab14a..2148e9a125 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -374,7 +374,7 @@ func (s *Service) waitForConnection() { // initDataFromContract calls the deposit contract and finds the deposit count // and deposit root. func (s *Service) initDataFromContract() error { - root, err := s.depositContractCaller.GetHashTreeRoot(&bind.CallOpts{}) + root, err := s.depositContractCaller.GetDepositRoot(&bind.CallOpts{}) if err != nil { return errors.Wrap(err, "could not retrieve deposit root") } diff --git a/beacon-chain/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index 3e52aeea97..344a406bda 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -16,7 +16,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/sync" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -65,7 +64,7 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest defer span.End() span.AddAttributes( trace.Int64Attribute("slot", int64(req.Slot)), - trace.Int64Attribute("shard", int64(req.Shard)), + trace.Int64Attribute("committeeIndex", int64(req.CommitteeIndex)), ) if as.syncChecker.Syncing() { @@ -104,6 +103,14 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest headState := as.headFetcher.HeadState() headRoot := as.headFetcher.HeadRoot() + // Safe guard against head state is nil in chain service. This should not happen. + if headState == nil { + headState, err = as.beaconDB.HeadState(ctx) + if err != nil { + return nil, err + } + } + headState, err = state.ProcessSlots(ctx, headState, req.Slot) if err != nil { return nil, errors.Wrapf(err, "could not process slots up to %d", req.Slot) @@ -121,29 +128,15 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest } } - startEpoch := headState.CurrentCrosslinks[req.Shard].EndEpoch - endEpoch := startEpoch + params.BeaconConfig().MaxEpochsPerCrosslink - if endEpoch > targetEpoch { - endEpoch = targetEpoch - } - crosslinkRoot, err := ssz.HashTreeRoot(headState.CurrentCrosslinks[req.Shard]) - if err != nil { - return nil, errors.Wrapf(err, "could not tree hash crosslink for shard %d", req.Shard) - } res = ðpb.AttestationData{ + Slot: req.Slot, + Index: req.CommitteeIndex, BeaconBlockRoot: headRoot[:], Source: headState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ Epoch: targetEpoch, Root: targetRoot, }, - Crosslink: ðpb.Crosslink{ - Shard: req.Shard, - StartEpoch: startEpoch, - EndEpoch: endEpoch, - ParentRoot: crosslinkRoot[:], - DataRoot: params.BeaconConfig().ZeroHash[:], - }, } if err := as.attestationCache.Put(ctx, req, res); err != nil { diff --git a/beacon-chain/rpc/attester_server_test.go b/beacon-chain/rpc/attester_server_test.go index 001c30e5a5..dc61b2900a 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -55,10 +55,9 @@ func TestSubmitAttestation_OK(t *testing.T) { } state := &pbp2p.BeaconState{ - Slot: params.BeaconConfig().SlotsPerEpoch + 1, - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slot: params.BeaconConfig().SlotsPerEpoch + 1, + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } if err := db.SaveHeadBlockRoot(ctx, root); err != nil { @@ -71,12 +70,8 @@ func TestSubmitAttestation_OK(t *testing.T) { req := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: root[:], - Crosslink: ðpb.Crosslink{ - Shard: 935, - DataRoot: []byte{'a'}, - }, - Source: ðpb.Checkpoint{}, - Target: ðpb.Checkpoint{}, + Source: ðpb.Checkpoint{}, + Target: ðpb.Checkpoint{}, }, } if _, err := attesterServer.SubmitAttestation(context.Background(), req); err != nil { @@ -110,16 +105,6 @@ func TestRequestAttestation_OK(t *testing.T) { beaconState := &pbp2p.BeaconState{ Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - CurrentCrosslinks: []*ethpb.Crosslink{ - { - DataRoot: []byte("A"), - }, - }, - PreviousCrosslinks: []*ethpb.Crosslink{ - { - DataRoot: []byte("A"), - }, - }, CurrentJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 2, Root: justifiedRoot[:], @@ -137,20 +122,16 @@ func TestRequestAttestation_OK(t *testing.T) { } req := &pb.AttestationRequest{ - Shard: 0, - Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, + CommitteeIndex: 0, + Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, } res, err := attesterServer.RequestAttestation(context.Background(), req) if err != nil { t.Fatalf("Could not get attestation info at slot: %v", err) } - crosslinkRoot, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[req.Shard]) - if err != nil { - t.Fatal(err) - } - expectedInfo := ðpb.AttestationData{ + Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: 2, @@ -159,11 +140,6 @@ func TestRequestAttestation_OK(t *testing.T) { Target: ðpb.Checkpoint{ Epoch: 3, }, - Crosslink: ðpb.Crosslink{ - EndEpoch: 3, - ParentRoot: crosslinkRoot[:], - DataRoot: params.BeaconConfig().ZeroHash[:], - }, } if !proto.Equal(res, expectedInfo) { @@ -222,16 +198,6 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { beaconState := &pbp2p.BeaconState{ Slot: 10000, BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - PreviousCrosslinks: []*ethpb.Crosslink{ - { - DataRoot: []byte("A"), - }, - }, - CurrentCrosslinks: []*ethpb.Crosslink{ - { - DataRoot: []byte("A"), - }, - }, CurrentJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: helpers.SlotToEpoch(1500), Root: justifiedBlockRoot[:], @@ -249,32 +215,23 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { } req := &pb.AttestationRequest{ - Shard: 0, - Slot: 10000, + CommitteeIndex: 0, + Slot: 10000, } res, err := attesterServer.RequestAttestation(context.Background(), req) if err != nil { t.Fatalf("Could not get attestation info at slot: %v", err) } - crosslinkRoot, err := ssz.HashTreeRoot(beaconState.CurrentCrosslinks[req.Shard]) - if err != nil { - t.Fatal(err) - } - expectedInfo := ðpb.AttestationData{ + Slot: req.Slot, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: helpers.SlotToEpoch(1500), Root: justifiedBlockRoot[:], }, Target: ðpb.Checkpoint{ - Epoch: 156, - }, - Crosslink: ðpb.Crosslink{ - ParentRoot: crosslinkRoot[:], - EndEpoch: params.BeaconConfig().SlotsPerEpoch, - DataRoot: params.BeaconConfig().ZeroHash[:], + Epoch: 312, }, } @@ -299,8 +256,8 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { } req := &pb.AttestationRequest{ - Shard: 1, - Slot: 2, + CommitteeIndex: 1, + Slot: 2, } res := ðpb.AttestationData{ diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index c1753afbe0..bc3b136dc4 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -19,6 +19,7 @@ import ( pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/pagination" "github.com/prysmaticlabs/prysm/shared/params" "google.golang.org/grpc/codes" @@ -42,17 +43,17 @@ type BeaconChainServer struct { } // sortableAttestations implements the Sort interface to sort attestations -// by shard as the canonical sorting attribute. +// by slot as the canonical sorting attribute. type sortableAttestations []*ethpb.Attestation func (s sortableAttestations) Len() int { return len(s) } func (s sortableAttestations) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortableAttestations) Less(i, j int) bool { - return s[i].Data.Crosslink.Shard < s[j].Data.Crosslink.Shard + return s[i].Data.Slot < s[j].Data.Slot } // ListAttestations retrieves attestations by block root, slot, or epoch. -// Attestations are sorted by crosslink shard by default. +// Attestations are sorted by data slot by default. // // The server may return an empty list when no attestations match the given // filter criteria. This RPC should not return NOT_FOUND. Only one filter @@ -611,10 +612,6 @@ func (bs *BeaconChainServer) ListValidatorAssignments( return nil, status.Errorf(codes.InvalidArgument, "validator index %d >= validator count %d", index, len(headState.Validators)) } - var committee []uint64 - var shard uint64 - var slot uint64 - var isProposer bool if shouldFetchFromArchive { archivedInfo, err := bs.beaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) if err != nil { @@ -631,25 +628,53 @@ func (bs *BeaconChainServer) ListValidatorAssignments( requestedEpoch, ) } - committee, shard, slot, err = bs.archivedValidatorCommittee(requestedEpoch, index, archivedInfo, activeIndices) + archivedBalances, err := bs.beaconDB.ArchivedBalances(ctx, requestedEpoch) if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve assignment for validator %d: %v", index, err) + return nil, status.Errorf( + codes.Internal, + "could not retrieve archived balances for epoch %d", + requestedEpoch, + ) } - isProposer = archivedInfo.ProposerIndex == index - } else { - committee, shard, slot, isProposer, err = helpers.CommitteeAssignment(headState, requestedEpoch, index) + if archivedBalances == nil { + return nil, status.Errorf( + codes.NotFound, + "no archival balances found for epoch %d", + requestedEpoch, + ) + } + committee, committeeIndex, attesterSlot, proposerSlot, err := archivedValidatorCommittee( + requestedEpoch, + index, + archivedInfo, + activeIndices, + archivedBalances, + ) if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve assignment for validator %d: %v", index, err) + return nil, status.Errorf(codes.Internal, "could not retrieve archived assignment for validator %d: %v", index, err) } + assign := ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: headState.Validators[index].PublicKey, + } + res = append(res, assign) + continue } - - res = append(res, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: headState.Validators[index].PublicKey, - }) + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(headState, requestedEpoch, index) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve assignment for validator %d: %v", index, err) + } + assign := ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: headState.Validators[index].PublicKey, + } + res = append(res, assign) } return ðpb.ValidatorAssignments{ @@ -661,38 +686,77 @@ func (bs *BeaconChainServer) ListValidatorAssignments( } // Computes validator assignments for an epoch and validator index using archived committee -// information and a set of active validators. -func (bs *BeaconChainServer) archivedValidatorCommittee( +// information, archived balances, and a set of active validators. +func archivedValidatorCommittee( epoch uint64, validatorIndex uint64, archivedInfo *ethpb.ArchivedCommitteeInfo, activeIndices []uint64, -) ([]uint64, uint64, uint64, error) { - startSlot := helpers.StartSlot(epoch) + archivedBalances []uint64, +) ([]uint64, uint64, uint64, uint64, error) { committeeCount := archivedInfo.CommitteeCount - committeesPerSlot := committeeCount / params.BeaconConfig().SlotsPerEpoch - epochStartShard := archivedInfo.StartShard - seed := bytesutil.ToBytes32(archivedInfo.Seed) - shardCount := params.BeaconConfig().ShardCount + proposerSeed := bytesutil.ToBytes32(archivedInfo.ProposerSeed) + attesterSeed := bytesutil.ToBytes32(archivedInfo.AttesterSeed) + startSlot := helpers.StartSlot(epoch) + proposerIndexToSlot := make(map[uint64]uint64) for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { - offset := committeesPerSlot * (slot % params.BeaconConfig().SlotsPerEpoch) - slotStartShard := (epochStartShard + offset) % params.BeaconConfig().ShardCount - for i := uint64(0); i < committeesPerSlot; i++ { - shard := (slotStartShard + i) % params.BeaconConfig().ShardCount - currentShard := (shard + shardCount - epochStartShard) % shardCount - committee, err := helpers.ComputeCommittee(activeIndices, seed, currentShard, committeeCount) + seedWithSlot := append(proposerSeed[:], bytesutil.Bytes8(slot)...) + seedWithSlotHash := hashutil.Hash(seedWithSlot) + i, err := archivedProposerIndex(activeIndices, archivedBalances, seedWithSlotHash) + if err != nil { + return nil, 0, 0, 0, errors.Wrapf(err, "could not check proposer at slot %d", slot) + } + proposerIndexToSlot[i] = slot + } + for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { + var countAtSlot = uint64(len(activeIndices)) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize + if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot { + countAtSlot = params.BeaconConfig().MaxCommitteesPerSlot + } + if countAtSlot == 0 { + countAtSlot = 1 + } + for i := uint64(0); i < countAtSlot; i++ { + epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot + committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, committeeCount) if err != nil { - return nil, 0, 0, errors.Wrap(err, "could not compute committee") + return nil, 0, 0, 0, errors.Wrap(err, "could not compute committee") } for _, index := range committee { if validatorIndex == index { - return committee, shard, slot, nil + proposerSlot, _ := proposerIndexToSlot[validatorIndex] + return committee, i, slot, proposerSlot, nil } } } } - return nil, 0, 0, fmt.Errorf("could not find committee for validator index %d", validatorIndex) + return nil, 0, 0, 0, fmt.Errorf("could not find committee for validator index %d", validatorIndex) +} + +func archivedProposerIndex(activeIndices []uint64, activeBalances []uint64, seed [32]byte) (uint64, error) { + length := uint64(len(activeIndices)) + if length == 0 { + return 0, errors.New("empty indices list") + } + maxRandomByte := uint64(1<<8 - 1) + for i := uint64(0); ; i++ { + candidateIndex, err := helpers.ComputeShuffledIndex(i%length, length, seed, true) + if err != nil { + return 0, err + } + b := append(seed[:], bytesutil.Bytes8(i/32)...) + randomByte := hashutil.Hash(b)[i%32] + effectiveBalance := activeBalances[candidateIndex] + if effectiveBalance >= params.BeaconConfig().MaxEffectiveBalance { + // if the actual balance is greater than or equal to the max effective balance, + // we just determine the proposer index using config.MaxEffectiveBalance. + effectiveBalance = params.BeaconConfig().MaxEffectiveBalance + } + if effectiveBalance*maxRandomByte >= params.BeaconConfig().MaxEffectiveBalance*uint64(randomByte) { + return candidateIndex, nil + } + } } // GetValidatorParticipation retrieves the validator participation information for a given epoch, diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index 9ca055b773..7f25a4d4a6 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -34,9 +34,7 @@ func TestBeaconChainServer_ListAttestationsNoPagination(t *testing.T) { attExample := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{ - Shard: i, - }, + Slot: i, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1), @@ -89,9 +87,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { Root: targetRoot, Epoch: targetEpoch, }, - Crosslink: ðpb.Crosslink{ - Shard: 3, - }, + Slot: 3, }, AggregationBits: bitfield.Bitlist{0b11}, }, @@ -106,9 +102,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { Root: targetRoot, Epoch: targetEpoch, }, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, + Slot: 4, }, AggregationBits: bitfield.Bitlist{0b11}, }, @@ -123,9 +117,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { Root: unknownRoot, Epoch: targetEpoch, }, - Crosslink: ðpb.Crosslink{ - Shard: 5, - }, + Slot: 5, }, AggregationBits: bitfield.Bitlist{0b11}, }, @@ -197,9 +189,7 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { attExample := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{ - Shard: i, - }, + Slot: i, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1), @@ -230,19 +220,19 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { Attestations: []*ethpb.Attestation{ {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 3}, + Slot: 3, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 4}, + Slot: 4, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 5}, + Slot: 5, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, @@ -261,31 +251,31 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { Attestations: []*ethpb.Attestation{ {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 50}, + Slot: 50, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 51}, + Slot: 51, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 52}, + Slot: 52, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 53}, + Slot: 53, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 54}, + Slot: 54, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, }, @@ -303,7 +293,7 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { Attestations: []*ethpb.Attestation{ {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 99}, + Slot: 99, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, @@ -321,13 +311,12 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { Attestations: []*ethpb.Attestation{ {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 0}, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1)}, {Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{Shard: 1}, + Slot: 1, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1), @@ -358,9 +347,7 @@ func TestBeaconChainServer_ListAttestationsPaginationOutOfRange(t *testing.T) { attExample := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{ - Shard: i, - }, + Slot: i, }, AggregationBits: bitfield.Bitlist{0b11}, } @@ -410,9 +397,7 @@ func TestBeaconChainServer_ListAttestationsDefaultPageSize(t *testing.T) { attExample := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: []byte("root"), - Crosslink: ðpb.Crosslink{ - Shard: i, - }, + Slot: i, }, AggregationBits: bitfield.Bitlist{0b11}, CustodyBits: bitfield.NewBitlist(1), @@ -1295,7 +1280,7 @@ func TestBeaconChainServer_ListAssignmentsExceedsMaxPageSize(t *testing.T) { } } -func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { +func TestBeaconChainServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1303,14 +1288,23 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { count := 1000 validators := make([]*ethpb.Validator, 0, count) for i := 0; i < count; i++ { - if err := db.SaveValidatorIndex(ctx, [48]byte{byte(i)}, uint64(i)); err != nil { + var pubKey [48]byte + copy(pubKey[:], strconv.Itoa(i)) + if err := db.SaveValidatorIndex(ctx, pubKey, uint64(i)); err != nil { t.Fatal(err) } // Mark the validators with index divisible by 3 inactive. if i%3 == 0 { - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: 0}) + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: 0, + }) } else { - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) } } @@ -1326,9 +1320,8 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { } s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1347,12 +1340,13 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { res, err := bs.ListValidatorAssignments(context.Background(), ðpb.ListValidatorAssignmentsRequest{ QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, + PublicKeys: [][]byte{[]byte("311")}, }) if err != nil { t.Fatal(err) } - // Construct the wanted assignments + // Construct the wanted assignments. var wanted []*ethpb.ValidatorAssignments_CommitteeAssignment activeIndices, err := helpers.ActiveValidatorIndices(s, 0) @@ -1360,20 +1354,20 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { t.Fatal(err) } for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: s.Validators[index].PublicKey, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, }) } - if !reflect.DeepEqual(res.Assignments, wanted) { + if !reflect.DeepEqual(res.Assignments[0], wanted[207]) { t.Error("Did not receive wanted assignments") } } @@ -1385,16 +1379,28 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing ctx := context.Background() count := 1000 validators := make([]*ethpb.Validator, 0, count) + balances := make([]uint64, count) for i := 0; i < count; i++ { - if err := db.SaveValidatorIndex(ctx, [48]byte{byte(i)}, uint64(i)); err != nil { + var pubKey [48]byte + copy(pubKey[:], strconv.Itoa(i)) + if err := db.SaveValidatorIndex(ctx, pubKey, uint64(i)); err != nil { t.Fatal(err) } // Mark the validators with index divisible by 3 inactive. if i%3 == 0 { - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: 0}) + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: 0, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) } else { - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) } + balances[i] = params.BeaconConfig().MaxEffectiveBalance } blk := ðpb.BeaconBlock{ @@ -1409,9 +1415,10 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing } s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + Validators: validators, + Balances: balances, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + } if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1432,60 +1439,57 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing // We then store archived data into the DB. currentEpoch := helpers.CurrentEpoch(s) - committeeCount, err := helpers.CommitteeCount(s, currentEpoch) + committeeCount, err := helpers.CommitteeCountAtSlot(s, helpers.StartSlot(currentEpoch)) if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(s, currentEpoch) + proposerSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { t.Fatal(err) } - startShard, err := helpers.StartShard(s, currentEpoch) + attesterSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } - proposerIndex, err := helpers.BeaconProposerIndex(s) - if err != nil { + if err := db.SaveArchivedCommitteeInfo(context.Background(), 0, ðpb.ArchivedCommitteeInfo{ + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, + }); err != nil { t.Fatal(err) } - if err := db.SaveArchivedCommitteeInfo(context.Background(), 0, ðpb.ArchivedCommitteeInfo{ - Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, - ProposerIndex: proposerIndex, - }); err != nil { + if err := db.SaveArchivedBalances(context.Background(), 0, balances); err != nil { t.Fatal(err) } + // Construct the wanted assignments. + var wanted []*ethpb.ValidatorAssignments_CommitteeAssignment + activeIndices, err := helpers.ActiveValidatorIndices(s, 0) + if err != nil { + t.Fatal(err) + } + for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) + if err != nil { + t.Fatal(err) + } + assign := ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, + } + wanted = append(wanted, assign) + } + res, err := bs.ListValidatorAssignments(context.Background(), ðpb.ListValidatorAssignmentsRequest{ QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, }) if err != nil { t.Fatal(err) } - - // Construct the wanted assignments - var wanted []*ethpb.ValidatorAssignments_CommitteeAssignment - - activeIndices, err := helpers.ActiveValidatorIndices(s, 0) - if err != nil { - t.Fatal(err) - } - for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) - if err != nil { - t.Fatal(err) - } - wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: s.Validators[index].PublicKey, - }) - } - if !reflect.DeepEqual(res.Assignments, wanted) { t.Error("Did not receive wanted assignments") } @@ -1518,9 +1522,8 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t } s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1543,7 +1546,7 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t t.Fatal(err) } - // Construct the wanted assignments + // Construct the wanted assignments. var wanted []*ethpb.ValidatorAssignments_CommitteeAssignment activeIndices, err := helpers.ActiveValidatorIndices(s, 0) @@ -1551,16 +1554,16 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t t.Fatal(err) } for _, index := range activeIndices[1:4] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: s.Validators[index].PublicKey, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1596,9 +1599,8 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1621,7 +1623,7 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination t.Fatal(err) } - // Construct the wanted assignments + // Construct the wanted assignments. var assignments []*ethpb.ValidatorAssignments_CommitteeAssignment activeIndices, err := helpers.ActiveValidatorIndices(s, 0) @@ -1629,16 +1631,16 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination t.Fatal(err) } for _, index := range activeIndices[3:5] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: s.Validators[index].PublicKey, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1661,16 +1663,16 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } for _, index := range activeIndices[6:7] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: s.Validators[index].PublicKey, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1764,14 +1766,7 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) balances[i] = params.BeaconConfig().MaxEffectiveBalance } - atts := []*pbp2p.PendingAttestation{{Data: ðpb.AttestationData{Crosslink: ðpb.Crosslink{Shard: 0}, Target: ðpb.Checkpoint{}}}} - var crosslinks []*ethpb.Crosslink - for i := uint64(0); i < params.BeaconConfig().ShardCount; i++ { - crosslinks = append(crosslinks, ðpb.Crosslink{ - StartEpoch: 0, - DataRoot: []byte{'A'}, - }) - } + atts := []*pbp2p.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} s := &pbp2p.BeaconState{ Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, @@ -1780,9 +1775,6 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, diff --git a/beacon-chain/rpc/proposer_server.go b/beacon-chain/rpc/proposer_server.go index f99930d19b..2a38c6f63b 100644 --- a/beacon-chain/rpc/proposer_server.go +++ b/beacon-chain/rpc/proposer_server.go @@ -98,7 +98,6 @@ func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest Attestations: atts, RandaoReveal: req.RandaoReveal, // TODO(2766): Implement rest of the retrievals for beacon block operations - Transfers: []*ethpb.Transfer{}, ProposerSlashings: []*ethpb.ProposerSlashing{}, AttesterSlashings: []*ethpb.AttesterSlashing{}, VoluntaryExits: []*ethpb.VoluntaryExit{}, diff --git a/beacon-chain/rpc/proposer_server_test.go b/beacon-chain/rpc/proposer_server_test.go index d2bb132478..dca74ca146 100644 --- a/beacon-chain/rpc/proposer_server_test.go +++ b/beacon-chain/rpc/proposer_server_test.go @@ -41,7 +41,7 @@ func TestProposeBlock_OK(t *testing.T) { numDeposits := params.BeaconConfig().MinGenesisActiveValidatorCount deposits, _, _ := testutil.SetupInitialDeposits(t, numDeposits) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not instantiate genesis state: %v", err) } @@ -85,7 +85,7 @@ func TestComputeStateRoot_OK(t *testing.T) { helpers.ClearAllCaches() deposits, _, privKeys := testutil.SetupInitialDeposits(t, 100) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not instantiate genesis state: %v", err) } @@ -946,7 +946,7 @@ func TestEth1Data(t *testing.T) { p := &mockPOW.POWChain{ BlockNumberByHeight: map[uint64]*big.Int{ - 60000: big.NewInt(4096), + slot * params.BeaconConfig().SecondsPerSlot: big.NewInt(4096), }, HashesByHeight: map[int][]byte{ 3072: []byte("3072"), diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index 96e2ba22e8..fd25536a5c 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -26,7 +26,7 @@ import ( // ValidatorServer defines a server implementation of the gRPC Validator service, // providing RPC endpoints for obtaining validator assignments per epoch, the slots -// and shards in which particular validators need to perform their responsibilities, +// and committees in which particular validators need to perform their responsibilities, // and more. type ValidatorServer struct { ctx context.Context @@ -201,17 +201,17 @@ func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.Assi } func (vs *ValidatorServer) assignment(idx uint64, beaconState *pbp2p.BeaconState, epoch uint64) (*pb.AssignmentResponse_ValidatorAssignment, error) { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(beaconState, epoch, idx) + committee, committeeIndex, aSlot, pSlot, err := helpers.CommitteeAssignment(beaconState, epoch, idx) if err != nil { return nil, err } status := vs.assignmentStatus(idx, beaconState) return &pb.AssignmentResponse_ValidatorAssignment{ - Committee: committee, - Shard: shard, - Slot: slot, - IsProposer: isProposer, - Status: status, + Committee: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: aSlot, + ProposerSlot: pSlot, + Status: status, }, nil } diff --git a/beacon-chain/rpc/validator_server_test.go b/beacon-chain/rpc/validator_server_test.go index 2aca4909d0..a44721d08a 100644 --- a/beacon-chain/rpc/validator_server_test.go +++ b/beacon-chain/rpc/validator_server_test.go @@ -68,7 +68,7 @@ func TestNextEpochCommitteeAssignment_WrongPubkeyLength(t *testing.T) { helpers.ClearAllCaches() deposits, _, _ := testutil.SetupInitialDeposits(t, 8) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatal(err) } @@ -101,7 +101,7 @@ func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { defer dbutil.TeardownDB(t, db) ctx := context.Background() deposits, _, _ := testutil.SetupInitialDeposits(t, params.BeaconConfig().MinGenesisActiveValidatorCount) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not setup genesis state: %v", err) } @@ -138,7 +138,7 @@ func TestCommitteeAssignment_OK(t *testing.T) { depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not setup genesis state: %v", err) } @@ -180,13 +180,9 @@ func TestCommitteeAssignment_OK(t *testing.T) { if err != nil { t.Fatalf("Could not call epoch committee assignment %v", err) } - if res.ValidatorAssignment[0].Shard >= params.BeaconConfig().ShardCount { - t.Errorf("Assigned shard %d can't be higher than %d", - res.ValidatorAssignment[0].Shard, params.BeaconConfig().ShardCount) - } - if res.ValidatorAssignment[0].Slot > state.Slot+params.BeaconConfig().SlotsPerEpoch { + if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { t.Errorf("Assigned slot %d can't be higher than %d", - res.ValidatorAssignment[0].Slot, state.Slot+params.BeaconConfig().SlotsPerEpoch) + res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) } // Test the last validator in registry. @@ -199,13 +195,9 @@ func TestCommitteeAssignment_OK(t *testing.T) { if err != nil { t.Fatalf("Could not call epoch committee assignment %v", err) } - if res.ValidatorAssignment[0].Shard >= params.BeaconConfig().ShardCount { - t.Errorf("Assigned shard %d can't be higher than %d", - res.ValidatorAssignment[0].Shard, params.BeaconConfig().ShardCount) - } - if res.ValidatorAssignment[0].Slot > state.Slot+params.BeaconConfig().SlotsPerEpoch { + if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { t.Errorf("Assigned slot %d can't be higher than %d", - res.ValidatorAssignment[0].Slot, state.Slot+params.BeaconConfig().SlotsPerEpoch) + res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) } } @@ -219,7 +211,7 @@ func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not setup genesis state: %v", err) } @@ -276,7 +268,7 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { genesis := blk.NewGenesisBlock([]byte{}) depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not setup genesis state: %v", err) } @@ -534,7 +526,7 @@ func TestValidatorStatus_Active(t *testing.T) { expected := &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_ACTIVE, ActivationEpoch: 5, - DepositInclusionSlot: 3413, + DepositInclusionSlot: 2218, } if !proto.Equal(resp, expected) { t.Errorf("Wanted %v, got %v", expected, resp) @@ -1000,7 +992,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { Status: &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_ACTIVE, Eth1DepositBlockNumber: 10, - DepositInclusionSlot: 3413, + DepositInclusionSlot: 2218, }, }, {PublicKey: pubKey2, @@ -1276,13 +1268,6 @@ func BenchmarkAssignment(b *testing.B) { EpochStart: 0, } - // Precache the shuffled indices - for i := uint64(0); i < validatorCount/params.BeaconConfig().TargetCommitteeSize; i++ { - if _, err := helpers.CrosslinkCommittee(state, 0, i); err != nil { - b.Fatal(err) - } - } - b.ResetTimer() for n := 0; n < b.N; n++ { if _, err := vs.CommitteeAssignment(context.Background(), req); err != nil { diff --git a/beacon-chain/sync/initial-sync/round_robin_test.go b/beacon-chain/sync/initial-sync/round_robin_test.go index 8f56af0e31..f95097344e 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -96,28 +96,28 @@ func TestRoundRobinSync(t *testing.T) { }, { name: "Multiple peers with failures", - currentSlot: 320, // 5 epochs + currentSlot: 320, // 10 epochs expectedBlockSlots: makeSequence(1, 320), peers: []*peerData{ { blocks: makeSequence(1, 320), - finalizedEpoch: 4, + finalizedEpoch: 8, headSlot: 320, }, { blocks: makeSequence(1, 320), - finalizedEpoch: 4, + finalizedEpoch: 8, headSlot: 320, - failureSlots: makeSequence(1, 64), // first epoch + failureSlots: makeSequence(1, 32), // first epoch }, { blocks: makeSequence(1, 320), - finalizedEpoch: 4, + finalizedEpoch: 8, headSlot: 320, }, { blocks: makeSequence(1, 320), - finalizedEpoch: 4, + finalizedEpoch: 8, headSlot: 320, }, }, @@ -129,17 +129,17 @@ func TestRoundRobinSync(t *testing.T) { peers: []*peerData{ { blocks: append(makeSequence(1, 64), makeSequence(500, 640)...), - finalizedEpoch: 9, + finalizedEpoch: 18, headSlot: 640, }, { blocks: append(makeSequence(1, 64), makeSequence(500, 640)...), - finalizedEpoch: 9, + finalizedEpoch: 18, headSlot: 640, }, { blocks: append(makeSequence(1, 64), makeSequence(500, 640)...), - finalizedEpoch: 9, + finalizedEpoch: 18, headSlot: 640, }, }, @@ -148,7 +148,7 @@ func TestRoundRobinSync(t *testing.T) { // TODO(3147): Handle multiple failures. //{ // name: "Multiple peers with multiple failures", - // currentSlot: 320, // 5 epochs + // currentSlot: 320, // 10 epochs // expectedBlockSlots: makeSequence(1, 320), // peers: []*peerData{ // { @@ -178,7 +178,7 @@ func TestRoundRobinSync(t *testing.T) { //}, { name: "Multiple peers with different finalized epoch", - currentSlot: 320, // 5 epochs + currentSlot: 320, // 10 epochs expectedBlockSlots: makeSequence(1, 320), peers: []*peerData{ { diff --git a/beacon-chain/sync/subscriber_beacon_blocks_test.go b/beacon-chain/sync/subscriber_beacon_blocks_test.go index fd95d24d2d..84d46c7fd7 100644 --- a/beacon-chain/sync/subscriber_beacon_blocks_test.go +++ b/beacon-chain/sync/subscriber_beacon_blocks_test.go @@ -2,6 +2,7 @@ package sync import ( "context" + "fmt" "testing" "github.com/prysmaticlabs/go-ssz" @@ -39,7 +40,7 @@ func TestRegularSyncBeaconBlockSubscriber_FilterByFinalizedEpoch(t *testing.T) { if err := r.beaconBlockSubscriber(context.Background(), b); err != nil { t.Fatal(err) } - testutil.AssertLogsContain(t, hook, "Received a block older than finalized checkpoint, 1 < 64") + testutil.AssertLogsContain(t, hook, fmt.Sprintf("Received a block older than finalized checkpoint, 1 < %d", params.BeaconConfig().SlotsPerEpoch)) hook.Reset() b.Slot = params.BeaconConfig().SlotsPerEpoch diff --git a/beacon-chain/sync/validate_attester_slashing_test.go b/beacon-chain/sync/validate_attester_slashing_test.go index a8deed108d..ea7a285398 100644 --- a/beacon-chain/sync/validate_attester_slashing_test.go +++ b/beacon-chain/sync/validate_attester_slashing_test.go @@ -21,7 +21,7 @@ import ( func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, *pb.BeaconState) { deposits, _, privKeys := testutil.SetupInitialDeposits(t, 5) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{}) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) for _, vv := range state.Validators { vv.WithdrawableEpoch = 1 * params.BeaconConfig().SlotsPerEpoch } @@ -30,9 +30,6 @@ func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, *pb.Beac Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } @@ -44,7 +41,7 @@ func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, *pb.Beac if err != nil { t.Error(err) } - domain := helpers.Domain(state.Fork, 0, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(state.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sig0 := privKeys[0].Sign(hashTreeRoot[:], domain) sig1 := privKeys[1].Sign(hashTreeRoot[:], domain) aggregateSig := bls.AggregateSignatures([]*bls.Signature{sig0, sig1}) @@ -54,9 +51,6 @@ func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, *pb.Beac Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }, CustodyBit_0Indices: []uint64{0, 1}, } diff --git a/beacon-chain/sync/validate_beacon_blocks_test.go b/beacon-chain/sync/validate_beacon_blocks_test.go index 1832dc32bb..520646397b 100644 --- a/beacon-chain/sync/validate_beacon_blocks_test.go +++ b/beacon-chain/sync/validate_beacon_blocks_test.go @@ -101,7 +101,6 @@ func TestValidateBeaconBlockPubSub_BlockAlreadyPresentInCache(t *testing.T) { t.Fatal(err) } msg := ðpb.BeaconBlock{ - Slot: 1, ParentRoot: testutil.Random32Bytes(t), Signature: sk.Sign([]byte("data"), 0).Marshal(), } @@ -160,7 +159,6 @@ func TestValidateBeaconBlockPubSub_ValidSignature(t *testing.T) { t.Fatal(err) } msg := ðpb.BeaconBlock{ - Slot: 1, ParentRoot: testutil.Random32Bytes(t), Signature: sk.Sign([]byte("data"), 0).Marshal(), } @@ -237,7 +235,6 @@ func TestValidateBeaconBlockPubSub_Syncing(t *testing.T) { t.Fatal(err) } msg := ðpb.BeaconBlock{ - Slot: 1, ParentRoot: testutil.Random32Bytes(t), Signature: sk.Sign([]byte("data"), 0).Marshal(), } diff --git a/beacon-chain/sync/validate_proposer_slashing_test.go b/beacon-chain/sync/validate_proposer_slashing_test.go index 2f266ab0ab..5ab7a054f3 100644 --- a/beacon-chain/sync/validate_proposer_slashing_test.go +++ b/beacon-chain/sync/validate_proposer_slashing_test.go @@ -43,9 +43,9 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, *pb.Beac PreviousVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, }, - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), LatestBlockHeader: ðpb.BeaconBlockHeader{}, diff --git a/contracts/deposit-contract/BUILD.bazel b/contracts/deposit-contract/BUILD.bazel index 4a41c6e609..c1b45fecd4 100644 --- a/contracts/deposit-contract/BUILD.bazel +++ b/contracts/deposit-contract/BUILD.bazel @@ -25,11 +25,19 @@ go_library( go_test( name = "go_default_test", - size = "small", - srcs = ["depositContract_test.go"], + size = "medium", + srcs = [ + "depositContract_test.go", + "deposit_tree_test.go", + ], embed = [":go_default_library"], deps = [ + "//shared/interop:go_default_library", + "//shared/params:go_default_library", + "//shared/trieutil:go_default_library", "@com_github_ethereum_go_ethereum//:go_default_library", + "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", ], ) diff --git a/contracts/deposit-contract/README.md b/contracts/deposit-contract/README.md index 4f07654357..04538c683f 100644 --- a/contracts/deposit-contract/README.md +++ b/contracts/deposit-contract/README.md @@ -29,7 +29,7 @@ To generate the abi using the vyper compiler, you can use ``` -vyper -f abi ./depositContract.v.py > abi.json +docker run -v $(pwd):/code ethereum/vyper:0.1.0b12 -f abi /code/depositContract.v.py > abi.json ``` @@ -39,7 +39,7 @@ To generate the bytecode you can then use ``` -vyper ./depositContract.v.py > bytecode.bin +docker run -v $(pwd):/code ethereum/vyper:0.1.0b12 /code/depositContract.v.py > bytecode.bin ``` @@ -47,31 +47,32 @@ and save the bytecode in `bytecode.bin` in the folder. Now with both the abi and we can generate the go bindings. ``` -abigen -bin ./bytecode.bin -abi ./abi.json -out ./depositContract.go --pkg depositcontract --type DepositContract + +bazel run @com_github_ethereum_go_ethereum//cmd/abigen -- -bin $(pwd)/bytecode.bin -abi $(pwd)/abi.json -out $(pwd)/depositContract.go --pkg depositcontract --type DepositContract ``` ## How to execute tests ``` -go test ./... +bazel test //contracts/deposit-contract:go_default_test ``` Run with `-v` option for detailed log output ``` -go test ./... -v -=== RUN TestSetupAndContractRegistration ---- PASS: TestSetupAndContractRegistration (0.01s) -=== RUN TestRegisterWithLessThan32Eth ---- PASS: TestRegisterWithLessThan32Eth (0.00s) -=== RUN TestRegisterWithMoreThan32Eth ---- PASS: TestRegisterWithMoreThan32Eth (0.00s) -=== RUN TestRegisterTwice ---- PASS: TestRegisterTwice (0.01s) -=== RUN TestRegister ---- PASS: TestRegister (0.01s) +bazel test //contracts/deposit-contract:go_default_test --test_arg=-test.v --test_output=streamed +=== RUN TestSetupRegistrationContract_OK +--- PASS: TestSetupRegistrationContract_OK (0.07s) +=== RUN TestRegister_Below1ETH +--- PASS: TestRegister_Below1ETH (0.02s) +=== RUN TestRegister_Above32Eth +--- PASS: TestRegister_Above32Eth (0.02s) +=== RUN TestValidatorRegister_OK +--- PASS: TestValidatorRegister_OK (0.08s) +=== RUN TestDrain +--- PASS: TestDrain (0.04s) PASS -ok beacon-chain/contracts/deposit-contract/ 0.151s +ok contracts/deposit-contract 0.633s ``` diff --git a/contracts/deposit-contract/abi.json b/contracts/deposit-contract/abi.json index 223af1cd65..529d6d07af 100644 --- a/contracts/deposit-contract/abi.json +++ b/contracts/deposit-contract/abi.json @@ -1 +1 @@ -[{"name": "DepositEvent", "inputs": [{"type": "bytes", "name": "pubkey", "indexed": false}, {"type": "bytes", "name": "withdrawal_credentials", "indexed": false}, {"type": "bytes", "name": "amount", "indexed": false}, {"type": "bytes", "name": "signature", "indexed": false}, {"type": "bytes", "name": "index", "indexed": false}], "anonymous": false, "type": "event"}, {"outputs": [], "inputs": [{"type": "uint256", "name": "minDeposit"}, {"type": "address", "name": "_drain_address"}], "constant": false, "payable": false, "type": "constructor"}, {"name": "get_hash_tree_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 91734}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 10493}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}], "constant": false, "payable": true, "type": "function", "gas": 1334707}, {"name": "drain", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 35823}, {"name": "MIN_DEPOSIT_AMOUNT", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 663}, {"name": "deposit_count", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 693}, {"name": "drain_address", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 723}] +[{"name": "DepositEvent", "inputs": [{"type": "bytes", "name": "pubkey", "indexed": false}, {"type": "bytes", "name": "withdrawal_credentials", "indexed": false}, {"type": "bytes", "name": "amount", "indexed": false}, {"type": "bytes", "name": "signature", "indexed": false}, {"type": "bytes", "name": "index", "indexed": false}], "anonymous": false, "type": "event"}, {"outputs": [], "inputs": [{"type": "address", "name": "_drain_address"}], "constant": false, "payable": false, "type": "constructor"}, {"name": "get_deposit_root", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 95389}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 17683}, {"name": "deposit", "outputs": [], "inputs": [{"type": "bytes", "name": "pubkey"}, {"type": "bytes", "name": "withdrawal_credentials"}, {"type": "bytes", "name": "signature"}, {"type": "bytes32", "name": "deposit_data_root"}], "constant": false, "payable": true, "type": "function", "gas": 1754607}, {"name": "drain", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 35793}, {"name": "drain_address", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 663}] diff --git a/contracts/deposit-contract/bytecode.bin b/contracts/deposit-contract/bytecode.bin index 780e1a8402..d78cf5297c 100644 --- a/contracts/deposit-contract/bytecode.bin +++ b/contracts/deposit-contract/bytecode.bin @@ -1 +1 @@ -0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260406114ff6101403934156100a757600080fd5b602060206114ff0160c03960c05160205181106100c357600080fd5b5061014051600055610160516004556101806000601f818352015b600061018051602081106100f157600080fd5b600160c052602060c02001546020826101a0010152602081019050610180516020811061011d57600080fd5b600160c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161015b57600080fd5b60c0519050606051600161018051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600160c052602060c02001555b81516001018083528114156100de575b50506114e756600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661018001602082840111156100bf57600080fd5b6020806101a082610140600060046015f1505081815280905090509050805160200180610240828460006004600a8704601201f16100fc57600080fd5b50506102405160206001820306601f82010390506102a0610240516008818352015b826102a051111561012e5761014a565b60006102a05161026001535b815160010180835281141561011e575b5050506020610220526040610240510160206001820306601f8201039050610200525b60006102005111151561017f5761019b565b602061020051036102200151602061020051036102005261016d565b610160515650005b600015610387575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156101ea578060000360020a82046101f1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561021c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610265578060000360020a820461026c565b8060020a82025b905090506101a0525b81516001018083528114156101cd575b5050601860086020820661020001602082840111156102a357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16102e057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156103125761032e565b6000610320516102e001535b8151600101808352811415610302575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156103635761037f565b602061028051036102a001516020610280510361028052610351565b610160515650005b63863a311b60005114156106185734156103a057600080fd5b6000610140526101405161016052600354610180526101a060006020818352015b60016001610180511614156104425760006101a051602081106103e357600080fd5b600260c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161043457600080fd5b60c0519050610160526104b0565b6000610160516020826101c00101526020810190506101a0516020811061046857600080fd5b600160c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16104a657600080fd5b60c0519050610160525b61018060026104be57600080fd5b60028151048152505b81516001018083528114156103c1575b505060006101605160208261044001015260208101905061014051610160516101805163806732896102c0526003546102e0526102e051600658016101ab565b506103405260006103a0525b6103405160206001820306601f82010390506103a0511015156105455761055e565b6103a05161036001526103a0516020016103a052610523565b61018052610160526101405261034060088060208461044001018260208501600060046012f150508051820191505060006018602082066103c001602082840111156105a957600080fd5b6020806103e082610140600060046015f150508181528090509050905060188060208461044001018260208501600060046014f150508051820191505080610440526104409050602060c0825160208401600060025af161060957600080fd5b60c051905060005260206000f3005b63621fd130600051141561072a57341561063157600080fd5b6380673289610140526003546101605261016051600658016101ab565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561067c57610695565b610220516101e00152610220516020016102205261065a565b6101c0805160200180610280828460006004600a8704601201f16106b857600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156106ea57610706565b60006102e0516102a001535b81516001018083528114156106da575b5050506020610260526040610280510160206001820306601f8201039050610260f3005b63c47e300d600051141561128257606060046101403760506004356004016101a037603060043560040135111561076057600080fd5b604060243560040161022037602060243560040135111561078057600080fd5b60806044356004016102803760606044356004013511156107a057600080fd5b63ffffffff600354106107b257600080fd5b633b9aca0061034052610340516107c857600080fd5b610340513404610320526000546103205110156107e457600080fd5b60306101a051146107f457600080fd5b6020610220511461080457600080fd5b6060610280511461081457600080fd5b6101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05163806732896103c052610320516103e0526103e051600658016101ab565b506104405260006104a0525b6104405160206001820306601f82010390506104a0511015156108a4576108bd565b6104a05161046001526104a0516020016104a052610882565b6103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610440805160200180610360828460006004600a8704601201f161092457600080fd5b50506101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c0516103e05161040051610420516104405161046051610480516104a05163806732896104c0526003546104e0526104e051600658016101ab565b506105405260006105a0525b6105405160206001820306601f82010390506105a0511015156109d5576109ee565b6105a05161056001526105a0516020016105a0526109b3565b6104a05261048052610460526104405261042052610400526103e0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526105408051602001806105c0828460006004600a8704601201f1610a7557600080fd5b505060a06106405261064051610680526101a08051602001806106405161068001828460006004600a8704601201f1610aad57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516040818352015b8361062051101515610aeb57610b08565b6000610620516020850101535b8151600101808352811415610ada575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106a0526102208051602001806106405161068001828460006004600a8704601201f1610b5f57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610b9d57610bba565b6000610620516020850101535b8151600101808352811415610b8c575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106c0526103608051602001806106405161068001828460006004600a8704601201f1610c1157600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610c4f57610c6c565b6000610620516020850101535b8151600101808352811415610c3e575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106e0526102808051602001806106405161068001828460006004600a8704601201f1610cc357600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516060818352015b8361062051101515610d0157610d1e565b6000610620516020850101535b8151600101808352811415610cf0575b50505050602061064051610680015160206001820306601f82010390506106405101016106405261064051610700526105c08051602001806106405161068001828460006004600a8704601201f1610d7557600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610db357610dd0565b6000610620516020850101535b8151600101808352811415610da2575b50505050602061064051610680015160206001820306601f8201039050610640510101610640527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561064051610680a160006107205260006101a06030806020846107e001018260208501600060046016f150508051820191505060006010602082066107600160208284011115610e6757600080fd5b60208061078082610720600060046015f15050818152809050905090506010806020846107e001018260208501600060046013f1505080518201915050806107e0526107e09050602060c0825160208401600060025af1610ec757600080fd5b60c0519050610740526000600060406020820661088001610280518284011115610ef057600080fd5b6060806108a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af1610f3057600080fd5b60c0519050602082610a800101526020810190506000604060206020820661094001610280518284011115610f6457600080fd5b606080610960826020602088068803016102800160006004601bf1505081815280905090509050602080602084610a0001018260208501600060046015f150508051820191505061072051602082610a0001015260208101905080610a0052610a009050602060c0825160208401600060025af1610fe157600080fd5b60c0519050602082610a8001015260208101905080610a8052610a809050602060c0825160208401600060025af161101857600080fd5b60c0519050610860526000600061074051602082610b20010152602081019050610220602080602084610b2001018260208501600060046015f150508051820191505080610b2052610b209050602060c0825160208401600060025af161107e57600080fd5b60c0519050602082610ca00101526020810190506000610360600880602084610c2001018260208501600060046012f15050805182019150506000601860208206610ba001602082840111156110d357600080fd5b602080610bc082610720600060046015f1505081815280905090509050601880602084610c2001018260208501600060046014f150508051820191505061086051602082610c2001015260208101905080610c2052610c209050602060c0825160208401600060025af161114657600080fd5b60c0519050602082610ca001015260208101905080610ca052610ca09050602060c0825160208401600060025af161117d57600080fd5b60c0519050610b0052600380546001825401101561119a57600080fd5b6001815401815550600354610d2052610d4060006020818352015b60016001610d20511614156111ea57610b0051610d4051602081106111d957600080fd5b600260c052602060c020015561127e565b6000610d4051602081106111fd57600080fd5b600260c052602060c0200154602082610d60010152602081019050610b0051602082610d6001015260208101905080610d6052610d609050602060c0825160208401600060025af161124e57600080fd5b60c0519050610b0052610d20600261126557600080fd5b60028151048152505b81516001018083528114156111b5575b5050005b639890220b60005114156112b657341561129b57600080fd5b600060006000600030316004546000f16112b457600080fd5b005b631ea30fef60005114156112dc5734156112cf57600080fd5b60005460005260206000f3005b63eb8545ee60005114156113025734156112f557600080fd5b60035460005260206000f3005b638ba35cdf600051141561132857341561131b57600080fd5b60045460005260206000f3005b60006000fd5b6101b96114e7036101b96000396101b96114e7036000f3 +0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206112736101403934156100a157600080fd5b602061127360c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b505061125b56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610265575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506103206102c0516020818352015b60206103205111156101f15761020d565b6000610320516102e001535b81516001018083528114156101e0575b505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102415761025d565b602061028051036102a00151602061028051036102805261022f565b610160515650005b63c5f2892f60005114156104f757341561027e57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103205760006101a051602081106102c157600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161031257600080fd5b60c05190506101605261038e565b6000610160516020826101c00101526020810190506101a0516020811061034657600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161038457600080fd5b60c0519050610160525b610180600261039c57600080fd5b60028151048152505b815160010180835281141561029f575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104235761043c565b6103c05161038001526103c0516020016103c052610401565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561048757600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104e757600080fd5b60c051905060005260206000f350005b63621fd13060005114156105f857341561051057600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561055b57610574565b610220516101e001526102205160200161022052610539565b6101c0805160200180610280828460006004600a8704601201f161059757600080fd5b50506102e0610280516020818352015b60206102e05111156105b8576105d4565b60006102e0516102a001535b81516001018083528114156105a7575b50506020610260526040610280510160206001820306601f8201039050610260f350005b6322895118600051141561105157605060043560040161014037603060043560040135111561062657600080fd5b60406024356004016101c037602060243560040135111561064657600080fd5b608060443560040161022037606060443560040135111561066657600080fd5b63ffffffff6001541061067857600080fd5b633b9aca006102e0526102e05161068e57600080fd5b6102e05134046102c052633b9aca006102c05110156106ac57600080fd5b603061014051146106bc57600080fd5b60206101c051146106cc57600080fd5b606061022051146106dc57600080fd5b610140610360525b61036051516020610360510161036052610360610360511015610706576106e4565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107525761076b565b6104605161042001526104605160200161046052610730565b610340610360525b610360515260206103605103610360526101406103605110151561079657610773565b610400805160200180610300828460006004600a8704601201f16107b957600080fd5b5050610140610480525b610480515160206104805101610480526104806104805110156107e5576107c3565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f82010390506105805110151561083057610849565b610580516105400152610580516020016105805261080e565b610460610480525b610480515260206104805103610480526101406104805110151561087457610851565b6105208051602001806105a0828460006004600a8704601201f161089757600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108cf57600080fd5b5050610600610620516106600151610240818352015b6102406106005111156108f757610918565b600061060051610620516106800101535b81516001018083528114156108e5575b5050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f161096d57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610995576109b6565b600061060051610620516106800101535b8151600101808352811415610983575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a0b57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610a3357610a54565b600061060051610620516106800101535b8151600101808352811415610a21575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610aa957600080fd5b5050610600610620516106600151610240818352015b610240610600511115610ad157610af2565b600061060051610620516106800101535b8151600101808352811415610abf575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610b4757600080fd5b5050610600610620516106600151610240818352015b610240610600511115610b6f57610b90565b600061060051610620516106800101535b8151600101808352811415610b5d575b5050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610c2557600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610c8557600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610cae57600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610cee57600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610d2257600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610d9f57600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610dd657600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610e3c57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610e9157600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f0457600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610f3b57600080fd5b60c0519050610ae052606435610ae05114610f5557600080fd5b6001805460018254011015610f6957600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d0051161415610fb957610ae051610d205160208110610fa857600080fd5b600060c052602060c020015561104d565b6000610d205160208110610fcc57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af161101d57600080fd5b60c0519050610ae052610d00600261103457600080fd5b60028151048152505b8151600101808352811415610f84575b5050005b639890220b600051141561108557341561106a57600080fd5b600060006000600030316002546000f161108357600080fd5b005b638ba35cdf60005114156110ac57341561109e57600080fd5b60025460005260206000f350005b60006000fd5b6101a961125b036101a96000396101a961125b036000f3 diff --git a/contracts/deposit-contract/deployContract/BUILD.bazel b/contracts/deposit-contract/deployContract/BUILD.bazel index 364310b19c..b224ee5f01 100644 --- a/contracts/deposit-contract/deployContract/BUILD.bazel +++ b/contracts/deposit-contract/deployContract/BUILD.bazel @@ -7,7 +7,6 @@ go_library( visibility = ["//visibility:private"], deps = [ "//contracts/deposit-contract:go_default_library", - "//shared/params:go_default_library", "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//accounts/keystore:go_default_library", diff --git a/contracts/deposit-contract/deployContract/README.md b/contracts/deposit-contract/deployContract/README.md index 75e2d70aca..a11a8c7221 100644 --- a/contracts/deposit-contract/deployContract/README.md +++ b/contracts/deposit-contract/deployContract/README.md @@ -11,15 +11,11 @@ This is a utility to help users deploy deposit contract for running their own be deployContract [global options] command [command options] [arguments...] *Flags:* -- --skipChainstartDelay Whether to skip ChainStart log being fired a day later - --ipcPath value Filename for IPC socket/pipe within the datadir - --httpPath value HTTP-RPC server listening interface (default: "http://localhost:8545/") - --passwordFile value Password file for unlock account (default: "./password.txt") - --privKey value Private key to unlock account - --k8sConfig value Name of kubernetes config map to update with the contract address -- --chainStart value Number of validators required for chain start (default: 16384) -- --minDeposit value Minimum deposit value allowed in contract (default: 1000000000) -- --maxDeposit value Maximum deposit value allowed in contract (default: 32000000000) - --help, -h show help - --version, -v print the version @@ -28,7 +24,7 @@ This is a utility to help users deploy deposit contract for running their own be To use private key with default RPC: ``` -bazel run //contracts/deposit-contract/deployContract -- --httpPath=https://goerli.prylabs.net --privKey=$(echo /path/to/private/key/file) --chainStart=8 --minDeposit=100 --maxDeposit=3200 +bazel run //contracts/deposit-contract/deployContract -- --httpPath=https://goerli.prylabs.net --privKey=$(echo /path/to/private/key/file) ``` diff --git a/contracts/deposit-contract/deployContract/deployContract.go b/contracts/deposit-contract/deployContract/deployContract.go index 9bb90e3da3..ba3acb7a26 100644 --- a/contracts/deposit-contract/deployContract/deployContract.go +++ b/contracts/deposit-contract/deployContract/deployContract.go @@ -16,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract" - "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/version" "github.com/sirupsen/logrus" "github.com/urfave/cli" @@ -33,10 +32,6 @@ func main() { var httpPath string var privKeyString string var k8sConfigMapName string - var depositsForChainStart int64 - var minDepositAmount int64 - var maxDepositAmount int64 - var customChainstartDelay uint64 var drainAddress string customFormatter := new(prefixed.TextFormatter) @@ -55,12 +50,6 @@ func main() { Usage: "Location of keystore", Destination: &keystoreUTCPath, }, - cli.Uint64Flag{ - Name: "customChainstartDelay", - Usage: "Number of seconds to delay the ChainStart genesis timestamp", - Value: 0, - Destination: &customChainstartDelay, - }, cli.StringFlag{ Name: "ipcPath", Usage: "Filename for IPC socket/pipe within the datadir", @@ -88,24 +77,6 @@ func main() { Usage: "Name of kubernetes config map to update with the contract address", Destination: &k8sConfigMapName, }, - cli.Int64Flag{ - Name: "chainStart", - Value: params.ContractConfig().MinGenesisActiveValidatorCount.Int64(), - Usage: "Number of validators required for chain start", - Destination: &depositsForChainStart, - }, - cli.Int64Flag{ - Name: "minDeposit", - Value: params.ContractConfig().MinDepositAmount.Int64(), - Usage: "Minimum deposit value allowed in contract", - Destination: &minDepositAmount, - }, - cli.Int64Flag{ - Name: "maxDeposit", - Value: params.ContractConfig().MaxEffectiveBalance.Int64(), - Usage: "Maximum deposit value allowed in contract", - Destination: &maxDepositAmount, - }, cli.StringFlag{ Name: "drainAddress", Value: "", @@ -180,7 +151,6 @@ func main() { addr, tx, _, err := contracts.DeployDepositContract( txOps, client, - big.NewInt(minDepositAmount), drain, ) diff --git a/contracts/deposit-contract/depositContract.go b/contracts/deposit-contract/depositContract.go index 7a1faf3956..b145a60026 100644 --- a/contracts/deposit-contract/depositContract.go +++ b/contracts/deposit-contract/depositContract.go @@ -28,18 +28,19 @@ var ( ) // DepositContractABI is the input ABI used to generate the binding from. -const DepositContractABI = "[{\"name\":\"DepositEvent\",\"inputs\":[{\"type\":\"bytes\",\"name\":\"pubkey\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"withdrawal_credentials\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"amount\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"signature\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"index\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"outputs\":[],\"inputs\":[{\"type\":\"uint256\",\"name\":\"minDeposit\"},{\"type\":\"address\",\"name\":\"_drain_address\"}],\"constant\":false,\"payable\":false,\"type\":\"constructor\"},{\"name\":\"get_hash_tree_root\",\"outputs\":[{\"type\":\"bytes32\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":91734},{\"name\":\"get_deposit_count\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":10493},{\"name\":\"deposit\",\"outputs\":[],\"inputs\":[{\"type\":\"bytes\",\"name\":\"pubkey\"},{\"type\":\"bytes\",\"name\":\"withdrawal_credentials\"},{\"type\":\"bytes\",\"name\":\"signature\"}],\"constant\":false,\"payable\":true,\"type\":\"function\",\"gas\":1334707},{\"name\":\"drain\",\"outputs\":[],\"inputs\":[],\"constant\":false,\"payable\":false,\"type\":\"function\",\"gas\":35823},{\"name\":\"MIN_DEPOSIT_AMOUNT\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":663},{\"name\":\"deposit_count\",\"outputs\":[{\"type\":\"uint256\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":693},{\"name\":\"drain_address\",\"outputs\":[{\"type\":\"address\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":723}]" +const DepositContractABI = "[{\"name\":\"DepositEvent\",\"inputs\":[{\"type\":\"bytes\",\"name\":\"pubkey\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"withdrawal_credentials\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"amount\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"signature\",\"indexed\":false},{\"type\":\"bytes\",\"name\":\"index\",\"indexed\":false}],\"anonymous\":false,\"type\":\"event\"},{\"outputs\":[],\"inputs\":[{\"type\":\"address\",\"name\":\"_drain_address\"}],\"constant\":false,\"payable\":false,\"type\":\"constructor\"},{\"name\":\"get_deposit_root\",\"outputs\":[{\"type\":\"bytes32\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":95389},{\"name\":\"get_deposit_count\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":17683},{\"name\":\"deposit\",\"outputs\":[],\"inputs\":[{\"type\":\"bytes\",\"name\":\"pubkey\"},{\"type\":\"bytes\",\"name\":\"withdrawal_credentials\"},{\"type\":\"bytes\",\"name\":\"signature\"},{\"type\":\"bytes32\",\"name\":\"deposit_data_root\"}],\"constant\":false,\"payable\":true,\"type\":\"function\",\"gas\":1754607},{\"name\":\"drain\",\"outputs\":[],\"inputs\":[],\"constant\":false,\"payable\":false,\"type\":\"function\",\"gas\":35793},{\"name\":\"drain_address\",\"outputs\":[{\"type\":\"address\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":663}]" // DepositContractBin is the compiled bytecode used for deploying new contracts. -const DepositContractBin = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260406114ff6101403934156100a757600080fd5b602060206114ff0160c03960c05160205181106100c357600080fd5b5061014051600055610160516004556101806000601f818352015b600061018051602081106100f157600080fd5b600160c052602060c02001546020826101a0010152602081019050610180516020811061011d57600080fd5b600160c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161015b57600080fd5b60c0519050606051600161018051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600160c052602060c02001555b81516001018083528114156100de575b50506114e756600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661018001602082840111156100bf57600080fd5b6020806101a082610140600060046015f1505081815280905090509050805160200180610240828460006004600a8704601201f16100fc57600080fd5b50506102405160206001820306601f82010390506102a0610240516008818352015b826102a051111561012e5761014a565b60006102a05161026001535b815160010180835281141561011e575b5050506020610220526040610240510160206001820306601f8201039050610200525b60006102005111151561017f5761019b565b602061020051036102200151602061020051036102005261016d565b610160515650005b600015610387575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156101ea578060000360020a82046101f1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561021c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610265578060000360020a820461026c565b8060020a82025b905090506101a0525b81516001018083528114156101cd575b5050601860086020820661020001602082840111156102a357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16102e057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156103125761032e565b6000610320516102e001535b8151600101808352811415610302575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156103635761037f565b602061028051036102a001516020610280510361028052610351565b610160515650005b63863a311b60005114156106185734156103a057600080fd5b6000610140526101405161016052600354610180526101a060006020818352015b60016001610180511614156104425760006101a051602081106103e357600080fd5b600260c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161043457600080fd5b60c0519050610160526104b0565b6000610160516020826101c00101526020810190506101a0516020811061046857600080fd5b600160c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16104a657600080fd5b60c0519050610160525b61018060026104be57600080fd5b60028151048152505b81516001018083528114156103c1575b505060006101605160208261044001015260208101905061014051610160516101805163806732896102c0526003546102e0526102e051600658016101ab565b506103405260006103a0525b6103405160206001820306601f82010390506103a0511015156105455761055e565b6103a05161036001526103a0516020016103a052610523565b61018052610160526101405261034060088060208461044001018260208501600060046012f150508051820191505060006018602082066103c001602082840111156105a957600080fd5b6020806103e082610140600060046015f150508181528090509050905060188060208461044001018260208501600060046014f150508051820191505080610440526104409050602060c0825160208401600060025af161060957600080fd5b60c051905060005260206000f3005b63621fd130600051141561072a57341561063157600080fd5b6380673289610140526003546101605261016051600658016101ab565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561067c57610695565b610220516101e00152610220516020016102205261065a565b6101c0805160200180610280828460006004600a8704601201f16106b857600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156106ea57610706565b60006102e0516102a001535b81516001018083528114156106da575b5050506020610260526040610280510160206001820306601f8201039050610260f3005b63c47e300d600051141561128257606060046101403760506004356004016101a037603060043560040135111561076057600080fd5b604060243560040161022037602060243560040135111561078057600080fd5b60806044356004016102803760606044356004013511156107a057600080fd5b63ffffffff600354106107b257600080fd5b633b9aca0061034052610340516107c857600080fd5b610340513404610320526000546103205110156107e457600080fd5b60306101a051146107f457600080fd5b6020610220511461080457600080fd5b6060610280511461081457600080fd5b6101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05163806732896103c052610320516103e0526103e051600658016101ab565b506104405260006104a0525b6104405160206001820306601f82010390506104a0511015156108a4576108bd565b6104a05161046001526104a0516020016104a052610882565b6103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610440805160200180610360828460006004600a8704601201f161092457600080fd5b50506101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c0516103e05161040051610420516104405161046051610480516104a05163806732896104c0526003546104e0526104e051600658016101ab565b506105405260006105a0525b6105405160206001820306601f82010390506105a0511015156109d5576109ee565b6105a05161056001526105a0516020016105a0526109b3565b6104a05261048052610460526104405261042052610400526103e0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526105408051602001806105c0828460006004600a8704601201f1610a7557600080fd5b505060a06106405261064051610680526101a08051602001806106405161068001828460006004600a8704601201f1610aad57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516040818352015b8361062051101515610aeb57610b08565b6000610620516020850101535b8151600101808352811415610ada575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106a0526102208051602001806106405161068001828460006004600a8704601201f1610b5f57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610b9d57610bba565b6000610620516020850101535b8151600101808352811415610b8c575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106c0526103608051602001806106405161068001828460006004600a8704601201f1610c1157600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610c4f57610c6c565b6000610620516020850101535b8151600101808352811415610c3e575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106e0526102808051602001806106405161068001828460006004600a8704601201f1610cc357600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516060818352015b8361062051101515610d0157610d1e565b6000610620516020850101535b8151600101808352811415610cf0575b50505050602061064051610680015160206001820306601f82010390506106405101016106405261064051610700526105c08051602001806106405161068001828460006004600a8704601201f1610d7557600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610db357610dd0565b6000610620516020850101535b8151600101808352811415610da2575b50505050602061064051610680015160206001820306601f8201039050610640510101610640527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561064051610680a160006107205260006101a06030806020846107e001018260208501600060046016f150508051820191505060006010602082066107600160208284011115610e6757600080fd5b60208061078082610720600060046015f15050818152809050905090506010806020846107e001018260208501600060046013f1505080518201915050806107e0526107e09050602060c0825160208401600060025af1610ec757600080fd5b60c0519050610740526000600060406020820661088001610280518284011115610ef057600080fd5b6060806108a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af1610f3057600080fd5b60c0519050602082610a800101526020810190506000604060206020820661094001610280518284011115610f6457600080fd5b606080610960826020602088068803016102800160006004601bf1505081815280905090509050602080602084610a0001018260208501600060046015f150508051820191505061072051602082610a0001015260208101905080610a0052610a009050602060c0825160208401600060025af1610fe157600080fd5b60c0519050602082610a8001015260208101905080610a8052610a809050602060c0825160208401600060025af161101857600080fd5b60c0519050610860526000600061074051602082610b20010152602081019050610220602080602084610b2001018260208501600060046015f150508051820191505080610b2052610b209050602060c0825160208401600060025af161107e57600080fd5b60c0519050602082610ca00101526020810190506000610360600880602084610c2001018260208501600060046012f15050805182019150506000601860208206610ba001602082840111156110d357600080fd5b602080610bc082610720600060046015f1505081815280905090509050601880602084610c2001018260208501600060046014f150508051820191505061086051602082610c2001015260208101905080610c2052610c209050602060c0825160208401600060025af161114657600080fd5b60c0519050602082610ca001015260208101905080610ca052610ca09050602060c0825160208401600060025af161117d57600080fd5b60c0519050610b0052600380546001825401101561119a57600080fd5b6001815401815550600354610d2052610d4060006020818352015b60016001610d20511614156111ea57610b0051610d4051602081106111d957600080fd5b600260c052602060c020015561127e565b6000610d4051602081106111fd57600080fd5b600260c052602060c0200154602082610d60010152602081019050610b0051602082610d6001015260208101905080610d6052610d609050602060c0825160208401600060025af161124e57600080fd5b60c0519050610b0052610d20600261126557600080fd5b60028151048152505b81516001018083528114156111b5575b5050005b639890220b60005114156112b657341561129b57600080fd5b600060006000600030316004546000f16112b457600080fd5b005b631ea30fef60005114156112dc5734156112cf57600080fd5b60005460005260206000f3005b63eb8545ee60005114156113025734156112f557600080fd5b60035460005260206000f3005b638ba35cdf600051141561132857341561131b57600080fd5b60045460005260206000f3005b60006000fd5b6101b96114e7036101b96000396101b96114e7036000f3` +var DepositContractBin = "0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206112736101403934156100a157600080fd5b602061127360c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b505061125b56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610265575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506103206102c0516020818352015b60206103205111156101f15761020d565b6000610320516102e001535b81516001018083528114156101e0575b505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102415761025d565b602061028051036102a00151602061028051036102805261022f565b610160515650005b63c5f2892f60005114156104f757341561027e57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103205760006101a051602081106102c157600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161031257600080fd5b60c05190506101605261038e565b6000610160516020826101c00101526020810190506101a0516020811061034657600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161038457600080fd5b60c0519050610160525b610180600261039c57600080fd5b60028151048152505b815160010180835281141561029f575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104235761043c565b6103c05161038001526103c0516020016103c052610401565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561048757600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104e757600080fd5b60c051905060005260206000f350005b63621fd13060005114156105f857341561051057600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561055b57610574565b610220516101e001526102205160200161022052610539565b6101c0805160200180610280828460006004600a8704601201f161059757600080fd5b50506102e0610280516020818352015b60206102e05111156105b8576105d4565b60006102e0516102a001535b81516001018083528114156105a7575b50506020610260526040610280510160206001820306601f8201039050610260f350005b6322895118600051141561105157605060043560040161014037603060043560040135111561062657600080fd5b60406024356004016101c037602060243560040135111561064657600080fd5b608060443560040161022037606060443560040135111561066657600080fd5b63ffffffff6001541061067857600080fd5b633b9aca006102e0526102e05161068e57600080fd5b6102e05134046102c052633b9aca006102c05110156106ac57600080fd5b603061014051146106bc57600080fd5b60206101c051146106cc57600080fd5b606061022051146106dc57600080fd5b610140610360525b61036051516020610360510161036052610360610360511015610706576106e4565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107525761076b565b6104605161042001526104605160200161046052610730565b610340610360525b610360515260206103605103610360526101406103605110151561079657610773565b610400805160200180610300828460006004600a8704601201f16107b957600080fd5b5050610140610480525b610480515160206104805101610480526104806104805110156107e5576107c3565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f82010390506105805110151561083057610849565b610580516105400152610580516020016105805261080e565b610460610480525b610480515260206104805103610480526101406104805110151561087457610851565b6105208051602001806105a0828460006004600a8704601201f161089757600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108cf57600080fd5b5050610600610620516106600151610240818352015b6102406106005111156108f757610918565b600061060051610620516106800101535b81516001018083528114156108e5575b5050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f161096d57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610995576109b6565b600061060051610620516106800101535b8151600101808352811415610983575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a0b57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610a3357610a54565b600061060051610620516106800101535b8151600101808352811415610a21575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610aa957600080fd5b5050610600610620516106600151610240818352015b610240610600511115610ad157610af2565b600061060051610620516106800101535b8151600101808352811415610abf575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610b4757600080fd5b5050610600610620516106600151610240818352015b610240610600511115610b6f57610b90565b600061060051610620516106800101535b8151600101808352811415610b5d575b5050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610c2557600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610c8557600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610cae57600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610cee57600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610d2257600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610d9f57600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610dd657600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610e3c57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610e9157600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f0457600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610f3b57600080fd5b60c0519050610ae052606435610ae05114610f5557600080fd5b6001805460018254011015610f6957600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d0051161415610fb957610ae051610d205160208110610fa857600080fd5b600060c052602060c020015561104d565b6000610d205160208110610fcc57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af161101d57600080fd5b60c0519050610ae052610d00600261103457600080fd5b60028151048152505b8151600101808352811415610f84575b5050005b639890220b600051141561108557341561106a57600080fd5b600060006000600030316002546000f161108357600080fd5b005b638ba35cdf60005114156110ac57341561109e57600080fd5b60025460005260206000f350005b60006000fd5b6101a961125b036101a96000396101a961125b036000f3" // DeployDepositContract deploys a new Ethereum contract, binding an instance of DepositContract to it. -func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, minDeposit *big.Int, _drain_address common.Address) (common.Address, *types.Transaction, *DepositContract, error) { +func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, _drain_address common.Address) (common.Address, *types.Transaction, *DepositContract, error) { parsed, err := abi.JSON(strings.NewReader(DepositContractABI)) if err != nil { return common.Address{}, nil, nil, err } - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(DepositContractBin), backend, minDeposit, _drain_address) + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(DepositContractBin), backend, _drain_address) if err != nil { return common.Address{}, nil, nil, err } @@ -188,58 +189,6 @@ func (_DepositContract *DepositContractTransactorRaw) Transact(opts *bind.Transa return _DepositContract.Contract.contract.Transact(opts, method, params...) } -// MINDEPOSITAMOUNT is a free data retrieval call binding the contract method 0x1ea30fef. -// -// Solidity: function MIN_DEPOSIT_AMOUNT() constant returns(uint256 out) -func (_DepositContract *DepositContractCaller) MINDEPOSITAMOUNT(opts *bind.CallOpts) (*big.Int, error) { - var ( - ret0 = new(*big.Int) - ) - out := ret0 - err := _DepositContract.contract.Call(opts, out, "MIN_DEPOSIT_AMOUNT") - return *ret0, err -} - -// MINDEPOSITAMOUNT is a free data retrieval call binding the contract method 0x1ea30fef. -// -// Solidity: function MIN_DEPOSIT_AMOUNT() constant returns(uint256 out) -func (_DepositContract *DepositContractSession) MINDEPOSITAMOUNT() (*big.Int, error) { - return _DepositContract.Contract.MINDEPOSITAMOUNT(&_DepositContract.CallOpts) -} - -// MINDEPOSITAMOUNT is a free data retrieval call binding the contract method 0x1ea30fef. -// -// Solidity: function MIN_DEPOSIT_AMOUNT() constant returns(uint256 out) -func (_DepositContract *DepositContractCallerSession) MINDEPOSITAMOUNT() (*big.Int, error) { - return _DepositContract.Contract.MINDEPOSITAMOUNT(&_DepositContract.CallOpts) -} - -// DepositCount is a free data retrieval call binding the contract method 0xeb8545ee. -// -// Solidity: function deposit_count() constant returns(uint256 out) -func (_DepositContract *DepositContractCaller) DepositCount(opts *bind.CallOpts) (*big.Int, error) { - var ( - ret0 = new(*big.Int) - ) - out := ret0 - err := _DepositContract.contract.Call(opts, out, "deposit_count") - return *ret0, err -} - -// DepositCount is a free data retrieval call binding the contract method 0xeb8545ee. -// -// Solidity: function deposit_count() constant returns(uint256 out) -func (_DepositContract *DepositContractSession) DepositCount() (*big.Int, error) { - return _DepositContract.Contract.DepositCount(&_DepositContract.CallOpts) -} - -// DepositCount is a free data retrieval call binding the contract method 0xeb8545ee. -// -// Solidity: function deposit_count() constant returns(uint256 out) -func (_DepositContract *DepositContractCallerSession) DepositCount() (*big.Int, error) { - return _DepositContract.Contract.DepositCount(&_DepositContract.CallOpts) -} - // DrainAddress is a free data retrieval call binding the contract method 0x8ba35cdf. // // Solidity: function drain_address() constant returns(address out) @@ -292,51 +241,51 @@ func (_DepositContract *DepositContractCallerSession) GetDepositCount() ([]byte, return _DepositContract.Contract.GetDepositCount(&_DepositContract.CallOpts) } -// GetHashTreeRoot is a free data retrieval call binding the contract method 0x863a311b. +// GetDepositRoot is a free data retrieval call binding the contract method 0xc5f2892f. // -// Solidity: function get_hash_tree_root() constant returns(bytes32 out) -func (_DepositContract *DepositContractCaller) GetHashTreeRoot(opts *bind.CallOpts) ([32]byte, error) { +// Solidity: function get_deposit_root() constant returns(bytes32 out) +func (_DepositContract *DepositContractCaller) GetDepositRoot(opts *bind.CallOpts) ([32]byte, error) { var ( ret0 = new([32]byte) ) out := ret0 - err := _DepositContract.contract.Call(opts, out, "get_hash_tree_root") + err := _DepositContract.contract.Call(opts, out, "get_deposit_root") return *ret0, err } -// GetHashTreeRoot is a free data retrieval call binding the contract method 0x863a311b. +// GetDepositRoot is a free data retrieval call binding the contract method 0xc5f2892f. // -// Solidity: function get_hash_tree_root() constant returns(bytes32 out) -func (_DepositContract *DepositContractSession) GetHashTreeRoot() ([32]byte, error) { - return _DepositContract.Contract.GetHashTreeRoot(&_DepositContract.CallOpts) +// Solidity: function get_deposit_root() constant returns(bytes32 out) +func (_DepositContract *DepositContractSession) GetDepositRoot() ([32]byte, error) { + return _DepositContract.Contract.GetDepositRoot(&_DepositContract.CallOpts) } -// GetHashTreeRoot is a free data retrieval call binding the contract method 0x863a311b. +// GetDepositRoot is a free data retrieval call binding the contract method 0xc5f2892f. // -// Solidity: function get_hash_tree_root() constant returns(bytes32 out) -func (_DepositContract *DepositContractCallerSession) GetHashTreeRoot() ([32]byte, error) { - return _DepositContract.Contract.GetHashTreeRoot(&_DepositContract.CallOpts) +// Solidity: function get_deposit_root() constant returns(bytes32 out) +func (_DepositContract *DepositContractCallerSession) GetDepositRoot() ([32]byte, error) { + return _DepositContract.Contract.GetDepositRoot(&_DepositContract.CallOpts) } -// Deposit is a paid mutator transaction binding the contract method 0xc47e300d. +// Deposit is a paid mutator transaction binding the contract method 0x22895118. // -// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature) returns() -func (_DepositContract *DepositContractTransactor) Deposit(opts *bind.TransactOpts, pubkey []byte, withdrawal_credentials []byte, signature []byte) (*types.Transaction, error) { - return _DepositContract.contract.Transact(opts, "deposit", pubkey, withdrawal_credentials, signature) +// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature, bytes32 deposit_data_root) returns() +func (_DepositContract *DepositContractTransactor) Deposit(opts *bind.TransactOpts, pubkey []byte, withdrawal_credentials []byte, signature []byte, deposit_data_root [32]byte) (*types.Transaction, error) { + return _DepositContract.contract.Transact(opts, "deposit", pubkey, withdrawal_credentials, signature, deposit_data_root) } -// Deposit is a paid mutator transaction binding the contract method 0xc47e300d. +// Deposit is a paid mutator transaction binding the contract method 0x22895118. // -// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature) returns() -func (_DepositContract *DepositContractSession) Deposit(pubkey []byte, withdrawal_credentials []byte, signature []byte) (*types.Transaction, error) { - return _DepositContract.Contract.Deposit(&_DepositContract.TransactOpts, pubkey, withdrawal_credentials, signature) +// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature, bytes32 deposit_data_root) returns() +func (_DepositContract *DepositContractSession) Deposit(pubkey []byte, withdrawal_credentials []byte, signature []byte, deposit_data_root [32]byte) (*types.Transaction, error) { + return _DepositContract.Contract.Deposit(&_DepositContract.TransactOpts, pubkey, withdrawal_credentials, signature, deposit_data_root) } -// Deposit is a paid mutator transaction binding the contract method 0xc47e300d. +// Deposit is a paid mutator transaction binding the contract method 0x22895118. // -// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature) returns() -func (_DepositContract *DepositContractTransactorSession) Deposit(pubkey []byte, withdrawal_credentials []byte, signature []byte) (*types.Transaction, error) { - return _DepositContract.Contract.Deposit(&_DepositContract.TransactOpts, pubkey, withdrawal_credentials, signature) +// Solidity: function deposit(bytes pubkey, bytes withdrawal_credentials, bytes signature, bytes32 deposit_data_root) returns() +func (_DepositContract *DepositContractTransactorSession) Deposit(pubkey []byte, withdrawal_credentials []byte, signature []byte, deposit_data_root [32]byte) (*types.Transaction, error) { + return _DepositContract.Contract.Deposit(&_DepositContract.TransactOpts, pubkey, withdrawal_credentials, signature, deposit_data_root) } // Drain is a paid mutator transaction binding the contract method 0x9890220b. @@ -485,3 +434,14 @@ func (_DepositContract *DepositContractFilterer) WatchDepositEvent(opts *bind.Wa } }), nil } + +// ParseDepositEvent is a log parse operation binding the contract event 0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5. +// +// Solidity: event DepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index) +func (_DepositContract *DepositContractFilterer) ParseDepositEvent(log types.Log) (*DepositContractDepositEvent, error) { + event := new(DepositContractDepositEvent) + if err := _DepositContract.contract.UnpackLog(event, "DepositEvent", log); err != nil { + return nil, err + } + return event, nil +} diff --git a/contracts/deposit-contract/depositContract.v.py b/contracts/deposit-contract/depositContract.v.py index ce4d7c8cb0..cc7e4fa9dc 100644 --- a/contracts/deposit-contract/depositContract.v.py +++ b/contracts/deposit-contract/depositContract.v.py @@ -1,11 +1,11 @@ -## compiled with v0.1.0-beta.9 ## +# Vyper target 0.1.0b12 +MIN_DEPOSIT_AMOUNT: constant(uint256) = 1000000000 # Gwei DEPOSIT_CONTRACT_TREE_DEPTH: constant(uint256) = 32 -SECONDS_PER_DAY: constant(uint256) = 86400 MAX_DEPOSIT_COUNT: constant(uint256) = 4294967295 # 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1 PUBKEY_LENGTH: constant(uint256) = 48 # bytes WITHDRAWAL_CREDENTIALS_LENGTH: constant(uint256) = 32 # bytes -AMOUNT_LENGTH: constant(uint256) = 8 # bytes SIGNATURE_LENGTH: constant(uint256) = 96 # bytes +AMOUNT_LENGTH: constant(uint256) = 8 # bytes DepositEvent: event({ pubkey: bytes[48], @@ -15,26 +15,17 @@ DepositEvent: event({ index: bytes[8], }) -MIN_DEPOSIT_AMOUNT: public(uint256) # Gwei -zero_hashes: bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] branch: bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] -deposit_count: public(uint256) +deposit_count: uint256 drain_address: public(address) +# Compute hashes in empty sparse Merkle tree +zero_hashes: bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] @public -def __init__( # Parameters for debugging, not for production use! - minDeposit: uint256, - _drain_address: address): - self.MIN_DEPOSIT_AMOUNT = minDeposit +def __init__(_drain_address: address): self.drain_address = _drain_address for i in range(DEPOSIT_CONTRACT_TREE_DEPTH - 1): - self.zero_hashes[i+1] = sha256(concat(self.zero_hashes[i], self.zero_hashes[i])) - -@private -@constant -def to_bytes8(value: uint256) -> bytes[8]: - return slice(convert(value, bytes32), start=24, len=8) - + self.zero_hashes[i + 1] = sha256(concat(self.zero_hashes[i], self.zero_hashes[i])) @private @constant @@ -53,7 +44,7 @@ def to_little_endian_64(value: uint256) -> bytes[8]: @public @constant -def get_hash_tree_root() -> bytes32: +def get_deposit_root() -> bytes32: zero_bytes32: bytes32 = 0x0000000000000000000000000000000000000000000000000000000000000000 node: bytes32 = zero_bytes32 size: uint256 = self.deposit_count @@ -76,13 +67,16 @@ def get_deposit_count() -> bytes[8]: @public def deposit(pubkey: bytes[PUBKEY_LENGTH], withdrawal_credentials: bytes[WITHDRAWAL_CREDENTIALS_LENGTH], - signature: bytes[SIGNATURE_LENGTH]): + signature: bytes[SIGNATURE_LENGTH], + deposit_data_root: bytes32): # Avoid overflowing the Merkle tree (and prevent edge case in computing `self.branch`) assert self.deposit_count < MAX_DEPOSIT_COUNT - # Validate deposit data + # Check deposit amount deposit_amount: uint256 = msg.value / as_wei_value(1, "gwei") - assert deposit_amount >= self.MIN_DEPOSIT_AMOUNT + assert deposit_amount >= MIN_DEPOSIT_AMOUNT + + # Length checks to facilitate formal verification (see https://github.com/ethereum/eth2.0-specs/pull/1362/files#r320361859) assert len(pubkey) == PUBKEY_LENGTH assert len(withdrawal_credentials) == WITHDRAWAL_CREDENTIALS_LENGTH assert len(signature) == SIGNATURE_LENGTH @@ -91,7 +85,7 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH], amount: bytes[8] = self.to_little_endian_64(deposit_amount) log.DepositEvent(pubkey, withdrawal_credentials, amount, signature, self.to_little_endian_64(self.deposit_count)) - # Compute `DepositData` hash tree root + # Compute deposit data root (`DepositData` hash tree root) zero_bytes32: bytes32 = 0x0000000000000000000000000000000000000000000000000000000000000000 pubkey_root: bytes32 = sha256(concat(pubkey, slice(zero_bytes32, start=0, len=64 - PUBKEY_LENGTH))) signature_root: bytes32 = sha256(concat( @@ -102,8 +96,10 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH], sha256(concat(pubkey_root, withdrawal_credentials)), sha256(concat(amount, slice(zero_bytes32, start=0, len=32 - AMOUNT_LENGTH), signature_root)), )) + # Verify computed and expected deposit data roots match + assert node == deposit_data_root - # Add `DepositData` hash tree root to Merkle tree (update a single `branch` node) + # Add deposit data root to Merkle tree (update a single `branch` node) self.deposit_count += 1 size: uint256 = self.deposit_count for height in range(DEPOSIT_CONTRACT_TREE_DEPTH): @@ -113,10 +109,9 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH], node = sha256(concat(self.branch[height], node)) size /= 2 - # !!! DEBUG ONLY !!! # This method is NOT part of the final ETH2.0 deposit contract, but we use it # to recover test funds. @public def drain(): - send(self.drain_address, self.balance) \ No newline at end of file + send(self.drain_address, self.balance) diff --git a/contracts/deposit-contract/depositContract_test.go b/contracts/deposit-contract/depositContract_test.go index 1b3382c142..a8bc85151b 100644 --- a/contracts/deposit-contract/depositContract_test.go +++ b/contracts/deposit-contract/depositContract_test.go @@ -1,4 +1,4 @@ -package depositcontract +package depositcontract_test import ( "context" @@ -9,10 +9,12 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" + depositcontract "github.com/prysmaticlabs/prysm/contracts/deposit-contract" + "github.com/prysmaticlabs/prysm/shared/interop" ) func TestSetupRegistrationContract_OK(t *testing.T) { - _, err := Setup() + _, err := depositcontract.Setup() if err != nil { log.Fatalf("Can not deploy validator registration contract: %v", err) } @@ -20,56 +22,61 @@ func TestSetupRegistrationContract_OK(t *testing.T) { // negative test case, deposit with less than 1 ETH which is less than the top off amount. func TestRegister_Below1ETH(t *testing.T) { - testAccount, err := Setup() + testAccount, err := depositcontract.Setup() if err != nil { t.Fatal(err) } - testAccount.TxOpts.Value = LessThan1Eth() - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, []byte{}, []byte{}, []byte{}) + // Generate deposit data + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 1) + if err != nil { + t.Fatal(err) + } + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } + + var depositDataRoot [32]byte + copy(depositDataRoot[:], depositDataRoots[0]) + testAccount.TxOpts.Value = depositcontract.LessThan1Eth() + _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubKeys[0].Marshal(), depositDataItems[0].WithdrawalCredentials, depositDataItems[0].Signature, depositDataRoot) if err == nil { t.Error("Validator registration should have failed with insufficient deposit") } } -// negative test case, deposit with more than 32 ETH which is more than the asked amount. -func TestRegister_Above32Eth(t *testing.T) { - testAccount, err := Setup() - if err != nil { - t.Fatal(err) - } - - testAccount.TxOpts.Value = Amount33Eth() - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, []byte{}, []byte{}, []byte{}) - if err == nil { - t.Error("Validator registration should have failed with more than asked deposit amount") - } -} - // normal test case, test depositing 32 ETH and verify HashChainValue event is correctly emitted. func TestValidatorRegister_OK(t *testing.T) { - testAccount, err := Setup() + testAccount, err := depositcontract.Setup() if err != nil { t.Fatal(err) } - testAccount.TxOpts.Value = Amount32Eth() - testAccount.TxOpts.GasLimit = 1000000 + testAccount.TxOpts.Value = depositcontract.Amount32Eth() - var pubkey [48]byte - var withdrawalCreds [32]byte - var sig [96]byte + // Generate deposit data + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 1) + if err != nil { + t.Fatal(err) + } + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubkey[:], withdrawalCreds[:], sig[:]) + var depositDataRoot [32]byte + copy(depositDataRoot[:], depositDataRoots[0]) + _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubKeys[0].Marshal(), depositDataItems[0].WithdrawalCredentials, depositDataItems[0].Signature, depositDataRoot) testAccount.Backend.Commit() if err != nil { t.Errorf("Validator registration failed: %v", err) } - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubkey[:], withdrawalCreds[:], sig[:]) + _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubKeys[0].Marshal(), depositDataItems[0].WithdrawalCredentials, depositDataItems[0].Signature, depositDataRoot) testAccount.Backend.Commit() if err != nil { t.Errorf("Validator registration failed: %v", err) } - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubkey[:], withdrawalCreds[:], sig[:]) + _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubKeys[0].Marshal(), depositDataItems[0].WithdrawalCredentials, depositDataItems[0].Signature, depositDataRoot) testAccount.Backend.Commit() if err != nil { t.Errorf("Validator registration failed: %v", err) @@ -89,7 +96,7 @@ func TestValidatorRegister_OK(t *testing.T) { merkleTreeIndex := make([]uint64, 5) for i, log := range logs { - _, _, _, _, idx, err := UnpackDepositLogData(log.Data) + _, _, _, _, idx, err := depositcontract.UnpackDepositLogData(log.Data) if err != nil { t.Fatalf("Unable to unpack log data: %v", err) } @@ -110,17 +117,25 @@ func TestValidatorRegister_OK(t *testing.T) { } func TestDrain(t *testing.T) { - testAccount, err := Setup() + testAccount, err := depositcontract.Setup() if err != nil { t.Fatal(err) } - testAccount.TxOpts.Value = Amount32Eth() + testAccount.TxOpts.Value = depositcontract.Amount32Eth() - var pubkey [48]byte - var withdrawalCreds [32]byte - var sig [96]byte + // Generate deposit data + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 1) + if err != nil { + t.Fatal(err) + } + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubkey[:], withdrawalCreds[:], sig[:]) + var depositDataRoot [32]byte + copy(depositDataRoot[:], depositDataRoots[0]) + _, err = testAccount.Contract.Deposit(testAccount.TxOpts, pubKeys[0].Marshal(), depositDataItems[0].WithdrawalCredentials, depositDataItems[0].Signature, depositDataRoot) testAccount.Backend.Commit() if err != nil { t.Errorf("Validator registration failed: %v", err) @@ -133,7 +148,7 @@ func TestDrain(t *testing.T) { if err != nil { t.Fatal(err) } - if bal.Cmp(Amount32Eth()) != 0 { + if bal.Cmp(depositcontract.Amount32Eth()) != 0 { t.Fatal("deposit didnt work") } diff --git a/contracts/deposit-contract/deposit_tree_test.go b/contracts/deposit-contract/deposit_tree_test.go new file mode 100644 index 0000000000..87af80897e --- /dev/null +++ b/contracts/deposit-contract/deposit_tree_test.go @@ -0,0 +1,139 @@ +package depositcontract_test + +import ( + "strconv" + "testing" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/prysmaticlabs/go-ssz" + depositcontract "github.com/prysmaticlabs/prysm/contracts/deposit-contract" + "github.com/prysmaticlabs/prysm/shared/interop" + "github.com/prysmaticlabs/prysm/shared/params" + "github.com/prysmaticlabs/prysm/shared/trieutil" +) + +func TestDepositTrieRoot_OK(t *testing.T) { + testAcc, err := depositcontract.Setup() + if err != nil { + t.Fatal(err) + } + + localTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatal(err) + } + + depRoot, err := testAcc.Contract.GetDepositRoot(&bind.CallOpts{}) + if err != nil { + t.Fatal(err) + } + + if depRoot != localTrie.HashTreeRoot() { + t.Errorf("Local deposit trie root and contract deposit trie root are not equal. Expected %#x , Got %#x", depRoot, localTrie.Root()) + } + + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 101) + if err != nil { + t.Fatal(err) + } + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } + + testAcc.TxOpts.Value = depositcontract.Amount32Eth() + + for i := 0; i < 100; i++ { + data := depositDataItems[i] + dataRoot := [32]byte{} + copy(dataRoot[:], depositDataRoots[i]) + + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, dataRoot); err != nil { + t.Fatalf("Could not deposit to deposit contract %v", err) + } + + testAcc.Backend.Commit() + item, err := ssz.HashTreeRoot(data) + if err != nil { + t.Fatal(err) + } + + err = localTrie.InsertIntoTrie(item[:], i) + if err != nil { + t.Error(err) + } + + depRoot, err = testAcc.Contract.GetDepositRoot(&bind.CallOpts{}) + if err != nil { + t.Fatal(err) + } + + if depRoot != localTrie.HashTreeRoot() { + t.Errorf("Local deposit trie root and contract deposit trie root are not equal for index %d. Expected %#x , Got %#x", i, depRoot, localTrie.Root()) + } + } +} + +func TestDepositTrieRoot_Fail(t *testing.T) { + testAcc, err := depositcontract.Setup() + if err != nil { + t.Fatal(err) + } + + localTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatal(err) + } + + depRoot, err := testAcc.Contract.GetDepositRoot(&bind.CallOpts{}) + if err != nil { + t.Fatal(err) + } + + if depRoot != localTrie.HashTreeRoot() { + t.Errorf("Local deposit trie root and contract deposit trie root are not equal. Expected %#x , Got %#x", depRoot, localTrie.Root()) + } + + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 101) + if err != nil { + t.Fatal(err) + } + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } + testAcc.TxOpts.Value = depositcontract.Amount32Eth() + + for i := 0; i < 100; i++ { + data := depositDataItems[i] + dataRoot := [32]byte{} + copy(dataRoot[:], depositDataRoots[i]) + + if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, dataRoot); err != nil { + t.Fatalf("Could not deposit to deposit contract %v", err) + } + + // Change an element in the data when storing locally + copy(data.PublicKey, []byte(strconv.Itoa(i+10))) + + testAcc.Backend.Commit() + item, err := ssz.HashTreeRoot(data) + if err != nil { + t.Fatal(err) + } + + err = localTrie.InsertIntoTrie(item[:], i) + if err != nil { + t.Error(err) + } + + depRoot, err = testAcc.Contract.GetDepositRoot(&bind.CallOpts{}) + if err != nil { + t.Fatal(err) + } + + if depRoot == localTrie.HashTreeRoot() { + t.Errorf("Local deposit trie root and contract deposit trie root are equal for index %d when they were expected to be not equal", i) + } + } +} diff --git a/contracts/deposit-contract/sendDepositTx/sendDeposits.go b/contracts/deposit-contract/sendDepositTx/sendDeposits.go index d0709bd629..77d3077326 100644 --- a/contracts/deposit-contract/sendDepositTx/sendDeposits.go +++ b/contracts/deposit-contract/sendDepositTx/sendDeposits.go @@ -132,19 +132,17 @@ func main() { client := ethclient.NewClient(rpcClient) depositAmountInGwei := uint64(depositAmount) - depositAmount = depositAmount * 1e9 - // User inputs private key, sign tx with private key if privKeyString != "" { + // User inputs private key, sign tx with private key privKey, err := crypto.HexToECDSA(privKeyString) if err != nil { log.Fatal(err) } txOps = bind.NewKeyedTransactor(privKey) - txOps.Value = big.NewInt(depositAmount) - txOps.GasLimit = 4000000 - // User inputs keystore json file, sign tx with keystore json + txOps.Value = new(big.Int).Mul(big.NewInt(depositAmount), big.NewInt(1e9)) } else { + // User inputs keystore json file, sign tx with keystore json password := loadTextFromFile(passwordFile) // #nosec - Inclusion of file via variable is OK for this tool. @@ -158,8 +156,7 @@ func main() { } txOps = bind.NewKeyedTransactor(privKey.PrivateKey) - txOps.Value = big.NewInt(depositAmount) - txOps.GasLimit = 4000000 + txOps.Value = new(big.Int).Mul(big.NewInt(depositAmount), big.NewInt(1e9)) } depositContract, err := contracts.NewDepositContract(common.HexToAddress(depositContractAddr), client) @@ -186,15 +183,13 @@ func main() { } for _, validatorKey := range validatorKeys { - data, err := prysmKeyStore.DepositInput(validatorKey, validatorKey, depositAmountInGwei) + data, depositRoot, err := prysmKeyStore.DepositInput(validatorKey, validatorKey, depositAmountInGwei) if err != nil { log.Errorf("Could not generate deposit input data: %v", err) continue } - for i := int64(0); i < numberOfDeposits; i++ { - //TODO(#2658): Use actual compressed pubkeys in G1 here - tx, err := depositContract.Deposit(txOps, data.PublicKey, data.WithdrawalCredentials, data.Signature) + tx, err := depositContract.Deposit(txOps, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoot) if err != nil { log.Error("unable to send transaction to contract") } diff --git a/contracts/deposit-contract/testutils.go b/contracts/deposit-contract/testutils.go index f042d3c8eb..84482db816 100644 --- a/contracts/deposit-contract/testutils.go +++ b/contracts/deposit-contract/testutils.go @@ -28,7 +28,7 @@ type TestAccount struct { TxOpts *bind.TransactOpts } -// Setup creates the simulated backedn with the deposit contract deployed +// Setup creates the simulated backend with the deposit contract deployed func Setup() (*TestAccount, error) { genesis := make(core.GenesisAlloc) privKey, _ := crypto.GenerateKey() @@ -48,8 +48,7 @@ func Setup() (*TestAccount, error) { genesis[addr] = core.GenesisAccount{Balance: startingBalance} backend := backends.NewSimulatedBackend(genesis, 210000000000) - minDeposit := big.NewInt(1e9) - contractAddr, _, contract, err := DeployDepositContract(txOpts, backend, minDeposit, addr) + contractAddr, _, contract, err := DeployDepositContract(txOpts, backend, addr) if err != nil { return nil, err } diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index b77e9294f0..74ff5e6ce4 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -38,19 +38,14 @@ type BeaconState struct { Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` Validators []*v1alpha1.Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` - StartShard uint64 `protobuf:"varint,5001,opt,name=start_shard,json=startShard,proto3" json:"start_shard,omitempty"` - RandaoMixes [][]byte `protobuf:"bytes,5002,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"65536,32"` - ActiveIndexRoots [][]byte `protobuf:"bytes,5003,rep,name=active_index_roots,json=activeIndexRoots,proto3" json:"active_index_roots,omitempty" ssz-size:"65536,32"` - CompactCommitteesRoots [][]byte `protobuf:"bytes,5004,rep,name=compact_committees_roots,json=compactCommitteesRoots,proto3" json:"compact_committees_roots,omitempty" ssz-size:"65536,32"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"65536,32"` Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"8192"` - PreviousEpochAttestations []*PendingAttestation `protobuf:"bytes,7001,rep,name=previous_epoch_attestations,json=previousEpochAttestations,proto3" json:"previous_epoch_attestations,omitempty" ssz-max:"8192"` - CurrentEpochAttestations []*PendingAttestation `protobuf:"bytes,7002,rep,name=current_epoch_attestations,json=currentEpochAttestations,proto3" json:"current_epoch_attestations,omitempty" ssz-max:"8192"` - PreviousCrosslinks []*v1alpha1.Crosslink `protobuf:"bytes,8001,rep,name=previous_crosslinks,json=previousCrosslinks,proto3" json:"previous_crosslinks,omitempty" ssz-size:"1024"` - CurrentCrosslinks []*v1alpha1.Crosslink `protobuf:"bytes,8002,rep,name=current_crosslinks,json=currentCrosslinks,proto3" json:"current_crosslinks,omitempty" ssz-size:"1024"` - JustificationBits github_com_prysmaticlabs_go_bitfield.Bitvector4 `protobuf:"bytes,9001,opt,name=justification_bits,json=justificationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitvector4" json:"justification_bits,omitempty" ssz-size:"1"` - PreviousJustifiedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,9002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` - CurrentJustifiedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,9003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` - FinalizedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,9004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + PreviousEpochAttestations []*PendingAttestation `protobuf:"bytes,7001,rep,name=previous_epoch_attestations,json=previousEpochAttestations,proto3" json:"previous_epoch_attestations,omitempty" ssz-max:"4096"` + CurrentEpochAttestations []*PendingAttestation `protobuf:"bytes,7002,rep,name=current_epoch_attestations,json=currentEpochAttestations,proto3" json:"current_epoch_attestations,omitempty" ssz-max:"4096"` + JustificationBits github_com_prysmaticlabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitvector4" json:"justification_bits,omitempty" ssz-size:"1"` + PreviousJustifiedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *v1alpha1.Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -173,13 +168,6 @@ func (m *BeaconState) GetBalances() []uint64 { return nil } -func (m *BeaconState) GetStartShard() uint64 { - if m != nil { - return m.StartShard - } - return 0 -} - func (m *BeaconState) GetRandaoMixes() [][]byte { if m != nil { return m.RandaoMixes @@ -187,20 +175,6 @@ func (m *BeaconState) GetRandaoMixes() [][]byte { return nil } -func (m *BeaconState) GetActiveIndexRoots() [][]byte { - if m != nil { - return m.ActiveIndexRoots - } - return nil -} - -func (m *BeaconState) GetCompactCommitteesRoots() [][]byte { - if m != nil { - return m.CompactCommitteesRoots - } - return nil -} - func (m *BeaconState) GetSlashings() []uint64 { if m != nil { return m.Slashings @@ -222,20 +196,6 @@ func (m *BeaconState) GetCurrentEpochAttestations() []*PendingAttestation { return nil } -func (m *BeaconState) GetPreviousCrosslinks() []*v1alpha1.Crosslink { - if m != nil { - return m.PreviousCrosslinks - } - return nil -} - -func (m *BeaconState) GetCurrentCrosslinks() []*v1alpha1.Crosslink { - if m != nil { - return m.CurrentCrosslinks - } - return nil -} - func (m *BeaconState) GetJustificationBits() github_com_prysmaticlabs_go_bitfield.Bitvector4 { if m != nil { return m.JustificationBits @@ -328,7 +288,7 @@ func (m *Fork) GetEpoch() uint64 { } type PendingAttestation struct { - AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"aggregation_bits,omitempty" ssz-max:"4096"` + AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"aggregation_bits,omitempty" ssz-max:"2048"` Data *v1alpha1.AttestationData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` InclusionDelay uint64 `protobuf:"varint,3,opt,name=inclusion_delay,json=inclusionDelay,proto3" json:"inclusion_delay,omitempty"` ProposerIndex uint64 `protobuf:"varint,4,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty"` @@ -626,26 +586,27 @@ func (m *HistoricalBatch) GetStateRoots() [][]byte { return nil } -type CompactCommittee struct { - Pubkeys [][]byte `protobuf:"bytes,1,rep,name=pubkeys,proto3" json:"pubkeys,omitempty" ssz-size:"?,48" ssz-max:"4096"` - CompactValidators []uint64 `protobuf:"varint,2,rep,packed,name=compact_validators,json=compactValidators,proto3" json:"compact_validators,omitempty" ssz-max:"4096"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type AggregateAndProof struct { + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + SelectionProof []byte `protobuf:"bytes,2,opt,name=selection_proof,json=selectionProof,proto3" json:"selection_proof,omitempty" ssz-size:"96"` + Aggregate *v1alpha1.Attestation `protobuf:"bytes,3,opt,name=aggregate,proto3" json:"aggregate,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *CompactCommittee) Reset() { *m = CompactCommittee{} } -func (m *CompactCommittee) String() string { return proto.CompactTextString(m) } -func (*CompactCommittee) ProtoMessage() {} -func (*CompactCommittee) Descriptor() ([]byte, []int) { +func (m *AggregateAndProof) Reset() { *m = AggregateAndProof{} } +func (m *AggregateAndProof) String() string { return proto.CompactTextString(m) } +func (*AggregateAndProof) ProtoMessage() {} +func (*AggregateAndProof) Descriptor() ([]byte, []int) { return fileDescriptor_e719e7d82cfa7b0d, []int{7} } -func (m *CompactCommittee) XXX_Unmarshal(b []byte) error { +func (m *AggregateAndProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *CompactCommittee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AggregateAndProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_CompactCommittee.Marshal(b, m, deterministic) + return xxx_messageInfo_AggregateAndProof.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalTo(b) @@ -655,28 +616,35 @@ func (m *CompactCommittee) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *CompactCommittee) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompactCommittee.Merge(m, src) +func (m *AggregateAndProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_AggregateAndProof.Merge(m, src) } -func (m *CompactCommittee) XXX_Size() int { +func (m *AggregateAndProof) XXX_Size() int { return m.Size() } -func (m *CompactCommittee) XXX_DiscardUnknown() { - xxx_messageInfo_CompactCommittee.DiscardUnknown(m) +func (m *AggregateAndProof) XXX_DiscardUnknown() { + xxx_messageInfo_AggregateAndProof.DiscardUnknown(m) } -var xxx_messageInfo_CompactCommittee proto.InternalMessageInfo +var xxx_messageInfo_AggregateAndProof proto.InternalMessageInfo -func (m *CompactCommittee) GetPubkeys() [][]byte { +func (m *AggregateAndProof) GetIndex() uint64 { if m != nil { - return m.Pubkeys + return m.Index + } + return 0 +} + +func (m *AggregateAndProof) GetSelectionProof() []byte { + if m != nil { + return m.SelectionProof } return nil } -func (m *CompactCommittee) GetCompactValidators() []uint64 { +func (m *AggregateAndProof) GetAggregate() *v1alpha1.Attestation { if m != nil { - return m.CompactValidators + return m.Aggregate } return nil } @@ -689,97 +657,90 @@ func init() { proto.RegisterType((*ValidatorLatestVote)(nil), "ethereum.beacon.p2p.v1.ValidatorLatestVote") proto.RegisterType((*AttestationDataAndCustodyBit)(nil), "ethereum.beacon.p2p.v1.AttestationDataAndCustodyBit") proto.RegisterType((*HistoricalBatch)(nil), "ethereum.beacon.p2p.v1.HistoricalBatch") - proto.RegisterType((*CompactCommittee)(nil), "ethereum.beacon.p2p.v1.CompactCommittee") + proto.RegisterType((*AggregateAndProof)(nil), "ethereum.beacon.p2p.v1.AggregateAndProof") } func init() { proto.RegisterFile("proto/beacon/p2p/v1/types.proto", fileDescriptor_e719e7d82cfa7b0d) } var fileDescriptor_e719e7d82cfa7b0d = []byte{ - // 1333 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4b, 0x8f, 0x1b, 0xc5, - 0x16, 0x56, 0xcf, 0xf8, 0xde, 0x24, 0xe5, 0xc9, 0xd8, 0x2e, 0x47, 0x99, 0xbe, 0x49, 0xee, 0xb4, - 0x6f, 0xeb, 0x26, 0x19, 0xa1, 0x8c, 0x1d, 0x3b, 0x13, 0x7b, 0x26, 0x21, 0x44, 0xf1, 0x24, 0xa3, - 0x80, 0x40, 0x42, 0x9d, 0x10, 0x09, 0x09, 0xd1, 0x2a, 0x77, 0xd7, 0xb8, 0x8b, 0x69, 0x77, 0xb5, - 0xba, 0xca, 0x56, 0x26, 0x08, 0xb1, 0x60, 0xc5, 0x43, 0x62, 0x01, 0x2b, 0x58, 0xc1, 0x8e, 0xc7, - 0x1f, 0x00, 0x56, 0xb0, 0x62, 0xc9, 0x6b, 0x03, 0x0b, 0x0b, 0x65, 0x07, 0xac, 0xf0, 0x92, 0x15, - 0xaa, 0xaa, 0x7e, 0x79, 0x32, 0x4e, 0x46, 0xc0, 0xae, 0xbb, 0xea, 0xfb, 0xbe, 0x73, 0xea, 0x9c, - 0x53, 0x75, 0x0e, 0x30, 0xc2, 0x88, 0x72, 0xda, 0xe8, 0x61, 0xe4, 0xd0, 0xa0, 0x11, 0xb6, 0xc2, - 0xc6, 0xa8, 0xd9, 0xe0,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5, 0xe4, 0xc0, 0x75, 0xe5, - 0x6d, 0x57, 0x30, 0x6e, 0x4a, 0x82, 0x55, 0x51, 0x2a, 0xb9, 0x25, 0xb8, 0x0e, 0x8a, 0x4a, 0x33, - 0xa2, 0x94, 0x33, 0xfd, 0xbb, 0x52, 0x6d, 0x7e, 0x65, 0xa1, 0x7b, 0x7c, 0x32, 0x36, 0x20, 0x63, - 0xf7, 0x56, 0x19, 0xb9, 0x87, 0x2f, 0x99, 0xeb, 0xcd, 0x8d, 0xd6, 0xb9, 0x0b, 0x2d, 0xd3, 0x02, - 0x12, 0x6b, 0x09, 0xa8, 0x60, 0x8a, 0xdc, 0xe0, 0x98, 0xf9, 0xfd, 0x23, 0x98, 0x12, 0xab, 0x98, - 0x16, 0x28, 0x7b, 0x84, 0x71, 0x1a, 0x11, 0x07, 0xf9, 0x31, 0xfd, 0x07, 0x45, 0x3f, 0x33, 0x19, - 0x1b, 0x66, 0x46, 0xbf, 0x2a, 0xb8, 0x35, 0xf1, 0x3f, 0x40, 0x77, 0x2f, 0x99, 0xcd, 0x76, 0xa7, - 0xd3, 0x69, 0x35, 0xdb, 0xa6, 0x55, 0xca, 0x04, 0x94, 0xe6, 0x15, 0x70, 0x04, 0x73, 0xaf, 0x69, - 0xbb, 0x88, 0x23, 0xfd, 0xb3, 0x25, 0x19, 0x18, 0x63, 0x46, 0x60, 0x6e, 0x70, 0xaf, 0x79, 0x1d, - 0x71, 0x64, 0x1d, 0xc6, 0xf1, 0x17, 0x7c, 0x01, 0x94, 0x52, 0xba, 0x3d, 0xa2, 0x1c, 0x33, 0xfd, - 0xf3, 0xa5, 0xda, 0xfc, 0x01, 0x44, 0xba, 0x70, 0x32, 0x36, 0x16, 0x33, 0x17, 0xcf, 0xb7, 0xd6, - 0x4c, 0xeb, 0x68, 0x22, 0x7c, 0x47, 0x48, 0xc1, 0x55, 0x00, 0x95, 0x3a, 0x0e, 0x29, 0x23, 0xdc, - 0x26, 0x81, 0x8b, 0xef, 0xea,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, 0x9d, - 0x76, 0xe0, 0xe9, 0xae, 0x33, 0x3d, 0xdd, 0xcd, 0x1d, 0x74, 0xb8, 0x33, 0xdf, 0xd1, 0x40, 0x79, - 0x73, 0x4f, 0x0b, 0x85, 0x8f, 0x83, 0x43, 0xe1, 0xb0, 0xb7, 0x83, 0x77, 0x13, 0x17, 0xcc, 0xc9, - 0xd8, 0x58, 0xce, 0xcf, 0x79, 0x6b, 0xeb, 0xb9, 0x39, 0x4f, 0xd6, 0xbd, 0x95, 0x50, 0xe0, 0x35, - 0x00, 0x93, 0x76, 0x9e, 0x9b, 0x8b, 0xe6, 0x64, 0x0b, 0x86, 0x0f, 0x5e, 0x18, 0xab, 0x12, 0xa3, - 0xd3, 0x5c, 0xb2, 0xee, 0xc2, 0xd7, 0xf7, 0x97, 0xb5, 0x6f, 0xee, 0x2f, 0x6b, 0x3f, 0xdf, 0x5f, - 0xd6, 0x7a, 0xff, 0x96, 0x23, 0xfd, 0x85, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xac, 0x2f, 0x60, - 0x17, 0xad, 0x0c, 0x00, 0x00, + // 1221 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x8f, 0xdb, 0xc4, + 0x1b, 0x96, 0x77, 0xf3, 0xfb, 0xd1, 0x4e, 0xd2, 0xf5, 0xee, 0x6c, 0xd5, 0x35, 0x6d, 0xa9, 0x17, + 0x8b, 0xb6, 0x2b, 0xd4, 0x4d, 0x6a, 0x77, 0x9b, 0xec, 0x6e, 0xd5, 0x96, 0xba, 0x2d, 0x2a, 0x08, + 0xa4, 0xca, 0x94, 0x4a, 0x48, 0x08, 0x6b, 0x62, 0x4f, 0xe2, 0x61, 0x1d, 0x8f, 0xe5, 0x99, 0x44, + 0xdd, 0x22, 0xc4, 0x81, 0x13, 0x07, 0xc4, 0x85, 0x13, 0x37, 0xb8, 0xf0, 0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 0xfa, 0xc0, 0x61, 0x72, 0x8f, 0x66, 0x45, 0x79, 0x15, 0x1c, + 0xed, 0x91, 0x08, 0x85, 0xe4, 0xfe, 0xb4, 0xfa, 0x37, 0x07, 0x56, 0x5f, 0x2d, 0xf8, 0xe5, 0xa2, + 0xf1, 0xa1, 0x02, 0x6a, 0x62, 0x44, 0xc3, 0x4b, 0x60, 0xb9, 0xa8, 0xd6, 0x08, 0x27, 0x8c, 0xd0, + 0x48, 0x53, 0xa4, 0x3f, 0xcb, 0xd3, 0xfe, 0x6c, 0x19, 0x8e, 0x9a, 0x23, 0xef, 0xa6, 0x40, 0xb8, + 0x03, 0xd4, 0xbc, 0x04, 0x39, 0x77, 0x61, 0x0e, 0x77, 0x29, 0x03, 0xe6, 0xd4, 0xa3, 0xe0, 0x7f, + 0xb2, 0x23, 0xb5, 0x45, 0x39, 0x46, 0xd2, 0x17, 0xe3, 0x83, 0x05, 0x00, 0x1f, 0xed, 0x3a, 0x38, + 0x00, 0xcb, 0xa8, 0xdf, 0x4f, 0x70, 0xbf, 0xd2, 0x45, 0x69, 0x92, 0xf6, 0x54, 0x3f, 0x5a, 0xe7, + 0xb7, 0xb6, 0x45, 0x1b, 0x9d, 0x3b, 0x68, 0x1b, 0x85, 0x84, 0x71, 0x47, 0xad, 0x68, 0xcb, 0x0e, + 0xda, 0x05, 0x35, 0x39, 0x88, 0x17, 0x64, 0x89, 0xcf, 0xcc, 0x29, 0x71, 0x25, 0x41, 0x39, 0x8e, + 0x25, 0x07, 0x9e, 0x05, 0x2a, 0x89, 0xbc, 0x70, 0x28, 0x3e, 0xd2, 0xf5, 0x71, 0x88, 0xf6, 0xb3, + 0x2f, 0x5c, 0x2a, 0x96, 0x6f, 0x88, 0x55, 0x78, 0x1a, 0x2c, 0xc5, 0x09, 0x8d, 0x29, 0xc3, 0x49, + 0x36, 0x51, 0x6b, 0x12, 0x77, 0x24, 0x5f, 0x95, 0xd3, 0xd4, 0xf8, 0x48, 0x01, 0x2b, 0x95, 0x48, + 0x77, 0x50, 0xd2, 0xc7, 0x1c, 0xc2, 0xec, 0x68, 0x56, 0x2a, 0x27, 0xf3, 0x65, 0xb0, 0x52, 0xbd, + 0x4b, 0xc8, 0x93, 0x29, 0xb3, 0x63, 0x65, 0x32, 0xd6, 0x8f, 0x94, 0x76, 0x88, 0xd9, 0xa6, 0x76, + 0xcb, 0xf3, 0x55, 0x9c, 0x41, 0xd0, 0x02, 0xf5, 0x18, 0x49, 0x2b, 0x25, 0x71, 0x71, 0x1e, 0x11, + 0xa4, 0x28, 0xc1, 0x31, 0xae, 0x82, 0xd5, 0x62, 0x80, 0xbf, 0x24, 0x0f, 0x67, 0x71, 0x62, 0x94, + 0xde, 0x2a, 0x15, 0x6f, 0x45, 0xce, 0x65, 0x4a, 0x8e, 0x7c, 0x36, 0xde, 0x02, 0x27, 0x1f, 0x2a, + 0xe3, 0xb5, 0xc8, 0xbf, 0x3e, 0x64, 0x9c, 0xfa, 0xfb, 0x36, 0xe1, 0x85, 0x13, 0xca, 0xbf, 0x70, + 0x42, 0x07, 0x75, 0x2f, 0x55, 0x12, 0x0d, 0x23, 0xc3, 0x1e, 0x72, 0x80, 0x57, 0x88, 0x1b, 0xef, + 0x2a, 0x40, 0xbd, 0x55, 0x1c, 0xc4, 0x36, 0xe2, 0x5e, 0x00, 0x3b, 0xd3, 0x17, 0x0a, 0xe5, 0xc0, + 0xf7, 0x89, 0xce, 0xf4, 0x7d, 0x62, 0xe1, 0xa0, 0xd7, 0x09, 0xe3, 0x53, 0x61, 0x70, 0xd6, 0x80, + 0xf8, 0x5a, 0xe4, 0xdf, 0x4e, 0x28, 0xed, 0x89, 0x12, 0xa6, 0x4d, 0x91, 0x95, 0x50, 0xbe, 0xc0, + 0x5d, 0xa0, 0x32, 0x1c, 0x62, 0x4f, 0xfe, 0x05, 0xb1, 0x00, 0xce, 0x36, 0x58, 0x4c, 0xe5, 0xa5, + 0x02, 0x99, 0x2a, 0x3e, 0x07, 0x0e, 0xe7, 0x7d, 0x8e, 0xa5, 0xbb, 0x75, 0xcb, 0x78, 0x7c, 0x3d, + 0x9d, 0x92, 0x64, 0x37, 0xbe, 0x7d, 0x70, 0x4a, 0xf9, 0xee, 0xc1, 0x29, 0xe5, 0xd7, 0x07, 0xa7, + 0x94, 0xee, 0xff, 0xe5, 0xc5, 0xf2, 0xc2, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x5e, 0xbc, + 0x96, 0x33, 0x0b, 0x00, 0x00, } func (m *BeaconState) Marshal() (dAtA []byte, err error) { @@ -941,42 +902,9 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(j4)) i += copy(dAtA[i:], dAtA5[:j4]) } - if m.StartShard != 0 { - dAtA[i] = 0xc8 - i++ - dAtA[i] = 0xb8 - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.StartShard)) - } if len(m.RandaoMixes) > 0 { for _, b := range m.RandaoMixes { - dAtA[i] = 0xd2 - i++ - dAtA[i] = 0xb8 - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) - } - } - if len(m.ActiveIndexRoots) > 0 { - for _, b := range m.ActiveIndexRoots { - dAtA[i] = 0xda - i++ - dAtA[i] = 0xb8 - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) - } - } - if len(m.CompactCommitteesRoots) > 0 { - for _, b := range m.CompactCommitteesRoots { - dAtA[i] = 0xe2 + dAtA[i] = 0xca i++ dAtA[i] = 0xb8 i++ @@ -1039,54 +967,22 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { i += n } } - if len(m.PreviousCrosslinks) > 0 { - for _, msg := range m.PreviousCrosslinks { - dAtA[i] = 0x8a - i++ - dAtA[i] = 0xf4 - i++ - dAtA[i] = 0x3 - i++ - i = encodeVarintTypes(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.CurrentCrosslinks) > 0 { - for _, msg := range m.CurrentCrosslinks { - dAtA[i] = 0x92 - i++ - dAtA[i] = 0xf4 - i++ - dAtA[i] = 0x3 - i++ - i = encodeVarintTypes(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } if len(m.JustificationBits) > 0 { - dAtA[i] = 0xca + dAtA[i] = 0x8a i++ - dAtA[i] = 0xb2 + dAtA[i] = 0xf4 i++ - dAtA[i] = 0x4 + dAtA[i] = 0x3 i++ i = encodeVarintTypes(dAtA, i, uint64(len(m.JustificationBits))) i += copy(dAtA[i:], m.JustificationBits) } if m.PreviousJustifiedCheckpoint != nil { - dAtA[i] = 0xd2 + dAtA[i] = 0x92 i++ - dAtA[i] = 0xb2 + dAtA[i] = 0xf4 i++ - dAtA[i] = 0x4 + dAtA[i] = 0x3 i++ i = encodeVarintTypes(dAtA, i, uint64(m.PreviousJustifiedCheckpoint.Size())) n8, err := m.PreviousJustifiedCheckpoint.MarshalTo(dAtA[i:]) @@ -1096,11 +992,11 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { i += n8 } if m.CurrentJustifiedCheckpoint != nil { - dAtA[i] = 0xda + dAtA[i] = 0x9a i++ - dAtA[i] = 0xb2 + dAtA[i] = 0xf4 i++ - dAtA[i] = 0x4 + dAtA[i] = 0x3 i++ i = encodeVarintTypes(dAtA, i, uint64(m.CurrentJustifiedCheckpoint.Size())) n9, err := m.CurrentJustifiedCheckpoint.MarshalTo(dAtA[i:]) @@ -1110,11 +1006,11 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { i += n9 } if m.FinalizedCheckpoint != nil { - dAtA[i] = 0xe2 + dAtA[i] = 0xa2 i++ - dAtA[i] = 0xb2 + dAtA[i] = 0xf4 i++ - dAtA[i] = 0x4 + dAtA[i] = 0x3 i++ i = encodeVarintTypes(dAtA, i, uint64(m.FinalizedCheckpoint.Size())) n10, err := m.FinalizedCheckpoint.MarshalTo(dAtA[i:]) @@ -1362,7 +1258,7 @@ func (m *HistoricalBatch) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CompactCommittee) Marshal() (dAtA []byte, err error) { +func (m *AggregateAndProof) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -1372,35 +1268,31 @@ func (m *CompactCommittee) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CompactCommittee) MarshalTo(dAtA []byte) (int, error) { +func (m *AggregateAndProof) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if len(m.Pubkeys) > 0 { - for _, b := range m.Pubkeys { - dAtA[i] = 0xa - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) - } + if m.Index != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.Index)) } - if len(m.CompactValidators) > 0 { - dAtA14 := make([]byte, len(m.CompactValidators)*10) - var j13 int - for _, num := range m.CompactValidators { - for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j13++ - } - dAtA14[j13] = uint8(num) - j13++ - } + if len(m.SelectionProof) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintTypes(dAtA, i, uint64(j13)) - i += copy(dAtA[i:], dAtA14[:j13]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SelectionProof))) + i += copy(dAtA[i:], m.SelectionProof) + } + if m.Aggregate != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.Aggregate.Size())) + n13, err := m.Aggregate.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n13 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -1481,27 +1373,12 @@ func (m *BeaconState) Size() (n int) { } n += 3 + sovTypes(uint64(l)) + l } - if m.StartShard != 0 { - n += 3 + sovTypes(uint64(m.StartShard)) - } if len(m.RandaoMixes) > 0 { for _, b := range m.RandaoMixes { l = len(b) n += 3 + l + sovTypes(uint64(l)) } } - if len(m.ActiveIndexRoots) > 0 { - for _, b := range m.ActiveIndexRoots { - l = len(b) - n += 3 + l + sovTypes(uint64(l)) - } - } - if len(m.CompactCommitteesRoots) > 0 { - for _, b := range m.CompactCommitteesRoots { - l = len(b) - n += 3 + l + sovTypes(uint64(l)) - } - } if len(m.Slashings) > 0 { l = 0 for _, e := range m.Slashings { @@ -1521,18 +1398,6 @@ func (m *BeaconState) Size() (n int) { n += 3 + l + sovTypes(uint64(l)) } } - if len(m.PreviousCrosslinks) > 0 { - for _, e := range m.PreviousCrosslinks { - l = e.Size() - n += 3 + l + sovTypes(uint64(l)) - } - } - if len(m.CurrentCrosslinks) > 0 { - for _, e := range m.CurrentCrosslinks { - l = e.Size() - n += 3 + l + sovTypes(uint64(l)) - } - } l = len(m.JustificationBits) if l > 0 { n += 3 + l + sovTypes(uint64(l)) @@ -1689,24 +1554,22 @@ func (m *HistoricalBatch) Size() (n int) { return n } -func (m *CompactCommittee) Size() (n int) { +func (m *AggregateAndProof) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Pubkeys) > 0 { - for _, b := range m.Pubkeys { - l = len(b) - n += 1 + l + sovTypes(uint64(l)) - } + if m.Index != 0 { + n += 1 + sovTypes(uint64(m.Index)) } - if len(m.CompactValidators) > 0 { - l = 0 - for _, e := range m.CompactValidators { - l += sovTypes(uint64(e)) - } - n += 1 + sovTypes(uint64(l)) + l + l = len(m.SelectionProof) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Aggregate != nil { + l = m.Aggregate.Size() + n += 1 + l + sovTypes(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2162,25 +2025,6 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) } case 5001: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartShard", wireType) - } - m.StartShard = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartShard |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5002: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RandaoMixes", wireType) } @@ -2212,70 +2056,6 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { m.RandaoMixes = append(m.RandaoMixes, make([]byte, postIndex-iNdEx)) copy(m.RandaoMixes[len(m.RandaoMixes)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5003: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ActiveIndexRoots", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ActiveIndexRoots = append(m.ActiveIndexRoots, make([]byte, postIndex-iNdEx)) - copy(m.ActiveIndexRoots[len(m.ActiveIndexRoots)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5004: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CompactCommitteesRoots", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CompactCommitteesRoots = append(m.CompactCommitteesRoots, make([]byte, postIndex-iNdEx)) - copy(m.CompactCommitteesRoots[len(m.CompactCommitteesRoots)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 6001: if wireType == 0 { var v uint64 @@ -2421,74 +2201,6 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 8001: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PreviousCrosslinks", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PreviousCrosslinks = append(m.PreviousCrosslinks, &v1alpha1.Crosslink{}) - if err := m.PreviousCrosslinks[len(m.PreviousCrosslinks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8002: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentCrosslinks", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CurrentCrosslinks = append(m.CurrentCrosslinks, &v1alpha1.Crosslink{}) - if err := m.CurrentCrosslinks[len(m.CurrentCrosslinks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9001: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field JustificationBits", wireType) } @@ -2522,7 +2234,7 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { m.JustificationBits = []byte{} } iNdEx = postIndex - case 9002: + case 8002: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PreviousJustifiedCheckpoint", wireType) } @@ -2558,7 +2270,7 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9003: + case 8003: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentJustifiedCheckpoint", wireType) } @@ -2594,7 +2306,7 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9004: + case 8004: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FinalizedCheckpoint", wireType) } @@ -3434,7 +3146,7 @@ func (m *HistoricalBatch) Unmarshal(dAtA []byte) error { } return nil } -func (m *CompactCommittee) Unmarshal(dAtA []byte) error { +func (m *AggregateAndProof) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3457,15 +3169,34 @@ func (m *CompactCommittee) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CompactCommittee: wiretype end group for non-group") + return fmt.Errorf("proto: AggregateAndProof: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CompactCommittee: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AggregateAndProof: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pubkeys", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SelectionProof", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -3492,85 +3223,47 @@ func (m *CompactCommittee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Pubkeys = append(m.Pubkeys, make([]byte, postIndex-iNdEx)) - copy(m.Pubkeys[len(m.Pubkeys)-1], dAtA[iNdEx:postIndex]) + m.SelectionProof = append(m.SelectionProof[:0], dAtA[iNdEx:postIndex]...) + if m.SelectionProof == nil { + m.SelectionProof = []byte{} + } iNdEx = postIndex - case 2: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Aggregate", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes } - m.CompactValidators = append(m.CompactValidators, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break } - elementCount = count - if elementCount != 0 && len(m.CompactValidators) == 0 { - m.CompactValidators = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CompactValidators = append(m.CompactValidators, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field CompactValidators", wireType) } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Aggregate == nil { + m.Aggregate = &v1alpha1.Attestation{} + } + if err := m.Aggregate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index adf1c3d2e5..10e350e337 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -27,11 +27,8 @@ message BeaconState { repeated ethereum.eth.v1alpha1.Validator validators = 4001 [(gogoproto.moretags) = "ssz-max:\"1099511627776\""]; repeated uint64 balances = 4002 [(gogoproto.moretags) = "ssz-max:\"1099511627776\""]; - // Shuffling [5001-6000] - uint64 start_shard = 5001; - repeated bytes randao_mixes = 5002 [(gogoproto.moretags) = "ssz-size:\"randao_mixes.size\""]; - repeated bytes active_index_roots = 5003 [(gogoproto.moretags) = "ssz-size:\"active_index_roots.size\""]; - repeated bytes compact_committees_roots = 5004 [(gogoproto.moretags) = "ssz-size:\"compact_committees_roots.size\""]; + // Randomness [5001-6000] + repeated bytes randao_mixes = 5001 [(gogoproto.moretags) = "ssz-size:\"randao_mixes.size\""]; // Slashings [6001-7000] repeated uint64 slashings = 6001 [(gogoproto.moretags) = "ssz-size:\"slashings.size\""]; @@ -40,16 +37,12 @@ message BeaconState { repeated PendingAttestation previous_epoch_attestations = 7001 [(gogoproto.moretags) = "ssz-max:\"previous_epoch_attestations.max\""]; repeated PendingAttestation current_epoch_attestations = 7002 [(gogoproto.moretags) = "ssz-max:\"current_epoch_attestations.max\""]; - // Crosslinks [8001-9000] - repeated ethereum.eth.v1alpha1.Crosslink previous_crosslinks = 8001 [(gogoproto.moretags) = "ssz-size:\"previous_crosslinks.size\""]; - repeated ethereum.eth.v1alpha1.Crosslink current_crosslinks = 8002 [(gogoproto.moretags) = "ssz-size:\"current_crosslinks.size\""]; - - // Finality [9001-10000] + // Finality [8001-9000] // Spec type [4]Bitvector which means this would be a fixed size of 4 bits. - bytes justification_bits = 9001 [(gogoproto.moretags) = "ssz-size:\"1\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"]; - ethereum.eth.v1alpha1.Checkpoint previous_justified_checkpoint = 9002; - ethereum.eth.v1alpha1.Checkpoint current_justified_checkpoint = 9003; - ethereum.eth.v1alpha1.Checkpoint finalized_checkpoint = 9004; + bytes justification_bits = 8001 [(gogoproto.moretags) = "ssz-size:\"1\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"]; + ethereum.eth.v1alpha1.Checkpoint previous_justified_checkpoint = 8002; + ethereum.eth.v1alpha1.Checkpoint current_justified_checkpoint = 8003; + ethereum.eth.v1alpha1.Checkpoint finalized_checkpoint = 8004; } message Fork { @@ -61,7 +54,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\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; + bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"2048\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; ethereum.eth.v1alpha1.AttestationData data = 2; // The difference of when attestation gets created and get included on chain. uint64 inclusion_delay = 3; @@ -86,7 +79,7 @@ message ValidatorLatestVote { message AttestationDataAndCustodyBit { ethereum.eth.v1alpha1.AttestationData data = 1; - // Challengeable bit (SSZ-bool, 1 byte) for the custody of crosslink data + // Challengeable bit (SSZ-bool, 1 byte) for the custody of beacon data bool custody_bit = 2; } @@ -95,9 +88,11 @@ message HistoricalBatch { repeated bytes state_roots = 2 [(gogoproto.moretags) = "ssz-size:\"state_roots.size\""]; } -message CompactCommittee { - // The list of the validator public keys in the committee. - repeated bytes pubkeys = 1 [(gogoproto.moretags) = "ssz-size:\"?,48\" ssz-max:\"4096\""]; - // The list of the validator indices in the committee. - repeated uint64 compact_validators = 2 [(gogoproto.moretags) = "ssz-max:\"4096\""]; +message AggregateAndProof { + // index is the aggregator's index + uint64 index = 1; + // selection_proof is the signature of the slot aggregator signed to + bytes selection_proof = 2 [(gogoproto.moretags) = "ssz-size:\"96\""]; + // aggregate is the constructed aggregated attestation + ethereum.eth.v1alpha1.Attestation aggregate = 3; } diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index 09170bf490..42c223a99c 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -34,18 +34,21 @@ const ( ValidatorRole_UNKNOWN ValidatorRole = 0 ValidatorRole_ATTESTER ValidatorRole = 1 ValidatorRole_PROPOSER ValidatorRole = 2 + ValidatorRole_BOTH ValidatorRole = 3 ) var ValidatorRole_name = map[int32]string{ 0: "UNKNOWN", 1: "ATTESTER", 2: "PROPOSER", + 3: "BOTH", } var ValidatorRole_value = map[string]int32{ "UNKNOWN": 0, "ATTESTER": 1, "PROPOSER": 2, + "BOTH": 3, } func (x ValidatorRole) String() string { @@ -205,7 +208,7 @@ type AttestationRequest struct { PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` PocBit []byte `protobuf:"bytes,2,opt,name=poc_bit,json=pocBit,proto3" json:"poc_bit,omitempty"` Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - Shard uint64 `protobuf:"varint,4,opt,name=shard,proto3" json:"shard,omitempty"` + CommitteeIndex uint64 `protobuf:"varint,4,opt,name=committee_index,json=committeeIndex,proto3" json:"committee_index,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -265,9 +268,9 @@ func (m *AttestationRequest) GetSlot() uint64 { return 0 } -func (m *AttestationRequest) GetShard() uint64 { +func (m *AttestationRequest) GetCommitteeIndex() uint64 { if m != nil { - return m.Shard + return m.CommitteeIndex } return 0 } @@ -958,9 +961,9 @@ func (m *AssignmentResponse) GetValidatorAssignment() []*AssignmentResponse_Vali type AssignmentResponse_ValidatorAssignment struct { Committee []uint64 `protobuf:"varint,1,rep,packed,name=committee,proto3" json:"committee,omitempty"` - Shard uint64 `protobuf:"varint,2,opt,name=shard,proto3" json:"shard,omitempty"` - Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - IsProposer bool `protobuf:"varint,4,opt,name=is_proposer,json=isProposer,proto3" json:"is_proposer,omitempty"` + CommitteeIndex uint64 `protobuf:"varint,2,opt,name=committee_index,json=committeeIndex,proto3" json:"committee_index,omitempty"` + AttesterSlot uint64 `protobuf:"varint,3,opt,name=attester_slot,json=attesterSlot,proto3" json:"attester_slot,omitempty"` + ProposerSlot uint64 `protobuf:"varint,4,opt,name=proposer_slot,json=proposerSlot,proto3" json:"proposer_slot,omitempty"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` Status ValidatorStatus `protobuf:"varint,6,opt,name=status,proto3,enum=ethereum.beacon.rpc.v1.ValidatorStatus" json:"status,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1010,25 +1013,25 @@ func (m *AssignmentResponse_ValidatorAssignment) GetCommittee() []uint64 { return nil } -func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetCommitteeIndex() uint64 { if m != nil { - return m.Shard + return m.CommitteeIndex } return 0 } -func (m *AssignmentResponse_ValidatorAssignment) GetSlot() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetAttesterSlot() uint64 { if m != nil { - return m.Slot + return m.AttesterSlot } return 0 } -func (m *AssignmentResponse_ValidatorAssignment) GetIsProposer() bool { +func (m *AssignmentResponse_ValidatorAssignment) GetProposerSlot() uint64 { if m != nil { - return m.IsProposer + return m.ProposerSlot } - return false + return 0 } func (m *AssignmentResponse_ValidatorAssignment) GetPublicKey() []byte { @@ -1430,105 +1433,106 @@ func init() { func init() { proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_9eb4e94b85965285) } var fileDescriptor_9eb4e94b85965285 = []byte{ - // 1564 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xcf, 0x6e, 0x13, 0x49, - 0x13, 0x67, 0x1c, 0xc7, 0x09, 0x65, 0x27, 0x99, 0x74, 0x4c, 0x62, 0x4c, 0x80, 0x7c, 0xf3, 0xc1, - 0xf7, 0x25, 0x91, 0xb0, 0x13, 0x83, 0x10, 0x0b, 0x62, 0x91, 0x13, 0x0f, 0xc1, 0x02, 0x39, 0x61, - 0x6c, 0x12, 0x56, 0x1c, 0x46, 0x6d, 0xbb, 0x89, 0x47, 0xd8, 0xd3, 0x93, 0x99, 0xb6, 0x45, 0x2e, - 0x2b, 0xed, 0x23, 0xec, 0x61, 0xcf, 0xab, 0x7d, 0x86, 0x3d, 0xec, 0x2b, 0x70, 0xdc, 0x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0xf2, 0xfb, 0xe7, 0x5b, 0xca, 0x5f, 0x9f, 0x6f, 0x29, 0xcd, 0x14, 0xd7, 0x70, 0xff, 0xdf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x41, 0x63, 0x28, 0xb3, 0x3d, 0x11, 0x00, 0x00, + // 1581 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4f, 0x6f, 0x13, 0x47, + 0x14, 0x67, 0x1d, 0xc7, 0x09, 0xcf, 0x4e, 0xb2, 0x99, 0x84, 0xc4, 0x98, 0x40, 0xd3, 0x2d, 0x94, + 0x24, 0x12, 0x76, 0x62, 0x10, 0x6a, 0x41, 0x14, 0xd9, 0xf1, 0x92, 0x58, 0x20, 0x27, 0xac, 0x4d, + 0x42, 0xc5, 0x61, 0x35, 0xb6, 0x87, 0x78, 0x85, 0xbd, 0xb3, 0xd9, 0x1d, 0x5b, 0xe4, 0x52, 0xa9, + 0x97, 0x4a, 0xbd, 0xb5, 0x87, 0x9e, 0xab, 0x7e, 0x86, 0x1e, 0xfa, 0x15, 0x38, 0xf6, 0x03, 0xf4, + 0x50, 0xa1, 0x7e, 0x90, 0x6a, 0x67, 0x66, 0xd7, 0x1b, 0xff, 0x21, 0x0e, 0xb7, 0x9d, 0xf7, 0xde, + 0xef, 0xbd, 0x37, 0x6f, 0xde, 0x3f, 0x1b, 0x34, 0xc7, 0xa5, 0x8c, 0xe6, 0xea, 0x04, 0x37, 0xa8, + 0x9d, 0x73, 0x9d, 0x46, 0xae, 0xb7, 0x93, 0xf3, 0x88, 0xdb, 0xb3, 0x1a, 0xc4, 0xcb, 0x72, 0x26, + 0x5a, 0x21, 0xac, 0x45, 0x5c, 0xd2, 0xed, 0x64, 0x85, 0x58, 0xd6, 0x75, 0x1a, 0xd9, 0xde, 0x4e, + 0xe6, 0xc6, 0x09, 0xa5, 0x27, 0x6d, 0x92, 0xe3, 0x52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 0x5c, 0x92, 0x0c, 0x84, 0x55, 0x19, 0x0a, 0xeb, 0xef, 0xb1, 0xc8, 0x5b, 0x45, + 0xf1, 0x32, 0xaa, 0x0f, 0xe1, 0x1a, 0x16, 0x54, 0xd2, 0x34, 0x87, 0x54, 0x15, 0x63, 0x69, 0xc5, + 0x58, 0x0a, 0x05, 0x0e, 0x43, 0xbd, 0xe8, 0x08, 0x66, 0xfd, 0x7c, 0xed, 0x7a, 0x44, 0x3c, 0x66, + 0x32, 0xff, 0x28, 0x3b, 0xba, 0xc4, 0xb3, 0x9f, 0x30, 0x9f, 0xad, 0x72, 0x1d, 0x46, 0xa8, 0x2b, + 0xe3, 0x40, 0x42, 0xd0, 0x2e, 0xca, 0xff, 0x3d, 0x48, 0x08, 0x10, 0x7f, 0xe8, 0x64, 0x3e, 0x77, + 0xa1, 0x79, 0x69, 0x4b, 0x9a, 0x36, 0x24, 0x5c, 0x7b, 0x04, 0xab, 0xfa, 0x7b, 0x8b, 0x91, 0x66, + 0xff, 0xf5, 0x26, 0x8e, 0xee, 0x63, 0x48, 0x0f, 0x63, 0x65, 0x64, 0x2f, 0x04, 0xbf, 0x04, 0xb4, + 0xdb, 0xc2, 0x96, 0x5d, 0x65, 0xd8, 0xed, 0xd7, 0x5b, 0x1a, 0x66, 0x3c, 0x9f, 0x40, 0x9a, 0xfc, + 0xce, 0xb3, 0x46, 0x70, 0x44, 0x5f, 0x42, 0xea, 0x84, 0xd8, 0xc4, 0xb3, 0x3c, 0x93, 0x59, 0x1d, + 0x22, 0x13, 0x3c, 0x29, 0x69, 0x35, 0xab, 0x43, 0xb4, 0x87, 0x70, 0x2d, 0xf4, 0x84, 0x17, 0xf4, + 0x64, 0xcd, 0x44, 0xcb, 0xc2, 0xca, 0x20, 0x4e, 0xba, 0xb3, 0x0c, 0xd3, 0xa2, 0x5f, 0x88, 0x62, + 0x16, 0x07, 0xed, 0x15, 0x2c, 0x16, 0x3c, 0xcf, 0x3a, 0xb1, 0x3b, 0xc4, 0x66, 0x91, 0x68, 0x11, + 0x87, 0x36, 0x5a, 0x26, 0x77, 0x58, 0x02, 0x80, 0x93, 0xf8, 0x15, 0x2f, 0xee, 0x01, 0xbf, 0x4c, + 0x01, 0x8a, 0xea, 0x95, 0x3e, 0x9c, 0xc2, 0x72, 0xbf, 0x78, 0x70, 0xc8, 0xe7, 0x21, 0x4d, 0xe6, + 0xbf, 0x1b, 0xf7, 0xf0, 0xc3, 0x9a, 0x22, 0xa9, 0xd8, 0xe7, 0x2d, 0xf5, 0x86, 0x89, 0x99, 0x9f, + 0x62, 0xb0, 0x34, 0x42, 0x18, 0xad, 0xc1, 0xd5, 0xb0, 0x63, 0xca, 0x2e, 0xd4, 0x27, 0x8c, 0x6a, + 0xb3, 0xb1, 0x51, 0x6d, 0xd6, 0x9f, 0x24, 0x62, 0x40, 0x11, 0xd7, 0x8c, 0x34, 0xeb, 0x54, 0x40, + 0xac, 0xca, 0x71, 0xe3, 0x88, 0x49, 0x22, 0x85, 0x44, 0xcb, 0x4e, 0x05, 0x44, 0x2e, 0x74, 0xfe, + 0x61, 0xa7, 0x07, 0xab, 0xe4, 0x69, 0x58, 0x25, 0x89, 0x75, 0x65, 0x63, 0x3e, 0x7f, 0x77, 0xd2, + 0x2a, 0x09, 0xaa, 0xe3, 0xaf, 0x18, 0xac, 0x8e, 0xa9, 0xa0, 0x88, 0x72, 0xe5, 0xb3, 0x94, 0xa3, + 0x6f, 0xe1, 0x3a, 0x61, 0xad, 0x1d, 0xb3, 0x49, 0x1c, 0xea, 0x59, 0x4c, 0x0c, 0x75, 0xd3, 0xee, + 0x76, 0xea, 0xc4, 0x95, 0x91, 0xf3, 0xf7, 0x86, 0x9d, 0x92, 0xe0, 0xf3, 0x01, 0x5d, 0xe1, 0x5c, + 0xf4, 0x00, 0x56, 0x02, 0x94, 0x65, 0x37, 0xda, 0x5d, 0xcf, 0xa2, 0x76, 0x34, 0x94, 0xcb, 0x92, + 0x5b, 0x0e, 0x98, 0x3c, 0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xc9, 0x4e, 0x2a, 0x2e, 0x2f, 0xdc, 0x86, 0xa5, + 0xdd, 0x60, 0x90, 0x47, 0x96, 0x82, 0xcd, 0x49, 0x36, 0x10, 0x61, 0x71, 0x6b, 0xf2, 0x65, 0x05, + 0x9d, 0x0e, 0x77, 0x87, 0x4b, 0xde, 0xef, 0xb2, 0x3b, 0x31, 0xfa, 0x51, 0x81, 0xe5, 0x51, 0x3f, + 0xc2, 0xd0, 0xc5, 0x2f, 0x34, 0xfc, 0x3b, 0x30, 0xf3, 0xe0, 0x72, 0x20, 0xe9, 0x43, 0x17, 0xd4, + 0xc1, 0x9d, 0x1a, 0x8d, 0xbd, 0xc8, 0x98, 0xcd, 0x3d, 0xb3, 0x3d, 0x39, 0x40, 0x9a, 0xfd, 0x3e, + 0x4c, 0xe6, 0xfe, 0x52, 0x8e, 0x56, 0xb2, 0xe2, 0x4f, 0x83, 0x6c, 0xf0, 0xf7, 0x44, 0x56, 0xef, + 0x38, 0xec, 0x6c, 0xfc, 0x33, 0x0e, 0x2f, 0xf4, 0xdb, 0x0a, 0x7a, 0x0e, 0x73, 0xbb, 0xd8, 0xa6, + 0xb6, 0xd5, 0xc0, 0xed, 0x7d, 0x82, 0x9b, 0x63, 0xd5, 0x4e, 0xd0, 0x0f, 0x8a, 0xa9, 0x0f, 0x1f, + 0x6f, 0x29, 0x7f, 0x7f, 0xbc, 0xa5, 0xfc, 0xfb, 0xf1, 0x96, 0x52, 0x4f, 0x70, 0x0d, 0xf7, 0xff, + 0x0f, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x0b, 0x30, 0xbe, 0x83, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2207,10 +2211,10 @@ func (m *AttestationRequest) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintServices(dAtA, i, uint64(m.Slot)) } - if m.Shard != 0 { + if m.CommitteeIndex != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintServices(dAtA, i, uint64(m.Shard)) + i = encodeVarintServices(dAtA, i, uint64(m.CommitteeIndex)) } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -2694,25 +2698,20 @@ func (m *AssignmentResponse_ValidatorAssignment) MarshalTo(dAtA []byte) (int, er i = encodeVarintServices(dAtA, i, uint64(j4)) i += copy(dAtA[i:], dAtA5[:j4]) } - if m.Shard != 0 { + if m.CommitteeIndex != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintServices(dAtA, i, uint64(m.Shard)) + i = encodeVarintServices(dAtA, i, uint64(m.CommitteeIndex)) } - if m.Slot != 0 { + if m.AttesterSlot != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintServices(dAtA, i, uint64(m.Slot)) + i = encodeVarintServices(dAtA, i, uint64(m.AttesterSlot)) } - if m.IsProposer { + if m.ProposerSlot != 0 { dAtA[i] = 0x20 i++ - if m.IsProposer { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ + i = encodeVarintServices(dAtA, i, uint64(m.ProposerSlot)) } if len(m.PublicKey) > 0 { dAtA[i] = 0x2a @@ -3007,8 +3006,8 @@ func (m *AttestationRequest) Size() (n int) { if m.Slot != 0 { n += 1 + sovServices(uint64(m.Slot)) } - if m.Shard != 0 { - n += 1 + sovServices(uint64(m.Shard)) + if m.CommitteeIndex != 0 { + n += 1 + sovServices(uint64(m.CommitteeIndex)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -3286,14 +3285,14 @@ func (m *AssignmentResponse_ValidatorAssignment) Size() (n int) { } n += 1 + sovServices(uint64(l)) + l } - if m.Shard != 0 { - n += 1 + sovServices(uint64(m.Shard)) + if m.CommitteeIndex != 0 { + n += 1 + sovServices(uint64(m.CommitteeIndex)) } - if m.Slot != 0 { - n += 1 + sovServices(uint64(m.Slot)) + if m.AttesterSlot != 0 { + n += 1 + sovServices(uint64(m.AttesterSlot)) } - if m.IsProposer { - n += 2 + if m.ProposerSlot != 0 { + n += 1 + sovServices(uint64(m.ProposerSlot)) } l = len(m.PublicKey) if l > 0 { @@ -3757,9 +3756,9 @@ func (m *AttestationRequest) Unmarshal(dAtA []byte) error { } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Shard", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeIndex", wireType) } - m.Shard = 0 + m.CommitteeIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowServices @@ -3769,7 +3768,7 @@ func (m *AttestationRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Shard |= uint64(b&0x7F) << shift + m.CommitteeIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -5259,9 +5258,9 @@ func (m *AssignmentResponse_ValidatorAssignment) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Shard", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeIndex", wireType) } - m.Shard = 0 + m.CommitteeIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowServices @@ -5271,16 +5270,16 @@ func (m *AssignmentResponse_ValidatorAssignment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Shard |= uint64(b&0x7F) << shift + m.CommitteeIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Slot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AttesterSlot", wireType) } - m.Slot = 0 + m.AttesterSlot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowServices @@ -5290,16 +5289,16 @@ func (m *AssignmentResponse_ValidatorAssignment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Slot |= uint64(b&0x7F) << shift + m.AttesterSlot |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsProposer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProposerSlot", wireType) } - var v int + m.ProposerSlot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowServices @@ -5309,12 +5308,11 @@ func (m *AssignmentResponse_ValidatorAssignment) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.ProposerSlot |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsProposer = bool(v != 0) case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) diff --git a/proto/beacon/rpc/v1/services.proto b/proto/beacon/rpc/v1/services.proto index 79e17cce36..09ac75c1e2 100644 --- a/proto/beacon/rpc/v1/services.proto +++ b/proto/beacon/rpc/v1/services.proto @@ -42,7 +42,7 @@ message AttestationRequest { bytes public_key = 1; bytes poc_bit = 2; uint64 slot = 3; - uint64 shard = 4; + uint64 committee_index = 4; } message AttestResponse { @@ -93,6 +93,7 @@ message ChainStartResponse { UNKNOWN = 0; ATTESTER = 1; PROPOSER = 2; + BOTH = 3; } message ValidatorIndexRequest { @@ -112,9 +113,9 @@ message AssignmentResponse { repeated ValidatorAssignment validator_assignment = 1; message ValidatorAssignment { repeated uint64 committee = 1; - uint64 shard = 2; - uint64 slot = 3; - bool is_proposer = 4; + uint64 committee_index = 2; + uint64 attester_slot = 3; + uint64 proposer_slot = 4; bytes public_key = 5; ValidatorStatus status = 6; } diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index ca623082da..92e1c285cd 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -32,18 +32,21 @@ const ( ValidatorRole_UNKNOWN ValidatorRole = 0 ValidatorRole_ATTESTER ValidatorRole = 1 ValidatorRole_PROPOSER ValidatorRole = 2 + ValidatorRole_BOTH ValidatorRole = 3 ) var ValidatorRole_name = map[int32]string{ 0: "UNKNOWN", 1: "ATTESTER", 2: "PROPOSER", + 3: "BOTH", } var ValidatorRole_value = map[string]int32{ "UNKNOWN": 0, "ATTESTER": 1, "PROPOSER": 2, + "BOTH": 3, } func (x ValidatorRole) String() string { @@ -187,7 +190,7 @@ type AttestationRequest struct { PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` PocBit []byte `protobuf:"bytes,2,opt,name=poc_bit,json=pocBit,proto3" json:"poc_bit,omitempty"` Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - Shard uint64 `protobuf:"varint,4,opt,name=shard,proto3" json:"shard,omitempty"` + CommitteeIndex uint64 `protobuf:"varint,4,opt,name=committee_index,json=committeeIndex,proto3" json:"committee_index,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -239,9 +242,9 @@ func (m *AttestationRequest) GetSlot() uint64 { return 0 } -func (m *AttestationRequest) GetShard() uint64 { +func (m *AttestationRequest) GetCommitteeIndex() uint64 { if m != nil { - return m.Shard + return m.CommitteeIndex } return 0 } @@ -828,9 +831,9 @@ func (m *AssignmentResponse) GetValidatorAssignment() []*AssignmentResponse_Vali type AssignmentResponse_ValidatorAssignment struct { Committee []uint64 `protobuf:"varint,1,rep,packed,name=committee,proto3" json:"committee,omitempty"` - Shard uint64 `protobuf:"varint,2,opt,name=shard,proto3" json:"shard,omitempty"` - Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - IsProposer bool `protobuf:"varint,4,opt,name=is_proposer,json=isProposer,proto3" json:"is_proposer,omitempty"` + CommitteeIndex uint64 `protobuf:"varint,2,opt,name=committee_index,json=committeeIndex,proto3" json:"committee_index,omitempty"` + AttesterSlot uint64 `protobuf:"varint,3,opt,name=attester_slot,json=attesterSlot,proto3" json:"attester_slot,omitempty"` + ProposerSlot uint64 `protobuf:"varint,4,opt,name=proposer_slot,json=proposerSlot,proto3" json:"proposer_slot,omitempty"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` Status ValidatorStatus `protobuf:"varint,6,opt,name=status,proto3,enum=ethereum.beacon.rpc.v1.ValidatorStatus" json:"status,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -872,25 +875,25 @@ func (m *AssignmentResponse_ValidatorAssignment) GetCommittee() []uint64 { return nil } -func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetCommitteeIndex() uint64 { if m != nil { - return m.Shard + return m.CommitteeIndex } return 0 } -func (m *AssignmentResponse_ValidatorAssignment) GetSlot() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetAttesterSlot() uint64 { if m != nil { - return m.Slot + return m.AttesterSlot } return 0 } -func (m *AssignmentResponse_ValidatorAssignment) GetIsProposer() bool { +func (m *AssignmentResponse_ValidatorAssignment) GetProposerSlot() uint64 { if m != nil { - return m.IsProposer + return m.ProposerSlot } - return false + return 0 } func (m *AssignmentResponse_ValidatorAssignment) GetPublicKey() []byte { @@ -1244,104 +1247,105 @@ func init() { func init() { proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_9eb4e94b85965285) } var fileDescriptor_9eb4e94b85965285 = []byte{ - // 1546 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x41, 0x4f, 0x1b, 0xc9, - 0x12, 0xce, 0x18, 0x63, 0x48, 0xd9, 0xc0, 0xd0, 0x38, 0xe0, 0x38, 0x44, 0xe1, 0xcd, 0x4b, 0xde, - 0x03, 0xa4, 0xd8, 0xe0, 0x44, 0x51, 0x5e, 0xa2, 0xbc, 0xc8, 0xe0, 0x09, 0xb1, 0x12, 0x19, 0x32, - 0x76, 0x20, 0xab, 0x1c, 0x46, 0x6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e3, 0xae, 0x3d, 0x08, 0x35, 0xf8, 0x22, 0x04, 0x49, 0x6b, 0x49, 0xd0, 0x23, 0xc5, - 0x3e, 0x7a, 0x02, 0x6b, 0x52, 0x14, 0xb7, 0x38, 0x1d, 0x90, 0x38, 0x42, 0x86, 0xe7, 0x96, 0x60, - 0x97, 0x05, 0x37, 0x86, 0x7b, 0x08, 0xa8, 0x47, 0x7d, 0x9f, 0x3a, 0xa7, 0x71, 0x48, 0x52, 0xdc, - 0x63, 0x59, 0x71, 0x62, 0xe2, 0x07, 0xb0, 0x81, 0x07, 0xc4, 0xc3, 0xa7, 0x64, 0xcc, 0x90, 0xad, - 0xdc, 0xce, 0xcd, 0x6e, 0x68, 0x9b, 0x09, 0xeb, 0xae, 0x92, 0x1b, 0xb1, 0xb8, 0x27, 0x85, 0x8c, - 0x17, 0x90, 0x8f, 0x68, 0x42, 0xe4, 0x42, 0x45, 0x8c, 0x84, 0x55, 0x1b, 0x0b, 0xeb, 0xcf, 0x89, - 0x58, 0xae, 0xe2, 0x78, 0x15, 0xd5, 0x27, 0x70, 0x0b, 0x4b, 0x2a, 0x69, 0xdb, 0x63, 0xaa, 0xf6, - 0x12, 0x39, 0xcd, 0x5a, 0x89, 0x04, 0x8e, 0x22, 0xbd, 0xe8, 0x18, 0xe6, 0x83, 0xe2, 0xec, 0xfb, - 0x44, 0x26, 0x33, 0x5d, 0x7a, 0x56, 0xb8, 0xfc, 0x39, 0x17, 0xbe, 0x62, 0xbe, 0x50, 0x17, 0x3a, - 0xac, 0x48, 0x57, 0xde, 0x85, 0x94, 0xa4, 0x5d, 0x55, 0xec, 0x07, 0x90, 0x92, 0x20, 0x91, 0xe8, - 0x74, 0xa9, 0x78, 0xa5, 0x79, 0x65, 0x4b, 0x99, 0xb6, 0x14, 0xdc, 0x78, 0x06, 0x6b, 0xe6, 0x17, - 0xca, 0x49, 0x7b, 0x98, 0xbd, 0xa9, 0xa3, 0xfb, 0x1c, 0x72, 0xe3, 0x58, 0x15, 0xd9, 0x2b, 0xc1, - 0xef, 0x00, 0xed, 0x77, 0x30, 0x75, 0xea, 0x1c, 0x7b, 0xc3, 0xf7, 0x96, 0x83, 0x39, 0x3f, 0x20, - 0x90, 0xb6, 0xb8, 0xf3, 0xbc, 0x15, 0x1e, 0xd1, 0xbf, 0x20, 0x73, 0x4a, 0x1c, 0xe2, 0x53, 0xdf, - 0xe6, 0xb4, 0x47, 0x54, 0x81, 0xa7, 0x15, 0xad, 0x41, 0x7b, 0xc4, 0x78, 0x02, 0xb7, 0x22, 0x4f, - 0xaa, 0x4e, 0x9b, 0x7c, 0x99, 0xae, 0x73, 0x18, 0x05, 0x58, 0x1d, 0xc5, 0x29, 0x77, 0xb2, 0x30, - 0x4b, 0x03, 0x82, 0x7a, 0xcc, 0xf2, 0x60, 0xbc, 0x87, 0xe5, 0xb2, 0xef, 0xd3, 0x53, 0xa7, 0x47, - 0x1c, 0x1e, 0x8b, 0x16, 0x71, 0x59, 0xab, 0x63, 0x0b, 0x87, 0x15, 0x00, 0x04, 0x49, 0x5c, 0xf1, - 0xea, 0x1e, 0xf0, 0x77, 0x02, 0x50, 0x5c, 0xaf, 0xf2, 0xe1, 0x0c, 0xb2, 0xc3, 0xc7, 0x83, 0x23, - 0xbe, 0x08, 0x69, 0xba, 0xf4, 0xff, 0x49, 0x89, 0x1f, 0xd7, 0x14, 0x2b, 0xc5, 0x21, 0x6f, 0x65, - 0x30, 0x4e, 0xcc, 0xff, 0xa9, 0xc1, 0xca, 0x25, 0xc2, 0x68, 0x1d, 0x6e, 0xb6, 0x58, 0xaf, 0x47, - 0x39, 0x27, 0x44, 0x75, 0xa1, 0x21, 0x61, 0xd8, 0x53, 0x13, 0xb1, 0x9e, 0x7a, 0x69, 0xf7, 0xbd, - 0x07, 0x69, 0xea, 0xdb, 0xae, 0x1c, 0x0a, 0x9e, 0xe8, 0xc1, 0xf3, 0x16, 0x50, 0x5f, 0x8d, 0x09, - 0x6f, 0x24, 0x61, 0xb3, 0xa3, 0xd5, 0xff, 0x32, 0xaa, 0xfe, 0xd4, 0x86, 0xb6, 0xb9, 0x58, 0xfa, - 0xef, 0xb4, 0xd5, 0x1f, 0x56, 0xfd, 0x6f, 0x09, 0x58, 0x9b, 0xf0, 0x32, 0x62, 0xca, 0xb5, 0x6f, - 0x52, 0x8e, 0xfe, 0x07, 0xb7, 0x09, 0xef, 0xec, 0xda, 0x6d, 0xe2, 0x32, 0x9f, 0x72, 0x39, 0x98, - 0x6d, 0xa7, 0xdf, 0x6b, 0x12, 0x4f, 0xc5, 0x26, 0x98, 0xfd, 0xbb, 0x15, 0xc9, 0x17, 0x43, 0xb6, - 0x26, 0xb8, 0xe8, 0x31, 0xac, 0x86, 0x28, 0xea, 0xb4, 0xba, 0x7d, 0x9f, 0x32, 0xc7, 0x8e, 0x85, - 0x2f, 0xab, 0xb8, 0xd5, 0x90, 0x59, 0x0f, 0xc2, 0xb9, 0x05, 0x3a, 0x8e, 0x9a, 0x8b, 0x2d, 0x4a, - 0x4e, 0xcd, 0xb5, 0xa5, 0x21, 0xdd, 0x0c, 0xc8, 0xe8, 0x25, 0xac, 0x0b, 0x05, 0x81, 0x20, 0x75, - 0xec, 0x18, 0xec, 0xac, 0x4f, 0xfa, 0xb2, 0x29, 0x27, 0xad, 0xdb, 0xa1, 0x4c, 0xd5, 0x19, 0x76, - 0xad, 0x77, 0x81, 0x80, 0xf1, 0x02, 0x16, 0x2a, 0xac, 0x87, 0x69, 0xd4, 0x83, 0xb3, 0x30, 0x2b, - 0x2d, 0xaa, 0x27, 0x22, 0x0e, 0x68, 0x15, 0x52, 0x6d, 0x21, 0x16, 0xce, 0x62, 0x79, 0x32, 0x9e, - 0xc3, 0x62, 0x08, 0x57, 0xe1, 0xde, 0x02, 0x3d, 0xa8, 0x2f, 0xcc, 0xfb, 0x1e, 0xb1, 0x15, 0x46, - 0xaa, 0x5a, 0x8a, 0xe8, 0x12, 0x62, 0xfc, 0x98, 0x80, 0x65, 0x11, 0xad, 0x86, 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0xaf, - 0x09, 0x6e, 0x4f, 0x54, 0x3b, 0x45, 0x3f, 0x68, 0xa6, 0x04, 0xe6, 0xd1, 0x3f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xc0, 0x92, 0xa7, 0x79, 0x2f, 0x11, 0x00, 0x00, + // 1563 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xcd, 0x6e, 0xdb, 0xc6, + 0x13, 0x0f, 0x65, 0x59, 0x76, 0x46, 0xb2, 0x4d, 0xaf, 0x1d, 0x5b, 0x51, 0x1c, 0xfc, 0xfd, 0x67, + 0x93, 0xc6, 0x36, 0x10, 0xc9, 0x56, 0x82, 0xa0, 0x4d, 0x90, 0x06, 0x92, 0xc5, 0xd8, 0x42, 0x02, + 0xd9, 0xa1, 0x14, 0x3b, 0x45, 0x0e, 0xc4, 0x4a, 0xda, 0x58, 0x44, 0x44, 0x2e, 0x4d, 0xae, 0x84, + 0xf8, 0x52, 0xa0, 0x97, 0x02, 0xbd, 0xb5, 0x87, 0x9e, 0x8b, 0x3e, 0x43, 0x0f, 0x7d, 0x85, 0x3e, + 0x44, 0x8f, 0x7d, 0x90, 0x82, 0xbb, 0x4b, 0x8a, 0xd6, 0x47, 0x2c, 0xe7, 0xc6, 0x9d, 0x99, 0xdf, + 0xcc, 0xec, 0xec, 0x7c, 0x49, 0xa0, 0xb9, 0x1e, 0x65, 0xb4, 0xd0, 0x24, 0xb8, 0x45, 0x9d, 0x82, + 0xe7, 0xb6, 0x0a, 0xfd, 0xbd, 0x82, 0x4f, 0xbc, 0xbe, 0xd5, 0x22, 0x7e, 0x9e, 0x33, 0xd1, 0x1a, + 0x61, 0x1d, 0xe2, 0x91, 0x9e, 0x9d, 0x17, 0x62, 0x79, 0xcf, 0x6d, 0xe5, 0xfb, 0x7b, 0xb9, 0x3b, + 0x67, 0x94, 0x9e, 0x75, 0x49, 0x81, 0x4b, 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x06, 0x15, 0x47, 0x4d, 0xc8, 0xe4, 0xa9, 0x29, 0xa3, 0xba, 0x34, 0xa0, 0xeb, + 0x01, 0x19, 0xbd, 0x80, 0x0d, 0xae, 0x20, 0x10, 0xb4, 0x1c, 0x33, 0x06, 0x3b, 0xef, 0x91, 0x9e, + 0x68, 0xde, 0x49, 0xe3, 0x76, 0x28, 0x53, 0x75, 0x06, 0xdd, 0xed, 0x4d, 0x20, 0xa0, 0x3d, 0x87, + 0x85, 0x0a, 0xb5, 0xb1, 0x15, 0xf5, 0xea, 0x55, 0x98, 0x15, 0x16, 0x65, 0x29, 0xf1, 0x03, 0x5a, + 0x83, 0x54, 0x9b, 0x8b, 0x85, 0x63, 0x5c, 0x9c, 0xb4, 0x67, 0xb0, 0x18, 0xc2, 0x65, 0xb8, 0xb7, + 0x41, 0x0d, 0xf2, 0x10, 0xb3, 0x9e, 0x47, 0x4c, 0x89, 0x11, 0xaa, 0x96, 0x22, 0xba, 0x80, 0x68, + 0xbf, 0x26, 0x60, 0x99, 0x47, 0xab, 0xe1, 0x91, 0xc1, 0x04, 0x7d, 0x09, 0x49, 0xe6, 0xc9, 0xbc, + 0x4d, 0x17, 0x8b, 0x93, 0x5e, 0x6b, 0x04, 0x98, 0x0f, 0x0e, 0x35, 0xda, 0x26, 0x06, 0xc7, 0xe7, + 0xfe, 0x54, 0x60, 0x3e, 0x24, 0xa1, 0x6f, 0x60, 0x96, 0x3f, 0x1b, 0x77, 0x25, 0x5d, 0xd4, 0x06, + 0x5a, 0x09, 0xeb, 0xe4, 0xc3, 0x7d, 0x2c, 0x5f, 0xe6, 0x26, 0xc4, 0x8a, 0x25, 0x00, 0x43, 0x6b, + 0x51, 0x62, 0x68, 0x2d, 0x0a, 0x06, 0xae, 0x8b, 0x3d, 0x66, 0xb5, 0x2c, 0x97, 0x0f, 0xa7, 0x3e, + 0x65, 0x24, 0x9c, 0xd1, 0xcb, 0x71, 0xce, 0x49, 0xc0, 0x08, 0x9a, 0x8b, 0x5c, 0x01, 0xb8, 0x9c, + 0x78, 0x55, 0x10, 0xd3, 0x3f, 0xa0, 0x68, 0xaf, 0x61, 0x35, 0x70, 0x9a, 0xbb, 0x10, 0x24, 0x43, + 0xf8, 0x2c, 0x77, 0xe0, 0x66, 0x90, 0x37, 0xe6, 0x07, 0x8f, 0xda, 0x32, 0x9e, 0xf3, 0x01, 0xe1, + 0xa5, 0x47, 0xed, 0x60, 0xcb, 0xe2, 0x4c, 0x46, 0x65, 0x3e, 0xa6, 0x82, 0x63, 0x83, 0xee, 0x94, + 0x61, 0x21, 0xca, 0x6a, 0x83, 0x76, 0x09, 0x4a, 0xc3, 0xdc, 0xdb, 0xda, 0xab, 0xda, 0xd1, 0x69, + 0x4d, 0xbd, 0x81, 0x32, 0x30, 0x5f, 0x6a, 0x34, 0xf4, 0x7a, 0x43, 0x37, 0x54, 0x25, 0x38, 0x1d, + 0x1b, 0x47, 0xc7, 0x47, 0x75, 0xdd, 0x50, 0x13, 0x68, 0x1e, 0x92, 0xe5, 0xa3, 0xc6, 0xa1, 0x3a, + 0xb3, 0xf3, 0x87, 0x02, 0x4b, 0x43, 0xa5, 0x81, 0x10, 0x2c, 0x4a, 0x35, 0x66, 0xbd, 0x51, 0x6a, + 0xbc, 0xad, 0xab, 0x37, 0xd0, 0x2a, 0xa8, 0x15, 0xfd, 0xf8, 0xa8, 0x5e, 0x6d, 0x98, 0x86, 0xbe, + 0xaf, 0x57, 0x4f, 0xf4, 0x8a, 0xaa, 0x04, 0x92, 0xc7, 0x7a, 0xad, 0x52, 0xad, 0x1d, 0x98, 0xa5, + 0xfd, 0x46, 0xf5, 0x44, 0x57, 0x13, 0x08, 0x20, 0x25, 0xbf, 0x67, 0x02, 0x7e, 0xb5, 0x56, 0x6d, + 0x54, 0x4b, 0x0d, 0xbd, 0x62, 0xea, 0xef, 0xaa, 0x0d, 0x35, 0x89, 0x54, 0xc8, 0x9c, 0x56, 0x1b, + 0x87, 0x15, 0xa3, 0x74, 0x5a, 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xdc, 0x85, 0x95, 0xfd, 0x70, 0x90, + 0xc7, 0x96, 0x82, 0xed, 0x69, 0x36, 0x10, 0x61, 0x71, 0x67, 0xfa, 0x65, 0x05, 0x9d, 0x8f, 0x76, + 0x87, 0x6b, 0xde, 0xef, 0xba, 0x3b, 0x31, 0xfa, 0x51, 0x81, 0xd5, 0x71, 0x3f, 0xc2, 0xd0, 0xd5, + 0x2f, 0x34, 0xfa, 0x3b, 0x30, 0xf7, 0xf8, 0x7a, 0x20, 0xe9, 0x43, 0x0f, 0xd4, 0xe1, 0x9d, 0x1a, + 0x4d, 0xbc, 0xc8, 0x84, 0xcd, 0x3d, 0xb7, 0x3b, 0x3d, 0x40, 0x9a, 0xfd, 0x3e, 0x4a, 0xe6, 0xc1, + 0x52, 0x8e, 0xd6, 0xf2, 0xe2, 0x4f, 0x83, 0x7c, 0xf8, 0xf7, 0x44, 0x5e, 0xb7, 0x5d, 0x76, 0x31, + 0xf9, 0x19, 0x47, 0x17, 0xfa, 0x5d, 0x05, 0xbd, 0x82, 0x85, 0x7d, 0xec, 0x50, 0xc7, 0x6a, 0xe1, + 0xee, 0x21, 0xc1, 0xed, 0x89, 0x6a, 0xa7, 0xe8, 0x07, 0xcd, 0x14, 0xc7, 0x3c, 0xfa, 0x2f, 0x00, + 0x00, 0xff, 0xff, 0x9f, 0x74, 0xae, 0xcd, 0x75, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/_compatibility/compatability_test.go b/proto/eth/v1alpha1/_compatibility/compatability_test.go index 4e0e3f81a8..2cadc6e5c7 100644 --- a/proto/eth/v1alpha1/_compatibility/compatability_test.go +++ b/proto/eth/v1alpha1/_compatibility/compatability_test.go @@ -29,10 +29,6 @@ func TestProtoCompatability(t *testing.T) { a: &pb.Checkpoint{}, b: &upstreampb.Checkpoint{}, }, - { - a: &pb.Crosslink{}, - b: &upstreampb.Crosslink{}, - }, // beacon_block.proto { a: &pb.BeaconBlock{}, @@ -62,10 +58,6 @@ func TestProtoCompatability(t *testing.T) { a: &pb.VoluntaryExit{}, b: &upstreampb.VoluntaryExit{}, }, - { - a: &pb.Transfer{}, - b: &upstreampb.Transfer{}, - }, { a: &pb.Eth1Data{}, b: &upstreampb.Eth1Data{}, diff --git a/proto/eth/v1alpha1/archive.pb.go b/proto/eth/v1alpha1/archive.pb.go index be11ffceb6..649abc7b8f 100755 --- a/proto/eth/v1alpha1/archive.pb.go +++ b/proto/eth/v1alpha1/archive.pb.go @@ -111,10 +111,9 @@ func (m *ArchivedActiveSetChanges) GetAttesterSlashings() []*AttesterSlashing { } type ArchivedCommitteeInfo struct { - Seed []byte `protobuf:"bytes,1,opt,name=seed,proto3" json:"seed,omitempty" ssz-size:"32"` - StartShard uint64 `protobuf:"varint,2,opt,name=start_shard,json=startShard,proto3" json:"start_shard,omitempty"` + ProposerSeed []byte `protobuf:"bytes,1,opt,name=proposer_seed,json=proposerSeed,proto3" json:"proposer_seed,omitempty" ssz-size:"32"` + AttesterSeed []byte `protobuf:"bytes,2,opt,name=attester_seed,json=attesterSeed,proto3" json:"attester_seed,omitempty" ssz-size:"32"` CommitteeCount uint64 `protobuf:"varint,3,opt,name=committee_count,json=committeeCount,proto3" json:"committee_count,omitempty"` - ProposerIndex uint64 `protobuf:"varint,4,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -153,18 +152,18 @@ func (m *ArchivedCommitteeInfo) XXX_DiscardUnknown() { var xxx_messageInfo_ArchivedCommitteeInfo proto.InternalMessageInfo -func (m *ArchivedCommitteeInfo) GetSeed() []byte { +func (m *ArchivedCommitteeInfo) GetProposerSeed() []byte { if m != nil { - return m.Seed + return m.ProposerSeed } return nil } -func (m *ArchivedCommitteeInfo) GetStartShard() uint64 { +func (m *ArchivedCommitteeInfo) GetAttesterSeed() []byte { if m != nil { - return m.StartShard + return m.AttesterSeed } - return 0 + return nil } func (m *ArchivedCommitteeInfo) GetCommitteeCount() uint64 { @@ -174,13 +173,6 @@ func (m *ArchivedCommitteeInfo) GetCommitteeCount() uint64 { return 0 } -func (m *ArchivedCommitteeInfo) GetProposerIndex() uint64 { - if m != nil { - return m.ProposerIndex - } - return 0 -} - func init() { proto.RegisterType((*ArchivedActiveSetChanges)(nil), "ethereum.eth.v1alpha1.ArchivedActiveSetChanges") proto.RegisterType((*ArchivedCommitteeInfo)(nil), "ethereum.eth.v1alpha1.ArchivedCommitteeInfo") @@ -189,35 +181,34 @@ func init() { func init() { proto.RegisterFile("proto/eth/v1alpha1/archive.proto", fileDescriptor_afd178f87193e24d) } var fileDescriptor_afd178f87193e24d = []byte{ - // 442 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x6a, 0xdb, 0x40, - 0x10, 0x86, 0x51, 0x2c, 0x9c, 0x76, 0xd3, 0x38, 0x64, 0x21, 0x45, 0x84, 0xe2, 0x18, 0x53, 0x13, - 0x5f, 0x22, 0x91, 0x84, 0x5e, 0xda, 0x93, 0x63, 0x7a, 0xc8, 0xa1, 0x50, 0x64, 0xc8, 0xa1, 0x17, - 0xb1, 0x92, 0x27, 0xda, 0xa5, 0x92, 0x56, 0xec, 0x8c, 0x84, 0x93, 0x97, 0xea, 0x6b, 0xf4, 0xd8, - 0x27, 0x28, 0xc5, 0xb7, 0x5e, 0xfb, 0x04, 0x45, 0x2b, 0x2b, 0x49, 0xd3, 0xb4, 0x37, 0xfd, 0xdf, - 0xff, 0xef, 0x3f, 0x68, 0x18, 0x36, 0x2a, 0x8d, 0x26, 0x1d, 0x00, 0xc9, 0xa0, 0x3e, 0x15, 0x59, - 0x29, 0xc5, 0x69, 0x20, 0x4c, 0x22, 0x55, 0x0d, 0xbe, 0xb5, 0xf8, 0x01, 0x90, 0x04, 0x03, 0x55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0x47, 0x04, 0xc7, 0x5f, 0x1c, 0x76, 0xd0, 0xed, 0x7a, 0xae, 0xf3, 0x5c, - 0x11, 0x01, 0x5c, 0x16, 0xd7, 0x9a, 0x4f, 0x98, 0x8b, 0x60, 0x77, 0xec, 0x4c, 0x5f, 0x5c, 0xec, - 0xff, 0xfa, 0x7e, 0xb4, 0x8b, 0x78, 0x7b, 0x82, 0xea, 0x16, 0xde, 0x8e, 0xcf, 0xcf, 0xc6, 0xa1, - 0xb5, 0xf9, 0x11, 0xdb, 0x41, 0x12, 0x86, 0x22, 0x94, 0xc2, 0x34, 0x6b, 0x77, 0xa6, 0x6e, 0xc8, - 0x2c, 0x5a, 0x34, 0x84, 0x1f, 0xb3, 0xbd, 0xa4, 0x2b, 0x8e, 0x12, 0x5d, 0x15, 0xe4, 0xf5, 0x6c, - 0x68, 0x70, 0x87, 0xe7, 0x0d, 0xe5, 0x13, 0x36, 0xb8, 0x5b, 0x9d, 0x2a, 0x96, 0xb0, 0xf2, 0x5c, - 0x9b, 0xdb, 0xed, 0xe8, 0x65, 0x03, 0x2f, 0xe6, 0x5f, 0xd7, 0x43, 0xe7, 0xdb, 0x7a, 0xe8, 0xfc, - 0x58, 0x0f, 0x9d, 0x4f, 0x6f, 0x1e, 0x5c, 0x60, 0x69, 0x6e, 0x30, 0x17, 0xa4, 0x92, 0x4c, 0xc4, - 0xd8, 0xaa, 0xe0, 0xef, 0x8b, 0x7b, 0x07, 0x24, 0xe3, 0xbe, 0xe5, 0xe7, 0xbf, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x82, 0x1f, 0xa7, 0x3d, 0xfa, 0x02, 0x00, 0x00, + // 426 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xcd, 0x6a, 0xd5, 0x40, + 0x18, 0x25, 0xbd, 0x97, 0x5b, 0x1d, 0xfb, 0x43, 0x07, 0x2a, 0xa1, 0x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b7, 0x9e, 0x60, 0x59, 0x5d, 0xeb, 0x9c, 0xa1, 0xe4, 0x19, 0x8b, + 0x75, 0x87, 0xfc, 0xff, 0x9f, 0xdc, 0x7b, 0x40, 0x11, 0xcf, 0x0c, 0x7f, 0xfa, 0x37, 0x00, 0x00, + 0xff, 0xff, 0x10, 0x2a, 0xd9, 0xca, 0xfb, 0x02, 0x00, 0x00, } func (m *ArchivedActiveSetChanges) Marshal() (dAtA []byte, err error) { @@ -343,27 +334,23 @@ func (m *ArchivedCommitteeInfo) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Seed) > 0 { + if len(m.ProposerSeed) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintArchive(dAtA, i, uint64(len(m.Seed))) - i += copy(dAtA[i:], m.Seed) + i = encodeVarintArchive(dAtA, i, uint64(len(m.ProposerSeed))) + i += copy(dAtA[i:], m.ProposerSeed) } - if m.StartShard != 0 { - dAtA[i] = 0x10 + if len(m.AttesterSeed) > 0 { + dAtA[i] = 0x12 i++ - i = encodeVarintArchive(dAtA, i, uint64(m.StartShard)) + i = encodeVarintArchive(dAtA, i, uint64(len(m.AttesterSeed))) + i += copy(dAtA[i:], m.AttesterSeed) } if m.CommitteeCount != 0 { dAtA[i] = 0x18 i++ i = encodeVarintArchive(dAtA, i, uint64(m.CommitteeCount)) } - if m.ProposerIndex != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintArchive(dAtA, i, uint64(m.ProposerIndex)) - } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -436,19 +423,17 @@ func (m *ArchivedCommitteeInfo) Size() (n int) { } var l int _ = l - l = len(m.Seed) + l = len(m.ProposerSeed) if l > 0 { n += 1 + l + sovArchive(uint64(l)) } - if m.StartShard != 0 { - n += 1 + sovArchive(uint64(m.StartShard)) + l = len(m.AttesterSeed) + if l > 0 { + n += 1 + l + sovArchive(uint64(l)) } if m.CommitteeCount != 0 { n += 1 + sovArchive(uint64(m.CommitteeCount)) } - if m.ProposerIndex != 0 { - n += 1 + sovArchive(uint64(m.ProposerIndex)) - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -883,7 +868,7 @@ func (m *ArchivedCommitteeInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProposerSeed", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -910,16 +895,16 @@ func (m *ArchivedCommitteeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Seed = append(m.Seed[:0], dAtA[iNdEx:postIndex]...) - if m.Seed == nil { - m.Seed = []byte{} + m.ProposerSeed = append(m.ProposerSeed[:0], dAtA[iNdEx:postIndex]...) + if m.ProposerSeed == nil { + m.ProposerSeed = []byte{} } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartShard", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AttesterSeed", wireType) } - m.StartShard = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowArchive @@ -929,11 +914,26 @@ func (m *ArchivedCommitteeInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartShard |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthArchive + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthArchive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AttesterSeed = append(m.AttesterSeed[:0], dAtA[iNdEx:postIndex]...) + if m.AttesterSeed == nil { + m.AttesterSeed = []byte{} + } + iNdEx = postIndex case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CommitteeCount", wireType) @@ -953,25 +953,6 @@ func (m *ArchivedCommitteeInfo) Unmarshal(dAtA []byte) error { break } } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposerIndex", wireType) - } - m.ProposerIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowArchive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProposerIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipArchive(dAtA[iNdEx:]) diff --git a/proto/eth/v1alpha1/archive.proto b/proto/eth/v1alpha1/archive.proto index 3a4e2c98e2..8699a86e33 100644 --- a/proto/eth/v1alpha1/archive.proto +++ b/proto/eth/v1alpha1/archive.proto @@ -37,15 +37,12 @@ message ArchivedActiveSetChanges { // ArchivedCommitteeInfo representing the minimal data required to reconstruct // validator committee assignments for an epoch N. message ArchivedCommitteeInfo { - // Seed represents the random seed used in shuffling validators. - bytes seed = 1 [(gogoproto.moretags) = "ssz-size:\"32\""]; + // Proposer seed represents the random seed used in shuffling proposers. + bytes proposer_seed = 1 [(gogoproto.moretags) = "ssz-size:\"32\""]; - // Start shard for the shuffling at epoch N. - uint64 start_shard = 2; + // Attester seed represents the random seed used in shuffling attesters. + bytes attester_seed = 2 [(gogoproto.moretags) = "ssz-size:\"32\""]; // Committee count is the size the committees during epoch N. uint64 committee_count = 3; - - // Proposer index assigned to propose a beacon block during epoch N. - uint64 proposer_index = 4; } diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index 223405f1eb..008971640b 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -25,9 +25,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package type Attestation struct { - AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"aggregation_bits,omitempty" ssz-max:"4096"` + AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"aggregation_bits,omitempty" ssz-max:"2048"` Data *AttestationData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - CustodyBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,3,opt,name=custody_bits,json=custodyBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"custody_bits,omitempty" ssz-max:"4096"` + CustodyBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,3,opt,name=custody_bits,json=custodyBits,proto3,casttype=github.com/prysmaticlabs/go-bitfield.Bitlist" json:"custody_bits,omitempty" ssz-max:"2048"` Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -96,10 +96,11 @@ func (m *Attestation) GetSignature() []byte { } type AttestationData struct { - BeaconBlockRoot []byte `protobuf:"bytes,1,opt,name=beacon_block_root,json=beaconBlockRoot,proto3" json:"beacon_block_root,omitempty" ssz-size:"32"` - Source *Checkpoint `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` - Target *Checkpoint `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"` - Crosslink *Crosslink `protobuf:"bytes,4,opt,name=crosslink,proto3" json:"crosslink,omitempty"` + Slot uint64 `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + BeaconBlockRoot []byte `protobuf:"bytes,3,opt,name=beacon_block_root,json=beaconBlockRoot,proto3" json:"beacon_block_root,omitempty" ssz-size:"32"` + Source *Checkpoint `protobuf:"bytes,4,opt,name=source,proto3" json:"source,omitempty"` + Target *Checkpoint `protobuf:"bytes,5,opt,name=target,proto3" json:"target,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -138,6 +139,20 @@ func (m *AttestationData) XXX_DiscardUnknown() { var xxx_messageInfo_AttestationData proto.InternalMessageInfo +func (m *AttestationData) GetSlot() uint64 { + if m != nil { + return m.Slot + } + return 0 +} + +func (m *AttestationData) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + func (m *AttestationData) GetBeaconBlockRoot() []byte { if m != nil { return m.BeaconBlockRoot @@ -159,13 +174,6 @@ func (m *AttestationData) GetTarget() *Checkpoint { return nil } -func (m *AttestationData) GetCrosslink() *Crosslink { - if m != nil { - return m.Crosslink - } - return nil -} - type Checkpoint struct { Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` Root []byte `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty" ssz-size:"32"` @@ -221,90 +229,10 @@ func (m *Checkpoint) GetRoot() []byte { return nil } -type Crosslink struct { - Shard uint64 `protobuf:"varint,1,opt,name=shard,proto3" json:"shard,omitempty"` - ParentRoot []byte `protobuf:"bytes,2,opt,name=parent_root,json=parentRoot,proto3" json:"parent_root,omitempty" ssz-size:"32"` - StartEpoch uint64 `protobuf:"varint,3,opt,name=start_epoch,json=startEpoch,proto3" json:"start_epoch,omitempty"` - EndEpoch uint64 `protobuf:"varint,4,opt,name=end_epoch,json=endEpoch,proto3" json:"end_epoch,omitempty"` - DataRoot []byte `protobuf:"bytes,5,opt,name=data_root,json=dataRoot,proto3" json:"data_root,omitempty" ssz-size:"32"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Crosslink) Reset() { *m = Crosslink{} } -func (m *Crosslink) String() string { return proto.CompactTextString(m) } -func (*Crosslink) ProtoMessage() {} -func (*Crosslink) Descriptor() ([]byte, []int) { - return fileDescriptor_f8f395ba51cd84e0, []int{3} -} -func (m *Crosslink) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Crosslink) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Crosslink.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalTo(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Crosslink) XXX_Merge(src proto.Message) { - xxx_messageInfo_Crosslink.Merge(m, src) -} -func (m *Crosslink) XXX_Size() int { - return m.Size() -} -func (m *Crosslink) XXX_DiscardUnknown() { - xxx_messageInfo_Crosslink.DiscardUnknown(m) -} - -var xxx_messageInfo_Crosslink proto.InternalMessageInfo - -func (m *Crosslink) GetShard() uint64 { - if m != nil { - return m.Shard - } - return 0 -} - -func (m *Crosslink) GetParentRoot() []byte { - if m != nil { - return m.ParentRoot - } - return nil -} - -func (m *Crosslink) GetStartEpoch() uint64 { - if m != nil { - return m.StartEpoch - } - return 0 -} - -func (m *Crosslink) GetEndEpoch() uint64 { - if m != nil { - return m.EndEpoch - } - return 0 -} - -func (m *Crosslink) GetDataRoot() []byte { - if m != nil { - return m.DataRoot - } - return nil -} - func init() { proto.RegisterType((*Attestation)(nil), "ethereum.eth.v1alpha1.Attestation") proto.RegisterType((*AttestationData)(nil), "ethereum.eth.v1alpha1.AttestationData") proto.RegisterType((*Checkpoint)(nil), "ethereum.eth.v1alpha1.Checkpoint") - proto.RegisterType((*Crosslink)(nil), "ethereum.eth.v1alpha1.Crosslink") } func init() { @@ -312,40 +240,35 @@ func init() { } var fileDescriptor_f8f395ba51cd84e0 = []byte{ - // 519 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0x96, 0xd3, 0xb4, 0x6a, 0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, 0xec, 0xf2, 0x52, 0xc6, 0x19, 0x5d, 0xbb, 0x19, 0x9a, 0xc1, 0x79, 0x0a, 0x4d, 0xea, - 0xa2, 0xb1, 0xad, 0x0b, 0x5a, 0xbb, 0xdf, 0x2c, 0x68, 0xfd, 0xf6, 0xa8, 0xa5, 0x74, 0xc6, 0x54, - 0xb2, 0x92, 0xa2, 0xc1, 0x19, 0x82, 0x5d, 0x32, 0xc5, 0x0b, 0x9c, 0xfc, 0x5b, 0x11, 0x0c, 0x8a, - 0x8a, 0xed, 0x81, 0xad, 0x91, 0x29, 0x9c, 0x98, 0x68, 0x3b, 0xa4, 0x07, 0x74, 0xf4, 0x81, 0xf2, - 0x3d, 0x82, 0x16, 0x2f, 0x92, 0xe5, 0xba, 0x49, 0xeb, 0x7d, 0x5e, 0x24, 0x66, 0xe9, 0x41, 0xab, - 0x7e, 0x89, 0xc6, 0x6f, 0x77, 0x9b, 0xdf, 0x7e, 0x8d, 0xa9, 0xdd, 0x82, 0xb3, 0xef, 0x8b, 0xae, - 0x75, 0xb5, 0xe8, 0x5a, 0x3f, 0x16, 0x5d, 0xeb, 0xd3, 0xab, 0xad, 0x6f, 0x92, 0x26, 0xff, 0xcf, - 0xbf, 0xc0, 0x6b, 0x8e, 0x59, 0xb4, 0x47, 0xe7, 0x27, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9e, - 0x9d, 0x31, 0x67, 0x26, 0x04, 0x00, 0x00, + // 444 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x14, 0x94, 0x83, 0x5b, 0x89, 0x4d, 0x21, 0x74, 0x05, 0x52, 0xc4, 0x21, 0x29, 0x16, 0xa0, 0x1e, + 0x88, 0x4d, 0x53, 0x40, 0x34, 0x88, 0x03, 0x2e, 0x17, 0xae, 0x3e, 0x72, 0xa9, 0xd6, 0xce, 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0x04, 0x3f, 0x16, 0x83, 0xe0, 0xeb, 0xdb, 0xad, + 0xdf, 0xcd, 0xa1, 0xe4, 0xef, 0x3f, 0xe5, 0x03, 0x90, 0xca, 0x77, 0xdd, 0xfd, 0xf1, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xce, 0x07, 0xca, 0x37, 0x4a, 0x03, 0x00, 0x00, } func (m *Attestation) Marshal() (dAtA []byte, err error) { @@ -412,14 +335,24 @@ func (m *AttestationData) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Slot != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintAttestation(dAtA, i, uint64(m.Slot)) + } + if m.Index != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintAttestation(dAtA, i, uint64(m.Index)) + } if len(m.BeaconBlockRoot) > 0 { - dAtA[i] = 0xa + dAtA[i] = 0x1a i++ i = encodeVarintAttestation(dAtA, i, uint64(len(m.BeaconBlockRoot))) i += copy(dAtA[i:], m.BeaconBlockRoot) } if m.Source != nil { - dAtA[i] = 0x12 + dAtA[i] = 0x22 i++ i = encodeVarintAttestation(dAtA, i, uint64(m.Source.Size())) n2, err := m.Source.MarshalTo(dAtA[i:]) @@ -429,7 +362,7 @@ func (m *AttestationData) MarshalTo(dAtA []byte) (int, error) { i += n2 } if m.Target != nil { - dAtA[i] = 0x1a + dAtA[i] = 0x2a i++ i = encodeVarintAttestation(dAtA, i, uint64(m.Target.Size())) n3, err := m.Target.MarshalTo(dAtA[i:]) @@ -438,16 +371,6 @@ func (m *AttestationData) MarshalTo(dAtA []byte) (int, error) { } i += n3 } - if m.Crosslink != nil { - dAtA[i] = 0x22 - i++ - i = encodeVarintAttestation(dAtA, i, uint64(m.Crosslink.Size())) - n4, err := m.Crosslink.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n4 - } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -486,54 +409,6 @@ func (m *Checkpoint) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Crosslink) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Crosslink) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Shard != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintAttestation(dAtA, i, uint64(m.Shard)) - } - if len(m.ParentRoot) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintAttestation(dAtA, i, uint64(len(m.ParentRoot))) - i += copy(dAtA[i:], m.ParentRoot) - } - if m.StartEpoch != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintAttestation(dAtA, i, uint64(m.StartEpoch)) - } - if m.EndEpoch != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintAttestation(dAtA, i, uint64(m.EndEpoch)) - } - if len(m.DataRoot) > 0 { - dAtA[i] = 0x2a - i++ - i = encodeVarintAttestation(dAtA, i, uint64(len(m.DataRoot))) - i += copy(dAtA[i:], m.DataRoot) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil -} - func encodeVarintAttestation(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -577,6 +452,12 @@ func (m *AttestationData) Size() (n int) { } var l int _ = l + if m.Slot != 0 { + n += 1 + sovAttestation(uint64(m.Slot)) + } + if m.Index != 0 { + n += 1 + sovAttestation(uint64(m.Index)) + } l = len(m.BeaconBlockRoot) if l > 0 { n += 1 + l + sovAttestation(uint64(l)) @@ -589,10 +470,6 @@ func (m *AttestationData) Size() (n int) { l = m.Target.Size() n += 1 + l + sovAttestation(uint64(l)) } - if m.Crosslink != nil { - l = m.Crosslink.Size() - n += 1 + l + sovAttestation(uint64(l)) - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -618,35 +495,6 @@ func (m *Checkpoint) Size() (n int) { return n } -func (m *Crosslink) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Shard != 0 { - n += 1 + sovAttestation(uint64(m.Shard)) - } - l = len(m.ParentRoot) - if l > 0 { - n += 1 + l + sovAttestation(uint64(l)) - } - if m.StartEpoch != 0 { - n += 1 + sovAttestation(uint64(m.StartEpoch)) - } - if m.EndEpoch != 0 { - n += 1 + sovAttestation(uint64(m.EndEpoch)) - } - l = len(m.DataRoot) - if l > 0 { - n += 1 + l + sovAttestation(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - func sovAttestation(x uint64) (n int) { for { n++ @@ -882,6 +730,44 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Slot", wireType) + } + m.Slot = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAttestation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Slot |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAttestation + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BeaconBlockRoot", wireType) } @@ -915,7 +801,7 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { m.BeaconBlockRoot = []byte{} } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) } @@ -951,7 +837,7 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) } @@ -987,42 +873,6 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Crosslink", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAttestation - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAttestation - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Crosslink == nil { - m.Crosslink = &Crosslink{} - } - if err := m.Crosslink.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAttestation(dAtA[iNdEx:]) @@ -1155,185 +1005,6 @@ func (m *Checkpoint) Unmarshal(dAtA []byte) error { } return nil } -func (m *Crosslink) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Crosslink: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Crosslink: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Shard", wireType) - } - m.Shard = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Shard |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ParentRoot", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAttestation - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAttestation - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ParentRoot = append(m.ParentRoot[:0], dAtA[iNdEx:postIndex]...) - if m.ParentRoot == nil { - m.ParentRoot = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartEpoch", wireType) - } - m.StartEpoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartEpoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EndEpoch", wireType) - } - m.EndEpoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EndEpoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataRoot", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAttestation - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAttestation - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAttestation - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataRoot = append(m.DataRoot[:0], dAtA[iNdEx:postIndex]...) - if m.DataRoot == nil { - m.DataRoot = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAttestation(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthAttestation - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthAttestation - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipAttestation(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/eth/v1alpha1/attestation.proto b/proto/eth/v1alpha1/attestation.proto index b53a074c32..a553b0e922 100644 --- a/proto/eth/v1alpha1/attestation.proto +++ b/proto/eth/v1alpha1/attestation.proto @@ -10,36 +10,39 @@ message Attestation { // A bitfield representation of validator indices that have voted exactly // the same vote and have been aggregated into this attestation. // Spec type: Bitlist[N] - bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"4096\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; + bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"2048\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; AttestationData data = 2; // Not used in phase 0. - bytes custody_bits = 3 [(gogoproto.moretags) = "ssz-max:\"4096\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; + bytes custody_bits = 3 [(gogoproto.moretags) = "ssz-max:\"2048\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"]; // 96 byte BLS aggregate signature. bytes signature = 4 [(gogoproto.moretags) = "ssz-size:\"96\""]; } message AttestationData { + // Slot of the attestation for. + uint64 slot = 1; + + // Committee index voted this attestation. + uint64 index = 2; + // Attestation data includes information on Casper the Friendly Finality Gadget's votes // See: https://arxiv.org/pdf/1710.09437.pdf // 32 byte root of the LMD GHOST block vote. - bytes beacon_block_root = 1 [(gogoproto.moretags) = "ssz-size:\"32\""]; + bytes beacon_block_root = 3 [(gogoproto.moretags) = "ssz-size:\"32\""]; // Source contains information relating to the recent justified epoch // as well as the 32 byte root of the epoch boundary block at the // source epoch. - Checkpoint source = 2; + Checkpoint source = 4; // Target contains information relating to the epoch the attestation // is targeting as well as the 32 byte root of the epoch boundary // block at the source epoch. - Checkpoint target = 3; - - // Crosslink voted by this attestation. - Crosslink crosslink = 4; + Checkpoint target = 5; } message Checkpoint { @@ -51,22 +54,3 @@ message Checkpoint { // block root of the check point reference to. bytes root = 2 [(gogoproto.moretags) = "ssz-size:\"32\""]; } - -message Crosslink { - // The shard that crosslinks to the beacon chain. - uint64 shard = 1; - - // 32 byte root of the parent crosslink. - bytes parent_root = 2 [(gogoproto.moretags) = "ssz-size:\"32\""]; - - // Start epoch must match the parent crosslink's end epoch. - uint64 start_epoch = 3; - - // Ending epoch for this crosslink period. This field matches the attestation - // target epoch or the start epoch + MAX_EPOCHS_PER_CROSSLINK, whichever is - // less. - uint64 end_epoch = 4; - - // 32 byte root of the crosslinked shard data since the previous crosslink. - bytes data_root = 5 [(gogoproto.moretags) = "ssz-size:\"32\""]; -} diff --git a/proto/eth/v1alpha1/beacon_block.pb.go b/proto/eth/v1alpha1/beacon_block.pb.go index fe053f245c..552ea64b0f 100755 --- a/proto/eth/v1alpha1/beacon_block.pb.go +++ b/proto/eth/v1alpha1/beacon_block.pb.go @@ -111,7 +111,6 @@ type BeaconBlockBody struct { Attestations []*Attestation `protobuf:"bytes,6,rep,name=attestations,proto3" json:"attestations,omitempty" ssz-max:"128"` Deposits []*Deposit `protobuf:"bytes,7,rep,name=deposits,proto3" json:"deposits,omitempty" ssz-max:"16"` VoluntaryExits []*VoluntaryExit `protobuf:"bytes,8,rep,name=voluntary_exits,json=voluntaryExits,proto3" json:"voluntary_exits,omitempty" ssz-max:"16"` - Transfers []*Transfer `protobuf:"bytes,9,rep,name=transfers,proto3" json:"transfers,omitempty" ssz-max:"0"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -206,13 +205,6 @@ func (m *BeaconBlockBody) GetVoluntaryExits() []*VoluntaryExit { return nil } -func (m *BeaconBlockBody) GetTransfers() []*Transfer { - if m != nil { - return m.Transfers - } - return nil -} - type ProposerSlashing struct { ProposerIndex uint64 `protobuf:"varint,1,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty"` Header_1 *BeaconBlockHeader `protobuf:"bytes,2,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty"` @@ -520,101 +512,6 @@ func (m *VoluntaryExit) GetSignature() []byte { return nil } -type Transfer struct { - SenderIndex uint64 `protobuf:"varint,1,opt,name=sender_index,json=senderIndex,proto3" json:"sender_index,omitempty" spec-name:"sender"` - RecipientIndex uint64 `protobuf:"varint,2,opt,name=recipient_index,json=recipientIndex,proto3" json:"recipient_index,omitempty" spec-name:"recipient"` - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` - Fee uint64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"` - Slot uint64 `protobuf:"varint,5,opt,name=slot,proto3" json:"slot,omitempty"` - SenderWithdrawalPublicKey []byte `protobuf:"bytes,6,opt,name=sender_withdrawal_public_key,json=senderWithdrawalPublicKey,proto3" json:"sender_withdrawal_public_key,omitempty" ssz-size:"48" spec-name:"pubkey"` - Signature []byte `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Transfer) Reset() { *m = Transfer{} } -func (m *Transfer) String() string { return proto.CompactTextString(m) } -func (*Transfer) ProtoMessage() {} -func (*Transfer) Descriptor() ([]byte, []int) { - return fileDescriptor_9369dd0265944233, []int{6} -} -func (m *Transfer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Transfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Transfer.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalTo(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Transfer) XXX_Merge(src proto.Message) { - xxx_messageInfo_Transfer.Merge(m, src) -} -func (m *Transfer) XXX_Size() int { - return m.Size() -} -func (m *Transfer) XXX_DiscardUnknown() { - xxx_messageInfo_Transfer.DiscardUnknown(m) -} - -var xxx_messageInfo_Transfer proto.InternalMessageInfo - -func (m *Transfer) GetSenderIndex() uint64 { - if m != nil { - return m.SenderIndex - } - return 0 -} - -func (m *Transfer) GetRecipientIndex() uint64 { - if m != nil { - return m.RecipientIndex - } - return 0 -} - -func (m *Transfer) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - -func (m *Transfer) GetFee() uint64 { - if m != nil { - return m.Fee - } - return 0 -} - -func (m *Transfer) GetSlot() uint64 { - if m != nil { - return m.Slot - } - return 0 -} - -func (m *Transfer) GetSenderWithdrawalPublicKey() []byte { - if m != nil { - return m.SenderWithdrawalPublicKey - } - return nil -} - -func (m *Transfer) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - type Eth1Data struct { DepositRoot []byte `protobuf:"bytes,1,opt,name=deposit_root,json=depositRoot,proto3" json:"deposit_root,omitempty" ssz-size:"32"` DepositCount uint64 `protobuf:"varint,2,opt,name=deposit_count,json=depositCount,proto3" json:"deposit_count,omitempty"` @@ -628,7 +525,7 @@ func (m *Eth1Data) Reset() { *m = Eth1Data{} } func (m *Eth1Data) String() string { return proto.CompactTextString(m) } func (*Eth1Data) ProtoMessage() {} func (*Eth1Data) Descriptor() ([]byte, []int) { - return fileDescriptor_9369dd0265944233, []int{7} + return fileDescriptor_9369dd0265944233, []int{6} } func (m *Eth1Data) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -693,7 +590,7 @@ func (m *BeaconBlockHeader) Reset() { *m = BeaconBlockHeader{} } func (m *BeaconBlockHeader) String() string { return proto.CompactTextString(m) } func (*BeaconBlockHeader) ProtoMessage() {} func (*BeaconBlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_9369dd0265944233, []int{8} + return fileDescriptor_9369dd0265944233, []int{7} } func (m *BeaconBlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -758,8 +655,8 @@ func (m *BeaconBlockHeader) GetSignature() []byte { } type IndexedAttestation struct { - CustodyBit_0Indices []uint64 `protobuf:"varint,1,rep,packed,name=custody_bit_0_indices,json=custodyBit0Indices,proto3" json:"custody_bit_0_indices,omitempty" ssz-max:"4096"` - CustodyBit_1Indices []uint64 `protobuf:"varint,2,rep,packed,name=custody_bit_1_indices,json=custodyBit1Indices,proto3" json:"custody_bit_1_indices,omitempty" ssz-max:"4096"` + CustodyBit_0Indices []uint64 `protobuf:"varint,1,rep,packed,name=custody_bit_0_indices,json=custodyBit0Indices,proto3" json:"custody_bit_0_indices,omitempty" ssz-max:"2048"` + CustodyBit_1Indices []uint64 `protobuf:"varint,2,rep,packed,name=custody_bit_1_indices,json=custodyBit1Indices,proto3" json:"custody_bit_1_indices,omitempty" ssz-max:"2048"` Data *AttestationData `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -771,7 +668,7 @@ func (m *IndexedAttestation) Reset() { *m = IndexedAttestation{} } func (m *IndexedAttestation) String() string { return proto.CompactTextString(m) } func (*IndexedAttestation) ProtoMessage() {} func (*IndexedAttestation) Descriptor() ([]byte, []int) { - return fileDescriptor_9369dd0265944233, []int{9} + return fileDescriptor_9369dd0265944233, []int{8} } func (m *IndexedAttestation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -836,7 +733,6 @@ func init() { proto.RegisterType((*Deposit)(nil), "ethereum.eth.v1alpha1.Deposit") proto.RegisterType((*Deposit_Data)(nil), "ethereum.eth.v1alpha1.Deposit.Data") proto.RegisterType((*VoluntaryExit)(nil), "ethereum.eth.v1alpha1.VoluntaryExit") - proto.RegisterType((*Transfer)(nil), "ethereum.eth.v1alpha1.Transfer") proto.RegisterType((*Eth1Data)(nil), "ethereum.eth.v1alpha1.Eth1Data") proto.RegisterType((*BeaconBlockHeader)(nil), "ethereum.eth.v1alpha1.BeaconBlockHeader") proto.RegisterType((*IndexedAttestation)(nil), "ethereum.eth.v1alpha1.IndexedAttestation") @@ -847,77 +743,69 @@ func init() { } var fileDescriptor_9369dd0265944233 = []byte{ - // 1117 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xdd, 0x6e, 0xe3, 0x44, - 0x14, 0x96, 0x13, 0xa7, 0x4d, 0x4e, 0x92, 0xfe, 0x8c, 0xb6, 0xab, 0x6c, 0x85, 0x9a, 0xc8, 0xdb, - 0x65, 0x03, 0xa2, 0xf9, 0x6b, 0x29, 0xbb, 0x85, 0x1b, 0xdc, 0xad, 0xd4, 0x15, 0x68, 0xb5, 0x32, - 0x08, 0x04, 0x37, 0xd6, 0xc4, 0x9e, 0xc4, 0x56, 0x13, 0x8f, 0xe5, 0x99, 0x74, 0x9b, 0xbd, 0xe1, - 0x11, 0xb8, 0xe4, 0x3d, 0x78, 0x05, 0x6e, 0xb8, 0x83, 0x27, 0x08, 0xa8, 0xdc, 0x73, 0x11, 0xf1, - 0x00, 0xc8, 0x33, 0x8e, 0xe3, 0xa4, 0x71, 0x69, 0xf7, 0x86, 0xbb, 0xb1, 0xfd, 0x9d, 0xef, 0x3b, - 0x3e, 0xf3, 0xcd, 0x99, 0x03, 0x4f, 0xfc, 0x80, 0x72, 0xda, 0x24, 0xdc, 0x69, 0x5e, 0xb6, 0xf1, - 0xc0, 0x77, 0x70, 0xbb, 0xd9, 0x25, 0xd8, 0xa2, 0x9e, 0xd9, 0x1d, 0x50, 0xeb, 0xa2, 0x21, 0xbe, - 0xa3, 0x1d, 0xc2, 0x1d, 0x12, 0x90, 0xd1, 0xb0, 0x41, 0xb8, 0xd3, 0x98, 0x21, 0x77, 0x0f, 0xfa, - 0x2e, 0x77, 0x46, 0xdd, 0x86, 0x45, 0x87, 0xcd, 0x3e, 0xed, 0xd3, 0xa6, 0x40, 0x77, 0x47, 0x3d, - 0xf1, 0x24, 0xa9, 0xc3, 0x95, 0x64, 0xd9, 0xdd, 0x5f, 0x21, 0x86, 0x39, 0x27, 0x8c, 0x63, 0xee, - 0x52, 0x4f, 0xa2, 0xb4, 0x7f, 0x14, 0x28, 0xea, 0x22, 0x05, 0x3d, 0xcc, 0x00, 0x21, 0x50, 0xd9, - 0x80, 0xf2, 0x8a, 0x52, 0x53, 0xea, 0xaa, 0x21, 0xd6, 0xa8, 0x03, 0x45, 0x1f, 0x07, 0xc4, 0xe3, - 0x66, 0x40, 0x29, 0xaf, 0x64, 0x6a, 0x4a, 0xbd, 0xa4, 0x6f, 0x4f, 0x27, 0xd5, 0x32, 0x63, 0x6f, - 0x0f, 0x98, 0xfb, 0x96, 0x9c, 0x68, 0x87, 0x1d, 0xcd, 0x00, 0x89, 0x32, 0x28, 0xe5, 0xa8, 0x05, - 0x10, 0x0a, 0x11, 0x19, 0x92, 0x4d, 0x0b, 0x29, 0x08, 0x90, 0x88, 0x38, 0x01, 0xb5, 0x4b, 0xed, - 0x71, 0x45, 0xad, 0x29, 0xf5, 0x62, 0x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- 0x63, 0x06, 0xd0, 0xcd, 0x26, 0x87, 0xce, 0x60, 0xc7, 0x1a, 0x31, 0x1e, 0x4a, 0x77, 0x5d, 0x6e, - 0xb6, 0x42, 0xff, 0xba, 0x16, 0x61, 0xa2, 0xb5, 0xa9, 0x3a, 0x9a, 0x4e, 0xaa, 0x1b, 0xf1, 0x65, - 0x74, 0xd4, 0x0a, 0x49, 0x51, 0x14, 0xa0, 0xbb, 0xbc, 0xf5, 0x52, 0xa2, 0x97, 0x69, 0xda, 0x31, - 0x4d, 0xe6, 0x2e, 0x34, 0xed, 0x19, 0xcd, 0x49, 0xd4, 0x2c, 0xb3, 0xb7, 0x8e, 0x8c, 0x89, 0xfc, - 0xe7, 0xfd, 0xf2, 0xde, 0xfd, 0x47, 0x3f, 0xfd, 0xf5, 0x7a, 0x4f, 0xf9, 0xfd, 0x7a, 0x4f, 0xf9, - 0xf3, 0x7a, 0x4f, 0xf9, 0xfe, 0xe3, 0xc4, 0x30, 0xee, 0x07, 0x63, 0x36, 0xc4, 0xdc, 0xb5, 0x06, - 0xb8, 0xcb, 0xe4, 0x53, 0xf3, 0xe6, 0xf0, 0xfd, 0x29, 0xe1, 0x4e, 0x77, 0x4d, 0xbc, 0x3f, 0xfc, - 0x37, 0x00, 0x00, 0xff, 0xff, 0xb3, 0xeb, 0x58, 0xf2, 0x0a, 0x0c, 0x00, 0x00, + // 989 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x6e, 0xe3, 0x44, + 0x1c, 0x97, 0x5b, 0xb7, 0x4d, 0xff, 0x49, 0xfa, 0x31, 0xda, 0xae, 0xa2, 0x1e, 0x9a, 0xc8, 0xdb, + 0x65, 0x03, 0xa2, 0x49, 0xed, 0x96, 0x52, 0x02, 0x17, 0x92, 0xad, 0xd4, 0x15, 0x08, 0x21, 0x23, + 0x21, 0xc1, 0xc5, 0x1a, 0xdb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, 0x7d, 0x4e, 0xb8, 0x67, 0x6f, 0x8a, 0xe7, 0x67, 0xff, + 0x05, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x25, 0x3c, 0xf0, 0x58, 0x0a, 0x00, 0x00, } func (m *BeaconBlock) Marshal() (dAtA []byte, err error) { @@ -1071,18 +959,6 @@ func (m *BeaconBlockBody) MarshalTo(dAtA []byte) (int, error) { i += n } } - if len(m.Transfers) > 0 { - for _, msg := range m.Transfers { - dAtA[i] = 0x4a - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -1296,64 +1172,6 @@ func (m *VoluntaryExit) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Transfer) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Transfer) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.SenderIndex != 0 { - dAtA[i] = 0x8 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(m.SenderIndex)) - } - if m.RecipientIndex != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(m.RecipientIndex)) - } - if m.Amount != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(m.Amount)) - } - if m.Fee != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(m.Fee)) - } - if m.Slot != 0 { - dAtA[i] = 0x28 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(m.Slot)) - } - if len(m.SenderWithdrawalPublicKey) > 0 { - dAtA[i] = 0x32 - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(len(m.SenderWithdrawalPublicKey))) - i += copy(dAtA[i:], m.SenderWithdrawalPublicKey) - } - if len(m.Signature) > 0 { - dAtA[i] = 0x3a - i++ - i = encodeVarintBeaconBlock(dAtA, i, uint64(len(m.Signature))) - i += copy(dAtA[i:], m.Signature) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil -} - func (m *Eth1Data) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1601,12 +1419,6 @@ func (m *BeaconBlockBody) Size() (n int) { n += 1 + l + sovBeaconBlock(uint64(l)) } } - if len(m.Transfers) > 0 { - for _, e := range m.Transfers { - l = e.Size() - n += 1 + l + sovBeaconBlock(uint64(l)) - } - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1727,41 +1539,6 @@ func (m *VoluntaryExit) Size() (n int) { return n } -func (m *Transfer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SenderIndex != 0 { - n += 1 + sovBeaconBlock(uint64(m.SenderIndex)) - } - if m.RecipientIndex != 0 { - n += 1 + sovBeaconBlock(uint64(m.RecipientIndex)) - } - if m.Amount != 0 { - n += 1 + sovBeaconBlock(uint64(m.Amount)) - } - if m.Fee != 0 { - n += 1 + sovBeaconBlock(uint64(m.Fee)) - } - if m.Slot != 0 { - n += 1 + sovBeaconBlock(uint64(m.Slot)) - } - l = len(m.SenderWithdrawalPublicKey) - if l > 0 { - n += 1 + l + sovBeaconBlock(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovBeaconBlock(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - func (m *Eth1Data) Size() (n int) { if m == nil { return 0 @@ -2377,40 +2154,6 @@ func (m *BeaconBlockBody) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Transfers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBeaconBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBeaconBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Transfers = append(m.Transfers, &Transfer{}) - if err := m.Transfers[len(m.Transfers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBeaconBlock(dAtA[iNdEx:]) @@ -3130,223 +2873,6 @@ func (m *VoluntaryExit) Unmarshal(dAtA []byte) error { } return nil } -func (m *Transfer) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Transfer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Transfer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SenderIndex", wireType) - } - m.SenderIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SenderIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RecipientIndex", wireType) - } - m.RecipientIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RecipientIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - m.Fee = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Fee |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Slot", wireType) - } - m.Slot = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Slot |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SenderWithdrawalPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBeaconBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBeaconBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SenderWithdrawalPublicKey = append(m.SenderWithdrawalPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.SenderWithdrawalPublicKey == nil { - m.SenderWithdrawalPublicKey = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBeaconBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBeaconBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipBeaconBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBeaconBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBeaconBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Eth1Data) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/eth/v1alpha1/beacon_block.proto b/proto/eth/v1alpha1/beacon_block.proto index 0e35715ec1..a5e31d40e7 100644 --- a/proto/eth/v1alpha1/beacon_block.proto +++ b/proto/eth/v1alpha1/beacon_block.proto @@ -53,10 +53,6 @@ message BeaconBlockBody { // At most MAX_VOLUNTARY_EXITS. repeated VoluntaryExit voluntary_exits = 8 [(gogoproto.moretags) = "ssz-max:\"16\""]; - - // At most MAX_TRANSFERS. - // Note: this is always empty for phase 0. - repeated Transfer transfers = 9 [(gogoproto.moretags) = "ssz-max:\"0\""]; } // Proposer slashings are proofs that a slashable offense has been committed by @@ -117,30 +113,6 @@ message VoluntaryExit { bytes signature = 3 [(gogoproto.moretags) = "ssz-size:\"96\""]; } -// A beacon chain transfer is a ETH currency transfer between two validators. -message Transfer { - // Validator index of the sender. - uint64 sender_index = 1 [(gogoproto.moretags) = "spec-name:\"sender\""]; - - // Validator index of the recipient. - uint64 recipient_index = 2 [(gogoproto.moretags) = "spec-name:\"recipient\""]; - - // Amount in gwei sent to the recipient. - uint64 amount = 3; - - // Fee in gwei for the block proposer to include this transfer. - uint64 fee = 4; - - // Slot at which transfer must be processed. This is used for replay protection. - uint64 slot = 5; - - // 48 byte sender's withdrawal public key. - bytes sender_withdrawal_public_key = 6 [(gogoproto.moretags) = "ssz-size:\"48\" spec-name:\"pubkey\""]; - - // 96 byte signature from the sender's withdrawal key. - bytes signature = 7 [(gogoproto.moretags) = "ssz-size:\"96\""]; -} - // Eth1Data represents references to the Ethereum 1.x deposit contract. message Eth1Data { // The 32 byte deposit tree root for the last deposit included in this @@ -177,8 +149,8 @@ message BeaconBlockHeader { } message IndexedAttestation { - repeated uint64 custody_bit_0_indices = 1 [(gogoproto.moretags) = "ssz-max:\"4096\""]; - repeated uint64 custody_bit_1_indices = 2 [(gogoproto.moretags) = "ssz-max:\"4096\""]; + repeated uint64 custody_bit_0_indices = 1 [(gogoproto.moretags) = "ssz-max:\"2048\""]; + repeated uint64 custody_bit_1_indices = 2 [(gogoproto.moretags) = "ssz-max:\"2048\""]; AttestationData data = 3; diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 305fca2374..303d7f3aa3 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -1785,10 +1785,10 @@ func (m *ValidatorAssignments) GetTotalSize() int32 { } type ValidatorAssignments_CommitteeAssignment struct { - CrosslinkCommittees []uint64 `protobuf:"varint,1,rep,packed,name=crosslink_committees,json=crosslinkCommittees,proto3" json:"crosslink_committees,omitempty"` - Shard uint64 `protobuf:"varint,2,opt,name=shard,proto3" json:"shard,omitempty"` - Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - Proposer bool `protobuf:"varint,4,opt,name=proposer,proto3" json:"proposer,omitempty"` + BeaconCommittees []uint64 `protobuf:"varint,1,rep,packed,name=beacon_committees,json=beaconCommittees,proto3" json:"beacon_committees,omitempty"` + CommitteeIndex uint64 `protobuf:"varint,2,opt,name=committee_index,json=committeeIndex,proto3" json:"committee_index,omitempty"` + AttesterSlot uint64 `protobuf:"varint,3,opt,name=attester_slot,json=attesterSlot,proto3" json:"attester_slot,omitempty"` + ProposerSlot uint64 `protobuf:"varint,4,opt,name=proposer_slot,json=proposerSlot,proto3" json:"proposer_slot,omitempty"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" ssz-size:"48"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -1830,32 +1830,32 @@ func (m *ValidatorAssignments_CommitteeAssignment) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorAssignments_CommitteeAssignment proto.InternalMessageInfo -func (m *ValidatorAssignments_CommitteeAssignment) GetCrosslinkCommittees() []uint64 { +func (m *ValidatorAssignments_CommitteeAssignment) GetBeaconCommittees() []uint64 { if m != nil { - return m.CrosslinkCommittees + return m.BeaconCommittees } return nil } -func (m *ValidatorAssignments_CommitteeAssignment) GetShard() uint64 { +func (m *ValidatorAssignments_CommitteeAssignment) GetCommitteeIndex() uint64 { if m != nil { - return m.Shard + return m.CommitteeIndex } return 0 } -func (m *ValidatorAssignments_CommitteeAssignment) GetSlot() uint64 { +func (m *ValidatorAssignments_CommitteeAssignment) GetAttesterSlot() uint64 { if m != nil { - return m.Slot + return m.AttesterSlot } return 0 } -func (m *ValidatorAssignments_CommitteeAssignment) GetProposer() bool { +func (m *ValidatorAssignments_CommitteeAssignment) GetProposerSlot() uint64 { if m != nil { - return m.Proposer + return m.ProposerSlot } - return false + return 0 } func (m *ValidatorAssignments_CommitteeAssignment) GetPublicKey() []byte { @@ -2150,108 +2150,108 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ - // 1601 bytes of a gzipped FileDescriptorProto + // 1612 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xbd, 0x6f, 0x1b, 0x47, - 0x16, 0xf7, 0x92, 0xd4, 0xd7, 0xa3, 0x3e, 0xac, 0x91, 0x64, 0xf3, 0x28, 0x4b, 0xa2, 0x57, 0x96, - 0x8e, 0x86, 0x6d, 0xd2, 0x92, 0x3f, 0xee, 0xe0, 0xc3, 0xc1, 0x67, 0x09, 0x3e, 0xeb, 0x2e, 0x46, - 0xa0, 0xac, 0x8c, 0x14, 0x69, 0x88, 0xe1, 0x72, 0x44, 0x8e, 0xb5, 0xdc, 0x59, 0xef, 0x0c, 0x05, - 0x4b, 0x5d, 0x52, 0x04, 0x48, 0x1d, 0x20, 0x41, 0x9a, 0x24, 0xad, 0x11, 0xa4, 0x4d, 0x63, 0x20, - 0x08, 0x52, 0xa5, 0x0c, 0x10, 0x20, 0xa5, 0x11, 0x18, 0x69, 0x53, 0xc4, 0xff, 0x40, 0x82, 0x9d, - 0x9d, 0xfd, 0xa2, 0xb8, 0x24, 0x0d, 0xab, 0x4a, 0xb7, 0xf3, 0xe6, 0xcd, 0xef, 0xfd, 0xe6, 0x7d, - 0xcc, 0xbc, 0x59, 0x58, 0x73, 0x5c, 0x26, 0x58, 0x95, 0x88, 0x56, 0xf5, 0x70, 0x03, 0x5b, 0x4e, - 0x0b, 0x6f, 0x54, 0xeb, 0x04, 0x9b, 0xcc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0, 0x0b, 0x03, 0x1c, - 0x81, 0xdd, 0x26, 0x11, 0x0a, 0x27, 0x17, 0xe0, 0xf8, 0xd2, 0x10, 0x47, 0x29, 0x49, 0x9c, 0x91, - 0x00, 0xc7, 0x17, 0x4a, 0x9c, 0x45, 0x98, 0x70, 0x70, 0x93, 0xd4, 0x38, 0x3d, 0x26, 0x85, 0xd1, - 0x92, 0x56, 0x1e, 0x31, 0xc6, 0x3d, 0xc1, 0x1e, 0x3d, 0x26, 0x68, 0x09, 0x40, 0x4e, 0x0a, 0x76, - 0x40, 0xec, 0xc2, 0x58, 0x49, 0x2b, 0x4f, 0x18, 0x52, 0xfd, 0x91, 0x27, 0xd8, 0x9a, 0x86, 0xc9, - 0x27, 0x1d, 0xe2, 0x1e, 0xd5, 0xf6, 0xa9, 0x25, 0x88, 0xab, 0x3f, 0xd3, 0xa0, 0x70, 0xd2, 0x43, - 0xdc, 0x61, 0x36, 0x27, 0xe8, 0xbf, 0x30, 0x19, 0x0b, 0x0f, 0x2f, 0x68, 0xa5, 0x6c, 0x39, 0xbf, - 0xa9, 0x57, 0x7a, 0xe6, 0x51, 0x25, 0x06, 0x61, 0x24, 0xd6, 0xa1, 0x75, 0x98, 0xb1, 0xc9, 0x53, - 0x51, 0x8b, 0x11, 0xcb, 0x48, 0x62, 0x53, 0x9e, 0x78, 0x37, 0x20, 0xe7, 0x71, 0x17, 0x4c, 0x60, - 0xcb, 0xdf, 0x59, 0x56, 0xee, 0x6c, 0x42, 0x4a, 0xbc, 0xad, 0xe9, 0x3f, 0x6b, 0x30, 0xeb, 0x71, - 0x95, 0x91, 0x09, 0xe3, 0x38, 0x0f, 0xb9, 0x44, 0xf0, 0xe4, 0xc8, 0x93, 0x72, 0x8b, 0x89, 0x30, - 0x56, 0x72, 0x84, 0xce, 0xc1, 0x88, 0xef, 0xfa, 0xac, 0x12, 0xfb, 0x43, 0xb4, 0x01, 0xf3, 0xd4, - 0x36, 0xad, 0x4e, 0x83, 0xd4, 0x6c,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0x00, 0xff, 0xff, 0xea, 0x59, 0x36, 0xfb, 0x44, 0x16, 0x00, - 0x00, + 0x16, 0xf7, 0x92, 0xd4, 0xd7, 0xa3, 0xa8, 0x8f, 0x91, 0x64, 0xf3, 0x28, 0x4b, 0xa2, 0x57, 0x96, + 0x4c, 0x43, 0x36, 0x69, 0xc9, 0x1f, 0x77, 0xf0, 0xe1, 0xe0, 0xb3, 0x04, 0x9f, 0xe5, 0x3b, 0xe3, + 0xa0, 0x5b, 0x19, 0x57, 0x5c, 0x43, 0x2c, 0x97, 0x23, 0x72, 0xac, 0xe5, 0xce, 0x9a, 0x33, 0x14, + 0x2c, 0x75, 0x97, 0x22, 0x40, 0xea, 0x00, 0x49, 0x97, 0xa4, 0x35, 0x82, 0xb4, 0x69, 0x0c, 0x04, + 0x41, 0xaa, 0x94, 0x01, 0x02, 0xa4, 0x34, 0x02, 0x23, 0x40, 0xaa, 0x14, 0xf1, 0x3f, 0x90, 0x60, + 0x67, 0x66, 0xbf, 0x28, 0x2e, 0x49, 0xc3, 0xaa, 0xd2, 0xed, 0xbc, 0x79, 0xf3, 0x7b, 0xbf, 0x79, + 0x6f, 0xde, 0xcc, 0x7b, 0x0b, 0x6b, 0x6e, 0x9b, 0x72, 0x5a, 0xc1, 0xbc, 0x59, 0x39, 0xda, 0x34, + 0x6d, 0xb7, 0x69, 0x6e, 0x56, 0x6a, 0xd8, 0xb4, 0xa8, 0x53, 0xb5, 0x9a, 0x26, 0x71, 0xca, 0x62, + 0x1e, 0x2d, 0x60, 0xde, 0xc4, 0x6d, 0xdc, 0x69, 0x95, 0x31, 0x6f, 0x96, 0x7d, 0xcd, 0xc2, 0xf5, + 0x06, 0xe1, 0xcd, 0x4e, 0xad, 0x6c, 0xd1, 0x56, 0xa5, 0x41, 0x1b, 0xb4, 0x22, 0xb4, 0x6b, 0x9d, + 0x03, 0x31, 0x92, 0xd0, 0xde, 0x97, 0x44, 0x29, 0x5c, 0x6c, 0x50, 0xda, 0xb0, 0x71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0x89, 0x4e, 0x13, 0x85, 0x08, 0x66, + 0x98, 0x5b, 0x8a, 0xd7, 0x09, 0xcc, 0x46, 0x29, 0xc8, 0x2a, 0x28, 0xe9, 0x58, 0xad, 0x0d, 0x72, + 0x95, 0x58, 0x9e, 0x74, 0xb6, 0x22, 0x34, 0x9e, 0x09, 0x33, 0x5f, 0xa8, 0x9f, 0x4e, 0x3d, 0x5f, + 0xf4, 0x3b, 0x7d, 0x52, 0xa7, 0x4f, 0xc9, 0x53, 0xd8, 0x78, 0x8b, 0xe7, 0x5d, 0xbf, 0x26, 0x98, + 0xae, 0xa3, 0xcb, 0xc9, 0x0e, 0x8b, 0x50, 0x7a, 0xa9, 0xc1, 0x9f, 0x12, 0xdf, 0x2e, 0xf4, 0xe7, + 0x21, 0x22, 0xdc, 0xeb, 0xb5, 0x2b, 0xdc, 0x7e, 0xbb, 0xb7, 0x63, 0xc0, 0x25, 0x16, 0xe1, 0x1e, + 0x7b, 0x64, 0xb6, 0x77, 0xbe, 0x7d, 0xbd, 0xac, 0x7d, 0xf7, 0x7a, 0x59, 0xfb, 0xf1, 0xf5, 0xb2, + 0xf6, 0xbf, 0xdb, 0x91, 0xbf, 0xbd, 0x6e, 0xfb, 0x98, 0xb5, 0x4c, 0x4e, 0x2c, 0xdb, 0xac, 0x31, + 0x39, 0xaa, 0x9c, 0xfe, 0xab, 0xfa, 0x57, 0xcc, 0x9b, 0xb5, 0x51, 0x21, 0xbf, 0xf9, 0x7b, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x25, 0x11, 0xba, 0xff, 0x6b, 0x16, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3502,10 +3502,10 @@ func (m *ValidatorAssignments_CommitteeAssignment) MarshalTo(dAtA []byte) (int, _ = i var l int _ = l - if len(m.CrosslinkCommittees) > 0 { - dAtA12 := make([]byte, len(m.CrosslinkCommittees)*10) + if len(m.BeaconCommittees) > 0 { + dAtA12 := make([]byte, len(m.BeaconCommittees)*10) var j11 int - for _, num := range m.CrosslinkCommittees { + for _, num := range m.BeaconCommittees { for num >= 1<<7 { dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -3519,25 +3519,20 @@ func (m *ValidatorAssignments_CommitteeAssignment) MarshalTo(dAtA []byte) (int, i = encodeVarintBeaconChain(dAtA, i, uint64(j11)) i += copy(dAtA[i:], dAtA12[:j11]) } - if m.Shard != 0 { + if m.CommitteeIndex != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(m.Shard)) + i = encodeVarintBeaconChain(dAtA, i, uint64(m.CommitteeIndex)) } - if m.Slot != 0 { + if m.AttesterSlot != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(m.Slot)) + i = encodeVarintBeaconChain(dAtA, i, uint64(m.AttesterSlot)) } - if m.Proposer { + if m.ProposerSlot != 0 { dAtA[i] = 0x20 i++ - if m.Proposer { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.ProposerSlot)) } if len(m.PublicKey) > 0 { dAtA[i] = 0x2a @@ -4264,21 +4259,21 @@ func (m *ValidatorAssignments_CommitteeAssignment) Size() (n int) { } var l int _ = l - if len(m.CrosslinkCommittees) > 0 { + if len(m.BeaconCommittees) > 0 { l = 0 - for _, e := range m.CrosslinkCommittees { + for _, e := range m.BeaconCommittees { l += sovBeaconChain(uint64(e)) } n += 1 + sovBeaconChain(uint64(l)) + l } - if m.Shard != 0 { - n += 1 + sovBeaconChain(uint64(m.Shard)) + if m.CommitteeIndex != 0 { + n += 1 + sovBeaconChain(uint64(m.CommitteeIndex)) } - if m.Slot != 0 { - n += 1 + sovBeaconChain(uint64(m.Slot)) + if m.AttesterSlot != 0 { + n += 1 + sovBeaconChain(uint64(m.AttesterSlot)) } - if m.Proposer { - n += 2 + if m.ProposerSlot != 0 { + n += 1 + sovBeaconChain(uint64(m.ProposerSlot)) } l = len(m.PublicKey) if l > 0 { @@ -7095,7 +7090,7 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error break } } - m.CrosslinkCommittees = append(m.CrosslinkCommittees, v) + m.BeaconCommittees = append(m.BeaconCommittees, v) } else if wireType == 2 { var packedLen int for shift := uint(0); ; shift += 7 { @@ -7130,8 +7125,8 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error } } elementCount = count - if elementCount != 0 && len(m.CrosslinkCommittees) == 0 { - m.CrosslinkCommittees = make([]uint64, 0, elementCount) + if elementCount != 0 && len(m.BeaconCommittees) == 0 { + m.BeaconCommittees = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -7149,16 +7144,16 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error break } } - m.CrosslinkCommittees = append(m.CrosslinkCommittees, v) + m.BeaconCommittees = append(m.BeaconCommittees, v) } } else { - return fmt.Errorf("proto: wrong wireType = %d for field CrosslinkCommittees", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BeaconCommittees", wireType) } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Shard", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CommitteeIndex", wireType) } - m.Shard = 0 + m.CommitteeIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBeaconChain @@ -7168,16 +7163,16 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Shard |= uint64(b&0x7F) << shift + m.CommitteeIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Slot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AttesterSlot", wireType) } - m.Slot = 0 + m.AttesterSlot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBeaconChain @@ -7187,16 +7182,16 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Slot |= uint64(b&0x7F) << shift + m.AttesterSlot |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProposerSlot", wireType) } - var v int + m.ProposerSlot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBeaconChain @@ -7206,12 +7201,11 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.ProposerSlot |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.Proposer = bool(v != 0) case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index 7a8bcdd1ac..f4eb3a1d86 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -20,7 +20,7 @@ service BeaconChain { // TODO(preston): Batch requests? // Retrieve attestations by block root, slot, or epoch. - // Attestations are sorted by crosslink shard by default. + // Attestations are sorted by slot by default. // // The server may return an empty list when no attestations match the given // filter criteria. This RPC should not return NOT_FOUND. Only one filter @@ -394,24 +394,23 @@ message ListValidatorAssignmentsRequest { message ValidatorAssignments { message CommitteeAssignment { - // Crosslink committees is responsible for crosslinking shard data back to the beacon chain, + // Beacon committees is responsible for crosslinking committee data back to the beacon chain, // they also attest and produce beacon chain blocks. This is a list of validator indices that // are in the same committee as requested validator, everyone in the committee is assigned to the - // same slot and same shard. - repeated uint64 crosslink_committees = 1; + // same slot and same committee. + repeated uint64 beacon_committees = 1; - // The shard index of which the validator must perform the attestation + // The committee index of which the validator must perform the attestation // or block proposal. - uint64 shard = 2; + uint64 committee_index = 2; // Beacon chain slot in which the validator must perform its assigned - // duty. - uint64 slot = 3; + // duty as an attester. + uint64 attester_slot = 3; - // Whether or not the validator is assigned to propose at this slot. If - // This field is false, then they are only to attest during the - // assignment time. - bool proposer = 4; + // Beacon chain slot in which the validator must perform its assigned + // duty as an attester. + uint64 proposer_slot = 4; // 48 byte BLS public key bytes public_key = 5 [(gogoproto.moretags) = "ssz-size:\"48\""]; diff --git a/proto/eth/v1alpha1/slasher.pb.go b/proto/eth/v1alpha1/slasher.pb.go index 3b77ef5465..bea45b2430 100755 --- a/proto/eth/v1alpha1/slasher.pb.go +++ b/proto/eth/v1alpha1/slasher.pb.go @@ -6,12 +6,11 @@ package eth import ( context "context" fmt "fmt" - io "io" - math "math" - proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/ssz_proto_library.bzl b/proto/ssz_proto_library.bzl index ed95a0c392..dd9663f409 100644 --- a/proto/ssz_proto_library.bzl +++ b/proto/ssz_proto_library.bzl @@ -8,17 +8,13 @@ These rules allow for variable substitution for hardcoded tag values like ssz-si ####### Configuration ####### mainnet = { - "block_roots.size": "8192,32", - "state_roots.size": "8192,32", - "eth1_data_votes.size": "1024", - "randao_mixes.size": "65536,32", - "active_index_roots.size": "65536,32", - "compact_committees_roots.size": "65536,32", - "previous_epoch_attestations.max": "8192", - "current_epoch_attestations.max": "8192", - "previous_crosslinks.size": "1024", - "current_crosslinks.size": "1024", - "slashings.size": "8192", + "block_roots.size": "8192,32", # SLOTS_PER_HISTORICAL_ROOT, [32]byte + "state_roots.size": "8192,32", # SLOTS_PER_HISTORICAL_ROOT, [32]byte + "eth1_data_votes.size": "1024", # SLOTS_PER_ETH1_VOTING_PERIOD + "randao_mixes.size": "65536,32", # EPOCHS_PER_HISTORICAL_VECTOR, [32]byte + "previous_epoch_attestations.max": "4096", # MAX_ATTESTATIONS * SLOTS_PER_EPOCH + "current_epoch_attestations.max": "4096", # MAX_ATTESTATIONS * SLOTS_PER_EPOCH + "slashings.size": "8192", # EPOCHS_PER_SLASHINGS_VECTOR } minimal = { @@ -26,12 +22,8 @@ minimal = { "state_roots.size": "64,32", "eth1_data_votes.size": "16", "randao_mixes.size": "64,32", - "active_index_roots.size": "64,32", - "compact_committees_roots.size": "64,32", "previous_epoch_attestations.max": "1024", "current_epoch_attestations.max": "1024", - "previous_crosslinks.size": "8", - "current_crosslinks.size": "8", "slashings.size": "64", } diff --git a/proto/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index cbf8707102..aece4ca082 100644 --- a/proto/testing/ssz_static_test.go +++ b/proto/testing/ssz_static_test.go @@ -100,6 +100,8 @@ func UnmarshalledSSZ(serializedBytes []byte, folderName string) (interface{}, er obj = &pb.AttestationDataAndCustodyBit{} case "AttesterSlashing": obj = ðpb.AttesterSlashing{} + case "AggregateAndProof": + obj = &pb.AggregateAndProof{} case "BeaconBlock": obj = ðpb.BeaconBlock{} case "BeaconBlockBody": @@ -110,10 +112,6 @@ func UnmarshalledSSZ(serializedBytes []byte, folderName string) (interface{}, er obj = &pb.BeaconState{} case "Checkpoint": obj = ðpb.Checkpoint{} - case "CompactCommittee": - obj = &pb.CompactCommittee{} - case "Crosslink": - obj = ðpb.Crosslink{} case "Deposit": obj = ðpb.Deposit{} case "DepositData": @@ -130,8 +128,6 @@ func UnmarshalledSSZ(serializedBytes []byte, folderName string) (interface{}, er obj = &pb.PendingAttestation{} case "ProposerSlashing": obj = ðpb.ProposerSlashing{} - case "Transfer": - obj = ðpb.Transfer{} case "Validator": obj = ðpb.Validator{} case "VoluntaryExit": diff --git a/shared/keystore/deposit_input.go b/shared/keystore/deposit_input.go index 1b3efdbbe8..40015d5de4 100644 --- a/shared/keystore/deposit_input.go +++ b/shared/keystore/deposit_input.go @@ -22,7 +22,7 @@ import ( // - Send a transaction on the Ethereum 1.0 chain to DEPOSIT_CONTRACT_ADDRESS executing def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96]) along with a deposit of amount Gwei. // // See: https://github.com/ethereum/eth2.0-specs/blob/master/specs/validator/0_beacon-chain-validator.md#submit-deposit -func DepositInput(depositKey *Key, withdrawalKey *Key, amountInGwei uint64) (*ethpb.Deposit_Data, error) { +func DepositInput(depositKey *Key, withdrawalKey *Key, amountInGwei uint64) (*ethpb.Deposit_Data, [32]byte, error) { di := ðpb.Deposit_Data{ PublicKey: depositKey.PublicKey.Marshal(), WithdrawalCredentials: withdrawalCredentialsHash(withdrawalKey), @@ -31,13 +31,18 @@ func DepositInput(depositKey *Key, withdrawalKey *Key, amountInGwei uint64) (*et sr, err := ssz.SigningRoot(di) if err != nil { - return nil, err + return nil, [32]byte{}, err } domain := bls.ComputeDomain(params.BeaconConfig().DomainDeposit) di.Signature = depositKey.SecretKey.Sign(sr[:], domain).Marshal() - return di, nil + dr, err := ssz.HashTreeRoot(di) + if err != nil { + return nil, [32]byte{}, err + } + + return di, dr, nil } // withdrawalCredentialsHash forms a 32 byte hash of the withdrawal public diff --git a/shared/keystore/deposit_input_test.go b/shared/keystore/deposit_input_test.go index 92a38bea37..21d39fc1ea 100644 --- a/shared/keystore/deposit_input_test.go +++ b/shared/keystore/deposit_input_test.go @@ -22,7 +22,7 @@ func TestDepositInput_GeneratesPb(t *testing.T) { t.Fatal(err) } - result, err := keystore.DepositInput(k1, k2, 0) + result, _, err := keystore.DepositInput(k1, k2, 0) if err != nil { t.Fatal(err) } diff --git a/shared/params/config.go b/shared/params/config.go index e42569e062..7b99f75a0d 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -18,9 +18,9 @@ type BeaconChainConfig struct { SecondsPerDay uint64 `yaml:"SECONDS_PER_DAY"` // SecondsPerDay number of seconds in day constant. // Misc constants. - ShardCount uint64 `yaml:"SHARD_COUNT"` // ShardCount is the number of shard chains in Ethereum 2.0. - TargetCommitteeSize uint64 `yaml:"TARGET_COMMITTEE_SIZE"` // TargetCommitteeSize is the number of validators in a committee when the chain is healthy. - MaxValidatorsPerCommittee uint64 `yaml:"MAX_VALIDATORS_PER_COMMITTEE"` // MaxValidatorsPerCommittee defines the upper bound of the size of a committee. + TargetCommitteeSize uint64 `yaml:"TARGET_COMMITTEE_SIZE"` // TargetCommitteeSize is the number of validators in a committee when the chain is healthy. + MaxValidatorsPerCommittee uint64 `yaml:"MAX_VALIDATORS_PER_COMMITTEE"` // MaxValidatorsPerCommittee defines the upper bound of the size of a committee. + MaxCommitteesPerSlot uint64 // MaxCommitteesPerSlot defines the max amount of committee in a single slot. MinPerEpochChurnLimit uint64 `yaml:"MIN_PER_EPOCH_CHURN_LIMIT"` // MinPerEpochChurnLimit is the minimum amount of churn allotted for validator rotations. ChurnLimitQuotient uint64 `yaml:"CHURN_LIMIT_QUOTIENT"` // ChurnLimitQuotient is used to determine the limit of how many validators can rotate per epoch. ShuffleRoundCount uint64 `yaml:"SHUFFLE_ROUND_COUNT"` // ShuffleRoundCount is used for retrieving the permuted index. @@ -42,12 +42,11 @@ type BeaconChainConfig struct { SecondsPerSlot uint64 `yaml:"SECONDS_PER_SLOT"` // SecondsPerSlot is how many seconds are in a single slot. SlotsPerEpoch uint64 `yaml:"SLOTS_PER_EPOCH"` // SlotsPerEpoch is the number of slots in an epoch. MinSeedLookahead uint64 `yaml:"MIN_SEED_LOOKAHEAD"` // SeedLookahead is the duration of randao look ahead seed. - ActivationExitDelay uint64 `yaml:"ACTIVATION_EXIT_DELAY"` // ActivationExitDelay is the duration a validator has to wait for entry and exit in epoch. + MaxSeedLookhead uint64 `yaml:"ACTIVATION_EXIT_DELAY"` // MaxSeedLookhead is the duration a validator has to wait for entry and exit in epoch. SlotsPerEth1VotingPeriod uint64 `yaml:"SLOTS_PER_ETH1_VOTING_PERIOD"` // SlotsPerEth1VotingPeriod defines how often the merkle root of deposit receipts get updated in beacon node. SlotsPerHistoricalRoot uint64 `yaml:"SLOTS_PER_HISTORICAL_ROOT"` // SlotsPerHistoricalRoot defines how often the historical root is saved. MinValidatorWithdrawabilityDelay uint64 `yaml:"MIN_VALIDATOR_WITHDRAWABILITY_DELAY"` // MinValidatorWithdrawabilityDelay is the shortest amount of time a validator has to wait to withdraw. PersistentCommitteePeriod uint64 `yaml:"PERSISTENT_COMMITTEE_PERIOD"` // PersistentCommitteePeriod is the minimum amount of epochs a validator must participate before exitting. - MaxEpochsPerCrosslink uint64 `yaml:"MAX_EPOCHS_PER_CROSSLINK"` // MaxEpochsPerCrosslink defines the max epoch from current a crosslink can be formed at. MinEpochsToInactivityPenalty uint64 `yaml:"MIN_EPOCHS_TO_INACTIVITY_PENALTY"` // MinEpochsToInactivityPenalty defines the minimum amount of epochs since finality to begin penalizing inactivity. Eth1FollowDistance uint64 // Eth1FollowDistance is the number of eth1.0 blocks to wait before considering a new deposit for voting. This only applies after the chain as been started. @@ -70,15 +69,13 @@ type BeaconChainConfig struct { MaxAttestations uint64 `yaml:"MAX_ATTESTATIONS"` // MaxAttestations defines the maximum allowed attestations in a beacon block. MaxDeposits uint64 `yaml:"MAX_DEPOSITS"` // MaxVoluntaryExits defines the maximum number of validator deposits in a block. MaxVoluntaryExits uint64 `yaml:"MAX_VOLUNTARY_EXITS"` // MaxVoluntaryExits defines the maximum number of validator exits in a block. - MaxTransfers uint64 `yaml:"MAX_TRANSFERS"` // MaxTransfers defines the maximum number of balance transfers in a block. // BLS domain values. DomainBeaconProposer []byte `yaml:"DOMAIN_BEACON_PROPOSER"` // DomainBeaconProposer defines the BLS signature domain for beacon proposal verification. DomainRandao []byte `yaml:"DOMAIN_RANDAO"` // DomainRandao defines the BLS signature domain for randao verification. - DomainAttestation []byte `yaml:"DOMAIN_ATTESTATION"` // DomainAttestation defines the BLS signature domain for attestation verification. + DomainBeaconAttester []byte `yaml:"DOMAIN_ATTESTATION"` // DomainBeaconAttester defines the BLS signature domain for attestation verification. DomainDeposit []byte `yaml:"DOMAIN_DEPOSIT"` // DomainDeposit defines the BLS signature domain for deposit verification. DomainVoluntaryExit []byte `yaml:"DOMAIN_VOLUNTARY_EXIT"` // DomainVoluntaryExit defines the BLS signature domain for exit verification. - DomainTransfer []byte `yaml:"DOMAIN_TRANSFER"` // DomainTransfer defines the BLS signature domain for transfer verification. // Prysm constants. GweiPerEth uint64 // GweiPerEth is the amount of gwei corresponding to 1 eth. @@ -110,14 +107,14 @@ type DepositContractConfig struct { var defaultBeaconConfig = &BeaconChainConfig{ // Constants (Non-configurable) FarFutureEpoch: 1<<64 - 1, - BaseRewardsPerEpoch: 5, + BaseRewardsPerEpoch: 4, DepositContractTreeDepth: 32, SecondsPerDay: 86400, // Misc constant. - ShardCount: 1024, TargetCommitteeSize: 128, - MaxValidatorsPerCommittee: 4096, + MaxValidatorsPerCommittee: 2048, + MaxCommitteesPerSlot: 64, MinPerEpochChurnLimit: 4, ChurnLimitQuotient: 1 << 16, ShuffleRoundCount: 90, @@ -136,15 +133,14 @@ var defaultBeaconConfig = &BeaconChainConfig{ // Time parameter constants. MinAttestationInclusionDelay: 1, - SecondsPerSlot: 6, - SlotsPerEpoch: 64, + SecondsPerSlot: 12, + SlotsPerEpoch: 32, MinSeedLookahead: 1, - ActivationExitDelay: 4, + MaxSeedLookhead: 4, SlotsPerEth1VotingPeriod: 1024, SlotsPerHistoricalRoot: 8192, MinValidatorWithdrawabilityDelay: 256, PersistentCommitteePeriod: 2048, - MaxEpochsPerCrosslink: 64, MinEpochsToInactivityPenalty: 4, Eth1FollowDistance: 1024, @@ -167,15 +163,13 @@ var defaultBeaconConfig = &BeaconChainConfig{ MaxAttestations: 128, MaxDeposits: 16, MaxVoluntaryExits: 16, - MaxTransfers: 0, // BLS domain values. DomainBeaconProposer: bytesutil.Bytes4(0), - DomainRandao: bytesutil.Bytes4(1), - DomainAttestation: bytesutil.Bytes4(2), + DomainBeaconAttester: bytesutil.Bytes4(1), + DomainRandao: bytesutil.Bytes4(2), DomainDeposit: bytesutil.Bytes4(3), DomainVoluntaryExit: bytesutil.Bytes4(4), - DomainTransfer: bytesutil.Bytes4(5), // Prysm constants. GweiPerEth: 1000000000, @@ -242,9 +236,9 @@ func DemoBeaconConfig() *BeaconChainConfig { func MinimalSpecConfig() *BeaconChainConfig { minimalConfig := *defaultBeaconConfig // Misc - minimalConfig.ShardCount = 8 + minimalConfig.MaxCommitteesPerSlot = 4 minimalConfig.TargetCommitteeSize = 4 - minimalConfig.MaxValidatorsPerCommittee = 4096 + minimalConfig.MaxValidatorsPerCommittee = 2048 minimalConfig.MinPerEpochChurnLimit = 4 minimalConfig.ChurnLimitQuotient = 65536 minimalConfig.ShuffleRoundCount = 10 @@ -261,16 +255,15 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.BLSWithdrawalPrefixByte = byte(0) // Time parameters - minimalConfig.SecondsPerSlot = 6 + minimalConfig.SecondsPerSlot = 12 minimalConfig.MinAttestationInclusionDelay = 1 minimalConfig.SlotsPerEpoch = 8 minimalConfig.MinSeedLookahead = 1 - minimalConfig.ActivationExitDelay = 4 + minimalConfig.MaxSeedLookhead = 4 minimalConfig.SlotsPerEth1VotingPeriod = 16 minimalConfig.SlotsPerHistoricalRoot = 64 minimalConfig.MinValidatorWithdrawabilityDelay = 256 minimalConfig.PersistentCommitteePeriod = 2048 - minimalConfig.MaxEpochsPerCrosslink = 4 minimalConfig.MinEpochsToInactivityPenalty = 4 // State vector lengths @@ -285,7 +278,6 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.ProposerRewardQuotient = 8 minimalConfig.InactivityPenaltyQuotient = 33554432 minimalConfig.MinSlashingPenaltyQuotient = 32 - minimalConfig.BaseRewardsPerEpoch = 5 // Max operations per block minimalConfig.MaxProposerSlashings = 16 @@ -293,15 +285,13 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.MaxAttestations = 128 minimalConfig.MaxDeposits = 16 minimalConfig.MaxVoluntaryExits = 16 - minimalConfig.MaxTransfers = 0 // Signature domains minimalConfig.DomainBeaconProposer = bytesutil.Bytes4(0) - minimalConfig.DomainRandao = bytesutil.Bytes4(1) - minimalConfig.DomainAttestation = bytesutil.Bytes4(2) + minimalConfig.DomainBeaconAttester = bytesutil.Bytes4(1) + minimalConfig.DomainRandao = bytesutil.Bytes4(2) minimalConfig.DomainDeposit = bytesutil.Bytes4(3) minimalConfig.DomainVoluntaryExit = bytesutil.Bytes4(4) - minimalConfig.DomainTransfer = bytesutil.Bytes4(5) minimalConfig.DepositContractTreeDepth = 32 minimalConfig.FarFutureEpoch = 1<<64 - 1 diff --git a/shared/params/config_test.go b/shared/params/config_test.go index 1577410852..7f7a0fe5bb 100644 --- a/shared/params/config_test.go +++ b/shared/params/config_test.go @@ -8,9 +8,9 @@ import ( func TestOverrideBeaconConfig(t *testing.T) { cfg := params.BeaconConfig() - cfg.ShardCount = 5 + cfg.SlotsPerEpoch = 5 params.OverrideBeaconConfig(cfg) - if c := params.BeaconConfig(); c.ShardCount != 5 { - t.Errorf("Shardcount in BeaconConfig incorrect. Wanted %d, got %d", 5, c.ShardCount) + if c := params.BeaconConfig(); c.SlotsPerEpoch != 5 { + t.Errorf("Shardcount in BeaconConfig incorrect. Wanted %d, got %d", 5, c.SlotsPerEpoch) } } diff --git a/shared/params/spectest/config_test.go b/shared/params/spectest/config_test.go index 84763358b3..133fe0f5ee 100644 --- a/shared/params/spectest/config_test.go +++ b/shared/params/spectest/config_test.go @@ -13,7 +13,7 @@ func TestConfig(t *testing.T) { } SetConfig("mainnet") - if params.BeaconConfig().SlotsPerEpoch != 64 { + if params.BeaconConfig().SlotsPerEpoch != 32 { t.Errorf("Expected mainnet config to be set, but got %d slots per epoch", params.BeaconConfig().SlotsPerEpoch) } } diff --git a/shared/testutil/block.go b/shared/testutil/block.go index ab33668d54..066c1373d2 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -195,18 +195,12 @@ func generateAttesterSlashings( ) []*ethpb.AttesterSlashing { attesterSlashings := make([]*ethpb.AttesterSlashing, maxSlashings) for i := uint64(0); i < maxSlashings; i++ { - crosslink := ðpb.Crosslink{ - Shard: i % params.BeaconConfig().ShardCount, - StartEpoch: i, - EndEpoch: i + 1, - } - committee, err := helpers.CrosslinkCommittee(bState, i, crosslink.Shard) + committee, err := helpers.BeaconCommittee(bState, i, i%params.BeaconConfig().MaxCommitteesPerSlot) if err != nil { t.Fatal(err) } committeeSize := uint64(len(committee)) attData1 := ðpb.AttestationData{ - Crosslink: crosslink, Target: ðpb.Checkpoint{ Epoch: i, Root: params.BeaconConfig().ZeroHash[:], @@ -231,12 +225,11 @@ func generateAttesterSlashings( if err != nil { t.Fatal(err) } - domain := helpers.Domain(bState.Fork, i, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(bState.Fork, i, params.BeaconConfig().DomainBeaconAttester) sig := privs[committee[i]].Sign(dataRoot[:], domain) att1.Signature = bls.AggregateSignatures([]*bls.Signature{sig}).Marshal() attData2 := ðpb.AttestationData{ - Crosslink: crosslink, Target: ðpb.Checkpoint{ Epoch: i, Root: params.BeaconConfig().ZeroHash[:], @@ -297,44 +290,10 @@ func generateAttestations( currentEpoch := helpers.CurrentEpoch(bState) attestations := make([]*ethpb.Attestation, maxAttestations) - committeeCount, err := helpers.CommitteeCount(bState, currentEpoch) + committee, err := helpers.BeaconCommittee(bState, currentEpoch, 0) if err != nil { t.Fatal(err) } - committeesPerSlot := committeeCount / params.BeaconConfig().SlotsPerEpoch - offSet := committeesPerSlot * (bState.Slot % params.BeaconConfig().SlotsPerEpoch) - startShard, err := helpers.StartShard(bState, currentEpoch) - if err != nil { - t.Fatal(err) - } - shard := (startShard + offSet) % params.BeaconConfig().ShardCount - - parentCrosslink := bState.CurrentCrosslinks[shard] - endEpoch := parentCrosslink.EndEpoch + params.BeaconConfig().MaxEpochsPerCrosslink - if currentEpoch < endEpoch { - endEpoch = currentEpoch - } - parentRoot, err := ssz.HashTreeRoot(parentCrosslink) - if err != nil { - t.Fatal(err) - } - crosslink := ðpb.Crosslink{ - Shard: shard, - StartEpoch: parentCrosslink.EndEpoch, - EndEpoch: endEpoch, - ParentRoot: parentRoot[:], - DataRoot: params.BeaconConfig().ZeroHash[:], - } - committee, err := helpers.CrosslinkCommittee(bState, currentEpoch, shard) - if err != nil { - t.Fatal(err) - } - committeeSize := uint64(len(committee)) - crosslinkParentRoot, err := ssz.HashTreeRoot(parentCrosslink) - if err != nil { - panic(err) - } - crosslink.ParentRoot = crosslinkParentRoot[:] headRoot, err := helpers.BlockRootAtSlot(headState, bState.Slot) if err != nil { @@ -352,11 +311,17 @@ func generateAttestations( } } + committeeSize := uint64(len(committee)) custodyBits := bitfield.NewBitlist(committeeSize) + attestingSlot := uint64(0) + if bState.Slot > 0 { + attestingSlot = bState.Slot - 1 + } + att := ðpb.Attestation{ Data: ðpb.AttestationData{ + Slot: attestingSlot, BeaconBlockRoot: headRoot, - Crosslink: crosslink, Source: bState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ Epoch: currentEpoch, @@ -383,7 +348,7 @@ func generateAttestations( } bitsPerAtt := committeeSize / maxAttestations - domain := helpers.Domain(bState.Fork, parentCrosslink.EndEpoch+1, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(bState.Fork, currentEpoch, params.BeaconConfig().DomainBeaconAttester) for i := uint64(0); i < committeeSize; i += bitsPerAtt { aggregationBits := bitfield.NewBitlist(committeeSize) sigs := []*bls.Signature{} diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index 56a6cf79b6..5fc083edf2 100644 --- a/shared/testutil/block_test.go +++ b/shared/testutil/block_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -32,6 +33,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { } func TestGenerateFullBlock_ThousandValidators(t *testing.T) { + helpers.ClearAllCaches() params.OverrideBeaconConfig(params.MinimalSpecConfig()) defer params.OverrideBeaconConfig(params.MainnetConfig()) deposits, _, privs := SetupInitialDeposits(t, 1024) @@ -55,10 +57,11 @@ func TestGenerateFullBlock_ThousandValidators(t *testing.T) { } func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { + helpers.ClearAllCaches() // Changing to minimal config as this will process 4 epochs of blocks. params.OverrideBeaconConfig(params.MinimalSpecConfig()) defer params.OverrideBeaconConfig(params.MainnetConfig()) - deposits, _, privs := SetupInitialDeposits(t, 128) + deposits, _, privs := SetupInitialDeposits(t, 32) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -94,7 +97,8 @@ func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { } func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + deposits, _, privs := SetupInitialDeposits(t, 257) + eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -120,7 +124,7 @@ func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { } func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + deposits, _, privs := SetupInitialDeposits(t, 256) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -146,7 +150,9 @@ func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { } func TestGenerateFullBlock_ValidAttestations(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + helpers.ClearAllCaches() + deposits, _, privs := SetupInitialDeposits(t, 256) + eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -172,13 +178,13 @@ func TestGenerateFullBlock_ValidAttestations(t *testing.T) { } func TestGenerateFullBlock_ValidDeposits(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + deposits, _, privs := SetupInitialDeposits(t, 256) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { t.Fatal(err) } - deposits, _, privs = SetupInitialDeposits(t, 129) + deposits, _, privs = SetupInitialDeposits(t, 257) eth1Data = GenerateEth1Data(t, deposits) beaconState.Eth1Data = eth1Data conf := &BlockGenConfig{ @@ -206,7 +212,7 @@ func TestGenerateFullBlock_ValidDeposits(t *testing.T) { } func TestGenerateFullBlock_ValidVoluntaryExits(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + deposits, _, privs := SetupInitialDeposits(t, 256) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { diff --git a/shared/testutil/helpers.go b/shared/testutil/helpers.go index 7a8d73fa29..0ea57de570 100644 --- a/shared/testutil/helpers.go +++ b/shared/testutil/helpers.go @@ -171,4 +171,5 @@ func ResetCache() { trie = nil privKeys = []*bls.SecretKey{} deposits = []*ethpb.Deposit{} + depositDataRoots = [][32]byte{} } diff --git a/shared/testutil/helpers_test.go b/shared/testutil/helpers_test.go index e4b8715124..cf9284a4eb 100644 --- a/shared/testutil/helpers_test.go +++ b/shared/testutil/helpers_test.go @@ -78,6 +78,8 @@ func TestSetupInitialDeposits(t *testing.T) { } func TestSignBlock(t *testing.T) { + helpers.ClearAllCaches() + deposits, _, privKeys := SetupInitialDeposits(t, 100) validators := make([]*ethpb.Validator, len(deposits)) for i := 0; i < len(validators); i++ { @@ -93,9 +95,8 @@ func TestSignBlock(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } block := ðpb.BeaconBlock{ @@ -140,9 +141,8 @@ func TestCreateRandaoReveal(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } epoch := helpers.CurrentEpoch(beaconState) diff --git a/shared/trieutil/sparse_merkle_test.go b/shared/trieutil/sparse_merkle_test.go index b3a7d4e462..60f31088a4 100644 --- a/shared/trieutil/sparse_merkle_test.go +++ b/shared/trieutil/sparse_merkle_test.go @@ -1,9 +1,7 @@ package trieutil import ( - "math/big" "reflect" - "strconv" "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -91,7 +89,7 @@ func TestMerkleTrieRoot_EmptyTrie(t *testing.T) { t.Fatal(err) } - depRoot, err := testAccount.Contract.GetHashTreeRoot(&bind.CallOpts{}) + depRoot, err := testAccount.Contract.GetDepositRoot(&bind.CallOpts{}) if err != nil { t.Fatal(err) } @@ -211,137 +209,3 @@ func BenchmarkVerifyMerkleBranch(b *testing.B) { } } } - -func TestDepositTrieRoot_OK(t *testing.T) { - testAcc, err := contracts.Setup() - if err != nil { - t.Fatal(err) - } - - localTrie, err := NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(err) - } - - depRoot, err := testAcc.Contract.GetHashTreeRoot(&bind.CallOpts{}) - if err != nil { - t.Fatal(err) - } - - if depRoot != localTrie.HashTreeRoot() { - t.Errorf("Local deposit trie root and contract deposit trie root are not equal. Expected %#x , Got %#x", depRoot, localTrie.Root()) - } - - var pubkey [48]byte - var withdrawalCreds [32]byte - var sig [96]byte - - data := ðpb.Deposit_Data{ - PublicKey: pubkey[:], - Signature: sig[:], - WithdrawalCredentials: withdrawalCreds[:], - Amount: big.NewInt(0).Div(contracts.Amount32Eth(), big.NewInt(1e9)).Uint64(), // In Gwei - } - - testAcc.TxOpts.Value = contracts.Amount32Eth() - testAcc.TxOpts.GasLimit = 1000000 - - for i := 0; i < 100; i++ { - copy(data.PublicKey, []byte(strconv.Itoa(i))) - copy(data.WithdrawalCredentials, []byte(strconv.Itoa(i))) - copy(data.Signature, []byte(strconv.Itoa(i))) - - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { - t.Fatalf("Could not deposit to deposit contract %v", err) - } - - testAcc.Backend.Commit() - item, err := ssz.HashTreeRoot(data) - if err != nil { - t.Fatal(err) - } - - err = localTrie.InsertIntoTrie(item[:], i) - if err != nil { - t.Error(err) - } - - depRoot, err = testAcc.Contract.GetHashTreeRoot(&bind.CallOpts{}) - if err != nil { - t.Fatal(err) - } - - if depRoot != localTrie.HashTreeRoot() { - t.Errorf("Local deposit trie root and contract deposit trie root are not equal for index %d. Expected %#x , Got %#x", i, depRoot, localTrie.Root()) - } - } -} - -func TestDepositTrieRoot_Fail(t *testing.T) { - testAcc, err := contracts.Setup() - if err != nil { - t.Fatal(err) - } - - localTrie, err := NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(err) - } - - depRoot, err := testAcc.Contract.GetHashTreeRoot(&bind.CallOpts{}) - if err != nil { - t.Fatal(err) - } - - if depRoot != localTrie.HashTreeRoot() { - t.Errorf("Local deposit trie root and contract deposit trie root are not equal. Expected %#x , Got %#x", depRoot, localTrie.Root()) - } - - var pubkey [48]byte - var withdrawalCreds [32]byte - var sig [96]byte - - data := ðpb.Deposit_Data{ - PublicKey: pubkey[:], - Signature: sig[:], - WithdrawalCredentials: withdrawalCreds[:], - Amount: big.NewInt(0).Div(contracts.Amount32Eth(), big.NewInt(1e9)).Uint64(), // In Gwei - } - - testAcc.TxOpts.Value = contracts.Amount32Eth() - testAcc.TxOpts.GasLimit = 1000000 - - for i := 0; i < 100; i++ { - copy(data.PublicKey, []byte(strconv.Itoa(i))) - copy(data.WithdrawalCredentials, []byte(strconv.Itoa(i))) - copy(data.Signature, []byte(strconv.Itoa(i))) - - if _, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature); err != nil { - t.Fatalf("Could not deposit to deposit contract %v", err) - } - - copy(data.PublicKey, []byte(strconv.Itoa(i+10))) - copy(data.WithdrawalCredentials, []byte(strconv.Itoa(i+10))) - copy(data.Signature, []byte(strconv.Itoa(i+10))) - - testAcc.Backend.Commit() - item, err := ssz.HashTreeRoot(data) - if err != nil { - t.Fatal(err) - } - - err = localTrie.InsertIntoTrie(item[:], i) - if err != nil { - t.Error(err) - } - - depRoot, err = testAcc.Contract.GetHashTreeRoot(&bind.CallOpts{}) - if err != nil { - t.Fatal(err) - } - - if depRoot == localTrie.HashTreeRoot() { - t.Errorf("Local deposit trie root and contract deposit trie root are equal for index %d when they were expected to be not equal", i) - } - } -} diff --git a/slasher/db/BUILD.bazel b/slasher/db/BUILD.bazel index 8aa70a1e2c..b9e9f97e1d 100644 --- a/slasher/db/BUILD.bazel +++ b/slasher/db/BUILD.bazel @@ -30,7 +30,7 @@ go_test( srcs = [ "block_header_test.go", "indexed_attestations_test.go", - "min_max-span_test.go", + "min_max_span_test.go", "setup_db_test.go", "validator_id_pubkey_test.go", ], diff --git a/slasher/db/indexed_attestations_test.go b/slasher/db/indexed_attestations_test.go index a141d2b665..7e07dad16e 100644 --- a/slasher/db/indexed_attestations_test.go +++ b/slasher/db/indexed_attestations_test.go @@ -19,27 +19,18 @@ func init() { iA: ðpb.IndexedAttestation{Signature: []byte("let me in"), CustodyBit_0Indices: []uint64{0}, Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 1}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, { iA: ðpb.IndexedAttestation{Signature: []byte("let me in 2nd"), CustodyBit_0Indices: []uint64{1, 2}, Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 2}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, { iA: ðpb.IndexedAttestation{Signature: []byte("let me in 3rd"), CustodyBit_0Indices: []uint64{0}, Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 1}, Target: ðpb.Checkpoint{Epoch: 2}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, } diff --git a/slasher/db/min_max-span_test.go b/slasher/db/min_max_span_test.go similarity index 99% rename from slasher/db/min_max-span_test.go rename to slasher/db/min_max_span_test.go index b8a5ab3441..d114b0e553 100644 --- a/slasher/db/min_max-span_test.go +++ b/slasher/db/min_max_span_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/gogo/protobuf/proto" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" ) diff --git a/slasher/rpc/server_test.go b/slasher/rpc/server_test.go index b3bfeed38c..cb040aaab6 100644 --- a/slasher/rpc/server_test.go +++ b/slasher/rpc/server_test.go @@ -121,7 +121,7 @@ func TestServer_DoubleBlock(t *testing.T) { } -func TestServer_SameEpochDifferentSlotSlashable(t *testing.T) { +func TestServer_SameSlotSlashable(t *testing.T) { dbs := db.SetupSlasherDB(t) defer db.TeardownSlasherDB(t, dbs) ctx := context.Background() @@ -138,7 +138,7 @@ func TestServer_SameEpochDifferentSlotSlashable(t *testing.T) { } psr2 := ðpb.ProposerSlashingRequest{ BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 63, + Slot: 1, StateRoot: []byte("B"), }, ValidatorIndex: 1, diff --git a/tools/cluster-pk-manager/server/server.go b/tools/cluster-pk-manager/server/server.go index 0d58b3aede..864fb4d769 100644 --- a/tools/cluster-pk-manager/server/server.go +++ b/tools/cluster-pk-manager/server/server.go @@ -64,11 +64,11 @@ func newServer( } } -func (s *server) makeDeposit(pubkey []byte, withdrawalCredentials []byte, signature []byte) error { +func (s *server) makeDeposit(pubkey []byte, withdrawalCredentials []byte, signature []byte, depositRoot [32]byte) error { txOps := bind.NewKeyedTransactor(s.txPk) txOps.Value = s.depositAmount txOps.GasLimit = gasLimit - tx, err := s.contract.Deposit(txOps, pubkey, withdrawalCredentials, signature) + tx, err := s.contract.Deposit(txOps, pubkey, withdrawalCredentials, signature, depositRoot) if err != nil { return errors.Wrap(err, "deposit failed") } @@ -141,13 +141,13 @@ func (s *server) allocateNewKeys(ctx context.Context, podName string, numKeys in // Make the validator deposit // NOTE: This uses the validator key as the withdrawal key - di, err := keystore.DepositInput(key /*depositKey*/, key /*withdrawalKey*/, new(big.Int).Div(s.depositAmount, big.NewInt(1e9)).Uint64()) + di, dr, err := keystore.DepositInput(key /*depositKey*/, key /*withdrawalKey*/, new(big.Int).Div(s.depositAmount, big.NewInt(1e9)).Uint64()) if err != nil { return nil, err } // Do the actual deposit - if err := s.makeDeposit(di.PublicKey, di.WithdrawalCredentials, di.Signature); err != nil { + if err := s.makeDeposit(di.PublicKey, di.WithdrawalCredentials, di.Signature, dr); err != nil { return nil, err } // Store in database diff --git a/validator/accounts/account.go b/validator/accounts/account.go index fe7e3b7580..0b07a81a72 100644 --- a/validator/accounts/account.go +++ b/validator/accounts/account.go @@ -82,7 +82,7 @@ func NewValidatorAccount(directory string, password string) error { validatorKeyFile, ).Info("Keystore generated for validator signatures at path") - data, err := keystore.DepositInput(validatorKey, shardWithdrawalKey, params.BeaconConfig().MaxEffectiveBalance) + data, depositRoot, err := keystore.DepositInput(validatorKey, shardWithdrawalKey, params.BeaconConfig().MaxEffectiveBalance) if err != nil { return errors.Wrap(err, "unable to generate deposit data") } @@ -92,7 +92,7 @@ func NewValidatorAccount(directory string, password string) error { } testAcc.TxOpts.GasLimit = 1000000 - tx, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature) + tx, err := testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoot) if err != nil { return errors.Wrap(err, "unable to create deposit transaction") } diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 2f55d75087..1c31064320 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -62,7 +62,6 @@ go_test( "//shared/testutil:go_default_library", "//validator/accounts:go_default_library", "//validator/internal:go_default_library", - "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_gogo_protobuf//types:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", diff --git a/validator/client/runner.go b/validator/client/runner.go index e87ce25e71..42768c14d2 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -93,10 +93,12 @@ func run(ctx context.Context, v Validator) { "role": role, }) switch role { + case pb.ValidatorRole_BOTH: + go v.AttestToBlockHead(slotCtx, slot, id) + v.ProposeBlock(slotCtx, slot, id) case pb.ValidatorRole_ATTESTER: v.AttestToBlockHead(slotCtx, slot, id) case pb.ValidatorRole_PROPOSER: - go v.AttestToBlockHead(slotCtx, slot, id) v.ProposeBlock(slotCtx, slot, id) case pb.ValidatorRole_UNKNOWN: log.Debug("No active role, doing nothing") diff --git a/validator/client/runner_test.go b/validator/client/runner_test.go index 4d1b473bd2..d828d8a816 100644 --- a/validator/client/runner_test.go +++ b/validator/client/runner_test.go @@ -162,7 +162,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) { slot := uint64(55) ticker := make(chan uint64) v.NextSlotRet = ticker - v.RoleAtRet = pb.ValidatorRole_PROPOSER + v.RoleAtRet = pb.ValidatorRole_BOTH go func() { ticker <- slot diff --git a/validator/client/validator.go b/validator/client/validator.go index daab8daf7e..3934ab2712 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -244,10 +244,10 @@ func (v *validator) UpdateAssignments(ctx context.Context, slot uint64) error { "status": assignment.Status, } if assignment.Status == pb.ValidatorStatus_ACTIVE { - if assignment.IsProposer { - lFields["proposerSlot"] = assignment.Slot + if assignment.ProposerSlot > 0 { + lFields["proposerSlot"] = assignment.ProposerSlot } - lFields["attesterSlot"] = assignment.Slot + lFields["attesterSlot"] = assignment.AttesterSlot } log.WithFields(lFields).Info("New assignment") } @@ -263,17 +263,16 @@ func (v *validator) RolesAt(slot uint64) map[[48]byte]pb.ValidatorRole { rolesAt := make(map[[48]byte]pb.ValidatorRole) for _, assignment := range v.assignments.ValidatorAssignment { var role pb.ValidatorRole - if assignment == nil { + switch { + case assignment == nil: role = pb.ValidatorRole_UNKNOWN - } - if assignment.Slot == slot { - // Note: A proposer also attests to the slot. - if assignment.IsProposer { - role = pb.ValidatorRole_PROPOSER - } else { - role = pb.ValidatorRole_ATTESTER - } - } else { + case assignment.ProposerSlot == slot && assignment.AttesterSlot == slot: + role = pb.ValidatorRole_BOTH + case assignment.AttesterSlot == slot: + role = pb.ValidatorRole_ATTESTER + case assignment.ProposerSlot == slot: + role = pb.ValidatorRole_PROPOSER + default: role = pb.ValidatorRole_UNKNOWN } var pubKey [48]byte diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index 181f724608..0d40becf40 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -29,8 +29,7 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ span.AddAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey))) log := log.WithField("pubKey", fmt.Sprintf("%#x", bytesutil.Trunc(pubKey[:]))) - // We fetch the validator index as it is necessary to generate the aggregation - // bitfield of the attestation itself. + // Fetch the validator index to generate the aggregation bitfield var assignment *pb.AssignmentResponse_ValidatorAssignment if v.assignments == nil { log.Errorf("No assignments for validators") @@ -54,8 +53,8 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ v.waitToSlotMidpoint(ctx, slot) req := &pb.AttestationRequest{ - Slot: slot, - Shard: assignment.Shard, + Slot: slot, + CommitteeIndex: assignment.CommitteeIndex, } data, err := v.attesterClient.RequestAttestation(ctx, req) if err != nil { @@ -63,6 +62,8 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ slot, err) return } + log = log.WithField("slot", data.Slot) + log = log.WithField("committeeIndex", data.Index) custodyBitfield := bitfield.NewBitlist(uint64(len(assignment.Committee))) @@ -79,7 +80,7 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ aggregationBitfield := bitfield.NewBitlist(uint64(len(assignment.Committee))) aggregationBitfield.SetBitAt(indexInCommittee, true) - domain, err := v.validatorClient.DomainData(ctx, &pb.DomainRequest{Epoch: data.Target.Epoch, Domain: params.BeaconConfig().DomainAttestation}) + domain, err := v.validatorClient.DomainData(ctx, &pb.DomainRequest{Epoch: data.Target.Epoch, Domain: params.BeaconConfig().DomainBeaconAttester}) if err != nil { log.WithError(err).Error("Failed to get domain data from beacon node") return @@ -116,7 +117,7 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ span.AddAttributes( trace.Int64Attribute("slot", int64(slot)), trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.Root)), - trace.Int64Attribute("shard", int64(data.Crosslink.Shard)), + trace.Int64Attribute("committeeIndex", int64(data.Index)), trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), diff --git a/validator/client/validator_attest_test.go b/validator/client/validator_attest_test.go index f9df738564..90b8125d95 100644 --- a/validator/client/validator_attest_test.go +++ b/validator/client/validator_attest_test.go @@ -3,14 +3,14 @@ package client import ( "context" "errors" + "reflect" "sync" "testing" "time" - "github.com/gogo/protobuf/proto" "github.com/golang/mock/gomock" - bitfield "github.com/prysmaticlabs/go-bitfield" - ssz "github.com/prysmaticlabs/go-ssz" + "github.com/prysmaticlabs/go-bitfield" + "github.com/prysmaticlabs/go-ssz" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" @@ -41,8 +41,8 @@ func TestAttestToBlockHead_RequestAttestationFailure(t *testing.T) { defer finish() validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - PublicKey: validatorKey.PublicKey.Marshal(), - Shard: 5, + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 5, }, }} m.validatorClient.EXPECT().ValidatorIndex( @@ -65,9 +65,9 @@ func TestAttestToBlockHead_SubmitAttestationRequestFailure(t *testing.T) { defer finish() validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - PublicKey: validatorKey.PublicKey.Marshal(), - Shard: 5, - Committee: make([]uint64, 111), + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 5, + Committee: make([]uint64, 111), }}} m.validatorClient.EXPECT().ValidatorIndex( gomock.Any(), // ctx @@ -82,7 +82,6 @@ func TestAttestToBlockHead_SubmitAttestationRequestFailure(t *testing.T) { BeaconBlockRoot: []byte{}, Target: ðpb.Checkpoint{}, Source: ðpb.Checkpoint{}, - Crosslink: ðpb.Crosslink{}, }, nil) m.validatorClient.EXPECT().DomainData( gomock.Any(), // ctx @@ -106,9 +105,9 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) { committee := []uint64{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - PublicKey: validatorKey.PublicKey.Marshal(), - Shard: 5, - Committee: committee, + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 5, + Committee: committee, }}} m.validatorClient.EXPECT().ValidatorIndex( gomock.Any(), // ctx @@ -123,7 +122,6 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) { BeaconBlockRoot: []byte("A"), Target: ðpb.Checkpoint{Root: []byte("B")}, Source: ðpb.Checkpoint{Root: []byte("C"), Epoch: 3}, - Crosslink: ðpb.Crosslink{Shard: 5, DataRoot: []byte{'D'}}, }, nil) m.validatorClient.EXPECT().DomainData( @@ -149,7 +147,6 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) { BeaconBlockRoot: []byte("A"), Target: ðpb.Checkpoint{Root: []byte("B")}, Source: ðpb.Checkpoint{Root: []byte("C"), Epoch: 3}, - Crosslink: ðpb.Crosslink{Shard: 5, DataRoot: []byte{'D'}}, }, AggregationBits: aggregationBitfield, CustodyBits: custodyBitfield, @@ -166,8 +163,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) { sig := validator.keys[validatorPubKey].SecretKey.Sign(root[:], 0).Marshal() expectedAttestation.Signature = sig - - if !proto.Equal(generatedAttestation, expectedAttestation) { + if !reflect.DeepEqual(generatedAttestation, expectedAttestation) { t.Errorf("Incorrectly attested head, wanted %v, received %v", expectedAttestation, generatedAttestation) } testutil.AssertLogsContain(t, hook, "Submitted new attestation") @@ -217,9 +213,9 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) { committee := []uint64{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - PublicKey: validatorKey.PublicKey.Marshal(), - Shard: 5, - Committee: committee, + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 5, + Committee: committee, }}} m.attesterClient.EXPECT().RequestAttestation( @@ -229,7 +225,6 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) { BeaconBlockRoot: []byte("A"), Target: ðpb.Checkpoint{Root: []byte("B")}, Source: ðpb.Checkpoint{Root: []byte("C"), Epoch: 3}, - Crosslink: ðpb.Crosslink{DataRoot: []byte{'D'}}, }, nil).Do(func(arg0, arg1 interface{}) { wg.Done() }) @@ -263,9 +258,9 @@ func TestAttestToBlockHead_CorrectBitfieldLength(t *testing.T) { committee := []uint64{0, 3, 4, 2, validatorIndex, 6, 8, 9, 10} validator.assignments = &pb.AssignmentResponse{ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - PublicKey: validatorKey.PublicKey.Marshal(), - Shard: 5, - Committee: committee, + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 5, + Committee: committee, }}} m.validatorClient.EXPECT().ValidatorIndex( gomock.Any(), // ctx @@ -277,9 +272,8 @@ func TestAttestToBlockHead_CorrectBitfieldLength(t *testing.T) { gomock.Any(), // ctx gomock.AssignableToTypeOf(&pb.AttestationRequest{}), ).Return(ðpb.AttestationData{ - Target: ðpb.Checkpoint{Root: []byte("B")}, - Source: ðpb.Checkpoint{Root: []byte("C"), Epoch: 3}, - Crosslink: ðpb.Crosslink{DataRoot: []byte{'D'}}, + Target: ðpb.Checkpoint{Root: []byte("B")}, + Source: ðpb.Checkpoint{Root: []byte("C"), Epoch: 3}, }, nil) m.validatorClient.EXPECT().DomainData( diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 334764de59..bd13cb18c6 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -460,9 +460,9 @@ func TestUpdateAssignments_DoesNothingWhenNotEpochStartAndAlreadyExistingAssignm assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Committee: []uint64{}, - Slot: 10, - Shard: 20, + Committee: []uint64{}, + AttesterSlot: 10, + CommitteeIndex: 20, }, }, }, @@ -488,7 +488,7 @@ func TestUpdateAssignments_ReturnsError(t *testing.T) { assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Shard: 1, + CommitteeIndex: 1, }, }, }, @@ -518,11 +518,11 @@ func TestUpdateAssignments_OK(t *testing.T) { resp := &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Slot: params.BeaconConfig().SlotsPerEpoch, - Shard: 100, - Committee: []uint64{0, 1, 2, 3}, - IsProposer: true, - PublicKey: []byte("testPubKey_1"), + AttesterSlot: params.BeaconConfig().SlotsPerEpoch, + CommitteeIndex: 100, + Committee: []uint64{0, 1, 2, 3}, + PublicKey: []byte("testPubKey_1"), + ProposerSlot: params.BeaconConfig().SlotsPerEpoch + 1, }, }, } @@ -538,15 +538,14 @@ func TestUpdateAssignments_OK(t *testing.T) { if err := v.UpdateAssignments(context.Background(), slot); err != nil { t.Fatalf("Could not update assignments: %v", err) } - - if v.assignments.ValidatorAssignment[0].Slot != params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Unexpected validator assignments. want=%v got=%v", params.BeaconConfig().SlotsPerEpoch, v.assignments.ValidatorAssignment[0].Slot) + if v.assignments.ValidatorAssignment[0].ProposerSlot != params.BeaconConfig().SlotsPerEpoch+1 { + t.Errorf("Unexpected validator assignments. want=%v got=%v", params.BeaconConfig().SlotsPerEpoch+1, v.assignments.ValidatorAssignment[0].ProposerSlot) } - if v.assignments.ValidatorAssignment[0].Shard != resp.ValidatorAssignment[0].Shard { - t.Errorf("Unexpected validator assignments. want=%v got=%v", resp.ValidatorAssignment[0].Shard, v.assignments.ValidatorAssignment[0].Slot) + if v.assignments.ValidatorAssignment[0].AttesterSlot != params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Unexpected validator assignments. want=%v got=%v", params.BeaconConfig().SlotsPerEpoch, v.assignments.ValidatorAssignment[0].AttesterSlot) } - if !v.assignments.ValidatorAssignment[0].IsProposer { - t.Errorf("Unexpected validator assignments. want: proposer=true") + if v.assignments.ValidatorAssignment[0].CommitteeIndex != resp.ValidatorAssignment[0].CommitteeIndex { + t.Errorf("Unexpected validator assignments. want=%v got=%v", resp.ValidatorAssignment[0].CommitteeIndex, v.assignments.ValidatorAssignment[0].CommitteeIndex) } } @@ -556,33 +555,40 @@ func TestRolesAt_OK(t *testing.T) { assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Shard: 1, - Slot: 1, - IsProposer: true, - PublicKey: []byte{0x01}, + CommitteeIndex: 1, + AttesterSlot: 1, + PublicKey: []byte{0x01}, }, { - Shard: 2, - Slot: 1, - PublicKey: []byte{0x02}, + CommitteeIndex: 2, + ProposerSlot: 1, + PublicKey: []byte{0x02}, }, { - Shard: 1, - Slot: 2, - PublicKey: []byte{0x03}, + CommitteeIndex: 1, + AttesterSlot: 2, + PublicKey: []byte{0x03}, + }, + { + CommitteeIndex: 2, + AttesterSlot: 1, + ProposerSlot: 1, + PublicKey: []byte{0x04}, }, }, }, } roleMap := v.RolesAt(1) - if roleMap[[48]byte{0x01}] != pb.ValidatorRole_PROPOSER { + if roleMap[[48]byte{0x01}] != pb.ValidatorRole_ATTESTER { t.Errorf("Unexpected validator role. want: ValidatorRole_PROPOSER") } - if roleMap[[48]byte{0x02}] != pb.ValidatorRole_ATTESTER { + if roleMap[[48]byte{0x02}] != pb.ValidatorRole_PROPOSER { t.Errorf("Unexpected validator role. want: ValidatorRole_ATTESTER") } if roleMap[[48]byte{0x03}] != pb.ValidatorRole_UNKNOWN { t.Errorf("Unexpected validator role. want: UNKNOWN") } - + if roleMap[[48]byte{0x04}] != pb.ValidatorRole_BOTH { + t.Errorf("Unexpected validator role. want: BOTH") + } }