From b3714e801f376c387755f6c1a358a4f75bf3b16a Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 29 Oct 2019 08:44:06 -0700 Subject: [PATCH 01/82] Update seed domains (#3872) --- beacon-chain/archiver/BUILD.bazel | 1 + beacon-chain/archiver/service.go | 3 +- beacon-chain/archiver/service_test.go | 2 +- .../forkchoice/process_attestation_test.go | 2 +- beacon-chain/core/blocks/block_operations.go | 2 +- .../core/blocks/block_operations_test.go | 21 +++++---- .../spectest/attestation_mainnet_test.go | 1 + .../spectest/attestation_minimal_test.go | 2 + .../attester_slashing_mainnet_test.go | 1 + .../attester_slashing_minimal_test.go | 2 + .../spectest/block_header_mainnet_test.go | 1 + .../spectest/block_header_minimal_test.go | 2 + .../spectest/block_processing_mainnet_test.go | 1 + .../spectest/block_processing_minimal_test.go | 1 + .../proposer_slashing_mainnet_test.go | 1 + .../proposer_slashing_minimal_test.go | 2 + beacon-chain/core/epoch/epoch_processing.go | 2 +- .../core/epoch/epoch_processing_test.go | 34 +++++++------- .../epoch/precompute/reward_penalty_test.go | 6 +-- .../epoch/spectest/crosslink_mainnet_test.go | 1 + .../spectest/final_updates_mainnet_test.go | 1 + .../spectest/final_updates_minimal_test.go | 2 + ...ification_and_finalization_mainnet_test.go | 1 + .../epoch/spectest/registry_mainnet_test.go | 1 + .../epoch/spectest/slashings_mainnet_test.go | 1 + beacon-chain/core/helpers/committee.go | 4 +- beacon-chain/core/helpers/committee_test.go | 46 +++++++++---------- beacon-chain/core/helpers/randao.go | 22 +++------ beacon-chain/core/helpers/randao_test.go | 8 ++-- beacon-chain/core/helpers/validators.go | 6 +-- beacon-chain/core/helpers/validators_test.go | 12 ++--- .../state/minimal_config_consensus_test.go | 2 + .../spectest/slot_processing_mainnet_test.go | 1 + .../spectest/slot_processing_minimal_test.go | 1 + beacon-chain/core/state/transition_test.go | 6 +-- beacon-chain/operations/attestation_test.go | 8 ++-- beacon-chain/rpc/beacon_chain_server_test.go | 3 +- .../sync/validate_attester_slashing_test.go | 2 +- shared/params/config.go | 26 +++++------ shared/testutil/block.go | 4 +- validator/client/validator_attest.go | 2 +- 41 files changed, 134 insertions(+), 113 deletions(-) diff --git a/beacon-chain/archiver/BUILD.bazel b/beacon-chain/archiver/BUILD.bazel index 74c659afa771..5a4335425e3b 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 1feb69b7cb3a..8cec5ef0c836 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" ) @@ -72,7 +73,7 @@ func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.Beacon if err != nil { return errors.Wrap(err, "could not get committee count") } - seed, err := helpers.Seed(headState, currentEpoch) + seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { return errors.Wrap(err, "could not generate seed") } diff --git a/beacon-chain/archiver/service_test.go b/beacon-chain/archiver/service_test.go index 23cbc5ab0947..5e32d9a1cb15 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -136,7 +136,7 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(headState, currentEpoch) + seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/blockchain/forkchoice/process_attestation_test.go b/beacon-chain/blockchain/forkchoice/process_attestation_test.go index a4fc02c5f98e..5803af05b93e 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation_test.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation_test.go @@ -210,7 +210,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/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index 5f7dbe5b31e7..790a321d94a7 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -816,7 +816,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) diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 2b7ef5deb213..567efdabf930 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -781,7 +781,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}) @@ -1220,7 +1220,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) @@ -1249,7 +1249,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { 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")}, @@ -1344,7 +1344,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { 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")}, @@ -1519,20 +1519,20 @@ func TestConvertToIndexed_OK(t *testing.T) { { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x05}, - wantedCustodyBit0Indices: []uint64{71}, - wantedCustodyBit1Indices: []uint64{127}, + wantedCustodyBit0Indices: []uint64{28}, + wantedCustodyBit1Indices: []uint64{125}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x06}, - wantedCustodyBit0Indices: []uint64{127}, - wantedCustodyBit1Indices: []uint64{71}, + wantedCustodyBit0Indices: []uint64{125}, + wantedCustodyBit1Indices: []uint64{28}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x07}, wantedCustodyBit0Indices: []uint64{}, - wantedCustodyBit1Indices: []uint64{71, 127}, + wantedCustodyBit1Indices: []uint64{28, 125}, }, } @@ -1563,6 +1563,7 @@ func TestConvertToIndexed_OK(t *testing.T) { } if !reflect.DeepEqual(wanted, ia) { diff, _ := messagediff.PrettyDiff(ia, wanted) + fmt.Println(ia, wanted) t.Log(diff) t.Error("convert attestation to indexed attestation didn't result as wanted") } @@ -1640,7 +1641,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 { diff --git a/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go b/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go index 7bae9a8b5b15..32acc58924da 100644 --- a/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestAttestationMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runAttestationTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/attestation_minimal_test.go b/beacon-chain/core/blocks/spectest/attestation_minimal_test.go index 72ffb5332a2c..2608f587769b 100644 --- a/beacon-chain/core/blocks/spectest/attestation_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/attestation_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestAttestationMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runAttestationTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go b/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go index f6064a96e31e..af85fe41a2aa 100644 --- a/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestAttesterSlashingMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runAttesterSlashingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go b/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go index 52417e9f4f09..2c8223d9ba01 100644 --- a/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestAttesterSlashingMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runAttesterSlashingTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go b/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go index 625b6fdb19fc..cbefae1f918b 100644 --- a/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestBlockHeaderMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockHeaderTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/block_header_minimal_test.go b/beacon-chain/core/blocks/spectest/block_header_minimal_test.go index c5f9e572015c..6f31b4c7edf7 100644 --- a/beacon-chain/core/blocks/spectest/block_header_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/block_header_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestBlockHeaderMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runBlockHeaderTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go b/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go index e64d83a6cc44..32f84432e5b8 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestBlockProcessingMainnetYaml(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockProcessingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go b/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go index f8c72ac7861a..9c9530a351b0 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestBlockProcessingMinimalYaml(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockProcessingTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go b/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go index d18d5d4c369c..0776a640aee8 100644 --- a/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestProposerSlashingMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runProposerSlashingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go b/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go index a8504aa1859e..167cfc06b2db 100644 --- a/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestProposerSlashingMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runProposerSlashingTest(t, "minimal") } diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 74e6bb081a5c..41f086466938 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -495,7 +495,7 @@ func ProcessFinalUpdates(state *pb.BeaconState) (*pb.BeaconState, error) { // 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 + activationDelay := params.BeaconConfig().MaxSeedLookhead idxRootPosition := (nextEpoch + activationDelay) % params.BeaconConfig().EpochsPerHistoricalVector activeIndices, err := helpers.ActiveValidatorIndices(state, nextEpoch+activationDelay) if err != nil { diff --git a/beacon-chain/core/epoch/epoch_processing_test.go b/beacon-chain/core/epoch/epoch_processing_test.go index c1280b5ab3fb..34c4afc7ac77 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -919,7 +919,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { } // Verify latest active index root is correctly updated in the right position. - pos := (ne + params.BeaconConfig().ActivationExitDelay) % params.BeaconConfig().EpochsPerHistoricalVector + pos := (ne + params.BeaconConfig().MaxSeedLookhead) % params.BeaconConfig().EpochsPerHistoricalVector if bytes.Equal(newS.ActiveIndexRoots[pos], params.BeaconConfig().ZeroHash[:]) { t.Error("latest active index roots still zero hashes") } @@ -977,8 +977,8 @@ 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,9 +991,9 @@ 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) } } } @@ -1032,7 +1032,7 @@ func TestCrosslinkDelta_SomeAttested(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958} + attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654} for _, i := range attestedIndices { // Since all these validators attested, they should get the same rewards. want := uint64(12649) @@ -1210,7 +1210,7 @@ func TestAttestationDelta_SomeAttested(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389} for _, i := range attestedIndices { base, err := BaseReward(state, i) if err != nil { @@ -1293,7 +1293,7 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389} for _, i := range attestedIndices { base, err := BaseReward(state, i) if err != nil { @@ -1373,10 +1373,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{}, } @@ -1385,9 +1385,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) } } } @@ -1412,9 +1412,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) } } } @@ -1502,7 +1502,7 @@ func TestProcessRewardsAndPenalties_SomeAttested(t *testing.T) { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[0]) } - wanted = uint64(31999995452) + wanted = uint64(31999797616) if state.Balances[4] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[1]) diff --git a/beacon-chain/core/epoch/precompute/reward_penalty_test.go b/beacon-chain/core/epoch/precompute/reward_penalty_test.go index ead3c5d267de..14b8dc0da031 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -56,7 +56,7 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { } // Indices that voted everything except for head, lost a bit money - wanted := uint64(31999995452) + wanted := uint64(31999797616) if state.Balances[4] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[4]) @@ -118,7 +118,7 @@ func TestAttestationDeltaPrecompute(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192} + attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654} for _, i := range attestedIndices { base, err := epoch.BaseReward(state, i) if err != nil { @@ -198,7 +198,7 @@ func TestCrosslinkDeltaPrecompute(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958} + attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654} for _, i := range attestedIndices { // Since all these validators attested, they should get the same rewards. want := uint64(12649) diff --git a/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go b/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go index f9f7acde0b25..70d8989aef7f 100644 --- a/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestCrosslinksProcessingMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runCrosslinkProcessingTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go b/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go index eed594f43152..20a52d2f2368 100644 --- a/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestFinalUpdatesMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runFinalUpdatesTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go b/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go index f34daf532d01..ad76e54884b5 100644 --- a/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestFinalUpdatesMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runFinalUpdatesTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go b/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go index 6b63703f4d84..004b680fd9d8 100644 --- a/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestJustificationAndFinalizationMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runJustificationAndFinalizationTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/registry_mainnet_test.go b/beacon-chain/core/epoch/spectest/registry_mainnet_test.go index 8315eab08164..dbe0769c1c7b 100644 --- a/beacon-chain/core/epoch/spectest/registry_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/registry_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestRegistryUpdatesMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runRegistryUpdatesTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go b/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go index 9ae037af5be2..c1b5a61dfb60 100644 --- a/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestSlashingsMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runSlashingsTests(t, "mainnet") } diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index 20fdf0608ea4..921f6862142d 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -90,7 +90,7 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui } } - seed, err := Seed(state, epoch) + seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { return nil, errors.Wrap(err, "could not get seed") } @@ -483,7 +483,7 @@ func CompactCommitteesRoot(state *pb.BeaconState, epoch uint64) ([32]byte, error // 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) } diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index 0b6f90b21a03..8a5a358ef9cc 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -139,7 +139,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) } @@ -198,7 +198,7 @@ func TestComputeCommittee_WithCache(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) } @@ -251,19 +251,19 @@ func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { attestationSlot: 3, stateSlot: 5, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{219, 476}, + wanted: []uint64{205, 150}, }, { attestationSlot: 2, stateSlot: 10, bitfield: bitfield.Bitlist{0x05}, - wanted: []uint64{123}, + wanted: []uint64{845}, }, { attestationSlot: 11, stateSlot: 10, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{880, 757}, + wanted: []uint64{376, 664}, }, } @@ -358,31 +358,31 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { }{ { index: 0, - slot: 146, - committee: []uint64{0, 3}, - shard: 82, + slot: 144, + committee: []uint64{95, 0}, + shard: 80, isProposer: true, }, { index: 105, - slot: 160, - committee: []uint64{105, 20}, - shard: 32, + slot: 171, + committee: []uint64{50, 105}, + shard: 43, isProposer: true, }, { index: 0, - slot: 146, - committee: []uint64{0, 3}, - shard: 18, + slot: 144, + committee: []uint64{95, 0}, + shard: 16, isProposer: true, }, { index: 11, - slot: 135, - committee: []uint64{119, 11}, - shard: 7, - isProposer: false, + slot: 129, + committee: []uint64{22, 11}, + shard: 1, + isProposer: true, }, } @@ -904,7 +904,7 @@ 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) } @@ -943,7 +943,7 @@ 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) } @@ -982,7 +982,7 @@ 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) } @@ -1022,7 +1022,7 @@ 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) } @@ -1062,7 +1062,7 @@ 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) } diff --git a/beacon-chain/core/helpers/randao.go b/beacon-chain/core/helpers/randao.go index 4d05ce2bba73..c79336f132a0 100644 --- a/beacon-chain/core/helpers/randao.go +++ b/beacon-chain/core/helpers/randao.go @@ -15,32 +15,24 @@ 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 } diff --git a/beacon-chain/core/helpers/randao_test.go b/beacon-chain/core/helpers/randao_test.go index c0a71237a59f..5045df132309 100644 --- a/beacon-chain/core/helpers/randao_test.go +++ b/beacon-chain/core/helpers/randao_test.go @@ -111,7 +111,7 @@ func TestActiveIndexRoot_OK(t *testing.T) { } for _, test := range tests { state.Slot = (test.epoch) * params.BeaconConfig().SlotsPerEpoch - for i := 0; i <= int(params.BeaconConfig().ActivationExitDelay); i++ { + for i := 0; i <= int(params.BeaconConfig().MaxSeedLookhead); i++ { indexRoot := ActiveIndexRoot(state, test.epoch+uint64(i)) if !bytes.Equal(activeIndexRoots[(test.epoch+uint64(i))%params.BeaconConfig().EpochsPerHistoricalVector], indexRoot) { @@ -179,13 +179,13 @@ func TestGenerateSeed_OK(t *testing.T) { 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/validators.go b/beacon-chain/core/helpers/validators.go index e3c619b7ab7c..735a22b74297 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -135,7 +135,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 @@ -173,7 +173,7 @@ func ValidatorChurnLimit(state *pb.BeaconState) (uint64, error) { // shard = Shard((get_start_shard(state, epoch) + offset) % SHARD_COUNT) // first_committee = get_crosslink_committee(state, epoch, shard) // MAX_RANDOM_BYTE = 2**8 - 1 -// seed = get_seed(state, epoch) +// seed = get_seed(state, epoch, DOMAIN_BEACON_PROPOSER) // i = 0 // while True: // candidate_index = first_committee[(epoch + i) % len(first_committee)] @@ -212,7 +212,7 @@ func BeaconProposerIndex(state *pb.BeaconState) (uint64, error) { // Use the generated seed to select proposer from the first committee maxRandomByte := uint64(1<<8 - 1) - seed, err := Seed(state, e) + seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconProposer) if err != nil { return 0, errors.Wrap(err, "could not generate seed") } diff --git a/beacon-chain/core/helpers/validators_test.go b/beacon-chain/core/helpers/validators_test.go index 514f49685ef0..4e5c0c50442b 100644 --- a/beacon-chain/core/helpers/validators_test.go +++ b/beacon-chain/core/helpers/validators_test.go @@ -172,23 +172,23 @@ func TestBeaconProposerIndex_OK(t *testing.T) { }{ { slot: 1, - index: 254, + index: 534, }, { slot: 5, - index: 391, + index: 861, }, { slot: 19, - index: 204, + index: 1411, }, { slot: 30, - index: 1051, + index: 1621, }, { slot: 43, - index: 1047, + index: 1355, }, } @@ -226,7 +226,7 @@ func TestBeaconProposerIndex_EmptyCommittee(t *testing.T) { 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) } diff --git a/beacon-chain/core/state/minimal_config_consensus_test.go b/beacon-chain/core/state/minimal_config_consensus_test.go index 07cc160860c7..d5a7f133a319 100644 --- a/beacon-chain/core/state/minimal_config_consensus_test.go +++ b/beacon-chain/core/state/minimal_config_consensus_test.go @@ -13,6 +13,8 @@ import ( ) func TestConsensusBugs(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + tests := []struct { name string blockPath string diff --git a/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go b/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go index 3a20ade80e98..1261c2e9c6f8 100644 --- a/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go +++ b/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestSlotProcessingMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runSlotProcessingTests(t, "mainnet") } diff --git a/beacon-chain/core/state/spectest/slot_processing_minimal_test.go b/beacon-chain/core/state/spectest/slot_processing_minimal_test.go index f8200022c5b7..b0b84faaa906 100644 --- a/beacon-chain/core/state/spectest/slot_processing_minimal_test.go +++ b/beacon-chain/core/state/spectest/slot_processing_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestSlotProcessingMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runSlotProcessingTests(t, "minimal") } diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index 7b417cc6d87a..108532ca26e6 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -222,7 +222,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}) @@ -521,7 +521,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}) @@ -1082,7 +1082,7 @@ 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) diff --git a/beacon-chain/operations/attestation_test.go b/beacon-chain/operations/attestation_test.go index 8c05679339ac..3291c58c9e72 100644 --- a/beacon-chain/operations/attestation_test.go +++ b/beacon-chain/operations/attestation_test.go @@ -57,7 +57,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) @@ -173,7 +173,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 @@ -278,7 +278,7 @@ 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{ @@ -432,7 +432,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{} diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index a9be91fa9eb5..de5a0ce6de62 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -1251,6 +1251,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { } func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1308,7 +1309,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(s, currentEpoch) + seed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/sync/validate_attester_slashing_test.go b/beacon-chain/sync/validate_attester_slashing_test.go index a8deed108d64..9e9b16e8ef8b 100644 --- a/beacon-chain/sync/validate_attester_slashing_test.go +++ b/beacon-chain/sync/validate_attester_slashing_test.go @@ -44,7 +44,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}) diff --git a/shared/params/config.go b/shared/params/config.go index 4a41ae74b2b4..bba4f046a580 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -39,17 +39,17 @@ type BeaconChainConfig struct { // Time parameters constants. MinAttestationInclusionDelay uint64 `yaml:"MIN_ATTESTATION_INCLUSION_DELAY"` // MinAttestationInclusionDelay defines how many slots validator has to wait to include attestation for beacon block. - 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. - 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. + 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. + 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. + 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. // State list lengths EpochsPerHistoricalVector uint64 `yaml:"EPOCHS_PER_HISTORICAL_VECTOR"` // EpochsPerHistoricalVector defines max length in epoch to store old historical stats in beacon state. @@ -75,7 +75,7 @@ type BeaconChainConfig struct { // 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. @@ -139,7 +139,7 @@ var defaultBeaconConfig = &BeaconChainConfig{ SecondsPerSlot: 6, SlotsPerEpoch: 64, MinSeedLookahead: 1, - ActivationExitDelay: 4, + MaxSeedLookhead: 4, SlotsPerEth1VotingPeriod: 1024, SlotsPerHistoricalRoot: 8192, MinValidatorWithdrawabilityDelay: 256, @@ -171,8 +171,8 @@ var defaultBeaconConfig = &BeaconChainConfig{ // 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), @@ -265,7 +265,7 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.MinAttestationInclusionDelay = 1 minimalConfig.SlotsPerEpoch = 8 minimalConfig.MinSeedLookahead = 1 - minimalConfig.ActivationExitDelay = 4 + minimalConfig.MaxSeedLookhead = 4 minimalConfig.SlotsPerEth1VotingPeriod = 16 minimalConfig.SlotsPerHistoricalRoot = 64 minimalConfig.MinValidatorWithdrawabilityDelay = 256 @@ -298,7 +298,7 @@ func MinimalSpecConfig() *BeaconChainConfig { // Signature domains minimalConfig.DomainBeaconProposer = bytesutil.Bytes4(0) minimalConfig.DomainRandao = bytesutil.Bytes4(1) - minimalConfig.DomainAttestation = bytesutil.Bytes4(2) + minimalConfig.DomainBeaconAttester = bytesutil.Bytes4(2) minimalConfig.DomainDeposit = bytesutil.Bytes4(3) minimalConfig.DomainVoluntaryExit = bytesutil.Bytes4(4) minimalConfig.DomainTransfer = bytesutil.Bytes4(5) diff --git a/shared/testutil/block.go b/shared/testutil/block.go index a2d1e1ab01fb..92a11cbfa597 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -215,7 +215,7 @@ 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() @@ -367,7 +367,7 @@ func generateAttestations( } bitsPerAtt := committeeSize / maxAttestations - domain := helpers.Domain(bState.Fork, parentCrosslink.EndEpoch+1, params.BeaconConfig().DomainAttestation) + domain := helpers.Domain(bState.Fork, parentCrosslink.EndEpoch+1, params.BeaconConfig().DomainBeaconAttester) for i := uint64(0); i < committeeSize; i += bitsPerAtt { aggregationBits := bitfield.NewBitlist(committeeSize) sigs := []*bls.Signature{} diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index 181f7246082a..5e8e24267874 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -79,7 +79,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 From 8eebd524ff3d4fe3966c40d6d104ac92495732b3 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 29 Oct 2019 10:27:34 -0700 Subject: [PATCH 02/82] Remove Transfers (#3870) --- beacon-chain/core/blocks/BUILD.bazel | 1 - beacon-chain/core/blocks/block_operations.go | 124 ---- .../core/blocks/block_operations_test.go | 201 ------ beacon-chain/core/state/BUILD.bazel | 1 - beacon-chain/core/state/transition.go | 43 -- beacon-chain/core/state/transition_test.go | 66 -- beacon-chain/rpc/proposer_server.go | 1 - proto/beacon/db/attestation_container.pb.go | 5 +- proto/beacon/p2p/v1/messages.pb.go | 5 +- proto/beacon/p2p/v1/types.pb.go | 5 +- proto/beacon/rpc/v1/services.pb.go | 5 +- proto/beacon/rpc/v1_gateway/services.pb.go | 3 +- .../_compatibility/compatability_test.go | 6 +- proto/eth/v1alpha1/archive.pb.go | 5 +- proto/eth/v1alpha1/attestation.pb.go | 5 +- proto/eth/v1alpha1/beacon_block.pb.go | 611 ++---------------- proto/eth/v1alpha1/beacon_block.proto | 28 - proto/eth/v1alpha1/beacon_chain.pb.go | 5 +- proto/eth/v1alpha1/node.pb.go | 5 +- proto/eth/v1alpha1/slasher.pb.go | 5 +- proto/eth/v1alpha1/validator.pb.go | 5 +- proto/sharding/p2p/v1/messages.pb.go | 3 +- proto/testing/ssz_static_mainnet_test.go | 1 + proto/testing/ssz_static_minimal_test.go | 2 + proto/testing/ssz_static_test.go | 2 - shared/params/config.go | 6 - 26 files changed, 95 insertions(+), 1054 deletions(-) diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 7c5fbb102584..fa7594cea013 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 790a321d94a7..0814fc99f106 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -1121,130 +1121,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 567efdabf930..4288bd0713af 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" @@ -2103,203 +2102,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/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index 0001639c1762..2f6f1928bae9 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -24,7 +24,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", diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index f2436c8ab5c9..acb14da46952 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" @@ -404,19 +403,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") @@ -437,10 +423,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 } @@ -481,19 +463,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") @@ -514,10 +483,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 } @@ -555,14 +520,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) } diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index 108532ca26e6..3ea00db89d45 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -840,8 +840,6 @@ 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 @@ -965,17 +963,6 @@ 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) @@ -1016,7 +1003,6 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { Attestations: attestations, ProposerSlashings: proposerSlashings, AttesterSlashings: attesterSlashings, - Transfers: transfers, }, } @@ -1216,24 +1202,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 +1242,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/rpc/proposer_server.go b/beacon-chain/rpc/proposer_server.go index 4c7b377dd9c5..1b623db1581b 100644 --- a/beacon-chain/rpc/proposer_server.go +++ b/beacon-chain/rpc/proposer_server.go @@ -90,7 +90,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/proto/beacon/db/attestation_container.pb.go b/proto/beacon/db/attestation_container.pb.go index 6689465ba04d..e07adc093af7 100755 --- a/proto/beacon/db/attestation_container.pb.go +++ b/proto/beacon/db/attestation_container.pb.go @@ -5,13 +5,12 @@ package db import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/messages.pb.go b/proto/beacon/p2p/v1/messages.pb.go index 429de7fc2a97..c49daf0c207c 100755 --- a/proto/beacon/p2p/v1/messages.pb.go +++ b/proto/beacon/p2p/v1/messages.pb.go @@ -5,11 +5,10 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index b77e9294f07d..99c22032db7e 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -5,13 +5,12 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index 09170bf4900d..bdba22dc3238 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -7,14 +7,13 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" - io "io" - math "math" - proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index ca623082da29..c7f6837657d9 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -6,13 +6,12 @@ package ethereum_beacon_rpc_v1 import ( context "context" fmt "fmt" - math "math" - proto "github.com/golang/protobuf/proto" empty "github.com/golang/protobuf/ptypes/empty" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + math "math" ) // 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 4e0e3f81a8b7..c676b2c7b1fe 100644 --- a/proto/eth/v1alpha1/_compatibility/compatability_test.go +++ b/proto/eth/v1alpha1/_compatibility/compatability_test.go @@ -12,6 +12,8 @@ import ( // Test that Prysm copied protobufs have the same wire type and tag number. func TestProtoCompatability(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + tests := []struct { a proto.Message b proto.Message @@ -62,10 +64,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 be11ffceb673..f943f90f0719 100755 --- a/proto/eth/v1alpha1/archive.pb.go +++ b/proto/eth/v1alpha1/archive.pb.go @@ -5,11 +5,10 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index 223405f1eb73..b1dd5518ad25 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -5,12 +5,11 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/beacon_block.pb.go b/proto/eth/v1alpha1/beacon_block.pb.go index fe053f245cf4..79a44be1bf29 100755 --- a/proto/eth/v1alpha1/beacon_block.pb.go +++ b/proto/eth/v1alpha1/beacon_block.pb.go @@ -5,11 +5,10 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -111,7 +110,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 +204,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 +511,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 +524,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 +589,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) @@ -771,7 +667,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 +732,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 +742,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, 0xe7, 0xfd, 0xc6, 0xca, 0x22, 0x34, 0x12, 0xb9, 0xea, 0xd4, - 0x1e, 0x1b, 0x22, 0x06, 0x35, 0xa1, 0xc0, 0xdc, 0xbe, 0x87, 0xf9, 0x28, 0x20, 0x95, 0xdc, 0x2a, - 0xb1, 0xe7, 0xc7, 0xa1, 0xd8, 0x0c, 0xa3, 0xfd, 0x95, 0x83, 0xcd, 0x25, 0x2a, 0x74, 0x0c, 0xe5, - 0x00, 0x7b, 0x36, 0xa6, 0x66, 0x40, 0x2e, 0x09, 0x1e, 0x88, 0x1a, 0xac, 0x24, 0x2a, 0x49, 0x9c, - 0x21, 0x60, 0xe8, 0x33, 0x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, 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, 0xcb, 0x6e, 0xe3, 0xd4, + 0x1b, 0x97, 0x5b, 0xb7, 0x4d, 0xbf, 0x24, 0xbd, 0x1c, 0x4d, 0x47, 0x51, 0x17, 0x4d, 0xe4, 0xe9, + 0xfc, 0x27, 0x7f, 0x44, 0x93, 0xd8, 0x2d, 0x65, 0x08, 0x6c, 0x48, 0xa6, 0x52, 0x47, 0x20, 0x84, + 0x8c, 0x84, 0x04, 0x1b, 0xeb, 0xd8, 0x3e, 0x8d, 0xad, 0x3a, 0x3e, 0x96, 0xcf, 0x49, 0xa6, 0x99, + 0x0d, 0x8f, 0xc0, 0x82, 0x05, 0xef, 0xc1, 0x2b, 0xb0, 0x61, 0x07, 0x4f, 0x10, 0xa1, 0x3e, 0x00, + 0x8b, 0x88, 0x07, 0x40, 0x3e, 0xc7, 0x49, 0x9c, 0x34, 0x0e, 0x9d, 0xd9, 0xb0, 0xf3, 0xe5, 0x77, + 0xf9, 0xfc, 0x9d, 0xef, 0x62, 0x78, 0x1e, 0xc5, 0x94, 0xd3, 0x26, 0xe1, 0x5e, 0x73, 0xa8, 0xe3, + 0x20, 0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 0xbd, 0x0d, + 0xd8, 0x4d, 0xd6, 0xa8, 0x24, 0xa8, 0xb9, 0x4b, 0x28, 0xc1, 0x08, 0xfc, 0x3b, 0xaf, 0xdb, 0x1f, + 0x37, 0x00, 0x3d, 0x6c, 0x41, 0x74, 0x05, 0x47, 0xce, 0x80, 0xf1, 0xc4, 0xda, 0xf6, 0xb9, 0xd5, + 0x4a, 0xce, 0xdf, 0x77, 0x08, 0x13, 0x8d, 0xa7, 0x76, 0xd0, 0x64, 0x5c, 0xdd, 0x9b, 0x0d, 0xcc, + 0x8b, 0x56, 0x22, 0x8a, 0x52, 0x42, 0xc7, 0xe7, 0xad, 0xd7, 0x12, 0xbd, 0x2c, 0xa3, 0xcf, 0x64, + 0x36, 0x1e, 0x23, 0xa3, 0x4f, 0x65, 0xda, 0x69, 0x2b, 0x6f, 0xae, 0xfd, 0x01, 0xc9, 0xc4, 0x3f, + 0xef, 0xe6, 0x77, 0xee, 0x8e, 0x4e, 0xf7, 0xb7, 0xfb, 0x13, 0xe5, 0x8f, 0xfb, 0x13, 0xe5, 0xcf, + 0xfb, 0x13, 0xe5, 0xfb, 0x8f, 0x32, 0xbf, 0x76, 0x51, 0x3c, 0x62, 0x7d, 0xcc, 0x7d, 0x27, 0xc0, + 0x36, 0x93, 0x77, 0xcd, 0x87, 0xbf, 0x72, 0x9f, 0x12, 0xee, 0xd9, 0xdb, 0xe2, 0xf9, 0xf9, 0x3f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x94, 0xeb, 0xed, 0x3a, 0x58, 0x0a, 0x00, 0x00, } func (m *BeaconBlock) Marshal() (dAtA []byte, err error) { @@ -1071,18 +958,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 +1171,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 +1418,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 +1538,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 +2153,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 +2872,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 0e35715ec14e..fa9ce7d0b815 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 diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 0e610275f8a8..affdb7697535 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -6,14 +6,13 @@ package eth import ( context "context" fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/node.pb.go b/proto/eth/v1alpha1/node.pb.go index 647805e30f3d..2ba95ac9b419 100755 --- a/proto/eth/v1alpha1/node.pb.go +++ b/proto/eth/v1alpha1/node.pb.go @@ -6,13 +6,12 @@ package eth import ( context "context" fmt "fmt" - io "io" - math "math" - proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/slasher.pb.go b/proto/eth/v1alpha1/slasher.pb.go index f4b2d952f016..411622ec22c9 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/eth/v1alpha1/validator.pb.go b/proto/eth/v1alpha1/validator.pb.go index 45de36f39f5f..160093ed7ac6 100755 --- a/proto/eth/v1alpha1/validator.pb.go +++ b/proto/eth/v1alpha1/validator.pb.go @@ -7,14 +7,13 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/sharding/p2p/v1/messages.pb.go b/proto/sharding/p2p/v1/messages.pb.go index 61228b93def4..ba268c5f4bac 100644 --- a/proto/sharding/p2p/v1/messages.pb.go +++ b/proto/sharding/p2p/v1/messages.pb.go @@ -5,10 +5,9 @@ package ethereum_sharding_p2p_v1 import ( fmt "fmt" + proto "github.com/gogo/protobuf/proto" io "io" math "math" - - proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/testing/ssz_static_mainnet_test.go b/proto/testing/ssz_static_mainnet_test.go index 584a7370f9be..b1b3100c0d0e 100644 --- a/proto/testing/ssz_static_mainnet_test.go +++ b/proto/testing/ssz_static_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestSZZStatic_Mainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runSSZStaticTests(t, "mainnet") } diff --git a/proto/testing/ssz_static_minimal_test.go b/proto/testing/ssz_static_minimal_test.go index 3f46871ee792..7eaffa9f02cb 100644 --- a/proto/testing/ssz_static_minimal_test.go +++ b/proto/testing/ssz_static_minimal_test.go @@ -5,5 +5,7 @@ import ( ) func TestSSZStatic_Minimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") + runSSZStaticTests(t, "minimal") } diff --git a/proto/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index cbf8707102d7..76116b9a565e 100644 --- a/proto/testing/ssz_static_test.go +++ b/proto/testing/ssz_static_test.go @@ -130,8 +130,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/params/config.go b/shared/params/config.go index bba4f046a580..eeec7b1e686b 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -70,7 +70,6 @@ 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. @@ -78,7 +77,6 @@ type BeaconChainConfig struct { 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. @@ -167,7 +165,6 @@ var defaultBeaconConfig = &BeaconChainConfig{ MaxAttestations: 128, MaxDeposits: 16, MaxVoluntaryExits: 16, - MaxTransfers: 0, // BLS domain values. DomainBeaconProposer: bytesutil.Bytes4(0), @@ -175,7 +172,6 @@ var defaultBeaconConfig = &BeaconChainConfig{ DomainRandao: bytesutil.Bytes4(2), DomainDeposit: bytesutil.Bytes4(3), DomainVoluntaryExit: bytesutil.Bytes4(4), - DomainTransfer: bytesutil.Bytes4(5), // Prysm constants. GweiPerEth: 1000000000, @@ -293,7 +289,6 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.MaxAttestations = 128 minimalConfig.MaxDeposits = 16 minimalConfig.MaxVoluntaryExits = 16 - minimalConfig.MaxTransfers = 0 // Signature domains minimalConfig.DomainBeaconProposer = bytesutil.Bytes4(0) @@ -301,7 +296,6 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.DomainBeaconAttester = 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 From b6645d6089d962b744401273149e11e8be0f3681 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 30 Oct 2019 08:51:16 -0700 Subject: [PATCH 03/82] Remove active index roots and compact committee roots (#3869) --- beacon-chain/archiver/service_test.go | 2 - .../forkchoice/process_attestation_test.go | 5 +- .../core/blocks/block_operations_test.go | 27 +- .../blocks/spectest/deposit_mainnet_test.go | 1 + .../blocks/spectest/deposit_minimal_test.go | 1 + .../spectest/voluntary_exit_mainnet_test.go | 1 + .../spectest/voluntary_exit_minimal_test.go | 1 + beacon-chain/core/epoch/epoch_processing.go | 24 - .../core/epoch/epoch_processing_test.go | 32 +- beacon-chain/core/epoch/participation_test.go | 2 - .../epoch/precompute/reward_penalty_test.go | 2 - .../epoch/spectest/crosslink_minimal_test.go | 1 + .../epoch/spectest/registry_minimal_test.go | 1 + .../epoch/spectest/slashings_minimal_test.go | 1 + beacon-chain/core/helpers/BUILD.bazel | 1 - beacon-chain/core/helpers/committee.go | 86 --- beacon-chain/core/helpers/committee_test.go | 110 ++-- beacon-chain/core/helpers/randao.go | 18 - beacon-chain/core/helpers/randao_test.go | 83 +-- beacon-chain/core/helpers/validators_test.go | 19 +- beacon-chain/core/state/state.go | 22 - beacon-chain/core/state/state_test.go | 22 - beacon-chain/core/state/transition_test.go | 14 +- .../core/validators/validator_test.go | 12 +- beacon-chain/rpc/attester_server_test.go | 7 +- beacon-chain/rpc/beacon_chain_server_test.go | 22 +- .../sync/validate_proposer_slashing_test.go | 6 +- proto/beacon/p2p/v1/types.pb.go | 568 +++--------------- proto/beacon/p2p/v1/types.proto | 9 - proto/beacon/rpc/v1_gateway/services.pb.go | 208 +++---- proto/testing/ssz_static_test.go | 2 - shared/testutil/helpers_test.go | 10 +- 32 files changed, 281 insertions(+), 1039 deletions(-) diff --git a/beacon-chain/archiver/service_test.go b/beacon-chain/archiver/service_test.go index 5e32d9a1cb15..9e583d3d73a9 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -269,8 +269,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{}, diff --git a/beacon-chain/blockchain/forkchoice/process_attestation_test.go b/beacon-chain/blockchain/forkchoice/process_attestation_test.go index 5803af05b93e..cda9bf7cae8f 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) } @@ -132,14 +131,12 @@ func TestStore_SaveCheckpointState(t *testing.T) { 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{}, } diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 4288bd0713af..b845f97f17a5 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -100,8 +100,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) @@ -153,8 +152,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) @@ -202,8 +200,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) @@ -257,8 +254,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) @@ -552,9 +548,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( @@ -1504,10 +1499,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 @@ -1592,8 +1586,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 diff --git a/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go b/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go index dcc4a048ca5f..435dcdc14c56 100644 --- a/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestDepositMainnetYaml(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runDepositTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/deposit_minimal_test.go b/beacon-chain/core/blocks/spectest/deposit_minimal_test.go index baedb27d0e0c..03a5c457e969 100644 --- a/beacon-chain/core/blocks/spectest/deposit_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/deposit_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestDepositMinimalYaml(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runDepositTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go b/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go index 42d97f1f59b1..346e733240a9 100644 --- a/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go @@ -5,5 +5,6 @@ import ( ) func TestVoluntaryExitMainnet(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runVoluntaryExitTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go b/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go index fb6ed1f5b070..2f023255f4d5 100644 --- a/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestVoluntaryExitMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runVoluntaryExitTest(t, "minimal") } diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 41f086466938..9ac601e91c93 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -490,30 +490,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().MaxSeedLookhead - 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 diff --git a/beacon-chain/core/epoch/epoch_processing_test.go b/beacon-chain/core/epoch/epoch_processing_test.go index 34c4afc7ac77..a9eaef7b1cfd 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -48,9 +48,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) @@ -99,9 +98,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) @@ -146,11 +144,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: 0, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + + Validators: validators, + Balances: balances, } balance, err := AttestingBalance(state, atts) @@ -198,7 +196,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) @@ -427,7 +424,6 @@ func TestWinningCrosslink_CanGetWinningRoot(t *testing.T) { BlockRoots: blockRoots, CurrentCrosslinks: crosslinks, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } winner, indices, err := WinningCrosslink(state, 1, ge) @@ -474,7 +470,6 @@ func TestProcessCrosslinks_NoUpdate(t *testing.T) { Balances: balances, BlockRoots: blockRoots, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), CurrentCrosslinks: crosslinks, } newState, err := ProcessCrosslinks(state) @@ -540,7 +535,6 @@ func TestProcessCrosslinks_SuccessfulUpdate(t *testing.T) { BlockRoots: blockRoots, CurrentCrosslinks: crosslinks, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } newState, err := ProcessCrosslinks(state) if err != nil { @@ -918,12 +912,6 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { 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().MaxSeedLookhead) % 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", @@ -1541,8 +1529,6 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState { 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 bf7e04fe0eb3..5e3fa26b0cb2 100644 --- a/beacon-chain/core/epoch/participation_test.go +++ b/beacon-chain/core/epoch/participation_test.go @@ -43,8 +43,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{}, diff --git a/beacon-chain/core/epoch/precompute/reward_penalty_test.go b/beacon-chain/core/epoch/precompute/reward_penalty_test.go index 14b8dc0da031..9a8adc55fe77 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -261,8 +261,6 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState { 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_minimal_test.go b/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go index f52b4da01e07..155a11308cf8 100644 --- a/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestCrosslinksProcessingMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runCrosslinkProcessingTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/registry_minimal_test.go b/beacon-chain/core/epoch/spectest/registry_minimal_test.go index be78f72e7c06..50376225f254 100644 --- a/beacon-chain/core/epoch/spectest/registry_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/registry_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestRegistryUpdatesMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runRegistryUpdatesTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/slashings_minimal_test.go b/beacon-chain/core/epoch/spectest/slashings_minimal_test.go index 5b337effec75..b0f5b27dee39 100644 --- a/beacon-chain/core/epoch/spectest/slashings_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/slashings_minimal_test.go @@ -5,5 +5,6 @@ import ( ) func TestSlashingsMinimal(t *testing.T) { + t.Skip("Disabled until v0.9.0 (#3865) completes") runSlashingsTests(t, "minimal") } diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 5aa98df69e0f..b7baa822a2bc 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -33,7 +33,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", ], diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index 921f6862142d..ec9951987838 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -6,7 +6,6 @@ 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" @@ -395,91 +394,6 @@ 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) { diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index 8a5a358ef9cc..dc213c02a043 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -128,10 +128,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) @@ -187,10 +186,9 @@ func TestComputeCommittee_WithCache(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) @@ -234,9 +232,8 @@ func TestAttestationParticipants_NoCommitteeCache(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{} @@ -304,9 +301,8 @@ 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{}} @@ -343,10 +339,9 @@ 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 { @@ -423,10 +418,9 @@ func TestCommitteeAssignment_EveryValidatorShouldPropose(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), } ClearAllCaches() @@ -443,9 +437,8 @@ func TestCommitteeAssignment_EveryValidatorShouldPropose(t *testing.T) { 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), + Slot: params.BeaconConfig().SlotsPerEpoch, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } index := uint64(10000) _, _, _, _, err := CommitteeAssignment(state, 1, index) @@ -603,9 +596,8 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { } state := &pb.BeaconState{ - Validators: validators, - ActiveIndexRoots: activeRoots, - RandaoMixes: activeRoots, + Validators: validators, + RandaoMixes: activeRoots, } tests := []struct { @@ -721,33 +713,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() @@ -761,9 +726,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) @@ -805,9 +769,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 { @@ -894,9 +857,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) @@ -933,9 +895,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) @@ -972,9 +933,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) @@ -1012,9 +972,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) @@ -1052,9 +1011,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) diff --git a/beacon-chain/core/helpers/randao.go b/beacon-chain/core/helpers/randao.go index c79336f132a0..bfff18cb2a02 100644 --- a/beacon-chain/core/helpers/randao.go +++ b/beacon-chain/core/helpers/randao.go @@ -37,24 +37,6 @@ func Seed(state *pb.BeaconState, epoch uint64, domain []byte) ([32]byte, error) 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 5045df132309..f816e338fb8d 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().MaxSeedLookhead); 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,9 +97,8 @@ 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, params.BeaconConfig().DomainBeaconAttester) if err != nil { diff --git a/beacon-chain/core/helpers/validators_test.go b/beacon-chain/core/helpers/validators_test.go index 4e5c0c50442b..ff917c63a360 100644 --- a/beacon-chain/core/helpers/validators_test.go +++ b/beacon-chain/core/helpers/validators_test.go @@ -160,10 +160,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 { @@ -212,9 +211,8 @@ 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), + Slot: 0, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } _, err := BeaconProposerIndex(beaconState) expected := fmt.Sprintf("empty first committee at slot %d", 0) @@ -252,10 +250,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/state.go b/beacon-chain/core/state/state.go index e9de909866ab..32f4a5e0a9d8 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" @@ -64,8 +63,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{ @@ -128,8 +125,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data // Recent state. CurrentCrosslinks: crosslinks, PreviousCrosslinks: crosslinks, - ActiveIndexRoots: activeIndexRoots, - CompactCommitteesRoots: compactRoots, HistoricalRoots: [][]byte{}, BlockRoots: blockRoots, StateRoots: stateRoots, @@ -197,23 +192,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 f362bbc844bd..bc03ae9625d8 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" @@ -128,32 +127,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") } diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index 3ea00db89d45..4cc814608f01 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -679,7 +679,6 @@ func TestProcessEpoch_CantGetTgtAttsCurrEpoch(t *testing.T) { 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") @@ -703,8 +702,6 @@ func TestProcessEpoch_CanProcess(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{}, @@ -738,8 +735,6 @@ func TestProcessEpochPrecompute_CanProcess(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{}, @@ -758,9 +753,9 @@ 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) @@ -816,7 +811,6 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { 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, } @@ -878,7 +872,7 @@ 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"), }, diff --git a/beacon-chain/core/validators/validator_test.go b/beacon-chain/core/validators/validator_test.go index 9251d9ead166..6c58f1bf6687 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/rpc/attester_server_test.go b/beacon-chain/rpc/attester_server_test.go index ba3cc2af8651..1b16be7c88b6 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -54,10 +54,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 { diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index de5a0ce6de62..f3cbf2799271 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -1198,9 +1198,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) } @@ -1282,9 +1281,8 @@ 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, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1391,9 +1389,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) } @@ -1469,9 +1466,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) } @@ -1653,8 +1649,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{}, diff --git a/beacon-chain/sync/validate_proposer_slashing_test.go b/beacon-chain/sync/validate_proposer_slashing_test.go index 2f266ab0ab56..5ab7a054f3d9 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/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 99c22032db7e..834569dc3520 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -39,8 +39,6 @@ type BeaconState struct { 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"` 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"` @@ -186,20 +184,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 @@ -625,61 +609,6 @@ 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:"-"` -} - -func (m *CompactCommittee) Reset() { *m = CompactCommittee{} } -func (m *CompactCommittee) String() string { return proto.CompactTextString(m) } -func (*CompactCommittee) ProtoMessage() {} -func (*CompactCommittee) Descriptor() ([]byte, []int) { - return fileDescriptor_e719e7d82cfa7b0d, []int{7} -} -func (m *CompactCommittee) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CompactCommittee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CompactCommittee.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 *CompactCommittee) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompactCommittee.Merge(m, src) -} -func (m *CompactCommittee) XXX_Size() int { - return m.Size() -} -func (m *CompactCommittee) XXX_DiscardUnknown() { - xxx_messageInfo_CompactCommittee.DiscardUnknown(m) -} - -var xxx_messageInfo_CompactCommittee proto.InternalMessageInfo - -func (m *CompactCommittee) GetPubkeys() [][]byte { - if m != nil { - return m.Pubkeys - } - return nil -} - -func (m *CompactCommittee) GetCompactValidators() []uint64 { - if m != nil { - return m.CompactValidators - } - return nil -} - func init() { proto.RegisterType((*BeaconState)(nil), "ethereum.beacon.p2p.v1.BeaconState") proto.RegisterType((*Fork)(nil), "ethereum.beacon.p2p.v1.Fork") @@ -688,97 +617,89 @@ 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") } 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, 0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0x07, 0xa4, 0xbe, 0x45, - 0xa3, 0x1d, 0x4b, 0x42, 0xe1, 0xf3, 0xa0, 0xea, 0x23, 0x11, 0x0a, 0x75, 0x48, 0xdb, 0xc3, 0xc8, - 0xc5, 0x91, 0xfe, 0x6d, 0x49, 0x2a, 0xac, 0x64, 0x0a, 0x98, 0x7b, 0xf5, 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,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, - 0x17, 0x32, 0x61, 0x80, 0xa2, 0xa3, 0x94, 0x44, 0xc1, 0x48, 0xb3, 0x87, 0x2d, 0xe0, 0xa4, 0xe2, - 0xe6, 0x6b, 0x1a, 0x28, 0xdd, 0x4c, 0xc7, 0xa2, 0x2e, 0xe2, 0x8e, 0x07, 0x3b, 0xd3, 0xe3, 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, + // 1225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x8f, 0xdb, 0xc4, + 0x17, 0x97, 0x77, 0xf3, 0xfd, 0xd2, 0x4e, 0x76, 0x37, 0xbb, 0x93, 0xaa, 0x6b, 0xda, 0x52, 0x07, + 0x8b, 0xb6, 0x2b, 0xd4, 0x4d, 0xea, 0x74, 0x9b, 0x74, 0x5b, 0x95, 0xaa, 0xee, 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x2b, 0xa1, + 0x7b, 0x75, 0xc8, 0x38, 0x75, 0xf7, 0x4d, 0xc2, 0xf3, 0x4a, 0x28, 0xff, 0xa0, 0x12, 0x1a, 0xa8, + 0x3a, 0x89, 0x92, 0x68, 0x18, 0xe9, 0xf6, 0x80, 0x05, 0x9c, 0x5c, 0x5c, 0x7f, 0x4b, 0x01, 0xb5, + 0x9b, 0xf9, 0xea, 0x61, 0x22, 0xee, 0xf8, 0xb0, 0x3b, 0xbd, 0x42, 0x29, 0x0b, 0x6f, 0x50, 0xdd, + 0xe9, 0x0d, 0x6a, 0x69, 0xd1, 0x05, 0xca, 0x5c, 0xf9, 0xfa, 0xfe, 0x71, 0xe5, 0x9b, 0xfb, 0xc7, + 0x95, 0x9f, 0xef, 0x1f, 0x57, 0x7a, 0xff, 0x97, 0x0b, 0xea, 0xd9, 0xbf, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xbc, 0x6f, 0xb7, 0x67, 0x7b, 0x0b, 0x00, 0x00, } func (m *BeaconState) Marshal() (dAtA []byte, err error) { @@ -961,30 +882,6 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { 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 - i++ - dAtA[i] = 0xb8 - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintTypes(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) - } - } if len(m.Slashings) > 0 { dAtA7 := make([]byte, len(m.Slashings)*10) var j6 int @@ -1361,52 +1258,6 @@ func (m *HistoricalBatch) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CompactCommittee) 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 *CompactCommittee) 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 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++ - } - dAtA[i] = 0x12 - i++ - i = encodeVarintTypes(dAtA, i, uint64(j13)) - i += copy(dAtA[i:], dAtA14[:j13]) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil -} - func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -1489,18 +1340,6 @@ func (m *BeaconState) Size() (n int) { 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 { @@ -1688,31 +1527,6 @@ func (m *HistoricalBatch) Size() (n int) { return n } -func (m *CompactCommittee) 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 len(m.CompactValidators) > 0 { - l = 0 - for _, e := range m.CompactValidators { - l += sovTypes(uint64(e)) - } - n += 1 + sovTypes(uint64(l)) + l - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - func sovTypes(x uint64) (n int) { for { n++ @@ -2211,70 +2025,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 @@ -3433,168 +3183,6 @@ func (m *HistoricalBatch) Unmarshal(dAtA []byte) error { } return nil } -func (m *CompactCommittee) 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 ErrIntOverflowTypes - } - 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: CompactCommittee: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CompactCommittee: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pubkeys", 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.Pubkeys = append(m.Pubkeys, make([]byte, postIndex-iNdEx)) - copy(m.Pubkeys[len(m.Pubkeys)-1], dAtA[iNdEx:postIndex]) - 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 - } - } - 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 { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - 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) - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - 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 skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index adf1c3d2e50a..50df9a106f17 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -30,8 +30,6 @@ message BeaconState { // 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\""]; // Slashings [6001-7000] repeated uint64 slashings = 6001 [(gogoproto.moretags) = "ssz-size:\"slashings.size\""]; @@ -94,10 +92,3 @@ message HistoricalBatch { repeated bytes block_roots = 1 [(gogoproto.moretags) = "ssz-size:\"block_roots.size\""]; 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\""]; -} diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index c7f6837657d9..1ae4b9f3e8ec 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -186,7 +186,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"` + Index uint64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -238,9 +238,9 @@ func (m *AttestationRequest) GetSlot() uint64 { return 0 } -func (m *AttestationRequest) GetShard() uint64 { +func (m *AttestationRequest) GetIndex() uint64 { if m != nil { - return m.Shard + return m.Index } return 0 } @@ -827,7 +827,7 @@ 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"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,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"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` @@ -871,9 +871,9 @@ func (m *AssignmentResponse_ValidatorAssignment) GetCommittee() []uint64 { return nil } -func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetIndex() uint64 { if m != nil { - return m.Shard + return m.Index } return 0 } @@ -1243,104 +1243,104 @@ 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, 0x6d, 0xbb, 0x83, 0x5b, 0xb1, 0xa7, 0x87, 0x99, 0xb6, 0x15, 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x49, 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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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, 0x47, 0x86, 0x93, - 0xf1, 0x15, 0x24, 0xb9, 0xa7, 0xea, 0x31,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a6, 0x04, 0xe6, 0xd1, 0x3f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xc0, 0x92, 0xa7, 0x79, 0x2f, 0x11, 0x00, 0x00, + // 1541 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4f, 0x4f, 0x1b, 0x4b, + 0x12, 0xcf, 0x18, 0x63, 0x48, 0xd9, 0xc0, 0xd0, 0x10, 0x70, 0x1c, 0xa2, 0xb0, 0xb3, 0xc9, 0x2e, + 0x20, 0xc5, 0x06, 0x27, 0x8a, 0xb2, 0x89, 0xb2, 0x91, 0xc1, 0x13, 0x62, 0x25, 0x32, 0x64, 0xec, + 0x40, 0x56, 0x39, 0x8c, 0xda, 0x76, 0x07, 0xb7, 0x62, 0x4f, 0x0f, 0x33, 0x6d, 0x2b, 0x5c, 0x56, + 0xda, 0x8f, 0xb0, 0x87, 0x3d, 0xaf, 0xf6, 0x33, 0xec, 0xe1, 0x7d, 0x85, 0xf7, 0x21, 0x9e, 0xde, + 0xe9, 0x1d, 0xde, 0xc7, 0x78, 0x9a, 0xee, 0x9e, 0x3f, 0xd8, 0x38, 0x98, 0xdc, 0xdc, 0x55, 0xf5, + 0xab, 0xaa, 0xae, 0xaa, 0xae, 0xaa, 0x31, 0x18, 0xae, 0xc7, 0x38, 0x2b, 0xb5, 0x08, 0x6e, 0x33, + 0xa7, 0xe4, 0xb9, 0xed, 0xd2, 0x70, 0xaf, 0xe4, 0x13, 0x6f, 0x48, 0xdb, 0xc4, 0x2f, 0x0a, 0x26, + 0x5a, 0x23, 0xbc, 0x4b, 0x3c, 0x32, 0xe8, 0x17, 0xa5, 0x58, 0xd1, 0x73, 0xdb, 0xc5, 0xe1, 0x5e, + 0xe1, 0xde, 0x19, 0x63, 0x67, 0x3d, 0x52, 0x12, 0x52, 0xad, 0xc1, 0x97, 0x12, 0xe9, 0xbb, 0xfc, + 0x42, 0x82, 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aa, 0xf6, + 0x53, 0x79, 0xcd, 0x5a, 0x89, 0x04, 0x8e, 0x23, 0xbd, 0xe8, 0x04, 0xe6, 0x83, 0xe2, 0x1c, 0xf8, + 0x44, 0x26, 0x33, 0x5b, 0x7e, 0x51, 0xbc, 0xfa, 0x39, 0x17, 0xbf, 0x63, 0xbe, 0xd8, 0x10, 0x3a, + 0xac, 0x48, 0x57, 0xc1, 0x85, 0x8c, 0xa4, 0x5d, 0x57, 0xec, 0x87, 0x90, 0x91, 0x20, 0x91, 0xe8, + 0x6c, 0xb9, 0x74, 0xad, 0x79, 0x65, 0x4b, 0x99, 0xb6, 0x14, 0xdc, 0x78, 0x01, 0xeb, 0xe6, 0x37, + 0xca, 0x49, 0x27, 0xce, 0xde, 0xd4, 0xd1, 0x7d, 0x09, 0xf9, 0x71, 0xac, 0x8a, 0xec, 0xb5, 0xe0, + 0x0f, 0x80, 0x0e, 0xba, 0x98, 0x3a, 0x0d, 0x8e, 0xbd, 0xf8, 0xbd, 0xe5, 0x61, 0xce, 0x0f, 0x08, + 0xa4, 0x23, 0xee, 0x3c, 0x6f, 0x85, 0x47, 0xf4, 0x27, 0xc8, 0x9d, 0x11, 0x87, 0xf8, 0xd4, 0xb7, + 0x39, 0xed, 0x13, 0x55, 0xe0, 0x59, 0x45, 0x6b, 0xd2, 0x3e, 0x31, 0x9e, 0xc1, 0x9d, 0xc8, 0x93, + 0x5a, 0xf0, 0xa0, 0xa7, 0xeb, 0x1c, 0x46, 0x11, 0xd6, 0x46, 0x71, 0xca, 0x9d, 0xa8, 0x4d, 0x68, + 0xc9, 0x36, 0xf1, 0x11, 0x96, 0x2b, 0xbe, 0x4f, 0xcf, 0x9c, 0x3e, 0x71, 0x78, 0x22, 0x5a, 0xc4, + 0x65, 0xed, 0xae, 0x2d, 0x1c, 0x56, 0x00, 0x10, 0x24, 0x71, 0xc5, 0xeb, 0x7b, 0xc0, 0xef, 0x29, + 0x40, 0x49, 0xbd, 0xca, 0x87, 0x73, 0x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e7, 0x03, 0x32, + 0x90, 0x4d, 0x39, 0x6d, 0xdd, 0x0d, 0x65, 0x6a, 0x4e, 0xdc, 0xb5, 0x3e, 0x04, 0x02, 0xc6, 0x2b, + 0x58, 0xa8, 0xb2, 0x3e, 0xa6, 0x51, 0x0f, 0x5e, 0x85, 0x59, 0x69, 0x51, 0x3d, 0x11, 0x71, 0x40, + 0x6b, 0x90, 0xe9, 0x08, 0xb1, 0x70, 0x16, 0xcb, 0x93, 0xf1, 0x12, 0x16, 0x43, 0xb8, 0x0a, 0xf7, + 0x36, 0xe8, 0x41, 0x7d, 0x61, 0x3e, 0xf0, 0x88, 0xad, 0x30, 0x52, 0xd5, 0x52, 0x44, 0x97, 0x10, + 0xe3, 0xdf, 0x29, 0x58, 0x16, 0xd1, 0x6a, 0x7a, 0x24, 0x9e, 0x8c, 0x6f, 0x20, 0xcd, 0x3d, 0x55, + 0x8f, 0xd9, 0x72, 0x79, 0x52, 0xb6, 0xc6, 0x80, 0xc5, 0xe0, 0x50, 0x67, 0x1d, 0x62, 0x09, 0x7c, + 0xe1, 0xff, 0x1a, 0xcc, 0x87, 0x24, 0xf4, 0x1c, 0x66, 0x45, 0xda, 0x84, 0x2b, 0xd9, 0xb2, 0x11, + 0x6b, 0x25, 0xbc, 0x5b, 0x0c, 0x77, 0xaa, 0xe2, 0xbe, 0x30, 0x21, 0xd7, 0x24, 0x09, 0x18, 0x59, + 0x6d, 0x52, 0x23, 0xab, 0x4d, 0x30, 0x48, 0x5d, 0xec, 0x71, 0xda, 0xa6, 0xae, 0x18, 0x3a, 0x43, + 0xc6, 0x49, 0x38, 0x7b, 0x97, 0x93, 0x9c, 0x93, 0x80, 0x11, 0xbc, 0x14, 0x35, 0xda, 0x85, 0x9c, + 0xcc, 0x2a, 0xc8, 0xa9, 0x1e, 0x50, 0x8c, 0xf7, 0xb0, 0x1a, 0x38, 0x2d, 0x5c, 0x08, 0x8a, 0x21, + 0x4c, 0xcb, 0x3d, 0xb8, 0x1d, 0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+ 0x8b, 0xfe, 0xa5, 0xc1, 0xea, 0x55, 0x9f, 0x54, 0xe8, 0xfa, 0x0c, 0x8d, 0x7f, 0xd5, 0x15, 0x9e, + 0xde, 0x0c, 0xa4, 0x7c, 0x18, 0x80, 0x3e, 0xba, 0x21, 0xa3, 0x89, 0x17, 0x99, 0xb0, 0x87, 0x17, + 0x76, 0xa7, 0x07, 0x28, 0xb3, 0xff, 0x88, 0x8a, 0x39, 0x5e, 0xb1, 0xd1, 0x5a, 0x51, 0x7e, 0xee, + 0x17, 0xc3, 0x3f, 0x16, 0x8a, 0x66, 0xdf, 0xe5, 0x17, 0x93, 0xd3, 0x38, 0xbe, 0x9e, 0xef, 0x6a, + 0xe8, 0x1d, 0x2c, 0x1c, 0x60, 0x87, 0x39, 0xb4, 0x8d, 0x7b, 0x6f, 0x09, 0xee, 0x4c, 0x54, 0x3b, + 0x45, 0x3f, 0x68, 0x65, 0x04, 0xe6, 0xc9, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x4d, 0x66, + 0x8f, 0x2f, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index 76116b9a565e..733903e5c168 100644 --- a/proto/testing/ssz_static_test.go +++ b/proto/testing/ssz_static_test.go @@ -110,8 +110,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": diff --git a/shared/testutil/helpers_test.go b/shared/testutil/helpers_test.go index e4b87151240e..84847eb21ce8 100644 --- a/shared/testutil/helpers_test.go +++ b/shared/testutil/helpers_test.go @@ -93,9 +93,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 +139,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) From cf169c88c79e9258b6bf9bd4df21e0809eeffd7f Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 30 Oct 2019 08:51:32 -0700 Subject: [PATCH 04/82] Update inclusion reward (#3886) --- beacon-chain/core/epoch/epoch_processing.go | 10 ++-------- beacon-chain/core/epoch/precompute/reward_penalty.go | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 9ac601e91c93..ec2f4930f31d 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -718,11 +718,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 @@ -821,8 +817,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") @@ -830,7 +824,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. diff --git a/beacon-chain/core/epoch/precompute/reward_penalty.go b/beacon-chain/core/epoch/precompute/reward_penalty.go index 468671244fbe..255371c78601 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty.go @@ -70,8 +70,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 } From 62940376dd402daf5f37ea9cde8980b0ab880b31 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 30 Oct 2019 10:01:07 -0700 Subject: [PATCH 05/82] Alter proposer selection logic (#3884) --- beacon-chain/core/blocks/block_operations.go | 12 ++- .../core/blocks/block_operations_test.go | 4 +- beacon-chain/core/helpers/committee.go | 37 +++++---- beacon-chain/core/helpers/committee_test.go | 66 +++++++++------ beacon-chain/core/helpers/shuffle.go | 7 +- beacon-chain/core/helpers/validators.go | 82 +++++++++---------- beacon-chain/core/helpers/validators_test.go | 24 ++---- beacon-chain/rpc/beacon_chain_server.go | 3 +- beacon-chain/rpc/beacon_chain_server_test.go | 10 +-- beacon-chain/rpc/validator_server.go | 3 +- shared/params/config.go | 14 ++-- shared/testutil/block_test.go | 9 +- shared/testutil/helpers_test.go | 2 + 13 files changed, 144 insertions(+), 129 deletions(-) diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index 0814fc99f106..ef7fb6d7232d 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -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 { diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index b845f97f17a5..805940fcd5b8 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -416,7 +416,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{ @@ -440,7 +440,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) } diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index ec9951987838..b1a35481b384 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -239,26 +239,39 @@ func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { func CommitteeAssignment( state *pb.BeaconState, epoch uint64, - validatorIndex uint64) ([]uint64, uint64, uint64, bool, error) { + validatorIndex uint64) ([]uint64, uint64, uint64, bool, uint64, error) { if epoch > NextEpoch(state) { - return nil, 0, 0, false, fmt.Errorf( + return nil, 0, 0, false, 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 := uint64(startSlot); slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { + state.Slot = slot + i, err := BeaconProposerIndex(state) + if err != nil { + return nil, 0, 0, false, 0, fmt.Errorf( + "could not check proposer v: %v", err) + } + proposerIndexToSlot[i] = slot + } + committeeCount, err := CommitteeCount(state, epoch) if err != nil { - return nil, 0, 0, false, errors.Wrap(err, "could not get committee count") + return nil, 0, 0, false, 0, 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( + return nil, 0, 0, false, 0, 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 @@ -266,25 +279,19 @@ func CommitteeAssignment( shard := (slotStatShard + i) % params.BeaconConfig().ShardCount committee, err := CrosslinkCommittee(state, epoch, shard) if err != nil { - return nil, 0, 0, false, fmt.Errorf( + return nil, 0, 0, false, 0, 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 + proposerSlot, isProposer := proposerIndexToSlot[index] + return committee, shard, slot, isProposer, proposerSlot, nil } } } } - return []uint64{}, 0, 0, false, status.Error(codes.NotFound, "validator not found in assignments") + return []uint64{}, 0, 0, false, 0, status.Error(codes.NotFound, "validator not found in assignments") } // ShardDelta returns the minimum number of shards get processed in one epoch. diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index dc213c02a043..f24addad4454 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -345,46 +345,48 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { } tests := []struct { - index uint64 - slot uint64 - committee []uint64 - shard uint64 - isProposer bool + index uint64 + slot uint64 + committee []uint64 + shard uint64 + isProposer bool + proposerSlot uint64 }{ { index: 0, slot: 144, committee: []uint64{95, 0}, - shard: 80, - isProposer: true, + shard: 16, + isProposer: false, }, { index: 105, slot: 171, committee: []uint64{50, 105}, shard: 43, - isProposer: true, + isProposer: false, }, { index: 0, slot: 144, committee: []uint64{95, 0}, shard: 16, - isProposer: true, + isProposer: false, }, { - index: 11, - slot: 129, - committee: []uint64{22, 11}, - shard: 1, - isProposer: true, + index: 11, + slot: 129, + committee: []uint64{22, 11}, + shard: 1, + isProposer: true, + proposerSlot: 179, }, } 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, shard, slot, isProposer, proposerSlot, err := CommitteeAssignment(state, tt.slot/params.BeaconConfig().SlotsPerEpoch, tt.index) if err != nil { t.Fatalf("failed to execute NextEpochCommitteeAssignment: %v", err) } @@ -404,14 +406,19 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { 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_EverySlotHasProposer(t *testing.T) { + params.UseMinimalConfig() + defer params.UseMainnetConfig() + + validators := make([]*ethpb.Validator, 64) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -424,24 +431,35 @@ func TestCommitteeAssignment_EveryValidatorShouldPropose(t *testing.T) { } ClearAllCaches() + proposerCount := uint64(0) for i := 0; i < len(validators); i++ { - _, _, _, isProposer, err := CommitteeAssignment(state, state.Slot/params.BeaconConfig().SlotsPerEpoch, uint64(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) + if isProposer { + proposerCount++ } } + if proposerCount != params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Did not get enough proposers, wanted: %d, got: %d", params.BeaconConfig().SlotsPerEpoch, proposerCount) + } } func TestCommitteeAssignment_CantFindValidator(t *testing.T) { + validators := make([]*ethpb.Validator, params.BeaconConfig().SlotsPerEpoch) + 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), } - index := uint64(10000) - _, _, _, _, err := CommitteeAssignment(state, 1, index) + index := uint64(params.BeaconConfig().SlotsPerEpoch + 1) + _, _, _, _, _, err := CommitteeAssignment(state, 1, index) statusErr, ok := status.FromError(err) if !ok { t.Fatal(err) diff --git a/beacon-chain/core/helpers/shuffle.go b/beacon-chain/core/helpers/shuffle.go index 21da641b797b..4f71b25a2bbe 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/validators.go b/beacon-chain/core/helpers/validators.go index 735a22b74297..aa400dd1c1cb 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" @@ -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) -// MAX_RANDOM_BYTE = 2**8 - 1 -// seed = get_seed(state, epoch, DOMAIN_BEACON_PROPOSER) -// i = 0 -// while True: -// candidate_index = first_committee[(epoch + i) % len(first_committee)] -// 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 +// 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) { - // Calculate the offset for slot and shard e := CurrentEpoch(state) - committeeCount, err := CommitteeCount(state, e) - if err != nil { - return 0, err - } - 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) + seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconProposer) if err != nil { - return 0, errors.Wrap(err, "could not get start shard") + return 0, errors.Wrap(err, "could not generate seed") } - 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) + 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 first committee") - } - if len(firstCommittee) == 0 { - return 0, fmt.Errorf("empty first committee at slot %d", state.Slot) + return 0, errors.Wrap(err, "could not get active indices") } - // Use the generated seed to select proposer from the first committee - maxRandomByte := uint64(1<<8 - 1) - seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconProposer) - if err != nil { - return 0, errors.Wrap(err, "could not generate seed") + 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 +// i = 0 +// while True: +// 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 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") } + maxRandomByte := uint64(1<<8 - 1) - // 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(uint64(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 ff917c63a360..b3d1b688876b 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" @@ -171,23 +170,23 @@ func TestBeaconProposerIndex_OK(t *testing.T) { }{ { slot: 1, - index: 534, + index: 505, }, { slot: 5, - index: 861, + index: 798, }, { slot: 19, - index: 1411, + index: 1956, }, { slot: 30, - index: 1621, + index: 991, }, { slot: 43, - index: 1355, + index: 1752, }, } @@ -208,19 +207,6 @@ func TestBeaconProposerIndex_OK(t *testing.T) { } } -func TestBeaconProposerIndex_EmptyCommittee(t *testing.T) { - ClearAllCaches() - beaconState := &pb.BeaconState{ - Slot: 0, - RandaoMixes: 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) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index 2274b16608c6..7e1c6bfb2181 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -609,7 +609,8 @@ func (bs *BeaconChainServer) ListValidatorAssignments( } isProposer = archivedInfo.ProposerIndex == index } else { - committee, shard, slot, isProposer, err = helpers.CommitteeAssignment(headState, requestedEpoch, index) + // TODO(3865): Update ValidatorAssignments_CommitteeAssignment to take in proposer slot + committee, shard, slot, isProposer, _, 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) } diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index f3cbf2799271..a9fb2c7c383c 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -1231,7 +1231,7 @@ 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, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } @@ -1344,7 +1344,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing t.Fatal(err) } for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } @@ -1421,7 +1421,7 @@ 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, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } @@ -1498,7 +1498,7 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination t.Fatal(err) } for _, index := range activeIndices[3:5] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } @@ -1530,7 +1530,7 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } for _, index := range activeIndices[6:7] { - committee, shard, slot, isProposer, err := helpers.CommitteeAssignment(s, 0, index) + committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index 5b1d89844766..f6cb539fb5eb 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -194,7 +194,8 @@ 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) + // TODO(3865): Update ValidatorAssignments_CommitteeAssignment to take in proposer slot + committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(beaconState, epoch, idx) if err != nil { return nil, err } diff --git a/shared/params/config.go b/shared/params/config.go index eeec7b1e686b..c73214602a6e 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -39,17 +39,17 @@ type BeaconChainConfig struct { // Time parameters constants. MinAttestationInclusionDelay uint64 `yaml:"MIN_ATTESTATION_INCLUSION_DELAY"` // MinAttestationInclusionDelay defines how many slots validator has to wait to include attestation for beacon block. - 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. - 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. + 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. + 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. + 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. // State list lengths EpochsPerHistoricalVector uint64 `yaml:"EPOCHS_PER_HISTORICAL_VECTOR"` // EpochsPerHistoricalVector defines max length in epoch to store old historical stats in beacon state. diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index 85dd47074a23..8d794fd11dee 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" @@ -94,7 +95,9 @@ func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { } func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { - deposits, _, privs := SetupInitialDeposits(t, 128) + helpers.ClearAllCaches() + + deposits, _, privs := SetupInitialDeposits(t, 64) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -146,7 +149,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 { diff --git a/shared/testutil/helpers_test.go b/shared/testutil/helpers_test.go index 84847eb21ce8..cf9284a4eb1e 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++ { From d2f4b2b489aac283d983d4ffc13ecbfd6f1e08d0 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 30 Oct 2019 15:30:52 -0700 Subject: [PATCH 06/82] Fix early committee bias (#3888) --- .../forkchoice/process_block_test.go | 4 +-- beacon-chain/blockchain/receive_block_test.go | 6 ++-- .../core/blocks/block_operations_test.go | 29 +++++++++---------- .../core/epoch/precompute/attestation_test.go | 10 +++---- beacon-chain/core/helpers/attestation_test.go | 6 ++-- beacon-chain/core/state/state.go | 13 +++++---- beacon-chain/core/state/state_test.go | 12 +++----- beacon-chain/core/state/transition_test.go | 12 ++++---- beacon-chain/operations/attestation_test.go | 8 ++--- beacon-chain/rpc/proposer_server_test.go | 4 +-- beacon-chain/rpc/validator_server_test.go | 10 +++---- .../sync/validate_attester_slashing_test.go | 2 +- shared/testutil/block_test.go | 16 +++++----- 13 files changed, 64 insertions(+), 68 deletions(-) diff --git a/beacon-chain/blockchain/forkchoice/process_block_test.go b/beacon-chain/blockchain/forkchoice/process_block_test.go index a67d339b6c15..a1b1d233edc0 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) } @@ -187,7 +187,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) } diff --git a/beacon-chain/blockchain/receive_block_test.go b/beacon-chain/blockchain/receive_block_test.go index 27544c09ba8a..03201981a534 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/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 805940fcd5b8..bc02a5c20bb4 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -40,7 +40,7 @@ func TestProcessBlockHeader_WrongProposerSig(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)}) if err != nil { t.Error(err) } @@ -315,7 +315,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) } @@ -348,7 +348,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) } @@ -752,7 +752,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 } @@ -857,7 +857,7 @@ func TestProcessAttestations_InclusionDelayFailure(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) } @@ -899,7 +899,7 @@ 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) } @@ -949,7 +949,7 @@ 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) } @@ -988,7 +988,7 @@ 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) } @@ -1074,7 +1074,7 @@ func TestProcessAttestations_CrosslinkMismatches(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) } @@ -1113,7 +1113,7 @@ func TestProcessAttestations_CrosslinkMismatches(t *testing.T) { 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) } @@ -1166,7 +1166,7 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { 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) } @@ -1238,7 +1238,7 @@ 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) } @@ -1333,7 +1333,7 @@ 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) } @@ -1439,7 +1439,7 @@ 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) } @@ -1556,7 +1556,6 @@ func TestConvertToIndexed_OK(t *testing.T) { } if !reflect.DeepEqual(wanted, ia) { diff, _ := messagediff.PrettyDiff(ia, wanted) - fmt.Println(ia, wanted) t.Log(diff) t.Error("convert attestation to indexed attestation didn't result as wanted") } diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index 273380469bbb..5d1356d5d90d 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -60,7 +60,7 @@ 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) } @@ -94,7 +94,7 @@ 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) } @@ -128,7 +128,7 @@ 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) } @@ -161,7 +161,7 @@ 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) } @@ -197,7 +197,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) } diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index eafdf8689df9..504a5e1f1f1a 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -19,7 +19,7 @@ import ( func TestAttestationDataSlot_OK(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) } @@ -63,7 +63,7 @@ func TestAttestationDataSlot_ReturnsErrorWithNilData(t *testing.T) { func TestAttestationDataSlot_ReturnsErrorWithErroneousTargetEpoch(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) } @@ -78,7 +78,7 @@ func TestAttestationDataSlot_ReturnsErrorWithErroneousTargetEpoch(t *testing.T) func TestAttestationDataSlot_ReturnsErrorWhenTargetEpochLessThanCurrentEpoch(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) } diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index 32f4a5e0a9d8..fe9bbd210d0a 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -25,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 @@ -51,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[:] @@ -83,10 +90,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{ diff --git a/beacon-chain/core/state/state_test.go b/beacon-chain/core/state/state_test.go index bc03ae9625d8..330527a94122 100644 --- a/beacon-chain/core/state/state_test.go +++ b/beacon-chain/core/state/state_test.go @@ -53,11 +53,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) } @@ -92,7 +88,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") } @@ -148,11 +144,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/transition_test.go b/beacon-chain/core/state/transition_test.go index 4cc814608f01..3713460e3f7b 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) } @@ -109,7 +109,7 @@ func TestExecuteStateTransition_FullProcess(t *testing.T) { func TestProcessBlock_IncorrectProposerSlashing(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) } @@ -164,7 +164,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) } @@ -315,7 +315,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) } @@ -434,7 +434,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { func TestProcessBlock_PassesProcessingConditions(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) } @@ -1027,7 +1027,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 diff --git a/beacon-chain/operations/attestation_test.go b/beacon-chain/operations/attestation_test.go index 3291c58c9e72..8ef357f2d928 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) } @@ -140,7 +140,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) } @@ -229,7 +229,7 @@ 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) } @@ -404,7 +404,7 @@ func TestRetrieveAttestations_OK(t *testing.T) { service.attestationPool = make(map[[32]byte]*dbpb.AttestationContainer) 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) } diff --git a/beacon-chain/rpc/proposer_server_test.go b/beacon-chain/rpc/proposer_server_test.go index d2bb132478a8..9506ba979502 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) } diff --git a/beacon-chain/rpc/validator_server_test.go b/beacon-chain/rpc/validator_server_test.go index f45b0d4a1203..9f99c8ef4de8 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) } @@ -100,7 +100,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) } @@ -136,7 +136,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) } @@ -216,7 +216,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) } @@ -272,7 +272,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) } diff --git a/beacon-chain/sync/validate_attester_slashing_test.go b/beacon-chain/sync/validate_attester_slashing_test.go index 9e9b16e8ef8b..bac0d194b2b6 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 } diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index 8d794fd11dee..c68b1b2aadc5 100644 --- a/shared/testutil/block_test.go +++ b/shared/testutil/block_test.go @@ -4,7 +4,6 @@ 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" @@ -25,6 +24,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 0, } + block := GenerateFullBlock(t, beaconState, privs, conf) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { @@ -95,9 +95,8 @@ func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { } func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { - helpers.ClearAllCaches() + deposits, _, privs := SetupInitialDeposits(t, 257) - deposits, _, privs := SetupInitialDeposits(t, 64) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -123,7 +122,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 { @@ -149,9 +148,8 @@ func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { } func TestGenerateFullBlock_ValidAttestations(t *testing.T) { - helpers.ClearAllCaches() - deposits, _, privs := SetupInitialDeposits(t, 256) + eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) if err != nil { @@ -177,13 +175,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{ @@ -211,7 +209,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 { From c864627ec7c34f51bb3c1652006ceb2d6e9ec564 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 30 Oct 2019 18:23:00 -0700 Subject: [PATCH 07/82] Remove shards and committees (#3896) --- beacon-chain/archiver/service.go | 10 +- beacon-chain/archiver/service_test.go | 19 +- .../forkchoice/process_attestation.go | 13 +- .../forkchoice/process_attestation_test.go | 23 +- .../forkchoice/process_block_test.go | 8 - .../blockchain/receive_attestation_test.go | 9 +- beacon-chain/cache/committee.go | 14 +- beacon-chain/core/blocks/block_operations.go | 64 +- .../core/blocks/block_operations_test.go | 283 +-------- beacon-chain/core/epoch/BUILD.bazel | 1 - beacon-chain/core/epoch/epoch_processing.go | 244 +------- .../core/epoch/epoch_processing_test.go | 554 +++--------------- beacon-chain/core/epoch/participation_test.go | 10 +- .../core/epoch/precompute/BUILD.bazel | 1 - .../core/epoch/precompute/attestation.go | 14 +- .../core/epoch/precompute/attestation_test.go | 44 +- .../justification_finalization_test.go | 12 +- .../core/epoch/precompute/reward_penalty.go | 55 +- .../epoch/precompute/reward_penalty_test.go | 104 +--- .../epoch/spectest/crosslink_mainnet_test.go | 10 - .../epoch/spectest/crosslink_minimal_test.go | 10 - .../core/epoch/spectest/crosslink_test.go | 33 -- beacon-chain/core/helpers/BUILD.bazel | 2 - beacon-chain/core/helpers/attestation.go | 36 -- beacon-chain/core/helpers/attestation_test.go | 78 --- beacon-chain/core/helpers/committee.go | 292 +++------ beacon-chain/core/helpers/committee_test.go | 502 +++------------- beacon-chain/core/helpers/slot_epoch_test.go | 18 +- beacon-chain/core/helpers/validators_test.go | 34 +- beacon-chain/core/state/state.go | 11 - beacon-chain/core/state/state_test.go | 15 - beacon-chain/core/state/transition.go | 10 - beacon-chain/core/state/transition_test.go | 180 +----- beacon-chain/db/kv/archive_test.go | 14 - beacon-chain/db/kv/attestations_test.go | 45 +- beacon-chain/db/kv/slashings_test.go | 8 +- beacon-chain/operations/attestation_test.go | 95 +-- beacon-chain/operations/block.go | 2 +- beacon-chain/operations/block_test.go | 15 +- beacon-chain/rpc/attester_server.go | 18 +- beacon-chain/rpc/attester_server_test.go | 50 +- beacon-chain/rpc/beacon_chain_server.go | 12 +- beacon-chain/rpc/beacon_chain_server_test.go | 68 +-- beacon-chain/rpc/validator_server_test.go | 19 +- .../sync/initial-sync/round_robin_test.go | 16 +- .../sync/subscriber_beacon_blocks_test.go | 3 +- .../sync/validate_attester_slashing_test.go | 6 - .../sync/validate_beacon_blocks_test.go | 3 - proto/beacon/p2p/v1/types.pb.go | 359 +++--------- proto/beacon/p2p/v1/types.proto | 19 +- proto/beacon/rpc/v1_gateway/services.pb.go | 208 +++---- .../_compatibility/compatability_test.go | 4 - proto/eth/v1alpha1/attestation.pb.go | 543 ++++------------- proto/eth/v1alpha1/attestation.proto | 34 +- proto/testing/ssz_static_test.go | 2 - shared/params/config.go | 17 +- shared/params/config_test.go | 6 +- shared/params/spectest/config_test.go | 2 +- shared/testutil/block.go | 49 +- shared/testutil/block_test.go | 3 + slasher/db/indexed_attestations_test.go | 9 - slasher/rpc/server_test.go | 4 +- slasher/server_test.go | 2 +- validator/client/validator_attest.go | 2 +- validator/client/validator_attest_test.go | 9 +- 65 files changed, 748 insertions(+), 3611 deletions(-) delete mode 100644 beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go delete mode 100644 beacon-chain/core/epoch/spectest/crosslink_minimal_test.go delete mode 100644 beacon-chain/core/epoch/spectest/crosslink_test.go diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index 8cec5ef0c836..1eab3c6ad314 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -69,7 +69,7 @@ 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") } @@ -77,18 +77,14 @@ func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.Beacon if err != nil { return errors.Wrap(err, "could not generate seed") } - startShard, err := helpers.StartShard(headState, currentEpoch) - 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") } + info := ðpb.ArchivedCommitteeInfo{ Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, ProposerIndex: proposerIndex, } if err := s.beaconDB.SaveArchivedCommitteeInfo(ctx, currentEpoch, info); err != nil { diff --git a/beacon-chain/archiver/service_test.go b/beacon-chain/archiver/service_test.go index 9e583d3d73a9..ef09cf16abd6 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -128,11 +128,7 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { triggerNewHeadEvent(t, svc, [32]byte{}) currentEpoch := helpers.CurrentEpoch(headState) - startShard, err := helpers.StartShard(headState, currentEpoch) - if err != nil { - t.Fatal(err) - } - committeeCount, err := helpers.CommitteeCount(headState, currentEpoch) + committeeCount, err := helpers.CommitteeCountAtSlot(headState, helpers.StartSlot(currentEpoch)) if err != nil { t.Fatal(err) } @@ -146,8 +142,7 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { } wanted := ðpb.ArchivedCommitteeInfo{ Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, ProposerIndex: propIdx, } @@ -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,7 +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), - 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 9f6c477cdafa..36b4f170f277 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation.go @@ -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) @@ -225,11 +220,7 @@ func (s *Store) aggregateAttestation(ctx context.Context, att *ethpb.Attestation // 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) + return helpers.VerifySlotTime(baseState.GenesisTime, d.Slot+1) } // verifyAttestation validates input attestation is valid. diff --git a/beacon-chain/blockchain/forkchoice/process_attestation_test.go b/beacon-chain/blockchain/forkchoice/process_attestation_test.go index cda9bf7cae8f..b5208e127c37 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation_test.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation_test.go @@ -117,28 +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), - StateRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - LatestBlockHeader: ðpb.BeaconBlockHeader{}, - JustificationBits: []byte{0}, - CurrentJustifiedCheckpoint: ðpb.Checkpoint{}, - CurrentCrosslinks: crosslinks, - 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) diff --git a/beacon-chain/blockchain/forkchoice/process_block_test.go b/beacon-chain/blockchain/forkchoice/process_block_test.go index a1b1d233edc0..38f1fe124223 100644 --- a/beacon-chain/blockchain/forkchoice/process_block_test.go +++ b/beacon-chain/blockchain/forkchoice/process_block_test.go @@ -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}, @@ -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 d6c96cd963ce..7b7fe22468cc 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/cache/committee.go b/beacon-chain/cache/committee.go index 0b1ae83a5e08..0a02f817d377 100644 --- a/beacon-chain/cache/committee.go +++ b/beacon-chain/cache/committee.go @@ -7,7 +7,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" - "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "k8s.io/client-go/tools/cache" ) @@ -66,7 +65,7 @@ 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) { +func (c *CommitteeCache) ShuffledIndices(epoch uint64, index uint64) ([]uint64, error) { c.lock.RLock() defer c.lock.RUnlock() obj, exists, err := c.CommitteeCache.GetByKey(strconv.Itoa(int(epoch))) @@ -86,8 +85,7 @@ func (c *CommitteeCache) ShuffledIndices(epoch uint64, shard uint64) ([]uint64, return nil, ErrNotCommittee } - start, end := startEndIndices(item, shard) - + start, end := startEndIndices(item, index) return item.Committee[start:end], nil } @@ -208,12 +206,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/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index ef7fb6d7232d..eca912e0dd06 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -558,15 +558,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)", @@ -576,16 +567,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, ) @@ -594,7 +582,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, ) } @@ -610,34 +598,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 { @@ -649,34 +625,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 } @@ -706,6 +655,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 diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index bc02a5c20bb4..1734c856d145 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -35,10 +35,6 @@ 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{BlockHash: make([]byte, 32)}) if err != nil { @@ -80,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{ @@ -132,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{ @@ -180,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{ @@ -234,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{ @@ -637,18 +617,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, - }, }, }, }, @@ -679,9 +653,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}, @@ -690,9 +661,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}, @@ -723,9 +691,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), }, @@ -733,9 +698,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), }, @@ -761,9 +723,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}, } @@ -785,9 +744,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}, } @@ -845,9 +801,7 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) { { Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 0, - }, + Slot: 5, }, }, } @@ -862,14 +816,9 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) { t.Fatal(err) } - attestationSlot, err := helpers.AttestationDataSlot(beaconState, attestations[0].Data) - 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, ) @@ -885,13 +834,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,11 +848,6 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { } 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{} @@ -927,17 +865,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, @@ -954,11 +888,6 @@ func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) { t.Fatal(err) } beaconState.Slot += params.BeaconConfig().MinAttestationInclusionDelay - beaconState.CurrentCrosslinks = []*ethpb.Crosslink{ - { - Shard: 0, - }, - } beaconState.CurrentJustifiedCheckpoint.Root = []byte("hello-world") beaconState.CurrentEpochAttestations = []*pb.PendingAttestation{} @@ -993,17 +922,15 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { 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, @@ -1017,11 +944,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{} @@ -1049,67 +971,6 @@ 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{BlockHash: make([]byte, 32)}) - 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) @@ -1118,17 +979,12 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { 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, } @@ -1140,26 +996,14 @@ 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") } } @@ -1171,36 +1015,20 @@ func TestProcessAttestations_OK(t *testing.T) { 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 { @@ -1247,10 +1075,6 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { 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) @@ -1263,15 +1087,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 { @@ -1303,9 +1120,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) @@ -1342,30 +1156,19 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { 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 { @@ -1386,19 +1189,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) @@ -1444,17 +1244,13 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) { 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, @@ -1464,22 +1260,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) } @@ -1487,9 +1270,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++ { @@ -1512,20 +1292,20 @@ func TestConvertToIndexed_OK(t *testing.T) { { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x05}, - wantedCustodyBit0Indices: []uint64{28}, - wantedCustodyBit1Indices: []uint64{125}, + wantedCustodyBit0Indices: []uint64{4}, + wantedCustodyBit1Indices: []uint64{30}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x06}, - wantedCustodyBit0Indices: []uint64{125}, - wantedCustodyBit1Indices: []uint64{28}, + wantedCustodyBit0Indices: []uint64{30}, + wantedCustodyBit1Indices: []uint64{4}, }, { aggregationBitfield: bitfield.Bitlist{0x07}, custodyBitfield: bitfield.Bitlist{0x07}, wantedCustodyBit0Indices: []uint64{}, - wantedCustodyBit1Indices: []uint64{28, 125}, + wantedCustodyBit1Indices: []uint64{4, 30}, }, } @@ -1534,9 +1314,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 { @@ -1564,10 +1341,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++ { diff --git a/beacon-chain/core/epoch/BUILD.bazel b/beacon-chain/core/epoch/BUILD.bazel index d82cdc372f6f..bb290cd1218a 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 ec2f4930f31d..6ecd9cc8e68a 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) - if err != nil { - return nil, errors.Wrap(err, "could not get attestation slot") - } - headRoot, err := helpers.BlockRootAtSlot(state, slot) + headRoot, err := helpers.BlockRootAtSlot(state, srcAtt.Data.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 } @@ -513,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{} @@ -567,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. // @@ -852,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 a9eaef7b1cfd..942b5253eea6 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" @@ -31,9 +30,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}, } @@ -82,9 +78,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}, } } @@ -122,11 +116,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}, @@ -144,7 +136,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { balances[i] = params.BeaconConfig().MaxEffectiveBalance } state := &pb.BeaconState{ - Slot: 0, + Slot: 2, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: validators, @@ -170,20 +162,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) @@ -204,35 +196,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") } @@ -244,20 +237,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) @@ -277,26 +270,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") @@ -310,242 +303,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), - } - - 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), - 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), - } - 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() @@ -554,10 +311,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() @@ -663,9 +420,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", @@ -712,9 +469,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", @@ -761,9 +518,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", @@ -907,11 +664,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 slashed balances correctly updated. if newS.Slashings[ce] != newS.Slashings[ne] { t.Errorf("wanted slashed balance %d, got %d", @@ -934,33 +686,6 @@ 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, @@ -986,81 +711,6 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) { } } -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{24, 100, 106, 196, 285, 534, 641, 654} - 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 @@ -1084,33 +734,6 @@ func TestAttestationDelta_CantGetAttestation(t *testing.T) { } } -func TestAttestationDelta_CantGetAttestationIndices(t *testing.T) { - e := params.BeaconConfig().SlotsPerEpoch - - state := buildState(e+2, 1) - atts := make([]*pb.PendingAttestation, 2) - 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{}, - }, - InclusionDelay: uint64(i + 100), - AggregationBits: bitfield.Bitlist{0xFF, 0x01}, - } - } - state.PreviousEpochAttestations = atts - - _, _, err := attestationDelta(state) - wanted := "could not get attestation indices" - if !strings.Contains(err.Error(), wanted) { - t.Fatalf("Got: %v, want: %v", err.Error(), wanted) - } -} - func TestAttestationDelta_NoOneAttested(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := params.BeaconConfig().MinGenesisActiveValidatorCount / 32 @@ -1120,10 +743,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{}, }, @@ -1160,15 +779,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{}, }, @@ -1177,18 +791,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) @@ -1198,18 +805,20 @@ func TestAttestationDelta_SomeAttested(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389} + 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]) } @@ -1242,15 +851,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{}, }, @@ -1260,18 +864,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) @@ -1281,7 +878,7 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) { t.Fatal(err) } - attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389} + attestedIndices := []uint64{100, 106, 196, 641, 654, 1606} for _, i := range attestedIndices { base, err := BaseReward(state, i) if err != nil { @@ -1439,7 +1036,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) @@ -1454,15 +1051,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{}, }, @@ -1471,26 +1063,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(31999797616) + wanted = uint64(31999810265) if state.Balances[4] != wanted { t.Errorf("wanted balance: %d, got: %d", wanted, state.Balances[1]) @@ -1527,7 +1110,6 @@ 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), Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10), diff --git a/beacon-chain/core/epoch/participation_test.go b/beacon-chain/core/epoch/participation_test.go index 5e3fa26b0cb2..7ac2a09d6cf6 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,7 +36,6 @@ func TestComputeValidatorParticipation(t *testing.T) { BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: 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 a25903867c00..dc5e76c11cc3 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 ef36e36010fc..350506fa658e 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 5d1356d5d90d..43d250be2bb8 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -66,14 +66,9 @@ func TestSameHead(t *testing.T) { } 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 { @@ -100,14 +95,9 @@ func TestSameTarget(t *testing.T) { } 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 { @@ -134,14 +124,9 @@ func TestAttestedPrevEpoch(t *testing.T) { } 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}) @@ -167,14 +152,9 @@ func TestAttestedCurrentEpoch(t *testing.T) { } 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}) @@ -205,11 +185,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 a17078ed51f8..bf36f9a2093d 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 255371c78601..16ff60bb6665 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 } @@ -117,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[i].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 9a8adc55fe77..d442cc1f52da 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(31999797616) + 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{24, 100, 106, 196, 285, 534, 641, 654} + 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{24, 100, 106, 196, 285, 534, 641, 654} - 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,7 +162,6 @@ 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), Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10), 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 70d8989aef7f..000000000000 --- a/beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package spectest - -import ( - "testing" -) - -func TestCrosslinksProcessingMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - 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 155a11308cf8..000000000000 --- a/beacon-chain/core/epoch/spectest/crosslink_minimal_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package spectest - -import ( - "testing" -) - -func TestCrosslinksProcessingMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - 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 cf072f39e28b..000000000000 --- 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/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index b7baa822a2bc..17076597aa8d 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -54,14 +54,12 @@ 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", "//shared/bytesutil: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", diff --git a/beacon-chain/core/helpers/attestation.go b/beacon-chain/core/helpers/attestation.go index 246a8fc24f98..175cade62b99 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 504a5e1f1f1a..42b95e767cde 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{BlockHash: make([]byte, 32)}) - 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{BlockHash: make([]byte, 32)}) - 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{BlockHash: make([]byte, 32)}) - 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 diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index b1a35481b384..e91e35a4da69 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -19,68 +19,54 @@ import ( 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(epoch, index) if err != nil { return nil, errors.Wrap(err, "could not interface with committee cache") } @@ -89,6 +75,13 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui } } + 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,19 +92,7 @@ func CrosslinkCommittee(state *pb.BeaconState, epoch uint64, shard uint64) ([]ui 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 @@ -129,17 +110,17 @@ 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[:]) + cachedShuffledList, err := shuffledIndicesCache.IndicesByIndexSeed(index, seed[:]) if err != nil { return nil, err } @@ -154,15 +135,16 @@ func ComputeCommittee( if err != nil { return []uint64{}, errors.Wrapf(err, "could not get shuffled index at index %d", i) } - shuffledIndices[i-start] = validatorIndices[permutedIndex] + shuffledIndices[i-start] = indices[permutedIndex] } if err := shuffledIndicesCache.AddShuffledValidatorList(&cache.IndicesByIndexSeed{ - Index: indexShard, + Index: index, Seed: seed[:], ShuffledIndices: shuffledIndices, }); err != nil { return []uint64{}, errors.Wrap(err, "could not add shuffled indices list to cache") } + return shuffledIndices, nil } @@ -175,10 +157,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") } @@ -196,45 +178,31 @@ func AttestingIndices(state *pb.BeaconState, data *ethpb.AttestationData, bf bit return indices, nil } -// VerifyBitfieldLength verifies that a bitfield length matches the given committee size. -func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { - if bf.Len() != committeeSize { - return fmt.Errorf( - "wanted participants bitfield length %d, got: %d", - committeeSize, - bf.Len()) - } - 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]]: +// 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 shard to which the committee is assigned +// * ``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 // -// committees_per_slot = get_committee_count(state, epoch) // SLOTS_PER_EPOCH -// start_slot = compute_start_slot_of_epoch(epoch) +// start_slot = compute_start_slot_at_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) +// 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, shard, Slot(slot) +// return committee, CommitteeIndex(index), Slot(slot) // return None func CommitteeAssignment( state *pb.BeaconState, @@ -260,32 +228,22 @@ func CommitteeAssignment( proposerIndexToSlot[i] = slot } - committeeCount, err := CommitteeCount(state, epoch) - if err != nil { - return nil, 0, 0, false, 0, 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, 0, fmt.Errorf( - "could not get epoch start shard: %v", err) - } - 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) + countAtSlot, err := CommitteeCountAtSlot(state, slot) + if err != nil { + return nil, 0, 0, false, 0, fmt.Errorf( + "could not get committee count at slot: %v", err) + } + for i := uint64(0); i < countAtSlot; i++ { + committee, err := BeaconCommittee(state, slot, i) if err != nil { return nil, 0, 0, false, 0, fmt.Errorf( "could not get crosslink committee: %v", err) } - for _, index := range committee { - if validatorIndex == index { - proposerSlot, isProposer := proposerIndexToSlot[index] - return committee, shard, slot, isProposer, proposerSlot, nil + for i, v := range committee { + if validatorIndex == v { + proposerSlot, isProposer := proposerIndexToSlot[v] + return committee, uint64(i), slot, isProposer, proposerSlot, nil } } } @@ -294,96 +252,21 @@ func CommitteeAssignment( return []uint64{}, 0, 0, false, 0, 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 +// VerifyBitfieldLength verifies that a bitfield length matches the given committee size. +func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { + if bf.Len() != committeeSize { + return fmt.Errorf( + "wanted participants bitfield length %d, got: %d", + committeeSize, + bf.Len()) } - - return startShard, nil + return 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") } @@ -436,42 +319,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, state.Slot) 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 f24addad4454..b38cced1481a 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -15,106 +15,6 @@ import ( "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) @@ -147,27 +47,27 @@ 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") @@ -201,14 +101,14 @@ func TestComputeCommittee_WithCache(t *testing.T) { t.Fatal(err) } - // Test shuffled indices are correct for shard 3 committee - shard := uint64(3) - committee3, err := ComputeCommittee(indices, seed, shard, committeeCount) + // Test shuffled indices are correct for index 3 committee + index := uint64(3) + committee3, err := ComputeCommittee(indices, seed, index, committeeCount) if err != nil { t.Errorf("could not compute committee: %v", err) } - cachedIndices, err := shuffledIndicesCache.IndicesByIndexSeed(shard, seed[:]) + cachedIndices, err := shuffledIndicesCache.IndicesByIndexSeed(index, seed[:]) if err != nil { t.Fatal(err) } @@ -219,10 +119,6 @@ func TestComputeCommittee_WithCache(t *testing.T) { } 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++ { @@ -232,6 +128,7 @@ func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { } state := &pb.BeaconState{ + Slot: params.BeaconConfig().SlotsPerEpoch, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } @@ -240,37 +137,30 @@ func TestAttestationParticipants_NoCommitteeCache(t *testing.T) { tests := []struct { attestationSlot uint64 - stateSlot uint64 bitfield bitfield.Bitlist wanted []uint64 }{ { attestationSlot: 3, - stateSlot: 5, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{205, 150}, + wanted: []uint64{355, 416}, }, { attestationSlot: 2, - stateSlot: 10, bitfield: bitfield.Bitlist{0x05}, - wanted: []uint64{845}, + wanted: []uint64{447}, }, { attestationSlot: 11, - stateSlot: 10, bitfield: bitfield.Bitlist{0x07}, - wanted: []uint64{376, 664}, + 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 { @@ -288,9 +178,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) @@ -304,7 +191,7 @@ func TestAttestationParticipants_EmptyBitfield(t *testing.T) { 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 { @@ -331,7 +218,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{ @@ -345,54 +232,47 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { } tests := []struct { - index uint64 - slot uint64 - committee []uint64 - shard uint64 - isProposer bool - proposerSlot uint64 + index uint64 + slot uint64 + committee []uint64 + committeeIndex uint64 + isProposer bool + proposerSlot uint64 }{ { - index: 0, - slot: 144, - committee: []uint64{95, 0}, - shard: 16, - isProposer: false, - }, - { - index: 105, - slot: 171, - committee: []uint64{50, 105}, - shard: 43, - isProposer: false, + index: 0, + slot: 92, + committee: []uint64{46, 0}, + committeeIndex: 1, + isProposer: false, }, { - index: 0, - slot: 144, - committee: []uint64{95, 0}, - shard: 16, - isProposer: false, + index: 1, + slot: 70, + committee: []uint64{1, 58}, + committeeIndex: 0, + isProposer: true, + proposerSlot: 91, }, { - index: 11, - slot: 129, - committee: []uint64{22, 11}, - shard: 1, - isProposer: true, - proposerSlot: 179, + index: 11, + slot: 64, + committee: []uint64{30, 11}, + committeeIndex: 1, + isProposer: false, }, } for i, tt := range tests { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { ClearAllCaches() - committee, shard, slot, isProposer, proposerSlot, err := CommitteeAssignment(state, tt.slot/params.BeaconConfig().SlotsPerEpoch, tt.index) + committee, committeeIndex, slot, isProposer, 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", @@ -402,6 +282,10 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { 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) @@ -414,40 +298,8 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { } } -func TestCommitteeAssignment_EverySlotHasProposer(t *testing.T) { - params.UseMinimalConfig() - defer params.UseMainnetConfig() - - validators := make([]*ethpb.Validator, 64) - 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), - } - - ClearAllCaches() - proposerCount := uint64(0) - 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 { - proposerCount++ - } - } - if proposerCount != params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Did not get enough proposers, wanted: %d, got: %d", params.BeaconConfig().SlotsPerEpoch, proposerCount) - } -} - func TestCommitteeAssignment_CantFindValidator(t *testing.T) { - validators := make([]*ethpb.Validator, params.BeaconConfig().SlotsPerEpoch) + validators := make([]*ethpb.Validator, 1) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -458,7 +310,8 @@ func TestCommitteeAssignment_CantFindValidator(t *testing.T) { Slot: params.BeaconConfig().SlotsPerEpoch, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } - index := uint64(params.BeaconConfig().SlotsPerEpoch + 1) + + index := uint64(10000) _, _, _, _, _, err := CommitteeAssignment(state, 1, index) statusErr, ok := status.FromError(err) if !ok { @@ -469,148 +322,13 @@ func TestCommitteeAssignment_CantFindValidator(t *testing.T) { } } -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) - } - - } -} - 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{ @@ -629,9 +347,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{}, }, }, @@ -643,9 +359,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{}, }, }, @@ -656,9 +370,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{}, }, }, @@ -669,9 +381,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{}, }, }, @@ -684,9 +394,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{}, }, }, @@ -698,9 +406,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{}, }, }, @@ -802,8 +508,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) } @@ -812,60 +518,6 @@ 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) @@ -889,15 +541,15 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { 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) } @@ -927,15 +579,15 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { 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) } @@ -966,16 +618,16 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { } 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 } } @@ -1005,16 +657,16 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { } 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 } } @@ -1044,16 +696,16 @@ func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { } 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/slot_epoch_test.go b/beacon-chain/core/helpers/slot_epoch_test.go index 03767b4bb5cf..2a1bdc853bf5 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_test.go b/beacon-chain/core/helpers/validators_test.go index b3d1b688876b..2c19860dbbbf 100644 --- a/beacon-chain/core/helpers/validators_test.go +++ b/beacon-chain/core/helpers/validators_test.go @@ -30,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, } @@ -45,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, } @@ -60,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, @@ -76,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, } @@ -91,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, @@ -107,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, @@ -124,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, @@ -143,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) @@ -186,7 +154,7 @@ func TestBeaconProposerIndex_OK(t *testing.T) { }, { slot: 43, - index: 1752, + index: 1751, }, } diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index fe9bbd210d0a..b0a7b343027a 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -70,14 +70,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data activeIndexRoots[i] = zeroHash } - 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 @@ -125,9 +117,6 @@ func GenesisBeaconState(deposits []*ethpb.Deposit, genesisTime uint64, eth1Data Root: params.BeaconConfig().ZeroHash[:], }, - // Recent state. - CurrentCrosslinks: crosslinks, - PreviousCrosslinks: crosslinks, HistoricalRoots: [][]byte{}, BlockRoots: blockRoots, StateRoots: stateRoots, diff --git a/beacon-chain/core/state/state_test.go b/beacon-chain/core/state/state_test.go index 330527a94122..2b7c0787904d 100644 --- a/beacon-chain/core/state/state_test.go +++ b/beacon-chain/core/state/state_test.go @@ -15,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}) { @@ -35,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") } @@ -107,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") } diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index acb14da46952..e7e3b860d382 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -586,11 +586,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") @@ -631,11 +626,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 3713460e3f7b..dc9fd4898234 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -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,22 +92,18 @@ 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) + 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) @@ -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}, } @@ -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), @@ -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,28 +387,15 @@ 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) + 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{ @@ -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,7 +611,7 @@ 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), @@ -689,20 +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), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, @@ -722,20 +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), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, @@ -753,7 +675,6 @@ func TestProcessEpochPrecompute_CanProcess(t *testing.T) { func TestProcessEpoch_NotPanicOnEmptyActiveValidatorIndices(t *testing.T) { newState := &pb.BeaconState{ - Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), RandaoMixes: make([][]byte, params.BeaconConfig().SlotsPerEpoch), } @@ -783,41 +704,27 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { var atts []*pb.PendingAttestation for i := uint64(0); i < shardCount; 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), - CurrentCrosslinks: crosslinks, PreviousEpochAttestations: atts, } // Precache the shuffled indices for i := uint64(0); i < shardCount; i++ { - if _, err := helpers.CrosslinkCommittee(s, 0, i); err != nil { + if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } } @@ -856,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{}, @@ -872,7 +771,6 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { Validators: validators, Balances: validatorBalances, Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - CurrentJustifiedCheckpoint: ðpb.Checkpoint{ Root: []byte("hello-world"), }, @@ -880,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 @@ -902,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}, }, }, @@ -963,23 +852,11 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { 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), @@ -1002,7 +879,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { // Precache the shuffled indices for i := uint64(0); i < shardCount; i++ { - if _, err := helpers.CrosslinkCommittee(s, 0, i); err != nil { + if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } } @@ -1036,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, } @@ -1062,6 +931,7 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { Data: att.Data, CustodyBit: false, } + domain := helpers.Domain(s.Fork, 0, params.BeaconConfig().DomainBeaconAttester) sigs := make([]*bls.Signature, len(attestingIndices)) for i, indice := range attestingIndices { @@ -1100,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 diff --git a/beacon-chain/db/kv/archive_test.go b/beacon-chain/db/kv/archive_test.go index e883b9b63959..3200970d051d 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[:], - }, }, }, }, diff --git a/beacon-chain/db/kv/attestations_test.go b/beacon-chain/db/kv/attestations_test.go index 52b5e77f0590..6089b45387fa 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 777b60059e10..e4bdbe20a51f 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/operations/attestation_test.go b/beacon-chain/operations/attestation_test.go index 8ef357f2d928..463cae1c8767 100644 --- a/beacon-chain/operations/attestation_test.go +++ b/beacon-chain/operations/attestation_test.go @@ -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}, @@ -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, @@ -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) } @@ -234,35 +214,17 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) 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) } @@ -285,10 +247,6 @@ func TestHandleAttestation_Skips_PreviouslyAggregatedAttestations(t *testing.T) 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,7 +353,7 @@ 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) + 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, @@ -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 ae34009161c0..016f8ce64c1a 100644 --- a/beacon-chain/operations/block.go +++ b/beacon-chain/operations/block.go @@ -42,7 +42,7 @@ func (s *Service) handleProcessedBlock(ctx context.Context, message proto.Messag "index": i, "root": fmt.Sprintf("%#x", root), "aggregation_bits": fmt.Sprintf("%8b", att.AggregationBits.Bytes()), - "shard": att.Data.Crosslink.Shard, + "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 00325e92c228..52b637cb8f98 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/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index da240cdfc929..0758abdb829d 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -15,7 +15,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" 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" ) @@ -112,29 +111,14 @@ 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{ + // TODO(#3865): Fill in rest of the missing information 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 1b16be7c88b6..59ce5a2dee80 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -69,12 +69,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 { @@ -108,16 +104,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[:], @@ -142,11 +128,6 @@ func TestRequestAttestation_OK(t *testing.T) { 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{ BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ @@ -156,11 +137,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) { @@ -209,16 +185,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[:], @@ -243,11 +209,6 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { 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{ BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ @@ -255,12 +216,7 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { Root: justifiedBlockRoot[:], }, Target: ðpb.Checkpoint{ - Epoch: 156, - }, - Crosslink: ðpb.Crosslink{ - ParentRoot: crosslinkRoot[:], - EndEpoch: params.BeaconConfig().SlotsPerEpoch, - DataRoot: params.BeaconConfig().ZeroHash[:], + Epoch: 312, }, } diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index 7e1c6bfb2181..b6f78a66fbb6 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -48,7 +48,7 @@ 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. @@ -644,23 +644,17 @@ func (bs *BeaconChainServer) archivedValidatorCommittee( startSlot := helpers.StartSlot(epoch) committeeCount := archivedInfo.CommitteeCount committeesPerSlot := committeeCount / params.BeaconConfig().SlotsPerEpoch - epochStartShard := archivedInfo.StartShard seed := bytesutil.ToBytes32(archivedInfo.Seed) - shardCount := params.BeaconConfig().ShardCount 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) + committee, err := helpers.ComputeCommittee(activeIndices, seed, i, committeeCount) if err != nil { return nil, 0, 0, errors.Wrap(err, "could not compute committee") } for _, index := range committee { if validatorIndex == index { - return committee, shard, slot, nil + return committee, i, slot, nil } } } diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index a9fb2c7c383c..c508eed9e78d 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), @@ -1303,7 +1288,7 @@ 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) } @@ -1311,10 +1296,6 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing if err != nil { t.Fatal(err) } - startShard, err := helpers.StartShard(s, currentEpoch) - if err != nil { - t.Fatal(err) - } proposerIndex, err := helpers.BeaconProposerIndex(s) if err != nil { t.Fatal(err) @@ -1322,8 +1303,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing if err := db.SaveArchivedCommitteeInfo(context.Background(), 0, ðpb.ArchivedCommitteeInfo{ Seed: seed[:], - StartShard: startShard, - CommitteeCount: committeeCount, + CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, ProposerIndex: proposerIndex, }); err != nil { t.Fatal(err) @@ -1633,14 +1613,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, @@ -1649,7 +1622,6 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) BlockRoots: make([][]byte, 128), Slashings: []uint64{0, 1e9, 1e9}, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentCrosslinks: crosslinks, CurrentEpochAttestations: atts, FinalizedCheckpoint: ðpb.Checkpoint{}, JustificationBits: bitfield.Bitvector4{0x00}, diff --git a/beacon-chain/rpc/validator_server_test.go b/beacon-chain/rpc/validator_server_test.go index 9f99c8ef4de8..4d6ff5bf6251 100644 --- a/beacon-chain/rpc/validator_server_test.go +++ b/beacon-chain/rpc/validator_server_test.go @@ -177,10 +177,6 @@ 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 { t.Errorf("Assigned slot %d can't be higher than %d", res.ValidatorAssignment[0].Slot, state.Slot+params.BeaconConfig().SlotsPerEpoch) @@ -196,10 +192,6 @@ 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 { t.Errorf("Assigned slot %d can't be higher than %d", res.ValidatorAssignment[0].Slot, state.Slot+params.BeaconConfig().SlotsPerEpoch) @@ -516,7 +508,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) @@ -975,7 +967,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { Status: &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_ACTIVE, Eth1DepositBlockNumber: 10, - DepositInclusionSlot: 3413, + DepositInclusionSlot: 2218, }, }, {PublicKey: pubKey2, @@ -1250,13 +1242,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 f8dd97a9d6d2..f92ef621ec59 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -87,28 +87,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, }, }, @@ -139,7 +139,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{ // { @@ -169,7 +169,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 fd95d24d2dc7..84d46c7fd723 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 bac0d194b2b6..ea7a2853985c 100644 --- a/beacon-chain/sync/validate_attester_slashing_test.go +++ b/beacon-chain/sync/validate_attester_slashing_test.go @@ -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}, } @@ -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 6124e53fe281..4e014f3bf5dd 100644 --- a/beacon-chain/sync/validate_beacon_blocks_test.go +++ b/beacon-chain/sync/validate_beacon_blocks_test.go @@ -98,7 +98,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(), } @@ -154,7 +153,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(), } @@ -228,7 +226,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/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 834569dc3520..9655491f531b 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -37,17 +37,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"` + 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"` + 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:"-"` @@ -170,13 +167,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 @@ -205,20 +195,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 @@ -622,84 +598,80 @@ func init() { func init() { proto.RegisterFile("proto/beacon/p2p/v1/types.proto", fileDescriptor_e719e7d82cfa7b0d) } var fileDescriptor_e719e7d82cfa7b0d = []byte{ - // 1225 bytes of a gzipped FileDescriptorProto + // 1159 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x8f, 0xdb, 0xc4, - 0x17, 0x97, 0x77, 0xf3, 0xfd, 0xd2, 0x4e, 0x76, 0x37, 0xbb, 0x93, 0xaa, 0x6b, 0xda, 0x52, 0x07, - 0x8b, 0xb6, 0x2b, 0xd4, 0x4d, 0xea, 0x74, 0x9b, 0x74, 0x5b, 0x95, 0xaa, 0xee, 0x0f, 0x15, 0x04, - 0x12, 0x72, 0x4b, 0x25, 0x24, 0x84, 0x35, 0xb1, 0x27, 0xf6, 0xb0, 0x8e, 0xc7, 0xf2, 0x4c, 0xa2, - 0x6e, 0x11, 0xe2, 0xc0, 0x09, 0x2e, 0x5c, 0x38, 0x71, 0x83, 0x1b, 0x3f, 0xfe, 0x01, 0xe0, 0x04, - 0x27, 0x8e, 0xfc, 0xba, 0xc0, 0x21, 0x42, 0xbd, 0x01, 0x27, 0x72, 0xe4, 0x02, 0x9a, 0xf1, 0xcf, - 0xb4, 0x49, 0x89, 0x80, 0x9b, 0xfd, 0xe6, 0xf3, 0xf9, 0xbc, 0x37, 0xef, 0x3d, 0xfb, 0x3d, 0xa0, - 0x45, 0x31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a, 0x71, 0xeb, 0xea, 0x76, 0x5b, 0xb4, 0xd1, + 0x95, 0x45, 0xdb, 0xc8, 0x27, 0x8c, 0x5b, 0xd5, 0x82, 0xb6, 0xec, 0xa0, 0x1d, 0x50, 0x92, 0x83, + 0x78, 0x49, 0xa6, 0xf8, 0xd2, 0x9c, 0x14, 0x17, 0x02, 0x94, 0xe3, 0x58, 0x72, 0xe0, 0x65, 0x50, + 0x25, 0x81, 0xe3, 0x0f, 0xc5, 0x47, 0xda, 0x2e, 0xf6, 0xd1, 0x61, 0xf2, 0x85, 0x2b, 0x99, 0xf9, + 0x9e, 0xb0, 0xc2, 0x8b, 0x60, 0x25, 0x8c, 0x68, 0x48, 0x19, 0x8e, 0x92, 0x89, 0x5a, 0x92, 0xb8, + 0x53, 0xa9, 0x55, 0x4e, 0x53, 0xfd, 0x23, 0x05, 0xac, 0x15, 0x3c, 0x3d, 0x44, 0x51, 0x1f, 0x73, + 0x08, 0x93, 0xd5, 0xac, 0x14, 0x36, 0xf3, 0x2d, 0xb0, 0x56, 0xbc, 0x4b, 0xc8, 0xcd, 0x94, 0x94, + 0x63, 0x6d, 0x32, 0xd6, 0x4e, 0xe5, 0xe5, 0x10, 0xb3, 0xad, 0xda, 0xcd, 0xf7, 0xab, 0xd8, 0x41, + 0xb0, 0x05, 0xca, 0x21, 0x92, 0xa5, 0x94, 0xc4, 0xe5, 0x79, 0x44, 0x10, 0xa3, 0x04, 0x47, 0xbf, + 0x03, 0x6a, 0xd9, 0x00, 0x7f, 0x51, 0x2e, 0x67, 0xb1, 0x31, 0xf2, 0xda, 0x2a, 0x85, 0xda, 0x8a, + 0x98, 0xf3, 0x90, 0x2c, 0xf9, 0xac, 0xbf, 0x05, 0xce, 0x3f, 0x92, 0xc6, 0xbb, 0x81, 0xbb, 0x3b, + 0x64, 0x9c, 0xba, 0x87, 0x26, 0xe1, 0x59, 0x25, 0x94, 0x7f, 0x51, 0x09, 0x0d, 0x94, 0x9d, 0x58, + 0x49, 0x34, 0x8c, 0x74, 0x7b, 0xc2, 0x02, 0x4e, 0x26, 0xae, 0xbf, 0xab, 0x80, 0xea, 0x83, 0x6c, + 0x11, 0x9b, 0x88, 0x3b, 0x1e, 0xec, 0x4c, 0x5f, 0x28, 0x94, 0x85, 0xef, 0x13, 0x9d, 0xe9, 0xfb, + 0xc4, 0xd2, 0xa2, 0xd7, 0x09, 0xb3, 0xf2, 0xcd, 0xf1, 0x05, 0xe5, 0xdb, 0xe3, 0x0b, 0xca, 0x2f, + 0xc7, 0x17, 0x94, 0xee, 0xff, 0xe5, 0x75, 0xed, 0xda, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x18, + 0x6a, 0xdd, 0x83, 0x89, 0x0a, 0x00, 0x00, } func (m *BeaconState) Marshal() (dAtA []byte, err error) { @@ -861,18 +833,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 + dAtA[i] = 0xca i++ dAtA[i] = 0xb8 i++ @@ -935,54 +898,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:]) @@ -992,11 +923,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:]) @@ -1006,11 +937,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:]) @@ -1331,9 +1262,6 @@ 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) @@ -1359,18 +1287,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)) @@ -1975,25 +1891,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) } @@ -2170,74 +2067,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) } @@ -2271,7 +2100,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) } @@ -2307,7 +2136,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) } @@ -2343,7 +2172,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) } diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index 50df9a106f17..c893de62ca96 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -27,9 +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\""]; + // 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\""]; @@ -38,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 { diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index 1ae4b9f3e8ec..c7f6837657d9 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -186,7 +186,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"` - Index uint64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"` + Shard uint64 `protobuf:"varint,4,opt,name=shard,proto3" json:"shard,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -238,9 +238,9 @@ func (m *AttestationRequest) GetSlot() uint64 { return 0 } -func (m *AttestationRequest) GetIndex() uint64 { +func (m *AttestationRequest) GetShard() uint64 { if m != nil { - return m.Index + return m.Shard } return 0 } @@ -827,7 +827,7 @@ func (m *AssignmentResponse) GetValidatorAssignment() []*AssignmentResponse_Vali type AssignmentResponse_ValidatorAssignment struct { Committee []uint64 `protobuf:"varint,1,rep,packed,name=committee,proto3" json:"committee,omitempty"` - Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,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"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` @@ -871,9 +871,9 @@ func (m *AssignmentResponse_ValidatorAssignment) GetCommittee() []uint64 { return nil } -func (m *AssignmentResponse_ValidatorAssignment) GetIndex() uint64 { +func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { if m != nil { - return m.Index + return m.Shard } return 0 } @@ -1243,104 +1243,104 @@ func init() { func init() { proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_9eb4e94b85965285) } var fileDescriptor_9eb4e94b85965285 = []byte{ - // 1541 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4f, 0x4f, 0x1b, 0x4b, - 0x12, 0xcf, 0x18, 0x63, 0x48, 0xd9, 0xc0, 0xd0, 0x10, 0x70, 0x1c, 0xa2, 0xb0, 0xb3, 0xc9, 0x2e, - 0x20, 0xc5, 0x06, 0x27, 0x8a, 0xb2, 0x89, 0xb2, 0x91, 0xc1, 0x13, 0x62, 0x25, 0x32, 0x64, 0xec, - 0x40, 0x56, 0x39, 0x8c, 0xda, 0x76, 0x07, 0xb7, 0x62, 0x4f, 0x0f, 0x33, 0x6d, 0x2b, 0x5c, 0x56, - 0xda, 0x8f, 0xb0, 0x87, 0x3d, 0xaf, 0xf6, 0x33, 0xec, 0xe1, 0x7d, 0x85, 0xf7, 0x21, 0x9e, 0xde, - 0xe9, 0x1d, 0xde, 0xc7, 0x78, 0x9a, 0xee, 0x9e, 0x3f, 0xd8, 0x38, 0x98, 0xdc, 0xdc, 0x55, 0xf5, - 0xab, 0xaa, 0xae, 0xaa, 0xae, 0xaa, 0x31, 0x18, 0xae, 0xc7, 0x38, 0x2b, 0xb5, 0x08, 0x6e, 0x33, - 0xa7, 0xe4, 0xb9, 0xed, 0xd2, 0x70, 0xaf, 0xe4, 0x13, 0x6f, 0x48, 0xdb, 0xc4, 0x2f, 0x0a, 0x26, - 0x5a, 0x23, 0xbc, 0x4b, 0x3c, 0x32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c, 0x3e, 0x71, 0x78, 0x22, 0x5a, 0xc4, - 0x65, 0xed, 0xae, 0x2d, 0x1c, 0x56, 0x00, 0x10, 0x24, 0x71, 0xc5, 0xeb, 0x7b, 0xc0, 0xef, 0x29, - 0x40, 0x49, 0xbd, 0xca, 0x87, 0x73, 0x58, 0x8d, 0x1f, 0x0f, 0x8e, 0xf8, 0x22, 0xa4, 0xd9, 0xf2, - 0xdf, 0x27, 0x25, 0x7e, 0x5c, 0x53, 0xa2, 0x14, 0x63, 0xde, 0xca, 0x70, 0x9c, 0x58, 0xf8, 0x55, - 0x83, 0x95, 0x2b, 0x84, 0xd1, 0x06, 0xdc, 0x6e, 0xb3, 0x7e, 0x9f, 0x72, 0x4e, 0x88, 0xea, 0x42, - 0x31, 0x21, 0x0e, 0x56, 0x2a, 0x11, 0xac, 0x2b, 0xbb, 0xef, 0x03, 0xc8, 0x52, 0xdf, 0x76, 0xe5, - 0x50, 0xf0, 0x44, 0x0f, 0x9e, 0xb7, 0x80, 0xfa, 0x6a, 0x4c, 0x78, 0x23, 0x09, 0x9b, 0x1d, 0xad, - 0xfe, 0xd7, 0x51, 0xf5, 0x67, 0x36, 0xb5, 0xad, 0xc5, 0xf2, 0x5f, 0xa7, 0xad, 0xfe, 0xb0, 0xea, - 0x7f, 0x4a, 0xc1, 0xfa, 0x84, 0x97, 0x91, 0x50, 0xae, 0xfd, 0x90, 0x72, 0xf4, 0x37, 0xb8, 0x4b, - 0x78, 0x77, 0xcf, 0xee, 0x10, 0x97, 0xf9, 0x94, 0xcb, 0xc1, 0x6c, 0x3b, 0x83, 0x7e, 0x8b, 0x78, - 0x2a, 0x36, 0xc1, 0xec, 0xdf, 0xab, 0x4a, 0xbe, 0x18, 0xb2, 0x75, 0xc1, 0x45, 0x4f, 0x61, 0x2d, - 0x44, 0x51, 0xa7, 0xdd, 0x1b, 0xf8, 0x94, 0x39, 0x76, 0x22, 0x7c, 0xab, 0x8a, 0x5b, 0x0b, 0x99, - 0x8d, 0x20, 0x9c, 0xdb, 0xa0, 0xe3, 0xa8, 0xb9, 0xd8, 0xa2, 0xe4, 0xd4, 0x5c, 0x5b, 0x8a, 0xe9, - 0x66, 0x40, 0x46, 0xaf, 0x61, 0x43, 0x28, 0x08, 0x04, 0xa9, 0x63, 0x27, 0x60, 0xe7, 0x03, 0x32, - 0x90, 0x4d, 0x39, 0x6d, 0xdd, 0x0d, 0x65, 0x6a, 0x4e, 0xdc, 0xb5, 0x3e, 0x04, 0x02, 0xc6, 0x2b, - 0x58, 0xa8, 0xb2, 0x3e, 0xa6, 0x51, 0x0f, 0x5e, 0x85, 0x59, 0x69, 0x51, 0x3d, 0x11, 0x71, 0x40, - 0x6b, 0x90, 0xe9, 0x08, 0xb1, 0x70, 0x16, 0xcb, 0x93, 0xf1, 0x12, 0x16, 0x43, 0xb8, 0x0a, 0xf7, - 0x36, 0xe8, 0x41, 0x7d, 0x61, 0x3e, 0xf0, 0x88, 0xad, 0x30, 0x52, 0xd5, 0x52, 0x44, 0x97, 0x10, - 0xe3, 0xdf, 0x29, 0x58, 0x16, 0xd1, 0x6a, 0x7a, 0x24, 0x9e, 0x8c, 0x6f, 0x20, 0xcd, 0x3d, 0x55, - 0x8f, 0xd9, 0x72, 0x79, 0x52, 0xb6, 0xc6, 0x80, 0xc5, 0xe0, 0x50, 0x67, 0x1d, 0x62, 0x09, 0x7c, - 0xe1, 0xff, 0x1a, 0xcc, 0x87, 0x24, 0xf4, 0x1c, 0x66, 0x45, 0xda, 0x84, 0x2b, 0xd9, 0xb2, 0x11, - 0x6b, 0x25, 0xbc, 0x5b, 0x0c, 0x77, 0xaa, 0xe2, 0xbe, 0x30, 0x21, 0xd7, 0x24, 0x09, 0x18, 0x59, - 0x6d, 0x52, 0x23, 0xab, 0x4d, 0x30, 0x48, 0x5d, 0xec, 0x71, 0xda, 0xa6, 0xae, 0x18, 0x3a, 0x43, - 0xc6, 0x49, 0x38, 0x7b, 0x97, 0x93, 0x9c, 0x93, 0x80, 0x11, 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 0xee, 0xc1, 0xca, 0x41, 0x38, 0xba, 0x13, 0x23, 0x7e, 0x7b, 0x9a, 0x7d, - 0x42, 0x5a, 0xdc, 0x99, 0x7e, 0xf5, 0x40, 0xe7, 0xe3, 0xdd, 0xe1, 0x86, 0xf7, 0xbb, 0xe9, 0x86, - 0x8b, 0xfe, 0xa5, 0xc1, 0xea, 0x55, 0x9f, 0x54, 0xe8, 0xfa, 0x0c, 0x8d, 0x7f, 0xd5, 0x15, 0x9e, - 0xde, 0x0c, 0xa4, 0x7c, 0x18, 0x80, 0x3e, 0xba, 0x21, 0xa3, 0x89, 0x17, 0x99, 0xb0, 0x87, 0x17, - 0x76, 0xa7, 0x07, 0x28, 0xb3, 0xff, 0x88, 0x8a, 0x39, 0x5e, 0xb1, 0xd1, 0x5a, 0x51, 0x7e, 0xee, - 0x17, 0xc3, 0x3f, 0x16, 0x8a, 0x66, 0xdf, 0xe5, 0x17, 0x93, 0xd3, 0x38, 0xbe, 0x9e, 0xef, 0x6a, - 0xe8, 0x1d, 0x2c, 0x1c, 0x60, 0x87, 0x39, 0xb4, 0x8d, 0x7b, 0x6f, 0x09, 0xee, 0x4c, 0x54, 0x3b, - 0x45, 0x3f, 0x68, 0x65, 0x04, 0xe6, 0xc9, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x4d, 0x66, - 0x8f, 0x2f, 0x11, 0x00, 0x00, + // 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, 0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40, + 0xe7, 0x8c, 0xe3, 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, 0x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 0xb4, 0x85, 0xbb, 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, } // 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 c676b2c7b1fe..b93292190b3f 100644 --- a/proto/eth/v1alpha1/_compatibility/compatability_test.go +++ b/proto/eth/v1alpha1/_compatibility/compatability_test.go @@ -31,10 +31,6 @@ func TestProtoCompatability(t *testing.T) { a: &pb.Checkpoint{}, b: &upstreampb.Checkpoint{}, }, - { - a: &pb.Crosslink{}, - b: &upstreampb.Crosslink{}, - }, // beacon_block.proto { a: &pb.BeaconBlock{}, diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index b1dd5518ad25..f911673b6365 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -95,10 +95,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:"-"` @@ -137,6 +138,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 @@ -158,13 +173,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"` @@ -220,90 +228,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() { @@ -311,40 +239,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,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8f, 0x00, 0x6b, 0x55, - 0xe7, 0x3e, 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, 0xa8, 0x94, 0x20, 0x0e, 0xb8, 0x5c, 0xb8, 0xfa, 0xc8, 0xa5, 0x5a, 0x3b, 0xaf, + 0xbb, 0xab, 0xda, 0x79, 0xd6, 0xee, 0x33, 0x6a, 0xfb, 0x85, 0x1c, 0xfb, 0x05, 0x11, 0xca, 0x17, + 0xa0, 0x1e, 0x39, 0x21, 0xef, 0x06, 0x25, 0x2a, 0x44, 0xe2, 0xd0, 0xdb, 0xce, 0xee, 0xcc, 0xbc, + 0x99, 0x67, 0x99, 0xbd, 0xac, 0x0d, 0x12, 0x26, 0x40, 0x2a, 0xf9, 0x76, 0x24, 0xca, 0x5a, 0x89, + 0xa3, 0x44, 0x10, 0x81, 0x25, 0x41, 0x1a, 0xe7, 0xb1, 0x7b, 0xe6, 0xcf, 0x80, 0x14, 0x18, 0x68, + 0xaa, 0x18, 0x48, 0xc5, 0x7f, 0x88, 0xcf, 0x47, 0x52, 0x93, 0x6a, 0xf2, 0xb8, 0xc0, 0x2a, 0x91, + 0x28, 0x31, 0x71, 0xec, 0xbc, 0x39, 0x77, 0xc8, 0x3b, 0xb7, 0x27, 0xef, 0x12, 0xdd, 0x74, 0x58, + 0xf7, 0xd3, 0xda, 0x9b, 0x57, 0xec, 0x89, 0x90, 0xd2, 0x80, 0x74, 0xf0, 0x2c, 0xd7, 0x64, 0xfb, + 0xc1, 0x41, 0x70, 0xb8, 0x97, 0xa6, 0xb7, 0x8b, 0xe1, 0x63, 0x6b, 0xaf, 0x47, 0x95, 0xb8, 0x9c, + 0x46, 0xef, 0xde, 0x4e, 0x4e, 0xa2, 0x5f, 0x8b, 0xe1, 0x9b, 0x8d, 0x71, 0xb5, 0xb9, 0xb2, 0x95, + 0x20, 0x5d, 0x94, 0x22, 0xb7, 0x89, 0xc4, 0x51, 0xae, 0xe9, 0x5c, 0x43, 0x39, 0x8b, 0x53, 0x4d, + 0xa5, 0xb6, 0x94, 0xf5, 0x36, 0xbc, 0x53, 0x4d, 0x96, 0x4f, 0x59, 0x38, 0x13, 0x24, 0xfa, 0x9d, + 0x83, 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xb3, 0x1c, 0x04, 0x3f, 0x96, 0x83, 0xe0, 0xeb, 0xfb, 0xad, + 0xdf, 0xcd, 0xa1, 0xe4, 0xef, 0x3f, 0xe5, 0x03, 0x90, 0xca, 0x77, 0xdd, 0xfd, 0xf1, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x26, 0x91, 0xff, 0x18, 0x4a, 0x03, 0x00, 0x00, } func (m *Attestation) Marshal() (dAtA []byte, err error) { @@ -411,14 +334,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:]) @@ -428,7 +361,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:]) @@ -437,16 +370,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) } @@ -485,54 +408,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) @@ -576,6 +451,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)) @@ -588,10 +469,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) } @@ -617,35 +494,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++ @@ -881,10 +729,10 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BeaconBlockRoot", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Slot", wireType) } - var byteLen int + m.Slot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAttestation @@ -894,31 +742,35 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.Slot |= uint64(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 + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) } - m.BeaconBlockRoot = append(m.BeaconBlockRoot[:0], dAtA[iNdEx:postIndex]...) - if m.BeaconBlockRoot == nil { - m.BeaconBlockRoot = []byte{} + 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 + } } - iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BeaconBlockRoot", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAttestation @@ -928,31 +780,29 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthAttestation } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAttestation } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Source == nil { - m.Source = &Checkpoint{} - } - if err := m.Source.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.BeaconBlockRoot = append(m.BeaconBlockRoot[:0], dAtA[iNdEx:postIndex]...) + if m.BeaconBlockRoot == nil { + m.BeaconBlockRoot = []byte{} } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -979,16 +829,16 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Target == nil { - m.Target = &Checkpoint{} + if m.Source == nil { + m.Source = &Checkpoint{} } - if err := m.Target.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Source.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Crosslink", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1015,10 +865,10 @@ func (m *AttestationData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Crosslink == nil { - m.Crosslink = &Crosslink{} + if m.Target == nil { + m.Target = &Checkpoint{} } - if err := m.Crosslink.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Target.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1154,185 +1004,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 b53a074c32ea..74cdfb5a8645 100644 --- a/proto/eth/v1alpha1/attestation.proto +++ b/proto/eth/v1alpha1/attestation.proto @@ -22,24 +22,27 @@ message Attestation { } 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/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index 733903e5c168..bf0c6e8e9952 100644 --- a/proto/testing/ssz_static_test.go +++ b/proto/testing/ssz_static_test.go @@ -110,8 +110,6 @@ func UnmarshalledSSZ(serializedBytes []byte, folderName string) (interface{}, er obj = &pb.BeaconState{} case "Checkpoint": obj = ðpb.Checkpoint{} - case "Crosslink": - obj = ðpb.Crosslink{} case "Deposit": obj = ðpb.Deposit{} case "DepositData": diff --git a/shared/params/config.go b/shared/params/config.go index c73214602a6e..12ac3805faed 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. @@ -108,14 +108,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, @@ -134,8 +134,8 @@ var defaultBeaconConfig = &BeaconChainConfig{ // Time parameter constants. MinAttestationInclusionDelay: 1, - SecondsPerSlot: 6, - SlotsPerEpoch: 64, + SecondsPerSlot: 12, + SlotsPerEpoch: 32, MinSeedLookahead: 1, MaxSeedLookhead: 4, SlotsPerEth1VotingPeriod: 1024, @@ -238,7 +238,6 @@ func DemoBeaconConfig() *BeaconChainConfig { func MinimalSpecConfig() *BeaconChainConfig { minimalConfig := *defaultBeaconConfig // Misc - minimalConfig.ShardCount = 8 minimalConfig.TargetCommitteeSize = 4 minimalConfig.MaxValidatorsPerCommittee = 4096 minimalConfig.MinPerEpochChurnLimit = 4 diff --git a/shared/params/config_test.go b/shared/params/config_test.go index 1577410852a3..7f7a0fe5bb8b 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 84763358b33e..133fe0f5ee85 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 92a11cbfa597..855839fbfa65 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -179,18 +179,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[:], @@ -220,7 +214,6 @@ func generateAttesterSlashings( att1.Signature = bls.AggregateSignatures([]*bls.Signature{sig}).Marshal() attData2 := ðpb.AttestationData{ - Crosslink: crosslink, Target: ðpb.Checkpoint{ Epoch: i, Root: params.BeaconConfig().ZeroHash[:], @@ -281,44 +274,10 @@ func generateAttestations( currentEpoch := helpers.CurrentEpoch(bState) attestations := make([]*ethpb.Attestation, maxAttestations) - committeeCount, err := helpers.CommitteeCount(bState, currentEpoch) - 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) + committee, err := helpers.BeaconCommittee(bState, currentEpoch, 0) 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 { @@ -336,11 +295,11 @@ func generateAttestations( } } + committeeSize := uint64(len(committee)) custodyBits := bitfield.NewBitlist(committeeSize) att := ðpb.Attestation{ Data: ðpb.AttestationData{ BeaconBlockRoot: headRoot, - Crosslink: crosslink, Source: bState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ Epoch: currentEpoch, @@ -367,7 +326,7 @@ func generateAttestations( } bitsPerAtt := committeeSize / maxAttestations - domain := helpers.Domain(bState.Fork, parentCrosslink.EndEpoch+1, params.BeaconConfig().DomainBeaconAttester) + 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 c68b1b2aadc5..e13b34d251f2 100644 --- a/shared/testutil/block_test.go +++ b/shared/testutil/block_test.go @@ -11,6 +11,7 @@ import ( ) func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { + t.Skip("Disabled until bug 3891 is fixed") deposits, _, privs := SetupInitialDeposits(t, 128) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) @@ -33,6 +34,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { } func TestGenerateFullBlock_ThousandValidators(t *testing.T) { + t.Skip("Disabled until bug 3891 is fixed") params.OverrideBeaconConfig(params.MinimalSpecConfig()) defer params.OverrideBeaconConfig(params.MainnetConfig()) deposits, _, privs := SetupInitialDeposits(t, 1024) @@ -56,6 +58,7 @@ func TestGenerateFullBlock_ThousandValidators(t *testing.T) { } func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { + t.Skip("Disabled until bug 3891 is fixed") // Changing to minimal config as this will process 4 epochs of blocks. params.OverrideBeaconConfig(params.MinimalSpecConfig()) defer params.OverrideBeaconConfig(params.MainnetConfig()) diff --git a/slasher/db/indexed_attestations_test.go b/slasher/db/indexed_attestations_test.go index d7197177e80f..b3adc682e66e 100644 --- a/slasher/db/indexed_attestations_test.go +++ b/slasher/db/indexed_attestations_test.go @@ -21,9 +21,6 @@ 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: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, { @@ -31,9 +28,6 @@ func init() { 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: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, { @@ -41,9 +35,6 @@ func init() { iA: ðpb.IndexedAttestation{Signature: []byte("let me in 3rd"), CustodyBit_0Indices: []uint64{0}, Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, Target: ðpb.Checkpoint{Epoch: 0}, - Crosslink: ðpb.Crosslink{ - Shard: 4, - }, }}, }, } diff --git a/slasher/rpc/server_test.go b/slasher/rpc/server_test.go index 6ef7b5af9689..f21d9d3ed14c 100644 --- a/slasher/rpc/server_test.go +++ b/slasher/rpc/server_test.go @@ -124,7 +124,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) @@ -142,7 +142,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/slasher/server_test.go b/slasher/server_test.go index 61b8a5334a46..47ea2c43ca6b 100644 --- a/slasher/server_test.go +++ b/slasher/server_test.go @@ -131,7 +131,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/validator/client/validator_attest.go b/validator/client/validator_attest.go index 5e8e24267874..83cd309da8db 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -116,7 +116,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 f9df738564b3..028dcf6a1cbf 100644 --- a/validator/client/validator_attest_test.go +++ b/validator/client/validator_attest_test.go @@ -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 @@ -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, @@ -229,7 +226,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() }) @@ -277,9 +273,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( From 2c883643df4a20235c6da184edfc52b4b275c564 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 31 Oct 2019 14:39:09 -0700 Subject: [PATCH 08/82] Epoch spec tests v0.9 (#3907) --- WORKSPACE | 13 +- beacon-chain/core/blocks/block_operations.go | 2 +- .../spectest/final_updates_mainnet_test.go | 1 - .../spectest/final_updates_minimal_test.go | 2 - ...ification_and_finalization_mainnet_test.go | 1 - .../epoch/spectest/registry_mainnet_test.go | 1 - .../epoch/spectest/registry_minimal_test.go | 1 - .../epoch/spectest/slashings_mainnet_test.go | 1 - .../epoch/spectest/slashings_minimal_test.go | 1 - beacon-chain/core/state/transition.go | 2 +- .../db/finalized_block_root_container.pb.go | 410 ++++++++++++++++++ proto/beacon/p2p/v1/types.pb.go | 152 +++---- proto/eth/v1alpha1/attestation.pb.go | 54 +-- proto/eth/v1alpha1/attestation.proto | 4 +- proto/ssz_proto_library.bzl | 12 +- shared/params/config.go | 7 +- 16 files changed, 529 insertions(+), 135 deletions(-) create mode 100755 proto/beacon/db/finalized_block_root_container.pb.go diff --git a/WORKSPACE b/WORKSPACE index 4e28f444ac16..db3521c86b20 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( diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index eca912e0dd06..fd80f2399315 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) diff --git a/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go b/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go index 20a52d2f2368..eed594f43152 100644 --- a/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/final_updates_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestFinalUpdatesMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runFinalUpdatesTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go b/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go index ad76e54884b5..f34daf532d01 100644 --- a/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/final_updates_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestFinalUpdatesMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runFinalUpdatesTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go b/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go index 004b680fd9d8..6b63703f4d84 100644 --- a/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/justification_and_finalization_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestJustificationAndFinalizationMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runJustificationAndFinalizationTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/registry_mainnet_test.go b/beacon-chain/core/epoch/spectest/registry_mainnet_test.go index dbe0769c1c7b..8315eab08164 100644 --- a/beacon-chain/core/epoch/spectest/registry_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/registry_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestRegistryUpdatesMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runRegistryUpdatesTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/registry_minimal_test.go b/beacon-chain/core/epoch/spectest/registry_minimal_test.go index 50376225f254..be78f72e7c06 100644 --- a/beacon-chain/core/epoch/spectest/registry_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/registry_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestRegistryUpdatesMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runRegistryUpdatesTests(t, "minimal") } diff --git a/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go b/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go index c1b5a61dfb60..9ae037af5be2 100644 --- a/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go +++ b/beacon-chain/core/epoch/spectest/slashings_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestSlashingsMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runSlashingsTests(t, "mainnet") } diff --git a/beacon-chain/core/epoch/spectest/slashings_minimal_test.go b/beacon-chain/core/epoch/spectest/slashings_minimal_test.go index b0f5b27dee39..5b337effec75 100644 --- a/beacon-chain/core/epoch/spectest/slashings_minimal_test.go +++ b/beacon-chain/core/epoch/spectest/slashings_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestSlashingsMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runSlashingsTests(t, "minimal") } diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index e7e3b860d382..cb5db4c69078 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -61,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) } } diff --git a/proto/beacon/db/finalized_block_root_container.pb.go b/proto/beacon/db/finalized_block_root_container.pb.go new file mode 100755 index 000000000000..a7eae5c80789 --- /dev/null +++ b/proto/beacon/db/finalized_block_root_container.pb.go @@ -0,0 +1,410 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: proto/beacon/db/finalized_block_root_container.proto + +package db + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type FinalizedBlockRootContainer struct { + ParentRoot []byte `protobuf:"bytes,1,opt,name=parent_root,json=parentRoot,proto3" json:"parent_root,omitempty"` + ChildRoot []byte `protobuf:"bytes,2,opt,name=child_root,json=childRoot,proto3" json:"child_root,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FinalizedBlockRootContainer) Reset() { *m = FinalizedBlockRootContainer{} } +func (m *FinalizedBlockRootContainer) String() string { return proto.CompactTextString(m) } +func (*FinalizedBlockRootContainer) ProtoMessage() {} +func (*FinalizedBlockRootContainer) Descriptor() ([]byte, []int) { + return fileDescriptor_f952363f5bc83b7b, []int{0} +} +func (m *FinalizedBlockRootContainer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalizedBlockRootContainer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalizedBlockRootContainer.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 *FinalizedBlockRootContainer) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalizedBlockRootContainer.Merge(m, src) +} +func (m *FinalizedBlockRootContainer) XXX_Size() int { + return m.Size() +} +func (m *FinalizedBlockRootContainer) XXX_DiscardUnknown() { + xxx_messageInfo_FinalizedBlockRootContainer.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalizedBlockRootContainer proto.InternalMessageInfo + +func (m *FinalizedBlockRootContainer) GetParentRoot() []byte { + if m != nil { + return m.ParentRoot + } + return nil +} + +func (m *FinalizedBlockRootContainer) GetChildRoot() []byte { + if m != nil { + return m.ChildRoot + } + return nil +} + +func init() { + proto.RegisterType((*FinalizedBlockRootContainer)(nil), "prysm.beacon.db.FinalizedBlockRootContainer") +} + +func init() { + proto.RegisterFile("proto/beacon/db/finalized_block_root_container.proto", fileDescriptor_f952363f5bc83b7b) +} + +var fileDescriptor_f952363f5bc83b7b = []byte{ + // 196 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x29, 0x28, 0xca, 0x2f, + 0xc9, 0xd7, 0x4f, 0x4a, 0x4d, 0x4c, 0xce, 0xcf, 0xd3, 0x4f, 0x49, 0xd2, 0x4f, 0xcb, 0xcc, 0x4b, + 0xcc, 0xc9, 0xac, 0x4a, 0x4d, 0x89, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0x8e, 0x2f, 0xca, 0xcf, 0x2f, + 0x89, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0xd2, 0x03, 0x2b, 0x17, 0xe2, 0x2f, + 0x28, 0xaa, 0x2c, 0xce, 0xd5, 0x83, 0xe8, 0xd2, 0x4b, 0x49, 0x52, 0x8a, 0xe5, 0x92, 0x76, 0x83, + 0x69, 0x74, 0x02, 0xe9, 0x0b, 0xca, 0xcf, 0x2f, 0x71, 0x86, 0xe9, 0x12, 0x92, 0xe7, 0xe2, 0x2e, + 0x48, 0x2c, 0x4a, 0xcd, 0x2b, 0x01, 0x1b, 0x27, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x13, 0xc4, 0x05, + 0x11, 0x02, 0xa9, 0x14, 0x92, 0xe5, 0xe2, 0x4a, 0xce, 0xc8, 0xcc, 0x49, 0x81, 0xc8, 0x33, 0x81, + 0xe5, 0x39, 0xc1, 0x22, 0x20, 0x69, 0x27, 0x9b, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, + 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x1f, 0xec, 0x90, 0xc4, 0x92, 0xcc, 0xe4, 0x9c, 0xc4, 0xa4, 0x62, 0x08, 0x4f, 0x1f, 0xcd, + 0x4b, 0x49, 0x6c, 0x60, 0x01, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xd3, 0xda, 0x04, + 0xec, 0x00, 0x00, 0x00, +} + +func (m *FinalizedBlockRootContainer) 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 *FinalizedBlockRootContainer) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ParentRoot) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintFinalizedBlockRootContainer(dAtA, i, uint64(len(m.ParentRoot))) + i += copy(dAtA[i:], m.ParentRoot) + } + if len(m.ChildRoot) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintFinalizedBlockRootContainer(dAtA, i, uint64(len(m.ChildRoot))) + i += copy(dAtA[i:], m.ChildRoot) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintFinalizedBlockRootContainer(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *FinalizedBlockRootContainer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ParentRoot) + if l > 0 { + n += 1 + l + sovFinalizedBlockRootContainer(uint64(l)) + } + l = len(m.ChildRoot) + if l > 0 { + n += 1 + l + sovFinalizedBlockRootContainer(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovFinalizedBlockRootContainer(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozFinalizedBlockRootContainer(x uint64) (n int) { + return sovFinalizedBlockRootContainer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *FinalizedBlockRootContainer) 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 ErrIntOverflowFinalizedBlockRootContainer + } + 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: FinalizedBlockRootContainer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalizedBlockRootContainer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChildRoot", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChildRoot = append(m.ChildRoot[:0], dAtA[iNdEx:postIndex]...) + if m.ChildRoot == nil { + m.ChildRoot = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFinalizedBlockRootContainer(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthFinalizedBlockRootContainer + } + 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 skipFinalizedBlockRootContainer(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthFinalizedBlockRootContainer + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthFinalizedBlockRootContainer + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFinalizedBlockRootContainer + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipFinalizedBlockRootContainer(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthFinalizedBlockRootContainer + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthFinalizedBlockRootContainer = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFinalizedBlockRootContainer = fmt.Errorf("proto: integer overflow") +) diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 9655491f531b..eebd32c2d6ef 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -39,8 +39,8 @@ type BeaconState struct { Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` 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"` + 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"` @@ -598,80 +598,80 @@ func init() { func init() { proto.RegisterFile("proto/beacon/p2p/v1/types.proto", fileDescriptor_e719e7d82cfa7b0d) } var fileDescriptor_e719e7d82cfa7b0d = []byte{ - // 1159 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x8f, 0xdb, 0xc4, - 0x17, 0x97, 0x77, 0xf3, 0xfd, 0xd2, 0x4e, 0xd2, 0xcd, 0xee, 0xa4, 0xea, 0x9a, 0xb6, 0xd4, 0xc1, - 0xa2, 0xed, 0x0a, 0x75, 0x93, 0x3a, 0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da, 0x2e, 0xf6, 0xd1, 0x61, 0xf2, 0x85, 0x2b, 0x99, 0xf9, - 0x9e, 0xb0, 0xc2, 0x8b, 0x60, 0x25, 0x8c, 0x68, 0x48, 0x19, 0x8e, 0x92, 0x89, 0x5a, 0x92, 0xb8, - 0x53, 0xa9, 0x55, 0x4e, 0x53, 0xfd, 0x23, 0x05, 0xac, 0x15, 0x3c, 0x3d, 0x44, 0x51, 0x1f, 0x73, - 0x08, 0x93, 0xd5, 0xac, 0x14, 0x36, 0xf3, 0x2d, 0xb0, 0x56, 0xbc, 0x4b, 0xc8, 0xcd, 0x94, 0x94, - 0x63, 0x6d, 0x32, 0xd6, 0x4e, 0xe5, 0xe5, 0x10, 0xb3, 0xad, 0xda, 0xcd, 0xf7, 0xab, 0xd8, 0x41, - 0xb0, 0x05, 0xca, 0x21, 0x92, 0xa5, 0x94, 0xc4, 0xe5, 0x79, 0x44, 0x10, 0xa3, 0x04, 0x47, 0xbf, - 0x03, 0x6a, 0xd9, 0x00, 0x7f, 0x51, 0x2e, 0x67, 0xb1, 0x31, 0xf2, 0xda, 0x2a, 0x85, 0xda, 0x8a, - 0x98, 0xf3, 0x90, 0x2c, 0xf9, 0xac, 0xbf, 0x05, 0xce, 0x3f, 0x92, 0xc6, 0xbb, 0x81, 0xbb, 0x3b, - 0x64, 0x9c, 0xba, 0x87, 0x26, 0xe1, 0x59, 0x25, 0x94, 0x7f, 0x51, 0x09, 0x0d, 0x94, 0x9d, 0x58, - 0x49, 0x34, 0x8c, 0x74, 0x7b, 0xc2, 0x02, 0x4e, 0x26, 0xae, 0xbf, 0xab, 0x80, 0xea, 0x83, 0x6c, - 0x11, 0x9b, 0x88, 0x3b, 0x1e, 0xec, 0x4c, 0x5f, 0x28, 0x94, 0x85, 0xef, 0x13, 0x9d, 0xe9, 0xfb, - 0xc4, 0xd2, 0xa2, 0xd7, 0x09, 0xb3, 0xf2, 0xcd, 0xf1, 0x05, 0xe5, 0xdb, 0xe3, 0x0b, 0xca, 0x2f, - 0xc7, 0x17, 0x94, 0xee, 0xff, 0xe5, 0x75, 0xed, 0xda, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x18, - 0x6a, 0xdd, 0x83, 0x89, 0x0a, 0x00, 0x00, + // 1158 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x8f, 0xdb, 0x44, + 0x14, 0x97, 0x77, 0x03, 0xb4, 0x93, 0x74, 0xb3, 0x3b, 0xa9, 0xba, 0xa6, 0x2d, 0x75, 0xb0, 0x68, + 0xbb, 0x42, 0xdd, 0xa4, 0x4e, 0xb7, 0x49, 0xb7, 0x55, 0x5b, 0xd5, 0x6d, 0x51, 0x41, 0x20, 0x21, + 0x53, 0x56, 0x42, 0x42, 0x58, 0x13, 0x7b, 0x12, 0x0f, 0xeb, 0x78, 0x2c, 0xcf, 0x24, 0xda, 0x5d, + 0x84, 0x38, 0x70, 0xe2, 0x80, 0xb8, 0x70, 0xe2, 0x06, 0xff, 0x05, 0x70, 0xe2, 0xe3, 0xc0, 0x91, + 0xaf, 0x0b, 0x1c, 0x22, 0xb4, 0x37, 0xe0, 0x44, 0x8e, 0x3d, 0xa1, 0x19, 0x7f, 0xa6, 0x9b, 0x40, + 0x84, 0xb8, 0xd9, 0x6f, 0x7e, 0xbf, 0xdf, 0x7b, 0x7e, 0xef, 0xf9, 0xbd, 0x01, 0x5a, 0x18, 0x51, + 0x4e, 0x9b, 0x5d, 0x8c, 0x1c, 0x1a, 0x34, 0xc3, 0x56, 0xd8, 0x1c, 0x19, 0x4d, 0xbe, 0x1f, 0x62, + 0xd6, 0x90, 0x27, 0xf0, 0x14, 0xe6, 0x1e, 0x8e, 0xf0, 0x70, 0xd0, 0x88, 0x31, 0x8d, 0xb0, 0x15, + 0x36, 0x46, 0xc6, 0xe9, 0xe7, 0x62, 0x22, 0xe6, 0x5e, 0x73, 0x64, 0x20,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, 0xcc, 0x53, 0x93, 0xb1, 0x06, 0x19, 0x3b, 0xd8, 0x64, 0xe4, 0x00, 0x5f, 0xd7, + 0xaf, 0x19, 0xdb, 0xad, 0x4b, 0x57, 0x5a, 0xba, 0x05, 0x24, 0xd6, 0x12, 0x50, 0xc1, 0x14, 0xb5, + 0xc1, 0x09, 0xf3, 0xa7, 0x7f, 0x61, 0x4a, 0x6c, 0xcc, 0xb4, 0xc0, 0xaa, 0x47, 0x18, 0xa7, 0x11, + 0x71, 0x90, 0x9f, 0xd0, 0x7f, 0x8e, 0xe9, 0x17, 0x26, 0x63, 0x4d, 0xcf, 0xe9, 0xb7, 0x05, 0xb7, + 0x2e, 0xde, 0x07, 0x68, 0xef, 0xba, 0x6e, 0xb4, 0x3b, 0x9d, 0x4e, 0xcb, 0x68, 0xeb, 0x56, 0x35, + 0x17, 0x88, 0x35, 0x6f, 0x82, 0xe3, 0x98, 0x7b, 0x86, 0xed, 0x22, 0x8e, 0xd4, 0xcf, 0xd7, 0x65, + 0x62, 0xb4, 0x39, 0x89, 0xb9, 0xcf, 0x3d, 0xe3, 0x1e, 0xe2, 0xc8, 0x3a, 0x86, 0x93, 0x27, 0xf8, + 0x26, 0xa8, 0x66, 0x74, 0x7b, 0x44, 0x39, 0x66, 0xea, 0x17, 0xeb, 0xf5, 0xe5, 0x05, 0x44, 0x4c, + 0x38, 0x19, 0x6b, 0x2b, 0x79, 0x88, 0x97, 0x5b, 0x5b, 0xba, 0x75, 0x22, 0x15, 0xde, 0x11, 0x52, + 0x70, 0x13, 0xc0, 0x58, 0x1d, 0x87, 0x94, 0x11, 0x6e, 0x93, 0xc0, 0xc5, 0x7b, 0xea, 0x97, 0xeb, + 0xb2, 0x2b, 0x56, 0x25, 0x36, 0x3e, 0x79, 0x51, 0x1c, 0xc0, 0xb7, 0x00, 0xc8, 0x9a, 0x95, 0xa9, + 0x9f, 0x6a, 0x32, 0x8e, 0xfa, 0x9c, 0x38, 0x76, 0x52, 0xa4, 0x79,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0, 0xbd, 0x3b, 0x64, + 0x9c, 0xba, 0xfb, 0x26, 0xe1, 0x59, 0x25, 0x94, 0xff, 0x50, 0x09, 0x0d, 0x94, 0x9d, 0x58, 0x49, + 0x34, 0x8c, 0x74, 0x7b, 0xcc, 0x02, 0x4e, 0x26, 0xae, 0xbf, 0xaf, 0x80, 0xea, 0x83, 0x6c, 0x11, + 0x9b, 0x88, 0x3b, 0x1e, 0xec, 0x4c, 0x5f, 0x28, 0x94, 0x85, 0xef, 0x13, 0x9d, 0xe9, 0xfb, 0xc4, + 0xd2, 0xa2, 0xd7, 0x09, 0xb3, 0xf2, 0xdd, 0xe1, 0x39, 0xe5, 0xfb, 0xc3, 0x73, 0xca, 0x6f, 0x87, + 0xe7, 0x94, 0xee, 0x93, 0xf2, 0xba, 0x76, 0xe5, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x33, + 0x62, 0x21, 0x89, 0x0a, 0x00, 0x00, } func (m *BeaconState) Marshal() (dAtA []byte, err error) { diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index f911673b6365..b68d1b3d02d9 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -24,9 +24,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:"-"` @@ -242,32 +242,32 @@ var fileDescriptor_f8f395ba51cd84e0 = []byte{ // 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, 0xa8, 0x94, 0x20, 0x0e, 0xb8, 0x5c, 0xb8, 0xfa, 0xc8, 0xa5, 0x5a, 0x3b, 0xaf, - 0xbb, 0xab, 0xda, 0x79, 0xd6, 0xee, 0x33, 0x6a, 0xfb, 0x85, 0x1c, 0xfb, 0x05, 0x11, 0xca, 0x17, - 0xa0, 0x1e, 0x39, 0x21, 0xef, 0x06, 0x25, 0x2a, 0x44, 0xe2, 0xd0, 0xdb, 0xce, 0xee, 0xcc, 0xbc, - 0x99, 0x67, 0x99, 0xbd, 0xac, 0x0d, 0x12, 0x26, 0x40, 0x2a, 0xf9, 0x76, 0x24, 0xca, 0x5a, 0x89, - 0xa3, 0x44, 0x10, 0x81, 0x25, 0x41, 0x1a, 0xe7, 0xb1, 0x7b, 0xe6, 0xcf, 0x80, 0x14, 0x18, 0x68, - 0xaa, 0x18, 0x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, 0x86, 0xd5, 0xd7, 0x30, 0x89, 0x4e, 0xde, 0x45, 0xd9, 0x8a, 0x13, 0xfd, + 0x0c, 0x58, 0x6f, 0x23, 0x31, 0xe7, 0x2c, 0xb4, 0x25, 0x92, 0x5b, 0x65, 0x98, 0xb9, 0x33, 0x7f, + 0xcc, 0x76, 0xf4, 0x6c, 0x0a, 0x97, 0xae, 0x7c, 0x98, 0x79, 0xc0, 0x3f, 0xb2, 0xfd, 0x1c, 0x44, + 0xd1, 0xee, 0xbe, 0xc4, 0xe2, 0xe2, 0xcc, 0x20, 0xd2, 0xb2, 0xda, 0xc6, 0xd8, 0xe3, 0x71, 0x94, + 0xf5, 0x3c, 0x37, 0x6d, 0xa9, 0x19, 0x22, 0xf1, 0x13, 0xb6, 0x6b, 0xb1, 0x31, 0x85, 0x8f, 0xda, + 0x1d, 0x3f, 0xdb, 0xb2, 0xd2, 0x53, 0x05, 0xc5, 0x45, 0x8d, 0x7a, 0x46, 0xd9, 0x52, 0xd0, 0x4a, + 0x49, 0x18, 0x09, 0xd4, 0xdf, 0xf9, 0x6f, 0xa9, 0x17, 0x44, 0x5f, 0x18, 0x5b, 0xdd, 0xb6, 0xc5, + 0xa0, 0xc6, 0x42, 0x2d, 0xdb, 0x7a, 0xc0, 0x5f, 0xb0, 0xd0, 0x75, 0xe9, 0x6c, 0xeb, 0xe2, 0x9e, + 0xd3, 0xd3, 0xef, 0x8b, 0x41, 0x70, 0xb3, 0x18, 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, 0x26, 0x91, 0xff, 0x18, 0x4a, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xce, 0x07, 0xca, 0x37, 0x4a, 0x03, 0x00, 0x00, } func (m *Attestation) Marshal() (dAtA []byte, err error) { diff --git a/proto/eth/v1alpha1/attestation.proto b/proto/eth/v1alpha1/attestation.proto index 74cdfb5a8645..a553b0e9221c 100644 --- a/proto/eth/v1alpha1/attestation.proto +++ b/proto/eth/v1alpha1/attestation.proto @@ -10,12 +10,12 @@ 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\""]; diff --git a/proto/ssz_proto_library.bzl b/proto/ssz_proto_library.bzl index ed95a0c3920a..415dea471b4e 100644 --- a/proto/ssz_proto_library.bzl +++ b/proto/ssz_proto_library.bzl @@ -12,12 +12,8 @@ mainnet = { "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", + "previous_epoch_attestations.max": "4096", + "current_epoch_attestations.max": "4096", "slashings.size": "8192", } @@ -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/shared/params/config.go b/shared/params/config.go index 12ac3805faed..a78cd9a5a4d8 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -238,8 +238,9 @@ func DemoBeaconConfig() *BeaconChainConfig { func MinimalSpecConfig() *BeaconChainConfig { minimalConfig := *defaultBeaconConfig // Misc + minimalConfig.MaxCommitteesPerSlot = 4 minimalConfig.TargetCommitteeSize = 4 - minimalConfig.MaxValidatorsPerCommittee = 4096 + minimalConfig.MaxValidatorsPerCommittee = 2048 minimalConfig.MinPerEpochChurnLimit = 4 minimalConfig.ChurnLimitQuotient = 65536 minimalConfig.ShuffleRoundCount = 10 @@ -291,8 +292,8 @@ func MinimalSpecConfig() *BeaconChainConfig { // Signature domains minimalConfig.DomainBeaconProposer = bytesutil.Bytes4(0) - minimalConfig.DomainRandao = bytesutil.Bytes4(1) - minimalConfig.DomainBeaconAttester = bytesutil.Bytes4(2) + minimalConfig.DomainBeaconAttester = bytesutil.Bytes4(1) + minimalConfig.DomainRandao = bytesutil.Bytes4(2) minimalConfig.DomainDeposit = bytesutil.Bytes4(3) minimalConfig.DomainVoluntaryExit = bytesutil.Bytes4(4) From acbc4006a9594269e9f4bcf9fd80e86e99d87bc9 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Fri, 1 Nov 2019 11:20:16 -0700 Subject: [PATCH 09/82] Block spec test v0.9 (#3905) * rm'ed in protobuf * build proto * build proto * build proto * fix core package * Gazelle * Fixed all the tests * Fixed static test * Comment out spec test for now * One more skip * fix-roundRobinSync (#3862) * Starting but need new seed function * Revert initial sync * Updated Proposer Slashing * Fixed all tests * Lint * Update inclusion reward * Fill randao mixes with eth1 data hash * Test * Fixing test part1 * All tests passing * One last test * Updated config * Build proto * Proper skip message * Conflict and fmt * Removed crosslinks and shards. Built * Format and gazelle * Fixed all the block package tests * Fixed all the helper tests * All epoch package tests pass * All core package tests pass * Fixed operation tests * Started fixing rpc test * RPC tests passed! * Fixed all init sync tests * All tests pass * Fixed blockchain tests * Lint * Lint * Preston's feedback * Starting * Remove container * Fixed block spec tests * All passing except for block_processing test * Failing block processing test * Starting * Add AggregateAndProof * All mainnet test passes --- .../spectest/attestation_mainnet_test.go | 1 - .../spectest/attestation_minimal_test.go | 2 - .../attester_slashing_mainnet_test.go | 1 - .../attester_slashing_minimal_test.go | 2 - .../spectest/block_header_mainnet_test.go | 1 - .../spectest/block_header_minimal_test.go | 2 - .../spectest/block_processing_mainnet_test.go | 1 - .../blocks/spectest/deposit_mainnet_test.go | 1 - .../blocks/spectest/deposit_minimal_test.go | 1 - .../proposer_slashing_mainnet_test.go | 1 - .../proposer_slashing_minimal_test.go | 2 - .../spectest/voluntary_exit_mainnet_test.go | 1 - .../spectest/voluntary_exit_minimal_test.go | 1 - proto/beacon/p2p/v1/types.pb.go | 426 +++++++++++++++--- proto/beacon/p2p/v1/types.proto | 11 +- proto/eth/v1alpha1/beacon_block.pb.go | 128 +++--- proto/eth/v1alpha1/beacon_block.proto | 4 +- proto/testing/ssz_static_mainnet_test.go | 1 - proto/testing/ssz_static_minimal_test.go | 2 - proto/testing/ssz_static_test.go | 2 + 20 files changed, 429 insertions(+), 162 deletions(-) diff --git a/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go b/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go index 32acc58924da..7bae9a8b5b15 100644 --- a/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/attestation_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestAttestationMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runAttestationTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/attestation_minimal_test.go b/beacon-chain/core/blocks/spectest/attestation_minimal_test.go index 2608f587769b..72ffb5332a2c 100644 --- a/beacon-chain/core/blocks/spectest/attestation_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/attestation_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestAttestationMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runAttestationTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go b/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go index af85fe41a2aa..f6064a96e31e 100644 --- a/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/attester_slashing_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestAttesterSlashingMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runAttesterSlashingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go b/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go index 2c8223d9ba01..52417e9f4f09 100644 --- a/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/attester_slashing_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestAttesterSlashingMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runAttesterSlashingTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go b/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go index cbefae1f918b..625b6fdb19fc 100644 --- a/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/block_header_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestBlockHeaderMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockHeaderTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/block_header_minimal_test.go b/beacon-chain/core/blocks/spectest/block_header_minimal_test.go index 6f31b4c7edf7..c5f9e572015c 100644 --- a/beacon-chain/core/blocks/spectest/block_header_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/block_header_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestBlockHeaderMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runBlockHeaderTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go b/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go index 32f84432e5b8..e64d83a6cc44 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestBlockProcessingMainnetYaml(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockProcessingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go b/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go index 435dcdc14c56..dcc4a048ca5f 100644 --- a/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/deposit_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestDepositMainnetYaml(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runDepositTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/deposit_minimal_test.go b/beacon-chain/core/blocks/spectest/deposit_minimal_test.go index 03a5c457e969..baedb27d0e0c 100644 --- a/beacon-chain/core/blocks/spectest/deposit_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/deposit_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestDepositMinimalYaml(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runDepositTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go b/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go index 0776a640aee8..d18d5d4c369c 100644 --- a/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/proposer_slashing_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestProposerSlashingMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runProposerSlashingTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go b/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go index 167cfc06b2db..a8504aa1859e 100644 --- a/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/proposer_slashing_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestProposerSlashingMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runProposerSlashingTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go b/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go index 346e733240a9..42d97f1f59b1 100644 --- a/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go +++ b/beacon-chain/core/blocks/spectest/voluntary_exit_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestVoluntaryExitMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runVoluntaryExitTest(t, "mainnet") } diff --git a/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go b/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go index 2f023255f4d5..fb6ed1f5b070 100644 --- a/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/voluntary_exit_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestVoluntaryExitMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runVoluntaryExitTest(t, "minimal") } diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index eebd32c2d6ef..3ff88f8599ac 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -287,7 +287,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"` @@ -585,6 +585,69 @@ func (m *HistoricalBatch) GetStateRoots() [][]byte { return nil } +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 *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 *AggregateAndProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AggregateAndProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AggregateAndProof.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 *AggregateAndProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_AggregateAndProof.Merge(m, src) +} +func (m *AggregateAndProof) XXX_Size() int { + return m.Size() +} +func (m *AggregateAndProof) XXX_DiscardUnknown() { + xxx_messageInfo_AggregateAndProof.DiscardUnknown(m) +} + +var xxx_messageInfo_AggregateAndProof proto.InternalMessageInfo + +func (m *AggregateAndProof) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *AggregateAndProof) GetSelectionProof() []byte { + if m != nil { + return m.SelectionProof + } + return nil +} + +func (m *AggregateAndProof) GetAggregate() *v1alpha1.Attestation { + if m != nil { + return m.Aggregate + } + return nil +} + func init() { proto.RegisterType((*BeaconState)(nil), "ethereum.beacon.p2p.v1.BeaconState") proto.RegisterType((*Fork)(nil), "ethereum.beacon.p2p.v1.Fork") @@ -593,85 +656,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((*AggregateAndProof)(nil), "ethereum.beacon.p2p.v1.AggregateAndProof") } func init() { proto.RegisterFile("proto/beacon/p2p/v1/types.proto", fileDescriptor_e719e7d82cfa7b0d) } var fileDescriptor_e719e7d82cfa7b0d = []byte{ - // 1158 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x8f, 0xdb, 0x44, - 0x14, 0x97, 0x77, 0x03, 0xb4, 0x93, 0x74, 0xb3, 0x3b, 0xa9, 0xba, 0xa6, 0x2d, 0x75, 0xb0, 0x68, - 0xbb, 0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05, 0xb7, - 0x2e, 0xde, 0x07, 0x68, 0xef, 0xba, 0x6e, 0xb4, 0x3b, 0x9d, 0x4e, 0xcb, 0x68, 0xeb, 0x56, 0x35, - 0x17, 0x88, 0x35, 0x6f, 0x82, 0xe3, 0x98, 0x7b, 0x86, 0xed, 0x22, 0x8e, 0xd4, 0xcf, 0xd7, 0x65, - 0x62, 0xb4, 0x39, 0x89, 0xb9, 0xcf, 0x3d, 0xe3, 0x1e, 0xe2, 0xc8, 0x3a, 0x86, 0x93, 0x27, 0xf8, - 0x26, 0xa8, 0x66, 0x74, 0x7b, 0x44, 0x39, 0x66, 0xea, 0x17, 0xeb, 0xf5, 0xe5, 0x05, 0x44, 0x4c, - 0x38, 0x19, 0x6b, 0x2b, 0x79, 0x88, 0x97, 0x5b, 0x5b, 0xba, 0x75, 0x22, 0x15, 0xde, 0x11, 0x52, - 0x70, 0x13, 0xc0, 0x58, 0x1d, 0x87, 0x94, 0x11, 0x6e, 0x93, 0xc0, 0xc5, 0x7b, 0xea, 0x97, 0xeb, - 0xb2, 0x2b, 0x56, 0x25, 0x36, 0x3e, 0x79, 0x51, 0x1c, 0xc0, 0xb7, 0x00, 0xc8, 0x9a, 0x95, 0xa9, - 0x9f, 0x6a, 0x32, 0x8e, 0xfa, 0x9c, 0x38, 0x76, 0x52, 0xa4, 0x79, 0x66, 0x32, 0xd6, 0xd6, 0x0b, - 0x81, 0x6c, 0x6f, 0x5f, 0x35, 0x8c, 0x76, 0xab, 0xd3, 0xe9, 0xb4, 0x75, 0xab, 0xa0, 0x08, 0xaf, - 0x81, 0x63, 0x5d, 0xe4, 0xa3, 0xc0, 0xc1, 0x4c, 0xfd, 0x4c, 0xa8, 0x97, 0xfe, 0x99, 0x9b, 0xa1, - 0xe1, 0x0d, 0x50, 0x89, 0x50, 0xe0, 0x22, 0x6a, 0x0f, 0xc8, 0x1e, 0x66, 0xea, 0x07, 0x17, 0x65, - 0xd5, 0xd6, 0x27, 0x63, 0xad, 0x96, 0x57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 0xe5, 0xfb, 0xc3, 0x73, 0xca, 0x6f, 0x87, - 0xe7, 0x94, 0xee, 0x93, 0xf2, 0xba, 0x76, 0xe5, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x33, - 0x62, 0x21, 0x89, 0x0a, 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, 0x37, 0x00, 0x27, 0x3e, + 0x0e, 0x1c, 0xf9, 0xba, 0xc0, 0x21, 0x42, 0xbd, 0x01, 0x27, 0x72, 0xe4, 0x84, 0x66, 0xfc, 0x99, + 0x36, 0xa1, 0x2b, 0xc4, 0xcd, 0x9e, 0x79, 0x9e, 0xe7, 0x7d, 0xfd, 0x3e, 0xaf, 0xdf, 0x19, 0xa0, + 0xc7, 0x09, 0xe5, 0xb4, 0xd5, 0xc5, 0xc8, 0xa3, 0x51, 0x2b, 0xb6, 0xe2, 0xd6, 0xc8, 0x6c, 0xf1, + 0xfd, 0x18, 0xb3, 0xa6, 0xdc, 0x81, 0xc7, 0x30, 0x0f, 0x70, 0x82, 0x87, 0x83, 0x66, 0x8a, 0x69, + 0xc6, 0x56, 0xdc, 0x1c, 0x99, 0x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 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) { @@ -1189,6 +1257,48 @@ func (m *HistoricalBatch) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *AggregateAndProof) 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 *AggregateAndProof) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Index != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.Index)) + } + if len(m.SelectionProof) > 0 { + dAtA[i] = 0x12 + i++ + 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) + } + return i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -1443,6 +1553,29 @@ func (m *HistoricalBatch) Size() (n int) { return n } +func (m *AggregateAndProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovTypes(uint64(m.Index)) + } + 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) + } + return n +} + func sovTypes(x uint64) (n int) { for { n++ @@ -3012,6 +3145,149 @@ func (m *HistoricalBatch) Unmarshal(dAtA []byte) error { } return nil } +func (m *AggregateAndProof) 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 ErrIntOverflowTypes + } + 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: AggregateAndProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 SelectionProof", 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.SelectionProof = append(m.SelectionProof[:0], dAtA[iNdEx:postIndex]...) + if m.SelectionProof == nil { + m.SelectionProof = []byte{} + } + iNdEx = postIndex + 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 + } + 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 + } + 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:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + 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 skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index c893de62ca96..5e45cfbdb744 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -54,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; @@ -87,3 +87,12 @@ message HistoricalBatch { repeated bytes block_roots = 1 [(gogoproto.moretags) = "ssz-size:\"block_roots.size\""]; repeated bytes state_roots = 2 [(gogoproto.moretags) = "ssz-size:\"state_roots.size\""]; } + +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/eth/v1alpha1/beacon_block.pb.go b/proto/eth/v1alpha1/beacon_block.pb.go index 79a44be1bf29..f9eb15a7834f 100755 --- a/proto/eth/v1alpha1/beacon_block.pb.go +++ b/proto/eth/v1alpha1/beacon_block.pb.go @@ -654,8 +654,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:"-"` @@ -743,68 +743,68 @@ func init() { var fileDescriptor_9369dd0265944233 = []byte{ // 989 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcb, 0x6e, 0xe3, 0xd4, - 0x1b, 0x97, 0x5b, 0xb7, 0x4d, 0xbf, 0x24, 0xbd, 0x1c, 0x4d, 0x47, 0x51, 0x17, 0x4d, 0xe4, 0xe9, - 0xfc, 0x27, 0x7f, 0x44, 0x93, 0xd8, 0x2d, 0x65, 0x08, 0x6c, 0x48, 0xa6, 0x52, 0x47, 0x20, 0x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x81, 0xb6, 0xfb, 0x37, 0xe2, 0x4e, + 0x4a, 0x27, 0x57, 0x52, 0xe5, 0xf0, 0x78, 0x89, 0x19, 0xe6, 0x9c, 0x30, 0x8e, 0xb9, 0x4f, 0x43, + 0x89, 0xd2, 0xfe, 0x55, 0xa0, 0xd8, 0x16, 0x21, 0xb4, 0x93, 0x08, 0x10, 0x02, 0x95, 0x05, 0x94, + 0x57, 0x94, 0x9a, 0x52, 0x57, 0x4d, 0x71, 0x8d, 0x0c, 0x28, 0x46, 0x38, 0x26, 0x21, 0xb7, 0x62, + 0x4a, 0x79, 0x65, 0xad, 0xa6, 0xd4, 0x4b, 0xed, 0xfd, 0xf1, 0xa8, 0x5a, 0x66, 0xec, 0xcd, 0x09, + 0xf3, 0xdf, 0x90, 0x96, 0x76, 0x66, 0x68, 0x26, 0x48, 0x94, 0x49, 0x29, 0x47, 0xa7, 0x00, 0x89, + 0x11, 0x91, 0x94, 0xf5, 0x3c, 0xca, 0xb6, 0x00, 0x09, 0x46, 0x0b, 0x54, 0x9b, 0xba, 0xc3, 0x8a, + 0x5a, 0x53, 0xea, 0x45, 0xe3, 0x83, 0xc6, 0xd2, 0x24, 0x34, 0x32, 0xb1, 0xb6, 0xa9, 0x3b, 0x34, + 0x05, 0x07, 0x35, 0x61, 0x9b, 0xf9, 0xdd, 0x10, 0xf3, 0x7e, 0x4c, 0x2a, 0x1b, 0xcb, 0xcc, 0x3e, + 0xbb, 0x48, 0xcc, 0x26, 0x18, 0xed, 0x97, 0x0d, 0xd8, 0x5d, 0x90, 0x42, 0x17, 0x50, 0x8e, 0x71, + 0xe8, 0x62, 0x6a, 0xc5, 0x64, 0x40, 0x70, 0x20, 0x72, 0xb0, 0x54, 0xa8, 0x24, 0x71, 0xa6, 0x80, + 0xa1, 0x2f, 0x60, 0x9b, 0x70, 0x4f, 0xb7, 0x5c, 0xcc, 0xb1, 0x48, 0x4e, 0xd1, 0xa8, 0xe6, 0x44, + 0x7f, 0xc5, 0x3d, 0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 0x8d, 0x47, 0xd5, 0x9d, 0xe9, 0xc0, 0x34, 0x4e, + 0xcf, 0x2f, 0x35, 0x13, 0xa5, 0x84, 0xb6, 0xcf, 0x4f, 0x5f, 0x49, 0xf4, 0xa2, 0x8c, 0x3e, 0x95, + 0x59, 0x7b, 0x8c, 0x8c, 0x3e, 0x91, 0x69, 0xa5, 0xad, 0xbc, 0xbe, 0xf2, 0x07, 0x24, 0x13, 0xff, + 0xac, 0x9b, 0xdf, 0xba, 0x3b, 0xda, 0x9d, 0x3f, 0xee, 0x8f, 0x94, 0xbf, 0xee, 0x8f, 0x94, 0xbf, + 0xef, 0x8f, 0x94, 0x1f, 0x3f, 0xc9, 0xfc, 0xda, 0x45, 0xf1, 0x90, 0xf5, 0x30, 0xf7, 0x9d, 0x00, + 0xdb, 0x4c, 0xde, 0x35, 0x1f, 0xfe, 0xca, 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) { diff --git a/proto/eth/v1alpha1/beacon_block.proto b/proto/eth/v1alpha1/beacon_block.proto index fa9ce7d0b815..a5e31d40e7ba 100644 --- a/proto/eth/v1alpha1/beacon_block.proto +++ b/proto/eth/v1alpha1/beacon_block.proto @@ -149,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/testing/ssz_static_mainnet_test.go b/proto/testing/ssz_static_mainnet_test.go index b1b3100c0d0e..584a7370f9be 100644 --- a/proto/testing/ssz_static_mainnet_test.go +++ b/proto/testing/ssz_static_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestSZZStatic_Mainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runSSZStaticTests(t, "mainnet") } diff --git a/proto/testing/ssz_static_minimal_test.go b/proto/testing/ssz_static_minimal_test.go index 7eaffa9f02cb..3f46871ee792 100644 --- a/proto/testing/ssz_static_minimal_test.go +++ b/proto/testing/ssz_static_minimal_test.go @@ -5,7 +5,5 @@ import ( ) func TestSSZStatic_Minimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - runSSZStaticTests(t, "minimal") } diff --git a/proto/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index bf0c6e8e9952..aece4ca0827d 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": From 59f528f74d3dc6f9914e4f75f96b3440050150ed Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sat, 2 Nov 2019 08:27:47 +0000 Subject: [PATCH 10/82] Update deposit contract (#3906) --- beacon-chain/powchain/log_processing_test.go | 43 ++++-- beacon-chain/powchain/service.go | 2 +- contracts/deposit-contract/BUILD.bazel | 10 +- contracts/deposit-contract/README.md | 22 +-- contracts/deposit-contract/abi.json | 2 +- contracts/deposit-contract/bytecode.bin | 2 +- .../deployContract/BUILD.bazel | 1 - .../deposit-contract/deployContract/README.md | 6 +- .../deployContract/deployContract.go | 30 ---- contracts/deposit-contract/depositContract.go | 120 +++++---------- .../deposit-contract/depositContract.v.py | 45 +++--- .../deposit-contract/depositContract_test.go | 79 ++++++---- .../deposit-contract/deposit_tree_test.go | 139 ++++++++++++++++++ .../sendDepositTx/sendDeposits.go | 17 +-- contracts/deposit-contract/testutils.go | 5 +- shared/keystore/deposit_input.go | 11 +- shared/keystore/deposit_input_test.go | 2 +- shared/testutil/helpers.go | 1 + shared/trieutil/sparse_merkle_test.go | 138 +---------------- tools/cluster-pk-manager/server/server.go | 8 +- validator/accounts/account.go | 4 +- 21 files changed, 324 insertions(+), 363 deletions(-) create mode 100644 contracts/deposit-contract/deposit_tree_test.go diff --git a/beacon-chain/powchain/log_processing_test.go b/beacon-chain/powchain/log_processing_test.go index fd1ab5a4d438..87bc55425c09 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) } @@ -110,17 +110,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) } @@ -171,12 +171,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() @@ -243,7 +243,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() @@ -254,7 +254,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) } @@ -311,7 +311,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 @@ -320,7 +320,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) } @@ -338,6 +338,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() @@ -348,7 +355,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, @@ -391,13 +398,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) } @@ -415,6 +422,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 693ec985c3e6..5d29f62ae158 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -301,7 +301,7 @@ func (s *Service) AreAllDepositsProcessed() (bool, error) { // 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/contracts/deposit-contract/BUILD.bazel b/contracts/deposit-contract/BUILD.bazel index 4a41c6e6099c..8a41ea997925 100644 --- a/contracts/deposit-contract/BUILD.bazel +++ b/contracts/deposit-contract/BUILD.bazel @@ -26,10 +26,18 @@ go_library( go_test( name = "go_default_test", size = "small", - srcs = ["depositContract_test.go"], + 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 4f0765435756..63001c07b573 100644 --- a/contracts/deposit-contract/README.md +++ b/contracts/deposit-contract/README.md @@ -62,16 +62,16 @@ 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) +=== 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 223af1cd650d..2d90df95e97c 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": 95727}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 18283}, {"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": 1342680}, {"name": "drain", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 35831}, {"name": "drain_address", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 701}] diff --git a/contracts/deposit-contract/bytecode.bin b/contracts/deposit-contract/bytecode.bin index 780e1a84029e..38fdaa70f322 100644 --- a/contracts/deposit-contract/bytecode.bin +++ b/contracts/deposit-contract/bytecode.bin @@ -1 +1 @@ -0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260406114ff6101403934156100a757600080fd5b602060206114ff0160c03960c05160205181106100c357600080fd5b5061014051600055610160516004556101806000601f818352015b600061018051602081106100f157600080fd5b600160c052602060c02001546020826101a0010152602081019050610180516020811061011d57600080fd5b600160c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161015b57600080fd5b60c0519050606051600161018051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600160c052602060c02001555b81516001018083528114156100de575b50506114e756600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661018001602082840111156100bf57600080fd5b6020806101a082610140600060046015f1505081815280905090509050805160200180610240828460006004600a8704601201f16100fc57600080fd5b50506102405160206001820306601f82010390506102a0610240516008818352015b826102a051111561012e5761014a565b60006102a05161026001535b815160010180835281141561011e575b5050506020610220526040610240510160206001820306601f8201039050610200525b60006102005111151561017f5761019b565b602061020051036102200151602061020051036102005261016d565b610160515650005b600015610387575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156101ea578060000360020a82046101f1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561021c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610265578060000360020a820461026c565b8060020a82025b905090506101a0525b81516001018083528114156101cd575b5050601860086020820661020001602082840111156102a357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16102e057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156103125761032e565b6000610320516102e001535b8151600101808352811415610302575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156103635761037f565b602061028051036102a001516020610280510361028052610351565b610160515650005b63863a311b60005114156106185734156103a057600080fd5b6000610140526101405161016052600354610180526101a060006020818352015b60016001610180511614156104425760006101a051602081106103e357600080fd5b600260c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161043457600080fd5b60c0519050610160526104b0565b6000610160516020826101c00101526020810190506101a0516020811061046857600080fd5b600160c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16104a657600080fd5b60c0519050610160525b61018060026104be57600080fd5b60028151048152505b81516001018083528114156103c1575b505060006101605160208261044001015260208101905061014051610160516101805163806732896102c0526003546102e0526102e051600658016101ab565b506103405260006103a0525b6103405160206001820306601f82010390506103a0511015156105455761055e565b6103a05161036001526103a0516020016103a052610523565b61018052610160526101405261034060088060208461044001018260208501600060046012f150508051820191505060006018602082066103c001602082840111156105a957600080fd5b6020806103e082610140600060046015f150508181528090509050905060188060208461044001018260208501600060046014f150508051820191505080610440526104409050602060c0825160208401600060025af161060957600080fd5b60c051905060005260206000f3005b63621fd130600051141561072a57341561063157600080fd5b6380673289610140526003546101605261016051600658016101ab565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561067c57610695565b610220516101e00152610220516020016102205261065a565b6101c0805160200180610280828460006004600a8704601201f16106b857600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156106ea57610706565b60006102e0516102a001535b81516001018083528114156106da575b5050506020610260526040610280510160206001820306601f8201039050610260f3005b63c47e300d600051141561128257606060046101403760506004356004016101a037603060043560040135111561076057600080fd5b604060243560040161022037602060243560040135111561078057600080fd5b60806044356004016102803760606044356004013511156107a057600080fd5b63ffffffff600354106107b257600080fd5b633b9aca0061034052610340516107c857600080fd5b610340513404610320526000546103205110156107e457600080fd5b60306101a051146107f457600080fd5b6020610220511461080457600080fd5b6060610280511461081457600080fd5b6101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05163806732896103c052610320516103e0526103e051600658016101ab565b506104405260006104a0525b6104405160206001820306601f82010390506104a0511015156108a4576108bd565b6104a05161046001526104a0516020016104a052610882565b6103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610440805160200180610360828460006004600a8704601201f161092457600080fd5b50506101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c0516103e05161040051610420516104405161046051610480516104a05163806732896104c0526003546104e0526104e051600658016101ab565b506105405260006105a0525b6105405160206001820306601f82010390506105a0511015156109d5576109ee565b6105a05161056001526105a0516020016105a0526109b3565b6104a05261048052610460526104405261042052610400526103e0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526105408051602001806105c0828460006004600a8704601201f1610a7557600080fd5b505060a06106405261064051610680526101a08051602001806106405161068001828460006004600a8704601201f1610aad57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516040818352015b8361062051101515610aeb57610b08565b6000610620516020850101535b8151600101808352811415610ada575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106a0526102208051602001806106405161068001828460006004600a8704601201f1610b5f57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610b9d57610bba565b6000610620516020850101535b8151600101808352811415610b8c575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106c0526103608051602001806106405161068001828460006004600a8704601201f1610c1157600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610c4f57610c6c565b6000610620516020850101535b8151600101808352811415610c3e575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106e0526102808051602001806106405161068001828460006004600a8704601201f1610cc357600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516060818352015b8361062051101515610d0157610d1e565b6000610620516020850101535b8151600101808352811415610cf0575b50505050602061064051610680015160206001820306601f82010390506106405101016106405261064051610700526105c08051602001806106405161068001828460006004600a8704601201f1610d7557600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610db357610dd0565b6000610620516020850101535b8151600101808352811415610da2575b50505050602061064051610680015160206001820306601f8201039050610640510101610640527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561064051610680a160006107205260006101a06030806020846107e001018260208501600060046016f150508051820191505060006010602082066107600160208284011115610e6757600080fd5b60208061078082610720600060046015f15050818152809050905090506010806020846107e001018260208501600060046013f1505080518201915050806107e0526107e09050602060c0825160208401600060025af1610ec757600080fd5b60c0519050610740526000600060406020820661088001610280518284011115610ef057600080fd5b6060806108a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af1610f3057600080fd5b60c0519050602082610a800101526020810190506000604060206020820661094001610280518284011115610f6457600080fd5b606080610960826020602088068803016102800160006004601bf1505081815280905090509050602080602084610a0001018260208501600060046015f150508051820191505061072051602082610a0001015260208101905080610a0052610a009050602060c0825160208401600060025af1610fe157600080fd5b60c0519050602082610a8001015260208101905080610a8052610a809050602060c0825160208401600060025af161101857600080fd5b60c0519050610860526000600061074051602082610b20010152602081019050610220602080602084610b2001018260208501600060046015f150508051820191505080610b2052610b209050602060c0825160208401600060025af161107e57600080fd5b60c0519050602082610ca00101526020810190506000610360600880602084610c2001018260208501600060046012f15050805182019150506000601860208206610ba001602082840111156110d357600080fd5b602080610bc082610720600060046015f1505081815280905090509050601880602084610c2001018260208501600060046014f150508051820191505061086051602082610c2001015260208101905080610c2052610c209050602060c0825160208401600060025af161114657600080fd5b60c0519050602082610ca001015260208101905080610ca052610ca09050602060c0825160208401600060025af161117d57600080fd5b60c0519050610b0052600380546001825401101561119a57600080fd5b6001815401815550600354610d2052610d4060006020818352015b60016001610d20511614156111ea57610b0051610d4051602081106111d957600080fd5b600260c052602060c020015561127e565b6000610d4051602081106111fd57600080fd5b600260c052602060c0200154602082610d60010152602081019050610b0051602082610d6001015260208101905080610d6052610d609050602060c0825160208401600060025af161124e57600080fd5b60c0519050610b0052610d20600261126557600080fd5b60028151048152505b81516001018083528114156111b5575b5050005b639890220b60005114156112b657341561129b57600080fd5b600060006000600030316004546000f16112b457600080fd5b005b631ea30fef60005114156112dc5734156112cf57600080fd5b60005460005260206000f3005b63eb8545ee60005114156113025734156112f557600080fd5b60035460005260206000f3005b638ba35cdf600051141561132857341561131b57600080fd5b60045460005260206000f3005b60006000fd5b6101b96114e7036101b96000396101b96114e7036000f3 +0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206113166101403934156100a157600080fd5b602061131660c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b50506112fe56600436101561000d5761114f565b600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610286575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100e8578060000360020a82046100ef565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561011a57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610163578060000360020a820461016a565b8060020a82025b905090506101a0525b81516001018083528114156100cb575b5050601860086020820661020001602082840111156101a157600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101de57600080fd5b50506102c05160206001820306601f82010390506103206102c0516020818352015b82610320511015156102115761022d565b6000610320516102e001535b8151600101808352811415610200575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102625761027e565b602061028051036102a001516020610280510361028052610250565b610160515650005b63c5f2892f600051141561051857341561029f57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103415760006101a051602081106102e257600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161033357600080fd5b60c0519050610160526103af565b6000610160516020826101c00101526020810190506101a0516020811061036757600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16103a557600080fd5b60c0519050610160525b61018060026103bd57600080fd5b60028151048152505b81516001018083528114156102c0575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e0526001546103005261030051600658016100a9565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104445761045d565b6103c05161038001526103c0516020016103c052610422565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e001602082840111156104a857600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af161050857600080fd5b60c051905060005260206000f350005b63621fd130600051141561062c57341561053157600080fd5b6380673289610140526001546101605261016051600658016100a9565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561057c57610595565b610220516101e00152610220516020016102205261055a565b6101c0805160200180610280828460006004600a8704601201f16105b857600080fd5b50506102805160206001820306601f82010390506102e0610280516020818352015b826102e0511015156105eb57610607565b60006102e0516102a001535b81516001018083528114156105da575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110f357605060043560040161014037603060043560040135111561065a57600080fd5b60406024356004016101c037602060243560040135111561067a57600080fd5b608060443560040161022037606060443560040135111561069a57600080fd5b63ffffffff600154106106ac57600080fd5b633b9aca006102e0526102e0516106c257600080fd5b6102e05134046102c052633b9aca006102c05110156106e057600080fd5b603061014051146106f057600080fd5b60206101c0511461070057600080fd5b6060610220511461071057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561073a57610718565b6380673289610380526102c0516103a0526103a051600658016100a9565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107865761079f565b6104605161042001526104605160200161046052610764565b610340610360525b61036051526020610360510361036052610140610360511015156107ca576107a7565b610400805160200180610300828460006004600a8704601201f16107ed57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610819576107f7565b63806732896104a0526001546104c0526104c051600658016100a9565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108645761087d565b6105805161054001526105805160200161058052610842565b610460610480525b61048051526020610480510361048052610140610480511015156108a857610885565b6105208051602001806105a0828460006004600a8704601201f16108cb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f161090357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516040818352015b826106005110151561094057610961565b600061060051610620516106800101535b815160010180835281141561092f575b505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109b757600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b82610600511015156109f457610a15565b600061060051610620516106800101535b81516001018083528114156109e3575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a6b57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610aa857610ac9565b600061060051610620516106800101535b8151600101808352811415610a97575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b1f57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516060818352015b8261060051101515610b5c57610b7d565b600061060051610620516106800101535b8151600101808352811415610b4b575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bd357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610c1057610c31565b600061060051610620516106800101535b8151600101808352811415610bff575b505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cc757600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d2757600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d5057600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d9057600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610dc457600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e4157600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e7857600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ede57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f3357600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610fa657600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fdd57600080fd5b60c0519050610ae052606435610ae05114610ff757600080fd5b600180546001825401101561100b57600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561105b57610ae051610d20516020811061104a57600080fd5b600060c052602060c02001556110ef565b6000610d20516020811061106e57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110bf57600080fd5b60c0519050610ae052610d0060026110d657600080fd5b60028151048152505b8151600101808352811415611026575b5050005b639890220b600051141561112757341561110c57600080fd5b600060006000600030316002546000f161112557600080fd5b005b638ba35cdf600051141561114e57341561114057600080fd5b60025460005260206000f350005b5b60006000fd5b6101a96112fe036101a96000396101a96112fe036000f3 diff --git a/contracts/deposit-contract/deployContract/BUILD.bazel b/contracts/deposit-contract/deployContract/BUILD.bazel index 364310b19c61..b224ee5f0138 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 75e2d70acaba..a11a8c722142 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 9bb90e3da3b4..ba3acb7a26d5 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 7a1faf3956f4..e2293f6ffd68 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\":95727},{\"name\":\"get_deposit_count\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":18283},{\"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\":1342680},{\"name\":\"drain\",\"outputs\":[],\"inputs\":[],\"constant\":false,\"payable\":false,\"type\":\"function\",\"gas\":35831},{\"name\":\"drain_address\",\"outputs\":[{\"type\":\"address\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":701}]" // DepositContractBin is the compiled bytecode used for deploying new contracts. -const DepositContractBin = `0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260406114ff6101403934156100a757600080fd5b602060206114ff0160c03960c05160205181106100c357600080fd5b5061014051600055610160516004556101806000601f818352015b600061018051602081106100f157600080fd5b600160c052602060c02001546020826101a0010152602081019050610180516020811061011d57600080fd5b600160c052602060c02001546020826101a0010152602081019050806101a0526101a09050602060c0825160208401600060025af161015b57600080fd5b60c0519050606051600161018051018060405190131561017a57600080fd5b809190121561018857600080fd5b6020811061019557600080fd5b600160c052602060c02001555b81516001018083528114156100de575b50506114e756600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a0526000156101a3575b6101605261014052601860086020820661018001602082840111156100bf57600080fd5b6020806101a082610140600060046015f1505081815280905090509050805160200180610240828460006004600a8704601201f16100fc57600080fd5b50506102405160206001820306601f82010390506102a0610240516008818352015b826102a051111561012e5761014a565b60006102a05161026001535b815160010180835281141561011e575b5050506020610220526040610240510160206001820306601f8201039050610200525b60006102005111151561017f5761019b565b602061020051036102200151602061020051036102005261016d565b610160515650005b600015610387575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156101ea578060000360020a82046101f1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561021c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610265578060000360020a820461026c565b8060020a82025b905090506101a0525b81516001018083528114156101cd575b5050601860086020820661020001602082840111156102a357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16102e057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156103125761032e565b6000610320516102e001535b8151600101808352811415610302575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156103635761037f565b602061028051036102a001516020610280510361028052610351565b610160515650005b63863a311b60005114156106185734156103a057600080fd5b6000610140526101405161016052600354610180526101a060006020818352015b60016001610180511614156104425760006101a051602081106103e357600080fd5b600260c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161043457600080fd5b60c0519050610160526104b0565b6000610160516020826101c00101526020810190506101a0516020811061046857600080fd5b600160c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16104a657600080fd5b60c0519050610160525b61018060026104be57600080fd5b60028151048152505b81516001018083528114156103c1575b505060006101605160208261044001015260208101905061014051610160516101805163806732896102c0526003546102e0526102e051600658016101ab565b506103405260006103a0525b6103405160206001820306601f82010390506103a0511015156105455761055e565b6103a05161036001526103a0516020016103a052610523565b61018052610160526101405261034060088060208461044001018260208501600060046012f150508051820191505060006018602082066103c001602082840111156105a957600080fd5b6020806103e082610140600060046015f150508181528090509050905060188060208461044001018260208501600060046014f150508051820191505080610440526104409050602060c0825160208401600060025af161060957600080fd5b60c051905060005260206000f3005b63621fd130600051141561072a57341561063157600080fd5b6380673289610140526003546101605261016051600658016101ab565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561067c57610695565b610220516101e00152610220516020016102205261065a565b6101c0805160200180610280828460006004600a8704601201f16106b857600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156106ea57610706565b60006102e0516102a001535b81516001018083528114156106da575b5050506020610260526040610280510160206001820306601f8201039050610260f3005b63c47e300d600051141561128257606060046101403760506004356004016101a037603060043560040135111561076057600080fd5b604060243560040161022037602060243560040135111561078057600080fd5b60806044356004016102803760606044356004013511156107a057600080fd5b63ffffffff600354106107b257600080fd5b633b9aca0061034052610340516107c857600080fd5b610340513404610320526000546103205110156107e457600080fd5b60306101a051146107f457600080fd5b6020610220511461080457600080fd5b6060610280511461081457600080fd5b6101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05163806732896103c052610320516103e0526103e051600658016101ab565b506104405260006104a0525b6104405160206001820306601f82010390506104a0511015156108a4576108bd565b6104a05161046001526104a0516020016104a052610882565b6103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a052610440805160200180610360828460006004600a8704601201f161092457600080fd5b50506101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a0516103c0516103e05161040051610420516104405161046051610480516104a05163806732896104c0526003546104e0526104e051600658016101ab565b506105405260006105a0525b6105405160206001820306601f82010390506105a0511015156109d5576109ee565b6105a05161056001526105a0516020016105a0526109b3565b6104a05261048052610460526104405261042052610400526103e0526103c0526103a05261038052610360526103405261032052610300526102e0526102c0526102a05261028052610260526102405261022052610200526101e0526101c0526101a0526105408051602001806105c0828460006004600a8704601201f1610a7557600080fd5b505060a06106405261064051610680526101a08051602001806106405161068001828460006004600a8704601201f1610aad57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516040818352015b8361062051101515610aeb57610b08565b6000610620516020850101535b8151600101808352811415610ada575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106a0526102208051602001806106405161068001828460006004600a8704601201f1610b5f57600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610b9d57610bba565b6000610620516020850101535b8151600101808352811415610b8c575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106c0526103608051602001806106405161068001828460006004600a8704601201f1610c1157600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610c4f57610c6c565b6000610620516020850101535b8151600101808352811415610c3e575b50505050602061064051610680015160206001820306601f820103905061064051010161064052610640516106e0526102808051602001806106405161068001828460006004600a8704601201f1610cc357600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516060818352015b8361062051101515610d0157610d1e565b6000610620516020850101535b8151600101808352811415610cf0575b50505050602061064051610680015160206001820306601f82010390506106405101016106405261064051610700526105c08051602001806106405161068001828460006004600a8704601201f1610d7557600080fd5b505061064051610680015160206001820306601f8201039050610640516106800161062081516020818352015b8361062051101515610db357610dd0565b6000610620516020850101535b8151600101808352811415610da2575b50505050602061064051610680015160206001820306601f8201039050610640510101610640527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561064051610680a160006107205260006101a06030806020846107e001018260208501600060046016f150508051820191505060006010602082066107600160208284011115610e6757600080fd5b60208061078082610720600060046015f15050818152809050905090506010806020846107e001018260208501600060046013f1505080518201915050806107e0526107e09050602060c0825160208401600060025af1610ec757600080fd5b60c0519050610740526000600060406020820661088001610280518284011115610ef057600080fd5b6060806108a0826020602088068803016102800160006004601bf1505081815280905090509050602060c0825160208401600060025af1610f3057600080fd5b60c0519050602082610a800101526020810190506000604060206020820661094001610280518284011115610f6457600080fd5b606080610960826020602088068803016102800160006004601bf1505081815280905090509050602080602084610a0001018260208501600060046015f150508051820191505061072051602082610a0001015260208101905080610a0052610a009050602060c0825160208401600060025af1610fe157600080fd5b60c0519050602082610a8001015260208101905080610a8052610a809050602060c0825160208401600060025af161101857600080fd5b60c0519050610860526000600061074051602082610b20010152602081019050610220602080602084610b2001018260208501600060046015f150508051820191505080610b2052610b209050602060c0825160208401600060025af161107e57600080fd5b60c0519050602082610ca00101526020810190506000610360600880602084610c2001018260208501600060046012f15050805182019150506000601860208206610ba001602082840111156110d357600080fd5b602080610bc082610720600060046015f1505081815280905090509050601880602084610c2001018260208501600060046014f150508051820191505061086051602082610c2001015260208101905080610c2052610c209050602060c0825160208401600060025af161114657600080fd5b60c0519050602082610ca001015260208101905080610ca052610ca09050602060c0825160208401600060025af161117d57600080fd5b60c0519050610b0052600380546001825401101561119a57600080fd5b6001815401815550600354610d2052610d4060006020818352015b60016001610d20511614156111ea57610b0051610d4051602081106111d957600080fd5b600260c052602060c020015561127e565b6000610d4051602081106111fd57600080fd5b600260c052602060c0200154602082610d60010152602081019050610b0051602082610d6001015260208101905080610d6052610d609050602060c0825160208401600060025af161124e57600080fd5b60c0519050610b0052610d20600261126557600080fd5b60028151048152505b81516001018083528114156111b5575b5050005b639890220b60005114156112b657341561129b57600080fd5b600060006000600030316004546000f16112b457600080fd5b005b631ea30fef60005114156112dc5734156112cf57600080fd5b60005460005260206000f3005b63eb8545ee60005114156113025734156112f557600080fd5b60035460005260206000f3005b638ba35cdf600051141561132857341561131b57600080fd5b60045460005260206000f3005b60006000fd5b6101b96114e7036101b96000396101b96114e7036000f3` +var DepositContractBin = "0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206113166101403934156100a157600080fd5b602061131660c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b50506112fe56600436101561000d5761114f565b600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610286575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100e8578060000360020a82046100ef565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561011a57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610163578060000360020a820461016a565b8060020a82025b905090506101a0525b81516001018083528114156100cb575b5050601860086020820661020001602082840111156101a157600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101de57600080fd5b50506102c05160206001820306601f82010390506103206102c0516020818352015b82610320511015156102115761022d565b6000610320516102e001535b8151600101808352811415610200575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102625761027e565b602061028051036102a001516020610280510361028052610250565b610160515650005b63c5f2892f600051141561051857341561029f57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103415760006101a051602081106102e257600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161033357600080fd5b60c0519050610160526103af565b6000610160516020826101c00101526020810190506101a0516020811061036757600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16103a557600080fd5b60c0519050610160525b61018060026103bd57600080fd5b60028151048152505b81516001018083528114156102c0575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e0526001546103005261030051600658016100a9565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104445761045d565b6103c05161038001526103c0516020016103c052610422565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e001602082840111156104a857600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af161050857600080fd5b60c051905060005260206000f350005b63621fd130600051141561062c57341561053157600080fd5b6380673289610140526001546101605261016051600658016100a9565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561057c57610595565b610220516101e00152610220516020016102205261055a565b6101c0805160200180610280828460006004600a8704601201f16105b857600080fd5b50506102805160206001820306601f82010390506102e0610280516020818352015b826102e0511015156105eb57610607565b60006102e0516102a001535b81516001018083528114156105da575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110f357605060043560040161014037603060043560040135111561065a57600080fd5b60406024356004016101c037602060243560040135111561067a57600080fd5b608060443560040161022037606060443560040135111561069a57600080fd5b63ffffffff600154106106ac57600080fd5b633b9aca006102e0526102e0516106c257600080fd5b6102e05134046102c052633b9aca006102c05110156106e057600080fd5b603061014051146106f057600080fd5b60206101c0511461070057600080fd5b6060610220511461071057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561073a57610718565b6380673289610380526102c0516103a0526103a051600658016100a9565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107865761079f565b6104605161042001526104605160200161046052610764565b610340610360525b61036051526020610360510361036052610140610360511015156107ca576107a7565b610400805160200180610300828460006004600a8704601201f16107ed57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610819576107f7565b63806732896104a0526001546104c0526104c051600658016100a9565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108645761087d565b6105805161054001526105805160200161058052610842565b610460610480525b61048051526020610480510361048052610140610480511015156108a857610885565b6105208051602001806105a0828460006004600a8704601201f16108cb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f161090357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516040818352015b826106005110151561094057610961565b600061060051610620516106800101535b815160010180835281141561092f575b505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109b757600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b82610600511015156109f457610a15565b600061060051610620516106800101535b81516001018083528114156109e3575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a6b57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610aa857610ac9565b600061060051610620516106800101535b8151600101808352811415610a97575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b1f57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516060818352015b8261060051101515610b5c57610b7d565b600061060051610620516106800101535b8151600101808352811415610b4b575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bd357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610c1057610c31565b600061060051610620516106800101535b8151600101808352811415610bff575b505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cc757600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d2757600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d5057600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d9057600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610dc457600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e4157600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e7857600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ede57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f3357600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610fa657600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fdd57600080fd5b60c0519050610ae052606435610ae05114610ff757600080fd5b600180546001825401101561100b57600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561105b57610ae051610d20516020811061104a57600080fd5b600060c052602060c02001556110ef565b6000610d20516020811061106e57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110bf57600080fd5b60c0519050610ae052610d0060026110d657600080fd5b60028151048152505b8151600101808352811415611026575b5050005b639890220b600051141561112757341561110c57600080fd5b600060006000600030316002546000f161112557600080fd5b005b638ba35cdf600051141561114e57341561114057600080fd5b60025460005260206000f350005b5b60006000fd5b6101a96112fe036101a96000396101a96112fe036000f3" // 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 ce4d7c8cb010..cc7e4fa9dcf8 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 @@ 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 1b3382c14266..a8bc85151b4f 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{}) - if err == nil { - t.Error("Validator registration should have failed with insufficient deposit") + // Generate deposit data + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, 1) + if err != nil { + t.Fatal(err) } -} - -// 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() + depositDataItems, depositDataRoots, err := interop.DepositDataFromKeys(privKeys, pubKeys) if err != nil { t.Fatal(err) } - testAccount.TxOpts.Value = Amount33Eth() - _, err = testAccount.Contract.Deposit(testAccount.TxOpts, []byte{}, []byte{}, []byte{}) + 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 more than asked deposit amount") + t.Error("Validator registration should have failed with insufficient deposit") } } // 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 000000000000..87af80897eb8 --- /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 d0709bd62984..77d30773262e 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 f042d3c8eb87..84482db81613 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/shared/keystore/deposit_input.go b/shared/keystore/deposit_input.go index 1b3efdbbe816..40015d5de48f 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 92a38bea3756..21d39fc1ea99 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/testutil/helpers.go b/shared/testutil/helpers.go index 7a8d73fa2914..0ea57de57059 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/trieutil/sparse_merkle_test.go b/shared/trieutil/sparse_merkle_test.go index b3a7d4e4622e..60f31088a4b3 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/tools/cluster-pk-manager/server/server.go b/tools/cluster-pk-manager/server/server.go index 0d58b3aede27..864fb4d769f7 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 fe7e3b7580a7..0b07a81a7282 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") } From 9bc9b9100d0b9351ffe8996920538fc25b20a6c3 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sat, 2 Nov 2019 09:39:56 -0700 Subject: [PATCH 11/82] Proto spec tests v0.9 (#3908) * Starting * Add AggregateAndProof From 2b87f398b22b54bd81f9c6429b7016fc9a6c5e65 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sat, 2 Nov 2019 09:49:13 -0700 Subject: [PATCH 12/82] Unskip block util tests (#3910) * rm'ed in protobuf * build proto * build proto * build proto * fix core package * Gazelle * Fixed all the tests * Fixed static test * Comment out spec test for now * One more skip * fix-roundRobinSync (#3862) * Starting but need new seed function * Revert initial sync * Updated Proposer Slashing * Fixed all tests * Lint * Update inclusion reward * Fill randao mixes with eth1 data hash * Test * Fixing test part1 * All tests passing * One last test * Updated config * Build proto * Proper skip message * Conflict and fmt * Removed crosslinks and shards. Built * Format and gazelle * Fixed all the block package tests * Fixed all the helper tests * All epoch package tests pass * All core package tests pass * Fixed operation tests * Started fixing rpc test * RPC tests passed! * Fixed all init sync tests * All tests pass * Fixed blockchain tests * Lint * Lint * Preston's feedback * Starting * Remove container * Fixed block spec tests * All passing except for block_processing test * Failing block processing test * Starting * Add AggregateAndProof * All mainnet test passes * Unskip block util tests --- shared/testutil/block.go | 6 ++++++ shared/testutil/block_test.go | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/shared/testutil/block.go b/shared/testutil/block.go index 855839fbfa65..8dc8bf1fbf18 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -297,8 +297,14 @@ 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, Source: bState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index e13b34d251f2..b6fa23a92641 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" @@ -11,7 +12,6 @@ import ( ) func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { - t.Skip("Disabled until bug 3891 is fixed") deposits, _, privs := SetupInitialDeposits(t, 128) eth1Data := GenerateEth1Data(t, deposits) beaconState, err := state.GenesisBeaconState(deposits, 0, eth1Data) @@ -34,7 +34,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { } func TestGenerateFullBlock_ThousandValidators(t *testing.T) { - t.Skip("Disabled until bug 3891 is fixed") + helpers.ClearAllCaches() params.OverrideBeaconConfig(params.MinimalSpecConfig()) defer params.OverrideBeaconConfig(params.MainnetConfig()) deposits, _, privs := SetupInitialDeposits(t, 1024) @@ -58,11 +58,11 @@ func TestGenerateFullBlock_ThousandValidators(t *testing.T) { } func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { - t.Skip("Disabled until bug 3891 is fixed") + 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 { @@ -151,6 +151,7 @@ func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { } func TestGenerateFullBlock_ValidAttestations(t *testing.T) { + helpers.ClearAllCaches() deposits, _, privs := SetupInitialDeposits(t, 256) eth1Data := GenerateEth1Data(t, deposits) From 064e963a529cf16df226db594c08ad2f129f8d3a Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sun, 3 Nov 2019 16:32:01 -0800 Subject: [PATCH 13/82] Slot processing spec test V0.9 (#3912) * Starting * Add AggregateAndProof * Unskip slot processing mainnet test --- beacon-chain/core/state/spectest/slot_processing_mainnet_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go b/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go index 1261c2e9c6f8..3a20ade80e98 100644 --- a/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go +++ b/beacon-chain/core/state/spectest/slot_processing_mainnet_test.go @@ -5,6 +5,5 @@ import ( ) func TestSlotProcessingMainnet(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runSlotProcessingTests(t, "mainnet") } From 5d2f142a75bf998dc5a40f9c2d32a2830beb056c Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 4 Nov 2019 11:44:08 -0800 Subject: [PATCH 14/82] Unskip minimal spec test for finalization (#3920) --- ...ification_and_finalization_minimal_test.go | 1 - .../justification_and_finalization_test.go | 43 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) 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 992821791f6f..57775ffc130a 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 2df30f929b50..d09f080ae5c3 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 +} From 842a5aca3ecf735ab9eb6f5291dcca32de0754ee Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 4 Nov 2019 15:31:35 -0800 Subject: [PATCH 15/82] Remove outdated interop tests (#3922) * Rm outdated interop tests * Rm test runner * Gazelle --- beacon-chain/core/state/BUILD.bazel | 20 ---- .../state/minimal_config_consensus_test.go | 97 ------------------ .../minimal/artemis_crosslink/block.ssz | Bin 1016 -> 0 bytes .../minimal/artemis_crosslink/post.ssz | Bin 17911 -> 0 bytes .../minimal/artemis_crosslink/pre.ssz | Bin 22069 -> 0 bytes .../minimal/crosslink_mismatch/block.ssz | Bin 706 -> 0 bytes .../minimal/crosslink_mismatch/post.ssz | Bin 16336 -> 0 bytes .../minimal/crosslink_mismatch/pre.ssz | Bin 18694 -> 0 bytes .../minimal/duplicate_rewards/block.ssz | Bin 1636 -> 0 bytes .../minimal/duplicate_rewards/post.ssz | Bin 18136 -> 0 bytes .../minimal/duplicate_rewards/pre.ssz | Bin 22519 -> 0 bytes 11 files changed, 117 deletions(-) delete mode 100644 beacon-chain/core/state/minimal_config_consensus_test.go delete mode 100644 beacon-chain/core/state/testdata/minimal/artemis_crosslink/block.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/artemis_crosslink/post.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/artemis_crosslink/pre.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/crosslink_mismatch/block.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/crosslink_mismatch/post.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/crosslink_mismatch/pre.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/duplicate_rewards/block.ssz delete mode 100755 beacon-chain/core/state/testdata/minimal/duplicate_rewards/post.ssz delete mode 100644 beacon-chain/core/state/testdata/minimal/duplicate_rewards/pre.ssz diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index 2f6f1928bae9..b2d43608a892 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -58,23 +58,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 d5a7f133a319..000000000000 --- a/beacon-chain/core/state/minimal_config_consensus_test.go +++ /dev/null @@ -1,97 +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) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - - 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/testdata/minimal/artemis_crosslink/block.ssz b/beacon-chain/core/state/testdata/minimal/artemis_crosslink/block.ssz deleted file mode 100644 index f38616caa20e9a3bc19e191357e62917528d2614..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1016 zcmWe&fPiD{2}`EE6E8iZAO7xtjmL%=TaUdoyI1}=b$#V`AD+pnN7?T*YW}pg{Cx1| zhhs%ooO`pv@|0)xt-g`HLD6YJ)~_`{V|KJ>M?DB?-5)l)xrMp7XELiHU(~-pB4!ib z`*vBCHYne2t~u|)FXjD%YyBK4+r|UDe^T`}iKcxkU{&AJCnCc)ZOzgb-=Y*|+h1yX z{NJ2)!4t77%m-dLF4-5Eq?Fe5CVK6|2>;UO;kvE#j%yz9< zD%rj8o20Fc;ah>#E+LI=i*8Ri!5^U7f3xe|W3hN0%?K&Aa-qa8`-)xPPYMXu=Un#X z+|mbb7vBblW$#h36IJWZ)Yc+p2cet z#QSUgF+VP0^Se%3{u8XP{k>SACf)vIQmwe~EseWbTZl~y?(~{?x6o7W=E?>C^|=q`<}Lnt z?&Ox$3g%U^|JN)3eAxEG@2YmP_;U-1z{)vMT0*w7Qs<_{biCSTyHd}~_1_)V#E8Q@ hPRkA~GF#XqDK5vmE@+4Be0J{gE5@nDb=zgxSO7eRTf_hW 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 9198471a2d8e88179aedd46dcc366e450944bbbb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17911 zcmeHP2T&AA7ap<*5*N`W3X+s~jAq5*>7)ua)9US z2@KPt=cw&kd35H!x}498Evo-0H0Zp%X`5<+~D(;pJVPw3z!sqRvfD=bo)EK8-gPu>s>nG|kR!_w`3ykrdEah`R&?xH% zpGho!P~R3nbG0*x;zOmlJO3eT-?V|_i52gs`dVoPW8RZ$Nc)FjO^OaOF##o{Oh7Ca z7fVMfc`m_)ZWAqh<^Co->IbAt1aJm392HjC%Qb=s*`Dy2m!>$Op+*l2X?0SVSxn5r z%U9(TUmqt-DP(5vyQIhTBu%L;_mWsCNwbflz_sMO84AbgGB)|nx;YJPy!l5n!%;>L z5!<&m9H_PxEN1OmY$@d{&PEXXUJnitH?4m2B}sq&@Yd|It=CYfbKlG?@$nZV%vl;I z3Idfs1BvFkTc65Nnk)v2WMI1F?{~+&F8UW(TCiVIUnUwy5KVK z#KYBhQhynf6_C|@H~#n)j?+rmnZ$IrXzQU<;mP)9 zcinUN#|hUa9}0-~zZaU3sGHn+O*$(mTWor*sKliLk`Gzg3G4rIBTVZ?)f9}lU+5A( zOYG=+13XDN`i-H;lMazhEKYK&2$2jZ-a}$|VxM9Tjizb{Lj(Ddn$rSZdhCy@eob_> z8Q}`-sc{cnj}&Mg9P(h%{Ma?)-K5KwsGixQF;Uo`JtzVsn!y z@3<)yvE!^eqx-!44pG5$je$Cz?Up=)LX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+|e2kzWi26YX+SFOF< z`Nb@$C!%i0Is-l=Roo+auJ4pYD4aV%`Jh~|yj2b|2ktM?%5X1DrSMD$+mv^r`ELaPzL)rGg@+MQjqohnz1wZlv)tW%G=A{l>V48+qGh; zWcR{vlD0O6Zv|GngfzA-x;^0pe}HQL&8~Nk#o~1|Bc#;Ig%ZE)D|UT9DIi#%bJ>@3 zOCPvhd>b5=!LNN~?T<;pPqX<>wf*^dz(?_JeUqoMXV!U#RnvK{m@huU9jI~c#LXa4 z0ccn`5dctSIH?Cf85kC0Vqkz_7NEERBLhRodaazy5Rok>%{Q*7vJl>)IWfA#`?3pr zCI6{?(c8=J0+kU3fJTAA7sgLBA{>^Bc88m-VheQHa`oKH{j*N2UJ>4`b(;Nv@EcaB zx}EF97KPNks+wP@$ZH^F?Be<&ep+t+Y*mrD{QdG*Z4CGL#1+CR1~=2Gg6z3=O_ xbNW8V9a+I^dlF^cPP8QV9VnJL6gH*G=}+`WokDePMYGrT?%Y-Xc5Y>70RVt_>`?#! 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 c478aacd3ff190fac2017c0c07cbc61bc28a3ade..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16336 zcmeHO2UJtp*1n;ND4`054k93ZP%xr&RGL%;q(x~Hq>2=ShTfzqok&qiXhTt|2pDC6 z0D=et3J8dhfYL!hL4U^O{nzrX8IxK6u-^OM%3X_W&OPUTdw*Z{y=R{!$2QN~8rVLV z|9JV613VuozeH;SUt+V8IDo5ztk=Vb8DbQr3Rqj@eP#r+f~@}J(jQKFGeM_DRQ8~| zXk7|>y;{#Xjm`&2Pfk*k8eVziz?@KQ+Wj|oH}Tm zZNS*XEighH8nhDp)$9=z0q5s1Rq}LTQ&(=(;)~uNVriXu$omE1YkrIW~c%dq3r6cjJk~n;B72$kJ%(nxA1m;Z@2ZgZLh4n}<&)S`1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_&QX(u*Bn#%#It`o)qe;yhW_9gxrC8odwBv#%&MMbLH@1g6Bk82{FKiW- zt9vt~rX}sq$z9%E(7dE5&-n@G?VX`wCbVqka>E$7JRN2y+fE)vkL$ z8@O-LWLF#Cg~%n^aU^}i>rMXVCfxCbR|0(>j#D;BrBbBm?QaE&Fdq4>BZzU0WhC>S zGL*Py=38YtZa`I^MR2w>M*CK>=z))VY9w?6Rg6)d6Ez<55#BN{8;N!tAZo6(sQ3LRpEGXvhCF1jo_;aLGy-w3i5b{B=(^MP2hpff1Eze^g#g^C00i(tmAr7P5i6;Pny zc`yhla-co2|4|SZyl%Y`BnNJ^vPKSSw~h6{er^YYfFcLl9oF6aB{W8x)TXM-?d7&; zt9km(Rx&0d%3%&j^$d-$7a%@p57yT!L2}^vHF8i}g@DFTB^U%0IWP#;%soD{GQ~CB zCAuQDwVvb-UW!9lOcH6YWG<5D$)xwhug>I257QsbaYmfXxD|+8hCc9WOdMc~4&TSIiAU=o-*4HaRa^Uz% F@ed4_9E|_~ 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 9192771ec21fd1f24b61fbc16f6eb10a2281ea5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1636 zcmWe&fPg1vd$xspyX@k~zPM}0nt5ImRk!!E>^P~QcFAmNsF|KicYn8u*@vGq$_#hx z=gnE&btyFP^tT+PhTSd+ZsMiSyVn4XX})!M)|=4zo4@V}EwBnc`JC-oSKh&yA@?@~ ze>{Dx_mh2q-Tr|2Phz=l9{43xcJ$6OCcT%{f0wTk6RG}}m~iL#Di+5!!?Xp-8WL}% zr=H$<&wk++U$Ny0G10OYD`kARJz3X2jPNgg9dsF&j#%$M$ zrIOtXze(EK7`_!)?Gn=1w&?bR6Z`?H{WrVbJr;}C(TtE%D;G-qvai_n{iJ|kea>ZH z&Mkf5cJXa+SO&lLm9;-61wYMx!)mY0_{8Rd@}dv_Uh2;+S<1JZRrb`A&*C5McP^7@ zdL#f1D<=W~sthOf04M{)J6IVQU>Ib+6C(pd2@?auGG+z_10XxR@?q~gwdGp7yt8kH zWr-G;MEe-5c)x0a0e9ef-Rdo$fLe$GK%>Cmc+A_DBePO|us_`RdTW5F%)DiMe_|xt z+@jWeTlMEVPb1J;Fp#+&64UTIz2U5`S*p;}$qT2IF*I`TRlmQk;p0?{>Kl_c7@*OIdZ}_3#xO71uegBQN4D()};Ig#Tyi? z72n3NvJAHnYZiQRbaK}ExH`X@LdJ?kNzu}AZ8w_ozidw5v$cLf-^~ljj!`+s6?X04 zbpA_Xle(httlx7uMdYvhZrt~;qHzA=llj*jUi|5=mooS_^(UX(l&yPP*9)!lef4+u zu08QGdnd4gLo6WlVqfs;JBISp`xYl@UOr%4V4Z3DDIi9I|45}Z=l|8X;uKvRmKF%5 zF<_DhgPrTd7KPNks+wP@$ZH^F?Be<&ep+t+Y*mrD1UZM|8ztS#Hl9jbyJ`4^*tEb$ zRg*ZJQw5imHGbAlc`9d_pSfn@72{{~=5Ay^aqQM+EB}pUtTitx{~s3qB2p2^CI0wx z+4Wmru5{!uEPs7vX4U^GyVokQJJu!r`Kr@+F7c9k+O6Y0$scVGS>IY B9%29h 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 0e0e0eebefea3979ae3a4da12b4f4d1b36695c35..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18136 zcmeHOc{r478-FF)3Kfy9Y&G_s?AdpXJwkHGF@sR{5+Ymn?CY_O5IVAzZICh{p%Aj4 zv1Sh$r%%4#KRVYr&7AAYbuyas-dHa(C z{C+~LrovcL=?Mw^^^>Zibd6|^%E*INt*6g)iNzU;@hSburQdv|7f6nr3|>;03HZFR zc1!CXkD3KNnezI2>g1D;rNuTe-#G8VN$3>ZsPB_Ga}{A@j5M1e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DgdO2<-dA?%Ygp?riLsF&`5^BgLa+@xO!O8a(7I_#8wM4<&`)Qc$#4q5F0 zj1@;oafVFG^N!}nh2s(s=GP^die6uvVdsmj2L?r<%Ua}A^lV%`X(AjU++O~2ff9iC z_wF-6##2lg9-rfF*1k}cbPDQeT`5%eR8VqOg@lYrvd#*JZ;R zjSZ>UilK{RE0I^;T`fQi=1Rob`nH9eYRJ0hQULSJELn8izrZ*7m|mkM5|}t??bkSMkM+>rFGm!J?O=OleMkXT>Wc*MeEm=Vx-N;uKKOeHu?Ma5I2S5YR;r+Lc0CCaT z0m^|jDkq}bPz@a@cpU^qM-G(7w3k6#@V=dDP!1gb`-&Vm`GC6|qQ>Wb>A642p=MTe z`}pk?27jIh!vbAcf^uSdM4RC-9en$`e(%?0aWl5P#$dW zRD!`3qw+SIAjIIWaKt~QVf+2_H&Z_j|hJi{w{>Db115Up3qxrTe_-{oENjYBN z34!`RT(G@U{ihs?+ikV{X5aLyb9fdtdGp27jIh!vbAcf*xiV)HCtf zwDIZU5w<=&6?-4%2KbWJv5%B^%qs{{xV;4NL0quCQw@eYxNt^=CAy6}cLMwKJZJw_#iIW-l+!VKztOr-P&~& z1V={>T(#Gf9L?0bHRqM?bb^eJPEcN9#vEpUEt!of)t!TQxt|Us0pfz~ooY}H#3%e0 Di4U`K From 4e22ca2485ded3e07c04b325bfe2dc2dcb218418 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 5 Nov 2019 08:07:26 -0800 Subject: [PATCH 16/82] Update validator to use proposer slot (#3919) --- beacon-chain/rpc/validator_server.go | 12 +- beacon-chain/rpc/validator_server_test.go | 8 +- proto/beacon/rpc/v1/services.pb.go | 250 ++++++++++----------- proto/beacon/rpc/v1/services.proto | 5 +- proto/beacon/rpc/v1_gateway/services.pb.go | 214 +++++++++--------- validator/client/BUILD.bazel | 1 - validator/client/runner.go | 4 +- validator/client/runner_test.go | 2 +- validator/client/validator.go | 25 +-- validator/client/validator_attest_test.go | 9 +- validator/client/validator_test.go | 62 ++--- 11 files changed, 300 insertions(+), 292 deletions(-) diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index f6cb539fb5eb..bce15d5d1f50 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -195,17 +195,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) { // TODO(3865): Update ValidatorAssignments_CommitteeAssignment to take in proposer slot - committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(beaconState, epoch, idx) + committee, shard, 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, + Shard: shard, + 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 4d6ff5bf6251..7f9142b6b511 100644 --- a/beacon-chain/rpc/validator_server_test.go +++ b/beacon-chain/rpc/validator_server_test.go @@ -177,9 +177,9 @@ func TestCommitteeAssignment_OK(t *testing.T) { if err != nil { t.Fatalf("Could not call epoch committee assignment %v", err) } - 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. @@ -192,9 +192,9 @@ func TestCommitteeAssignment_OK(t *testing.T) { if err != nil { t.Fatalf("Could not call epoch committee assignment %v", err) } - 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) } } diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index bdba22dc3238..d275e6bbd7d6 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -33,18 +33,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 { @@ -958,8 +961,8 @@ 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"` + 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:"-"` @@ -1016,18 +1019,18 @@ func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { 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 { @@ -1429,105 +1432,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, 0x07, 0x58,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xfb, 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, + // 1577 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4f, 0x4f, 0x1b, 0x49, + 0x16, 0x4f, 0x1b, 0x63, 0xc8, 0xb3, 0x81, 0xa6, 0x70, 0xc0, 0x71, 0x48, 0x96, 0xed, 0x4d, 0x76, + 0x01, 0x29, 0x36, 0x38, 0x51, 0xb4, 0x9b, 0x28, 0x1b, 0xd9, 0xb8, 0x03, 0x56, 0x22, 0x43, 0xda, + 0x0e, 0x64, 0x95, 0x43, 0xab, 0x6c, 0x57, 0x70, 0x2b, 0x76, 0x57, 0xd3, 0x5d, 0xb6, 0xc2, 0x65, + 0xa5, 0xfd, 0x08, 0x7b, 0x98, 0xf3, 0x68, 0x3e, 0xc3, 0x1c, 0xe6, 0x2b, 0xe4, 0x38, 0x1f, 0x60, + 0x0e, 0xa3, 0x68, 0xbe, 0xc1, 0x9c, 0x47, 0x1a, 0x75, 0x55, 0xf5, 0x1f, 0x6c, 0x1c, 0x4c, 0x6e, + 0x5d, 0xef, 0xbd, 0xdf, 0x7b, 0xaf, 0x5e, 0xbd, 0x7f, 0x36, 0x68, 0x8e, 0x4b, 0x19, 0x2d, 0xb6, + 0x08, 0x6e, 0x53, 0xbb, 0xe8, 0x3a, 0xed, 0xe2, 0x70, 0xb7, 0xe8, 0x11, 0x77, 0x68, 0xb5, 0x89, + 0x57, 0xe0, 0x4c, 0xb4, 0x4a, 0x58, 0x97, 0xb8, 0x64, 0xd0, 0x2f, 0x08, 0xb1, 0x82, 0xeb, 0xb4, + 0x0b, 0xc3, 0xdd, 0xfc, 0x9d, 0x53, 0x4a, 0x4f,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bc, 0x70, 0x0f, 0x56, 0xf6, 0x82, 0xc9, 0x1e, 0xdb, + 0x00, 0xb6, 0xa6, 0x59, 0x37, 0x84, 0xc5, 0xed, 0xe9, 0x37, 0x13, 0x74, 0x36, 0xde, 0x1d, 0xae, + 0x79, 0xbf, 0xeb, 0x2e, 0xc0, 0xe8, 0x7f, 0x0a, 0x64, 0x2f, 0xfb, 0xc5, 0x85, 0xae, 0x7e, 0xa1, + 0xf1, 0x1f, 0x7d, 0xf9, 0xc7, 0xd7, 0x03, 0x49, 0x1f, 0x06, 0xa0, 0x8e, 0x2e, 0xd0, 0x68, 0xe2, + 0x45, 0x26, 0xac, 0xe9, 0xf9, 0x9d, 0xe9, 0x01, 0xd2, 0xec, 0x7f, 0xc2, 0x64, 0x8e, 0x36, 0x70, + 0xb4, 0x5a, 0x10, 0xff, 0x06, 0x14, 0x82, 0xff, 0x1d, 0x0a, 0x7a, 0xdf, 0x61, 0xe7, 0x93, 0x9f, + 0x71, 0x7c, 0x7b, 0xdf, 0x51, 0xd0, 0x2b, 0x58, 0xd8, 0xc3, 0x36, 0xb5, 0xad, 0x36, 0xee, 0x1d, + 0x10, 0xdc, 0x99, 0xa8, 0x76, 0x8a, 0x7e, 0x50, 0xc9, 0x7c, 0xfe, 0x72, 0x4f, 0xf9, 0xf9, 0xcb, + 0x3d, 0xe5, 0xd7, 0x2f, 0xf7, 0x94, 0x56, 0x8a, 0x6b, 0x78, 0xf4, 0x67, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xda, 0x2d, 0x51, 0xd7, 0x5c, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2698,20 +2702,15 @@ func (m *AssignmentResponse_ValidatorAssignment) MarshalTo(dAtA []byte) (int, er i++ i = encodeVarintServices(dAtA, i, uint64(m.Shard)) } - 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 @@ -3288,11 +3287,11 @@ func (m *AssignmentResponse_ValidatorAssignment) Size() (n int) { if m.Shard != 0 { n += 1 + sovServices(uint64(m.Shard)) } - 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 { @@ -5277,9 +5276,9 @@ func (m *AssignmentResponse_ValidatorAssignment) Unmarshal(dAtA []byte) error { } 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 @@ -5289,16 +5288,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 @@ -5308,12 +5307,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 79e17cce369c..4ca36d84e33a 100644 --- a/proto/beacon/rpc/v1/services.proto +++ b/proto/beacon/rpc/v1/services.proto @@ -93,6 +93,7 @@ message ChainStartResponse { UNKNOWN = 0; ATTESTER = 1; PROPOSER = 2; + BOTH = 3; } message ValidatorIndexRequest { @@ -113,8 +114,8 @@ message AssignmentResponse { message ValidatorAssignment { repeated uint64 committee = 1; uint64 shard = 2; - uint64 slot = 3; - bool is_proposer = 4; + 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 c7f6837657d9..1960a0cf71b6 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -31,18 +31,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 { @@ -828,8 +831,8 @@ 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"` + 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:"-"` @@ -878,18 +881,18 @@ func (m *AssignmentResponse_ValidatorAssignment) GetShard() uint64 { 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 { @@ -1243,104 +1246,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, 0x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, 0x40, - 0xe7, 0x8c, 0xe3, 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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0x39, 0xb4, 0x85, 0xbb, 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, + // 1558 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x5f, 0x4f, 0x1b, 0x49, + 0x12, 0xcf, 0x18, 0x63, 0x48, 0xd9, 0xc0, 0xd0, 0x38, 0xe0, 0x38, 0x44, 0xc7, 0xcd, 0x25, 0x77, + 0x80, 0x14, 0x1b, 0x9c, 0x28, 0xba, 0x4b, 0x94, 0x8b, 0x6c, 0x3c, 0x01, 0x2b, 0x91, 0x21, 0x63, + 0x07, 0x72, 0xca, 0xc3, 0xa8, 0x6d, 0x77, 0xf0, 0x28, 0x9e, 0xe9, 0x61, 0xa6, 0x6d, 0x85, 0x97, + 0x93, 0xee, 0x23, 0xdc, 0xc3, 0x3d, 0x9f, 0xf6, 0x33, 0xec, 0xc3, 0x7e, 0x85, 0xfd, 0x10, 0xfb, + 0xb8, 0xdf, 0x60, 0x9f, 0x57, 0x5a, 0x4d, 0x77, 0xcf, 0x1f, 0x6c, 0x1c, 0x4c, 0xde, 0xa6, 0xab, + 0xea, 0x57, 0x55, 0x5d, 0x5d, 0xff, 0x6c, 0xd0, 0x5c, 0x8f, 0x32, 0x5a, 0xee, 0x10, 0xdc, 0xa5, + 0x4e, 0xd9, 0x73, 0xbb, 0xe5, 0xd1, 0x7e, 0xd9, 0x27, 0xde, 0xc8, 0xea, 0x12, 0xbf, 0xc4, 0x99, + 0x68, 0x9d, 0xb0, 0x3e, 0xf1, 0xc8, 0xd0, 0x2e, 0x09, 0xb1, 0x92, 0xe7, 0x76, 0x4b, 0xa3, 0xfd, + 0xe2, 0x83, 0x73, 0x4a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50, 0x71, + 0xd4, 0x71, 0x4c, 0x9e, 0x87, 0x32, 0xaa, 0x2b, 0x31, 0x5d, 0x0f, 0xc8, 0xe8, 0x35, 0x6c, 0x72, + 0x05, 0x81, 0xa0, 0xe5, 0x98, 0x09, 0xd8, 0xc5, 0x90, 0x0c, 0x45, 0xa7, 0x4e, 0x1b, 0xf7, 0x43, + 0x99, 0x86, 0x13, 0xb7, 0xb2, 0xf7, 0x81, 0x80, 0xf6, 0x0a, 0x96, 0xea, 0xd4, 0xc6, 0x56, 0xd4, + 0x98, 0xf3, 0x30, 0x2f, 0x2c, 0xca, 0xba, 0xe1, 0x07, 0xb4, 0x0e, 0x99, 0x1e, 0x17, 0x0b, 0x07, + 0xb4, 0x38, 0x69, 0x2f, 0x61, 0x39, 0x84, 0xcb, 0x70, 0xef, 0x80, 0x1a, 0x24, 0x1d, 0x66, 0x43, + 0x8f, 0x98, 0x12, 0x23, 0x54, 0xad, 0x44, 0x74, 0x01, 0xd1, 0xfe, 0x9b, 0x82, 0x55, 0x1e, 0xad, + 0xb6, 0x47, 0xe2, 0x71, 0xf9, 0x06, 0xd2, 0xcc, 0x93, 0x49, 0x9a, 0xad, 0x54, 0xa6, 0xbd, 0xd6, + 0x04, 0xb0, 0x14, 0x1c, 0x9a, 0xb4, 0x47, 0x0c, 0x8e, 0x2f, 0xfe, 0xa8, 0xc0, 0x62, 0x48, 0x42, + 0x7f, 0x87, 0x79, 0xfe, 0x6c, 0xdc, 0x95, 0x6c, 0x45, 0x8b, 0xb5, 0x12, 0xd6, 0x2f, 0x85, 0x8b, + 0x56, 0xa9, 0xc6, 0x4d, 0x88, 0xdd, 0x49, 0x00, 0xc6, 0xf6, 0x9d, 0xd4, 0xd8, 0xbe, 0x13, 0x4c, + 0x57, 0x17, 0x7b, 0xcc, 0xea, 0x5a, 0x2e, 0x9f, 0x44, 0x23, 0xca, 0x48, 0x38, 0x90, 0x57, 0x93, + 0x9c, 0xd3, 0x80, 0x11, 0x74, 0x12, 0x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3c, 0x80, 0xb5, 0x83, 0x70, 0xb2, 0x27, 0x36, 0x80, 0x9d, 0x59, 0xd6, + 0x0d, 0x61, 0x71, 0x77, 0xf6, 0xcd, 0x04, 0x5d, 0x4c, 0x76, 0x87, 0x5b, 0xde, 0xef, 0xb6, 0x0b, + 0x30, 0xfa, 0x8f, 0x02, 0xf9, 0xeb, 0x7e, 0x71, 0xa1, 0x9b, 0x5f, 0x68, 0xf2, 0x47, 0x5f, 0xf1, + 0xd9, 0xed, 0x40, 0xd2, 0x87, 0x21, 0xa8, 0xe3, 0x0b, 0x34, 0x9a, 0x7a, 0x91, 0x29, 0x6b, 0x7a, + 0x71, 0x6f, 0x76, 0x80, 0x34, 0xfb, 0xaf, 0x28, 0x99, 0xe3, 0x0d, 0x1c, 0xad, 0x97, 0xc4, 0xbf, + 0x01, 0xa5, 0xf0, 0x7f, 0x87, 0x92, 0x6e, 0xbb, 0xec, 0x72, 0xfa, 0x33, 0x4e, 0x6e, 0xef, 0x7b, + 0x0a, 0x7a, 0x0b, 0x4b, 0x07, 0xd8, 0xa1, 0x8e, 0xd5, 0xc5, 0x83, 0x23, 0x82, 0x7b, 0x53, 0xd5, + 0xce, 0xd0, 0x0f, 0x3a, 0x19, 0x8e, 0x79, 0xfa, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xfd, + 0xbc, 0x8c, 0x4e, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 0ed8887760e3..5b00371ce63d 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -60,7 +60,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 7c550297ad1f..dcce0102d810 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -89,10 +89,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 4d1b473bd2e8..d828d8a81620 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 20bbf6ff9c94..e2e4d4df6ed0 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -207,10 +207,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") } @@ -226,17 +226,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_test.go b/validator/client/validator_attest_test.go index 028dcf6a1cbf..10ade4a1292b 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" @@ -163,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") diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index f466666f4cb3..56876f78ed3b 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -391,9 +391,9 @@ func TestUpdateAssignments_DoesNothingWhenNotEpochStartAndAlreadyExistingAssignm assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Committee: []uint64{}, - Slot: 10, - Shard: 20, + Committee: []uint64{}, + AttesterSlot: 10, + Shard: 20, }, }, }, @@ -449,11 +449,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, + Shard: 100, + Committee: []uint64{0, 1, 2, 3}, + PublicKey: []byte("testPubKey_1"), + ProposerSlot: params.BeaconConfig().SlotsPerEpoch + 1, }, }, } @@ -469,15 +469,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].Shard != resp.ValidatorAssignment[0].Shard { + t.Errorf("Unexpected validator assignments. want=%v got=%v", resp.ValidatorAssignment[0].Shard, v.assignments.ValidatorAssignment[0].Shard) } } @@ -487,33 +486,40 @@ func TestRolesAt_OK(t *testing.T) { assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Shard: 1, - Slot: 1, - IsProposer: true, - PublicKey: []byte{0x01}, + Shard: 1, + AttesterSlot: 1, + PublicKey: []byte{0x01}, }, { - Shard: 2, - Slot: 1, - PublicKey: []byte{0x02}, + Shard: 2, + ProposerSlot: 1, + PublicKey: []byte{0x02}, }, { - Shard: 1, - Slot: 2, - PublicKey: []byte{0x03}, + Shard: 1, + AttesterSlot: 2, + PublicKey: []byte{0x03}, + }, + { + Shard: 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") + } } From 86173446ac01312d5afc4c51b85e8686e3ca33c0 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 5 Nov 2019 11:46:34 -0800 Subject: [PATCH 17/82] Fix committee assignment (#3931) --- beacon-chain/core/helpers/committee.go | 2 +- beacon-chain/core/helpers/committee_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index e91e35a4da69..ce08a1c7071c 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -240,7 +240,7 @@ func CommitteeAssignment( return nil, 0, 0, false, 0, fmt.Errorf( "could not get crosslink committee: %v", err) } - for i, v := range committee { + for _, v := range committee { if validatorIndex == v { proposerSlot, isProposer := proposerIndexToSlot[v] return committee, uint64(i), slot, isProposer, proposerSlot, nil diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index b38cced1481a..bd4b07fc26d8 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -243,7 +243,7 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { index: 0, slot: 92, committee: []uint64{46, 0}, - committeeIndex: 1, + committeeIndex: 0, isProposer: false, }, { @@ -258,7 +258,7 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { index: 11, slot: 64, committee: []uint64{30, 11}, - committeeIndex: 1, + committeeIndex: 0, isProposer: false, }, } From b20fc615fda5e49c3c654da4821f3668cce75259 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 5 Nov 2019 14:57:16 -0800 Subject: [PATCH 18/82] Replace shard with committee index (#3930) --- beacon-chain/cache/attestation_data.go | 2 +- beacon-chain/cache/attestation_data_test.go | 4 +- beacon-chain/rpc/attester_server.go | 2 +- beacon-chain/rpc/attester_server_test.go | 12 +- beacon-chain/rpc/beacon_chain_server.go | 21 +- beacon-chain/rpc/beacon_chain_server_test.go | 60 ++--- beacon-chain/rpc/validator_server.go | 13 +- proto/beacon/rpc/v1/services.pb.go | 240 +++++++++--------- proto/beacon/rpc/v1/services.proto | 4 +- proto/beacon/rpc/v1_gateway/services.pb.go | 210 ++++++++-------- proto/eth/v1alpha1/beacon_chain.pb.go | 250 +++++++++---------- proto/eth/v1alpha1/beacon_chain.proto | 12 +- validator/client/validator_attest.go | 10 +- validator/client/validator_attest_test.go | 28 +-- validator/client/validator_test.go | 48 ++-- 15 files changed, 458 insertions(+), 458 deletions(-) diff --git a/beacon-chain/cache/attestation_data.go b/beacon-chain/cache/attestation_data.go index 5529c3f631cc..8b20295b310f 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 c17e3eb01756..ad6d84034bdb 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/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index 0758abdb829d..49f37bf199f9 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -60,7 +60,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)), ) res, err := as.attestationCache.Get(ctx, req) if err != nil { diff --git a/beacon-chain/rpc/attester_server_test.go b/beacon-chain/rpc/attester_server_test.go index 59ce5a2dee80..5cae039e9478 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -120,8 +120,8 @@ 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 { @@ -201,8 +201,8 @@ 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 { @@ -240,8 +240,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 b6f78a66fbb6..ebfdf1cfbb20 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -42,7 +42,7 @@ type BeaconChainServer struct { } // sortableAttestations implements the Sort interface to sort attestations -// by shard as the canonical sorting attribute. +// by committeeIndex as the canonical sorting attribute. type sortableAttestations []*ethpb.Attestation func (s sortableAttestations) Len() int { return len(s) } @@ -52,7 +52,7 @@ func (s sortableAttestations) Less(i, j int) bool { } // ListAttestations retrieves attestations by block root, slot, or epoch. -// Attestations are sorted by crosslink shard by default. +// Attestations are sorted by crosslink committeeIndex 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 @@ -584,7 +584,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( index, len(headState.Validators)) } var committee []uint64 - var shard uint64 + var committeeIndex uint64 var slot uint64 var isProposer bool if shouldFetchFromArchive { @@ -603,25 +603,24 @@ func (bs *BeaconChainServer) ListValidatorAssignments( requestedEpoch, ) } - committee, shard, slot, err = bs.archivedValidatorCommittee(requestedEpoch, index, archivedInfo, activeIndices) + committee, committeeIndex, slot, err = bs.archivedValidatorCommittee(requestedEpoch, index, archivedInfo, activeIndices) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve assignment for validator %d: %v", index, err) } isProposer = archivedInfo.ProposerIndex == index } else { - // TODO(3865): Update ValidatorAssignments_CommitteeAssignment to take in proposer slot - committee, shard, slot, isProposer, _, err = helpers.CommitteeAssignment(headState, requestedEpoch, index) + committee, committeeIndex, slot, isProposer, _, 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) } } res = append(res, ðpb.ValidatorAssignments_CommitteeAssignment{ - CrosslinkCommittees: committee, - Shard: shard, - Slot: slot, - Proposer: isProposer, - PublicKey: headState.Validators[index].PublicKey, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + Slot: slot, + Proposer: isProposer, + PublicKey: headState.Validators[index].PublicKey, }) } diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index c508eed9e78d..6af1f7d677ff 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -1216,16 +1216,16 @@ 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, 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, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + Slot: slot, + Proposer: isProposer, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1324,16 +1324,16 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing t.Fatal(err) } for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { - committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, 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, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + Slot: slot, + Proposer: isProposer, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1401,16 +1401,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, 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, + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + Slot: slot, + Proposer: isProposer, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1478,16 +1478,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, slot, isProposer, _, 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, + Slot: slot, + Proposer: isProposer, + PublicKey: s.Validators[index].PublicKey, }) } @@ -1510,16 +1510,16 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } for _, index := range activeIndices[6:7] { - committee, shard, slot, isProposer, _, err := helpers.CommitteeAssignment(s, 0, index) + committee, committeeIndex, slot, isProposer, _, 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, + Slot: slot, + Proposer: isProposer, + PublicKey: s.Validators[index].PublicKey, }) } diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index bce15d5d1f50..71977dcb9f89 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -194,18 +194,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) { - // TODO(3865): Update ValidatorAssignments_CommitteeAssignment to take in proposer slot - committee, shard, aSlot, _, pSlot, 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, - AttesterSlot: aSlot, - ProposerSlot: pSlot, - Status: status, + Committee: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: aSlot, + ProposerSlot: pSlot, + Status: status, }, nil } diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index d275e6bbd7d6..bcae8f7cec38 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -207,7 +207,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:"-"` @@ -267,9 +267,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 } @@ -960,7 +960,7 @@ 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"` + 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"` @@ -1012,9 +1012,9 @@ 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 } @@ -1432,106 +1432,106 @@ func init() { func init() { proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_9eb4e94b85965285) } var fileDescriptor_9eb4e94b85965285 = []byte{ - // 1577 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4f, 0x4f, 0x1b, 0x49, - 0x16, 0x4f, 0x1b, 0x63, 0xc8, 0xb3, 0x81, 0xa6, 0x70, 0xc0, 0x71, 0x48, 0x96, 0xed, 0x4d, 0x76, - 0x01, 0x29, 0x36, 0x38, 0x51, 0xb4, 0x9b, 0x28, 0x1b, 0xd9, 0xb8, 0x03, 0x56, 0x22, 0x43, 0xda, - 0x0e, 0x64, 0x95, 0x43, 0xab, 0x6c, 0x57, 0x70, 0x2b, 0x76, 0x57, 0xd3, 0x5d, 0xb6, 0xc2, 0x65, - 0xa5, 0xfd, 0x08, 0x7b, 0x98, 0xf3, 0x68, 0x3e, 0xc3, 0x1c, 0xe6, 0x2b, 0xe4, 0x38, 0x1f, 0x60, - 0x0e, 0xa3, 0x68, 0xbe, 0xc1, 0x9c, 0x47, 0x1a, 0x75, 0x55, 0xf5, 0x1f, 0x6c, 0x1c, 0x4c, 0x6e, - 0x5d, 0xef, 0xbd, 0xdf, 0x7b, 0xaf, 0x5e, 0xbd, 0x7f, 0x36, 0x68, 0x8e, 0x4b, 0x19, 0x2d, 0xb6, - 0x08, 0x6e, 0x53, 0xbb, 0xe8, 0x3a, 0xed, 0xe2, 0x70, 0xb7, 0xe8, 0x11, 0x77, 0x68, 0xb5, 0x89, - 0x57, 0xe0, 0x4c, 0xb4, 0x4a, 0x58, 0x97, 0xb8, 0x64, 0xd0, 0x2f, 0x08, 0xb1, 0x82, 0xeb, 0xb4, - 0x0b, 0xc3, 0xdd, 0xfc, 0x9d, 0x53, 0x4a, 0x4f, 0x7b, 0xa4, 0xc8, 0xa5, 0x5a, 0x83, 0x0f, 0x45,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b, - 0x00, 0xb6, 0xa6, 0x59, 0x37, 0x84, 0xc5, 0xed, 0xe9, 0x37, 0x13, 0x74, 0x36, 0xde, 0x1d, 0xae, - 0x79, 0xbf, 0xeb, 0x2e, 0xc0, 0xe8, 0x7f, 0x0a, 0x64, 0x2f, 0xfb, 0xc5, 0x85, 0xae, 0x7e, 0xa1, - 0xf1, 0x1f, 0x7d, 0xf9, 0xc7, 0xd7, 0x03, 0x49, 0x1f, 0x06, 0xa0, 0x8e, 0x2e, 0xd0, 0x68, 0xe2, - 0x45, 0x26, 0xac, 0xe9, 0xf9, 0x9d, 0xe9, 0x01, 0xd2, 0xec, 0x7f, 0xc2, 0x64, 0x8e, 0x36, 0x70, - 0xb4, 0x5a, 0x10, 0xff, 0x06, 0x14, 0x82, 0xff, 0x1d, 0x0a, 0x7a, 0xdf, 0x61, 0xe7, 0x93, 0x9f, - 0x71, 0x7c, 0x7b, 0xdf, 0x51, 0xd0, 0x2b, 0x58, 0xd8, 0xc3, 0x36, 0xb5, 0xad, 0x36, 0xee, 0x1d, - 0x10, 0xdc, 0x99, 0xa8, 0x76, 0x8a, 0x7e, 0x50, 0xc9, 0x7c, 0xfe, 0x72, 0x4f, 0xf9, 0xf9, 0xcb, - 0x3d, 0xe5, 0xd7, 0x2f, 0xf7, 0x94, 0x56, 0x8a, 0x6b, 0x78, 0xf4, 0x67, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xda, 0x2d, 0x51, 0xd7, 0x5c, 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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 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, 0x5a, 0x9b, 0xa0, 0xe2, 0xb0, 0x09, 0x99, 0x3c, 0x35, 0x65, 0x54, 0x17, + 0xfa, 0x74, 0xdd, 0x27, 0xa3, 0xa7, 0xb0, 0xc6, 0x15, 0xf8, 0x82, 0x96, 0x6d, 0x46, 0x60, 0xa7, + 0x5d, 0xd2, 0x15, 0xcd, 0x3b, 0x6e, 0x5c, 0x0f, 0x64, 0xca, 0x76, 0xbf, 0xbb, 0xbd, 0xf4, 0x05, + 0xb4, 0x27, 0x30, 0x57, 0xa2, 0x1d, 0x6c, 0x85, 0xbd, 0x7a, 0x19, 0xa6, 0x85, 0x45, 0x59, 0x4a, + 0xfc, 0x80, 0x56, 0x20, 0xd1, 0xe4, 0x62, 0xc1, 0x18, 0x17, 0x27, 0xed, 0x31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+ 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. @@ -2210,10 +2210,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) @@ -2697,10 +2697,10 @@ 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.AttesterSlot != 0 { dAtA[i] = 0x18 @@ -3005,8 +3005,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) @@ -3284,8 +3284,8 @@ 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.AttesterSlot != 0 { n += 1 + sovServices(uint64(m.AttesterSlot)) @@ -3755,9 +3755,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 @@ -3767,7 +3767,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 } @@ -5257,9 +5257,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 @@ -5269,7 +5269,7 @@ 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 } diff --git a/proto/beacon/rpc/v1/services.proto b/proto/beacon/rpc/v1/services.proto index 4ca36d84e33a..09ac75c1e233 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 { @@ -113,7 +113,7 @@ message AssignmentResponse { repeated ValidatorAssignment validator_assignment = 1; message ValidatorAssignment { repeated uint64 committee = 1; - uint64 shard = 2; + uint64 committee_index = 2; uint64 attester_slot = 3; uint64 proposer_slot = 4; bytes public_key = 5; diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index 1960a0cf71b6..c708d734c2bc 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -189,7 +189,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:"-"` @@ -241,9 +241,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 } @@ -830,7 +830,7 @@ 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"` + 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"` @@ -874,9 +874,9 @@ 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 } @@ -1246,105 +1246,105 @@ func init() { func init() { proto.RegisterFile("proto/beacon/rpc/v1/services.proto", fileDescriptor_9eb4e94b85965285) } var fileDescriptor_9eb4e94b85965285 = []byte{ - // 1558 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x5f, 0x4f, 0x1b, 0x49, - 0x12, 0xcf, 0x18, 0x63, 0x48, 0xd9, 0xc0, 0xd0, 0x38, 0xe0, 0x38, 0x44, 0xc7, 0xcd, 0x25, 0x77, - 0x80, 0x14, 0x1b, 0x9c, 0x28, 0xba, 0x4b, 0x94, 0x8b, 0x6c, 0x3c, 0x01, 0x2b, 0x91, 0x21, 0x63, - 0x07, 0x72, 0xca, 0xc3, 0xa8, 0x6d, 0x77, 0xf0, 0x28, 0x9e, 0xe9, 0x61, 0xa6, 0x6d, 0x85, 0x97, - 0x93, 0xee, 0x23, 0xdc, 0xc3, 0x3d, 0x9f, 0xf6, 0x33, 0xec, 0xc3, 0x7e, 0x85, 0xfd, 0x10, 0xfb, - 0xb8, 0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0xfa, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xfd, - 0xbc, 0x8c, 0x4e, 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, 0x35, 0x7b, 0x1f, 0x0a, 0xc4, 0x76, 0xd9, 0x85, 0x00, + 0xe5, 0xee, 0x0b,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eb, + 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, 0x2a, 0xbf, 0xd6, 0xd5, 0xd9, 0x00, 0x11, 0xf0, 0xf4, 0x8a, 0x9a, + 0x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 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/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index affdb7697535..22848825a0d9 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -1744,8 +1744,8 @@ 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"` + 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"` Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` Proposer bool `protobuf:"varint,4,opt,name=proposer,proto3" json:"proposer,omitempty"` PublicKey []byte `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" ssz-size:"48"` @@ -1789,16 +1789,16 @@ 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 } @@ -2109,108 +2109,108 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ - // 1606 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4b, 0x6f, 0x1b, 0x47, - 0x12, 0xf6, 0x88, 0xa4, 0x1e, 0x45, 0x3d, 0xac, 0x96, 0x64, 0x73, 0x47, 0x96, 0x44, 0x8f, 0x2c, - 0x2d, 0x0d, 0xdb, 0xa4, 0x25, 0x3f, 0x76, 0xe1, 0xc5, 0xc2, 0x6b, 0x09, 0x5e, 0x6b, 0x77, 0x8d, - 0x85, 0x32, 0x32, 0x72, 0xc8, 0x85, 0x68, 0x0e, 0x5b, 0x64, 0x5b, 0xc3, 0xe9, 0xf1, 0x74, 0x53, - 0xb0, 0x74, 0x4b, 0x0e, 0x01, 0x72, 0x0e, 0x90, 0x20, 0x97, 0x24, 0x57, 0x23, 0xc8, 0x21, 0x97, - 0x5c, 0x0c, 0x04, 0x41, 0x4e, 0x39, 0x05, 0x01, 0x02, 0xe4, 0x68, 0x04, 0x46, 0xfe, 0x40, 0xfc, - 0x07, 0x12, 0x4c, 0x4f, 0xcf, 0x83, 0x14, 0x87, 0xa4, 0x61, 0x1d, 0x72, 0x9b, 0xae, 0xae, 0xfe, - 0xea, 0xeb, 0xaa, 0xea, 0xea, 0xea, 0x81, 0x35, 0xd7, 0x63, 0x82, 0x55, 0x88, 0x68, 0x56, 0x0e, - 0x37, 0xb0, 0xed, 0x36, 0xf1, 0x46, 0xa5, 0x46, 0xb0, 0xc5, 0x9c, 0xaa, 0xd5, 0xc4, 0xd4, 0x29, - 0xcb, 0x79, 0xb4, 0x40, 0x44, 0x93, 0x78, 0xa4, 0xdd, 0x2a, 0x13, 0xd1, 0x2c, 0x87, 0x9a, 0xfa, - 0xb5, 0x06, 0x15, 0xcd, 0x76, 0xad, 0x6c, 0xb1, 0x56, 0xa5, 0xc1, 0x1a, 0xac, 0x22, 0xb5, 0x6b, - 0xed, 0x7d, 0x39, 0x0a, 0xa0, 0xfd, 0xaf, 0x00, 0x45, 0xbf, 0xd0, 0x60, 0xac, 0x61, 0x93, 0x0a, - 0x76, 0x69, 0x05, 0x3b, 0x0e, 0x13, 0x58, 0x50, 0xe6, 0x70, 0x35, 0xbb, 0xa8, 0x66, 0x23, 0x0c, - 0xd2, 0x72, 0xc5, 0x91, 0x9a, 0xbc, 0xd4, 0x83, 0x27, 0x16, 0x82, 0xf0, 0x00, 0x43, 0x69, 0xf5, - 0xd9, 0x4d, 0xcd, 0x66, 0xd6, 0x81, 0x52, 0x33, 0x7a, 0xa8, 0x1d, 0x62, 0x9b, 0xd6, 0xb1, 0x60, - 0x5e, 0xa0, 0x63, 0x7c, 0x36, 0x02, 0xe7, 0x1f, 0x52, 0x2e, 0xee, 0xc5, 0x46, 0xb8, 0x49, 0x9e, - 0xb4, 0x09, 0x17, 0xa8, 0x04, 0x33, 0x4d, 0x82, 0xeb, 0x01, 0x66, 0xd5, 0x63, 0x4c, 0x14, 0xb4, - 0xa2, 0x56, 0x9a, 0xdc, 0x39, 0x63, 0x4e, 0xf9, 0x13, 0x5b, 0xbe, 0xdc, 0x64, 0x4c, 0xa0, 0x55, - 0x98, 0xe4, 0xac, 0xed, 0x59, 0xa4, 0x4a, 0x5c, 0x66, 0x35, 0x0b, 0x23, 0x45, 0xad, 0x94, 0xdd, - 0x39, 0x63, 0xe6, 0x03, 0xe9, 0x7d, 0x5f, 0x88, 0x2e, 0x82, 0x1a, 0x06, 0x50, 0x19, 0x05, 0x05, - 0x81, 0x30, 0xc4, 0x11, 0xd8, 0x6b, 0x10, 0xa1, 0x70, 0xb2, 0x21, 0x4e, 0x20, 0x8d, 0x70, 0x94, - 0x92, 0xc4, 0xc9, 0x85, 0x38, 0x81, 0x50, 0xe2, 0x2c, 0xc2, 0x84, 0x8b, 0x1b, 0xa4, 0xca, 0xe9, - 0x31, 0x29, 0x8c, 0x16, 0xb5, 0x52, 0xce, 0x1c, 0xf7, 0x05, 0x7b, 0xf4, 0x98, 0xa0, 0x25, 0x00, - 0x39, 0x29, 0xd8, 0x01, 0x71, 0x0a, 0x63, 0x45, 0xad, 0x34, 0x61, 0x4a, 0xf5, 0x47, 0xbe, 0x60, - 0x6b, 0x1a, 0x26, 0x9f, 0xb4, 0x89, 0x77, 0x54, 0xdd, 0xa7, 0xb6, 0x20, 0x9e, 0xf1, 0x4c, 0x83, - 0xc2, 0x49, 0x0f, 0x71, 0x97, 0x39, 0x9c, 0xa0, 0x7f, 0xc3, 0x64, 0x22, 0x3c, 0xbc, 0xa0, 0x15, - 0x33, 0xa5, 0xfc, 0xa6, 0x51, 0xee, 0x99, 0x47, 0xe5, 0x04, 0x84, 0xd9, 0xb1, 0x0e, 0xad, 0xc3, - 0x8c, 0x43, 0x9e, 0x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0xf1, - 0x9a, 0xfa, 0x56, 0x67, 0xe2, 0x7a, 0xca, 0x99, 0x38, 0xb1, 0xb6, 0xac, 0x3e, 0xcc, 0x08, 0x41, - 0x3f, 0x80, 0x31, 0x25, 0xf4, 0x33, 0x3b, 0xde, 0x4e, 0xef, 0xcc, 0xf6, 0xf7, 0x32, 0x11, 0xed, - 0x05, 0xcd, 0x43, 0x8e, 0x3a, 0x75, 0xf2, 0x54, 0x25, 0x75, 0x30, 0xf0, 0x37, 0xa8, 0xe0, 0x55, - 0x26, 0x87, 0x43, 0xe3, 0x23, 0x0d, 0xe6, 0x93, 0x41, 0x78, 0x23, 0xef, 0x77, 0x14, 0x9f, 0x4c, - 0xdf, 0xe2, 0x93, 0x1d, 0x54, 0x7c, 0xbe, 0xd0, 0x00, 0x62, 0x56, 0xfe, 0xbe, 0x12, 0x74, 0x42, - 0x32, 0xff, 0x02, 0x88, 0xee, 0x56, 0x9f, 0x8f, 0xef, 0xfa, 0xe2, 0x20, 0xd7, 0x9b, 0x89, 0x35, - 0xbd, 0x0a, 0x52, 0x66, 0x70, 0x41, 0xca, 0x76, 0x17, 0x24, 0x0a, 0xab, 0x49, 0x2f, 0xde, 0xb3, - 0x04, 0x3d, 0x24, 0x7b, 0x44, 0x6c, 0x37, 0xb1, 0xd3, 0x78, 0xa3, 0x94, 0x3e, 0xe1, 0x98, 0x6f, - 0x46, 0xe0, 0x6c, 0x37, 0x7e, 0x8a, 0x7b, 0x1e, 0xc0, 0x02, 0xf6, 0x35, 0xb1, 0x20, 0xf5, 0x6a, - 0xf2, 0x5c, 0x8c, 0xa4, 0x9f, 0x8b, 0xb9, 0x68, 0xc5, 0x6e, 0x7c, 0x40, 0xee, 0x01, 0x22, 0x4f, - 0x69, 0x37, 0x4a, 0x9f, 0xd3, 0x75, 0x36, 0x50, 0x4f, 0x40, 0x6c, 0xc3, 0x1c, 0xb7, 0x31, 0x6f, - 0x76, 0x61, 0x64, 0xd3, 0x31, 0x66, 0x95, 0x7e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0xfe, 0x36, 0x44, 0x84, 0x7b, 0xdd, 0x76, - 0xfa, 0xad, 0xd7, 0xbb, 0x3b, 0x06, 0x14, 0xb1, 0x04, 0xf7, 0x8e, 0x4b, 0x66, 0x6b, 0xfb, 0xfb, - 0x97, 0xcb, 0xda, 0x8f, 0x2f, 0x97, 0xb5, 0x5f, 0x5e, 0x2e, 0x6b, 0xef, 0xdc, 0x4a, 0xfc, 0x2d, - 0x75, 0xbd, 0x23, 0xde, 0xc2, 0x82, 0x5a, 0x36, 0xae, 0xf1, 0x60, 0x54, 0x39, 0xf9, 0x57, 0xf2, - 0x1f, 0x44, 0x34, 0x6b, 0xa3, 0x52, 0x7e, 0xe3, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x64, - 0x78, 0xb7, 0xab, 0x15, 0x00, 0x00, + // 1605 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xbd, 0x6f, 0x1b, 0xc7, + 0x12, 0xf7, 0x89, 0xa4, 0x3e, 0x86, 0xfa, 0x5c, 0x49, 0x36, 0xdf, 0xc9, 0x92, 0xe8, 0x93, 0x25, + 0xd3, 0x90, 0x4d, 0x5a, 0xf2, 0xc7, 0x7b, 0xf0, 0xc3, 0x83, 0x9f, 0x25, 0xf8, 0x59, 0x7e, 0x31, + 0x02, 0xe5, 0x64, 0xa4, 0x48, 0x43, 0x1c, 0x8f, 0x2b, 0x72, 0xad, 0xe3, 0xed, 0x99, 0xbb, 0x14, + 0x2c, 0x75, 0x49, 0x11, 0x20, 0x75, 0x80, 0xa4, 0x4b, 0x52, 0x05, 0x30, 0x82, 0x14, 0x69, 0xd2, + 0x18, 0x48, 0x91, 0x2a, 0x4d, 0x82, 0x00, 0x01, 0x52, 0x1a, 0x81, 0x91, 0x7f, 0x20, 0xfe, 0x07, + 0x12, 0xdc, 0xee, 0xde, 0x07, 0x29, 0x1e, 0x49,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, 0xd2, 0x7e, 0x7b, 0xb9, 0xa4, 0xbd, 0x77, 0x33, 0xf6, 0xeb, 0xd4, + 0x6b, 0x1e, 0xb1, 0x86, 0xc5, 0x89, 0xed, 0x58, 0x15, 0x26, 0x47, 0xa5, 0x93, 0xbf, 0x28, 0xff, + 0x8d, 0x79, 0xbd, 0x32, 0x2c, 0xe4, 0xd7, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x35, 0x6f, 0xbd, + 0x16, 0xb8, 0x15, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3434,10 +3434,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 @@ -3451,10 +3451,10 @@ 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 { dAtA[i] = 0x18 @@ -4179,15 +4179,15 @@ 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)) @@ -6889,7 +6889,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 { @@ -6924,8 +6924,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 @@ -6943,16 +6943,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 @@ -6962,7 +6962,7 @@ 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 } diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index a8a0dffa1f53..07cf364c9ea5 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 crosslink committee 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 @@ -375,15 +375,15 @@ 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. diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index 83cd309da8db..180b15685ef0 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))) @@ -78,6 +79,7 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ aggregationBitfield := bitfield.NewBitlist(uint64(len(assignment.Committee))) aggregationBitfield.SetBitAt(indexInCommittee, true) + log = log.WithField("bitfield", fmt.Sprintf("%#x", aggregationBitfield)) domain, err := v.validatorClient.DomainData(ctx, &pb.DomainRequest{Epoch: data.Target.Epoch, Domain: params.BeaconConfig().DomainBeaconAttester}) if err != nil { diff --git a/validator/client/validator_attest_test.go b/validator/client/validator_attest_test.go index 10ade4a1292b..90b8125d9508 100644 --- a/validator/client/validator_attest_test.go +++ b/validator/client/validator_attest_test.go @@ -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 @@ -105,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 @@ -213,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( @@ -258,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 diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 56876f78ed3b..3541b8659c78 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -391,9 +391,9 @@ func TestUpdateAssignments_DoesNothingWhenNotEpochStartAndAlreadyExistingAssignm assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Committee: []uint64{}, - AttesterSlot: 10, - Shard: 20, + Committee: []uint64{}, + AttesterSlot: 10, + CommitteeIndex: 20, }, }, }, @@ -419,7 +419,7 @@ func TestUpdateAssignments_ReturnsError(t *testing.T) { assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Shard: 1, + CommitteeIndex: 1, }, }, }, @@ -449,11 +449,11 @@ func TestUpdateAssignments_OK(t *testing.T) { resp := &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - AttesterSlot: params.BeaconConfig().SlotsPerEpoch, - Shard: 100, - Committee: []uint64{0, 1, 2, 3}, - PublicKey: []byte("testPubKey_1"), - ProposerSlot: params.BeaconConfig().SlotsPerEpoch + 1, + AttesterSlot: params.BeaconConfig().SlotsPerEpoch, + CommitteeIndex: 100, + Committee: []uint64{0, 1, 2, 3}, + PublicKey: []byte("testPubKey_1"), + ProposerSlot: params.BeaconConfig().SlotsPerEpoch + 1, }, }, } @@ -475,8 +475,8 @@ func TestUpdateAssignments_OK(t *testing.T) { 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].Shard != resp.ValidatorAssignment[0].Shard { - t.Errorf("Unexpected validator assignments. want=%v got=%v", resp.ValidatorAssignment[0].Shard, v.assignments.ValidatorAssignment[0].Shard) + 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) } } @@ -486,25 +486,25 @@ func TestRolesAt_OK(t *testing.T) { assignments: &pb.AssignmentResponse{ ValidatorAssignment: []*pb.AssignmentResponse_ValidatorAssignment{ { - Shard: 1, - AttesterSlot: 1, - PublicKey: []byte{0x01}, + CommitteeIndex: 1, + AttesterSlot: 1, + PublicKey: []byte{0x01}, }, { - Shard: 2, - ProposerSlot: 1, - PublicKey: []byte{0x02}, + CommitteeIndex: 2, + ProposerSlot: 1, + PublicKey: []byte{0x02}, }, { - Shard: 1, - AttesterSlot: 2, - PublicKey: []byte{0x03}, + CommitteeIndex: 1, + AttesterSlot: 2, + PublicKey: []byte{0x03}, }, { - Shard: 2, - AttesterSlot: 1, - ProposerSlot: 1, - PublicKey: []byte{0x04}, + CommitteeIndex: 2, + AttesterSlot: 1, + ProposerSlot: 1, + PublicKey: []byte{0x04}, }, }, }, From 03f2cb053478746a9f02bf5eadd5b311def10362 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Tue, 5 Nov 2019 17:52:16 -0800 Subject: [PATCH 19/82] Conflict --- README.md | 26 +- WORKSPACE | 4 +- beacon-chain/blockchain/chain_info.go | 6 + beacon-chain/blockchain/service_test.go | 23 +- beacon-chain/blockchain/testing/BUILD.bazel | 4 + beacon-chain/blockchain/testing/mock.go | 27 ++ beacon-chain/cache/active_count.go | 4 + beacon-chain/cache/active_indices.go | 4 + beacon-chain/cache/committee.go | 24 ++ beacon-chain/cache/feature_flag_test.go | 8 +- beacon-chain/cache/shuffled_indices.go | 7 + beacon-chain/cache/shuffled_indices_test.go | 8 + .../core/epoch/precompute/attestation.go | 13 +- .../core/epoch/precompute/attestation_test.go | 17 +- beacon-chain/core/helpers/BUILD.bazel | 2 + beacon-chain/core/helpers/committee_test.go | 13 +- beacon-chain/core/state/BUILD.bazel | 7 + beacon-chain/core/state/interop/BUILD.bazel | 5 +- beacon-chain/core/state/skip_slot_cache.go | 24 ++ .../core/state/skip_slot_cache_test.go | 54 +++ beacon-chain/core/state/transition.go | 41 +++ beacon-chain/db/db.go | 1 + beacon-chain/db/filters/BUILD.bazel | 5 +- beacon-chain/db/kv/BUILD.bazel | 2 + beacon-chain/db/kv/checkpoint.go | 6 +- beacon-chain/db/kv/checkpoint_test.go | 23 +- beacon-chain/db/kv/finalized_block_roots.go | 93 ++++++ .../db/kv/finalized_block_roots_test.go | 86 +++++ beacon-chain/db/kv/kv.go | 1 + beacon-chain/db/kv/schema.go | 1 + beacon-chain/db/kv/state_test.go | 20 +- beacon-chain/main.go | 1 + beacon-chain/node/BUILD.bazel | 2 - beacon-chain/node/clear_db.go | 47 +-- beacon-chain/node/node.go | 31 +- beacon-chain/p2p/handshake.go | 21 +- beacon-chain/powchain/BUILD.bazel | 2 + beacon-chain/powchain/block_reader_test.go | 44 ++- beacon-chain/powchain/deposit_test.go | 49 +-- beacon-chain/powchain/log_processing.go | 116 +++---- beacon-chain/powchain/log_processing_test.go | 76 +++-- beacon-chain/powchain/service.go | 128 +++++-- beacon-chain/powchain/service_test.go | 77 +++-- beacon-chain/powchain/testing/faulty_mock.go | 5 + beacon-chain/powchain/testing/mock.go | 5 + beacon-chain/rpc/attester_server.go | 3 +- beacon-chain/rpc/attester_server_test.go | 2 + beacon-chain/rpc/beacon_chain_server.go | 34 +- beacon-chain/rpc/beacon_chain_server_test.go | 180 ++++++++-- beacon-chain/rpc/proposer_server.go | 56 ++-- beacon-chain/rpc/service.go | 1 + beacon-chain/rpc/service_test.go | 4 + beacon-chain/rpc/validator_server.go | 41 ++- beacon-chain/rpc/validator_server_test.go | 13 +- beacon-chain/sync/initial-sync/BUILD.bazel | 5 + beacon-chain/sync/initial-sync/round_robin.go | 52 ++- .../sync/initial-sync/round_robin_test.go | 95 +++++- beacon-chain/sync/initial-sync/service.go | 2 + beacon-chain/sync/peerstatus/BUILD.bazel | 9 +- beacon-chain/sync/peerstatus/peer_statuses.go | 5 +- .../sync/peerstatus/peer_statuses_test.go | 26 ++ .../sync/rpc_beacon_blocks_by_range.go | 49 ++- beacon-chain/sync/rpc_status.go | 5 +- beacon-chain/sync/rpc_status_test.go | 16 + beacon-chain/sync/service.go | 1 + .../sync/validate_beacon_attestation.go | 16 +- beacon-chain/usage.go | 1 + proto/beacon/db/BUILD.bazel | 5 +- .../db/finalized_block_root_container.pb.go | 7 + .../db/finalized_block_root_container.proto | 10 + proto/eth/v1alpha1/beacon_chain.pb.go | 314 +++++++++++++++++- proto/eth/v1alpha1/beacon_chain.proto | 21 +- proto/eth/v1alpha1/validator.pb.go | 128 +++---- proto/eth/v1alpha1/validator.proto | 8 +- scripts/interop_start.sh | 8 +- scripts/start-beacon-chain.sh | 2 +- shared/bls/BUILD.bazel | 1 - shared/bls/bls.go | 7 +- shared/cmd/flags.go | 9 +- shared/featureconfig/BUILD.bazel | 5 +- shared/featureconfig/config.go | 58 +++- shared/featureconfig/config_test.go | 12 +- shared/featureconfig/flags.go | 71 +++- shared/featureconfig/flags_test.go | 19 ++ shared/interop/BUILD.bazel | 4 + shared/interop/generate_deposits_test.go | 72 ++++ shared/interop/generate_genesis_state.go | 58 +++- shared/interop/generate_keys.go | 31 ++ shared/mputil/BUILD.bazel | 18 + shared/mputil/benchmark_test.go | 57 ++++ shared/mputil/scatter.go | 77 +++++ shared/mputil/scatter_test.go | 118 +++++++ shared/params/config.go | 4 +- shared/testutil/block.go | 26 +- shared/testutil/block_test.go | 16 +- shared/traceutil/errors.go | 3 + .../traceutil/recovery_interceptor_option.go | 4 +- shared/version/version.go | 16 + slasher/BUILD.bazel | 52 ++- slasher/README.md | 13 + slasher/db/BUILD.bazel | 2 + slasher/db/db.go | 1 + slasher/db/indexed_attestations.go | 47 +-- slasher/db/indexed_attestations_test.go | 48 ++- slasher/db/schema.go | 6 +- slasher/db/validator_id_pubkey.go | 44 +++ slasher/db/validator_id_pubkey_test.go | 105 ++++++ slasher/flags/BUILD.bazel | 9 + slasher/flags/flags.go | 24 ++ slasher/main.go | 124 +++++++ slasher/rpc/server.go | 4 +- slasher/rpc/server_test.go | 4 - slasher/server.go | 66 ---- slasher/server_test.go | 159 --------- slasher/service/BUILD.bazel | 37 +++ slasher/{ => service}/service.go | 117 ++++++- slasher/{ => service}/service_test.go | 45 ++- slasher/usage.go | 98 ++++++ slasher/usage_test.go | 41 +++ tools/extractor/BUILD.bazel | 20 ++ tools/extractor/main.go | 50 +++ validator/client/BUILD.bazel | 2 + validator/client/runner.go | 2 +- validator/client/service.go | 3 + validator/client/validator.go | 4 + validator/client/validator_attest.go | 2 +- 126 files changed, 3240 insertions(+), 857 deletions(-) create mode 100644 beacon-chain/core/state/skip_slot_cache.go create mode 100644 beacon-chain/core/state/skip_slot_cache_test.go create mode 100644 beacon-chain/db/kv/finalized_block_roots.go create mode 100644 beacon-chain/db/kv/finalized_block_roots_test.go create mode 100644 beacon-chain/sync/peerstatus/peer_statuses_test.go create mode 100644 proto/beacon/db/finalized_block_root_container.proto create mode 100644 shared/featureconfig/flags_test.go create mode 100644 shared/interop/generate_deposits_test.go create mode 100644 shared/mputil/BUILD.bazel create mode 100644 shared/mputil/benchmark_test.go create mode 100644 shared/mputil/scatter.go create mode 100644 shared/mputil/scatter_test.go create mode 100644 slasher/README.md create mode 100644 slasher/db/validator_id_pubkey.go create mode 100644 slasher/db/validator_id_pubkey_test.go create mode 100644 slasher/flags/BUILD.bazel create mode 100644 slasher/flags/flags.go create mode 100644 slasher/main.go delete mode 100644 slasher/server.go delete mode 100644 slasher/server_test.go create mode 100644 slasher/service/BUILD.bazel rename slasher/{ => service}/service.go (56%) rename slasher/{ => service}/service_test.go (68%) create mode 100644 slasher/usage.go create mode 100644 slasher/usage_test.go create mode 100644 tools/extractor/BUILD.bazel create mode 100644 tools/extractor/main.go diff --git a/README.md b/README.md index 417da1498448..0be00e71ba38 100644 --- a/README.md +++ b/README.md @@ -98,12 +98,26 @@ To understand the role that both the beacon node and validator play in Prysm, se To start your beacon node, issue the following command: ``` -docker run -v $HOME/prysm-data:/data -p 4000:4000 --name beacon-node \ +docker run -v $HOME/prysm-data:/data -p 4000:4000 \ + --name beacon-node \ gcr.io/prysmaticlabs/prysm/beacon-chain:latest \ + --no-genesis-delay \ --datadir=/data ``` -The beacon node can be halted by either using `Ctrl+c` or with the command: +(Optional) If you want to enable gRPC, then run this command instead of the one above: + +``` +docker run -v $HOME/prysm-data:/data -p 4000:4000 -p 7000:7000 \ + --name beacon-node \ + gcr.io/prysmaticlabs/prysm/beacon-chain:latest \ + --datadir=/data \ + --no-genesis-delay \ + --grpc-gateway-port=7000 +``` + +You can stop the beacon node using `Ctrl+c` or with the following command: +======= ``` docker stop beacon-node @@ -121,13 +135,13 @@ To delete a corrupted container, issue the command: docker rm beacon-node ``` -To recreate a deleted container and refresh the chain database, issue the start command with an additional `--clear-db` parameter: +To recreate a deleted container and refresh the chain database, issue the start command with an additional `--force-clear-db` parameter: ``` docker run -it -v $HOME/prysm-data:/data -p 4000:4000 --name beacon-node \ gcr.io/prysmaticlabs/prysm/beacon-chain:latest \ --datadir=/data \ - --clear-db + --force-clear-db ``` **Docker on Windows:** @@ -142,14 +156,14 @@ docker run -it -v $HOME/prysm-data:/data -p 4000:4000 --name beacon-node \ 4) To run the beacon node, issue the command: ``` -docker run -it -v c:/tmp/prysm-data:/data -p 4000:4000 gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data --clear-db +docker run -it -v c:/tmp/prysm-data:/data -p 4000:4000 gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data ``` ### Running via Bazel 1) To start your Beacon Node with Bazel, issue the command: ``` -bazel run //beacon-chain -- --clear-db --datadir=/tmp/prysm-data +bazel run //beacon-chain -- --datadir=/tmp/prysm-data ``` This will sync up the Beacon Node with the latest head block in the network. Note that the beacon node must be **completely synced** before attempting to initialise a validator client, otherwise the validator will not be able to complete the deposit and funds will be lost. diff --git a/WORKSPACE b/WORKSPACE index db3521c86b20..6e3a2cccc65c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1013,7 +1013,7 @@ go_repository( go_repository( name = "grpc_ecosystem_grpc_gateway", - commit = "e652ba06e9067ef41c199af59b9c6c67724850d4", + commit = "da7a886035e25b2f274f89b6f3c64bf70a9f6780", importpath = "github.com/grpc-ecosystem/grpc-gateway", ) @@ -1201,7 +1201,7 @@ go_repository( go_repository( name = "com_github_prysmaticlabs_ethereumapis", - commit = "b4ca5785e074dd8fed39f18a61aae0318b57b4b0", + commit = "1205871db17ccc2fb824fc6dfa40d01c48fb6a7e", importpath = "github.com/prysmaticlabs/ethereumapis", ) diff --git a/beacon-chain/blockchain/chain_info.go b/beacon-chain/blockchain/chain_info.go index 908b8bd40d3d..036ea9880ba5 100644 --- a/beacon-chain/blockchain/chain_info.go +++ b/beacon-chain/blockchain/chain_info.go @@ -110,5 +110,11 @@ func (s *Service) GenesisTime() time.Time { // CurrentFork retrieves the latest fork information of the beacon chain. func (s *Service) CurrentFork() *pb.Fork { + if s.headState == nil { + return &pb.Fork{ + PreviousVersion: params.BeaconConfig().GenesisForkVersion, + CurrentVersion: params.BeaconConfig().GenesisForkVersion, + } + } return proto.Clone(s.headState.Fork).(*pb.Fork) } diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index dd6b1720aa66..f8c95771a680 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -199,13 +199,9 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service { ctx := context.Background() var web3Service *powchain.Service var err error - client := &mockClient{} web3Service, err = powchain.NewService(ctx, &powchain.Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: common.Address{}, - Reader: client, - Client: client, - Logger: client, }) if err != nil { t.Fatalf("unable to set up web3 service: %v", err) @@ -354,13 +350,28 @@ func TestChainService_InitializeChainInfo(t *testing.T) { defer testDB.TeardownDB(t, db) ctx := context.Background() + genesis := b.NewGenesisBlock([]byte{}) + genesisRoot, err := ssz.SigningRoot(genesis) + if err != nil { + t.Fatal(err) + } + if err := db.SaveGenesisBlockRoot(ctx, genesisRoot); err != nil { + t.Fatal(err) + } + if err := db.SaveBlock(ctx, genesis); err != nil { + t.Fatal(err) + } + finalizedSlot := params.BeaconConfig().SlotsPerEpoch*2 + 1 - headBlock := ðpb.BeaconBlock{Slot: finalizedSlot} + headBlock := ðpb.BeaconBlock{Slot: finalizedSlot, ParentRoot: genesisRoot[:]} headState := &pb.BeaconState{Slot: finalizedSlot} headRoot, _ := ssz.SigningRoot(headBlock) if err := db.SaveState(ctx, headState, headRoot); err != nil { t.Fatal(err) } + if err := db.SaveBlock(ctx, headBlock); err != nil { + t.Fatal(err) + } if err := db.SaveFinalizedCheckpoint(ctx, ðpb.Checkpoint{ Epoch: helpers.SlotToEpoch(finalizedSlot), Root: headRoot[:], diff --git a/beacon-chain/blockchain/testing/BUILD.bazel b/beacon-chain/blockchain/testing/BUILD.bazel index e46c6ae3ebb4..e880ef3b1c4d 100644 --- a/beacon-chain/blockchain/testing/BUILD.bazel +++ b/beacon-chain/blockchain/testing/BUILD.bazel @@ -7,8 +7,12 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//beacon-chain/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/event:go_default_library", + "@com_github_pkg_errors//:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", ], ) diff --git a/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index 61588435d5f9..d4c1b6a63ee9 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -1,12 +1,17 @@ package testing import ( + "bytes" "context" "time" + "github.com/pkg/errors" + "github.com/prysmaticlabs/go-ssz" + "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/event" + "github.com/sirupsen/logrus" ) // ChainService defines the mock interface for testing @@ -18,6 +23,8 @@ type ChainService struct { StateFeed *event.Feed BlocksReceived []*ethpb.BeaconBlock Genesis time.Time + Fork *pb.Fork + DB db.Database } // ReceiveBlock mocks ReceiveBlock method in chain service. @@ -40,8 +47,23 @@ func (ms *ChainService) ReceiveBlockNoPubsubForkchoice(ctx context.Context, bloc if ms.State == nil { ms.State = &pb.BeaconState{} } + if !bytes.Equal(ms.Root, block.ParentRoot) { + return errors.Errorf("wanted %#x but got %#x", ms.Root, block.ParentRoot) + } ms.State.Slot = block.Slot ms.BlocksReceived = append(ms.BlocksReceived, block) + signingRoot, err := ssz.SigningRoot(block) + if err != nil { + return err + } + if ms.DB != nil { + if err := ms.DB.SaveBlock(ctx, block); err != nil { + return err + } + logrus.Infof("Saved block with root: %#x at slot %d", signingRoot, block.Slot) + } + ms.Root = signingRoot[:] + ms.Block = block return nil } @@ -67,6 +89,11 @@ func (ms *ChainService) HeadState() *pb.BeaconState { return ms.State } +// CurrentFork mocks HeadState method in chain service. +func (ms *ChainService) CurrentFork() *pb.Fork { + return ms.Fork +} + // FinalizedCheckpt mocks FinalizedCheckpt method in chain service. func (ms *ChainService) FinalizedCheckpt() *ethpb.Checkpoint { return ms.FinalizedCheckPoint diff --git a/beacon-chain/cache/active_count.go b/beacon-chain/cache/active_count.go index d11e0761fc96..cda0e83e7113 100644 --- a/beacon-chain/cache/active_count.go +++ b/beacon-chain/cache/active_count.go @@ -7,6 +7,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" "k8s.io/client-go/tools/cache" ) @@ -62,6 +63,9 @@ func NewActiveCountCache() *ActiveCountCache { // ActiveCountInEpoch fetches ActiveCountByEpoch by epoch. Returns true with a // reference to the ActiveCountInEpoch info, if exists. Otherwise returns false, nil. func (c *ActiveCountCache) ActiveCountInEpoch(epoch uint64) (uint64, error) { + if !featureconfig.Get().EnableActiveCountCache { + return params.BeaconConfig().FarFutureEpoch, nil + } c.lock.RLock() defer c.lock.RUnlock() obj, exists, err := c.activeCountCache.GetByKey(strconv.Itoa(int(epoch))) diff --git a/beacon-chain/cache/active_indices.go b/beacon-chain/cache/active_indices.go index 4c62b97e0b62..6fe18be717b7 100644 --- a/beacon-chain/cache/active_indices.go +++ b/beacon-chain/cache/active_indices.go @@ -7,6 +7,7 @@ import ( "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" ) @@ -61,6 +62,9 @@ func NewActiveIndicesCache() *ActiveIndicesCache { // ActiveIndicesInEpoch fetches ActiveIndicesByEpoch by epoch. Returns true with a // reference to the ActiveIndicesInEpoch info, if exists. Otherwise returns false, nil. func (c *ActiveIndicesCache) ActiveIndicesInEpoch(epoch uint64) ([]uint64, error) { + if !featureconfig.Get().EnableActiveIndicesCache { + return nil, nil + } c.lock.RLock() defer c.lock.RUnlock() obj, exists, err := c.activeIndicesCache.GetByKey(strconv.Itoa(int(epoch))) diff --git a/beacon-chain/cache/committee.go b/beacon-chain/cache/committee.go index 0a02f817d377..7c9d4059611e 100644 --- a/beacon-chain/cache/committee.go +++ b/beacon-chain/cache/committee.go @@ -7,6 +7,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/sliceutil" "k8s.io/client-go/tools/cache" ) @@ -66,6 +67,10 @@ 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, 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))) @@ -92,6 +97,9 @@ func (c *CommitteeCache) ShuffledIndices(epoch uint64, index uint64) ([]uint64, // AddCommitteeShuffledList adds Committee shuffled list object to the cache. T // his method also trims the least recently list if the cache size has ready the max cache size limit. func (c *CommitteeCache) AddCommitteeShuffledList(committee *Committee) error { + if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { + return nil + } c.lock.Lock() defer c.lock.Unlock() if err := c.CommitteeCache.AddIfNotPresent(committee); err != nil { @@ -103,6 +111,9 @@ func (c *CommitteeCache) AddCommitteeShuffledList(committee *Committee) error { // Epochs returns the epochs stored in the committee cache. These are the keys to the cache. func (c *CommitteeCache) Epochs() ([]uint64, error) { + if !featureconfig.Get().EnableShuffledIndexCache { + return nil, nil + } c.lock.RLock() defer c.lock.RUnlock() @@ -119,6 +130,9 @@ func (c *CommitteeCache) Epochs() ([]uint64, error) { // EpochInCache returns true if an input epoch is part of keys in cache. func (c *CommitteeCache) EpochInCache(wantedEpoch uint64) (bool, error) { + if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { + return false, nil + } c.lock.RLock() defer c.lock.RUnlock() @@ -136,6 +150,9 @@ func (c *CommitteeCache) EpochInCache(wantedEpoch uint64) (bool, error) { // CommitteeCount returns the total number of committees in a given epoch as stored in cache. func (c *CommitteeCache) CommitteeCount(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))) @@ -160,6 +177,9 @@ func (c *CommitteeCache) CommitteeCount(epoch uint64) (uint64, bool, error) { // 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))) @@ -184,6 +204,10 @@ func (c *CommitteeCache) StartShard(epoch uint64) (uint64, bool, error) { // ActiveIndices returns the active indices of a given epoch stored in cache. func (c *CommitteeCache) ActiveIndices(epoch 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))) diff --git a/beacon-chain/cache/feature_flag_test.go b/beacon-chain/cache/feature_flag_test.go index 36e9dcac996e..8d578bf99532 100644 --- a/beacon-chain/cache/feature_flag_test.go +++ b/beacon-chain/cache/feature_flag_test.go @@ -4,7 +4,11 @@ import "github.com/prysmaticlabs/prysm/shared/featureconfig" func init() { featureconfig.Init(&featureconfig.Flag{ - EnableAttestationCache: true, - EnableEth1DataVoteCache: true, + EnableAttestationCache: true, + EnableEth1DataVoteCache: true, + EnableShuffledIndexCache: true, + EnableCommitteeCache: true, + EnableActiveCountCache: true, + EnableActiveIndicesCache: true, }) } diff --git a/beacon-chain/cache/shuffled_indices.go b/beacon-chain/cache/shuffled_indices.go index c9ef6d443d6d..7fb531458ec1 100644 --- a/beacon-chain/cache/shuffled_indices.go +++ b/beacon-chain/cache/shuffled_indices.go @@ -7,6 +7,7 @@ import ( "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" ) @@ -62,6 +63,9 @@ func NewShuffledIndicesCache() *ShuffledIndicesCache { // 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)) @@ -88,6 +92,9 @@ func (c *ShuffledIndicesCache) IndicesByIndexSeed(index uint64, seed []byte) ([] // 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 { diff --git a/beacon-chain/cache/shuffled_indices_test.go b/beacon-chain/cache/shuffled_indices_test.go index 1d1f32273a90..da2b6fe72009 100644 --- a/beacon-chain/cache/shuffled_indices_test.go +++ b/beacon-chain/cache/shuffled_indices_test.go @@ -4,8 +4,16 @@ 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, diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index 350506fa658e..eb2348f0e713 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -129,6 +129,12 @@ func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *pb } if record.IsPrevEpochAttester { vp[i].IsPrevEpochAttester = true + // Update attestation inclusion info if inclusion slot is lower than before + if inclusionSlot < vp[i].InclusionSlot { + vp[i].InclusionSlot = aSlot + a.InclusionDelay + vp[i].InclusionDistance = a.InclusionDelay + vp[i].ProposerIndex = a.ProposerIndex + } } if record.IsPrevEpochTargetAttester { vp[i].IsPrevEpochTargetAttester = true @@ -136,13 +142,6 @@ func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *pb if record.IsPrevEpochHeadAttester { vp[i].IsPrevEpochHeadAttester = true } - - // Update attestation inclusion info if inclusion slot is lower than before - if inclusionSlot < vp[i].InclusionSlot { - vp[i].InclusionSlot = aSlot + a.InclusionDelay - vp[i].InclusionDistance = a.InclusionDelay - vp[i].ProposerIndex = a.ProposerIndex - } } return vp } diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index 43d250be2bb8..164c5c971614 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -14,7 +14,7 @@ import ( "github.com/prysmaticlabs/prysm/shared/testutil" ) -func TestUpdateValidator(t *testing.T) { +func TestUpdateValidator_Works(t *testing.T) { e := params.BeaconConfig().FarFutureEpoch vp := []*precompute.Validator{{}, {InclusionSlot: e}, {}, {InclusionSlot: e}, {}, {InclusionSlot: e}} record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true, @@ -33,6 +33,21 @@ func TestUpdateValidator(t *testing.T) { } } +func TestUpdateValidator_InclusionOnlyCountsPrevEpoch(t *testing.T) { + e := params.BeaconConfig().FarFutureEpoch + vp := []*precompute.Validator{{InclusionSlot: e}} + record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true} + a := &pb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} + + // Verify inclusion info doesnt get updated. + vp = precompute.UpdateValidator(vp, record, []uint64{0}, a, 100) + wanted := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true, InclusionSlot: e} + wantedVp := []*precompute.Validator{wanted} + if !reflect.DeepEqual(vp, wantedVp) { + t.Error("Incorrect attesting validator calculations") + } +} + func TestUpdateBalance(t *testing.T) { vp := []*precompute.Validator{ {IsCurrentEpochAttester: true, CurrentEpochEffectiveBalance: 100}, diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 17076597aa8d..e547a0bf18c4 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -18,6 +18,7 @@ go_library( "//beacon-chain:__subpackages__", "//shared/testutil:__pkg__", "//slasher:__subpackages__", + "//validator:__subpackages__", ], deps = [ "//beacon-chain/cache:go_default_library", @@ -58,6 +59,7 @@ go_test( "//proto/eth/v1alpha1:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", + "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index bd4b07fc26d8..d9db33c12f2a 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -75,6 +76,11 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { } 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 @@ -481,6 +487,11 @@ func TestShuffledIndices_ShuffleRightLength(t *testing.T) { } func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { + c := featureconfig.Get() + c.EnableShuffledIndexCache = true + featureconfig.Init(c) + defer featureconfig.Init(nil) + ClearAllCaches() validatorCount := int(params.BeaconConfig().MinGenesisActiveValidatorCount) @@ -514,7 +525,7 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { t.Fatal(err) } if len(indices) != int(params.BeaconConfig().TargetCommitteeSize) { - t.Error("Did not save correct indices lengths") + t.Errorf("Did not save correct indices lengths, got %d wanted %d", len(indices), params.BeaconConfig().TargetCommitteeSize) } } diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index b2d43608a892..39a5dddc0651 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -5,6 +5,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", srcs = [ + "skip_slot_cache.go", "state.go", "transition.go", ], @@ -29,7 +30,10 @@ go_library( "//shared/traceutil:go_default_library", "//shared/trieutil:go_default_library", "@com_github_gogo_protobuf//proto:go_default_library", + "@com_github_hashicorp_golang_lru//:go_default_library", "@com_github_pkg_errors//:go_default_library", + "@com_github_prometheus_client_golang//prometheus:go_default_library", + "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@io_opencensus_go//trace:go_default_library", ], @@ -39,6 +43,7 @@ go_test( name = "go_default_test", size = "small", srcs = [ + "skip_slot_cache_test.go", "state_test.go", "transition_test.go", ], @@ -49,10 +54,12 @@ go_test( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/bls:go_default_library", + "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/trieutil:go_default_library", + "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", diff --git a/beacon-chain/core/state/interop/BUILD.bazel b/beacon-chain/core/state/interop/BUILD.bazel index a403ff9e90b9..189fb9ed65b7 100644 --- a/beacon-chain/core/state/interop/BUILD.bazel +++ b/beacon-chain/core/state/interop/BUILD.bazel @@ -8,7 +8,10 @@ go_library( "write_state_to_disk.go", ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop", - visibility = ["//beacon-chain:__subpackages__"], + visibility = [ + "//beacon-chain:__subpackages__", + "//tools:__subpackages__", + ], deps = [ "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", diff --git a/beacon-chain/core/state/skip_slot_cache.go b/beacon-chain/core/state/skip_slot_cache.go new file mode 100644 index 000000000000..4382d7275ce9 --- /dev/null +++ b/beacon-chain/core/state/skip_slot_cache.go @@ -0,0 +1,24 @@ +package state + +import ( + lru "github.com/hashicorp/golang-lru" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" +) + +// skipSlotCache exists for the unlikely scenario that is a large gap between the head state and +// the current slot. If the beacon chain were ever to be stalled for several epochs, it may be +// difficult or impossible to compute the appropriate beacon state for assignments within a +// reasonable amount of time. +var skipSlotCache, _ = lru.New(8) + +var ( + skipSlotCacheHit = promauto.NewCounter(prometheus.CounterOpts{ + Name: "skip_slot_cache_hit", + Help: "The total number of cache hits on the skip slot cache.", + }) + skipSlotCacheMiss = promauto.NewCounter(prometheus.CounterOpts{ + Name: "skip_slot_cache_miss", + Help: "The total number of cache misses on the skip slot cache.", + }) +) diff --git a/beacon-chain/core/state/skip_slot_cache_test.go b/beacon-chain/core/state/skip_slot_cache_test.go new file mode 100644 index 000000000000..5b50690de6ed --- /dev/null +++ b/beacon-chain/core/state/skip_slot_cache_test.go @@ -0,0 +1,54 @@ +package state_test + +import ( + "context" + "testing" + "time" + + "github.com/gogo/protobuf/proto" + "github.com/prysmaticlabs/go-ssz" + "github.com/prysmaticlabs/prysm/beacon-chain/core/state" + pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/shared/featureconfig" + "github.com/prysmaticlabs/prysm/shared/params" + "github.com/prysmaticlabs/prysm/shared/testutil" +) + +func TestSkipSlotCache_OK(t *testing.T) { + deps, _, privs := testutil.SetupInitialDeposits(t, params.MinimalSpecConfig().MinGenesisActiveValidatorCount) + bState, err := state.GenesisBeaconState(deps, uint64(time.Now().Unix()), testutil.GenerateEth1Data(t, deps)) + if err != nil { + t.Fatalf("Could not generate genesis state: %v", err) + } + + originalState := proto.Clone(bState).(*pb.BeaconState) + + blkCfg := testutil.DefaultBlockGenConfig() + blkCfg.MaxAttestations = 1 + blkCfg.MaxDeposits = 0 + blkCfg.MaxVoluntaryExits = 0 + blkCfg.MaxProposerSlashings = 0 + blkCfg.MaxAttesterSlashings = 0 + + cfg := featureconfig.Get() + cfg.EnableSkipSlotsCache = true + featureconfig.Init(cfg) + + // First transition will be with an empty cache, so the cache becomes populated + // with the state + blk := testutil.GenerateFullBlock(t, bState, privs, blkCfg, originalState.Slot+10) + originalState, err = state.ExecuteStateTransition(context.Background(), originalState, blk) + if err != nil { + t.Fatalf("Could not run state transition: %v", err) + } + + bState, err = state.ExecuteStateTransition(context.Background(), bState, blk) + if err != nil { + t.Fatalf("Could not process state transition: %v", err) + } + + if !ssz.DeepEqual(originalState, bState) { + t.Fatal("Skipped slots cache leads to different states") + } + +} diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index cb5db4c69078..005473dc88b2 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -244,9 +244,42 @@ func ProcessSlots(ctx context.Context, state *pb.BeaconState, slot uint64) (*pb. traceutil.AnnotateError(span, err) return nil, err } + highestSlot := state.Slot + var root [32]byte + var writeToCache bool + var err error + + if featureconfig.Get().EnableSkipSlotsCache { + // Restart from cached value, if one exists. + root, err = ssz.HashTreeRoot(state) + if err != nil { + return nil, errors.Wrap(err, "could not HashTreeRoot(state)") + } + cached, ok := skipSlotCache.Get(root) + // if cache key does not exist, we write it to the cache. + writeToCache = !ok + if ok { + // do not write to cache if state with higher slot exists. + writeToCache = cached.(*pb.BeaconState).Slot <= slot + if cached.(*pb.BeaconState).Slot <= slot { + state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState) + highestSlot = state.Slot + skipSlotCacheHit.Inc() + } else { + skipSlotCacheMiss.Inc() + } + } + } + for state.Slot < slot { if ctx.Err() != nil { traceutil.AnnotateError(span, ctx.Err()) + if featureconfig.Get().EnableSkipSlotsCache { + // Cache last best value. + if highestSlot < state.Slot && writeToCache { + skipSlotCache.Add(root, proto.Clone(state).(*pb.BeaconState)) + } + } return nil, ctx.Err() } state, err := ProcessSlot(ctx, state) @@ -271,6 +304,14 @@ func ProcessSlots(ctx context.Context, state *pb.BeaconState, slot uint64) (*pb. } state.Slot++ } + + if featureconfig.Get().EnableSkipSlotsCache { + // Clone result state so that caches are not mutated. + if highestSlot < state.Slot && writeToCache { + skipSlotCache.Add(root, proto.Clone(state).(*pb.BeaconState)) + } + } + return state, nil } diff --git a/beacon-chain/db/db.go b/beacon-chain/db/db.go index 1a1010c61608..d00fce5ed978 100644 --- a/beacon-chain/db/db.go +++ b/beacon-chain/db/db.go @@ -39,6 +39,7 @@ type Database interface { SaveBlocks(ctx context.Context, blocks []*ethpb.BeaconBlock) error SaveHeadBlockRoot(ctx context.Context, blockRoot [32]byte) error SaveGenesisBlockRoot(ctx context.Context, blockRoot [32]byte) error + IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool // Validator related methods. ValidatorLatestVote(ctx context.Context, validatorIdx uint64) (*pb.ValidatorLatestVote, error) HasValidatorLatestVote(ctx context.Context, validatorIdx uint64) bool diff --git a/beacon-chain/db/filters/BUILD.bazel b/beacon-chain/db/filters/BUILD.bazel index 5d9c82420600..d638212d9b37 100644 --- a/beacon-chain/db/filters/BUILD.bazel +++ b/beacon-chain/db/filters/BUILD.bazel @@ -4,7 +4,10 @@ go_library( name = "go_default_library", srcs = ["filter.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/db/filters", - visibility = ["//beacon-chain:__subpackages__"], + visibility = [ + "//beacon-chain:__subpackages__", + "//tools:__subpackages__", + ], ) go_test( diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index b6d29c4a3ee6..e92552d92747 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "blocks.go", "checkpoint.go", "deposit_contract.go", + "finalized_block_roots.go", "kv.go", "operations.go", "schema.go", @@ -49,6 +50,7 @@ go_test( "blocks_test.go", "checkpoint_test.go", "deposit_contract_test.go", + "finalized_block_roots_test.go", "kv_test.go", "operations_test.go", "slashings_test.go", diff --git a/beacon-chain/db/kv/checkpoint.go b/beacon-chain/db/kv/checkpoint.go index 7ad56bf61326..06c0177ee33e 100644 --- a/beacon-chain/db/kv/checkpoint.go +++ b/beacon-chain/db/kv/checkpoint.go @@ -86,6 +86,10 @@ func (k *Store) SaveFinalizedCheckpoint(ctx context.Context, checkpoint *ethpb.C traceutil.AnnotateError(span, errMissingStateForFinalizedCheckpoint) return errMissingStateForFinalizedCheckpoint } - return bucket.Put(finalizedCheckpointKey, enc) + + if err := bucket.Put(finalizedCheckpointKey, enc); err != nil { + return err + } + return updateFinalizedBlockRoots(ctx, tx, checkpoint) }) } diff --git a/beacon-chain/db/kv/checkpoint_test.go b/beacon-chain/db/kv/checkpoint_test.go index 9ac583b7deb4..5b2d3f27fb85 100644 --- a/beacon-chain/db/kv/checkpoint_test.go +++ b/beacon-chain/db/kv/checkpoint_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/gogo/protobuf/proto" + "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/bytesutil" @@ -36,12 +37,32 @@ func TestStore_FinalizedCheckpoint_CanSaveRetrieve(t *testing.T) { db := setupDB(t) defer teardownDB(t, db) ctx := context.Background() - root := bytesutil.ToBytes32([]byte{'B'}) + + genesis := bytesutil.ToBytes32([]byte{'G', 'E', 'N', 'E', 'S', 'I', 'S'}) + if err := db.SaveGenesisBlockRoot(ctx, genesis); err != nil { + t.Fatal(err) + } + + blk := ðpb.BeaconBlock{ + ParentRoot: genesis[:], + Slot: 40, + } + + root, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + cp := ðpb.Checkpoint{ Epoch: 5, Root: root[:], } + // a valid chain is required to save finalized checkpoint. + if err := db.SaveBlock(ctx, blk); err != nil { + t.Fatal(err) + } + // a state is required to save checkpoint if err := db.SaveState(ctx, &pb.BeaconState{}, root); err != nil { t.Fatal(err) diff --git a/beacon-chain/db/kv/finalized_block_roots.go b/beacon-chain/db/kv/finalized_block_roots.go new file mode 100644 index 000000000000..72726dec6391 --- /dev/null +++ b/beacon-chain/db/kv/finalized_block_roots.go @@ -0,0 +1,93 @@ +package kv + +import ( + "bytes" + "context" + "fmt" + + "github.com/boltdb/bolt" + "github.com/gogo/protobuf/proto" + "github.com/pkg/errors" + dbpb "github.com/prysmaticlabs/prysm/proto/beacon/db" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/traceutil" + "go.opencensus.io/trace" +) + +var errMissingParentBlockInDatabase = errors.New("missing block in database") + +func updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, checkpoint *ethpb.Checkpoint) error { + ctx, span := trace.StartSpan(ctx, "BeaconDB.updateFinalizedBlockRoots") + defer span.End() + + bkt := tx.Bucket(finalizedBlockRootsIndexBucket) + blocks := tx.Bucket(blocksBucket) + + root := checkpoint.Root + var previousRoot []byte + genesisRoot := blocks.Get(genesisBlockRootKey) + + // Walk up the ancestry chain until we reach a block root present in the finalized block roots + // index bucket or genesis block root. + for { + if bytes.Equal(root, genesisRoot) { + return nil + } + + enc := blocks.Get(root) + if enc == nil { + err := fmt.Errorf("missing block in database: block root=%#x", root) + traceutil.AnnotateError(span, err) + return err + } + block := ðpb.BeaconBlock{} + if err := proto.Unmarshal(enc, block); err != nil { + traceutil.AnnotateError(span, err) + return err + } + + container := &dbpb.FinalizedBlockRootContainer{ + ParentRoot: block.ParentRoot, + ChildRoot: previousRoot, + } + + enc, err := proto.Marshal(container) + if err != nil { + traceutil.AnnotateError(span, err) + return err + } + if err := bkt.Put(root, enc); err != nil { + traceutil.AnnotateError(span, err) + return err + } + if parentBytes := bkt.Get(block.ParentRoot); parentBytes != nil { + parent := &dbpb.FinalizedBlockRootContainer{} + if err := proto.Unmarshal(parentBytes, parent); err != nil { + traceutil.AnnotateError(span, err) + return err + } + parent.ChildRoot = root + enc, err := proto.Marshal(parent) + if err != nil { + traceutil.AnnotateError(span, err) + return err + } + return bkt.Put(block.ParentRoot, enc) + } + previousRoot = root + root = block.ParentRoot + } +} + +// IsFinalizedBlock returns true if the block root is present in the finalized block root index. +func (kv *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool { + ctx, span := trace.StartSpan(ctx, "BeaconDB.IsFinalizedBlock") + defer span.End() + + var exists bool + kv.db.View(func(tx *bolt.Tx) error { + exists = tx.Bucket(finalizedBlockRootsIndexBucket).Get(blockRoot[:]) != nil + return nil + }) + return exists +} diff --git a/beacon-chain/db/kv/finalized_block_roots_test.go b/beacon-chain/db/kv/finalized_block_roots_test.go new file mode 100644 index 000000000000..5b2b804e8b60 --- /dev/null +++ b/beacon-chain/db/kv/finalized_block_roots_test.go @@ -0,0 +1,86 @@ +package kv + +import ( + "context" + "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/bytesutil" +) + +var genesisBlockRoot = bytesutil.ToBytes32([]byte{'G', 'E', 'N', 'E', 'S', 'I', 'S'}) + +func TestStore_IsFinalizedBlock(t *testing.T) { + db := setupDB(t) + defer teardownDB(t, db) + ctx := context.Background() + + if err := db.SaveGenesisBlockRoot(ctx, genesisBlockRoot); err != nil { + t.Fatal(err) + } + + blks := makeBlocks(t, 128) + if err := db.SaveBlocks(ctx, blks); err != nil { + t.Fatal(err) + } + + root, err := ssz.SigningRoot(blks[64]) + if err != nil { + t.Fatal(err) + } + + cp := ðpb.Checkpoint{ + Epoch: 1, + Root: root[:], + } + + // a state is required to save checkpoint + if err := db.SaveState(ctx, &pb.BeaconState{}, root); err != nil { + t.Fatal(err) + } + + if err := db.SaveFinalizedCheckpoint(ctx, cp); err != nil { + t.Fatal(err) + } + + // All blocks up to 64 should be in the finalized index. + for i := 0; i <= 64; i++ { + root, err := ssz.SigningRoot(blks[i]) + if err != nil { + t.Fatal(err) + } + if !db.IsFinalizedBlock(ctx, root) { + t.Errorf("Block at index %d was not considered finalized in the index", i) + } + } + for i := 65; i < len(blks); i++ { + root, err := ssz.SigningRoot(blks[i]) + if err != nil { + t.Fatal(err) + } + if db.IsFinalizedBlock(ctx, root) { + t.Errorf("Block at index %d was considered finalized in the index, but should not have", i) + } + } +} + +func makeBlocks(t *testing.T, n int) []*ethpb.BeaconBlock { + previousRoot := genesisBlockRoot + blocks := make([]*ethpb.BeaconBlock, n) + for i := 0; i < n; i++ { + parentRoot := make([]byte, 32) + copy(parentRoot, previousRoot[:]) + blocks[i] = ðpb.BeaconBlock{ + Slot: uint64(i + 1), + ParentRoot: parentRoot, + } + var err error + previousRoot, err = ssz.SigningRoot(blocks[i]) + if err != nil { + t.Fatal(err) + } + } + return blocks +} diff --git a/beacon-chain/db/kv/kv.go b/beacon-chain/db/kv/kv.go index 26e74e5b9a16..fa6ccafa973b 100644 --- a/beacon-chain/db/kv/kv.go +++ b/beacon-chain/db/kv/kv.go @@ -79,6 +79,7 @@ func NewKVStore(dirPath string) (*Store, error) { attestationTargetEpochIndicesBucket, blockSlotIndicesBucket, blockParentRootIndicesBucket, + finalizedBlockRootsIndexBucket, ) }); err != nil { return nil, err diff --git a/beacon-chain/db/kv/schema.go b/beacon-chain/db/kv/schema.go index 92b0e598d404..377a07cad027 100644 --- a/beacon-chain/db/kv/schema.go +++ b/beacon-chain/db/kv/schema.go @@ -29,6 +29,7 @@ var ( attestationSourceEpochIndicesBucket = []byte("attestation-source-epoch-indices") attestationTargetRootIndicesBucket = []byte("attestation-target-root-indices") attestationTargetEpochIndicesBucket = []byte("attestation-target-epoch-indices") + finalizedBlockRootsIndexBucket = []byte("finalized-block-roots-index") // Specific item keys. headBlockRootKey = []byte("head-root") diff --git a/beacon-chain/db/kv/state_test.go b/beacon-chain/db/kv/state_test.go index 9d4598e07270..61d33490ec5a 100644 --- a/beacon-chain/db/kv/state_test.go +++ b/beacon-chain/db/kv/state_test.go @@ -8,6 +8,7 @@ import ( "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/bytesutil" ) func TestState_CanSaveRetrieve(t *testing.T) { @@ -187,7 +188,24 @@ func TestStore_DeleteFinalizedState(t *testing.T) { defer teardownDB(t, db) ctx := context.Background() - finalizedBlockRoot := [32]byte{'A'} + genesis := bytesutil.ToBytes32([]byte{'G', 'E', 'N', 'E', 'S', 'I', 'S'}) + if err := db.SaveGenesisBlockRoot(ctx, genesis); err != nil { + t.Fatal(err) + } + + blk := ðpb.BeaconBlock{ + ParentRoot: genesis[:], + Slot: 100, + } + if err := db.SaveBlock(ctx, blk); err != nil { + t.Fatal(err) + } + + finalizedBlockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + finalizedState := &pb.BeaconState{Slot: 100} if err := db.SaveState(ctx, finalizedState, finalizedBlockRoot); err != nil { t.Fatal(err) diff --git a/beacon-chain/main.go b/beacon-chain/main.go index 9d6342eaf108..57f0a13d659b 100644 --- a/beacon-chain/main.go +++ b/beacon-chain/main.go @@ -59,6 +59,7 @@ var appFlags = []cli.Flag{ cmd.MonitoringPortFlag, cmd.DisableMonitoringFlag, cmd.ClearDB, + cmd.ForceClearDB, cmd.LogFormat, cmd.MaxGoroutines, debug.PProfFlag, diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index e46569508596..fd02cc647d10 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -33,8 +33,6 @@ go_library( "//shared/tracing:go_default_library", "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", - "@com_github_ethereum_go_ethereum//ethclient:go_default_library", - "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli//:go_default_library", diff --git a/beacon-chain/node/clear_db.go b/beacon-chain/node/clear_db.go index 49f4b3eb9006..5fe9fdea2616 100644 --- a/beacon-chain/node/clear_db.go +++ b/beacon-chain/node/clear_db.go @@ -9,38 +9,41 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db" ) -func confirmDelete(d db.Database, path string) (db.Database, error) { +func confirmDelete(d db.Database, path string, force bool) (db.Database, error) { var clearDB bool var err error reader := bufio.NewReader(os.Stdin) + if force { + clearDB = true + } else { + log.Warn("This will delete your beacon chain data base stored in your data directory. " + + "Your database backups will not be removed - do you want to proceed? (Y/N)") - log.Warn("This will delete your beacon chain data base stored in your data directory. " + - "Your database backups will not be removed - do you want to proceed? (Y/N)") + for { + fmt.Print(">> ") - for { - fmt.Print(">> ") - - line, _, err := reader.ReadLine() - if err != nil { - return nil, err - } - trimmedLine := strings.TrimSpace(string(line)) - lineInput := strings.ToUpper(trimmedLine) - if lineInput != "Y" && lineInput != "N" { - log.Errorf("Invalid option of %s chosen, enter Y/N", line) - continue - } - if lineInput == "Y" { - log.Warn("Deleting beaconchain.db from data directory") - clearDB = true + line, _, err := reader.ReadLine() + if err != nil { + return nil, err + } + trimmedLine := strings.TrimSpace(string(line)) + lineInput := strings.ToUpper(trimmedLine) + if lineInput != "Y" && lineInput != "N" { + log.Errorf("Invalid option of %s chosen, enter Y/N", line) + continue + } + if lineInput == "Y" { + clearDB = true + break + } + log.Info("Not deleting chain database, the db will be initialized" + + " with the current data directory.") break } - log.Info("Not deleting chain database, the db will be initialized" + - " with the current data directory.") - break } if clearDB { + log.Warning("Removing database") if err := d.ClearDB(); err != nil { return nil, err } diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 46278844ee84..04f37c7113e0 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -15,8 +15,6 @@ import ( "syscall" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - gethRPC "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/archiver" "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" @@ -200,17 +198,19 @@ func (b *BeaconNode) Close() { func (b *BeaconNode) startDB(ctx *cli.Context) error { baseDir := ctx.GlobalString(cmd.DataDirFlag.Name) dbPath := path.Join(baseDir, beaconChainDBName) + clearDB := ctx.GlobalBool(cmd.ClearDB.Name) + forceClearDB := ctx.GlobalBool(cmd.ForceClearDB.Name) + d, err := db.NewDB(dbPath) if err != nil { return err } - if b.ctx.GlobalBool(cmd.ClearDB.Name) { - d, err = confirmDelete(d, dbPath) + if clearDB || forceClearDB { + d, err = confirmDelete(d, dbPath, forceClearDB) if err != nil { return err } } - log.WithField("database-path", dbPath).Info("Checking DB") b.db = d b.depositCache = depositcache.NewDepositCache() @@ -309,28 +309,11 @@ func (b *BeaconNode) registerPOWChainService(cliCtx *cli.Context) error { log.Fatalf("Invalid deposit contract address given: %s", depAddress) } - httpRPCClient, err := gethRPC.Dial(cliCtx.GlobalString(flags.HTTPWeb3ProviderFlag.Name)) - if err != nil { - log.Fatalf("Access to PoW chain is required for validator. Unable to connect to Geth node: %v", err) - } - httpClient := ethclient.NewClient(httpRPCClient) - - rpcClient, err := gethRPC.Dial(cliCtx.GlobalString(flags.Web3ProviderFlag.Name)) - if err != nil { - log.Fatalf("Access to PoW chain is required for validator. Unable to connect to Geth node: %v", err) - } - powClient := ethclient.NewClient(rpcClient) - ctx := context.Background() cfg := &powchain.Web3ServiceConfig{ - Endpoint: cliCtx.GlobalString(flags.Web3ProviderFlag.Name), + ETH1Endpoint: cliCtx.GlobalString(flags.Web3ProviderFlag.Name), + HTTPEndPoint: cliCtx.GlobalString(flags.HTTPWeb3ProviderFlag.Name), DepositContract: common.HexToAddress(depAddress), - Client: httpClient, - Reader: powClient, - Logger: powClient, - HTTPLogger: httpClient, - BlockFetcher: httpClient, - ContractBackend: httpClient, BeaconDB: b.db, DepositCache: b.depositCache, } diff --git a/beacon-chain/p2p/handshake.go b/beacon-chain/p2p/handshake.go index b5fa4c288aa3..78be07000b19 100644 --- a/beacon-chain/p2p/handshake.go +++ b/beacon-chain/p2p/handshake.go @@ -15,18 +15,19 @@ import ( func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error) { s.host.Network().Notify(&network.NotifyBundle{ ConnectedF: func(net network.Network, conn network.Conn) { - // Must be handled in a goroutine as this callback cannot be blocking. - go func() { - if peerstatus.IsBadPeer(conn.RemotePeer()) { - // Add Peer to gossipsub blacklist - s.pubsub.BlacklistPeer(conn.RemotePeer()) - log.WithField("peerID", conn.RemotePeer().Pretty()).Debug("Disconnecting with bad peer") - if err := s.Disconnect(conn.RemotePeer()); err != nil { - log.WithError(err).Errorf("Unable to close peer %s", conn.RemotePeer()) - return - } + if peerstatus.IsBadPeer(conn.RemotePeer()) { + // Add Peer to gossipsub blacklist + s.pubsub.BlacklistPeer(conn.RemotePeer()) + log.WithField("peerID", conn.RemotePeer().Pretty()).Trace("Disconnecting with bad peer") + if err := s.Disconnect(conn.RemotePeer()); err != nil { + log.WithError(err).Errorf("Unable to close peer %s", conn.RemotePeer()) return } + return + } + + // Must be handled in a goroutine as this callback cannot be blocking. + go func() { ctx := context.Background() log := log.WithField("peer", conn.RemotePeer()) if conn.Stat().Direction == network.DirInbound { diff --git a/beacon-chain/powchain/BUILD.bazel b/beacon-chain/powchain/BUILD.bazel index 2c031ca37bad..519ef0ecebbd 100644 --- a/beacon-chain/powchain/BUILD.bazel +++ b/beacon-chain/powchain/BUILD.bazel @@ -28,6 +28,8 @@ go_library( "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//core/types:go_default_library", + "@com_github_ethereum_go_ethereum//ethclient:go_default_library", + "@com_github_ethereum_go_ethereum//rpc:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", diff --git a/beacon-chain/powchain/block_reader_test.go b/beacon-chain/powchain/block_reader_test.go index a17d67acb492..1b9c2a01a1d6 100644 --- a/beacon-chain/powchain/block_reader_test.go +++ b/beacon-chain/powchain/block_reader_test.go @@ -15,6 +15,14 @@ import ( var endpoint = "ws://127.0.0.1" +func setDefaultMocks(service *Service) *Service { + service.reader = &goodReader{} + service.blockFetcher = &goodFetcher{} + service.logger = &goodLogger{} + service.httpLogger = &goodLogger{} + return service +} + func TestLatestMainchainInfo_OK(t *testing.T) { testAcc, err := contracts.Setup() if err != nil { @@ -23,18 +31,18 @@ func TestLatestMainchainInfo_OK(t *testing.T) { beaconDB := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, beaconDB) web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - BlockFetcher: &goodFetcher{}, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, BeaconDB: beaconDB, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() exitRoutine := make(chan bool) @@ -83,12 +91,12 @@ func TestLatestMainchainInfo_OK(t *testing.T) { func TestBlockHashByHeight_ReturnsHash(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: &goodFetcher{}, + ETH1Endpoint: endpoint, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) ctx := context.Background() block := gethTypes.NewBlock( @@ -122,12 +130,12 @@ func TestBlockHashByHeight_ReturnsHash(t *testing.T) { func TestBlockExists_ValidHash(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: &goodFetcher{}, + ETH1Endpoint: endpoint, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) block := gethTypes.NewBlock( &gethTypes.Header{ @@ -161,12 +169,12 @@ func TestBlockExists_ValidHash(t *testing.T) { func TestBlockExists_InvalidHash(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: &goodFetcher{}, + ETH1Endpoint: endpoint, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) _, _, err = web3Service.BlockExists(context.Background(), common.BytesToHash([]byte{0})) if err == nil { @@ -176,12 +184,13 @@ func TestBlockExists_InvalidHash(t *testing.T) { func TestBlockExists_UsesCachedBlockInfo(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: nil, // nil blockFetcher would panic if cached value not used + ETH1Endpoint: endpoint, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + // nil blockFetcher would panic if cached value not used + web3Service.blockFetcher = nil block := gethTypes.NewBlock( &gethTypes.Header{ @@ -211,13 +220,14 @@ func TestBlockExists_UsesCachedBlockInfo(t *testing.T) { func TestBlockNumberByTimestamp(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: &goodFetcher{}, - Client: nil, + ETH1Endpoint: endpoint, }) if err != nil { t.Fatal(err) } + web3Service = setDefaultMocks(web3Service) + web3Service.client = nil + ctx := context.Background() bn, err := web3Service.BlockNumberByTimestamp(ctx, 150000 /* time */) if err != nil { diff --git a/beacon-chain/powchain/deposit_test.go b/beacon-chain/powchain/deposit_test.go index 63d660d58165..e069573f7c5e 100644 --- a/beacon-chain/powchain/deposit_test.go +++ b/beacon-chain/powchain/deposit_test.go @@ -21,16 +21,13 @@ const pubKeyErr = "could not deserialize validator public key" func TestProcessDeposit_OK(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) deposits, depositDataRoots, _ := testutil.SetupInitialDeposits(t, 1) @@ -57,16 +54,13 @@ func TestProcessDeposit_OK(t *testing.T) { func TestProcessDeposit_InvalidMerkleBranch(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) deposits, depositDataRoots, _ := testutil.SetupInitialDeposits(t, 1) @@ -99,16 +93,13 @@ func TestProcessDeposit_InvalidMerkleBranch(t *testing.T) { func TestProcessDeposit_InvalidPublicKey(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) deposits, _, _ := testutil.SetupInitialDeposits(t, 1) deposits[0].Data.PublicKey = []byte("junk") @@ -142,16 +133,13 @@ func TestProcessDeposit_InvalidPublicKey(t *testing.T) { func TestProcessDeposit_InvalidSignature(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) deposits, _, _ := testutil.SetupInitialDeposits(t, 1) var fakeSig [96]byte @@ -189,16 +177,13 @@ func TestProcessDeposit_InvalidSignature(t *testing.T) { func TestProcessDeposit_UnableToVerify(t *testing.T) { helpers.ClearAllCaches() web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) testutil.ResetCache() deposits, _, keys := testutil.SetupInitialDeposits(t, 1) @@ -221,16 +206,13 @@ func TestProcessDeposit_UnableToVerify(t *testing.T) { func TestProcessDeposit_IncompleteDeposit(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) deposit := ðpb.Deposit{ Data: ðpb.Deposit_Data{ @@ -275,16 +257,13 @@ func TestProcessDeposit_IncompleteDeposit(t *testing.T) { func TestProcessDeposit_AllDepositedSuccessfully(t *testing.T) { web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, + ETH1Endpoint: endpoint, BeaconDB: &kv.Store{}, - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("Unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) testutil.ResetCache() deposits, _, keys := testutil.SetupInitialDeposits(t, 10) diff --git a/beacon-chain/powchain/log_processing.go b/beacon-chain/powchain/log_processing.go index 4b80c59fc189..1ae60d66201a 100644 --- a/beacon-chain/powchain/log_processing.go +++ b/beacon-chain/powchain/log_processing.go @@ -33,6 +33,45 @@ func (s *Service) Eth2GenesisPowchainInfo() (uint64, *big.Int) { return s.eth2GenesisTime, s.chainStartBlockNumber } +// ProcessETH1Block processes the logs from the provided eth1Block. +func (s *Service) ProcessETH1Block(ctx context.Context, blkNum *big.Int) error { + query := ethereum.FilterQuery{ + Addresses: []common.Address{ + s.depositContractAddress, + }, + FromBlock: blkNum, + ToBlock: blkNum, + } + logs, err := s.httpLogger.FilterLogs(ctx, query) + if err != nil { + return err + } + for _, log := range logs { + if err := s.ProcessLog(ctx, log); err != nil { + return errors.Wrap(err, "could not process log") + } + } + if !s.chainStarted { + blk, err := s.blockFetcher.BlockByNumber(ctx, blkNum) + if err != nil { + return errors.Wrap(err, "could not get eth1 block") + } + if blk == nil { + return errors.Wrap(err, "got empty block from powchain service") + } + if blk.Hash() == [32]byte{} { + return errors.New("got empty blockhash from powchain service") + } + timeStamp := blk.Time() + triggered := state.IsValidGenesisState(s.activeValidatorCount, timeStamp) + if triggered { + s.setGenesisTime(timeStamp) + s.ProcessChainStart(uint64(s.eth2GenesisTime), blk.Hash(), blk.Number()) + } + } + return nil +} + // ProcessLog is the main method which handles the processing of all // logs from the deposit contract on the ETH1.0 chain. func (s *Service) ProcessLog(ctx context.Context, depositLog gethTypes.Log) error { @@ -43,24 +82,6 @@ func (s *Service) ProcessLog(ctx context.Context, depositLog gethTypes.Log) erro if err := s.ProcessDepositLog(ctx, depositLog); err != nil { return errors.Wrap(err, "Could not process deposit log") } - if !s.chainStarted { - if depositLog.BlockHash == [32]byte{} { - return errors.New("got empty blockhash from powchain service") - } - blk, err := s.blockFetcher.BlockByHash(ctx, depositLog.BlockHash) - if err != nil { - return errors.Wrap(err, "could not get eth1 block") - } - if blk == nil { - return errors.Wrap(err, "got empty block from powchain service") - } - timeStamp := blk.Time() - triggered := state.IsValidGenesisState(s.activeValidatorCount, timeStamp) - if triggered { - s.setGenesisTime(timeStamp) - s.ProcessChainStart(uint64(s.eth2GenesisTime), depositLog.BlockHash, blk.Number()) - } - } return nil } log.WithField("signature", fmt.Sprintf("%#x", depositLog.Topics[0])).Debug("Not a valid event signature") @@ -212,7 +233,7 @@ func (s *Service) ProcessChainStart(genesisTime uint64, eth1BlockHash [32]byte, } func (s *Service) setGenesisTime(timeStamp uint64) { - if featureconfig.Get().NoGenesisDelay { + if !featureconfig.Get().GenesisDelay { s.eth2GenesisTime = uint64(time.Unix(int64(timeStamp), 0).Add(30 * time.Second).Unix()) } else { timeStampRdDown := timeStamp - timeStamp%params.BeaconConfig().SecondsPerDay @@ -229,17 +250,23 @@ func (s *Service) processPastLogs(ctx context.Context) error { s.depositContractAddress, }, } - logs, err := s.httpLogger.FilterLogs(ctx, query) if err != nil { return err } - for _, log := range logs { - if err := s.ProcessLog(ctx, log); err != nil { - return errors.Wrap(err, "could not process log") + if len(logs) > 0 { + start := logs[0].BlockNumber + end := s.blockHeight.Uint64() + // Process logs from each block one by one + for i := start; i <= end; i++ { + err := s.ProcessETH1Block(ctx, big.NewInt(int64(i))) + if err != nil { + return err + } } } + s.lastRequestedBlock.Set(s.blockHeight) currentState, err := s.beaconDB.HeadState(ctx) @@ -260,24 +287,10 @@ func (s *Service) requestBatchedLogs(ctx context.Context) error { // We request for the nth block behind the current head, in order to have // stabilized logs when we retrieve it from the 1.0 chain. requestedBlock := big.NewInt(0).Sub(s.blockHeight, big.NewInt(params.BeaconConfig().LogBlockDelay)) - query := ethereum.FilterQuery{ - Addresses: []common.Address{ - s.depositContractAddress, - }, - FromBlock: s.lastRequestedBlock.Add(s.lastRequestedBlock, big.NewInt(1)), - ToBlock: requestedBlock, - } - logs, err := s.httpLogger.FilterLogs(ctx, query) - if err != nil { - return err - } - - // Only process log slices which are larger than zero. - if len(logs) > 0 { - for _, log := range logs { - if err := s.ProcessLog(ctx, log); err != nil { - return errors.Wrap(err, "could not process log") - } + for i := s.lastRequestedBlock.Uint64() + 1; i <= requestedBlock.Uint64(); i++ { + err := s.ProcessETH1Block(ctx, big.NewInt(int64(i))) + if err != nil { + return err } } @@ -290,24 +303,11 @@ func (s *Service) requestBatchedLogs(ctx context.Context) error { func (s *Service) requestMissingLogs(ctx context.Context, blkNumber uint64, wantedIndex int64) error { // We request from the last requested block till the current block(exclusive) beforeCurrentBlk := big.NewInt(int64(blkNumber) - 1) - query := ethereum.FilterQuery{ - Addresses: []common.Address{ - s.depositContractAddress, - }, - FromBlock: big.NewInt(0).Add(s.lastRequestedBlock, big.NewInt(1)), - ToBlock: beforeCurrentBlk, - } - logs, err := s.httpLogger.FilterLogs(ctx, query) - if err != nil { - return err - } - // Only process log slices which are larger than zero. - if len(logs) > 0 { - for _, log := range logs { - if err := s.ProcessLog(ctx, log); err != nil { - return errors.Wrap(err, "could not process log") - } + for i := s.lastRequestedBlock.Uint64() + 1; i <= beforeCurrentBlk.Uint64(); i++ { + err := s.ProcessETH1Block(ctx, big.NewInt(int64(i))) + if err != nil { + return err } } diff --git a/beacon-chain/powchain/log_processing_test.go b/beacon-chain/powchain/log_processing_test.go index 87bc55425c09..9a814d4534e8 100644 --- a/beacon-chain/powchain/log_processing_test.go +++ b/beacon-chain/powchain/log_processing_test.go @@ -33,19 +33,19 @@ func TestProcessDepositLog_OK(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, BeaconDB: &kv.Store{}, DepositCache: depositcache.NewDepositCache(), - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() deposits, depositRoots, _ := testutil.SetupInitialDeposits(t, 1) @@ -95,18 +95,19 @@ func TestProcessDepositLog_InsertsPendingDeposit(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, BeaconDB: &kv.Store{}, DepositCache: depositcache.NewDepositCache(), }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() @@ -154,16 +155,17 @@ func TestUnpackDepositLogData_OK(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() @@ -222,19 +224,19 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, BeaconDB: &kv.Store{}, DepositCache: depositcache.NewDepositCache(), - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } bConfig := params.MinimalSpecConfig() bConfig.MinGenesisTime = 0 @@ -291,19 +293,19 @@ func TestProcessETH2GenesisLog(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, BeaconDB: &kv.Store{}, DepositCache: depositcache.NewDepositCache(), - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } bConfig := params.MinimalSpecConfig() bConfig.MinGenesisTime = 0 params.OverrideBeaconConfig(bConfig) @@ -353,6 +355,11 @@ func TestProcessETH2GenesisLog(t *testing.T) { web3Service.ProcessLog(context.Background(), log) } + err = web3Service.ProcessETH1Block(context.Background(), big.NewInt(int64(logs[len(logs)-1].BlockNumber))) + if err != nil { + t.Fatal(err) + } + cachedDeposits := web3Service.ChainStartDeposits() if len(cachedDeposits) != depositsReqForChainStart { t.Fatalf( @@ -378,19 +385,20 @@ func TestWeb3ServiceProcessDepositLog_RequestMissedDeposits(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: testAcc.Backend, - ContractBackend: testAcc.Backend, BeaconDB: &kv.Store{}, DepositCache: depositcache.NewDepositCache(), - BlockFetcher: &goodFetcher{}, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } + web3Service.httpLogger = testAcc.Backend bConfig := params.MinimalSpecConfig() bConfig.MinGenesisTime = 0 params.OverrideBeaconConfig(bConfig) diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index 5d29f62ae158..2148e9a125fc 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -14,6 +14,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + gethRPC "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -45,6 +47,9 @@ var ( }) ) +// time to wait before trying to reconnect with the eth1 node. +var backOffPeriod = 6 * time.Second + // Reader defines a struct that can fetch latest header events from a web3 endpoint. type Reader interface { SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error) @@ -61,6 +66,7 @@ type ChainStartFetcher interface { // ChainInfoFetcher retrieves information about eth1 metadata at the eth2 genesis time. type ChainInfoFetcher interface { Eth2GenesisPowchainInfo() (uint64, *big.Int) + IsConnectedToETH1() bool } // POWBlockFetcher defines a struct that can retrieve mainchain blocks. @@ -106,7 +112,8 @@ type Service struct { cancel context.CancelFunc client Client headerChan chan *gethTypes.Header - endpoint string + eth1Endpoint string + httpEndpoint string depositContractAddress common.Address chainStartFeed *event.Feed reader Reader @@ -134,18 +141,14 @@ type Service struct { depositedPubkeys map[[48]byte]uint64 processingLock sync.RWMutex eth2GenesisTime uint64 + connectedETH1 bool } // Web3ServiceConfig defines a config struct for web3 service to use through its life cycle. type Web3ServiceConfig struct { - Endpoint string + ETH1Endpoint string + HTTPEndPoint string DepositContract common.Address - Client Client - Reader Reader - Logger bind.ContractFilterer - HTTPLogger bind.ContractFilterer - BlockFetcher RPCBlockFetcher - ContractBackend bind.ContractBackend BeaconDB db.Database DepositCache *depositcache.DepositCache } @@ -153,18 +156,13 @@ type Web3ServiceConfig struct { // NewService sets up a new instance with an ethclient when // given a web3 endpoint as a string in the config. func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error) { - if !strings.HasPrefix(config.Endpoint, "ws") && !strings.HasPrefix(config.Endpoint, "ipc") { + if !strings.HasPrefix(config.ETH1Endpoint, "ws") && !strings.HasPrefix(config.ETH1Endpoint, "ipc") { return nil, fmt.Errorf( "powchain service requires either an IPC or WebSocket endpoint, provided %s", - config.Endpoint, + config.ETH1Endpoint, ) } - depositContractCaller, err := contracts.NewDepositContractCaller(config.DepositContract, config.ContractBackend) - if err != nil { - return nil, errors.Wrap(err, "could not create deposit contract caller") - } - ctx, cancel := context.WithCancel(ctx) depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) if err != nil { @@ -175,19 +173,14 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error ctx: ctx, cancel: cancel, headerChan: make(chan *gethTypes.Header), - endpoint: config.Endpoint, + eth1Endpoint: config.ETH1Endpoint, + httpEndpoint: config.HTTPEndPoint, blockHeight: nil, blockHash: common.BytesToHash([]byte{}), blockCache: newBlockCache(), depositContractAddress: config.DepositContract, chainStartFeed: new(event.Feed), - client: config.Client, depositTrie: depositTrie, - reader: config.Reader, - logger: config.Logger, - httpLogger: config.HTTPLogger, - blockFetcher: config.BlockFetcher, - depositContractCaller: depositContractCaller, chainStartDeposits: make([]*ethpb.Deposit, 0), beaconDB: config.BeaconDB, depositCache: config.DepositCache, @@ -200,10 +193,10 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error // Start a web3 service's main event loop. func (s *Service) Start() { - log.WithFields(logrus.Fields{ - "endpoint": s.endpoint, - }).Info("Connected to eth1 proof-of-work chain") - go s.run(s.ctx.Done()) + go func() { + s.waitForConnection() + s.run(s.ctx.Done()) + }() } // Stop the web3 service's main event loop and associated goroutines. @@ -254,6 +247,11 @@ func (s *Service) Status() error { return nil } +// IsConnectedToETH1 checks if the beacon node is connected to a ETH1 Node. +func (s *Service) IsConnectedToETH1() bool { + return s.connectedETH1 +} + // DepositRoot returns the Merkle root of the latest deposit trie // from the ETH1.0 deposit contract. func (s *Service) DepositRoot() [32]byte { @@ -298,6 +296,81 @@ func (s *Service) AreAllDepositsProcessed() (bool, error) { return true, nil } +func (s *Service) connectToPowChain() error { + powClient, httpClient, err := s.dialETH1Nodes() + if err != nil { + return errors.Wrap(err, "could not dial eth1 nodes") + } + + depositContractCaller, err := contracts.NewDepositContractCaller(s.depositContractAddress, httpClient) + if err != nil { + return errors.Wrap(err, "could not create deposit contract caller") + } + + s.initializeConnection(powClient, httpClient, depositContractCaller) + return nil +} + +func (s *Service) dialETH1Nodes() (*ethclient.Client, *ethclient.Client, error) { + httpRPCClient, err := gethRPC.Dial(s.httpEndpoint) + if err != nil { + return nil, nil, err + } + httpClient := ethclient.NewClient(httpRPCClient) + + rpcClient, err := gethRPC.Dial(s.eth1Endpoint) + if err != nil { + httpClient.Close() + return nil, nil, err + } + powClient := ethclient.NewClient(rpcClient) + + return powClient, httpClient, nil +} + +func (s *Service) initializeConnection(powClient *ethclient.Client, + httpClient *ethclient.Client, contractCaller *contracts.DepositContractCaller) { + + s.reader = powClient + s.logger = powClient + s.client = httpClient + s.httpLogger = httpClient + s.blockFetcher = httpClient + s.depositContractCaller = contractCaller +} + +func (s *Service) waitForConnection() { + err := s.connectToPowChain() + if err == nil { + s.connectedETH1 = true + log.WithFields(logrus.Fields{ + "endpoint": s.eth1Endpoint, + }).Info("Connected to eth1 proof-of-work chain") + return + } + log.WithError(err).Error("Could not connect to powchain endpoint") + ticker := time.NewTicker(backOffPeriod) + for { + select { + case <-ticker.C: + err := s.connectToPowChain() + if err == nil { + s.connectedETH1 = true + log.WithFields(logrus.Fields{ + "endpoint": s.eth1Endpoint, + }).Info("Connected to eth1 proof-of-work chain") + ticker.Stop() + return + } + log.WithError(err).Error("Could not connect to powchain endpoint") + case <-s.ctx.Done(): + ticker.Stop() + log.Debug("Received cancelled context,closing existing powchain service") + return + } + } +} + // initDataFromContract calls the deposit contract and finds the deposit count // and deposit root. func (s *Service) initDataFromContract() error { @@ -395,10 +468,13 @@ func (s *Service) run(done <-chan struct{}) { case <-done: s.isRunning = false s.runError = nil + s.connectedETH1 = false log.Debug("Context closed, exiting goroutine") return case s.runError = <-headSub.Err(): log.WithError(s.runError).Error("Subscription to new head notifier failed") + s.connectedETH1 = false + s.waitForConnection() headSub, err = s.reader.SubscribeNewHead(s.ctx, s.headerChan) if err != nil { log.WithError(err).Error("Unable to re-subscribe to incoming ETH1.0 chain headers") diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 70b8b5e56bcc..3a64d9d51eec 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -103,37 +103,29 @@ func TestNewWeb3Service_OK(t *testing.T) { ctx := context.Background() var err error if _, err = NewService(ctx, &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: common.Address{}, - Reader: &goodReader{}, - Logger: &goodLogger{}, }); err == nil { t.Errorf("passing in an HTTP endpoint should throw an error, received nil") } endpoint = "ftp://127.0.0.1" if _, err = NewService(ctx, &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: common.Address{}, - Reader: &goodReader{}, - Logger: &goodLogger{}, }); err == nil { t.Errorf("passing in a non-ws, wss, or ipc endpoint should throw an error, received nil") } endpoint = "ws://127.0.0.1" if _, err = NewService(ctx, &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: common.Address{}, - Reader: &goodReader{}, - Logger: &goodLogger{}, }); err != nil { t.Errorf("passing in as ws endpoint should not throw error, received %v", err) } endpoint = "ipc://geth.ipc" if _, err = NewService(ctx, &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: common.Address{}, - Reader: &goodReader{}, - Logger: &goodLogger{}, }); err != nil { t.Errorf("passing in an ipc endpoint should not throw error, received %v", err) } @@ -148,26 +140,27 @@ func TestStart_OK(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - BlockFetcher: &goodFetcher{}, - ContractBackend: testAcc.Backend, BeaconDB: beaconDB, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() web3Service.Start() - - msg := hook.LastEntry().Message - want := "Could not connect to ETH1.0 chain RPC client" - if strings.Contains(want, msg) { - t.Errorf("incorrect log, expected %s, got %s", want, msg) + if len(hook.Entries) > 0 { + msg := hook.LastEntry().Message + want := "Could not connect to ETH1.0 chain RPC client" + if strings.Contains(want, msg) { + t.Errorf("incorrect log, expected %s, got %s", want, msg) + } } hook.Reset() web3Service.cancel() @@ -181,16 +174,17 @@ func TestStop_OK(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - BlockFetcher: &goodFetcher{}, - ContractBackend: testAcc.Backend, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() @@ -212,16 +206,17 @@ func TestInitDataFromContract_OK(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &goodReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() if err := web3Service.initDataFromContract(); err != nil { @@ -237,16 +232,17 @@ func TestWeb3Service_BadReader(t *testing.T) { t.Fatalf("Unable to set up simulated backend %v", err) } web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, + ETH1Endpoint: endpoint, DepositContract: testAcc.ContractAddr, - Reader: &badReader{}, - Logger: &goodLogger{}, - HTTPLogger: &goodLogger{}, - ContractBackend: testAcc.Backend, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + web3Service = setDefaultMocks(web3Service) + web3Service.depositContractCaller, err = contracts.NewDepositContractCaller(testAcc.ContractAddr, testAcc.Backend) + if err != nil { + t.Fatal(err) + } testAcc.Backend.Commit() web3Service.reader = &badReader{} @@ -296,12 +292,13 @@ func TestHandlePanic_OK(t *testing.T) { hook := logTest.NewGlobal() web3Service, err := NewService(context.Background(), &Web3ServiceConfig{ - Endpoint: endpoint, - BlockFetcher: nil, // nil blockFetcher would panic if cached value not used + ETH1Endpoint: endpoint, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) } + // nil blockFetcher would panic if cached value not used + web3Service.blockFetcher = nil web3Service.processSubscribedHeaders(nil) testutil.AssertLogsContain(t, hook, "Panicked when handling data from ETH 1.0 Chain!") diff --git a/beacon-chain/powchain/testing/faulty_mock.go b/beacon-chain/powchain/testing/faulty_mock.go index 5635753857cc..267ec2d44154 100644 --- a/beacon-chain/powchain/testing/faulty_mock.go +++ b/beacon-chain/powchain/testing/faulty_mock.go @@ -80,3 +80,8 @@ func (f *FaultyMockPOWChain) ChainStartDepositHashes() ([][]byte, error) { func (f *FaultyMockPOWChain) ChainStartEth1Data() *ethpb.Eth1Data { return ðpb.Eth1Data{} } + +// IsConnectedToETH1 -- +func (f *FaultyMockPOWChain) IsConnectedToETH1() bool { + return true +} diff --git a/beacon-chain/powchain/testing/mock.go b/beacon-chain/powchain/testing/mock.go index 63836579a651..6023c941f3ac 100644 --- a/beacon-chain/powchain/testing/mock.go +++ b/beacon-chain/powchain/testing/mock.go @@ -99,3 +99,8 @@ func (m *POWChain) ChainStartDepositHashes() ([][]byte, error) { func (m *POWChain) ChainStartEth1Data() *ethpb.Eth1Data { return m.Eth1Data } + +// IsConnectedToETH1 -- +func (m *POWChain) IsConnectedToETH1() bool { + return true +} diff --git a/beacon-chain/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index 49f37bf199f9..e5626298b2e9 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -112,7 +112,8 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest } res = ðpb.AttestationData{ - // TODO(#3865): Fill in rest of the missing information + Slot: req.Slot, + Index: req.CommitteeIndex, BeaconBlockRoot: headRoot[:], Source: headState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ diff --git a/beacon-chain/rpc/attester_server_test.go b/beacon-chain/rpc/attester_server_test.go index 5cae039e9478..0ac7dc928f64 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -129,6 +129,7 @@ func TestRequestAttestation_OK(t *testing.T) { } expectedInfo := ðpb.AttestationData{ + Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: 2, @@ -210,6 +211,7 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { } expectedInfo := ðpb.AttestationData{ + Slot: req.Slot, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: helpers.SlotToEpoch(1500), diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index ebfdf1cfbb20..50ffdce076a0 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -242,9 +242,15 @@ func (bs *BeaconChainServer) ListValidatorBalances( ctx context.Context, req *ethpb.GetValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) { - res := make([]*ethpb.ValidatorBalances_Balance, 0, len(req.PublicKeys)+len(req.Indices)) + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + + res := make([]*ethpb.ValidatorBalances_Balance, 0) filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. + headState := bs.headFetcher.HeadState() var requestingGenesis bool var epoch uint64 switch q := req.QueryFilter.(type) { @@ -253,11 +259,11 @@ func (bs *BeaconChainServer) ListValidatorBalances( case *ethpb.GetValidatorBalancesRequest_Genesis: requestingGenesis = q.Genesis default: + epoch = helpers.CurrentEpoch(headState) } var balances []uint64 var err error - headState := bs.headFetcher.HeadState() validators := headState.Validators if requestingGenesis { balances, err = bs.beaconDB.ArchivedBalances(ctx, 0 /* genesis epoch */) @@ -319,7 +325,29 @@ func (bs *BeaconChainServer) ListValidatorBalances( }) } } - return ðpb.ValidatorBalances{Balances: res}, nil + + if len(req.Indices) == 0 && len(req.PublicKeys) == 0 { + // return everything. + for i := 0; i < len(headState.Balances); i++ { + res = append(res, ðpb.ValidatorBalances_Balance{ + PublicKey: headState.Validators[i].PublicKey, + Index: uint64(i), + Balance: balances[i], + }) + } + } + + balancesCount := len(res) + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), balancesCount) + if err != nil { + return nil, err + } + return ðpb.ValidatorBalances{ + Epoch: epoch, + Balances: res[start:end], + TotalSize: int32(balancesCount), + NextPageToken: nextPageToken, + }, nil } // GetValidators retrieves the current list of active validators with an optional historical epoch flag to diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon_chain_server_test.go index 6af1f7d677ff..2a2bb6bd07f9 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -464,7 +464,46 @@ func TestBeaconChainServer_AttestationPool(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances(t *testing.T) { +func TestBeaconChainServer_ListValidatorBalances_PaginationOutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + setupValidators(t, db, 3) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &BeaconChainServer{ + headFetcher: &mock.ChainService{ + State: headState, + }, + } + + req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 100} + wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(headState.Balances)) + if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestBeaconChainServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { + bs := &BeaconChainServer{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf( + "requested page size %d can not be greater than max size %d", + exceedsMax, + params.BeaconConfig().MaxPageSize, + ) + req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestBeaconChainServer_ListValidatorBalances_NoPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -485,46 +524,135 @@ func TestBeaconChainServer_ListValidatorBalances(t *testing.T) { res *ethpb.ValidatorBalances }{ {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{99}}}, - res: ðpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{{ - Index: 99, PublicKey: []byte{99}, Balance: 99}}, - }}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 99, PublicKey: []byte{99}, Balance: 99}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 1, + }, + }, {req: ðpb.GetValidatorBalancesRequest{Indices: []uint64{1, 2, 3}}, - res: ðpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 1, PublicKey: []byte{1}, Balance: 1}, - {Index: 2, PublicKey: []byte{2}, Balance: 2}, - {Index: 3, PublicKey: []byte{3}, Balance: 3}}, - }}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 1, PublicKey: []byte{1}, Balance: 1}, + {Index: 2, PublicKey: []byte{2}, Balance: 2}, + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, + }, + }, {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{10}, {11}, {12}}}, - res: ðpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 10, PublicKey: []byte{10}, Balance: 10}, - {Index: 11, PublicKey: []byte{11}, Balance: 11}, - {Index: 12, PublicKey: []byte{12}, Balance: 12}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 10, PublicKey: []byte{10}, Balance: 10}, + {Index: 11, PublicKey: []byte{11}, Balance: 11}, + {Index: 12, PublicKey: []byte{12}, Balance: 12}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, }}, {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{2}, {3}}, Indices: []uint64{3, 4}}, // Duplication - res: ðpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 2, PublicKey: []byte{2}, Balance: 2}, - {Index: 3, PublicKey: []byte{3}, Balance: 3}, - {Index: 4, PublicKey: []byte{4}, Balance: 4}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 2, PublicKey: []byte{2}, Balance: 2}, + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + {Index: 4, PublicKey: []byte{4}, Balance: 4}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, }}, {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{}}, Indices: []uint64{3, 4}}, // Public key has a blank value - res: ðpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 3, PublicKey: []byte{3}, Balance: 3}, - {Index: 4, PublicKey: []byte{4}, Balance: 4}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + {Index: 4, PublicKey: []byte{4}, Balance: 4}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 2, }}, } + for _, test := range tests { + res, err := bs.ListValidatorBalances(context.Background(), test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Expected %v, received %v", test.res, res) + } + } +} +func TestBeaconChainServer_ListValidatorBalances_Pagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + count := 1000 + setupValidators(t, db, count) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &BeaconChainServer{ + headFetcher: &mock.ChainService{ + State: headState, + }, + } + + tests := []struct { + req *ethpb.GetValidatorBalancesRequest + res *ethpb.ValidatorBalances + }{ + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 3}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{3}, Index: 3, Balance: uint64(3)}, + {PublicKey: []byte{4}, Index: 4, Balance: uint64(4)}, + {PublicKey: []byte{5}, Index: 5, Balance: uint64(5)}}, + NextPageToken: strconv.Itoa(2), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(10), PageSize: 5}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{50}, Index: 50, Balance: uint64(50)}, + {PublicKey: []byte{51}, Index: 51, Balance: uint64(51)}, + {PublicKey: []byte{52}, Index: 52, Balance: uint64(52)}, + {PublicKey: []byte{53}, Index: 53, Balance: uint64(53)}, + {PublicKey: []byte{54}, Index: 54, Balance: uint64(54)}}, + NextPageToken: strconv.Itoa(11), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(33), PageSize: 3}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{99}, Index: 99, Balance: uint64(99)}, + {PublicKey: []byte{100}, Index: 100, Balance: uint64(100)}, + {PublicKey: []byte{101}, Index: 101, Balance: uint64(101)}, + }, + NextPageToken: strconv.Itoa(34), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageSize: 2}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{0}, Index: 0, Balance: uint64(0)}, + {PublicKey: []byte{1}, Index: 1, Balance: uint64(1)}}, + NextPageToken: strconv.Itoa(1), + TotalSize: int32(count)}}, + } for _, test := range tests { res, err := bs.ListValidatorBalances(context.Background(), test.req) if err != nil { t.Fatal(err) } if !proto.Equal(res, test.res) { - t.Error("Incorrect respond of validator balances") + t.Errorf("Expected %v, received %v", test.res, res) } } } -func TestBeaconChainServer_ListValidatorBalancesOutOfRange(t *testing.T) { +func TestBeaconChainServer_ListValidatorBalances_OutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) setupValidators(t, db, 1) @@ -546,7 +674,7 @@ func TestBeaconChainServer_ListValidatorBalancesOutOfRange(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalancesFromArchive(t *testing.T) { +func TestBeaconChainServer_ListValidatorBalances_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -594,7 +722,7 @@ func TestBeaconChainServer_ListValidatorBalancesFromArchive(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalancesFromArchive_NewValidatorNotFound(t *testing.T) { +func TestBeaconChainServer_ListValidatorBalances_FromArchive_NewValidatorNotFound(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -1863,7 +1991,9 @@ func setupValidators(t *testing.T, db db.Database, count int) ([]*ethpb.Validato t.Fatal(err) } balances[i] = uint64(i) - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}}) + validators = append(validators, ðpb.Validator{ + PublicKey: []byte{byte(i)}, + }) } blk := ðpb.BeaconBlock{ Slot: 0, diff --git a/beacon-chain/rpc/proposer_server.go b/beacon-chain/rpc/proposer_server.go index 1b623db1581b..a57216335abb 100644 --- a/beacon-chain/rpc/proposer_server.go +++ b/beacon-chain/rpc/proposer_server.go @@ -132,29 +132,8 @@ func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlo // - Subtract that eth1block.number by ETH1_FOLLOW_DISTANCE. // - This is the eth1block to use for the block proposal. func (ps *ProposerServer) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth1Data, error) { - if ps.mockEth1Votes { - // If a mock eth1 data votes is specified, we use the following for the - // eth1data we provide to every proposer based on https://github.com/ethereum/eth2.0-pm/issues/62: - // - // slot_in_voting_period = current_slot % SLOTS_PER_ETH1_VOTING_PERIOD - // Eth1Data( - // DepositRoot = hash(current_epoch + slot_in_voting_period), - // DepositCount = state.eth1_deposit_index, - // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), - // ) - slotInVotingPeriod := slot % params.BeaconConfig().SlotsPerEth1VotingPeriod - headState := ps.headFetcher.HeadState() - enc, err := ssz.Marshal(helpers.SlotToEpoch(slot) + slotInVotingPeriod) - if err != nil { - return nil, err - } - depRoot := hashutil.Hash(enc) - blockHash := hashutil.Hash(depRoot[:]) - return ðpb.Eth1Data{ - DepositRoot: depRoot[:], - DepositCount: headState.Eth1DepositIndex, - BlockHash: blockHash[:], - }, nil + if ps.mockEth1Votes || !ps.eth1InfoFetcher.IsConnectedToETH1() { + return ps.mockETH1DataVote(slot) } eth1VotingPeriodStartTime, _ := ps.eth1InfoFetcher.Eth2GenesisPowchainInfo() @@ -163,12 +142,39 @@ func (ps *ProposerServer) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth // Look up most recent block up to timestamp blockNumber, err := ps.eth1BlockFetcher.BlockNumberByTimestamp(ctx, eth1VotingPeriodStartTime) if err != nil { - return nil, err + return nil, errors.Wrap(err, "could not get block number from timestamp") } return ps.defaultEth1DataResponse(ctx, blockNumber) } +func (ps *ProposerServer) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) { + log.Warn("Beacon Node is no longer connected to an ETH1 Chain, so " + + "ETH1 Data votes are now mocked.") + // If a mock eth1 data votes is specified, we use the following for the + // eth1data we provide to every proposer based on https://github.com/ethereum/eth2.0-pm/issues/62: + // + // slot_in_voting_period = current_slot % SLOTS_PER_ETH1_VOTING_PERIOD + // Eth1Data( + // DepositRoot = hash(current_epoch + slot_in_voting_period), + // DepositCount = state.eth1_deposit_index, + // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), + // ) + slotInVotingPeriod := slot % params.BeaconConfig().SlotsPerEth1VotingPeriod + headState := ps.headFetcher.HeadState() + enc, err := ssz.Marshal(helpers.SlotToEpoch(slot) + slotInVotingPeriod) + if err != nil { + return nil, err + } + depRoot := hashutil.Hash(enc) + blockHash := hashutil.Hash(depRoot[:]) + return ðpb.Eth1Data{ + DepositRoot: depRoot[:], + DepositCount: headState.Eth1DepositIndex, + BlockHash: blockHash[:], + }, nil +} + // computeStateRoot computes the state root after a block has been processed through a state transition and // returns it to the validator client. func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.BeaconBlock) ([]byte, error) { @@ -196,7 +202,7 @@ func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.Bea // enough support, then use that vote for basis of determining deposits, otherwise use current state // eth1data. func (ps *ProposerServer) deposits(ctx context.Context, currentVote *ethpb.Eth1Data) ([]*ethpb.Deposit, error) { - if ps.mockEth1Votes { + if ps.mockEth1Votes || !ps.eth1InfoFetcher.IsConnectedToETH1() { return []*ethpb.Deposit{}, nil } // Need to fetch if the deposits up to the state's latest eth 1 data matches diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index abd687bb3bbd..05700bab0a66 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -193,6 +193,7 @@ func (s *Service) Start() { canonicalStateChan: s.canonicalStateChan, blockFetcher: s.powChainService, chainStartFetcher: s.chainStartFetcher, + eth1InfoFetcher: s.powChainService, depositFetcher: s.depositFetcher, stateFeedListener: s.stateFeedListener, chainStartChan: make(chan time.Time), diff --git a/beacon-chain/rpc/service_test.go b/beacon-chain/rpc/service_test.go index 85efe42e225c..ae20d8cd8739 100644 --- a/beacon-chain/rpc/service_test.go +++ b/beacon-chain/rpc/service_test.go @@ -8,6 +8,7 @@ import ( "testing" mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/sirupsen/logrus" @@ -30,6 +31,7 @@ func TestLifecycle_OK(t *testing.T) { AttestationReceiver: &mock.ChainService{}, HeadFetcher: &mock.ChainService{}, StateFeedListener: &mock.ChainService{}, + POWChainService: &mockPOW.POWChain{}, }) rpcService.Start() @@ -49,6 +51,7 @@ func TestRPC_BadEndpoint(t *testing.T) { BlockReceiver: &mock.ChainService{}, AttestationReceiver: &mock.ChainService{}, HeadFetcher: &mock.ChainService{}, + POWChainService: &mockPOW.POWChain{}, StateFeedListener: &mock.ChainService{}, }) @@ -81,6 +84,7 @@ func TestRPC_InsecureEndpoint(t *testing.T) { AttestationReceiver: &mock.ChainService{}, HeadFetcher: &mock.ChainService{}, StateFeedListener: &mock.ChainService{}, + POWChainService: &mockPOW.POWChain{}, }) rpcService.Start() diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index 71977dcb9f89..b033279974f4 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -36,6 +36,7 @@ type ValidatorServer struct { blockFetcher powchain.POWBlockFetcher depositFetcher depositcache.DepositFetcher chainStartFetcher powchain.ChainStartFetcher + eth1InfoFetcher powchain.ChainInfoFetcher stateFeedListener blockchain.ChainFeeds chainStartChan chan time.Time } @@ -293,6 +294,23 @@ func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainReq } func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { + if !vs.eth1InfoFetcher.IsConnectedToETH1() { + vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) + if err != nil { + return &pb.ValidatorStatusResponse{ + Status: pb.ValidatorStatus_UNKNOWN_STATUS, + ActivationEpoch: params.BeaconConfig().FarFutureEpoch, + } + } + statusResp := &pb.ValidatorStatusResponse{ + Status: vStatus, + } + if vStatus == pb.ValidatorStatus_ACTIVE { + statusResp.ActivationEpoch = headState.Validators[idx].ActivationEpoch + } + return statusResp + } + _, eth1BlockNumBigInt := vs.depositFetcher.DepositByPubkey(ctx, pubKey) if eth1BlockNumBigInt == nil { return &pb.ValidatorStatusResponse{ @@ -312,16 +330,10 @@ func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, h return statusResp } statusResp.DepositInclusionSlot = depositBlockSlot - - idx, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) if err != nil { return statusResp } - if !ok || headState == nil { - return statusResp - } - - vStatus := vs.assignmentStatus(uint64(idx), headState) statusResp.Status = vStatus if vStatus == pb.ValidatorStatus_ACTIVE { @@ -348,6 +360,21 @@ func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, h } } +func (vs *ValidatorServer) retrieveStatusFromState(ctx context.Context, pubKey []byte, + headState *pbp2p.BeaconState) (pb.ValidatorStatus, uint64, error) { + if headState == nil { + return pb.ValidatorStatus(0), 0, errors.New("head state does not exist") + } + idx, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + if err != nil { + return pb.ValidatorStatus(0), 0, err + } + if !ok { + return pb.ValidatorStatus(0), 0, errors.New("pubkey does not exist") + } + return vs.assignmentStatus(uint64(idx), headState), uint64(idx), nil +} + func (vs *ValidatorServer) assignmentStatus(validatorIdx uint64, beaconState *pbp2p.BeaconState) pb.ValidatorStatus { var status pb.ValidatorStatus v := beaconState.Validators[validatorIdx] diff --git a/beacon-chain/rpc/validator_server_test.go b/beacon-chain/rpc/validator_server_test.go index 7f9142b6b511..2a5f2b2c3582 100644 --- a/beacon-chain/rpc/validator_server_test.go +++ b/beacon-chain/rpc/validator_server_test.go @@ -347,6 +347,7 @@ func TestValidatorStatus_DepositReceived(t *testing.T) { headFetcher: &mockChain.ChainService{ State: &pbp2p.BeaconState{}, }, + eth1InfoFetcher: p, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -419,6 +420,7 @@ func TestValidatorStatus_PendingActive(t *testing.T) { beaconDB: db, chainStartFetcher: p, blockFetcher: p, + eth1InfoFetcher: p, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } @@ -494,6 +496,7 @@ func TestValidatorStatus_Active(t *testing.T) { beaconDB: db, chainStartFetcher: p, blockFetcher: p, + eth1InfoFetcher: p, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } @@ -573,6 +576,7 @@ func TestValidatorStatus_InitiatedExit(t *testing.T) { beaconDB: db, chainStartFetcher: p, blockFetcher: p, + eth1InfoFetcher: p, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } @@ -642,6 +646,7 @@ func TestValidatorStatus_Withdrawable(t *testing.T) { beaconDB: db, chainStartFetcher: p, blockFetcher: p, + eth1InfoFetcher: p, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } @@ -710,6 +715,7 @@ func TestValidatorStatus_ExitedSlashed(t *testing.T) { vs := &ValidatorServer{ beaconDB: db, chainStartFetcher: p, + eth1InfoFetcher: p, depositFetcher: depositCache, blockFetcher: p, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, @@ -780,6 +786,7 @@ func TestValidatorStatus_Exited(t *testing.T) { vs := &ValidatorServer{ beaconDB: db, chainStartFetcher: p, + eth1InfoFetcher: p, blockFetcher: p, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, @@ -802,7 +809,8 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) { pubKey := []byte{'A'} depositCache := depositcache.NewDepositCache() vs := &ValidatorServer{ - depositFetcher: depositCache, + depositFetcher: depositCache, + eth1InfoFetcher: &mockPOW.POWChain{}, headFetcher: &mockChain.ChainService{ State: &pbp2p.BeaconState{ Slot: 0, @@ -845,6 +853,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { ctx: ctx, chainStartFetcher: &mockPOW.POWChain{}, blockFetcher: &mockPOW.POWChain{}, + eth1InfoFetcher: &mockPOW.POWChain{}, canonicalStateChan: make(chan *pbp2p.BeaconState, 1), depositFetcher: depositcache.NewDepositCache(), headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, @@ -949,6 +958,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { canonicalStateChan: make(chan *pbp2p.BeaconState, 1), chainStartFetcher: &mockPOW.POWChain{}, blockFetcher: &mockPOW.POWChain{}, + eth1InfoFetcher: &mockPOW.POWChain{}, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } @@ -1062,6 +1072,7 @@ func TestMultipleValidatorStatus_OK(t *testing.T) { canonicalStateChan: make(chan *pbp2p.BeaconState, 1), chainStartFetcher: &mockPOW.POWChain{}, blockFetcher: &mockPOW.POWChain{}, + eth1InfoFetcher: &mockPOW.POWChain{}, depositFetcher: depositCache, headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index 0a36c6313063..39dab0ddba8b 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -35,18 +35,23 @@ go_test( name = "go_default_test", srcs = ["round_robin_test.go"], embed = [":go_default_library"], + race = "on", + tags = ["race_on"], deps = [ "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/db/testing:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/sync:go_default_library", "//beacon-chain/sync/peerstatus:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//shared/hashutil:go_default_library", "//shared/params:go_default_library", "//shared/roughtime:go_default_library", "//shared/sliceutil:go_default_library", "@com_github_libp2p_go_libp2p_core//network:go_default_library", "@com_github_libp2p_go_libp2p_core//peer:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], ) diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index 369bdd6a89eb..9ae6352f33be 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -4,8 +4,9 @@ import ( "context" "fmt" "io" + "math/rand" "sort" - "sync" + "sync/atomic" "time" "github.com/libp2p/go-libp2p-core/peer" @@ -40,14 +41,18 @@ func (s *InitialSync) roundRobinSync(genesis time.Time) error { defer cancel() counter := ratecounter.NewRateCounter(counterSeconds * time.Second) + randGenerator := rand.New(rand.NewSource(time.Now().Unix())) var lastEmptyRequests int - errChan := make(chan error) // Step 1 - Sync to end of finalized epoch. for s.chain.HeadSlot() < helpers.StartSlot(highestFinalizedEpoch()+1) { root, finalizedEpoch, peers := bestFinalized() - var blocks []*eth.BeaconBlock + // shuffle peers to prevent a bad peer from + // stalling sync with invalid blocks + randGenerator.Shuffle(len(peers), func(i, j int) { + peers[i], peers[j] = peers[j], peers[i] + }) // request a range of blocks to be requested from multiple peers. // Example: @@ -61,11 +66,14 @@ func (s *InitialSync) roundRobinSync(genesis time.Time) error { if len(peers) == 0 { return nil, errors.WithStack(errors.New("no peers left to request blocks")) } - var wg sync.WaitGroup + var p2pRequestCount int32 + errChan := make(chan error) + blocksChan := make(chan []*eth.BeaconBlock) // Handle block large block ranges of skipped slots. start += count * uint64(lastEmptyRequests*len(peers)) + atomic.AddInt32(&p2pRequestCount, int32(len(peers))) for i, pid := range peers { if ctx.Err() != nil { return nil, ctx.Err() @@ -90,10 +98,14 @@ func (s *InitialSync) roundRobinSync(genesis time.Time) error { Step: step, } - // Fulfill requests asynchronously, in parallel, and wait for results from all. - wg.Add(1) go func(i int, pid peer.ID) { - defer wg.Done() + defer func() { + zeroIfIAmTheLast := atomic.AddInt32(&p2pRequestCount, -1) + if zeroIfIAmTheLast == 0 { + close(blocksChan) + } + }() + resp, err := s.requestBlocks(ctx, req, pid) log.WithField("peer", pid.Pretty()).Debugf("Received %d blocks", len(resp)) if err != nil { @@ -110,28 +122,30 @@ func (s *InitialSync) roundRobinSync(genesis time.Time) error { errChan <- errors.WithStack(errors.New("no peers left to request blocks")) return } - _, err = request(start, step, count/uint64(len(ps)) /*count*/, ps, int(count)%len(ps) /*remainder*/) + resp, err = request(start, step, count/uint64(len(ps)) /*count*/, ps, int(count)%len(ps) /*remainder*/) if err != nil { errChan <- err return } } - blocks = append(blocks, resp...) + blocksChan <- resp }(i, pid) } - // Wait for done signal or any error. - done := make(chan interface{}) - go func() { - wg.Wait() - done <- true - }() + var unionRespBlocks []*eth.BeaconBlock for { select { case err := <-errChan: return nil, err - case <-done: - return blocks, nil + case resp, ok := <-blocksChan: + if ok { + // if this synchronization becomes a bottleneck: + // think about immediately allocating space for all peers in unionRespBlocks, + // and write without synchronization + unionRespBlocks = append(unionRespBlocks, resp...) + } else { + return unionRespBlocks, nil + } } } } @@ -156,6 +170,10 @@ func (s *InitialSync) roundRobinSync(genesis time.Time) error { for _, blk := range blocks { logSyncStatus(genesis, blk, peers, counter) + if !s.db.HasBlock(ctx, bytesutil.ToBytes32(blk.ParentRoot)) { + log.Debugf("Beacon node doesn't have a block in db with root %#x", blk.ParentRoot) + continue + } if featureconfig.Get().InitSyncNoVerify { if err := s.chain.ReceiveBlockNoVerify(ctx, blk); err != nil { return err diff --git a/beacon-chain/sync/initial-sync/round_robin_test.go b/beacon-chain/sync/initial-sync/round_robin_test.go index f92ef621ec59..fd137c06983b 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -1,6 +1,7 @@ package initialsync import ( + "context" "fmt" "reflect" "testing" @@ -8,6 +9,9 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/prysmaticlabs/go-ssz" + dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/beacon-chain/sync" @@ -15,17 +19,22 @@ import ( p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/roughtime" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/sirupsen/logrus" ) +var rootCache map[uint64][32]byte +var parentSlotCache map[uint64]uint64 + type peerData struct { blocks []uint64 // slots that peer has blocks finalizedEpoch uint64 headSlot uint64 failureSlots []uint64 // slots at which the peer will return an error + forkedPeer bool } func init() { @@ -194,25 +203,66 @@ func TestRoundRobinSync(t *testing.T) { }, }, }, + { + name: "Multiple peers with missing parent blocks", + currentSlot: 320, // 5 epochs + expectedBlockSlots: makeSequence(1, 320), + peers: []*peerData{ + { + blocks: makeSequence(1, 320), + finalizedEpoch: 4, + headSlot: 320, + }, + { + blocks: append(makeSequence(1, 6), makeSequence(161, 165)...), + finalizedEpoch: 4, + headSlot: 320, + forkedPeer: true, + }, + { + blocks: makeSequence(1, 320), + finalizedEpoch: 4, + headSlot: 320, + }, + { + blocks: makeSequence(1, 320), + finalizedEpoch: 4, + headSlot: 320, + }, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + initializeRootCache(tt.expectedBlockSlots, t) peerstatus.Clear() p := p2pt.NewTestP2P(t) + beaconDB := dbtest.SetupDB(t) + connectPeers(t, p, tt.peers) + genesisRoot := rootCache[0] + + err := beaconDB.SaveBlock(context.Background(), ð.BeaconBlock{ + Slot: 0, + }) + if err != nil { + t.Fatal(err) + } mc := &mock.ChainService{ State: &p2ppb.BeaconState{}, + Root: genesisRoot[:], + DB: beaconDB, } // no-op mock s := &InitialSync{ chain: mc, p2p: p, + db: beaconDB, synced: false, chainStarted: true, } - if err := s.roundRobinSync(makeGenesisTime(tt.currentSlot)); err != nil { t.Error(err) } @@ -229,6 +279,7 @@ func TestRoundRobinSync(t *testing.T) { if missing := sliceutil.NotUint64(sliceutil.IntersectionUint64(tt.expectedBlockSlots, receivedBlockSlots), tt.expectedBlockSlots); len(missing) > 0 { t.Errorf("Missing blocks at slots %v", missing) } + dbtest.TeardownDB(t, beaconDB) }) } } @@ -273,7 +324,19 @@ func connectPeers(t *testing.T, host *p2pt.TestP2P, data []*peerData) { if (slot-req.StartSlot)%req.Step != 0 { continue } - ret = append(ret, ð.BeaconBlock{Slot: slot}) + parentRoot := rootCache[parentSlotCache[slot]] + blk := ð.BeaconBlock{ + Slot: slot, + ParentRoot: parentRoot[:], + } + // If forked peer, give a different parent root. + if datum.forkedPeer { + newRoot := hashutil.Hash(parentRoot[:]) + blk.ParentRoot = newRoot[:] + } + ret = append(ret, blk) + currRoot, _ := ssz.SigningRoot(blk) + logrus.Infof("block with slot %d , signing root %#x and parent root %#x", slot, currRoot, parentRoot) } if uint64(len(ret)) > req.Count { @@ -325,6 +388,34 @@ func makeSequence(start, end uint64) []uint64 { return seq } +func initializeRootCache(reqSlots []uint64, t *testing.T) { + rootCache = make(map[uint64][32]byte) + parentSlotCache = make(map[uint64]uint64) + parentSlot := uint64(0) + genesisBlock := ð.BeaconBlock{ + Slot: 0, + } + genesisRoot, err := ssz.SigningRoot(genesisBlock) + if err != nil { + t.Fatal(err) + } + rootCache[0] = genesisRoot + parentRoot := genesisRoot + for _, slot := range reqSlots { + currentBlock := ð.BeaconBlock{ + Slot: slot, + ParentRoot: parentRoot[:], + } + parentRoot, err = ssz.SigningRoot(currentBlock) + if err != nil { + t.Fatal(err) + } + rootCache[slot] = parentRoot + parentSlotCache[slot] = parentSlot + parentSlot = slot + } +} + // sanity test on helper function func TestMakeSequence(t *testing.T) { got := makeSequence(3, 5) diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index 247af6f20c9b..d5fab504dc4a 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -39,6 +39,7 @@ type Config struct { type InitialSync struct { chain blockchainService p2p p2p.P2P + db db.Database synced bool chainStarted bool } @@ -49,6 +50,7 @@ func NewInitialSync(cfg *Config) *InitialSync { return &InitialSync{ chain: cfg.Chain, p2p: cfg.P2P, + db: cfg.DB, } } diff --git a/beacon-chain/sync/peerstatus/BUILD.bazel b/beacon-chain/sync/peerstatus/BUILD.bazel index 43abf404aad1..f62634254d60 100644 --- a/beacon-chain/sync/peerstatus/BUILD.bazel +++ b/beacon-chain/sync/peerstatus/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", @@ -14,3 +14,10 @@ go_library( "@com_github_libp2p_go_libp2p_core//peer:go_default_library", ], ) + +go_test( + name = "go_default_test", + srcs = ["peer_statuses_test.go"], + embed = [":go_default_library"], + deps = ["@com_github_libp2p_go_libp2p_core//peer:go_default_library"], +) diff --git a/beacon-chain/sync/peerstatus/peer_statuses.go b/beacon-chain/sync/peerstatus/peer_statuses.go index 95e07170c866..46501f2c8ea8 100644 --- a/beacon-chain/sync/peerstatus/peer_statuses.go +++ b/beacon-chain/sync/peerstatus/peer_statuses.go @@ -44,7 +44,6 @@ func Set(pid peer.ID, status *pb.Status) { status: status, lastUpdated: roughtime.Now(), } - failureCount[pid] = 0 } // Delete peer status from cache. Threadsafe. @@ -88,10 +87,10 @@ func IncreaseFailureCount(pid peer.ID) { defer lock.Unlock() count, ok := failureCount[pid] if !ok { + failureCount[pid] = 1 return } - count++ - failureCount[pid] = count + failureCount[pid] = count + 1 } // FailureCount returns the failure count for the particular peer. diff --git a/beacon-chain/sync/peerstatus/peer_statuses_test.go b/beacon-chain/sync/peerstatus/peer_statuses_test.go new file mode 100644 index 000000000000..a091cd5d5cd0 --- /dev/null +++ b/beacon-chain/sync/peerstatus/peer_statuses_test.go @@ -0,0 +1,26 @@ +package peerstatus + +import ( + "testing" + + "github.com/libp2p/go-libp2p-core/peer" +) + +func TestIncrementFailureCount(t *testing.T) { + testID := peer.ID("test") + IncreaseFailureCount(testID) + if FailureCount(testID) != 1 { + t.Errorf("Wanted failure count of %d but got %d", 1, FailureCount(testID)) + } +} + +func TestAboveFailureThreshold(t *testing.T) { + testID := peer.ID("test") + for i := 0; i <= maxFailureThreshold; i++ { + IncreaseFailureCount(testID) + } + if !IsBadPeer(testID) { + t.Errorf("Peer isnt considered as a bad peer despite crossing the failure threshold "+ + "with a failure count of %d", FailureCount(testID)) + } +} diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range.go b/beacon-chain/sync/rpc_beacon_blocks_by_range.go index eead13b5486b..9e487880ea59 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range.go @@ -6,12 +6,17 @@ import ( libp2pcore "github.com/libp2p/go-libp2p-core" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/shared/traceutil" + "go.opencensus.io/trace" ) // beaconBlocksByRangeRPCHandler looks up the request blocks from the database from a given start block. func (r *RegularSync) beaconBlocksByRangeRPCHandler(ctx context.Context, msg interface{}, stream libp2pcore.Stream) error { + ctx, span := trace.StartSpan(ctx, "sync.BeaconBlocksByRangeHandler") + defer span.End() defer stream.Close() ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() @@ -23,6 +28,14 @@ func (r *RegularSync) beaconBlocksByRangeRPCHandler(ctx context.Context, msg int startSlot := m.StartSlot endSlot := startSlot + (m.Step * m.Count) + span.AddAttributes( + trace.Int64Attribute("start", int64(startSlot)), + trace.Int64Attribute("end", int64(endSlot)), + trace.Int64Attribute("step", int64(m.Step)), + trace.Int64Attribute("count", int64(m.Count)), + trace.StringAttribute("peer", stream.Conn().RemotePeer().Pretty()), + ) + // TODO(3147): Update this with reasonable constraints. if endSlot-startSlot > 1000 || m.Step == 0 { resp, err := r.generateErrorResponse(responseCodeInvalidRequest, "invalid range or step") @@ -33,13 +46,12 @@ func (r *RegularSync) beaconBlocksByRangeRPCHandler(ctx context.Context, msg int log.WithError(err).Errorf("Failed to write to stream") } } - return errors.New("invalid range or step") + err = errors.New("invalid range or step") + traceutil.AnnotateError(span, err) + return err } - // TODO(3147): Only return blocks on the chain of the head root. - blks, err := r.db.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot)) - if err != nil { - log.WithError(err).Error("Failed to retrieve blocks") + var errResponse = func() { resp, err := r.generateErrorResponse(responseCodeServerError, genericError) if err != nil { log.WithError(err).Error("Failed to generate a response error") @@ -48,11 +60,32 @@ func (r *RegularSync) beaconBlocksByRangeRPCHandler(ctx context.Context, msg int log.WithError(err).Errorf("Failed to write to stream") } } - return err } - for _, blk := range blks { - if blk != nil && (blk.Slot-startSlot)%m.Step == 0 { + filter := filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot) + blks, err := r.db.Blocks(ctx, filter) + if err != nil { + log.WithError(err).Error("Failed to retrieve blocks") + errResponse() + traceutil.AnnotateError(span, err) + return err + } + roots, err := r.db.BlockRoots(ctx, filter) + if err != nil { + log.WithError(err).Error("Failed to retrieve block roots") + errResponse() + traceutil.AnnotateError(span, err) + return err + } + checkpoint, err := r.db.FinalizedCheckpoint(ctx) + if err != nil { + log.WithError(err).Error("Failed to retrieve finalized checkpoint") + errResponse() + traceutil.AnnotateError(span, err) + return err + } + for i, blk := range blks { + if blk != nil && (blk.Slot-startSlot)%m.Step == 0 && (blk.Slot > helpers.StartSlot(checkpoint.Epoch+1) || r.db.IsFinalizedBlock(ctx, roots[i])) { if err := r.chunkWriter(stream, blk); err != nil { log.WithError(err).Error("Failed to send a chunked response") return err diff --git a/beacon-chain/sync/rpc_status.go b/beacon-chain/sync/rpc_status.go index 95e74e99211c..9f0c31ea3926 100644 --- a/beacon-chain/sync/rpc_status.go +++ b/beacon-chain/sync/rpc_status.go @@ -45,7 +45,7 @@ func (r *RegularSync) sendRPCStatusRequest(ctx context.Context, id peer.ID) erro defer cancel() resp := &pb.Status{ - HeadForkVersion: params.BeaconConfig().GenesisForkVersion, + HeadForkVersion: r.chain.CurrentFork().CurrentVersion, FinalizedRoot: r.chain.FinalizedCheckpt().Root, FinalizedEpoch: r.chain.FinalizedCheckpt().Epoch, HeadRoot: r.chain.HeadRoot(), @@ -62,6 +62,7 @@ func (r *RegularSync) sendRPCStatusRequest(ctx context.Context, id peer.ID) erro } if code != 0 { + peerstatus.IncreaseFailureCount(stream.Conn().RemotePeer()) return errors.New(errMsg) } @@ -117,7 +118,7 @@ func (r *RegularSync) statusRPCHandler(ctx context.Context, msg interface{}, str } resp := &pb.Status{ - HeadForkVersion: params.BeaconConfig().GenesisForkVersion, + HeadForkVersion: r.chain.CurrentFork().CurrentVersion, FinalizedRoot: r.chain.FinalizedCheckpt().Root, FinalizedEpoch: r.chain.FinalizedCheckpt().Epoch, HeadRoot: r.chain.HeadRoot(), diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index 581365da39c6..71d2ae28e146 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -112,6 +112,10 @@ func TestHelloRPCHandler_ReturnsHelloMessage(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], + Fork: &pb.Fork{ + PreviousVersion: params.BeaconConfig().GenesisForkVersion, + CurrentVersion: params.BeaconConfig().GenesisForkVersion, + }, }, } @@ -165,6 +169,10 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { chain: &mock.ChainService{ State: &pb.BeaconState{Slot: 5}, FinalizedCheckPoint: ðpb.Checkpoint{}, + Fork: &pb.Fork{ + PreviousVersion: params.BeaconConfig().GenesisForkVersion, + CurrentVersion: params.BeaconConfig().GenesisForkVersion, + }, }, ctx: context.Background(), } @@ -250,6 +258,10 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], + Fork: &pb.Fork{ + PreviousVersion: params.BeaconConfig().GenesisForkVersion, + CurrentVersion: params.BeaconConfig().GenesisForkVersion, + }, }, ctx: context.Background(), } @@ -318,6 +330,10 @@ func TestStatusRPCRequest_BadPeerHandshake(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], + Fork: &pb.Fork{ + PreviousVersion: params.BeaconConfig().GenesisForkVersion, + CurrentVersion: params.BeaconConfig().GenesisForkVersion, + }, }, ctx: context.Background(), } diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index ef274174460f..5d3d490c8a25 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -31,6 +31,7 @@ type blockchainService interface { blockchain.BlockReceiver blockchain.HeadFetcher blockchain.FinalizationFetcher + blockchain.ForkFetcher blockchain.AttestationReceiver blockchain.ChainFeeds blockchain.GenesisTimeFetcher diff --git a/beacon-chain/sync/validate_beacon_attestation.go b/beacon-chain/sync/validate_beacon_attestation.go index 35a57adb9007..d819b18ca5dc 100644 --- a/beacon-chain/sync/validate_beacon_attestation.go +++ b/beacon-chain/sync/validate_beacon_attestation.go @@ -11,8 +11,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/traceutil" + "go.opencensus.io/trace" ) +var errPointsToBlockNotInDatabase = errors.New("attestation points to a block which is not in the database") + // validateBeaconAttestation validates that the block being voted for passes validation before forwarding to the // network. func (r *RegularSync) validateBeaconAttestation(ctx context.Context, msg proto.Message, p p2p.Broadcaster, fromSelf bool) (bool, error) { @@ -22,6 +26,9 @@ func (r *RegularSync) validateBeaconAttestation(ctx context.Context, msg proto.M return false, nil } + ctx, span := trace.StartSpan(ctx, "sync.validateBeaconAttestation") + defer span.End() + // TODO(1332): Add blocks.VerifyAttestation before processing further. // Discussion: https://github.com/ethereum/eth2.0-specs/issues/1332 @@ -32,12 +39,18 @@ func (r *RegularSync) validateBeaconAttestation(ctx context.Context, msg proto.M return false, errors.Wrap(err, "could not hash attestation") } + span.AddAttributes( + trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", att.Data.BeaconBlockRoot)), + trace.StringAttribute("attRoot", fmt.Sprintf("%#x", attRoot)), + ) + // Only valid blocks are saved in the database. if !r.db.HasBlock(ctx, bytesutil.ToBytes32(att.Data.BeaconBlockRoot)) { log.WithField( "blockRoot", fmt.Sprintf("%#x", att.Data.BeaconBlockRoot), - ).Debug("Ignored incoming attestation that points to a block which is not in the database") + ).WithError(errPointsToBlockNotInDatabase).Debug("Ignored incoming attestation that points to a block which is not in the database") + traceutil.AnnotateError(span, errPointsToBlockNotInDatabase) return false, nil } @@ -53,6 +66,7 @@ func (r *RegularSync) validateBeaconAttestation(ctx context.Context, msg proto.M if err := p.Broadcast(ctx, msg); err != nil { log.WithError(err).Error("Failed to broadcast message") + traceutil.AnnotateError(span, err) } return true, nil } diff --git a/beacon-chain/usage.go b/beacon-chain/usage.go index da9b0054706d..da5055199cff 100644 --- a/beacon-chain/usage.go +++ b/beacon-chain/usage.go @@ -58,6 +58,7 @@ var appHelpFlagGroups = []flagGroup{ cmd.MonitoringPortFlag, cmd.DisableMonitoringFlag, cmd.MaxGoroutines, + cmd.ForceClearDB, cmd.ClearDB, }, }, diff --git a/proto/beacon/db/BUILD.bazel b/proto/beacon/db/BUILD.bazel index 1402ac407137..c25efa7f31e5 100644 --- a/proto/beacon/db/BUILD.bazel +++ b/proto/beacon/db/BUILD.bazel @@ -4,7 +4,10 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") proto_library( name = "db_proto", - srcs = ["attestation_container.proto"], + srcs = [ + "attestation_container.proto", + "finalized_block_root_container.proto", + ], visibility = ["//visibility:public"], deps = [ "//proto/eth/v1alpha1:v1alpha1_proto", diff --git a/proto/beacon/db/finalized_block_root_container.pb.go b/proto/beacon/db/finalized_block_root_container.pb.go index a7eae5c80789..19dcaa284980 100755 --- a/proto/beacon/db/finalized_block_root_container.pb.go +++ b/proto/beacon/db/finalized_block_root_container.pb.go @@ -5,9 +5,16 @@ package db import ( fmt "fmt" +<<<<<<< HEAD proto "github.com/gogo/protobuf/proto" io "io" math "math" +======= + io "io" + math "math" + + proto "github.com/gogo/protobuf/proto" +>>>>>>> 9c1e3c260a9be24657336a9c3c71c9f5ad776dd6 ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/db/finalized_block_root_container.proto b/proto/beacon/db/finalized_block_root_container.proto new file mode 100644 index 000000000000..9837afe28166 --- /dev/null +++ b/proto/beacon/db/finalized_block_root_container.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package prysm.beacon.db; + +option go_package = "github.com/prysmaticlabs/prysm/proto/beacon/db"; + +message FinalizedBlockRootContainer { + bytes parent_root = 1; + bytes child_root = 2; +} diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 22848825a0d9..94fc0a2ee479 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -698,6 +698,8 @@ type GetValidatorBalancesRequest struct { QueryFilter isGetValidatorBalancesRequest_QueryFilter `protobuf_oneof:"query_filter"` PublicKeys [][]byte `protobuf:"bytes,3,rep,name=public_keys,json=publicKeys,proto3" json:"public_keys,omitempty" ssz-size:"?,48"` Indices []uint64 `protobuf:"varint,4,rep,packed,name=indices,proto3" json:"indices,omitempty"` + PageSize int32 `protobuf:"varint,5,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + PageToken string `protobuf:"bytes,6,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -787,6 +789,20 @@ func (m *GetValidatorBalancesRequest) GetIndices() []uint64 { return nil } +func (m *GetValidatorBalancesRequest) GetPageSize() int32 { + if m != nil { + return m.PageSize + } + return 0 +} + +func (m *GetValidatorBalancesRequest) GetPageToken() string { + if m != nil { + return m.PageToken + } + return "" +} + // XXX_OneofFuncs is for the internal use of the proto package. func (*GetValidatorBalancesRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _GetValidatorBalancesRequest_OneofMarshaler, _GetValidatorBalancesRequest_OneofUnmarshaler, _GetValidatorBalancesRequest_OneofSizer, []interface{}{ @@ -856,7 +872,10 @@ func _GetValidatorBalancesRequest_OneofSizer(msg proto.Message) (n int) { } type ValidatorBalances struct { - Balances []*ValidatorBalances_Balance `protobuf:"bytes,1,rep,name=balances,proto3" json:"balances,omitempty"` + Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` + Balances []*ValidatorBalances_Balance `protobuf:"bytes,2,rep,name=balances,proto3" json:"balances,omitempty"` + NextPageToken string `protobuf:"bytes,3,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` + TotalSize int32 `protobuf:"varint,4,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -895,6 +914,13 @@ func (m *ValidatorBalances) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorBalances proto.InternalMessageInfo +func (m *ValidatorBalances) GetEpoch() uint64 { + if m != nil { + return m.Epoch + } + return 0 +} + func (m *ValidatorBalances) GetBalances() []*ValidatorBalances_Balance { if m != nil { return m.Balances @@ -902,6 +928,20 @@ func (m *ValidatorBalances) GetBalances() []*ValidatorBalances_Balance { return nil } +func (m *ValidatorBalances) GetNextPageToken() string { + if m != nil { + return m.NextPageToken + } + return "" +} + +func (m *ValidatorBalances) GetTotalSize() int32 { + if m != nil { + return m.TotalSize + } + return 0 +} + type ValidatorBalances_Balance struct { PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" ssz-size:"48"` Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` @@ -2109,6 +2149,7 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ +<<<<<<< HEAD // 1605 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xbd, 0x6f, 0x1b, 0xc7, 0x12, 0xf7, 0x89, 0xa4, 0x3e, 0x86, 0xfa, 0x5c, 0x49, 0x36, 0xdf, 0xc9, 0x92, 0xe8, 0x93, 0x25, @@ -2211,6 +2252,110 @@ var fileDescriptor_678c88b69c3c78d4 = []byte{ 0x6b, 0x1e, 0xb1, 0x86, 0xc5, 0x89, 0xed, 0x58, 0x15, 0x26, 0x47, 0xa5, 0x93, 0xbf, 0x28, 0xff, 0x8d, 0x79, 0xbd, 0x32, 0x2c, 0xe4, 0xd7, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x35, 0x6f, 0xbd, 0x16, 0xb8, 0x15, 0x00, 0x00, +======= + // 1601 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, + 0x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 0x56, 0x21, 0x53, 0xd2, 0xca, 0xb9, 0x9d, 0x33, 0x46, 0xde, + 0x97, 0xde, 0xf7, 0x84, 0xe8, 0x22, 0xa8, 0xa1, 0x0f, 0x95, 0x55, 0x50, 0xe0, 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, 0x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b1, 0xa0, 0xa6, 0x85, 0xeb, 0xdc, 0x1f, 0x55, 0x4f, 0xfe, 0x2e, 0xfd, 0x17, 0x11, 0xad, 0xfa, + 0xa8, 0x94, 0xdf, 0xf8, 0x33, 0x00, 0x00, 0xff, 0xff, 0xea, 0x59, 0x36, 0xfb, 0x44, 0x16, 0x00, + 0x00, +>>>>>>> 9c1e3c260a9be24657336a9c3c71c9f5ad776dd6 } // Reference imports to suppress errors if they are not otherwise used. @@ -2938,6 +3083,17 @@ func (m *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintBeaconChain(dAtA, i, uint64(j4)) i += copy(dAtA[i:], dAtA5[:j4]) } + if m.PageSize != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.PageSize)) + } + if len(m.PageToken) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.PageToken))) + i += copy(dAtA[i:], m.PageToken) + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -2978,9 +3134,14 @@ func (m *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Epoch != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.Epoch)) + } if len(m.Balances) > 0 { for _, msg := range m.Balances { - dAtA[i] = 0xa + dAtA[i] = 0x12 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) @@ -2990,6 +3151,17 @@ func (m *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { i += n } } + if len(m.NextPageToken) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.NextPageToken))) + i += copy(dAtA[i:], m.NextPageToken) + } + if m.TotalSize != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.TotalSize)) + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -3861,6 +4033,13 @@ func (m *GetValidatorBalancesRequest) Size() (n int) { } n += 1 + sovBeaconChain(uint64(l)) + l } + if m.PageSize != 0 { + n += 1 + sovBeaconChain(uint64(m.PageSize)) + } + l = len(m.PageToken) + if l > 0 { + n += 1 + l + sovBeaconChain(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -3891,12 +4070,22 @@ func (m *ValidatorBalances) Size() (n int) { } var l int _ = l + if m.Epoch != 0 { + n += 1 + sovBeaconChain(uint64(m.Epoch)) + } if len(m.Balances) > 0 { for _, e := range m.Balances { l = e.Size() n += 1 + l + sovBeaconChain(uint64(l)) } } + l = len(m.NextPageToken) + if l > 0 { + n += 1 + l + sovBeaconChain(uint64(l)) + } + if m.TotalSize != 0 { + n += 1 + sovBeaconChain(uint64(m.TotalSize)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -5455,6 +5644,57 @@ func (m *GetValidatorBalancesRequest) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field Indices", wireType) } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PageSize", wireType) + } + m.PageSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PageSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PageToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PageToken = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBeaconChain(dAtA[iNdEx:]) @@ -5510,6 +5750,25 @@ func (m *ValidatorBalances) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) } @@ -5543,6 +5802,57 @@ func (m *ValidatorBalances) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextPageToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextPageToken = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSize", wireType) + } + m.TotalSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipBeaconChain(dAtA[iNdEx:]) diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index 07cf364c9ea5..fec46f308e2b 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -251,9 +251,21 @@ message GetValidatorBalancesRequest { // Validator indices to filter validators for the given epoch. repeated uint64 indices = 4; + + // The maximum number of Validators to return in the response. + // This field is optional. + int32 page_size = 5; + + // A pagination token returned from a previous call to `GetValidators` + // that indicates where this listing should continue from. + // This field is optional. + string page_token = 6; } message ValidatorBalances { + // Epoch which the state was considered to determine the validator balances. + uint64 epoch = 1; + message Balance { // Validator's 48 byte BLS public key. bytes public_key = 1 [(gogoproto.moretags) = "ssz-size:\"48\""]; @@ -265,7 +277,14 @@ message ValidatorBalances { uint64 balance = 3; } - repeated Balance balances = 1; + repeated Balance balances = 2; + + // A pagination token returned from a previous call to `GetListValidatorBalances` + // that indicates from where listing should continue. + string next_page_token = 3; + + // Total count of Validators matching the request filter. + int32 total_size = 4; } message GetValidatorsRequest { diff --git a/proto/eth/v1alpha1/validator.pb.go b/proto/eth/v1alpha1/validator.pb.go index 160093ed7ac6..d4f83587b8da 100755 --- a/proto/eth/v1alpha1/validator.pb.go +++ b/proto/eth/v1alpha1/validator.pb.go @@ -497,66 +497,66 @@ func init() { func init() { proto.RegisterFile("proto/eth/v1alpha1/validator.proto", fileDescriptor_86a2b3961d336368) } var fileDescriptor_86a2b3961d336368 = []byte{ - // 935 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0xb5, 0x4e, 0xd2, 0x26, 0x13, 0xa7, 0x25, 0x93, 0x34, 0x18, 0xd3, 0x26, 0xd6, 0x36, - 0xae, 0x02, 0xc5, 0xbb, 0x34, 0x2d, 0x08, 0x85, 0x03, 0xe0, 0x34, 0x0a, 0x12, 0x12, 0x54, 0x5b, - 0x89, 0x43, 0x39, 0xac, 0x66, 0x77, 0x9f, 0xbd, 0xa3, 0x8c, 0x3d, 0xdb, 0x9d, 0xb1, 0x8b, 0x23, - 0x21, 0x21, 0xbe, 0x02, 0x07, 0x38, 0xf4, 0xc2, 0x37, 0xe1, 0xc8, 0x11, 0x89, 0x7b, 0x84, 0x22, - 0x3e, 0x41, 0x3e, 0x01, 0xda, 0x37, 0xbb, 0xde, 0x35, 0xd8, 0x6a, 0x6e, 0x3b, 0xef, 0xfd, 0xe6, - 0xbd, 0xff, 0xbe, 0x79, 0xf3, 0x86, 0xd8, 0x49, 0x2a, 0xb5, 0x74, 0x41, 0xc7, 0xee, 0xf8, 0x11, - 0x13, 0x49, 0xcc, 0x1e, 0xb9, 0x63, 0x26, 0x78, 0xc4, 0xb4, 0x4c, 0x1d, 0x74, 0xd2, 0x3b, 0xa0, - 0x63, 0x48, 0x61, 0x34, 0x70, 0x40, 0xc7, 0x4e, 0x81, 0x35, 0x3b, 0x7d, 0xae, 0xe3, 0x51, 0xe0, - 0x84, 0x72, 0xe0, 0xf6, 0x65, 0x5f, 0xba, 0x48, 0x07, 0xa3, 0x1e, 0xae, 0x4c, 0xdc, 0xec, 0xcb, - 0x44, 0x69, 0xde, 0xed, 0x4b, 0xd9, 0x17, 0xe0, 0xb2, 0x84, 0xbb, 0x6c, 0x38, 0x94, 0x9a, 0x69, - 0x2e, 0x87, 0x2a, 0xf7, 0xbe, 0x9b, 0x7b, 0xa7, 0x31, 0x60, 0x90, 0xe8, 0x49, 0xee, 0x6c, 0xcf, - 0x11, 0x19, 0x00, 0x0b, 0xe5, 0xd0, 0x0f, 0x84, 0x0c, 0xcf, 0x72, 0x6c, 0x7f, 0x0e, 0xc6, 0xb4, - 0x06, 0x65, 0x52, 0x19, 0xca, 0xfe, 0x8e, 0x6c, 0x3c, 0x1d, 0x69, 0x0e, 0xca, 0x83, 0x97, 0x23, - 0x50, 0x9a, 0x6e, 0x93, 0x15, 0x48, 0x64, 0x18, 0x37, 0xac, 0x96, 0x75, 0xb0, 0xec, 0x99, 0x05, - 0x7d, 0x42, 0xd6, 0x93, 0x51, 0x20, 0x78, 0xe8, 0x9f, 0xc1, 0x44, 0x35, 0x6a, 0xad, 0xa5, 0x83, - 0x7a, 0x77, 0xeb, 0xea, 0x62, 0xef, 0xb6, 0x52, 0xe7, 0x1d, 0xc5, 0xcf, 0xe1, 0xc8, 0xfe, 0xec, - 0x83, 0x27, 0x9f, 0xd8, 0x1e, 0x31, 0xdc, 0x57, 0x30, 0x51, 0xf6, 0x2f, 0x35, 0x72, 0xab, 0x88, - 0xae, 0x12, 0x39, 0x54, 0x40, 0xbb, 0xe4, 0x46, 0x84, 0x96, 0x86, 0xd5, 0x5a, 0x3a, 0x58, 0x3f, - 0x7c, 0xdf, 0x99, 0x5b, 0x4e, 0x67, 0x76, 0x5b, 0xb6, 0x9c, 0x78, 0xf9, 0xce, 0xe6, 0xef, 0x16, - 0x59, 0xce, 0x0c, 0xf4, 0x43, 0x42, 0x4a, 0x55, 0x28, 0xb8, 0xde, 0xdd, 0xbc, 0xba, 0xd8, 0xdb, - 0x28, 0x45, 0x65, 0x92, 0xd6, 0xa6, 0x92, 0xe8, 0x7b, 0xe4, 0xad, 0x4a, 0x0d, 0x7c, 0x25, 0xa4, - 0x6e, 0xd4, 0xf0, 0x47, 0x6f, 0x57, 0xec, 0xcf, 0x85, 0xd4, 0xf4, 0x21, 0xd9, 0x9c, 0x41, 0x63, - 0x96, 0x46, 0x8d, 0x25, 0x64, 0xab, 0x31, 0x9e, 0x67, 0x76, 0xea, 0x90, 0x2d, 0xac, 0xbd, 0x9f, - 0xa4, 0x32, 0x91, 0x8a, 0x09, 0x13, 0x7a, 0x19, 0xf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xf8, 0xe9, 0xaf, 0x7f, 0x7e, 0xae, 0xb5, 0xe8, 0xee, 0x82, - 0x69, 0xef, 0x9a, 0x61, 0x43, 0xcf, 0xc9, 0xea, 0x29, 0x68, 0xbc, 0xac, 0xf4, 0xfe, 0x82, 0xd0, - 0xd5, 0xab, 0xdc, 0xb4, 0x17, 0x41, 0xf8, 0x7f, 0x88, 0xda, 0x6d, 0x4c, 0xbe, 0x47, 0xef, 0x2d, - 0x4a, 0x8e, 0x13, 0x83, 0xbe, 0x24, 0x75, 0x33, 0x35, 0xc0, 0xe4, 0xbf, 0x46, 0xe8, 0xe6, 0x8e, - 0x63, 0xde, 0x0e, 0xa7, 0x78, 0x3b, 0x9c, 0x93, 0xec, 0xed, 0x28, 0x52, 0xda, 0x6f, 0x48, 0xf9, - 0xab, 0x45, 0xe8, 0x29, 0xe8, 0xff, 0x0c, 0x10, 0xda, 0x59, 0x90, 0x79, 0xfe, 0xa0, 0x69, 0x3e, - 0xb8, 0x1e, 0x6e, 0x3f, 0x44, 0x51, 0x6d, 0x7a, 0x7f, 0x91, 0xa8, 0xca, 0xa0, 0xa5, 0x3f, 0x10, - 0x9a, 0x57, 0xa3, 0x12, 0x66, 0x61, 0x4d, 0x2a, 0xcc, 0xc2, 0x9a, 0xe4, 0xe9, 0xed, 0xeb, 0xa4, - 0xef, 0x1e, 0xff, 0x71, 0xb9, 0x6b, 0xfd, 0x79, 0xb9, 0x6b, 0xfd, 0x7d, 0xb9, 0x6b, 0xbd, 0xf8, - 0xa8, 0xf2, 0xdc, 0x27, 0xe9, 0x44, 0x0d, 0x98, 0xe6, 0xa1, 0x60, 0x81, 0x32, 0x2b, 0xf7, 0xff, - 0x8f, 0xef, 0xa7, 0xa0, 0xe3, 0xe0, 0x06, 0xda, 0x1f, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x3a, - 0xed, 0xda, 0x36, 0x69, 0x08, 0x00, 0x00, + // 934 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b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0xe3, 0x60, 0x15, 0xed, 0x8f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xcf, + 0xae, 0x14, 0x65, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -574,7 +574,7 @@ type BeaconNodeValidatorClient interface { GetDuties(ctx context.Context, in *DutiesRequest, opts ...grpc.CallOption) (*DutiesResponse, error) GetBlock(ctx context.Context, in *BlockRequest, opts ...grpc.CallOption) (*BeaconBlock, error) ProposeBlock(ctx context.Context, in *BeaconBlock, opts ...grpc.CallOption) (*types.Empty, error) - GetAttestationData(ctx context.Context, in *AttestationDataRequest, opts ...grpc.CallOption) (*AttestationData, error) + GetAttestationData(ctx context.Context, in *AttestationDataRequest, opts ...grpc.CallOption) (*Attestation, error) ProposeAttestation(ctx context.Context, in *Attestation, opts ...grpc.CallOption) (*types.Empty, error) } @@ -613,8 +613,8 @@ func (c *beaconNodeValidatorClient) ProposeBlock(ctx context.Context, in *Beacon return out, nil } -func (c *beaconNodeValidatorClient) GetAttestationData(ctx context.Context, in *AttestationDataRequest, opts ...grpc.CallOption) (*AttestationData, error) { - out := new(AttestationData) +func (c *beaconNodeValidatorClient) GetAttestationData(ctx context.Context, in *AttestationDataRequest, opts ...grpc.CallOption) (*Attestation, error) { + out := new(Attestation) err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.BeaconNodeValidator/GetAttestationData", in, out, opts...) if err != nil { return nil, err @@ -636,7 +636,7 @@ type BeaconNodeValidatorServer interface { GetDuties(context.Context, *DutiesRequest) (*DutiesResponse, error) GetBlock(context.Context, *BlockRequest) (*BeaconBlock, error) ProposeBlock(context.Context, *BeaconBlock) (*types.Empty, error) - GetAttestationData(context.Context, *AttestationDataRequest) (*AttestationData, error) + GetAttestationData(context.Context, *AttestationDataRequest) (*Attestation, error) ProposeAttestation(context.Context, *Attestation) (*types.Empty, error) } diff --git a/proto/eth/v1alpha1/validator.proto b/proto/eth/v1alpha1/validator.proto index bc160de298db..8d3ee22da9c2 100644 --- a/proto/eth/v1alpha1/validator.proto +++ b/proto/eth/v1alpha1/validator.proto @@ -52,11 +52,11 @@ service BeaconNodeValidator { }; } - // Retrieves the latest valid attestation data to be attested on the beacon chain. + // Retrieves the latest valid attestation to a block on the beacon chain. // - // The server returns the latest valid attestation data which represents the correct vote - // for the head of the beacon chain, - rpc GetAttestationData(AttestationDataRequest) returns (AttestationData) { + // The server returns the latest valid attestation which represents the correct vote + // for the head of the beacon chain. + rpc GetAttestationData(AttestationDataRequest) returns (Attestation) { option (google.api.http) = { get: "/eth/v1alpha1/validator/attestation" }; diff --git a/scripts/interop_start.sh b/scripts/interop_start.sh index d7a34e70b8bc..4ca89e5272fb 100755 --- a/scripts/interop_start.sh +++ b/scripts/interop_start.sh @@ -17,6 +17,7 @@ IDENTITY="" # P2P private key PEERS="" # Comma separated list of peers GEN_STATE="" # filepath to ssz encoded state. PORT="8000" # port to serve p2p traffic +RPCPORT="8001" # port to serve rpc traffic YAML_KEY_FILE="" # Path to yaml keyfile as defined here: https://github.com/ethereum/eth2.0-pm/tree/master/interop/mocked_start # Constants @@ -28,7 +29,8 @@ usage() { echo "--peer=" echo "--num-validators=" echo "--gen-state=" - port "--port=" + echo "--port=" + echo "--rpcport=" } while [ "$1" != "" ]; @@ -53,6 +55,9 @@ do --port) PORT=$VALUE ;; + --rpcport) + RPCPORT=$VALUE + ;; --help) usage exit @@ -81,6 +86,7 @@ echo -n "$IDENTITY" > /tmp/id.key BEACON_FLAGS="--bootstrap-node= \ --deposit-contract=0xD775140349E6A5D12524C6ccc3d6A1d4519D4029 \ --p2p-port=$PORT \ + --grpc-gateway-port=$RPCPORT \ --peer=$PEERS \ --interop-genesis-state=$GEN_STATE \ --p2p-priv-key=/tmp/id.key \ diff --git a/scripts/start-beacon-chain.sh b/scripts/start-beacon-chain.sh index 5e6ba730ffa2..0c577603f87d 100755 --- a/scripts/start-beacon-chain.sh +++ b/scripts/start-beacon-chain.sh @@ -13,4 +13,4 @@ while test $# -gt 0; do esac done -bazel run //beacon-chain -- --clear-db --deposit-contract $DEPOSIT_CONTRACT --web3provider=wss://goerli.infura.io/ws/v3/be3fb7ed377c418087602876a40affa1 \ No newline at end of file +bazel run //beacon-chain -- --clear-db --deposit-contract $DEPOSIT_CONTRACT --web3provider=wss://goerli.infura.io/ws/v3/be3fb7ed377c418087602876a40affa1 diff --git a/shared/bls/BUILD.bazel b/shared/bls/BUILD.bazel index 719fa2e2f392..29d1b06a8ab5 100644 --- a/shared/bls/BUILD.bazel +++ b/shared/bls/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", - "//shared/params:go_default_library", "@com_github_karlseguin_ccache//:go_default_library", "@com_github_kilic_bls12-381//:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/shared/bls/bls.go b/shared/bls/bls.go index 076c1fecb183..5ad7044e133b 100644 --- a/shared/bls/bls.go +++ b/shared/bls/bls.go @@ -11,13 +11,11 @@ import ( "time" "github.com/karlseguin/ccache" + bls12 "github.com/kilic/bls12-381" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" - "github.com/prysmaticlabs/prysm/shared/params" - - bls12 "github.com/kilic/bls12-381" ) var pubkeyCache = ccache.New(ccache.Configure()) @@ -287,8 +285,7 @@ func Domain(domainType []byte, forkVersion []byte) uint64 { // """ // return Domain(domain_type + fork_version) func ComputeDomain(domainType []byte) uint64 { - // TODO(#3853): Hardcode the fork version to []byte{0,0,0,0} - return Domain(domainType, params.BeaconConfig().GenesisForkVersion) + return Domain(domainType, []byte{0, 0, 0, 0}) } // HashWithDomain hashes 32 byte message and uint64 domain parameters a Fp2 element diff --git a/shared/cmd/flags.go b/shared/cmd/flags.go index 21bca7ea8a58..2fd57f3d62ef 100644 --- a/shared/cmd/flags.go +++ b/shared/cmd/flags.go @@ -119,10 +119,15 @@ var ( Usage: "The encoding format of messages sent over the wire. The default is 0, which represents ssz", Value: "ssz", } - // ClearDB tells the beacon node to remove any previously stored data at the data directory. + // ForceClearDB removes any previously stored data at the data directory. + ForceClearDB = cli.BoolFlag{ + Name: "force-clear-db", + Usage: "Clear any previously stored data at the data directory", + } + // ClearDB prompts user to see if they want to remove any previously stored data at the data directory. ClearDB = cli.BoolFlag{ Name: "clear-db", - Usage: "Clears any previously stored data at the data directory", + Usage: "Prompt for clearing any previously stored data at the data directory", } // LogFormat specifies the log output format. LogFormat = cli.StringFlag{ diff --git a/shared/featureconfig/BUILD.bazel b/shared/featureconfig/BUILD.bazel index 68e7bccc3148..7e5a7fccc329 100644 --- a/shared/featureconfig/BUILD.bazel +++ b/shared/featureconfig/BUILD.bazel @@ -17,7 +17,10 @@ go_library( go_test( name = "go_default_test", size = "small", - srcs = ["config_test.go"], + srcs = [ + "config_test.go", + "flags_test.go", + ], embed = [":go_default_library"], deps = ["@com_github_urfave_cli//:go_default_library"], ) diff --git a/shared/featureconfig/config.go b/shared/featureconfig/config.go index 5c8fb5ccf074..9443f31b6d22 100644 --- a/shared/featureconfig/config.go +++ b/shared/featureconfig/config.go @@ -25,20 +25,26 @@ var log = logrus.WithField("prefix", "flags") // Flag is a struct to represent what features the client will perform on runtime. type Flag struct { - NoGenesisDelay bool // NoGenesisDelay when processing a chain start genesis event. + GenesisDelay bool // GenesisDelay when processing a chain start genesis event. MinimalConfig bool // MinimalConfig as defined in the spec. WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory. InitSyncNoVerify bool // InitSyncNoVerify when initial syncing w/o verifying block's contents. SkipBLSVerify bool // Skips BLS verification across the runtime. - EnableBackupWebhook bool // EnableBackupWebhook to allow database backups to trigger from monitoring port /db/backup - OptimizeProcessEpoch bool // OptimizeProcessEpoch to process epoch with optimizations by pre computing records + EnableBackupWebhook bool // EnableBackupWebhook to allow database backups to trigger from monitoring port /db/backup. + OptimizeProcessEpoch bool // OptimizeProcessEpoch to process epoch with optimizations by pre computing records. + Scatter bool // Scatter sequential processing by scattering it to multiple cores. PruneFinalizedStates bool // PruneFinalizedStates from the database. // Cache toggles. - EnableAttestationCache bool // EnableAttestationCache; see https://github.com/prysmaticlabs/prysm/issues/3106. - EnableEth1DataVoteCache bool // EnableEth1DataVoteCache; see https://github.com/prysmaticlabs/prysm/issues/3106. - EnableNewCache bool // EnableNewCache enables the node to use the new caching scheme. - EnableBLSPubkeyCache bool // EnableBLSPubkeyCache to improve wall time of PubkeyFromBytes. + EnableAttestationCache bool // EnableAttestationCache; see https://github.com/prysmaticlabs/prysm/issues/3106. + EnableEth1DataVoteCache bool // EnableEth1DataVoteCache; see https://github.com/prysmaticlabs/prysm/issues/3106. + EnableNewCache bool // EnableNewCache enables the node to use the new caching scheme. + EnableBLSPubkeyCache bool // EnableBLSPubkeyCache to improve wall time of PubkeyFromBytes. + EnableShuffledIndexCache bool // EnableShuffledIndexCache to cache expensive shuffled index computation. + EnableSkipSlotsCache bool // EnableSkipSlotsCache caches the state in skipped slots. + EnableCommitteeCache bool // EnableCommitteeCache to cache committee computation. + EnableActiveIndicesCache bool // EnableActiveIndicesCache. + EnableActiveCountCache bool // EnableActiveCountCache. } var featureConfig *Flag @@ -59,14 +65,15 @@ func Init(c *Flag) { // ConfigureBeaconChain sets the global config based // on what flags are enabled for the beacon-chain client. func ConfigureBeaconChain(ctx *cli.Context) { + complainOnDeprecatedFlags(ctx) cfg := &Flag{} if ctx.GlobalBool(MinimalConfigFlag.Name) { log.Warn("Using minimal config") cfg.MinimalConfig = true } - if ctx.GlobalBool(NoGenesisDelayFlag.Name) { + if ctx.GlobalBool(GenesisDelayFlag.Name) { log.Warn("Using non standard genesis delay. This may cause problems in a multi-node environment.") - cfg.NoGenesisDelay = true + cfg.GenesisDelay = true } if ctx.GlobalBool(writeSSZStateTransitionsFlag.Name) { log.Warn("Writing SSZ states and blocks after state transitions") @@ -104,16 +111,41 @@ func ConfigureBeaconChain(ctx *cli.Context) { log.Warn("Processing epoch with optimizations") cfg.OptimizeProcessEpoch = true } + if ctx.GlobalBool(Scatter.Name) { + log.Warn("Scattering sequential proceses to multiple cores") + cfg.Scatter = true + } if ctx.GlobalBool(pruneFinalizedStatesFlag.Name) { log.Warn("Enabled pruning old finalized states from database.") cfg.PruneFinalizedStates = true } + if ctx.GlobalBool(enableShuffledIndexCache.Name) { + log.Warn("Enabled shuffled index cache.") + cfg.EnableShuffledIndexCache = true + } + if ctx.GlobalBool(enableSkipSlotsCache.Name) { + log.Warn("Enabled skip slots cache.") + cfg.EnableSkipSlotsCache = true + } + if ctx.GlobalBool(enableCommitteeCacheFlag.Name) { + log.Warn("Enabled committee cache.") + cfg.EnableCommitteeCache = true + } + if ctx.GlobalBool(enableActiveIndicesCacheFlag.Name) { + log.Warn("Enabled active indices cache.") + cfg.EnableActiveIndicesCache = true + } + if ctx.GlobalBool(enableActiveCountCacheFlag.Name) { + log.Warn("Enabled active count cache.") + cfg.EnableActiveCountCache = true + } Init(cfg) } // ConfigureValidator sets the global config based // on what flags are enabled for the validator client. func ConfigureValidator(ctx *cli.Context) { + complainOnDeprecatedFlags(ctx) cfg := &Flag{} if ctx.GlobalBool(MinimalConfigFlag.Name) { log.Warn("Using minimal config") @@ -121,3 +153,11 @@ func ConfigureValidator(ctx *cli.Context) { } Init(cfg) } + +func complainOnDeprecatedFlags(ctx *cli.Context) { + for _, f := range deprecatedFlags { + if ctx.IsSet(f.GetName()) { + log.Errorf("%s is deprecated and has no effect. Do not use this flag, it will be deleted soon.", f.GetName()) + } + } +} diff --git a/shared/featureconfig/config_test.go b/shared/featureconfig/config_test.go index 87dacaf75f4c..85720593df4f 100644 --- a/shared/featureconfig/config_test.go +++ b/shared/featureconfig/config_test.go @@ -10,21 +10,21 @@ import ( func TestInitFeatureConfig(t *testing.T) { cfg := &featureconfig.Flag{ - NoGenesisDelay: true, + GenesisDelay: true, } featureconfig.Init(cfg) - if c := featureconfig.Get(); !c.NoGenesisDelay { - t.Errorf("NoGenesisDelay in FeatureFlags incorrect. Wanted true, got false") + if c := featureconfig.Get(); !c.GenesisDelay { + t.Errorf("GenesisDelay in FeatureFlags incorrect. Wanted true, got false") } } func TestConfigureBeaconConfig(t *testing.T) { app := cli.NewApp() set := flag.NewFlagSet("test", 0) - set.Bool(featureconfig.NoGenesisDelayFlag.Name, true, "enable attestation verification") + set.Bool(featureconfig.GenesisDelayFlag.Name, true, "enable attestation verification") context := cli.NewContext(app, set, nil) featureconfig.ConfigureBeaconChain(context) - if c := featureconfig.Get(); !c.NoGenesisDelay { - t.Errorf("NoGenesisDelay in FeatureFlags incorrect. Wanted true, got false") + if c := featureconfig.Get(); !c.GenesisDelay { + t.Errorf("GenesisDelay in FeatureFlags incorrect. Wanted true, got false") } } diff --git a/shared/featureconfig/flags.go b/shared/featureconfig/flags.go index d4472addf67c..ecf43ec0ab00 100644 --- a/shared/featureconfig/flags.go +++ b/shared/featureconfig/flags.go @@ -5,10 +5,10 @@ import ( ) var ( - // NoGenesisDelayFlag disables the standard genesis delay. - NoGenesisDelayFlag = cli.BoolFlag{ - Name: "no-genesis-delay", - Usage: "Process genesis event 30s after the ETH1 block time, rather than wait to midnight of the next day.", + // GenesisDelayFlag disables the standard genesis delay. + GenesisDelayFlag = cli.BoolFlag{ + Name: "genesis-delay", + Usage: "Wait and process the genesis event at the midnight of the next day rather than 30s after the ETH1 block time of the chainstart triggering deposit", } // MinimalConfigFlag enables the minimal configuration. MinimalConfigFlag = cli.BoolFlag{ @@ -29,6 +29,22 @@ var ( Name: "enable-eth1-data-vote-cache", Usage: "Enable unsafe cache mechanism. See https://github.com/prysmaticlabs/prysm/issues/3106", } + enableShuffledIndexCache = cli.BoolFlag{ + Name: "enable-shuffled-index-cache", + Usage: "Enable unsafe cache mechanism. See https://github.com/prysmaticlabs/prysm/issues/3106", + } + enableCommitteeCacheFlag = cli.BoolFlag{ + Name: "enable-committee-cache", + Usage: "Enable unsafe cache mechanism. See https://github.com/prysmaticlabs/prysm/issues/3106", + } + enableActiveIndicesCacheFlag = cli.BoolFlag{ + Name: "enable-active-indices-cache", + Usage: "Enable unsafe cache mechanism. See https://github.com/prysmaticlabs/prysm/issues/3106", + } + enableActiveCountCacheFlag = cli.BoolFlag{ + Name: "enable-active-count-cache", + Usage: "Enable unsafe cache mechanism. See https://github.com/prysmaticlabs/prysm/issues/3106", + } // InitSyncNoVerifyFlag enables the initial sync no verify configuration. InitSyncNoVerifyFlag = cli.BoolFlag{ Name: "init-sync-no-verify", @@ -57,20 +73,51 @@ var ( Name: "optimize-process-epoch", Usage: "Process epoch with optimizations", } + // Scatter scatters sequential processes to multiple cores + Scatter = cli.BoolFlag{ + Name: "scatter", + Usage: "Scatter sequential processes to multiple cores", + } pruneFinalizedStatesFlag = cli.BoolFlag{ Name: "prune-finalized-states", Usage: "Delete old states from the database after reaching new finalized checkpoint", } + // enableSkipSlotsCache enables the skips slots lru cache to be used in runtime. + enableSkipSlotsCache = cli.BoolFlag{ + Name: "enable-skip-slots-cache", + Usage: "Enables the skip slot cache to be used in the event of skipped slots.", + } ) +// Deprecated flags list. +const deprecatedUsage = "DEPRECATED. DO NOT USE." + +var ( + deprecatedNoGenesisDelayFlag = cli.BoolFlag{ + Name: "no-genesis-delay", + Usage: deprecatedUsage, + Hidden: true, + } + deprecatedEnableFinalizedBlockRootIndexFlag = cli.BoolFlag{ + Name: "enable-finalized-block-root-index", + Usage: deprecatedUsage, + Hidden: true, + } +) + +var deprecatedFlags = []cli.Flag{ + deprecatedNoGenesisDelayFlag, + deprecatedEnableFinalizedBlockRootIndexFlag, +} + // ValidatorFlags contains a list of all the feature flags that apply to the validator client. -var ValidatorFlags = []cli.Flag{ +var ValidatorFlags = append(deprecatedFlags, []cli.Flag{ MinimalConfigFlag, -} +}...) // BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client. -var BeaconChainFlags = []cli.Flag{ - NoGenesisDelayFlag, +var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{ + GenesisDelayFlag, MinimalConfigFlag, writeSSZStateTransitionsFlag, EnableAttestationCacheFlag, @@ -79,7 +126,13 @@ var BeaconChainFlags = []cli.Flag{ NewCacheFlag, SkipBLSVerifyFlag, OptimizeProcessEpoch, + Scatter, enableBackupWebhookFlag, enableBLSPubkeyCacheFlag, + enableShuffledIndexCache, + enableCommitteeCacheFlag, + enableActiveIndicesCacheFlag, + enableActiveCountCacheFlag, pruneFinalizedStatesFlag, -} + enableSkipSlotsCache, +}...) diff --git a/shared/featureconfig/flags_test.go b/shared/featureconfig/flags_test.go new file mode 100644 index 000000000000..f78d56325178 --- /dev/null +++ b/shared/featureconfig/flags_test.go @@ -0,0 +1,19 @@ +package featureconfig + +import ( + "reflect" + "strings" + "testing" +) + +func TestDeprecatedFlags(t *testing.T) { + for _, f := range deprecatedFlags { + fv := reflect.ValueOf(f) + if !fv.FieldByName("Hidden").Bool() { + t.Errorf("%s must be hidden when deprecated.", f.GetName()) + } + if !strings.Contains(fv.FieldByName("Usage").String(), "DEPRECATED. DO NOT USE.") { + t.Errorf("Usage for %s must contain \"DEPRECATED. DO NOT USE.\"", f.GetName()) + } + } +} diff --git a/shared/interop/BUILD.bazel b/shared/interop/BUILD.bazel index dc8bc8b8ef65..516a0a293d2b 100644 --- a/shared/interop/BUILD.bazel +++ b/shared/interop/BUILD.bazel @@ -13,7 +13,9 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/bls:go_default_library", + "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", + "//shared/mputil:go_default_library", "//shared/params:go_default_library", "//shared/roughtime:go_default_library", "//shared/trieutil:go_default_library", @@ -25,6 +27,7 @@ go_library( go_test( name = "go_default_test", srcs = [ + "generate_deposits_test.go", "generate_genesis_state_test.go", "generate_keys_test.go", ], @@ -35,6 +38,7 @@ go_test( deps = [ "//beacon-chain/core/state:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/trieutil:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", diff --git a/shared/interop/generate_deposits_test.go b/shared/interop/generate_deposits_test.go new file mode 100644 index 000000000000..28e2695ae641 --- /dev/null +++ b/shared/interop/generate_deposits_test.go @@ -0,0 +1,72 @@ +package interop_test + +import ( + "bytes" + "testing" + + "github.com/prysmaticlabs/prysm/shared/featureconfig" + "github.com/prysmaticlabs/prysm/shared/interop" + "github.com/prysmaticlabs/prysm/shared/params" + "github.com/prysmaticlabs/prysm/shared/trieutil" +) + +func TestSPMPDeposits(t *testing.T) { + // Confirm that internal single-processor deposits end up with the same results as the multi-processor version + + numDeposits := 557 + + cfg := &featureconfig.Flag{ + Scatter: false, + } + featureconfig.Init(cfg) + spPrivKeys, spPubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, uint64(numDeposits)) + if err != nil { + t.Fatal(err) + } + spDepositDataItems, spDepositDataRoots, err := interop.DepositDataFromKeys(spPrivKeys, spPubKeys) + if err != nil { + t.Fatal(err) + } + trie, err := trieutil.GenerateTrieFromItems( + spDepositDataRoots, + int(params.BeaconConfig().DepositContractTreeDepth), + ) + if err != nil { + t.Fatal(err) + } + spDeposits, err := interop.GenerateDepositsFromData(spDepositDataItems, trie) + if err != nil { + t.Fatal(err) + } + + cfg = &featureconfig.Flag{ + Scatter: true, + } + featureconfig.Init(cfg) + privKeys, pubKeys, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, uint64(numDeposits)) + if err != nil { + t.Fatal(err) + } + depositDataItems, _, err := interop.DepositDataFromKeys(privKeys, pubKeys) + if err != nil { + t.Fatal(err) + } + deposits, err := interop.GenerateDepositsFromData(depositDataItems, trie) + if err != nil { + t.Fatal(err) + } + + for i := range deposits { + spD, err := spDeposits[i].Marshal() + if err != nil { + t.Fatal(err) + } + d, err := deposits[i].Marshal() + if err != nil { + t.Fatal(err) + } + if bytes.Compare(d, spD) != 0 { + t.Fatalf("Deposit mismatch at index %d: %v vs %v", i, spD, d) + } + } +} diff --git a/shared/interop/generate_genesis_state.go b/shared/interop/generate_genesis_state.go index f0bba9980900..c3fe8f69b142 100644 --- a/shared/interop/generate_genesis_state.go +++ b/shared/interop/generate_genesis_state.go @@ -1,13 +1,17 @@ package interop import ( + "sync" + "github.com/pkg/errors" "github.com/prysmaticlabs/go-ssz" "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/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" + "github.com/prysmaticlabs/prysm/shared/mputil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/roughtime" "github.com/prysmaticlabs/prysm/shared/trieutil" @@ -58,11 +62,33 @@ func GenerateGenesisState(genesisTime, numValidators uint64) (*pb.BeaconState, [ // GenerateDepositsFromData a list of deposit items by creating proofs for each of them from a sparse Merkle trie. func GenerateDepositsFromData(depositDataItems []*ethpb.Deposit_Data, trie *trieutil.MerkleTrie) ([]*ethpb.Deposit, error) { + if c := featureconfig.Get(); c.Scatter { + deposits := make([]*ethpb.Deposit, len(depositDataItems)) + results, err := mputil.Scatter(len(depositDataItems), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + return generateDepositsFromData(depositDataItems[offset:offset+entries], offset, trie) + }) + if err != nil { + return nil, errors.Wrap(err, "failed to generate deposits from data") + } + for _, result := range results { + if depositExtent, ok := result.Extent.([]*ethpb.Deposit); ok { + copy(deposits[result.Offset:], depositExtent) + } else { + return nil, errors.New("extent not of expected type") + } + } + return deposits, nil + } + return generateDepositsFromData(depositDataItems, 0, trie) +} + +// generateDepositsFromData a list of deposit items by creating proofs for each of them from a sparse Merkle trie. +func generateDepositsFromData(depositDataItems []*ethpb.Deposit_Data, offset int, trie *trieutil.MerkleTrie) ([]*ethpb.Deposit, error) { deposits := make([]*ethpb.Deposit, len(depositDataItems)) for i, item := range depositDataItems { - proof, err := trie.MerkleProof(i) + proof, err := trie.MerkleProof(i + offset) if err != nil { - return nil, errors.Wrapf(err, "could not generate proof for deposit %d", i) + return nil, errors.Wrapf(err, "could not generate proof for deposit %d", i+offset) } deposits[i] = ðpb.Deposit{ Proof: proof, @@ -74,6 +100,34 @@ func GenerateDepositsFromData(depositDataItems []*ethpb.Deposit_Data, trie *trie // DepositDataFromKeys generates a list of deposit data items from a set of BLS validator keys. func DepositDataFromKeys(privKeys []*bls.SecretKey, pubKeys []*bls.PublicKey) ([]*ethpb.Deposit_Data, [][]byte, error) { + if c := featureconfig.Get(); c.Scatter { + type depositData struct { + items []*ethpb.Deposit_Data + roots [][]byte + } + depositDataItems := make([]*ethpb.Deposit_Data, len(privKeys)) + depositDataRoots := make([][]byte, len(privKeys)) + results, err := mputil.Scatter(len(privKeys), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + items, roots, err := depositDataFromKeys(privKeys[offset:offset+entries], pubKeys[offset:offset+entries]) + return &depositData{items: items, roots: roots}, err + }) + if err != nil { + return nil, nil, errors.Wrap(err, "failed to generate deposit data from keys") + } + for _, result := range results { + if depositDataExtent, ok := result.Extent.(*depositData); ok { + copy(depositDataItems[result.Offset:], depositDataExtent.items) + copy(depositDataRoots[result.Offset:], depositDataExtent.roots) + } else { + return nil, nil, errors.New("extent not of expected type") + } + } + return depositDataItems, depositDataRoots, nil + } + return depositDataFromKeys(privKeys, pubKeys) +} + +func depositDataFromKeys(privKeys []*bls.SecretKey, pubKeys []*bls.PublicKey) ([]*ethpb.Deposit_Data, [][]byte, error) { dataRoots := make([][]byte, len(privKeys)) depositDataItems := make([]*ethpb.Deposit_Data, len(privKeys)) for i := 0; i < len(privKeys); i++ { diff --git a/shared/interop/generate_keys.go b/shared/interop/generate_keys.go index c00b953d0158..766c43b7dfab 100644 --- a/shared/interop/generate_keys.go +++ b/shared/interop/generate_keys.go @@ -3,10 +3,13 @@ package interop import ( "encoding/binary" "math/big" + "sync" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/shared/bls" + "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" + "github.com/prysmaticlabs/prysm/shared/mputil" ) const ( @@ -17,6 +20,34 @@ const ( // the algorithm specified in the Eth2.0-Specs interop mock start section found here: // https://github.com/ethereum/eth2.0-pm/blob/a085c9870f3956d6228ed2a40cd37f0c6580ecd7/interop/mocked_start/README.md func DeterministicallyGenerateKeys(startIndex, numKeys uint64) ([]*bls.SecretKey, []*bls.PublicKey, error) { + if c := featureconfig.Get(); c.Scatter { + privKeys := make([]*bls.SecretKey, numKeys) + pubKeys := make([]*bls.PublicKey, numKeys) + type keys struct { + secrets []*bls.SecretKey + publics []*bls.PublicKey + } + results, err := mputil.Scatter(int(numKeys), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + secs, pubs, err := deterministicallyGenerateKeys(uint64(offset)+startIndex, uint64(entries)) + return &keys{secrets: secs, publics: pubs}, err + }) + if err != nil { + return nil, nil, errors.Wrap(err, "failed to generate keys") + } + for _, result := range results { + if keysExtent, ok := result.Extent.(*keys); ok { + copy(privKeys[result.Offset:], keysExtent.secrets) + copy(pubKeys[result.Offset:], keysExtent.publics) + } else { + return nil, nil, errors.New("extent not of expected type") + } + } + return privKeys, pubKeys, nil + } + return deterministicallyGenerateKeys(startIndex, numKeys) +} + +func deterministicallyGenerateKeys(startIndex, numKeys uint64) ([]*bls.SecretKey, []*bls.PublicKey, error) { privKeys := make([]*bls.SecretKey, numKeys) pubKeys := make([]*bls.PublicKey, numKeys) for i := startIndex; i < startIndex+numKeys; i++ { diff --git a/shared/mputil/BUILD.bazel b/shared/mputil/BUILD.bazel new file mode 100644 index 000000000000..640b04a7a0c5 --- /dev/null +++ b/shared/mputil/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["scatter.go"], + importpath = "github.com/prysmaticlabs/prysm/shared/mputil", + visibility = ["//visibility:public"], +) + +go_test( + name = "go_default_test", + size = "small", + srcs = [ + "benchmark_test.go", + "scatter_test.go", + ], + embed = [":go_default_library"], +) diff --git a/shared/mputil/benchmark_test.go b/shared/mputil/benchmark_test.go new file mode 100644 index 000000000000..3667e8c6a382 --- /dev/null +++ b/shared/mputil/benchmark_test.go @@ -0,0 +1,57 @@ +package mputil_test + +import ( + "crypto/rand" + "crypto/sha256" + "sync" + "testing" + + "github.com/prysmaticlabs/prysm/shared/mputil" +) + +var input [][]byte + +const ( + benchmarkElements = 65536 + benchmarkElementSize = 32 + benchmarkHashRuns = 128 +) + +func init() { + input = make([][]byte, benchmarkElements) + for i := 0; i < benchmarkElements; i++ { + input[i] = make([]byte, benchmarkElementSize) + rand.Read(input[i]) + } +} + +// hash repeatedly hashes the data passed to it +func hash(input [][]byte) [][]byte { + output := make([][]byte, len(input)) + for i := range input { + copy(output, input) + for j := 0; j < benchmarkHashRuns; j++ { + hash := sha256.Sum256(output[i]) + output[i] = hash[:] + } + } + return output +} + +func BenchmarkHash(b *testing.B) { + for i := 0; i < b.N; i++ { + hash(input) + } +} + +func BenchmarkHashMP(b *testing.B) { + output := make([][]byte, len(input)) + for i := 0; i < b.N; i++ { + workerResults, _ := mputil.Scatter(len(input), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + return hash(input[offset : offset+entries]), nil + }) + for _, result := range workerResults { + copy(output[result.Offset:], result.Extent.([][]byte)) + } + } +} diff --git a/shared/mputil/scatter.go b/shared/mputil/scatter.go new file mode 100644 index 000000000000..993c7ceb996c --- /dev/null +++ b/shared/mputil/scatter.go @@ -0,0 +1,77 @@ +package mputil + +import ( + "errors" + "runtime" + "sync" +) + +// WorkerResults are the results of a scatter worker. +type WorkerResults struct { + Offset int + Extent interface{} +} + +// Scatter scatters a computation across multiple goroutines. +// This breaks the task in to a number of chunks and executes those chunks in parallel with the function provided. +// Results returned are collected and presented a a set of WorkerResults, which can be reassembled by the calling function. +// Any error that occurs in the workers will be passed back to the calling function. +func Scatter(inputLen int, sFunc func(int, int, *sync.RWMutex) (interface{}, error)) ([]*WorkerResults, error) { + if inputLen <= 0 { + return nil, errors.New("input length must be greater than 0") + } + + chunkSize := calculateChunkSize(inputLen) + workers := inputLen / chunkSize + if inputLen%chunkSize != 0 { + workers++ + } + resultCh := make(chan *WorkerResults, workers) + defer close(resultCh) + errorCh := make(chan error, workers) + defer close(errorCh) + mutex := new(sync.RWMutex) + for worker := 0; worker < workers; worker++ { + offset := worker * chunkSize + entries := chunkSize + if offset+entries > inputLen { + entries = inputLen - offset + } + go func(offset int, entries int) { + extent, err := sFunc(offset, entries, mutex) + if err != nil { + errorCh <- err + } else { + resultCh <- &WorkerResults{ + Offset: offset, + Extent: extent, + } + } + }(offset, entries) + } + + // Collect results from workers + results := make([]*WorkerResults, workers) + for i := 0; i < workers; i++ { + select { + case result := <-resultCh: + results[i] = result + case err := <-errorCh: + return nil, err + } + } + return results, nil +} + +// calculateChunkSize calculates a suitable chunk size for the purposes of parallelisation. +func calculateChunkSize(items int) int { + // Start with a simple even split + chunkSize := items / runtime.GOMAXPROCS(0) + + // Add 1 if we have leftovers (or if we have fewer items than processors). + if chunkSize == 0 || items%chunkSize != 0 { + chunkSize++ + } + + return chunkSize +} diff --git a/shared/mputil/scatter_test.go b/shared/mputil/scatter_test.go new file mode 100644 index 000000000000..c3784404d7e8 --- /dev/null +++ b/shared/mputil/scatter_test.go @@ -0,0 +1,118 @@ +package mputil_test + +import ( + "errors" + "sync" + "testing" + + "github.com/prysmaticlabs/prysm/shared/mputil" +) + +func TestDouble(t *testing.T) { + tests := []struct { + name string + inValues int + err error + }{ + { + name: "0", + inValues: 0, + err: errors.New("input length must be greater than 0"), + }, + { + name: "1", + inValues: 1, + }, + { + name: "1023", + inValues: 1023, + }, + { + name: "1024", + inValues: 1024, + }, + { + name: "1025", + inValues: 1025, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + inValues := make([]int, test.inValues) + for i := 0; i < test.inValues; i++ { + inValues[i] = i + } + outValues := make([]int, test.inValues) + workerResults, err := mputil.Scatter(len(inValues), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) { + extent := make([]int, entries) + for i := 0; i < entries; i++ { + extent[i] = inValues[offset+i] * 2 + } + return extent, nil + }) + if test.err != nil { + if err == nil { + t.Fatalf("Missing expected error %v", test.err) + } + if test.err.Error() != err.Error() { + t.Fatalf("Unexpected error value: expected \"%v\", found \"%v\"", test.err, err) + } + } else { + if err != nil { + t.Fatalf("Unexpected error %v", test.err) + } + + for _, result := range workerResults { + copy(outValues[result.Offset:], result.Extent.([]int)) + } + + for i := 0; i < test.inValues; i++ { + if outValues[i] != inValues[i]*2 { + t.Fatalf("Outvalue at %d mismatch: expected %d, found %d", i, inValues[i]*2, outValues[i]) + } + } + } + }) + } +} + +func TestMutex(t *testing.T) { + totalRuns := 1048576 + val := 0 + _, err := mputil.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) { + for i := 0; i < entries; i++ { + mu.Lock() + val++ + mu.Unlock() + } + return nil, nil + }) + if err != nil { + t.Fatalf("Unexpected error %v", err) + } + + if val != totalRuns { + t.Fatalf("Unexpected value: expected \"%v\", found \"%v\"", totalRuns, val) + } +} + +func TestError(t *testing.T) { + totalRuns := 1024 + val := 0 + _, err := mputil.Scatter(totalRuns, func(offset int, entries int, mu *sync.RWMutex) (interface{}, error) { + for i := 0; i < entries; i++ { + mu.Lock() + val++ + if val == 1011 { + mu.Unlock() + return nil, errors.New("Bad number!") + } + mu.Unlock() + } + return nil, nil + }) + if err == nil { + t.Fatalf("Missing expected error") + } +} diff --git a/shared/params/config.go b/shared/params/config.go index a78cd9a5a4d8..f61a038b43c5 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -224,12 +224,12 @@ func DemoBeaconConfig() *BeaconChainConfig { demoConfig := MinimalSpecConfig() demoConfig.MinDepositAmount = 100 demoConfig.MaxEffectiveBalance = 3.2 * 1e9 - demoConfig.EjectionBalance = 1.6 * 1e9 + demoConfig.EjectionBalance = 3 * 1e9 demoConfig.EffectiveBalanceIncrement = 0.1 * 1e9 demoConfig.Eth1FollowDistance = 16 // Increment this number after a full testnet tear down. - demoConfig.GenesisForkVersion = []byte{0, 0, 0, 2} + demoConfig.GenesisForkVersion = []byte{0, 0, 0, 3} return demoConfig } diff --git a/shared/testutil/block.go b/shared/testutil/block.go index 8dc8bf1fbf18..066c1373d2f9 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -26,6 +26,18 @@ type BlockGenConfig struct { MaxVoluntaryExits uint64 } +// DefaultBlockGenConfig returns the block config that utilizes the +// current params in the beacon config. +func DefaultBlockGenConfig() *BlockGenConfig { + return &BlockGenConfig{ + MaxProposerSlashings: params.BeaconConfig().MaxProposerSlashings, + MaxAttesterSlashings: params.BeaconConfig().MaxAttesterSlashings, + MaxAttestations: params.BeaconConfig().MaxAttestations, + MaxDeposits: params.BeaconConfig().MaxDeposits, + MaxVoluntaryExits: params.BeaconConfig().MaxVoluntaryExits, + } +} + // GenerateFullBlock generates a fully valid block with the requested parameters. // Use BlockGenConfig to declare the conditions you would like the block generated under. func GenerateFullBlock( @@ -33,9 +45,13 @@ func GenerateFullBlock( bState *pb.BeaconState, privs []*bls.SecretKey, conf *BlockGenConfig, + slot uint64, ) *ethpb.BeaconBlock { currentSlot := bState.Slot + if currentSlot > slot { + t.Fatalf("Current slot in state is larger than given slot. %d > %d", currentSlot, slot) + } pSlashings := []*ethpb.ProposerSlashing{} if conf.MaxProposerSlashings > 0 { @@ -75,15 +91,15 @@ func GenerateFullBlock( // Temporarily incrementing the beacon state slot here since BeaconProposerIndex is a // function deterministic on beacon state slot. - bState.Slot++ + bState.Slot = slot reveal, err := CreateRandaoReveal(bState, helpers.CurrentEpoch(bState), privs) if err != nil { t.Fatal(err) } - bState.Slot-- + bState.Slot = currentSlot block := ðpb.BeaconBlock{ - Slot: currentSlot + 1, + Slot: slot, ParentRoot: parentRoot[:], Body: ðpb.BeaconBlockBody{ Eth1Data: eth1Data, @@ -111,12 +127,12 @@ func GenerateFullBlock( } // Temporarily incrementing the beacon state slot here since BeaconProposerIndex is a // function deterministic on beacon state slot. - bState.Slot++ + bState.Slot = slot proposerIdx, err := helpers.BeaconProposerIndex(bState) if err != nil { t.Fatal(err) } - bState.Slot-- + bState.Slot = currentSlot domain := helpers.Domain(bState.Fork, helpers.CurrentEpoch(bState), params.BeaconConfig().DomainBeaconProposer) block.Signature = privs[proposerIdx].Sign(blockRoot[:], domain).Marshal() diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index b6fa23a92641..14e32d615efa 100644 --- a/shared/testutil/block_test.go +++ b/shared/testutil/block_test.go @@ -26,7 +26,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -50,7 +50,7 @@ func TestGenerateFullBlock_ThousandValidators(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -78,7 +78,7 @@ func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { } finalSlot := params.BeaconConfig().SlotsPerEpoch*4 + 3 for i := 0; i < int(finalSlot); i++ { - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransitionNoVerify(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -112,7 +112,7 @@ func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -138,7 +138,7 @@ func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -168,7 +168,7 @@ func TestGenerateFullBlock_ValidAttestations(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -195,7 +195,7 @@ func TestGenerateFullBlock_ValidDeposits(t *testing.T) { MaxDeposits: 1, MaxVoluntaryExits: 0, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) @@ -228,7 +228,7 @@ func TestGenerateFullBlock_ValidVoluntaryExits(t *testing.T) { MaxDeposits: 0, MaxVoluntaryExits: 1, } - block := GenerateFullBlock(t, beaconState, privs, conf) + block := GenerateFullBlock(t, beaconState, privs, conf, beaconState.Slot+1) beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, block) if err != nil { t.Fatal(err) diff --git a/shared/traceutil/errors.go b/shared/traceutil/errors.go index 2311c9b26d24..85f7a9ecc366 100644 --- a/shared/traceutil/errors.go +++ b/shared/traceutil/errors.go @@ -6,6 +6,9 @@ import ( // AnnotateError on span. This should be used any time a particular span experiences an error. func AnnotateError(span *trace.Span, err error) { + if err == nil { + return + } span.AddAttributes(trace.BoolAttribute("error", true)) span.SetStatus(trace.Status{ Code: trace.StatusCodeUnknown, diff --git a/shared/traceutil/recovery_interceptor_option.go b/shared/traceutil/recovery_interceptor_option.go index 9b594cfce032..c37058bc4085 100644 --- a/shared/traceutil/recovery_interceptor_option.go +++ b/shared/traceutil/recovery_interceptor_option.go @@ -2,7 +2,7 @@ package traceutil import ( "context" - "errors" + "fmt" "runtime/debug" "github.com/sirupsen/logrus" @@ -16,7 +16,7 @@ func RecoveryHandlerFunc(ctx context.Context, p interface{}) error { if span != nil { span.AddAttributes(trace.StringAttribute("stack", string(debug.Stack()))) } - err := errors.New(p.(string)) + err := fmt.Errorf("%v", p) logrus.WithError(err).WithField("stack", string(debug.Stack())).Error("gRPC panicked!") return err } diff --git a/shared/version/version.go b/shared/version/version.go index af4d76f333e1..c781f91c3635 100644 --- a/shared/version/version.go +++ b/shared/version/version.go @@ -2,6 +2,10 @@ package version import ( "fmt" + "log" + "os/exec" + "strings" + "time" ) // The value of these vars are set through linker options. @@ -10,5 +14,17 @@ var buildDate = "Moments ago" // GetVersion returns the version string of this build. func GetVersion() string { + // if doing a local build, these values are not interpolated + if gitCommit == "{STABLE_GIT_COMMIT}" { + commit, err := exec.Command("git", "rev-parse", "HEAD").Output() + if err != nil { + log.Fatal(err) + } + gitCommit = strings.TrimRight(string(commit), "\r\n") + } + if buildDate == "{DATE}" { + now := time.Now().Format(time.RFC3339) + buildDate = now + } return fmt.Sprintf("Git commit: %s. Built at: %s", gitCommit, buildDate) } diff --git a/slasher/BUILD.bazel b/slasher/BUILD.bazel index 152b58a5dc7d..49530afce1f3 100644 --- a/slasher/BUILD.bazel +++ b/slasher/BUILD.bazel @@ -1,47 +1,37 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") go_library( name = "go_default_library", srcs = [ - "server.go", - "service.go", + "main.go", + "usage.go", ], importpath = "github.com/prysmaticlabs/prysm/slasher", visibility = ["//slasher:__subpackages__"], deps = [ - "//beacon-chain/core/helpers:go_default_library", - "//proto/eth/v1alpha1:go_default_library", - "//slasher/db:go_default_library", - "//slasher/rpc:go_default_library", - "@com_github_gogo_protobuf//proto:go_default_library", - "@com_github_gogo_protobuf//types:go_default_library", - "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", - "@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library", - "@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library", - "@com_github_pkg_errors//:go_default_library", + "//shared/cmd:go_default_library", + "//shared/debug:go_default_library", + "//shared/logutil:go_default_library", + "//shared/version:go_default_library", + "//slasher/flags:go_default_library", + "//slasher/service:go_default_library", + "@com_github_joonix_log//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", - "@io_opencensus_go//plugin/ocgrpc:go_default_library", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//codes:go_default_library", - "@org_golang_google_grpc//credentials:go_default_library", - "@org_golang_google_grpc//reflection:go_default_library", - "@org_golang_google_grpc//status:go_default_library", + "@com_github_urfave_cli//:go_default_library", + "@com_github_x_cray_logrus_prefixed_formatter//:go_default_library", ], ) go_test( name = "go_default_test", - srcs = [ - "server_test.go", - "service_test.go", - ], + size = "small", + srcs = ["usage_test.go"], embed = [":go_default_library"], - deps = [ - "//proto/eth/v1alpha1:go_default_library", - "//shared/testutil:go_default_library", - "//slasher/db:go_default_library", - "@com_github_gogo_protobuf//proto:go_default_library", - "@com_github_sirupsen_logrus//:go_default_library", - "@com_github_sirupsen_logrus//hooks/test:go_default_library", - ], + deps = ["@com_github_urfave_cli//:go_default_library"], +) + +go_binary( + name = "slasher", + embed = [":go_default_library"], + visibility = ["//visibility:public"], ) diff --git a/slasher/README.md b/slasher/README.md new file mode 100644 index 000000000000..062feed12e7d --- /dev/null +++ b/slasher/README.md @@ -0,0 +1,13 @@ +# Prysmatic Labs Hash Slinging Slasher Server Implementation + +This is the main project folder for a slasher server implementation of Ethereum Serenity in Golang by [Prysmatic Labs](https://prysmaticlabs.com). A slasher listens to queries from a running beacon node in order to detect slashable attestations and block proposals. +It is advised to run the slasher in a closed network and let only your beacon node connect to it while not exposing its endpoints to the public network as DOS attacks on the slasher are easy to accomplish as the lookup for certain can have serious overhead if spammed. + +Before you begin, check out our main [README](https://github.com/prysmaticlabs/prysm/blob/master/README.md) and join our active chat room on Discord or Gitter below: + +[![Discord](https://user-images.githubusercontent.com/7288322/34471967-1df7808a-efbb-11e7-9088-ed0b04151291.png)](https://discord.gg/KSA7rPr) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prysmaticlabs/prysm?badge&utm_medium=badge&utm_campaign=pr-badge) + +Also, read the latest sharding + casper [design spec](https://github.com/ethereum/eth2.0-specs), this design spec serves as a source of truth for the beacon chain implementation we follow at prysmatic labs. +Check out the [FAQs](https://notes.ethereum.org/9MMuzWeFTTSg-3Tz_YeiBA?view). Refer this page on [why](http://email.mg2.substack.com/c/eJwlj9GOhCAMRb9G3jRQQPGBh5mM8xsbhKrsDGIAM9m_X9xN2qZtbpt7rCm4xvSjj5gLOTOmL-809CMbKXFaOKakIl4DZYr2AGyQIGjHOnWH22OiYnoIxmDijaBhhS6fcy7GvjobA9m0mSXOcnZq5GBqLkilXBZhBsus5ZK89VbKkRt-a-BZI6DzZ7iur1lQ953KJ9bemnxgahuQU9XJu6pFPdu8meT8vragzEjpMCwMGLlgLo6h5z1JumQTu4IJd4v15xqMf_8ZLP_Y1bSLdbnrD-LL71i2Kj7DLxaWWF4) +we are combining sharding and casper together. diff --git a/slasher/db/BUILD.bazel b/slasher/db/BUILD.bazel index 4a919ac80dd1..2063e01af7ab 100644 --- a/slasher/db/BUILD.bazel +++ b/slasher/db/BUILD.bazel @@ -8,6 +8,7 @@ go_library( "indexed_attestations.go", "schema.go", "setup_db.go", + "validator_id_pubkey.go", ], importpath = "github.com/prysmaticlabs/prysm/slasher/db", visibility = ["//slasher:__subpackages__"], @@ -29,6 +30,7 @@ go_test( "block_header_test.go", "indexed_attestations_test.go", "setup_db_test.go", + "validator_id_pubkey_test.go", ], embed = [":go_default_library"], deps = ["//proto/eth/v1alpha1:go_default_library"], diff --git a/slasher/db/db.go b/slasher/db/db.go index e9fd22b717de..36f497f75117 100644 --- a/slasher/db/db.go +++ b/slasher/db/db.go @@ -85,6 +85,7 @@ func NewKVStore(dirPath string) (*Store, error) { historicIndexedAttestationsBucket, historicBlockHeadersBucket, indexedAttestationsIndicesBucket, + validatorsPublicKeysBucket, ) }); err != nil { return nil, err diff --git a/slasher/db/indexed_attestations.go b/slasher/db/indexed_attestations.go index 9f0cb5bc1231..5f8540ed7fa9 100644 --- a/slasher/db/indexed_attestations.go +++ b/slasher/db/indexed_attestations.go @@ -34,9 +34,9 @@ func createValidatorIDsToIndexedAttestationList(enc []byte) (*ethpb.ValidatorIDT // IndexedAttestation accepts a epoch and validator index and returns a list of // indexed attestations. // Returns nil if the indexed attestation does not exist. -func (db *Store) IndexedAttestation(epoch uint64, validatorID uint64) ([]*ethpb.IndexedAttestation, error) { +func (db *Store) IndexedAttestation(sourceEpoch uint64, targetEpoch uint64, validatorID uint64) ([]*ethpb.IndexedAttestation, error) { var iAtt []*ethpb.IndexedAttestation - key := bytesutil.Bytes8(epoch) + key := append(bytesutil.Bytes8(sourceEpoch), bytesutil.Bytes8(targetEpoch)...) err := db.view(func(tx *bolt.Tx) error { bucket := tx.Bucket(indexedAttestationsIndicesBucket) enc := bucket.Get(key) @@ -48,7 +48,7 @@ func (db *Store) IndexedAttestation(epoch uint64, validatorID uint64) ([]*ethpb. i := sort.Search(len(a.Indices), func(i int) bool { return a.Indices[i] >= validatorID }) if i < len(a.Indices) && a.Indices[i] == validatorID { iaBucket := tx.Bucket(historicIndexedAttestationsBucket) - key := encodeEpochSig(epoch, a.Signature) + key := encodeEpochSig(sourceEpoch, targetEpoch, a.Signature) enc = iaBucket.Get(key) if len(enc) == 0 { continue @@ -67,8 +67,8 @@ func (db *Store) IndexedAttestation(epoch uint64, validatorID uint64) ([]*ethpb. } // HasIndexedAttestation accepts an epoch and validator id and returns true if the indexed attestation exists. -func (db *Store) HasIndexedAttestation(epoch uint64, validatorID uint64) bool { - key := bytesutil.Bytes8(epoch) +func (db *Store) HasIndexedAttestation(sourceEpoch uint64, targetEpoch uint64, validatorID uint64) bool { + key := append(bytesutil.Bytes8(sourceEpoch), bytesutil.Bytes8(targetEpoch)...) var hasAttestation bool // #nosec G104 _ = db.view(func(tx *bolt.Tx) error { @@ -93,8 +93,8 @@ func (db *Store) HasIndexedAttestation(epoch uint64, validatorID uint64) bool { } // SaveIndexedAttestation accepts epoch and indexed attestation and writes it to disk. -func (db *Store) SaveIndexedAttestation(epoch uint64, idxAttestation *ethpb.IndexedAttestation) error { - key := encodeEpochSig(epoch, idxAttestation.Signature) +func (db *Store) SaveIndexedAttestation(idxAttestation *ethpb.IndexedAttestation) error { + key := encodeEpochSig(idxAttestation.Data.Source.Epoch, idxAttestation.Data.Target.Epoch, idxAttestation.Signature) enc, err := proto.Marshal(idxAttestation) if err != nil { return errors.Wrap(err, "failed to marshal") @@ -107,7 +107,7 @@ func (db *Store) SaveIndexedAttestation(epoch uint64, idxAttestation *ethpb.Inde if val != nil { return nil } - createIndexedAttestationIndicesFromData(epoch, idxAttestation, tx) + createIndexedAttestationIndicesFromData(idxAttestation, tx) if err := bucket.Put(key, enc); err != nil { return errors.Wrap(err, "failed to include the indexed attestation in the historic indexed attestation bucket") } @@ -116,25 +116,27 @@ func (db *Store) SaveIndexedAttestation(epoch uint64, idxAttestation *ethpb.Inde }) // prune history to max size every 10th epoch - if epoch%10 == 0 { + if idxAttestation.Data.Source.Epoch%10 == 0 { weakSubjectivityPeriod := uint64(54000) - err = db.PruneHistory(epoch, weakSubjectivityPeriod) + err = db.PruneHistory(idxAttestation.Data.Source.Epoch, weakSubjectivityPeriod) } return err } -func createIndexedAttestationIndicesFromData(epoch uint64, idxAttestation *ethpb.IndexedAttestation, tx *bolt.Tx) error { +func createIndexedAttestationIndicesFromData(idxAttestation *ethpb.IndexedAttestation, tx *bolt.Tx) error { indices := append(idxAttestation.CustodyBit_0Indices, idxAttestation.CustodyBit_1Indices...) - dataRoot, err := ssz.Marshal(idxAttestation.Data) + dataRoot, err := ssz.HashTreeRoot(idxAttestation.Data) + if err != nil { - return errors.Wrap(err, "failed to marshal indexed attestation data.") + return errors.Wrap(err, "failed to hash indexed attestation data.") } protoIdxAtt := ðpb.ValidatorIDToIdxAtt{ Signature: idxAttestation.Signature, Indices: indices, - DataRoot: dataRoot, + DataRoot: dataRoot[:], } - key := bytesutil.Bytes8(epoch) + key := append(bytesutil.Bytes8(idxAttestation.Data.Source.Epoch), bytesutil.Bytes8(idxAttestation.Data.Target.Epoch)...) + bucket := tx.Bucket(indexedAttestationsIndicesBucket) enc := bucket.Get(key) vIdxList, err := createValidatorIDsToIndexedAttestationList(enc) @@ -153,31 +155,32 @@ func createIndexedAttestationIndicesFromData(epoch uint64, idxAttestation *ethpb } // DeleteIndexedAttestation deletes a indexed attestation using the slot and its root as keys in their respective buckets. -func (db *Store) DeleteIndexedAttestation(epoch uint64, idxAttestation *ethpb.IndexedAttestation) error { - key := encodeEpochSig(epoch, idxAttestation.Signature) +func (db *Store) DeleteIndexedAttestation(idxAttestation *ethpb.IndexedAttestation) error { + key := encodeEpochSig(idxAttestation.Data.Source.Epoch, idxAttestation.Data.Target.Epoch, idxAttestation.Signature) return db.update(func(tx *bolt.Tx) error { bucket := tx.Bucket(historicIndexedAttestationsBucket) enc := bucket.Get(key) if enc == nil { return nil } - removeIndexedAttestationIndicesFromData(epoch, idxAttestation, tx) + removeIndexedAttestationIndicesFromData(idxAttestation, tx) if err := bucket.Delete(key); err != nil { + tx.Rollback() return errors.Wrap(err, "failed to delete the indexed attestation from historic indexed attestation bucket") } return nil }) } -func removeIndexedAttestationIndicesFromData(epoch uint64, idxAttestation *ethpb.IndexedAttestation, tx *bolt.Tx) error { +func removeIndexedAttestationIndicesFromData(idxAttestation *ethpb.IndexedAttestation, tx *bolt.Tx) error { indices := append(idxAttestation.CustodyBit_0Indices, idxAttestation.CustodyBit_1Indices...) - dataRoot, err := ssz.Marshal(idxAttestation.Data) + dataRoot, err := ssz.HashTreeRoot(idxAttestation.Data) protoIdxAtt := ðpb.ValidatorIDToIdxAtt{ Signature: idxAttestation.Signature, Indices: indices, - DataRoot: dataRoot, + DataRoot: dataRoot[:], } - key := bytesutil.Bytes8(epoch) + key := append(bytesutil.Bytes8(idxAttestation.Data.Source.Epoch), bytesutil.Bytes8(idxAttestation.Data.Target.Epoch)...) bucket := tx.Bucket(indexedAttestationsIndicesBucket) enc := bucket.Get(key) vIdxList, err := createValidatorIDsToIndexedAttestationList(enc) diff --git a/slasher/db/indexed_attestations_test.go b/slasher/db/indexed_attestations_test.go index b3adc682e66e..7e07dad16e0e 100644 --- a/slasher/db/indexed_attestations_test.go +++ b/slasher/db/indexed_attestations_test.go @@ -8,8 +8,7 @@ import ( ) type testStruct struct { - epoch uint64 - iA *ethpb.IndexedAttestation + iA *ethpb.IndexedAttestation } var tests []testStruct @@ -17,24 +16,21 @@ var tests []testStruct func init() { tests = []testStruct{ { - epoch: uint64(0), iA: ðpb.IndexedAttestation{Signature: []byte("let me in"), CustodyBit_0Indices: []uint64{0}, Data: ðpb.AttestationData{ Source: ðpb.Checkpoint{Epoch: 0}, - Target: ðpb.Checkpoint{Epoch: 0}, + Target: ðpb.Checkpoint{Epoch: 1}, }}, }, { - epoch: uint64(0), 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: 0}, + Target: ðpb.Checkpoint{Epoch: 2}, }}, }, { - epoch: uint64(1), iA: ðpb.IndexedAttestation{Signature: []byte("let me in 3rd"), CustodyBit_0Indices: []uint64{0}, Data: ðpb.AttestationData{ - Source: ðpb.Checkpoint{Epoch: 0}, - Target: ðpb.Checkpoint{Epoch: 0}, + Source: ðpb.Checkpoint{Epoch: 1}, + Target: ðpb.Checkpoint{Epoch: 2}, }}, }, } @@ -47,12 +43,12 @@ func TestNilDBHistoryIdxAtt(t *testing.T) { epoch := uint64(1) validatorID := uint64(1) - hasIdxAtt := db.HasIndexedAttestation(epoch, validatorID) + hasIdxAtt := db.HasIndexedAttestation(epoch, epoch, validatorID) if hasIdxAtt { t.Fatal("HasIndexedAttestation should return false") } - idxAtt, err := db.IndexedAttestation(epoch, validatorID) + idxAtt, err := db.IndexedAttestation(epoch, epoch, validatorID) if err != nil { t.Fatalf("failed to get indexed attestation: %v", err) } @@ -66,12 +62,12 @@ func TestSaveIdxAtt(t *testing.T) { defer TeardownSlasherDB(t, db) for _, tt := range tests { - err := db.SaveIndexedAttestation(tt.epoch, tt.iA) + err := db.SaveIndexedAttestation(tt.iA) if err != nil { t.Fatalf("save indexed attestation failed: %v", err) } - iAarray, err := db.IndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + iAarray, err := db.IndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if err != nil { t.Fatalf("failed to get indexed attestation: %v", err) } @@ -89,14 +85,14 @@ func TestDeleteHistoryIdxAtt(t *testing.T) { for _, tt := range tests { - err := db.SaveIndexedAttestation(tt.epoch, tt.iA) + err := db.SaveIndexedAttestation(tt.iA) if err != nil { t.Fatalf("save indexed attestation failed: %v", err) } } for _, tt := range tests { - iAarray, err := db.IndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + iAarray, err := db.IndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if err != nil { t.Fatalf("failed to get index attestation: %v", err) } @@ -104,12 +100,12 @@ func TestDeleteHistoryIdxAtt(t *testing.T) { if iAarray == nil || !reflect.DeepEqual(iAarray[0], tt.iA) { t.Fatalf("get should return indexed attestation: %v", iAarray) } - err = db.DeleteIndexedAttestation(tt.epoch, tt.iA) + err = db.DeleteIndexedAttestation(tt.iA) if err != nil { t.Fatalf("delete index attestation failed: %v", err) } - iAarray, err = db.IndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) - hasA := db.HasIndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + iAarray, err = db.IndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) + hasA := db.HasIndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if err != nil { t.Fatal(err) } @@ -130,18 +126,18 @@ func TestHasIdxAtt(t *testing.T) { for _, tt := range tests { - found := db.HasIndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + found := db.HasIndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if found { t.Fatal("has indexed attestation should return false for indexed attestations that are not in db") } - err := db.SaveIndexedAttestation(tt.epoch, tt.iA) + err := db.SaveIndexedAttestation(tt.iA) if err != nil { t.Fatalf("save indexed attestation failed: %v", err) } } for _, tt := range tests { - found := db.HasIndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + found := db.HasIndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if !found { t.Fatal("has indexed attestation should return true") @@ -154,12 +150,12 @@ func TestPruneHistoryIdxAtt(t *testing.T) { defer TeardownSlasherDB(t, db) for _, tt := range tests { - err := db.SaveIndexedAttestation(tt.epoch, tt.iA) + err := db.SaveIndexedAttestation(tt.iA) if err != nil { t.Fatalf("save indexed attestation failed: %v", err) } - iAarray, err := db.IndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + iAarray, err := db.IndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if err != nil { t.Fatalf("failed to get indexed attestation: %v", err) } @@ -176,13 +172,13 @@ func TestPruneHistoryIdxAtt(t *testing.T) { } for _, tt := range tests { - iAarray, err := db.IndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + iAarray, err := db.IndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) if err != nil { t.Fatalf("failed to get indexed attestation: %v", err) } - hasIa := db.HasIndexedAttestation(tt.epoch, tt.iA.CustodyBit_0Indices[0]) + hasIa := db.HasIndexedAttestation(tt.iA.Data.Source.Epoch, tt.iA.Data.Target.Epoch, tt.iA.CustodyBit_0Indices[0]) - if tt.epoch > currentEpoch-historyToKeep { + if tt.iA.Data.Source.Epoch > currentEpoch-historyToKeep { if iAarray == nil || !reflect.DeepEqual(iAarray[0], tt.iA) { t.Fatalf("get should return indexed attestation: %v", iAarray) } diff --git a/slasher/db/schema.go b/slasher/db/schema.go index ffe491f52693..cede6407b873 100644 --- a/slasher/db/schema.go +++ b/slasher/db/schema.go @@ -9,6 +9,7 @@ var ( historicIndexedAttestationsBucket = []byte("historic-indexed-attestations-bucket") historicBlockHeadersBucket = []byte("historic-block-headers-bucket") indexedAttestationsIndicesBucket = []byte("indexed-attestations-indices-bucket") + validatorsPublicKeysBucket = []byte("validators-public-keys-bucket") ) func encodeEpochValidatorID(epoch uint64, validatorID uint64) []byte { @@ -19,6 +20,7 @@ func encodeEpochValidatorIDSig(epoch uint64, validatorID uint64, sig []byte) []b return append(append(bytesutil.Bytes8(epoch), bytesutil.Bytes8(validatorID)...), sig...) } -func encodeEpochSig(epoch uint64, sig []byte) []byte { - return append(bytesutil.Bytes8(epoch), sig...) +func encodeEpochSig(sourceEpoch uint64, targetEpoch uint64, sig []byte) []byte { + st := append(bytesutil.Bytes8(sourceEpoch), bytesutil.Bytes8(targetEpoch)...) + return append(st, sig...) } diff --git a/slasher/db/validator_id_pubkey.go b/slasher/db/validator_id_pubkey.go new file mode 100644 index 000000000000..93b7c152f4d8 --- /dev/null +++ b/slasher/db/validator_id_pubkey.go @@ -0,0 +1,44 @@ +package db + +import ( + "github.com/boltdb/bolt" + "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/shared/bytesutil" +) + +// ValidatorPubKey accepts validator id and returns the corresponding pubkey. +// Returns nil if the pubkey for this validator id does not exist. +func (db *Store) ValidatorPubKey(validatorID uint64) ([]byte, error) { + var pk []byte + err := db.view(func(tx *bolt.Tx) error { + b := tx.Bucket(validatorsPublicKeysBucket) + pk = b.Get(bytesutil.Bytes4(validatorID)) + return nil + }) + return pk, err +} + +// SavePubKey accepts a validator id and its public key and writes it to disk. +func (db *Store) SavePubKey(validatorID uint64, pubKey []byte) error { + err := db.update(func(tx *bolt.Tx) error { + bucket := tx.Bucket(validatorsPublicKeysBucket) + key := bytesutil.Bytes4(validatorID) + if err := bucket.Put(key, pubKey); err != nil { + return errors.Wrap(err, "failed to add validator public key to slasher db.") + } + return nil + }) + return err +} + +// DeletePubKey deletes a public key of a validator id. +func (db *Store) DeletePubKey(validatorID uint64) error { + return db.update(func(tx *bolt.Tx) error { + bucket := tx.Bucket(validatorsPublicKeysBucket) + key := bytesutil.Bytes4(validatorID) + if err := bucket.Delete(key); err != nil { + return errors.Wrap(err, "failed to delete public key from validators public key bucket") + } + return bucket.Delete(key) + }) +} diff --git a/slasher/db/validator_id_pubkey_test.go b/slasher/db/validator_id_pubkey_test.go new file mode 100644 index 000000000000..311110260c61 --- /dev/null +++ b/slasher/db/validator_id_pubkey_test.go @@ -0,0 +1,105 @@ +package db + +import ( + "bytes" + "testing" +) + +type publicKeyTestStruct struct { + validatorID uint64 + pk []byte +} + +var pkTests []publicKeyTestStruct + +func init() { + pkTests = []publicKeyTestStruct{ + { + validatorID: 1, + pk: []byte{1, 2, 3}, + }, + { + validatorID: 2, + pk: []byte{4, 5, 6}, + }, + { + validatorID: 3, + pk: []byte{7, 8, 9}, + }, + } +} + +func TestNilDBValidatorPublicKey(t *testing.T) { + db := SetupSlasherDB(t) + defer TeardownSlasherDB(t, db) + + validatorID := uint64(1) + + pk, err := db.ValidatorPubKey(validatorID) + if err != nil { + t.Fatal("nil ValidatorPubKey should not return error") + } + if pk != nil { + t.Fatal("ValidatorPubKey should return nil") + } + +} + +func TestSavePubKey(t *testing.T) { + db := SetupSlasherDB(t) + defer TeardownSlasherDB(t, db) + + for _, tt := range pkTests { + err := db.SavePubKey(tt.validatorID, tt.pk) + if err != nil { + t.Fatalf("save validator public key failed: %v", err) + } + + pk, err := db.ValidatorPubKey(tt.validatorID) + if err != nil { + t.Fatalf("failed to get validator public key: %v", err) + } + + if pk == nil || !bytes.Equal(pk, tt.pk) { + t.Fatalf("get should return validator public key: %v", tt.pk) + } + } + +} + +func TestDeletePublicKey(t *testing.T) { + db := SetupSlasherDB(t) + defer TeardownSlasherDB(t, db) + + for _, tt := range pkTests { + + err := db.SavePubKey(tt.validatorID, tt.pk) + if err != nil { + t.Fatalf("save validator public key failed: %v", err) + } + } + + for _, tt := range pkTests { + pk, err := db.ValidatorPubKey(tt.validatorID) + if err != nil { + t.Fatalf("failed to get validator public key: %v", err) + } + + if pk == nil || !bytes.Equal(pk, tt.pk) { + t.Fatalf("get should return validator public key: %v", pk) + } + err = db.DeletePubKey(tt.validatorID) + if err != nil { + t.Fatalf("delete validator public key: %v", err) + } + pk, err = db.ValidatorPubKey(tt.validatorID) + if err != nil { + t.Fatal(err) + } + if pk != nil { + t.Errorf("Expected validator public key to be deleted, received: %v", pk) + } + + } + +} diff --git a/slasher/flags/BUILD.bazel b/slasher/flags/BUILD.bazel new file mode 100644 index 000000000000..556d00effc52 --- /dev/null +++ b/slasher/flags/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["flags.go"], + importpath = "github.com/prysmaticlabs/prysm/slasher/flags", + visibility = ["//visibility:public"], + deps = ["@com_github_urfave_cli//:go_default_library"], +) diff --git a/slasher/flags/flags.go b/slasher/flags/flags.go new file mode 100644 index 000000000000..745310a53d52 --- /dev/null +++ b/slasher/flags/flags.go @@ -0,0 +1,24 @@ +package flags + +import ( + "github.com/urfave/cli" +) + +var ( + // CertFlag defines a flag for the node's TLS certificate. + CertFlag = cli.StringFlag{ + Name: "tls-cert", + Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.", + } + // RPCPort defines a slasher node RPC port to open. + RPCPort = cli.IntFlag{ + Name: "rpc-port", + Usage: "RPC port exposed by a beacon node", + Value: 5000, + } + // KeyFlag defines a flag for the node's TLS key. + KeyFlag = cli.StringFlag{ + Name: "tls-key", + Usage: "Key for secure gRPC. Pass this and the tls-cert flag in order to use gRPC securely.", + } +) diff --git a/slasher/main.go b/slasher/main.go new file mode 100644 index 000000000000..92772690767a --- /dev/null +++ b/slasher/main.go @@ -0,0 +1,124 @@ +package main + +import ( + "fmt" + "os" + "runtime" + + joonix "github.com/joonix/log" + "github.com/prysmaticlabs/prysm/shared/cmd" + "github.com/prysmaticlabs/prysm/shared/debug" + "github.com/prysmaticlabs/prysm/shared/logutil" + "github.com/prysmaticlabs/prysm/shared/version" + "github.com/prysmaticlabs/prysm/slasher/flags" + "github.com/prysmaticlabs/prysm/slasher/service" + "github.com/sirupsen/logrus" + "github.com/urfave/cli" + prefixed "github.com/x-cray/logrus-prefixed-formatter" +) + +var log = logrus.WithField("prefix", "main") + +func startSlasher(ctx *cli.Context) error { + verbosity := ctx.GlobalString(cmd.VerbosityFlag.Name) + level, err := logrus.ParseLevel(verbosity) + if err != nil { + return err + } + logrus.SetLevel(level) + port := ctx.GlobalString(flags.RPCPort.Name) + cert := ctx.GlobalString(flags.CertFlag.Name) + key := ctx.GlobalString(flags.KeyFlag.Name) + cfg := service.Config{ + Port: port, + CertFlag: cert, + KeyFlag: key, + } + slasher, err := service.NewRPCService(&cfg, ctx) + if err != nil { + return err + } + slasher.Start() + return nil +} + +var appFlags = []cli.Flag{ + cmd.VerbosityFlag, + cmd.LogFormat, + cmd.DataDirFlag, + cmd.VerbosityFlag, + cmd.DataDirFlag, + cmd.EnableTracingFlag, + cmd.TracingProcessNameFlag, + cmd.TracingEndpointFlag, + cmd.TraceSampleFractionFlag, + cmd.BootstrapNode, + cmd.MonitoringPortFlag, + cmd.LogFileName, + cmd.LogFormat, + debug.PProfFlag, + debug.PProfAddrFlag, + debug.PProfPortFlag, + debug.MemProfileRateFlag, + debug.CPUProfileFlag, + debug.TraceFlag, + flags.CertFlag, + flags.RPCPort, + flags.KeyFlag, +} + +func init() { + +} + +func main() { + app := cli.NewApp() + app.Name = "hash slinging slasher" + app.Usage = `launches an Ethereum Serenity slasher server that interacts with a beacon chain.` + app.Version = version.GetVersion() + app.Action = startSlasher + app.Flags = appFlags + + app.Before = func(ctx *cli.Context) error { + format := ctx.GlobalString(cmd.LogFormat.Name) + switch format { + case "text": + formatter := new(prefixed.TextFormatter) + formatter.TimestampFormat = "2006-01-02 15:04:05" + formatter.FullTimestamp = true + // If persistent log files are written - we disable the log messages coloring because + // the colors are ANSI codes and seen as Gibberish in the log files. + formatter.DisableColors = ctx.GlobalString(cmd.LogFileName.Name) != "" + logrus.SetFormatter(formatter) + break + case "fluentd": + logrus.SetFormatter(joonix.NewFormatter()) + break + case "json": + logrus.SetFormatter(&logrus.JSONFormatter{}) + break + default: + return fmt.Errorf("unknown log format %s", format) + } + + logFileName := ctx.GlobalString(cmd.LogFileName.Name) + if logFileName != "" { + if err := logutil.ConfigurePersistentLogging(logFileName); err != nil { + log.WithError(err).Error("Failed to configuring logging to disk.") + } + } + + runtime.GOMAXPROCS(runtime.NumCPU()) + return debug.Setup(ctx) + } + + app.After = func(ctx *cli.Context) error { + debug.Exit(ctx) + return nil + } + + if err := app.Run(os.Args); err != nil { + log.Error(err.Error()) + os.Exit(1) + } +} diff --git a/slasher/rpc/server.go b/slasher/rpc/server.go index f4ad7c1f499b..0d175e1e0589 100644 --- a/slasher/rpc/server.go +++ b/slasher/rpc/server.go @@ -3,9 +3,10 @@ package rpc import ( "context" + "github.com/pkg/errors" + "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/types" - "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/slasher/db" @@ -30,6 +31,7 @@ func (ss *Server) IsSlashableAttestation(ctx context.Context, req *ethpb.Attesta // IsSlashableBlock returns a proposer slashing if the block header submitted is // a slashable proposal. func (ss *Server) IsSlashableBlock(ctx context.Context, psr *ethpb.ProposerSlashingRequest) (*ethpb.ProposerSlashingResponse, error) { + //TODO(#3133): add signature validation epoch := helpers.SlotToEpoch(psr.BlockHeader.Slot) blockHeaders, err := ss.SlasherDb.BlockHeader(epoch, psr.ValidatorIndex) if err != nil { diff --git a/slasher/rpc/server_test.go b/slasher/rpc/server_test.go index f21d9d3ed14c..cb040aaab655 100644 --- a/slasher/rpc/server_test.go +++ b/slasher/rpc/server_test.go @@ -11,7 +11,6 @@ import ( func TestServer_IsSlashableBlock(t *testing.T) { dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) ctx := context.Background() slasherServer := &Server{ @@ -57,7 +56,6 @@ func TestServer_IsSlashableBlock(t *testing.T) { func TestServer_IsNotSlashableBlock(t *testing.T) { dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) slasherServer := &Server{ @@ -95,7 +93,6 @@ func TestServer_IsNotSlashableBlock(t *testing.T) { func TestServer_DoubleBlock(t *testing.T) { dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) ctx := context.Background() slasherServer := &Server{ @@ -126,7 +123,6 @@ func TestServer_DoubleBlock(t *testing.T) { func TestServer_SameSlotSlashable(t *testing.T) { dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) ctx := context.Background() slasherServer := &Server{ diff --git a/slasher/server.go b/slasher/server.go deleted file mode 100644 index 93c205cd1224..000000000000 --- a/slasher/server.go +++ /dev/null @@ -1,66 +0,0 @@ -package slasher - -import ( - "context" - - "github.com/pkg/errors" - - "github.com/gogo/protobuf/proto" - types "github.com/gogo/protobuf/types" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/slasher/db" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// Server defines a server implementation of the gRPC Slasher service, -// providing RPC endpoints for retrieving slashing proofs for malicious validators. -type Server struct { - slasherDb *db.Store - ctx context.Context -} - -// IsSlashableAttestation returns an attester slashing if the attestation submitted -// is a slashable vote. -func (ss *Server) IsSlashableAttestation(ctx context.Context, req *ethpb.Attestation) (*ethpb.AttesterSlashing, error) { - return nil, status.Error(codes.Unimplemented, "not implemented") -} - -// IsSlashableBlock returns a proposer slashing if the block header submitted is -// a slashable proposal. -func (ss *Server) IsSlashableBlock(ctx context.Context, psr *ethpb.ProposerSlashingRequest) (*ethpb.ProposerSlashingResponse, error) { - //TODO(#3133): add signature validation - epoch := helpers.SlotToEpoch(psr.BlockHeader.Slot) - bha, err := ss.slasherDb.BlockHeader(epoch, psr.ValidatorIndex) - - if err != nil { - return nil, errors.Wrap(err, "slasher service error while trying to retrieve blocks") - } - pSlashingsResponse := ðpb.ProposerSlashingResponse{} - presentInDb := false - for _, bh := range bha { - if proto.Equal(bh, psr.BlockHeader) { - presentInDb = true - continue - } - pSlashingsResponse.ProposerSlashing = append(pSlashingsResponse.ProposerSlashing, ðpb.ProposerSlashing{ProposerIndex: psr.ValidatorIndex, Header_1: psr.BlockHeader, Header_2: bh}) - } - if len(pSlashingsResponse.ProposerSlashing) == 0 && !presentInDb { - err = ss.slasherDb.SaveBlockHeader(epoch, psr.ValidatorIndex, psr.BlockHeader) - if err != nil { - return nil, err - } - } - return pSlashingsResponse, nil -} - -// SlashableProposals is a subscription to receive all slashable proposer slashing events found by the watchtower. -func (ss *Server) SlashableProposals(req *types.Empty, server ethpb.Slasher_SlashableProposalsServer) error { - return status.Error(codes.Unimplemented, "not implemented") -} - -// SlashableAttestations is a subscription to receive all slashable attester slashing events found by the watchtower. -func (ss *Server) SlashableAttestations(req *types.Empty, server ethpb.Slasher_SlashableAttestationsServer) error { - return status.Error(codes.Unimplemented, "not implemented") -} diff --git a/slasher/server_test.go b/slasher/server_test.go deleted file mode 100644 index 47ea2c43ca6b..000000000000 --- a/slasher/server_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package slasher - -import ( - "context" - "testing" - - "github.com/gogo/protobuf/proto" - - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/slasher/db" -) - -func TestServer_IsSlashableBlock(t *testing.T) { - dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) - ctx := context.Background() - slasherServer := &Server{ - ctx: ctx, - slasherDb: dbs, - } - psr := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("A"), - }, - ValidatorIndex: 1, - } - psr2 := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("B"), - }, - ValidatorIndex: 1, - } - if _, err := slasherServer.IsSlashableBlock(ctx, psr); err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - sr, err := slasherServer.IsSlashableBlock(ctx, psr2) - if err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - want := ðpb.ProposerSlashing{ - ProposerIndex: psr.ValidatorIndex, - Header_1: psr2.BlockHeader, - Header_2: psr.BlockHeader, - } - - if len(sr.ProposerSlashing) != 1 { - t.Errorf("Should return 1 slashaing proof: %v", sr) - } - if !proto.Equal(sr.ProposerSlashing[0], want) { - t.Errorf("wanted slashing proof: %v got: %v", want, sr.ProposerSlashing[0]) - } -} - -func TestServer_IsNotSlashableBlock(t *testing.T) { - dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) - ctx := context.Background() - slasherServer := &Server{ - ctx: ctx, - slasherDb: dbs, - } - psr := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("A"), - }, - ValidatorIndex: 1, - } - psr2 := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 65, - StateRoot: []byte("B"), - }, - ValidatorIndex: 1, - } - if _, err := slasherServer.IsSlashableBlock(ctx, psr); err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - sr, err := slasherServer.IsSlashableBlock(ctx, psr2) - if err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - if len(sr.ProposerSlashing) != 0 { - t.Errorf("Should return 0 slashaing proof: %v", sr) - } -} - -func TestServer_DoubleBlock(t *testing.T) { - dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) - ctx := context.Background() - slasherServer := &Server{ - ctx: ctx, - slasherDb: dbs, - } - psr := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("A"), - }, - ValidatorIndex: 1, - } - if _, err := slasherServer.IsSlashableBlock(ctx, psr); err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - sr, err := slasherServer.IsSlashableBlock(ctx, psr) - if err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - if len(sr.ProposerSlashing) != 0 { - t.Errorf("Should return 0 slashaing proof: %v", sr) - } -} - -func TestServer_SameEpochDifferentSlotSlashable(t *testing.T) { - dbs := db.SetupSlasherDB(t) - defer db.TeardownSlasherDB(t, dbs) - ctx := context.Background() - slasherServer := &Server{ - ctx: ctx, - slasherDb: dbs, - } - psr := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("A"), - }, - ValidatorIndex: 1, - } - psr2 := ðpb.ProposerSlashingRequest{ - BlockHeader: ðpb.BeaconBlockHeader{ - Slot: 1, - StateRoot: []byte("B"), - }, - ValidatorIndex: 1, - } - want := ðpb.ProposerSlashing{ - ProposerIndex: psr.ValidatorIndex, - Header_1: psr2.BlockHeader, - Header_2: psr.BlockHeader, - } - - if _, err := slasherServer.IsSlashableBlock(ctx, psr); err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - sr, err := slasherServer.IsSlashableBlock(ctx, psr2) - if err != nil { - t.Errorf("Could not call RPC method: %v", err) - } - - if len(sr.ProposerSlashing) != 1 { - t.Errorf("Should return 1 slashaing proof: %v", sr) - } - if !proto.Equal(sr.ProposerSlashing[0], want) { - t.Errorf("wanted slashing proof: %v got: %v", want, sr.ProposerSlashing[0]) - } -} diff --git a/slasher/service/BUILD.bazel b/slasher/service/BUILD.bazel new file mode 100644 index 000000000000..7a731e5f44b0 --- /dev/null +++ b/slasher/service/BUILD.bazel @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["service.go"], + importpath = "github.com/prysmaticlabs/prysm/slasher/service", + visibility = ["//visibility:public"], + deps = [ + "//proto/eth/v1alpha1:go_default_library", + "//shared/cmd:go_default_library", + "//shared/debug:go_default_library", + "//shared/version:go_default_library", + "//slasher/db:go_default_library", + "//slasher/rpc:go_default_library", + "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", + "@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library", + "@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", + "@com_github_urfave_cli//:go_default_library", + "@io_opencensus_go//plugin/ocgrpc:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//credentials:go_default_library", + "@org_golang_google_grpc//reflection:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["service_test.go"], + embed = [":go_default_library"], + deps = [ + "//shared/testutil:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", + "@com_github_sirupsen_logrus//hooks/test:go_default_library", + "@com_github_urfave_cli//:go_default_library", + ], +) diff --git a/slasher/service.go b/slasher/service/service.go similarity index 56% rename from slasher/service.go rename to slasher/service/service.go index dda3d010a253..cd776818918b 100644 --- a/slasher/service.go +++ b/slasher/service/service.go @@ -1,25 +1,38 @@ -// Package slasher defines the service used to retrieve slashings proofs. -package slasher +// Package service defines the service used to retrieve slashings proofs and +// feed attestations and block headers into the slasher db. +package service import ( "fmt" "net" + "os" + "os/signal" + "path" + "sync" + "syscall" + + grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/prysmaticlabs/prysm/shared/cmd" + "github.com/prysmaticlabs/prysm/shared/debug" + "github.com/prysmaticlabs/prysm/shared/version" + "github.com/prysmaticlabs/prysm/slasher/rpc" + "github.com/urfave/cli" + "go.opencensus.io/plugin/ocgrpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/reflection" middleware "github.com/grpc-ecosystem/go-grpc-middleware" recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" - grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/slasher/db" - "github.com/prysmaticlabs/prysm/slasher/rpc" "github.com/sirupsen/logrus" - "go.opencensus.io/plugin/ocgrpc" "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/reflection" ) var log logrus.FieldLogger +const slasherDBName = "slasherdata" + func init() { log = logrus.WithField("prefix", "slasherRPC") } @@ -34,6 +47,9 @@ type Service struct { listener net.Listener credentialError error failStatus error + ctx *cli.Context + lock sync.RWMutex + stop chan struct{} // Channel to wait for termination notifications. } // Config options for the slasher server. @@ -46,16 +62,59 @@ type Config struct { // NewRPCService creates a new instance of a struct implementing the SlasherService // interface. -func NewRPCService(cfg *Config) *Service { - return &Service{ +func NewRPCService(cfg *Config, ctx *cli.Context) (*Service, error) { + s := &Service{ slasherDb: cfg.SlasherDb, port: cfg.Port, + withCert: cfg.CertFlag, + withKey: cfg.KeyFlag, + ctx: ctx, + stop: make(chan struct{}), + } + if err := s.startDB(s.ctx); err != nil { + return nil, err } + + return s, nil } // Start the gRPC server. func (s *Service) Start() { - log.Info("Starting service on port: %v", s.port) + s.lock.Lock() + log.WithFields(logrus.Fields{ + "version": version.GetVersion(), + }).Info("Starting hash slinging slasher node") + s.startSlasher() + stop := s.stop + s.lock.Unlock() + + go func() { + sigc := make(chan os.Signal, 1) + signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) + defer signal.Stop(sigc) + <-sigc + log.Info("Got interrupt, shutting down...") + debug.Exit(s.ctx) // Ensure trace and CPU profile data are flushed. + go s.Close() + for i := 10; i > 0; i-- { + <-sigc + if i > 1 { + log.Info("Already shutting down, interrupt more to panic", "times", i-1) + } + } + panic("Panic closing the hash slinging slasher node") + }() + + // Wait for stop channel to be closed. + select { + case <-stop: + return + default: + } + +} +func (s *Service) startSlasher() { + log.Info("Starting service on port: ", s.port) lis, err := net.Listen("tcp", fmt.Sprintf(":%s", s.port)) if err != nil { log.Errorf("Could not listen to port in Start() :%s: %v", s.port, err) @@ -108,6 +167,9 @@ func (s *Service) Start() { // Stop the service. func (s *Service) Stop() error { log.Info("Stopping service") + if s.slasherDb != nil { + s.slasherDb.Close() + } if s.listener != nil { s.grpcServer.GracefulStop() log.Debug("Initiated graceful stop of gRPC server") @@ -115,6 +177,19 @@ func (s *Service) Stop() error { return nil } +// Close handles graceful shutdown of the system. +func (s *Service) Close() { + s.lock.Lock() + defer s.lock.Unlock() + + log.Info("Stopping hash slinging slasher") + s.Stop() + if err := s.slasherDb.Close(); err != nil { + log.Errorf("Failed to close slasher database: %v", err) + } + close(s.stop) +} + // Status returns nil, credentialError or fail status. func (s *Service) Status() error { if s.credentialError != nil { @@ -125,3 +200,25 @@ func (s *Service) Status() error { } return nil } + +func (s *Service) startDB(ctx *cli.Context) error { + baseDir := ctx.GlobalString(cmd.DataDirFlag.Name) + dbPath := path.Join(baseDir, slasherDBName) + d, err := db.NewDB(dbPath) + if err != nil { + return err + } + if s.ctx.GlobalBool(cmd.ClearDB.Name) { + if err := d.ClearDB(); err != nil { + return err + } + d, err = db.NewDB(dbPath) + if err != nil { + return err + } + } + + log.WithField("path", dbPath).Info("Checking db") + s.slasherDb = d + return nil +} diff --git a/slasher/service_test.go b/slasher/service/service_test.go similarity index 68% rename from slasher/service_test.go rename to slasher/service/service_test.go index 338a92ad1fd4..17099944303f 100644 --- a/slasher/service_test.go +++ b/slasher/service/service_test.go @@ -1,11 +1,14 @@ -package slasher +package service import ( "errors" + "flag" "fmt" "io/ioutil" "testing" + "github.com/urfave/cli" + "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/sirupsen/logrus" logTest "github.com/sirupsen/logrus/hooks/test" @@ -18,29 +21,38 @@ func init() { func TestLifecycle_OK(t *testing.T) { hook := logTest.NewGlobal() - rpcService := NewRPCService(&Config{ + app := cli.NewApp() + set := flag.NewFlagSet("test", 0) + context := cli.NewContext(app, set, nil) + rpcService, err := NewRPCService(&Config{ Port: "7348", CertFlag: "alice.crt", KeyFlag: "alice.key", - }) - + }, context) + if err != nil { + t.Error("gRPC Service fail to initialize:", err) + } rpcService.Start() testutil.AssertLogsContain(t, hook, "Starting service") testutil.AssertLogsContain(t, hook, "Listening on port") - rpcService.Stop() + rpcService.Close() testutil.AssertLogsContain(t, hook, "Stopping service") } func TestRPC_BadEndpoint(t *testing.T) { hook := logTest.NewGlobal() - - rpcService := NewRPCService(&Config{ + app := cli.NewApp() + set := flag.NewFlagSet("test", 0) + context := cli.NewContext(app, set, nil) + rpcService, err := NewRPCService(&Config{ Port: "ralph merkle!!!", - }) - + }, context) + if err != nil { + t.Error("gRPC Service fail to initialize:", err) + } testutil.AssertLogsDoNotContain(t, hook, "Could not listen to port in Start()") testutil.AssertLogsDoNotContain(t, hook, "Could not load TLS keys") testutil.AssertLogsDoNotContain(t, hook, "Could not serve gRPC") @@ -50,7 +62,7 @@ func TestRPC_BadEndpoint(t *testing.T) { testutil.AssertLogsContain(t, hook, "Starting service") testutil.AssertLogsContain(t, hook, "Could not listen to port in Start()") - rpcService.Stop() + rpcService.Close() } func TestStatus_CredentialError(t *testing.T) { @@ -64,16 +76,21 @@ func TestStatus_CredentialError(t *testing.T) { func TestRPC_InsecureEndpoint(t *testing.T) { hook := logTest.NewGlobal() - rpcService := NewRPCService(&Config{ + app := cli.NewApp() + set := flag.NewFlagSet("test", 0) + context := cli.NewContext(app, set, nil) + rpcService, err := NewRPCService(&Config{ Port: "7777", - }) - + }, context) + if err != nil { + t.Error("gRPC Service fail to initialize:", err) + } rpcService.Start() testutil.AssertLogsContain(t, hook, "Starting service") testutil.AssertLogsContain(t, hook, fmt.Sprint("Listening on port")) testutil.AssertLogsContain(t, hook, "You are using an insecure gRPC connection") - rpcService.Stop() + rpcService.Close() testutil.AssertLogsContain(t, hook, "Stopping service") } diff --git a/slasher/usage.go b/slasher/usage.go new file mode 100644 index 000000000000..9440fb0e1d0c --- /dev/null +++ b/slasher/usage.go @@ -0,0 +1,98 @@ +// This code was adapted from https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/usage.go +package main + +import ( + "io" + "sort" + + "github.com/prysmaticlabs/prysm/shared/cmd" + "github.com/prysmaticlabs/prysm/shared/debug" + "github.com/prysmaticlabs/prysm/slasher/flags" + "github.com/urfave/cli" +) + +var appHelpTemplate = `NAME: + {{.App.Name}} - {{.App.Usage}} +USAGE: + {{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}} + {{if .App.Version}} +AUTHOR: + {{range .App.Authors}}{{ . }}{{end}} + {{end}}{{if .App.Commands}} +GLOBAL OPTIONS: + {{range .App.Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} + {{end}}{{end}}{{if .FlagGroups}} +{{range .FlagGroups}}{{.Name}} OPTIONS: + {{range .Flags}}{{.}} + {{end}} +{{end}}{{end}}{{if .App.Copyright }} +COPYRIGHT: + {{.App.Copyright}} +VERSION: + {{.App.Version}} + {{end}}{{if len .App.Authors}} + {{end}} +` + +type flagGroup struct { + Name string + Flags []cli.Flag +} + +var appHelpFlagGroups = []flagGroup{ + { + Name: "cmd", + Flags: []cli.Flag{ + cmd.VerbosityFlag, + cmd.DataDirFlag, + cmd.EnableTracingFlag, + cmd.TracingProcessNameFlag, + cmd.TracingEndpointFlag, + cmd.TraceSampleFractionFlag, + cmd.BootstrapNode, + cmd.MonitoringPortFlag, + cmd.LogFormat, + cmd.LogFileName, + }, + }, + { + Name: "debug", + Flags: []cli.Flag{ + debug.PProfFlag, + debug.PProfAddrFlag, + debug.PProfPortFlag, + debug.MemProfileRateFlag, + debug.CPUProfileFlag, + debug.TraceFlag, + }, + }, + { + Name: "slasher", + Flags: []cli.Flag{ + flags.CertFlag, + flags.KeyFlag, + flags.RPCPort, + }, + }, +} + +func init() { + cli.AppHelpTemplate = appHelpTemplate + + type helpData struct { + App interface{} + FlagGroups []flagGroup + } + + originalHelpPrinter := cli.HelpPrinter + cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) { + if tmpl == appHelpTemplate { + for _, group := range appHelpFlagGroups { + sort.Sort(cli.FlagsByName(group.Flags)) + } + originalHelpPrinter(w, tmpl, helpData{data, appHelpFlagGroups}) + } else { + originalHelpPrinter(w, tmpl, data) + } + } +} diff --git a/slasher/usage_test.go b/slasher/usage_test.go new file mode 100644 index 000000000000..a8652d502616 --- /dev/null +++ b/slasher/usage_test.go @@ -0,0 +1,41 @@ +package main + +import ( + "testing" + + "github.com/urfave/cli" +) + +func TestAllFlagsExistInHelp(t *testing.T) { + // If this test is failing, it is because you've recently added/removed a + // flag in beacon chain main.go, but did not add/remove it to the usage.go + // flag grouping (appHelpFlagGroups). + + var helpFlags []cli.Flag + for _, group := range appHelpFlagGroups { + helpFlags = append(helpFlags, group.Flags...) + } + + for _, flag := range appFlags { + if !doesFlagExist(flag, helpFlags) { + t.Errorf("Flag %s does not exist in help/usage flags.", flag.GetName()) + } + } + + for _, flag := range helpFlags { + if !doesFlagExist(flag, appFlags) { + t.Errorf("Flag %s does not exist in main.go, "+ + "but exists in help flags", flag.GetName()) + } + } +} + +func doesFlagExist(flag cli.Flag, flags []cli.Flag) bool { + for _, f := range flags { + if f == flag { + return true + } + } + + return false +} diff --git a/tools/extractor/BUILD.bazel b/tools/extractor/BUILD.bazel new file mode 100644 index 000000000000..0a838619bbb9 --- /dev/null +++ b/tools/extractor/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/prysm/tools/extractor", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/core/state/interop:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/db/filters:go_default_library", + "//shared/featureconfig:go_default_library", + ], +) + +go_binary( + name = "extractor", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/tools/extractor/main.go b/tools/extractor/main.go new file mode 100644 index 000000000000..df7c8144004a --- /dev/null +++ b/tools/extractor/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "context" + "flag" + "fmt" + + "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop" + "github.com/prysmaticlabs/prysm/beacon-chain/db" + "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" + "github.com/prysmaticlabs/prysm/shared/featureconfig" +) + +var ( + // Required fields + datadir = flag.String("datadir", "", "Path to data directory.") + + state = flag.Uint("state", 0, "Extract state at this slot.") +) + +func init() { + fc := featureconfig.Get() + fc.WriteSSZStateTransitions = true + featureconfig.Init(fc) +} + +func main() { + flag.Parse() + fmt.Println("Starting process...") + d, err := db.NewDB(*datadir) + if err != nil { + panic(err) + } + ctx := context.Background() + slot := uint64(*state) + roots, err := d.BlockRoots(ctx, filters.NewFilter().SetStartSlot(slot).SetEndSlot(slot)) + if err != nil { + panic(err) + } + if len(roots) != 1 { + fmt.Printf("Expected 1 block root for slot %d, got %d roots", *state, len(roots)) + } + s, err := d.State(ctx, roots[0]) + if err != nil { + panic(err) + } + + interop.WriteStateToDisk(s) + fmt.Println("done") +} diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 5b00371ce63d..1c310643205f 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -13,6 +13,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/validator/client", visibility = ["//validator:__subpackages__"], deps = [ + "//beacon-chain/core/helpers:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", @@ -24,6 +25,7 @@ go_library( "@com_github_gogo_protobuf//types:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library", + "@com_github_grpc_ecosystem_go_grpc_prometheus//: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", diff --git a/validator/client/runner.go b/validator/client/runner.go index dcce0102d810..7ed566aac114 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -73,7 +73,7 @@ func run(ctx context.Context, v Validator) { // Keep trying to update assignments if they are nil or if we are past an // epoch transition in the beacon node's state. - if err := v.UpdateAssignments(slotCtx, slot); err != nil { + if err := v.UpdateAssignments(ctx, slot); err != nil { handleAssignmentError(err, slot) cancel() span.End() diff --git a/validator/client/service.go b/validator/client/service.go index 298a30c279ff..04b8e3373a5d 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -6,6 +6,7 @@ import ( middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing" + grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/pkg/errors" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -81,9 +82,11 @@ func (v *ValidatorService) Start() { grpc.WithStatsHandler(&ocgrpc.ClientHandler{}), grpc.WithStreamInterceptor(middleware.ChainStreamClient( grpc_opentracing.StreamClientInterceptor(), + grpc_prometheus.StreamClientInterceptor, )), grpc.WithUnaryInterceptor(middleware.ChainUnaryClient( grpc_opentracing.UnaryClientInterceptor(), + grpc_prometheus.UnaryClientInterceptor, )), } conn, err := grpc.DialContext(v.ctx, v.endpoint, opts...) diff --git a/validator/client/validator.go b/validator/client/validator.go index e2e4d4df6ed0..e5333cbc0846 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -9,6 +9,7 @@ import ( ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/keystore" @@ -182,6 +183,9 @@ func (v *validator) UpdateAssignments(ctx context.Context, slot uint64) error { // Do nothing if not epoch start AND assignments already exist. return nil } + // Set deadline to end of epoch. + ctx, cancel := context.WithDeadline(ctx, v.SlotDeadline(helpers.StartSlot(helpers.SlotToEpoch(slot)+1))) + defer cancel() ctx, span := trace.StartSpan(ctx, "validator.UpdateAssignments") defer span.End() diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index 180b15685ef0..412f259d2299 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -79,7 +79,7 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ aggregationBitfield := bitfield.NewBitlist(uint64(len(assignment.Committee))) aggregationBitfield.SetBitAt(indexInCommittee, true) - log = log.WithField("bitfield", fmt.Sprintf("%#x", aggregationBitfield)) + log = log.WithField("bitfield", fmt.Sprintf("%08b", aggregationBitfield)) domain, err := v.validatorClient.DomainData(ctx, &pb.DomainRequest{Epoch: data.Target.Epoch, Domain: params.BeaconConfig().DomainBeaconAttester}) if err != nil { From a35da60790b0fec9c2eb7e47bc0452df743bb3de Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 5 Nov 2019 20:28:07 -0800 Subject: [PATCH 20/82] Clean up (#3933) --- beacon-chain/cache/committee.go | 14 ++++----- beacon-chain/cache/committee_test.go | 30 +++++++++--------- beacon-chain/core/blocks/block_operations.go | 33 ++++++-------------- beacon-chain/core/helpers/committee.go | 8 ++--- beacon-chain/core/state/transition_test.go | 10 +++--- beacon-chain/rpc/beacon_chain_server.go | 4 +-- beacon-chain/rpc/validator_server.go | 2 +- proto/beacon/p2p/v1/types.proto | 2 +- proto/eth/v1alpha1/beacon_chain.proto | 2 +- shared/params/config.go | 3 -- 10 files changed, 46 insertions(+), 62 deletions(-) diff --git a/beacon-chain/cache/committee.go b/beacon-chain/cache/committee.go index fe2775cad247..980de4d8df6b 100644 --- a/beacon-chain/cache/committee.go +++ b/beacon-chain/cache/committee.go @@ -35,13 +35,13 @@ var ( // Committee defines the committee per epoch and shard. type Committee struct { - StartShard uint64 + CommitteeIndex 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. type CommitteeCache struct { CommitteeCache *cache.FIFO lock sync.RWMutex @@ -64,8 +64,8 @@ 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. +// ShuffledIndices fetches the shuffled indices by epoch and committee. Every list of indices +// represent one committee. Returns true if the list exists with epoch and committee. Otherwise returns false, nil. func (c *CommitteeCache) ShuffledIndices(epoch uint64, index uint64) ([]uint64, error) { if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { return nil, nil @@ -174,8 +174,8 @@ func (c *CommitteeCache) CommitteeCount(epoch uint64) (uint64, bool, error) { 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) { +// CommitteeIndex returns the committee index in a given epoch as stored in cache. +func (c *CommitteeCache) CommitteeIndex(epoch uint64) (uint64, bool, error) { if !featureconfig.Get().EnableShuffledIndexCache && !featureconfig.Get().EnableNewCache { return 0, false, nil } @@ -198,7 +198,7 @@ func (c *CommitteeCache) StartShard(epoch uint64) (uint64, bool, error) { return 0, false, ErrNotCommittee } - return item.StartShard, true, nil + return item.CommitteeIndex, true, nil } // ActiveIndices returns the active indices of a given epoch stored in cache. diff --git a/beacon-chain/cache/committee_test.go b/beacon-chain/cache/committee_test.go index 0f9778f81b5d..cb957b330dfe 100644 --- a/beacon-chain/cache/committee_test.go +++ b/beacon-chain/cache/committee_test.go @@ -36,12 +36,12 @@ func TestCommitteeCache_CommitteesByEpoch(t *testing.T) { Epoch: 1, Committee: []uint64{1, 2, 3, 4, 5, 6}, CommitteeCount: 3, - StartShard: 1, + CommitteeIndex: 1, } epoch := uint64(1) - startShard := uint64(1) - indices, err := cache.ShuffledIndices(epoch, startShard) + committeeIndex := uint64(1) + indices, err := cache.ShuffledIndices(epoch, committeeIndex) if err != nil { t.Fatal(err) } @@ -52,12 +52,12 @@ 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(2) + indices, err = cache.ShuffledIndices(epoch, 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", @@ -174,34 +174,34 @@ func TestCommitteeCache_CommitteesCount(t *testing.T) { } } -func TestCommitteeCache_ShardCount(t *testing.T) { +func TestCommitteeCache_IndexCount(t *testing.T) { cache := NewCommitteeCache() - startShard := uint64(7) + committeeIndex := uint64(7) epoch := uint64(3) - item := &Committee{Epoch: epoch, StartShard: startShard} + item := &Committee{Epoch: epoch, CommitteeIndex: committeeIndex} - _, exists, err := cache.StartShard(1) + _, exists, err := cache.CommitteeIndex(1) if err != nil { t.Fatal(err) } if exists { - t.Error("Expected start shard not to exist in empty cache") + t.Error("Expected start index not to exist in empty cache") } if err := cache.AddCommitteeShuffledList(item); err != nil { t.Fatal(err) } - shard, exists, err := cache.StartShard(epoch) + index, exists, err := cache.CommitteeIndex(epoch) if err != nil { t.Fatal(err) } if !exists { - t.Error("Expected start shard to be in cache") + t.Error("Expected start index to be in cache") } - if shard != startShard { - t.Errorf("wanted: %d, got: %d", startShard, shard) + if index != committeeIndex { + t.Errorf("wanted: %d, got: %d", committeeIndex, index) } } diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index fd80f2399315..ab05a6741c03 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -506,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)) diff --git a/beacon-chain/core/helpers/committee.go b/beacon-chain/core/helpers/committee.go index ce08a1c7071c..94843c83010d 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -128,7 +128,7 @@ func ComputeCommittee( 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) @@ -268,11 +268,11 @@ func VerifyBitfieldLength(bf bitfield.Bitfield, committeeSize uint64) error { func VerifyAttestationBitfieldLengths(bState *pb.BeaconState, att *ethpb.Attestation) error { 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 { @@ -311,7 +311,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} { diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index dc9fd4898234..65908745deea 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -689,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) @@ -702,7 +702,7 @@ 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{}, AggregationBits: []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, @@ -723,7 +723,7 @@ func BenchmarkProcessEpoch65536Validators(b *testing.B) { } // Precache the shuffled indices - for i := uint64(0); i < shardCount; i++ { + for i := uint64(0); i < comitteeCount; i++ { if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } @@ -743,7 +743,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { helpers.ClearAllCaches() 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{ @@ -878,7 +878,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { } // Precache the shuffled indices - for i := uint64(0); i < shardCount; i++ { + for i := uint64(0); i < committeeCount; i++ { if _, err := helpers.BeaconCommittee(s, 0, i); err != nil { b.Fatal(err) } diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index 50ffdce076a0..de9be747ab1d 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -42,7 +42,7 @@ type BeaconChainServer struct { } // sortableAttestations implements the Sort interface to sort attestations -// by committeeIndex as the canonical sorting attribute. +// by slot as the canonical sorting attribute. type sortableAttestations []*ethpb.Attestation func (s sortableAttestations) Len() int { return len(s) } @@ -52,7 +52,7 @@ func (s sortableAttestations) Less(i, j int) bool { } // ListAttestations retrieves attestations by block root, slot, or epoch. -// Attestations are sorted by crosslink committeeIndex 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 diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index b033279974f4..9fb121049fc7 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -25,7 +25,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 diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index 5e45cfbdb744..10e350e337c1 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -79,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; } diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index fec46f308e2b..f2d4e2b40a2f 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 committee 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 diff --git a/shared/params/config.go b/shared/params/config.go index f61a038b43c5..08c51c00b7c1 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -47,7 +47,6 @@ type BeaconChainConfig struct { 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. @@ -142,7 +141,6 @@ var defaultBeaconConfig = &BeaconChainConfig{ SlotsPerHistoricalRoot: 8192, MinValidatorWithdrawabilityDelay: 256, PersistentCommitteePeriod: 2048, - MaxEpochsPerCrosslink: 64, MinEpochsToInactivityPenalty: 4, Eth1FollowDistance: 1024, @@ -266,7 +264,6 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.SlotsPerHistoricalRoot = 64 minimalConfig.MinValidatorWithdrawabilityDelay = 256 minimalConfig.PersistentCommitteePeriod = 2048 - minimalConfig.MaxEpochsPerCrosslink = 4 minimalConfig.MinEpochsToInactivityPenalty = 4 // State vector lengths From d5c2e0cd35493e4f4c39a117cd64930cc2e26808 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 6 Nov 2019 07:48:59 -0800 Subject: [PATCH 21/82] Remove shard filter in db (#3936) --- beacon-chain/db/filters/filter.go | 22 ++++++---------------- beacon-chain/db/filters/filter_test.go | 10 ++++------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/beacon-chain/db/filters/filter.go b/beacon-chain/db/filters/filter.go index 0ecd6d21c5bc..985061d0df29 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 72e2598c8a6f..53c69ecfb752 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") } From 45a88bbefdb1978f3e0985d6920067be773bfe65 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 6 Nov 2019 08:43:10 -0800 Subject: [PATCH 22/82] Remove lightouse compatibility test (#3939) --- beacon-chain/p2p/encoder/BUILD.bazel | 1 - beacon-chain/p2p/encoder/ssz_test.go | 11 ----------- 2 files changed, 12 deletions(-) diff --git a/beacon-chain/p2p/encoder/BUILD.bazel b/beacon-chain/p2p/encoder/BUILD.bazel index bb6865b1e0ad..bd38107582c8 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 d6d05743f578..ffaa10083503 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, 0, 0, 0, 0, 0, 0, 28, 71, 156, 79, 199, 27, 222, 126, 43, 250, 217, 225, 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, 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{ From bb6476209c50a0e4d9ba930936a13fe9f7963609 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 7 Nov 2019 11:12:21 -0800 Subject: [PATCH 23/82] Update Committee Cache for v0.9 (#3948) * Updated committee cache * Removed shuffled indices cache * Started testing run time * Lint * Fixed test --- .../forkchoice/process_attestation.go | 1 - .../blockchain/forkchoice/process_block.go | 7 ++ beacon-chain/cache/BUILD.bazel | 2 - beacon-chain/cache/committee.go | 58 ++++------ beacon-chain/cache/committee_test.go | 74 ++---------- beacon-chain/cache/shuffled_indices.go | 106 ------------------ beacon-chain/cache/shuffled_indices_test.go | 93 --------------- .../core/blocks/block_operations_test.go | 1 - .../core/epoch/epoch_processing_test.go | 2 - beacon-chain/core/helpers/cache.go | 6 - beacon-chain/core/helpers/committee.go | 21 +--- beacon-chain/core/helpers/committee_test.go | 54 --------- beacon-chain/gateway/gateway.go | 4 +- beacon-chain/rpc/attester_server.go | 4 +- beacon-chain/rpc/attester_server_test.go | 4 +- validator/client/validator_attest.go | 1 - 16 files changed, 42 insertions(+), 396 deletions(-) delete mode 100644 beacon-chain/cache/shuffled_indices.go delete mode 100644 beacon-chain/cache/shuffled_indices_test.go diff --git a/beacon-chain/blockchain/forkchoice/process_attestation.go b/beacon-chain/blockchain/forkchoice/process_attestation.go index 36b4f170f277..f13766e0809b 100644 --- a/beacon-chain/blockchain/forkchoice/process_attestation.go +++ b/beacon-chain/blockchain/forkchoice/process_attestation.go @@ -205,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 { diff --git a/beacon-chain/blockchain/forkchoice/process_block.go b/beacon-chain/blockchain/forkchoice/process_block.go index c4fda088dec7..9f8506d021b3 100644 --- a/beacon-chain/blockchain/forkchoice/process_block.go +++ b/beacon-chain/blockchain/forkchoice/process_block.go @@ -215,6 +215,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 diff --git a/beacon-chain/cache/BUILD.bazel b/beacon-chain/cache/BUILD.bazel index 4c33da840c59..1ec8954ba298 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/committee.go b/beacon-chain/cache/committee.go index 980de4d8df6b..4339fbcc706e 100644 --- a/beacon-chain/cache/committee.go +++ b/beacon-chain/cache/committee.go @@ -8,6 +8,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prysmaticlabs/prysm/shared/featureconfig" + "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "k8s.io/client-go/tools/cache" ) @@ -33,15 +34,14 @@ var ( }) ) -// Committee defines the committee per epoch and shard. +// Committee defines the committee per epoch and index. type Committee struct { - CommitteeIndex uint64 CommitteeCount uint64 Epoch uint64 Committee []uint64 } -// CommitteeCache is a struct with 1 queue for looking up shuffled indices list by epoch and committee. +// 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 @@ -64,15 +64,17 @@ func NewCommitteeCache() *CommitteeCache { } } -// ShuffledIndices fetches the shuffled indices by epoch and committee. Every list of indices -// represent one committee. Returns true if the list exists with epoch and committee. Otherwise returns false, nil. -func (c *CommitteeCache) ShuffledIndices(epoch uint64, index 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 } @@ -89,7 +91,13 @@ func (c *CommitteeCache) ShuffledIndices(epoch uint64, index uint64) ([]uint64, return nil, ErrNotCommittee } - start, end := startEndIndices(item, index) + 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 } @@ -147,40 +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) { - 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.CommitteeCount, true, nil -} - -// CommitteeIndex returns the committee index in a given epoch as stored in cache. -func (c *CommitteeCache) CommitteeIndex(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 @@ -198,7 +180,7 @@ func (c *CommitteeCache) CommitteeIndex(epoch uint64) (uint64, bool, error) { return 0, false, ErrNotCommittee } - return item.CommitteeIndex, true, nil + return item.CommitteeCount / params.BeaconConfig().SlotsPerEpoch, true, nil } // ActiveIndices returns the active indices of a given epoch stored in cache. diff --git a/beacon-chain/cache/committee_test.go b/beacon-chain/cache/committee_test.go index cb957b330dfe..2bdbfee69cd1 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, - CommitteeIndex: 1, } - epoch := uint64(1) + slot := uint64(item.Epoch * params.BeaconConfig().SlotsPerEpoch) committeeIndex := uint64(1) - indices, err := cache.ShuffledIndices(epoch, committeeIndex) + indices, err := cache.ShuffledIndices(slot, committeeIndex) if err != nil { t.Fatal(err) } @@ -52,11 +53,12 @@ func TestCommitteeCache_CommitteesByEpoch(t *testing.T) { if err := cache.AddCommitteeShuffledList(item); err != nil { t.Fatal(err) } - wantedIndex := uint64(2) - indices, err = cache.ShuffledIndices(epoch, wantedIndex) + wantedIndex := uint64(0) + indices, err = cache.ShuffledIndices(slot, wantedIndex) if err != nil { t.Fatal(err) } + start, end := startEndIndices(item, wantedIndex) if !reflect.DeepEqual(indices, item.Committee[start:end]) { t.Errorf( @@ -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_IndexCount(t *testing.T) { - cache := NewCommitteeCache() - - committeeIndex := uint64(7) - epoch := uint64(3) - item := &Committee{Epoch: epoch, CommitteeIndex: committeeIndex} - - _, exists, err := cache.CommitteeIndex(1) - if err != nil { - t.Fatal(err) - } - if exists { - t.Error("Expected start index not to exist in empty cache") - } - - if err := cache.AddCommitteeShuffledList(item); err != nil { - t.Fatal(err) - } - - index, exists, err := cache.CommitteeIndex(epoch) - if err != nil { - t.Fatal(err) - } - if !exists { - t.Error("Expected start index to be in cache") - } - if index != committeeIndex { - t.Errorf("wanted: %d, got: %d", committeeIndex, index) - } -} - 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 7fb531458ec1..000000000000 --- 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 da2b6fe72009..000000000000 --- 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/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 1734c856d145..3f7b3dedc1f7 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -502,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{ diff --git a/beacon-chain/core/epoch/epoch_processing_test.go b/beacon-chain/core/epoch/epoch_processing_test.go index 942b5253eea6..5c5ce0729b68 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -15,8 +15,6 @@ import ( ) func init() { - helpers.ClearShuffledValidatorCache() - // TODO(2312): remove this and use the mainnet count. c := params.BeaconConfig() c.MinGenesisActiveValidatorCount = 16384 diff --git a/beacon-chain/core/helpers/cache.go b/beacon-chain/core/helpers/cache.go index 62fd2848566a..ffa627678468 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 94843c83010d..b53974a20f4d 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -16,7 +16,6 @@ import ( "google.golang.org/grpc/status" ) -var shuffledIndicesCache = cache.NewShuffledIndicesCache() var committeeCache = cache.NewCommitteeCache() // CommitteeCountAtSlot returns the number of crosslink committees of a slot. @@ -66,7 +65,7 @@ func CommitteeCountAtSlot(state *pb.BeaconState, slot 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, index) + indices, err := committeeCache.ShuffledIndices(slot, index) if err != nil { return nil, errors.Wrap(err, "could not interface with committee cache") } @@ -119,15 +118,6 @@ func ComputeCommittee( 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(index, 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 committee index. shuffledIndices := make([]uint64, end-start) for i := start; i < end; i++ { @@ -137,13 +127,6 @@ func ComputeCommittee( } shuffledIndices[i-start] = indices[permutedIndex] } - if err := shuffledIndicesCache.AddShuffledValidatorList(&cache.IndicesByIndexSeed{ - Index: index, - Seed: seed[:], - ShuffledIndices: shuffledIndices, - }); err != nil { - return []uint64{}, errors.Wrap(err, "could not add shuffled indices list to cache") - } return shuffledIndices, nil } @@ -319,7 +302,7 @@ func UpdateCommitteeCache(state *pb.BeaconState) error { if err != nil { return err } - count, err := CommitteeCountAtSlot(state, state.Slot) + count, err := CommitteeCountAtSlot(state, epoch*params.BeaconConfig().SlotsPerEpoch) if err != nil { return err } diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index d9db33c12f2a..1b1ee7fe2396 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -75,55 +75,6 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { } } -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), - } - - epoch := CurrentEpoch(state) - indices, err := ActiveValidatorIndices(state, epoch) - if err != nil { - t.Fatal(err) - } - seed, err := Seed(state, epoch, params.BeaconConfig().DomainBeaconAttester) - if err != nil { - t.Fatal(err) - } - - // Test shuffled indices are correct for index 3 committee - index := uint64(3) - committee3, err := ComputeCommittee(indices, seed, index, committeeCount) - if err != nil { - t.Errorf("could not compute committee: %v", err) - } - - cachedIndices, err := shuffledIndicesCache.IndicesByIndexSeed(index, 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) { committeeSize := uint64(16) validators := make([]*ethpb.Validator, committeeSize*params.BeaconConfig().SlotsPerEpoch) @@ -530,7 +481,6 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { } func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 300000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -568,7 +518,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{ @@ -606,7 +555,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{ @@ -645,7 +593,6 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { } func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 1000000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -684,7 +631,6 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { } func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { - ClearShuffledValidatorCache() validators := make([]*ethpb.Validator, 4000000) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ diff --git a/beacon-chain/gateway/gateway.go b/beacon-chain/gateway/gateway.go index 0b0e84d88ccb..640cc435873d 100644 --- a/beacon-chain/gateway/gateway.go +++ b/beacon-chain/gateway/gateway.go @@ -46,8 +46,8 @@ func (g *Gateway) Start() { } g.conn = conn - - gwmux := gwruntime.NewServeMux(gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.JSONPb{OrigName:false})) + + gwmux := gwruntime.NewServeMux(gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.JSONPb{OrigName: false})) for _, f := range []func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error{ ethpb.RegisterNodeHandler, ethpb.RegisterBeaconChainHandler, diff --git a/beacon-chain/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index e5626298b2e9..c7d9b7c66e06 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -112,8 +112,8 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest } res = ðpb.AttestationData{ - Slot: req.Slot, - Index: req.CommitteeIndex, + Slot: req.Slot, + Index: req.CommitteeIndex, BeaconBlockRoot: headRoot[:], Source: headState.CurrentJustifiedCheckpoint, Target: ðpb.Checkpoint{ diff --git a/beacon-chain/rpc/attester_server_test.go b/beacon-chain/rpc/attester_server_test.go index 0ac7dc928f64..31547868b2f1 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester_server_test.go @@ -129,7 +129,7 @@ func TestRequestAttestation_OK(t *testing.T) { } expectedInfo := ðpb.AttestationData{ - Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, + Slot: 3*params.BeaconConfig().SlotsPerEpoch + 1, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: 2, @@ -211,7 +211,7 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { } expectedInfo := ðpb.AttestationData{ - Slot: req.Slot, + Slot: req.Slot, BeaconBlockRoot: blockRoot[:], Source: ðpb.Checkpoint{ Epoch: helpers.SlotToEpoch(1500), diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index 412f259d2299..0d40becf4002 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -79,7 +79,6 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, pubKey [ aggregationBitfield := bitfield.NewBitlist(uint64(len(assignment.Committee))) aggregationBitfield.SetBitAt(indexInCommittee, true) - log = log.WithField("bitfield", fmt.Sprintf("%08b", aggregationBitfield)) domain, err := v.validatorClient.DomainData(ctx, &pb.DomainRequest{Epoch: data.Target.Epoch, Domain: params.BeaconConfig().DomainBeaconAttester}) if err != nil { From b9256840c0ddf21960cf1a0246273f7abbd0d411 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Thu, 7 Nov 2019 22:06:31 -0800 Subject: [PATCH 24/82] Safeguard against nil head state --- beacon-chain/rpc/attester_server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/beacon-chain/rpc/attester_server.go b/beacon-chain/rpc/attester_server.go index c7d9b7c66e06..dc200e221841 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester_server.go @@ -94,6 +94,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) From bbe99082f55715baeb56e7c608e47dfac75ba063 Mon Sep 17 00:00:00 2001 From: nisdas Date: Fri, 8 Nov 2019 19:33:03 +0800 Subject: [PATCH 25/82] address edge case --- beacon-chain/db/kv/finalized_block_roots_test.go | 5 ++--- beacon-chain/sync/validate_beacon_attestation.go | 3 ++- proto/eth/v1alpha1/slasher.pb.go | 5 +++-- slasher/db/min_max-span_test.go | 3 ++- validator/internal/attester_service_mock.go | 3 ++- validator/internal/node_mock.go | 3 ++- validator/internal/proposer_service_mock.go | 3 ++- validator/internal/validator_service_mock.go | 3 ++- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/beacon-chain/db/kv/finalized_block_roots_test.go b/beacon-chain/db/kv/finalized_block_roots_test.go index d3c9c6a3ddd9..9503bd1149db 100644 --- a/beacon-chain/db/kv/finalized_block_roots_test.go +++ b/beacon-chain/db/kv/finalized_block_roots_test.go @@ -57,7 +57,7 @@ func TestStore_IsFinalizedBlock(t *testing.T) { t.Errorf("Block at index %d was not considered finalized in the index", i) } } - for i := slotsPerEpoch*3; i < len(blks); i++ { + for i := slotsPerEpoch * 3; i < len(blks); i++ { root, err := ssz.SigningRoot(blks[i]) if err != nil { t.Fatal(err) @@ -83,11 +83,10 @@ func TestStore_IsFinalized_ForkEdgeCase(t *testing.T) { blocks0 := makeBlocks(t, slotsPerEpoch*0, slotsPerEpoch, genesisBlockRoot) blocks1 := append( makeBlocks(t, slotsPerEpoch*1, 1, bytesutil.ToBytes32(sszRootOrDie(t, blocks0[len(blocks0)-1]))), // No block builds off of the first block in epoch. - makeBlocks(t, slotsPerEpoch*1+1, slotsPerEpoch-1, bytesutil.ToBytes32(sszRootOrDie(t, blocks0[len(blocks0)-1])))... + makeBlocks(t, slotsPerEpoch*1+1, slotsPerEpoch-1, bytesutil.ToBytes32(sszRootOrDie(t, blocks0[len(blocks0)-1])))..., ) blocks2 := makeBlocks(t, slotsPerEpoch*2, slotsPerEpoch, bytesutil.ToBytes32(sszRootOrDie(t, blocks1[len(blocks1)-1]))) - db := setupDB(t) defer teardownDB(t, db) ctx := context.Background() diff --git a/beacon-chain/sync/validate_beacon_attestation.go b/beacon-chain/sync/validate_beacon_attestation.go index dfc29df7bb1d..30671f9b9d4e 100644 --- a/beacon-chain/sync/validate_beacon_attestation.go +++ b/beacon-chain/sync/validate_beacon_attestation.go @@ -66,7 +66,8 @@ func (r *RegularSync) validateBeaconAttestation(ctx context.Context, msg proto.M } finalizedEpoch := r.chain.FinalizedCheckpt().Epoch - if finalizedEpoch >= att.Data.Source.Epoch || finalizedEpoch >= att.Data.Target.Epoch { + attestationDataEpochOld := finalizedEpoch >= att.Data.Source.Epoch || finalizedEpoch >= att.Data.Target.Epoch + if finalizedEpoch != 0 && attestationDataEpochOld { log.WithFields(logrus.Fields{ "AttestationRoot": fmt.Sprintf("%#x", attRoot), "TargetEpoch": att.Data.Target.Epoch, diff --git a/proto/eth/v1alpha1/slasher.pb.go b/proto/eth/v1alpha1/slasher.pb.go index bea45b2430d6..3b77ef546531 100755 --- a/proto/eth/v1alpha1/slasher.pb.go +++ b/proto/eth/v1alpha1/slasher.pb.go @@ -6,11 +6,12 @@ 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/slasher/db/min_max-span_test.go b/slasher/db/min_max-span_test.go index 9612d5a8ae8e..b8a5ab34414b 100644 --- a/slasher/db/min_max-span_test.go +++ b/slasher/db/min_max-span_test.go @@ -1,9 +1,10 @@ package db import ( - "github.com/gogo/protobuf/proto" "testing" + "github.com/gogo/protobuf/proto" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" ) diff --git a/validator/internal/attester_service_mock.go b/validator/internal/attester_service_mock.go index d122e21de965..b0b92d61fee4 100644 --- a/validator/internal/attester_service_mock.go +++ b/validator/internal/attester_service_mock.go @@ -6,11 +6,12 @@ package internal import ( context "context" + reflect "reflect" + gomock "github.com/golang/mock/gomock" v1 "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" grpc "google.golang.org/grpc" - reflect "reflect" ) // MockAttesterServiceClient is a mock of AttesterServiceClient interface diff --git a/validator/internal/node_mock.go b/validator/internal/node_mock.go index 8d90816e2030..210ab496451f 100644 --- a/validator/internal/node_mock.go +++ b/validator/internal/node_mock.go @@ -6,11 +6,12 @@ package internal import ( context "context" + reflect "reflect" + types "github.com/gogo/protobuf/types" gomock "github.com/golang/mock/gomock" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" grpc "google.golang.org/grpc" - reflect "reflect" ) // MockNodeClient is a mock of NodeClient interface diff --git a/validator/internal/proposer_service_mock.go b/validator/internal/proposer_service_mock.go index 7716f940dc8a..40ced19dfafe 100644 --- a/validator/internal/proposer_service_mock.go +++ b/validator/internal/proposer_service_mock.go @@ -6,11 +6,12 @@ package internal import ( context "context" + reflect "reflect" + gomock "github.com/golang/mock/gomock" v1 "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" grpc "google.golang.org/grpc" - reflect "reflect" ) // MockProposerServiceClient is a mock of ProposerServiceClient interface diff --git a/validator/internal/validator_service_mock.go b/validator/internal/validator_service_mock.go index fb1b2721d74d..439f73d236bf 100644 --- a/validator/internal/validator_service_mock.go +++ b/validator/internal/validator_service_mock.go @@ -6,13 +6,14 @@ package internal import ( context "context" + reflect "reflect" + types "github.com/gogo/protobuf/types" gomock "github.com/golang/mock/gomock" v1 "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" grpc "google.golang.org/grpc" metadata "google.golang.org/grpc/metadata" - reflect "reflect" ) // MockValidatorServiceClient is a mock of ValidatorServiceClient interface From 6bec964220e36a407953f35f3d3481386a1a0c41 Mon Sep 17 00:00:00 2001 From: nisdas Date: Fri, 8 Nov 2019 19:36:27 +0800 Subject: [PATCH 26/82] add test --- .../sync/validate_beacon_attestation_test.go | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/beacon-chain/sync/validate_beacon_attestation_test.go b/beacon-chain/sync/validate_beacon_attestation_test.go index f99cc0789f7c..2efe04e95cef 100644 --- a/beacon-chain/sync/validate_beacon_attestation_test.go +++ b/beacon-chain/sync/validate_beacon_attestation_test.go @@ -252,3 +252,57 @@ func TestValidateBeaconAttestation_OldAttestation(t *testing.T) { t.Error("Message was broadcasted") } } + +func TestValidateBeaconAttestation_FirstEpoch(t *testing.T) { + db := dbtest.SetupDB(t) + defer dbtest.TeardownDB(t, db) + p := p2ptest.NewTestP2P(t) + ctx := context.Background() + + rs := &RegularSync{ + db: db, + chain: &mockChain.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + initialSync: &mockSync.Sync{IsSyncing: false}, + } + + blk := ðpb.BeaconBlock{ + Slot: 1, + } + if err := db.SaveBlock(ctx, blk); err != nil { + t.Fatal(err) + } + + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + + // Attestation at genesis epoch should not be rejected + msg := ðpb.Attestation{ + Data: ðpb.AttestationData{ + BeaconBlockRoot: blockRoot[:], + Source: ðpb.Checkpoint{ + Epoch: 0, + }, + Target: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + valid, err := rs.validateBeaconAttestation(ctx, msg, p, false /*fromSelf*/) + if err != nil { + t.Errorf("Beacon attestation failed validation: %v", err) + } + if !valid { + t.Error("Beacon attestation did not pass validation") + } + + if !p.BroadcastCalled { + t.Error("Message was not broadcasted") + } +} From 166dc3b515c32d4a7d4bda9f1989788a7abcb468 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Fri, 8 Nov 2019 08:09:43 -0800 Subject: [PATCH 27/82] Fixed TestRoundRobinSync by doubling the epochs --- beacon-chain/sync/initial-sync/round_robin_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/sync/initial-sync/round_robin_test.go b/beacon-chain/sync/initial-sync/round_robin_test.go index fd137c06983b..f95097344ea3 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -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, }, }, From df3f0121196e385e81e8d8e02efeff0abfbe4ee4 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Fri, 8 Nov 2019 13:32:13 -0800 Subject: [PATCH 28/82] Unskip TestProtoCompatability (#3958) * Unskip TestProtoCompatability * Update WORKSPACE --- WORKSPACE | 2 +- proto/eth/v1alpha1/_compatibility/compatability_test.go | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 7a613acd258f..45bbcbf359f5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1201,7 +1201,7 @@ go_repository( go_repository( name = "com_github_prysmaticlabs_ethereumapis", - commit = "1205871db17ccc2fb824fc6dfa40d01c48fb6a7e", + commit = "1233869b5d734015dce0faf257f54d32d9368045", importpath = "github.com/prysmaticlabs/ethereumapis", ) diff --git a/proto/eth/v1alpha1/_compatibility/compatability_test.go b/proto/eth/v1alpha1/_compatibility/compatability_test.go index b93292190b3f..2cadc6e5c722 100644 --- a/proto/eth/v1alpha1/_compatibility/compatability_test.go +++ b/proto/eth/v1alpha1/_compatibility/compatability_test.go @@ -12,8 +12,6 @@ import ( // Test that Prysm copied protobufs have the same wire type and tag number. func TestProtoCompatability(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") - tests := []struct { a proto.Message b proto.Message From ceddcf4bb08b805b23617e9cfe5227601ce8b50b Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Fri, 8 Nov 2019 17:03:04 -0500 Subject: [PATCH 29/82] Fix minimal config (#3959) * fix minimal configs * fix hardcoded value in test --- .../spectest/block_processing_minimal_test.go | 1 - .../core/blocks/spectest/block_processing_test.go | 5 ++++- .../state/spectest/slot_processing_minimal_test.go | 1 - beacon-chain/rpc/proposer_server_test.go | 2 +- proto/ssz_proto_library.bzl | 14 +++++++------- shared/params/config.go | 3 +-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go b/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go index 9c9530a351b0..f8c72ac7861a 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestBlockProcessingMinimalYaml(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runBlockProcessingTest(t, "minimal") } diff --git a/beacon-chain/core/blocks/spectest/block_processing_test.go b/beacon-chain/core/blocks/spectest/block_processing_test.go index 105a4fa77430..ea9bd84f4f1c 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/state/spectest/slot_processing_minimal_test.go b/beacon-chain/core/state/spectest/slot_processing_minimal_test.go index b0b84faaa906..f8200022c5b7 100644 --- a/beacon-chain/core/state/spectest/slot_processing_minimal_test.go +++ b/beacon-chain/core/state/spectest/slot_processing_minimal_test.go @@ -5,6 +5,5 @@ import ( ) func TestSlotProcessingMinimal(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") runSlotProcessingTests(t, "minimal") } diff --git a/beacon-chain/rpc/proposer_server_test.go b/beacon-chain/rpc/proposer_server_test.go index 9506ba979502..dca74ca14680 100644 --- a/beacon-chain/rpc/proposer_server_test.go +++ b/beacon-chain/rpc/proposer_server_test.go @@ -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/proto/ssz_proto_library.bzl b/proto/ssz_proto_library.bzl index 415dea471b4e..dd9663f409da 100644 --- a/proto/ssz_proto_library.bzl +++ b/proto/ssz_proto_library.bzl @@ -8,13 +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", - "previous_epoch_attestations.max": "4096", - "current_epoch_attestations.max": "4096", - "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 = { diff --git a/shared/params/config.go b/shared/params/config.go index 08c51c00b7c1..7b99f75a0dfc 100644 --- a/shared/params/config.go +++ b/shared/params/config.go @@ -255,7 +255,7 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.BLSWithdrawalPrefixByte = byte(0) // Time parameters - minimalConfig.SecondsPerSlot = 6 + minimalConfig.SecondsPerSlot = 12 minimalConfig.MinAttestationInclusionDelay = 1 minimalConfig.SlotsPerEpoch = 8 minimalConfig.MinSeedLookahead = 1 @@ -278,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 From 0438c52cd3a76ed4935ead3f054ec4766273c53b Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sat, 9 Nov 2019 07:23:08 -0800 Subject: [PATCH 30/82] Simplify verify att time (#3961) --- beacon-chain/blockchain/forkchoice/process_attestation.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/beacon-chain/blockchain/forkchoice/process_attestation.go b/beacon-chain/blockchain/forkchoice/process_attestation.go index f13766e0809b..f594e326e224 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 } @@ -217,11 +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 { - return helpers.VerifySlotTime(baseState.GenesisTime, d.Slot+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) From 4376e01009cf62e70829c515b1b19fb953310c48 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sun, 10 Nov 2019 13:30:28 -0500 Subject: [PATCH 31/82] update readme for deposit contract, regen bindings for vyper 0.1.0b12 (#3963) * update readme for deposit contract, regen bindings * medium --- WORKSPACE | 91 +++++++++++++++++++ contracts/deposit-contract/BUILD.bazel | 2 +- contracts/deposit-contract/README.md | 11 ++- contracts/deposit-contract/abi.json | 2 +- contracts/deposit-contract/bytecode.bin | 2 +- contracts/deposit-contract/depositContract.go | 4 +- 6 files changed, 102 insertions(+), 10 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 45bbcbf359f5..97cb769cbe54 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1258,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/contracts/deposit-contract/BUILD.bazel b/contracts/deposit-contract/BUILD.bazel index 8a41ea997925..c1b45fecd41b 100644 --- a/contracts/deposit-contract/BUILD.bazel +++ b/contracts/deposit-contract/BUILD.bazel @@ -25,7 +25,7 @@ go_library( go_test( name = "go_default_test", - size = "small", + size = "medium", srcs = [ "depositContract_test.go", "deposit_tree_test.go", diff --git a/contracts/deposit-contract/README.md b/contracts/deposit-contract/README.md index 63001c07b573..04538c683f2b 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,21 +47,22 @@ 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 +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 diff --git a/contracts/deposit-contract/abi.json b/contracts/deposit-contract/abi.json index 2d90df95e97c..529d6d07afa8 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": "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": 95727}, {"name": "get_deposit_count", "outputs": [{"type": "bytes", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 18283}, {"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": 1342680}, {"name": "drain", "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 35831}, {"name": "drain_address", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 701}] +[{"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 38fdaa70f322..d78cf5297cf3 100644 --- a/contracts/deposit-contract/bytecode.bin +++ b/contracts/deposit-contract/bytecode.bin @@ -1 +1 @@ -0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206113166101403934156100a157600080fd5b602061131660c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b50506112fe56600436101561000d5761114f565b600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610286575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100e8578060000360020a82046100ef565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561011a57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610163578060000360020a820461016a565b8060020a82025b905090506101a0525b81516001018083528114156100cb575b5050601860086020820661020001602082840111156101a157600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101de57600080fd5b50506102c05160206001820306601f82010390506103206102c0516020818352015b82610320511015156102115761022d565b6000610320516102e001535b8151600101808352811415610200575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102625761027e565b602061028051036102a001516020610280510361028052610250565b610160515650005b63c5f2892f600051141561051857341561029f57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103415760006101a051602081106102e257600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161033357600080fd5b60c0519050610160526103af565b6000610160516020826101c00101526020810190506101a0516020811061036757600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16103a557600080fd5b60c0519050610160525b61018060026103bd57600080fd5b60028151048152505b81516001018083528114156102c0575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e0526001546103005261030051600658016100a9565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104445761045d565b6103c05161038001526103c0516020016103c052610422565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e001602082840111156104a857600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af161050857600080fd5b60c051905060005260206000f350005b63621fd130600051141561062c57341561053157600080fd5b6380673289610140526001546101605261016051600658016100a9565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561057c57610595565b610220516101e00152610220516020016102205261055a565b6101c0805160200180610280828460006004600a8704601201f16105b857600080fd5b50506102805160206001820306601f82010390506102e0610280516020818352015b826102e0511015156105eb57610607565b60006102e0516102a001535b81516001018083528114156105da575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110f357605060043560040161014037603060043560040135111561065a57600080fd5b60406024356004016101c037602060243560040135111561067a57600080fd5b608060443560040161022037606060443560040135111561069a57600080fd5b63ffffffff600154106106ac57600080fd5b633b9aca006102e0526102e0516106c257600080fd5b6102e05134046102c052633b9aca006102c05110156106e057600080fd5b603061014051146106f057600080fd5b60206101c0511461070057600080fd5b6060610220511461071057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561073a57610718565b6380673289610380526102c0516103a0526103a051600658016100a9565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107865761079f565b6104605161042001526104605160200161046052610764565b610340610360525b61036051526020610360510361036052610140610360511015156107ca576107a7565b610400805160200180610300828460006004600a8704601201f16107ed57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610819576107f7565b63806732896104a0526001546104c0526104c051600658016100a9565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108645761087d565b6105805161054001526105805160200161058052610842565b610460610480525b61048051526020610480510361048052610140610480511015156108a857610885565b6105208051602001806105a0828460006004600a8704601201f16108cb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f161090357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516040818352015b826106005110151561094057610961565b600061060051610620516106800101535b815160010180835281141561092f575b505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109b757600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b82610600511015156109f457610a15565b600061060051610620516106800101535b81516001018083528114156109e3575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a6b57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610aa857610ac9565b600061060051610620516106800101535b8151600101808352811415610a97575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b1f57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516060818352015b8261060051101515610b5c57610b7d565b600061060051610620516106800101535b8151600101808352811415610b4b575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bd357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610c1057610c31565b600061060051610620516106800101535b8151600101808352811415610bff575b505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cc757600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d2757600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d5057600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d9057600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610dc457600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e4157600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e7857600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ede57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f3357600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610fa657600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fdd57600080fd5b60c0519050610ae052606435610ae05114610ff757600080fd5b600180546001825401101561100b57600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561105b57610ae051610d20516020811061104a57600080fd5b600060c052602060c02001556110ef565b6000610d20516020811061106e57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110bf57600080fd5b60c0519050610ae052610d0060026110d657600080fd5b60028151048152505b8151600101808352811415611026575b5050005b639890220b600051141561112757341561110c57600080fd5b600060006000600030316002546000f161112557600080fd5b005b638ba35cdf600051141561114e57341561114057600080fd5b60025460005260206000f350005b5b60006000fd5b6101a96112fe036101a96000396101a96112fe036000f3 +0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206112736101403934156100a157600080fd5b602061127360c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b505061125b56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610265575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506103206102c0516020818352015b60206103205111156101f15761020d565b6000610320516102e001535b81516001018083528114156101e0575b505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102415761025d565b602061028051036102a00151602061028051036102805261022f565b610160515650005b63c5f2892f60005114156104f757341561027e57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103205760006101a051602081106102c157600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161031257600080fd5b60c05190506101605261038e565b6000610160516020826101c00101526020810190506101a0516020811061034657600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161038457600080fd5b60c0519050610160525b610180600261039c57600080fd5b60028151048152505b815160010180835281141561029f575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104235761043c565b6103c05161038001526103c0516020016103c052610401565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561048757600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104e757600080fd5b60c051905060005260206000f350005b63621fd13060005114156105f857341561051057600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561055b57610574565b610220516101e001526102205160200161022052610539565b6101c0805160200180610280828460006004600a8704601201f161059757600080fd5b50506102e0610280516020818352015b60206102e05111156105b8576105d4565b60006102e0516102a001535b81516001018083528114156105a7575b50506020610260526040610280510160206001820306601f8201039050610260f350005b6322895118600051141561105157605060043560040161014037603060043560040135111561062657600080fd5b60406024356004016101c037602060243560040135111561064657600080fd5b608060443560040161022037606060443560040135111561066657600080fd5b63ffffffff6001541061067857600080fd5b633b9aca006102e0526102e05161068e57600080fd5b6102e05134046102c052633b9aca006102c05110156106ac57600080fd5b603061014051146106bc57600080fd5b60206101c051146106cc57600080fd5b606061022051146106dc57600080fd5b610140610360525b61036051516020610360510161036052610360610360511015610706576106e4565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107525761076b565b6104605161042001526104605160200161046052610730565b610340610360525b610360515260206103605103610360526101406103605110151561079657610773565b610400805160200180610300828460006004600a8704601201f16107b957600080fd5b5050610140610480525b610480515160206104805101610480526104806104805110156107e5576107c3565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f82010390506105805110151561083057610849565b610580516105400152610580516020016105805261080e565b610460610480525b610480515260206104805103610480526101406104805110151561087457610851565b6105208051602001806105a0828460006004600a8704601201f161089757600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108cf57600080fd5b5050610600610620516106600151610240818352015b6102406106005111156108f757610918565b600061060051610620516106800101535b81516001018083528114156108e5575b5050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f161096d57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610995576109b6565b600061060051610620516106800101535b8151600101808352811415610983575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a0b57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610a3357610a54565b600061060051610620516106800101535b8151600101808352811415610a21575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610aa957600080fd5b5050610600610620516106600151610240818352015b610240610600511115610ad157610af2565b600061060051610620516106800101535b8151600101808352811415610abf575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610b4757600080fd5b5050610600610620516106600151610240818352015b610240610600511115610b6f57610b90565b600061060051610620516106800101535b8151600101808352811415610b5d575b5050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610c2557600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610c8557600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610cae57600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610cee57600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610d2257600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610d9f57600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610dd657600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610e3c57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610e9157600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f0457600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610f3b57600080fd5b60c0519050610ae052606435610ae05114610f5557600080fd5b6001805460018254011015610f6957600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d0051161415610fb957610ae051610d205160208110610fa857600080fd5b600060c052602060c020015561104d565b6000610d205160208110610fcc57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af161101d57600080fd5b60c0519050610ae052610d00600261103457600080fd5b60028151048152505b8151600101808352811415610f84575b5050005b639890220b600051141561108557341561106a57600080fd5b600060006000600030316002546000f161108357600080fd5b005b638ba35cdf60005114156110ac57341561109e57600080fd5b60025460005260206000f350005b60006000fd5b6101a961125b036101a96000396101a961125b036000f3 diff --git a/contracts/deposit-contract/depositContract.go b/contracts/deposit-contract/depositContract.go index e2293f6ffd68..b145a60026e4 100644 --- a/contracts/deposit-contract/depositContract.go +++ b/contracts/deposit-contract/depositContract.go @@ -28,10 +28,10 @@ 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\":\"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\":95727},{\"name\":\"get_deposit_count\",\"outputs\":[{\"type\":\"bytes\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":18283},{\"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\":1342680},{\"name\":\"drain\",\"outputs\":[],\"inputs\":[],\"constant\":false,\"payable\":false,\"type\":\"function\",\"gas\":35831},{\"name\":\"drain_address\",\"outputs\":[{\"type\":\"address\",\"name\":\"out\"}],\"inputs\":[],\"constant\":true,\"payable\":false,\"type\":\"function\",\"gas\":701}]" +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. -var DepositContractBin = "0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206113166101403934156100a157600080fd5b602061131660c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b50506112fe56600436101561000d5761114f565b600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610286575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100e8578060000360020a82046100ef565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561011a57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610163578060000360020a820461016a565b8060020a82025b905090506101a0525b81516001018083528114156100cb575b5050601860086020820661020001602082840111156101a157600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101de57600080fd5b50506102c05160206001820306601f82010390506103206102c0516020818352015b82610320511015156102115761022d565b6000610320516102e001535b8151600101808352811415610200575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102625761027e565b602061028051036102a001516020610280510361028052610250565b610160515650005b63c5f2892f600051141561051857341561029f57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103415760006101a051602081106102e257600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161033357600080fd5b60c0519050610160526103af565b6000610160516020826101c00101526020810190506101a0516020811061036757600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af16103a557600080fd5b60c0519050610160525b61018060026103bd57600080fd5b60028151048152505b81516001018083528114156102c0575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e0526001546103005261030051600658016100a9565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104445761045d565b6103c05161038001526103c0516020016103c052610422565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e001602082840111156104a857600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af161050857600080fd5b60c051905060005260206000f350005b63621fd130600051141561062c57341561053157600080fd5b6380673289610140526001546101605261016051600658016100a9565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561057c57610595565b610220516101e00152610220516020016102205261055a565b6101c0805160200180610280828460006004600a8704601201f16105b857600080fd5b50506102805160206001820306601f82010390506102e0610280516020818352015b826102e0511015156105eb57610607565b60006102e0516102a001535b81516001018083528114156105da575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110f357605060043560040161014037603060043560040135111561065a57600080fd5b60406024356004016101c037602060243560040135111561067a57600080fd5b608060443560040161022037606060443560040135111561069a57600080fd5b63ffffffff600154106106ac57600080fd5b633b9aca006102e0526102e0516106c257600080fd5b6102e05134046102c052633b9aca006102c05110156106e057600080fd5b603061014051146106f057600080fd5b60206101c0511461070057600080fd5b6060610220511461071057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561073a57610718565b6380673289610380526102c0516103a0526103a051600658016100a9565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107865761079f565b6104605161042001526104605160200161046052610764565b610340610360525b61036051526020610360510361036052610140610360511015156107ca576107a7565b610400805160200180610300828460006004600a8704601201f16107ed57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610819576107f7565b63806732896104a0526001546104c0526104c051600658016100a9565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108645761087d565b6105805161054001526105805160200161058052610842565b610460610480525b61048051526020610480510361048052610140610480511015156108a857610885565b6105208051602001806105a0828460006004600a8704601201f16108cb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f161090357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516040818352015b826106005110151561094057610961565b600061060051610620516106800101535b815160010180835281141561092f575b505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109b757600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b82610600511015156109f457610a15565b600061060051610620516106800101535b81516001018083528114156109e3575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a6b57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610aa857610ac9565b600061060051610620516106800101535b8151600101808352811415610a97575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b1f57600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516060818352015b8261060051101515610b5c57610b7d565b600061060051610620516106800101535b8151600101808352811415610b4b575b505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bd357600080fd5b505061062051610660015160206001820306601f82010390506106006106205161066001516020818352015b8261060051101515610c1057610c31565b600061060051610620516106800101535b8151600101808352811415610bff575b505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cc757600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d2757600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d5057600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d9057600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610dc457600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e4157600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e7857600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ede57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f3357600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610fa657600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fdd57600080fd5b60c0519050610ae052606435610ae05114610ff757600080fd5b600180546001825401101561100b57600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561105b57610ae051610d20516020811061104a57600080fd5b600060c052602060c02001556110ef565b6000610d20516020811061106e57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110bf57600080fd5b60c0519050610ae052610d0060026110d657600080fd5b60028151048152505b8151600101808352811415611026575b5050005b639890220b600051141561112757341561110c57600080fd5b600060006000600030316002546000f161112557600080fd5b005b638ba35cdf600051141561114e57341561114057600080fd5b60025460005260206000f350005b5b60006000fd5b6101a96112fe036101a96000396101a96112fe036000f3" +var DepositContractBin = "0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05260206112736101403934156100a157600080fd5b602061127360c03960c05160205181106100ba57600080fd5b50610140516002556101606000601f818352015b600061016051602081106100e157600080fd5b600360c052602060c0200154602082610180010152602081019050610160516020811061010d57600080fd5b600360c052602060c020015460208261018001015260208101905080610180526101809050602060c0825160208401600060025af161014b57600080fd5b60c0519050606051600161016051018060405190131561016a57600080fd5b809190121561017857600080fd5b6020811061018557600080fd5b600360c052602060c02001555b81516001018083528114156100ce575b505061125b56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610265575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506103206102c0516020818352015b60206103205111156101f15761020d565b6000610320516102e001535b81516001018083528114156101e0575b505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102415761025d565b602061028051036102a00151602061028051036102805261022f565b610160515650005b63c5f2892f60005114156104f757341561027e57600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103205760006101a051602081106102c157600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161031257600080fd5b60c05190506101605261038e565b6000610160516020826101c00101526020810190506101a0516020811061034657600080fd5b600360c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161038457600080fd5b60c0519050610160525b610180600261039c57600080fd5b60028151048152505b815160010180835281141561029f575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104235761043c565b6103c05161038001526103c0516020016103c052610401565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561048757600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104e757600080fd5b60c051905060005260206000f350005b63621fd13060005114156105f857341561051057600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561055b57610574565b610220516101e001526102205160200161022052610539565b6101c0805160200180610280828460006004600a8704601201f161059757600080fd5b50506102e0610280516020818352015b60206102e05111156105b8576105d4565b60006102e0516102a001535b81516001018083528114156105a7575b50506020610260526040610280510160206001820306601f8201039050610260f350005b6322895118600051141561105157605060043560040161014037603060043560040135111561062657600080fd5b60406024356004016101c037602060243560040135111561064657600080fd5b608060443560040161022037606060443560040135111561066657600080fd5b63ffffffff6001541061067857600080fd5b633b9aca006102e0526102e05161068e57600080fd5b6102e05134046102c052633b9aca006102c05110156106ac57600080fd5b603061014051146106bc57600080fd5b60206101c051146106cc57600080fd5b606061022051146106dc57600080fd5b610140610360525b61036051516020610360510161036052610360610360511015610706576106e4565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107525761076b565b6104605161042001526104605160200161046052610730565b610340610360525b610360515260206103605103610360526101406103605110151561079657610773565b610400805160200180610300828460006004600a8704601201f16107b957600080fd5b5050610140610480525b610480515160206104805101610480526104806104805110156107e5576107c3565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f82010390506105805110151561083057610849565b610580516105400152610580516020016105805261080e565b610460610480525b610480515260206104805103610480526101406104805110151561087457610851565b6105208051602001806105a0828460006004600a8704601201f161089757600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108cf57600080fd5b5050610600610620516106600151610240818352015b6102406106005111156108f757610918565b600061060051610620516106800101535b81516001018083528114156108e5575b5050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f161096d57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610995576109b6565b600061060051610620516106800101535b8151600101808352811415610983575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a0b57600080fd5b5050610600610620516106600151610240818352015b610240610600511115610a3357610a54565b600061060051610620516106800101535b8151600101808352811415610a21575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610aa957600080fd5b5050610600610620516106600151610240818352015b610240610600511115610ad157610af2565b600061060051610620516106800101535b8151600101808352811415610abf575b5050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610b4757600080fd5b5050610600610620516106600151610240818352015b610240610600511115610b6f57610b90565b600061060051610620516106800101535b8151600101808352811415610b5d575b5050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610c2557600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610c8557600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610cae57600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610cee57600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610d2257600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610d9f57600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610dd657600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610e3c57600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610e9157600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f0457600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610f3b57600080fd5b60c0519050610ae052606435610ae05114610f5557600080fd5b6001805460018254011015610f6957600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d0051161415610fb957610ae051610d205160208110610fa857600080fd5b600060c052602060c020015561104d565b6000610d205160208110610fcc57600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af161101d57600080fd5b60c0519050610ae052610d00600261103457600080fd5b60028151048152505b8151600101808352811415610f84575b5050005b639890220b600051141561108557341561106a57600080fd5b600060006000600030316002546000f161108357600080fd5b005b638ba35cdf60005114156110ac57341561109e57600080fd5b60025460005260206000f350005b60006000fd5b6101a961125b036101a96000396101a961125b036000f3" // DeployDepositContract deploys a new Ethereum contract, binding an instance of DepositContract to it. func DeployDepositContract(auth *bind.TransactOpts, backend bind.ContractBackend, _drain_address common.Address) (common.Address, *types.Transaction, *DepositContract, error) { From 11cc97ebc783f7e6bf49e02c6f8889ea7ae3ac40 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sun, 10 Nov 2019 14:37:45 -0500 Subject: [PATCH 32/82] Check nil base state (#3964) --- beacon-chain/blockchain/forkchoice/process_block.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beacon-chain/blockchain/forkchoice/process_block.go b/beacon-chain/blockchain/forkchoice/process_block.go index 9f8506d021b3..8fa9b2967861 100644 --- a/beacon-chain/blockchain/forkchoice/process_block.go +++ b/beacon-chain/blockchain/forkchoice/process_block.go @@ -288,6 +288,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") From 4f2a7819acb62c6da52901f5d655864ea9e587f2 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Mon, 11 Nov 2019 23:29:10 +0800 Subject: [PATCH 33/82] Copy Block When Receiving it From Sync (#3966) * copy block * clone for other service methods too --- .../blockchain/forkchoice/process_block.go | 1 - beacon-chain/blockchain/receive_block.go | 50 ++++++++++--------- proto/beacon/db/attestation_container.pb.go | 5 +- .../db/finalized_block_root_container.pb.go | 3 +- proto/beacon/p2p/v1/messages.pb.go | 5 +- proto/beacon/p2p/v1/types.pb.go | 5 +- proto/beacon/rpc/v1/services.pb.go | 5 +- proto/beacon/rpc/v1_gateway/services.pb.go | 3 +- proto/eth/v1alpha1/archive.pb.go | 5 +- proto/eth/v1alpha1/attestation.pb.go | 5 +- proto/eth/v1alpha1/beacon_block.pb.go | 5 +- proto/eth/v1alpha1/beacon_chain.pb.go | 5 +- proto/eth/v1alpha1/node.pb.go | 5 +- proto/eth/v1alpha1/validator.pb.go | 5 +- proto/sharding/p2p/v1/messages.pb.go | 3 +- 15 files changed, 63 insertions(+), 47 deletions(-) diff --git a/beacon-chain/blockchain/forkchoice/process_block.go b/beacon-chain/blockchain/forkchoice/process_block.go index 8fa9b2967861..ae10cf49a9c8 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") diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 3fdfa12bfa79..3af34bac8948 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/proto/beacon/db/attestation_container.pb.go b/proto/beacon/db/attestation_container.pb.go index e07adc093af7..6689465ba04d 100755 --- a/proto/beacon/db/attestation_container.pb.go +++ b/proto/beacon/db/attestation_container.pb.go @@ -5,12 +5,13 @@ package db import ( fmt "fmt" + io "io" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/db/finalized_block_root_container.pb.go b/proto/beacon/db/finalized_block_root_container.pb.go index a7eae5c80789..ec2d6ffa74b4 100755 --- a/proto/beacon/db/finalized_block_root_container.pb.go +++ b/proto/beacon/db/finalized_block_root_container.pb.go @@ -5,9 +5,10 @@ package db import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" io "io" math "math" + + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/messages.pb.go b/proto/beacon/p2p/v1/messages.pb.go index c49daf0c207c..429de7fc2a97 100755 --- a/proto/beacon/p2p/v1/messages.pb.go +++ b/proto/beacon/p2p/v1/messages.pb.go @@ -5,10 +5,11 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 3ff88f8599ac..74ff5e6ce4a8 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -5,12 +5,13 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" + io "io" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index bcae8f7cec38..42c223a99c73 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -7,13 +7,14 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" + io "io" + math "math" + proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index c708d734c2bc..92e1c285cd45 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -6,12 +6,13 @@ package ethereum_beacon_rpc_v1 import ( context "context" fmt "fmt" + math "math" + proto "github.com/golang/protobuf/proto" empty "github.com/golang/protobuf/ptypes/empty" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/archive.pb.go b/proto/eth/v1alpha1/archive.pb.go index f943f90f0719..be11ffceb673 100755 --- a/proto/eth/v1alpha1/archive.pb.go +++ b/proto/eth/v1alpha1/archive.pb.go @@ -5,10 +5,11 @@ package eth import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index b68d1b3d02d9..008971640b79 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -5,11 +5,12 @@ package eth import ( fmt "fmt" + io "io" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/beacon_block.pb.go b/proto/eth/v1alpha1/beacon_block.pb.go index f9eb15a7834f..552ea64b0fd1 100755 --- a/proto/eth/v1alpha1/beacon_block.pb.go +++ b/proto/eth/v1alpha1/beacon_block.pb.go @@ -5,10 +5,11 @@ package eth import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 2374817142c3..9319c481b72b 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -6,13 +6,14 @@ package eth import ( context "context" fmt "fmt" + io "io" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/node.pb.go b/proto/eth/v1alpha1/node.pb.go index 2ba95ac9b419..647805e30f3d 100755 --- a/proto/eth/v1alpha1/node.pb.go +++ b/proto/eth/v1alpha1/node.pb.go @@ -6,12 +6,13 @@ package eth import ( context "context" fmt "fmt" + io "io" + math "math" + proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/validator.pb.go b/proto/eth/v1alpha1/validator.pb.go index d4f83587b8da..4fb145895295 100755 --- a/proto/eth/v1alpha1/validator.pb.go +++ b/proto/eth/v1alpha1/validator.pb.go @@ -7,13 +7,14 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" + io "io" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" - io "io" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/sharding/p2p/v1/messages.pb.go b/proto/sharding/p2p/v1/messages.pb.go index ba268c5f4bac..61228b93def4 100644 --- a/proto/sharding/p2p/v1/messages.pb.go +++ b/proto/sharding/p2p/v1/messages.pb.go @@ -5,9 +5,10 @@ package ethereum_sharding_p2p_v1 import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" io "io" math "math" + + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. From e2467ef0058deb5e6a2242d4321ea83651f0dafc Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Tue, 12 Nov 2019 00:19:23 +0800 Subject: [PATCH 34/82] Change logging of Bitfield (#3956) * change logging of bits * preston's review --- beacon-chain/operations/block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/operations/block.go b/beacon-chain/operations/block.go index 016f8ce64c1a..7f92e96c4acc 100644 --- a/beacon-chain/operations/block.go +++ b/beacon-chain/operations/block.go @@ -41,7 +41,7 @@ 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()), + "aggregation_bits": fmt.Sprintf("%08b", att.AggregationBits.Bytes()), "committeeIndex": att.Data.Index, }).Debug("block attestation") } From 828046e2561ae0434882878d34b5c3b5dc370af4 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Tue, 12 Nov 2019 01:25:10 +0800 Subject: [PATCH 35/82] Unskip Beacon Server Test (#3962) * run test till the end * fix up proto message types * fmt * resolve broken tests * better error handling * fixing new logic to use archived proposer info * fix up logic * clip using the max effective balance * broken build fix with num arg mismatch * amend archive * archival logic changed * rename test * archive both proposer and attester seeds * page size 100 * further experiments * further experimentation, archivedProposerIndex seems wrong * test passes * rem log * fix broken test * fix test * gaz * fix imports * ethapis --- WORKSPACE | 2 +- beacon-chain/archiver/service.go | 10 +- beacon-chain/archiver/service_test.go | 8 +- beacon-chain/core/helpers/BUILD.bazel | 4 - beacon-chain/core/helpers/attestation_test.go | 48 ++-- beacon-chain/core/helpers/committee.go | 28 +- beacon-chain/core/helpers/committee_test.go | 19 +- beacon-chain/core/helpers/validators.go | 2 +- beacon-chain/db/kv/archive_test.go | 4 +- .../operations/recent_att_multi_map_test.go | 8 +- beacon-chain/rpc/beacon_chain_server.go | 122 +++++++-- beacon-chain/rpc/beacon_chain_server_test.go | 107 +++++--- beacon-chain/rpc/validator_server.go | 2 +- proto/eth/v1alpha1/archive.pb.go | 157 +++++------ proto/eth/v1alpha1/archive.proto | 11 +- proto/eth/v1alpha1/beacon_chain.pb.go | 252 +++++++++--------- proto/eth/v1alpha1/beacon_chain.proto | 11 +- proto/eth/v1alpha1/slasher.pb.go | 5 +- slasher/db/BUILD.bazel | 2 +- ..._max-span_test.go => min_max_span_test.go} | 1 - 20 files changed, 424 insertions(+), 379 deletions(-) rename slasher/db/{min_max-span_test.go => min_max_span_test.go} (99%) diff --git a/WORKSPACE b/WORKSPACE index 97cb769cbe54..3b0dbb7f8388 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1201,7 +1201,7 @@ go_repository( go_repository( name = "com_github_prysmaticlabs_ethereumapis", - commit = "1233869b5d734015dce0faf257f54d32d9368045", + commit = "c7f1fd03716c94dcc287a0d35905ed35b8a0afe1", importpath = "github.com/prysmaticlabs/ethereumapis", ) diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index 1eab3c6ad314..8761e1a7e034 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -73,19 +73,19 @@ func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.Beacon if err != nil { return errors.Wrap(err, "could not get committee count") } - seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) + proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { return errors.Wrap(err, "could not generate seed") } - proposerIndex, err := helpers.BeaconProposerIndex(headState) + attesterSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) 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[:], + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, - ProposerIndex: proposerIndex, } 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 ef09cf16abd6..66f5080e327f 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -132,18 +132,18 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) + proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) 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[:], + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, - ProposerIndex: propIdx, } retrieved, err := svc.beaconDB.ArchivedCommitteeInfo(svc.ctx, helpers.CurrentEpoch(headState)) diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index e547a0bf18c4..2e5e19e02c32 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -34,8 +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", - "@org_golang_google_grpc//codes:go_default_library", - "@org_golang_google_grpc//status:go_default_library", ], ) @@ -64,8 +62,6 @@ go_test( "//shared/sliceutil: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_test.go b/beacon-chain/core/helpers/attestation_test.go index 42b95e767cde..675a7f573b08 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -86,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}, }, }, { @@ -110,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/committee.go b/beacon-chain/core/helpers/committee.go index b53974a20f4d..7516ff51e588 100644 --- a/beacon-chain/core/helpers/committee.go +++ b/beacon-chain/core/helpers/committee.go @@ -12,8 +12,6 @@ import ( "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 committeeCache = cache.NewCommitteeCache() @@ -90,7 +88,6 @@ func BeaconCommittee(state *pb.BeaconState, slot uint64, index uint64) ([]uint64 if err != nil { return nil, errors.Wrap(err, "could not get active indices") } - return ComputeCommittee(indices, seed, epochOffset, count) } @@ -190,23 +187,23 @@ func AttestingIndices(state *pb.BeaconState, data *ethpb.AttestationData, bf bit func CommitteeAssignment( state *pb.BeaconState, epoch uint64, - validatorIndex uint64) ([]uint64, uint64, uint64, bool, uint64, error) { + validatorIndex uint64, +) ([]uint64, uint64, uint64, uint64, error) { if epoch > NextEpoch(state) { - return nil, 0, 0, false, 0, fmt.Errorf( + 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 + // Track which slot has which proposer. startSlot := StartSlot(epoch) proposerIndexToSlot := make(map[uint64]uint64) - for slot := uint64(startSlot); slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { + for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { state.Slot = slot i, err := BeaconProposerIndex(state) if err != nil { - return nil, 0, 0, false, 0, fmt.Errorf( - "could not check proposer v: %v", err) + return nil, 0, 0, 0, errors.Wrapf(err, "could not check proposer at slot %d", state.Slot) } proposerIndexToSlot[i] = slot } @@ -214,25 +211,22 @@ func CommitteeAssignment( for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { countAtSlot, err := CommitteeCountAtSlot(state, slot) if err != nil { - return nil, 0, 0, false, 0, fmt.Errorf( - "could not get committee count at slot: %v", err) + 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, false, 0, fmt.Errorf( - "could not get crosslink committee: %v", err) + 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, isProposer := proposerIndexToSlot[v] - return committee, uint64(i), slot, isProposer, proposerSlot, nil + proposerSlot, _ := proposerIndexToSlot[v] + return committee, i, slot, proposerSlot, nil } } } } - - return []uint64{}, 0, 0, false, 0, status.Error(codes.NotFound, "validator not found in assignments") + 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. diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index 1b1ee7fe2396..78cdcc6f7166 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -7,13 +7,12 @@ 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 TestComputeCommittee_WithoutCache(t *testing.T) { @@ -223,7 +222,7 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { for i, tt := range tests { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { ClearAllCaches() - committee, committeeIndex, slot, isProposer, proposerSlot, 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) } @@ -235,10 +234,6 @@ func TestCommitteeAssignment_CanRetrieve(t *testing.T) { 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) @@ -269,13 +264,9 @@ func TestCommitteeAssignment_CantFindValidator(t *testing.T) { } 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) + _, _, _, _, err := CommitteeAssignment(state, 1, index) + if err != nil && !strings.Contains(err.Error(), "not found in assignments") { + t.Errorf("Wanted 'not found in assignments', received %v", err) } } diff --git a/beacon-chain/core/helpers/validators.go b/beacon-chain/core/helpers/validators.go index aa400dd1c1cb..7fc396b9dfba 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -213,7 +213,7 @@ func ComputeProposerIndex(state *pb.BeaconState, indices []uint64, seed [32]byte maxRandomByte := uint64(1<<8 - 1) for i := uint64(0); ; i++ { - candidateIndex, err := ComputeShuffledIndex(uint64(i)%length, length, seed, true) + candidateIndex, err := ComputeShuffledIndex(i%length, length, seed, true) if err != nil { return 0, err } diff --git a/beacon-chain/db/kv/archive_test.go b/beacon-chain/db/kv/archive_test.go index 3200970d051d..e995fed48683 100644 --- a/beacon-chain/db/kv/archive_test.go +++ b/beacon-chain/db/kv/archive_test.go @@ -104,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/operations/recent_att_multi_map_test.go b/beacon-chain/operations/recent_att_multi_map_test.go index f88a40463280..db2574337d1c 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/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index de9be747ab1d..bc3b136dc484 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" @@ -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 committeeIndex 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, committeeIndex, 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, + ) + } + if archivedBalances == nil { + return nil, status.Errorf( + codes.NotFound, + "no archival balances found for epoch %d", + requestedEpoch, + ) } - isProposer = archivedInfo.ProposerIndex == index - } else { - committee, committeeIndex, slot, isProposer, _, err = helpers.CommitteeAssignment(headState, requestedEpoch, index) + 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{ + 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, - Slot: slot, - Proposer: isProposer, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, PublicKey: headState.Validators[index].PublicKey, - }) + } + res = append(res, assign) } return ðpb.ValidatorAssignments{ @@ -661,32 +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 - seed := bytesutil.ToBytes32(archivedInfo.Seed) + 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++ { + 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++ { - for i := uint64(0); i < committeesPerSlot; i++ { - committee, err := helpers.ComputeCommittee(activeIndices, seed, i, committeeCount) + 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, i, 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 2a2bb6bd07f9..7f25a4d4a683 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon_chain_server_test.go @@ -1280,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) @@ -1288,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, + }) } } @@ -1331,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) @@ -1344,42 +1354,53 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize(t *testing.T) { t.Fatal(err) } for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { - committee, committeeIndex, 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{ BeaconCommittees: committee, CommitteeIndex: committeeIndex, - Slot: slot, - Proposer: isProposer, + 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") } } func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing.T) { - t.Skip("Disabled until v0.9.0 (#3865) completes") db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) 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{ @@ -1395,7 +1416,9 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing s := &pbp2p.BeaconState{ Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + Balances: balances, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + } if err := db.SaveState(ctx, s, blockRoot); err != nil { t.Fatal(err) } @@ -1420,51 +1443,53 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing if err != nil { t.Fatal(err) } - seed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) + proposerSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { t.Fatal(err) } - proposerIndex, err := helpers.BeaconProposerIndex(s) + attesterSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { t.Fatal(err) } - if err := db.SaveArchivedCommitteeInfo(context.Background(), 0, ðpb.ArchivedCommitteeInfo{ - Seed: seed[:], + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, - ProposerIndex: proposerIndex, }); err != nil { t.Fatal(err) } - res, err := bs.ListValidatorAssignments(context.Background(), ðpb.ListValidatorAssignmentsRequest{ - QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, - }) - if err != nil { + if err := db.SaveArchivedBalances(context.Background(), 0, balances); err != nil { t.Fatal(err) } - // Construct the wanted assignments + // 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, 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{ + assign := ðpb.ValidatorAssignments_CommitteeAssignment{ BeaconCommittees: committee, CommitteeIndex: committeeIndex, - Slot: slot, - Proposer: isProposer, + 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) + } if !reflect.DeepEqual(res.Assignments, wanted) { t.Error("Did not receive wanted assignments") } @@ -1521,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) @@ -1529,15 +1554,15 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t t.Fatal(err) } for _, index := range activeIndices[1:4] { - committee, committeeIndex, 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{ BeaconCommittees: committee, CommitteeIndex: committeeIndex, - Slot: slot, - Proposer: isProposer, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, PublicKey: s.Validators[index].PublicKey, }) } @@ -1598,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) @@ -1606,15 +1631,15 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination t.Fatal(err) } for _, index := range activeIndices[3:5] { - committee, committeeIndex, 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{ BeaconCommittees: committee, CommitteeIndex: committeeIndex, - Slot: slot, - Proposer: isProposer, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, PublicKey: s.Validators[index].PublicKey, }) } @@ -1638,15 +1663,15 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } for _, index := range activeIndices[6:7] { - committee, committeeIndex, 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{ BeaconCommittees: committee, CommitteeIndex: committeeIndex, - Slot: slot, - Proposer: isProposer, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, PublicKey: s.Validators[index].PublicKey, }) } diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator_server.go index 9fb121049fc7..4321cfa24f9b 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator_server.go @@ -195,7 +195,7 @@ 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, committeeIndex, aSlot, _, pSlot, err := helpers.CommitteeAssignment(beaconState, epoch, idx) + committee, committeeIndex, aSlot, pSlot, err := helpers.CommitteeAssignment(beaconState, epoch, idx) if err != nil { return nil, err } diff --git a/proto/eth/v1alpha1/archive.pb.go b/proto/eth/v1alpha1/archive.pb.go index be11ffceb673..649abc7b8f5c 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, 0x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x00, - 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, 0xc8, 0xf5, 0x12, 0x94, 0x66, + 0xd3, 0x84, 0xb6, 0xe8, 0x42, 0x57, 0xb7, 0xc1, 0x85, 0x0b, 0x41, 0x52, 0xe8, 0xc2, 0x4d, 0x98, + 0x4c, 0xbe, 0x66, 0x06, 0x93, 0x4c, 0xc8, 0x7c, 0x09, 0x6d, 0x9f, 0xca, 0xc7, 0x70, 0xe9, 0x13, + 0x88, 0xdc, 0x9d, 0x5b, 0x9f, 0x40, 0x32, 0x49, 0x6e, 0x6a, 0x6d, 0xbb, 0xcb, 0x39, 0xdf, 0x39, + 0xe7, 0x3b, 0x33, 0x19, 0xb2, 0x28, 0x2b, 0x85, 0xca, 0x07, 0x14, 0x7e, 0x73, 0xcc, 0xb2, 0x52, + 0xb0, 0x63, 0x9f, 0x55, 0x5c, 0xc8, 0x06, 0x3c, 0x33, 0xa2, 0xfb, 0x80, 0x02, 0x2a, 0xa8, 0x73, + 0x0f, 0x50, 0x78, 0x83, 0xe8, 0xe0, 0x28, 0x95, 0x28, 0xea, 0xd8, 0xe3, 0x2a, 0xf7, 0x53, 0x95, + 0x2a, 0xdf, 0xa8, 0xe3, 0xfa, 0xd2, 0xa0, 0x2e, 0xb5, 0xfd, 0xea, 0x52, 0x0e, 0x5e, 0xdf, 0xb3, + 0x27, 0x06, 0xc6, 0x55, 0x11, 0xc5, 0x99, 0xe2, 0x5f, 0x3b, 0x99, 0xf3, 0x7b, 0x83, 0xd8, 0xcb, + 0x6e, 0x7d, 0xb2, 0xe4, 0x28, 0x1b, 0x38, 0x07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 0xc4, 0x43, 0xbe, 0x75, + 0x9d, 0xd6, 0x77, 0x48, 0x76, 0xf9, 0x50, 0x20, 0xe2, 0xaa, 0x2e, 0xd0, 0x9e, 0x2c, 0x2c, 0x77, + 0x1a, 0xee, 0xac, 0xe9, 0xa0, 0x65, 0xcf, 0x82, 0xef, 0xab, 0xb9, 0xf5, 0x63, 0x35, 0xb7, 0x7e, + 0xad, 0xe6, 0xd6, 0x97, 0x37, 0xb7, 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 3a4e2c98e201..8699a86e337a 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/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 9319c481b72b..303d7f3aa3b9 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -1787,8 +1787,8 @@ func (m *ValidatorAssignments) GetTotalSize() int32 { type ValidatorAssignments_CommitteeAssignment struct { 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"` - Slot uint64 `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty"` - Proposer bool `protobuf:"varint,4,opt,name=proposer,proto3" json:"proposer,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:"-"` @@ -1844,18 +1844,18 @@ func (m *ValidatorAssignments_CommitteeAssignment) GetCommitteeIndex() uint64 { 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{ - // 1602 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xbd, 0x6f, 0x1b, 0xc7, - 0x12, 0xf7, 0x91, 0xd4, 0xd7, 0x50, 0x9f, 0x2b, 0xc9, 0xe6, 0xa3, 0x2c, 0x89, 0x3e, 0x59, 0x32, - 0x0d, 0xd9, 0xa4, 0x25, 0x7f, 0xbc, 0x07, 0x3f, 0x3c, 0xf8, 0x59, 0x82, 0x63, 0x39, 0x31, 0x02, - 0xe5, 0x64, 0xa4, 0x48, 0x43, 0x1c, 0x8f, 0x2b, 0x72, 0xad, 0xe3, 0xed, 0x99, 0xbb, 0x14, 0x2c, - 0x75, 0x49, 0x11, 0x20, 0x75, 0x80, 0xa4, 0x4b, 0x52, 0x05, 0x30, 0x82, 0xb4, 0x69, 0x0c, 0xa4, - 0x48, 0x95, 0x26, 0x40, 0x80, 0x00, 0x29, 0x8d, 0xc0, 0x48, 0x9b, 0x22, 0xfe, 0x07, 0x12, 0xdc, - 0xee, 0xde, 0x17, 0xc5, 0x23, 0x69, 0x58, 0x55, 0xba, 0xdb, 0xd9, 0xd9, 0xdf, 0xfc, 0x76, 0x66, - 0x67, 0x77, 0xe6, 0x60, 0xd5, 0x6d, 0x51, 0x4e, 0xcb, 0x98, 0x37, 0xca, 0x87, 0x1b, 0xa6, 0xed, - 0x36, 0xcc, 0x8d, 0x72, 0x15, 0x9b, 0x16, 0x75, 0x2a, 0x56, 0xc3, 0x24, 0x4e, 0x49, 0xcc, 0xa3, - 0x79, 0xcc, 0x1b, 0xb8, 0x85, 0xdb, 0xcd, 0x12, 0xe6, 0x8d, 0x92, 0xaf, 0x99, 0xbf, 0x5a, 0x27, - 0xbc, 0xd1, 0xae, 0x96, 0x2c, 0xda, 0x2c, 0xd7, 0x69, 0x9d, 0x96, 0x85, 0x76, 0xb5, 0xbd, 0x2f, - 0x46, 0x12, 0xda, 0xfb, 0x92, 0x28, 0xf9, 0xf3, 0x75, 0x4a, 0xeb, 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 0x1d, 0xc3, 0x4c, 0x94, 0x82, 0xac, - 0x75, 0x92, 0x8e, 0xd5, 0x6a, 0x3f, 0x57, 0x89, 0xe5, 0x49, 0x67, 0x2b, 0x42, 0xe3, 0x89, 0x30, - 0xf3, 0xad, 0xfa, 0xb5, 0xd4, 0xf5, 0xdd, 0xbe, 0xd5, 0x23, 0x75, 0x7a, 0x14, 0x36, 0xf9, 0xf5, - 0xd7, 0x78, 0xc4, 0xf5, 0x2b, 0x82, 0xe9, 0x1a, 0xba, 0x98, 0xec, 0xb0, 0x08, 0xa5, 0xe7, 0x1a, - 0xfc, 0x2b, 0xf1, 0xed, 0x42, 0xff, 0x1e, 0x20, 0xc2, 0xdd, 0x5e, 0xbb, 0xfc, 0xcd, 0xd7, 0x7b, - 0x3b, 0xfa, 0x5c, 0x62, 0x11, 0xee, 0xb1, 0x47, 0x66, 0x6b, 0xfb, 0xc7, 0x97, 0x4b, 0xda, 0xcf, - 0x2f, 0x97, 0xb4, 0xdf, 0x5e, 0x2e, 0x69, 0x1f, 0xdc, 0x8c, 0xfc, 0xd3, 0x75, 0x5b, 0x47, 0xac, - 0x69, 0x72, 0x62, 0xd9, 0x66, 0x95, 0xc9, 0x51, 0xf9, 0xe4, 0xbf, 0xd3, 0xff, 0x62, 0xde, 0xa8, - 0x0e, 0x0b, 0xf9, 0xf5, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x43, 0x64, 0x57, 0x48, 0x51, 0x16, - 0x00, 0x00, + // 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, 0xa8, 0x8f, 0x91, 0x64, 0xf3, 0x28, 0x4b, 0xa2, 0x57, 0x96, + 0x4c, 0x43, 0x36, 0x69, 0xc9, 0x1f, 0x77, 0xf0, 0xe1, 0xe0, 0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x5f, + 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. @@ -3524,20 +3524,15 @@ func (m *ValidatorAssignments_CommitteeAssignment) MarshalTo(dAtA []byte) (int, i++ 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 @@ -4274,11 +4269,11 @@ func (m *ValidatorAssignments_CommitteeAssignment) Size() (n int) { 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 { @@ -7175,9 +7170,9 @@ func (m *ValidatorAssignments_CommitteeAssignment) Unmarshal(dAtA []byte) error } 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 f2d4e2b40a2f..f4eb3a1d86c6 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -405,13 +405,12 @@ message ValidatorAssignments { 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 3b77ef546531..bea45b2430d6 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/slasher/db/BUILD.bazel b/slasher/db/BUILD.bazel index 8aa70a1e2cd1..b9e9f97e1d7b 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/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 b8a5ab34414b..d114b0e55362 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" ) From f38fb076b3c8d2d63e73df12d66ab5e6102a4191 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 14:11:54 -0600 Subject: [PATCH 36/82] setup request/response types for the committees --- proto/eth/v1alpha1/beacon_chain.proto | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index f4eb3a1d86c6..f5aa6220d758 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -69,6 +69,17 @@ service BeaconChain { }; } + // Retrieve the beacon chain committees for a given epoch. + // + // This request may specify validator indices or public keys to filter out + // validator beacon chain committees. If no filter criteria is specified, the response returns + // all beacon committees for the current epoch. The results are paginated by default. + rpc ListBeaconCommittees(ListCommitteesRequest) returns (BeaconCommittees) { + option (google.api.http) = { + get: "/eth/v1alpha1/beacon/committees" + }; + } + // Retrieve validator balances for a given set of public keys at a specific // epoch in time. rpc ListValidatorBalances(GetValidatorBalancesRequest) returns (ValidatorBalances) { @@ -237,6 +248,51 @@ message ChainHead { bytes previous_justified_block_root = 8 [(gogoproto.moretags) = "ssz-size:\"32\""]; } +message ListCommitteesRequest { + oneof query_filter { + // Optional criteria to retrieve data at a specific epoch. + uint64 epoch = 1; + + // Optional criteria to retrieve genesis data. + bool genesis = 2; + } + // Validator 48 byte BLS public keys to filter validator indices for the given + // epoch. This field is optional. + repeated bytes public_keys = 3 [(gogoproto.moretags) = "ssz-size:\"?,48\""]; + + // Validator indices to filter validator indices for the given epoch. + // This field is optional. + repeated uint64 indices = 4; + + // The maximum number of Validators to return in the response. + // This field is optional. + int32 page_size = 5; + + // A pagination token returned from a previous call to `GetValidators` + // that indicates where this listing should continue from. + // This field is optional. + string page_token = 6; +} + +message BeaconCommittees { + message Committee { + // A committee of validator indices that need to attest to beacon blocks. + repeated uint64 = 1; + } + // The epoch for which the committees in the response belong to. + uint64 epoch = 1; + + // A list of committees of validators for given epoch. + repeated Committee committees = 2; + + // A pagination token returned from a previous call + // that indicates from where the listing should continue. + string next_page_token = 3; + + // Total count of committees matching the request filter. + int32 total_size = 4; +} + message GetValidatorBalancesRequest { oneof query_filter { // Optional criteria to retrieve balances at a specific epoch. From b9dce72f0a77c7bb0304c29b10a2e2aec2d3ab30 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 14:19:43 -0600 Subject: [PATCH 37/82] list beacon committees impl --- beacon-chain/rpc/beacon_chain_server.go | 20 + proto/beacon/db/attestation_container.pb.go | 5 +- .../db/finalized_block_root_container.pb.go | 3 +- proto/beacon/p2p/v1/messages.pb.go | 5 +- proto/beacon/p2p/v1/types.pb.go | 5 +- proto/beacon/rpc/v1/services.pb.go | 5 +- proto/beacon/rpc/v1_gateway/services.pb.go | 3 +- proto/eth/v1alpha1/archive.pb.go | 5 +- proto/eth/v1alpha1/attestation.pb.go | 5 +- proto/eth/v1alpha1/beacon_block.pb.go | 5 +- proto/eth/v1alpha1/beacon_chain.pb.go | 1513 +++++++++++++++-- proto/eth/v1alpha1/beacon_chain.proto | 6 +- proto/eth/v1alpha1/node.pb.go | 5 +- proto/eth/v1alpha1/validator.pb.go | 5 +- proto/sharding/p2p/v1/messages.pb.go | 3 +- 15 files changed, 1376 insertions(+), 217 deletions(-) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index bc3b136dc484..57cb0d02926f 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -236,6 +236,26 @@ func (bs *BeaconChainServer) GetChainHead(ctx context.Context, _ *ptypes.Empty) }, nil } +// ListBeaconCommittees for a given epoch. +// +// This request may specify validator indices or public keys to filter out +// validator beacon chain committees. If no filter criteria is specified, the response returns +// all beacon committees for the current epoch. The results are paginated by default. +func (bs *BeaconChainServer) ListBeaconCommittees( + ctx context.Context, + req *ethpb.ListCommitteesRequest, +) (*ethpb.BeaconCommittees, error) { + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf( + codes.InvalidArgument, + "requested page size %d can not be greater than max size %d", + req.PageSize, + params.BeaconConfig().MaxPageSize, + ) + } + return nil, nil +} + // ListValidatorBalances retrieves the validator balances for a given set of public keys. // An optional Epoch parameter is provided to request historical validator balances from // archived, persistent data. diff --git a/proto/beacon/db/attestation_container.pb.go b/proto/beacon/db/attestation_container.pb.go index 6689465ba04d..e07adc093af7 100755 --- a/proto/beacon/db/attestation_container.pb.go +++ b/proto/beacon/db/attestation_container.pb.go @@ -5,13 +5,12 @@ package db import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/db/finalized_block_root_container.pb.go b/proto/beacon/db/finalized_block_root_container.pb.go index ec2d6ffa74b4..a7eae5c80789 100755 --- a/proto/beacon/db/finalized_block_root_container.pb.go +++ b/proto/beacon/db/finalized_block_root_container.pb.go @@ -5,10 +5,9 @@ package db import ( fmt "fmt" + proto "github.com/gogo/protobuf/proto" io "io" math "math" - - proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/messages.pb.go b/proto/beacon/p2p/v1/messages.pb.go index 429de7fc2a97..c49daf0c207c 100755 --- a/proto/beacon/p2p/v1/messages.pb.go +++ b/proto/beacon/p2p/v1/messages.pb.go @@ -5,11 +5,10 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 74ff5e6ce4a8..3ff88f8599ac 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -5,13 +5,12 @@ package ethereum_beacon_p2p_v1 import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1/services.pb.go b/proto/beacon/rpc/v1/services.pb.go index 42c223a99c73..bcae8f7cec38 100755 --- a/proto/beacon/rpc/v1/services.pb.go +++ b/proto/beacon/rpc/v1/services.pb.go @@ -7,14 +7,13 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" - io "io" - math "math" - proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/beacon/rpc/v1_gateway/services.pb.go b/proto/beacon/rpc/v1_gateway/services.pb.go index 92e1c285cd45..c708d734c2bc 100755 --- a/proto/beacon/rpc/v1_gateway/services.pb.go +++ b/proto/beacon/rpc/v1_gateway/services.pb.go @@ -6,13 +6,12 @@ package ethereum_beacon_rpc_v1 import ( context "context" fmt "fmt" - math "math" - proto "github.com/golang/protobuf/proto" empty "github.com/golang/protobuf/ptypes/empty" v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/archive.pb.go b/proto/eth/v1alpha1/archive.pb.go index 649abc7b8f5c..9d19417d855c 100755 --- a/proto/eth/v1alpha1/archive.pb.go +++ b/proto/eth/v1alpha1/archive.pb.go @@ -5,11 +5,10 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/attestation.pb.go b/proto/eth/v1alpha1/attestation.pb.go index 008971640b79..b68d1b3d02d9 100755 --- a/proto/eth/v1alpha1/attestation.pb.go +++ b/proto/eth/v1alpha1/attestation.pb.go @@ -5,12 +5,11 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/beacon_block.pb.go b/proto/eth/v1alpha1/beacon_block.pb.go index 552ea64b0fd1..f9eb15a7834f 100755 --- a/proto/eth/v1alpha1/beacon_block.pb.go +++ b/proto/eth/v1alpha1/beacon_block.pb.go @@ -5,11 +5,10 @@ package eth import ( fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index 303d7f3aa3b9..f1b06d236b8b 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -6,14 +6,13 @@ package eth import ( context "context" fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -692,6 +691,304 @@ func (m *ChainHead) GetPreviousJustifiedBlockRoot() []byte { return nil } +type ListCommitteesRequest struct { + // Types that are valid to be assigned to QueryFilter: + // *ListCommitteesRequest_Epoch + // *ListCommitteesRequest_Genesis + QueryFilter isListCommitteesRequest_QueryFilter `protobuf_oneof:"query_filter"` + PublicKeys [][]byte `protobuf:"bytes,3,rep,name=public_keys,json=publicKeys,proto3" json:"public_keys,omitempty" ssz-size:"?,48"` + Indices []uint64 `protobuf:"varint,4,rep,packed,name=indices,proto3" json:"indices,omitempty"` + PageSize int32 `protobuf:"varint,5,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + PageToken string `protobuf:"bytes,6,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListCommitteesRequest) Reset() { *m = ListCommitteesRequest{} } +func (m *ListCommitteesRequest) String() string { return proto.CompactTextString(m) } +func (*ListCommitteesRequest) ProtoMessage() {} +func (*ListCommitteesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_678c88b69c3c78d4, []int{5} +} +func (m *ListCommitteesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListCommitteesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListCommitteesRequest.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 *ListCommitteesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListCommitteesRequest.Merge(m, src) +} +func (m *ListCommitteesRequest) XXX_Size() int { + return m.Size() +} +func (m *ListCommitteesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListCommitteesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListCommitteesRequest proto.InternalMessageInfo + +type isListCommitteesRequest_QueryFilter interface { + isListCommitteesRequest_QueryFilter() + MarshalTo([]byte) (int, error) + Size() int +} + +type ListCommitteesRequest_Epoch struct { + Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3,oneof"` +} +type ListCommitteesRequest_Genesis struct { + Genesis bool `protobuf:"varint,2,opt,name=genesis,proto3,oneof"` +} + +func (*ListCommitteesRequest_Epoch) isListCommitteesRequest_QueryFilter() {} +func (*ListCommitteesRequest_Genesis) isListCommitteesRequest_QueryFilter() {} + +func (m *ListCommitteesRequest) GetQueryFilter() isListCommitteesRequest_QueryFilter { + if m != nil { + return m.QueryFilter + } + return nil +} + +func (m *ListCommitteesRequest) GetEpoch() uint64 { + if x, ok := m.GetQueryFilter().(*ListCommitteesRequest_Epoch); ok { + return x.Epoch + } + return 0 +} + +func (m *ListCommitteesRequest) GetGenesis() bool { + if x, ok := m.GetQueryFilter().(*ListCommitteesRequest_Genesis); ok { + return x.Genesis + } + return false +} + +func (m *ListCommitteesRequest) GetPublicKeys() [][]byte { + if m != nil { + return m.PublicKeys + } + return nil +} + +func (m *ListCommitteesRequest) GetIndices() []uint64 { + if m != nil { + return m.Indices + } + return nil +} + +func (m *ListCommitteesRequest) GetPageSize() int32 { + if m != nil { + return m.PageSize + } + return 0 +} + +func (m *ListCommitteesRequest) GetPageToken() string { + if m != nil { + return m.PageToken + } + return "" +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*ListCommitteesRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _ListCommitteesRequest_OneofMarshaler, _ListCommitteesRequest_OneofUnmarshaler, _ListCommitteesRequest_OneofSizer, []interface{}{ + (*ListCommitteesRequest_Epoch)(nil), + (*ListCommitteesRequest_Genesis)(nil), + } +} + +func _ListCommitteesRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*ListCommitteesRequest) + // query_filter + switch x := m.QueryFilter.(type) { + case *ListCommitteesRequest_Epoch: + _ = b.EncodeVarint(1<<3 | proto.WireVarint) + _ = b.EncodeVarint(uint64(x.Epoch)) + case *ListCommitteesRequest_Genesis: + t := uint64(0) + if x.Genesis { + t = 1 + } + _ = b.EncodeVarint(2<<3 | proto.WireVarint) + _ = b.EncodeVarint(t) + case nil: + default: + return fmt.Errorf("ListCommitteesRequest.QueryFilter has unexpected type %T", x) + } + return nil +} + +func _ListCommitteesRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*ListCommitteesRequest) + switch tag { + case 1: // query_filter.epoch + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.QueryFilter = &ListCommitteesRequest_Epoch{x} + return true, err + case 2: // query_filter.genesis + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.QueryFilter = &ListCommitteesRequest_Genesis{x != 0} + return true, err + default: + return false, nil + } +} + +func _ListCommitteesRequest_OneofSizer(msg proto.Message) (n int) { + m := msg.(*ListCommitteesRequest) + // query_filter + switch x := m.QueryFilter.(type) { + case *ListCommitteesRequest_Epoch: + n += 1 // tag and wire + n += proto.SizeVarint(uint64(x.Epoch)) + case *ListCommitteesRequest_Genesis: + n += 1 // tag and wire + n += 1 + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type BeaconCommittees struct { + Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` + Committees []*BeaconCommittees_CommitteeItem `protobuf:"bytes,2,rep,name=committees,proto3" json:"committees,omitempty"` + NextPageToken string `protobuf:"bytes,3,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` + TotalSize int32 `protobuf:"varint,4,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BeaconCommittees) Reset() { *m = BeaconCommittees{} } +func (m *BeaconCommittees) String() string { return proto.CompactTextString(m) } +func (*BeaconCommittees) ProtoMessage() {} +func (*BeaconCommittees) Descriptor() ([]byte, []int) { + return fileDescriptor_678c88b69c3c78d4, []int{6} +} +func (m *BeaconCommittees) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BeaconCommittees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BeaconCommittees.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 *BeaconCommittees) XXX_Merge(src proto.Message) { + xxx_messageInfo_BeaconCommittees.Merge(m, src) +} +func (m *BeaconCommittees) XXX_Size() int { + return m.Size() +} +func (m *BeaconCommittees) XXX_DiscardUnknown() { + xxx_messageInfo_BeaconCommittees.DiscardUnknown(m) +} + +var xxx_messageInfo_BeaconCommittees proto.InternalMessageInfo + +func (m *BeaconCommittees) GetEpoch() uint64 { + if m != nil { + return m.Epoch + } + return 0 +} + +func (m *BeaconCommittees) GetCommittees() []*BeaconCommittees_CommitteeItem { + if m != nil { + return m.Committees + } + return nil +} + +func (m *BeaconCommittees) GetNextPageToken() string { + if m != nil { + return m.NextPageToken + } + return "" +} + +func (m *BeaconCommittees) GetTotalSize() int32 { + if m != nil { + return m.TotalSize + } + return 0 +} + +type BeaconCommittees_CommitteeItem struct { + Committee []uint64 `protobuf:"varint,1,rep,packed,name=committee,proto3" json:"committee,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BeaconCommittees_CommitteeItem) Reset() { *m = BeaconCommittees_CommitteeItem{} } +func (m *BeaconCommittees_CommitteeItem) String() string { return proto.CompactTextString(m) } +func (*BeaconCommittees_CommitteeItem) ProtoMessage() {} +func (*BeaconCommittees_CommitteeItem) Descriptor() ([]byte, []int) { + return fileDescriptor_678c88b69c3c78d4, []int{6, 0} +} +func (m *BeaconCommittees_CommitteeItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BeaconCommittees_CommitteeItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BeaconCommittees_CommitteeItem.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 *BeaconCommittees_CommitteeItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_BeaconCommittees_CommitteeItem.Merge(m, src) +} +func (m *BeaconCommittees_CommitteeItem) XXX_Size() int { + return m.Size() +} +func (m *BeaconCommittees_CommitteeItem) XXX_DiscardUnknown() { + xxx_messageInfo_BeaconCommittees_CommitteeItem.DiscardUnknown(m) +} + +var xxx_messageInfo_BeaconCommittees_CommitteeItem proto.InternalMessageInfo + +func (m *BeaconCommittees_CommitteeItem) GetCommittee() []uint64 { + if m != nil { + return m.Committee + } + return nil +} + type GetValidatorBalancesRequest struct { // Types that are valid to be assigned to QueryFilter: // *GetValidatorBalancesRequest_Epoch @@ -710,7 +1007,7 @@ func (m *GetValidatorBalancesRequest) Reset() { *m = GetValidatorBalance func (m *GetValidatorBalancesRequest) String() string { return proto.CompactTextString(m) } func (*GetValidatorBalancesRequest) ProtoMessage() {} func (*GetValidatorBalancesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{5} + return fileDescriptor_678c88b69c3c78d4, []int{7} } func (m *GetValidatorBalancesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -886,7 +1183,7 @@ func (m *ValidatorBalances) Reset() { *m = ValidatorBalances{} } func (m *ValidatorBalances) String() string { return proto.CompactTextString(m) } func (*ValidatorBalances) ProtoMessage() {} func (*ValidatorBalances) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{6} + return fileDescriptor_678c88b69c3c78d4, []int{8} } func (m *ValidatorBalances) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -956,7 +1253,7 @@ func (m *ValidatorBalances_Balance) Reset() { *m = ValidatorBalances_Bal func (m *ValidatorBalances_Balance) String() string { return proto.CompactTextString(m) } func (*ValidatorBalances_Balance) ProtoMessage() {} func (*ValidatorBalances_Balance) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{6, 0} + return fileDescriptor_678c88b69c3c78d4, []int{8, 0} } func (m *ValidatorBalances_Balance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1022,7 +1319,7 @@ func (m *GetValidatorsRequest) Reset() { *m = GetValidatorsRequest{} } func (m *GetValidatorsRequest) String() string { return proto.CompactTextString(m) } func (*GetValidatorsRequest) ProtoMessage() {} func (*GetValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{7} + return fileDescriptor_678c88b69c3c78d4, []int{9} } func (m *GetValidatorsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1184,7 +1481,7 @@ func (m *Validators) Reset() { *m = Validators{} } func (m *Validators) String() string { return proto.CompactTextString(m) } func (*Validators) ProtoMessage() {} func (*Validators) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{8} + return fileDescriptor_678c88b69c3c78d4, []int{10} } func (m *Validators) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1255,7 +1552,7 @@ func (m *GetValidatorActiveSetChangesRequest) Reset() { *m = GetValidato func (m *GetValidatorActiveSetChangesRequest) String() string { return proto.CompactTextString(m) } func (*GetValidatorActiveSetChangesRequest) ProtoMessage() {} func (*GetValidatorActiveSetChangesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{9} + return fileDescriptor_678c88b69c3c78d4, []int{11} } func (m *GetValidatorActiveSetChangesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1406,7 +1703,7 @@ func (m *ActiveSetChanges) Reset() { *m = ActiveSetChanges{} } func (m *ActiveSetChanges) String() string { return proto.CompactTextString(m) } func (*ActiveSetChanges) ProtoMessage() {} func (*ActiveSetChanges) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{10} + return fileDescriptor_678c88b69c3c78d4, []int{12} } func (m *ActiveSetChanges) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1483,7 +1780,7 @@ func (m *ValidatorQueue) Reset() { *m = ValidatorQueue{} } func (m *ValidatorQueue) String() string { return proto.CompactTextString(m) } func (*ValidatorQueue) ProtoMessage() {} func (*ValidatorQueue) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{11} + return fileDescriptor_678c88b69c3c78d4, []int{13} } func (m *ValidatorQueue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1551,7 +1848,7 @@ func (m *ListValidatorAssignmentsRequest) Reset() { *m = ListValidatorAs func (m *ListValidatorAssignmentsRequest) String() string { return proto.CompactTextString(m) } func (*ListValidatorAssignmentsRequest) ProtoMessage() {} func (*ListValidatorAssignmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{12} + return fileDescriptor_678c88b69c3c78d4, []int{14} } func (m *ListValidatorAssignmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1727,7 +2024,7 @@ func (m *ValidatorAssignments) Reset() { *m = ValidatorAssignments{} } func (m *ValidatorAssignments) String() string { return proto.CompactTextString(m) } func (*ValidatorAssignments) ProtoMessage() {} func (*ValidatorAssignments) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{13} + return fileDescriptor_678c88b69c3c78d4, []int{15} } func (m *ValidatorAssignments) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1801,7 +2098,7 @@ func (m *ValidatorAssignments_CommitteeAssignment) Reset() { func (m *ValidatorAssignments_CommitteeAssignment) String() string { return proto.CompactTextString(m) } func (*ValidatorAssignments_CommitteeAssignment) ProtoMessage() {} func (*ValidatorAssignments_CommitteeAssignment) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{13, 0} + return fileDescriptor_678c88b69c3c78d4, []int{15, 0} } func (m *ValidatorAssignments_CommitteeAssignment) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1879,7 +2176,7 @@ func (m *GetValidatorParticipationRequest) Reset() { *m = GetValidatorPa func (m *GetValidatorParticipationRequest) String() string { return proto.CompactTextString(m) } func (*GetValidatorParticipationRequest) ProtoMessage() {} func (*GetValidatorParticipationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{14} + return fileDescriptor_678c88b69c3c78d4, []int{16} } func (m *GetValidatorParticipationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2026,7 +2323,7 @@ func (m *ValidatorParticipationResponse) Reset() { *m = ValidatorPartici func (m *ValidatorParticipationResponse) String() string { return proto.CompactTextString(m) } func (*ValidatorParticipationResponse) ProtoMessage() {} func (*ValidatorParticipationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{15} + return fileDescriptor_678c88b69c3c78d4, []int{17} } func (m *ValidatorParticipationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2087,7 +2384,7 @@ func (m *AttestationPoolResponse) Reset() { *m = AttestationPoolResponse func (m *AttestationPoolResponse) String() string { return proto.CompactTextString(m) } func (*AttestationPoolResponse) ProtoMessage() {} func (*AttestationPoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_678c88b69c3c78d4, []int{16} + return fileDescriptor_678c88b69c3c78d4, []int{18} } func (m *AttestationPoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2129,6 +2426,9 @@ func init() { proto.RegisterType((*ListBlocksRequest)(nil), "ethereum.eth.v1alpha1.ListBlocksRequest") proto.RegisterType((*ListBlocksResponse)(nil), "ethereum.eth.v1alpha1.ListBlocksResponse") proto.RegisterType((*ChainHead)(nil), "ethereum.eth.v1alpha1.ChainHead") + proto.RegisterType((*ListCommitteesRequest)(nil), "ethereum.eth.v1alpha1.ListCommitteesRequest") + proto.RegisterType((*BeaconCommittees)(nil), "ethereum.eth.v1alpha1.BeaconCommittees") + proto.RegisterType((*BeaconCommittees_CommitteeItem)(nil), "ethereum.eth.v1alpha1.BeaconCommittees.CommitteeItem") proto.RegisterType((*GetValidatorBalancesRequest)(nil), "ethereum.eth.v1alpha1.GetValidatorBalancesRequest") proto.RegisterType((*ValidatorBalances)(nil), "ethereum.eth.v1alpha1.ValidatorBalances") proto.RegisterType((*ValidatorBalances_Balance)(nil), "ethereum.eth.v1alpha1.ValidatorBalances.Balance") @@ -2150,108 +2450,114 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ - // 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, 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, 0x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- 0x98, 0xf5, 0xb8, 0x8a, 0xc8, 0x04, 0x71, 0x9c, 0x87, 0x4c, 0x2c, 0x78, 0x62, 0xe4, 0x49, 0x99, - 0x4d, 0x79, 0x10, 0x2b, 0x31, 0x42, 0xe7, 0x61, 0x44, 0xba, 0x3e, 0xad, 0xc4, 0x72, 0x88, 0x36, - 0x61, 0x9e, 0x38, 0x96, 0xdd, 0xa9, 0xe3, 0xaa, 0x43, 0x1d, 0xcb, 0x74, 0xa8, 0x43, 0x2c, 0xd3, - 0x16, 0x11, 0x1a, 0x37, 0xe6, 0xd4, 0xdc, 0xbf, 0x23, 0x53, 0xf1, 0x20, 0x8c, 0xf4, 0x0d, 0xc2, - 0xe8, 0xa0, 0x20, 0x7c, 0xac, 0x01, 0x8a, 0x6e, 0x4c, 0xb9, 0xff, 0x2e, 0x8c, 0x8a, 0xc3, 0x39, - 0xc8, 0xf1, 0xdb, 0x22, 0x39, 0xe4, 0x79, 0x55, 0x2b, 0xce, 0xca, 0xe5, 0xdf, 0xa4, 0x61, 0x62, - 0xc7, 0xbb, 0x42, 0x76, 0xb1, 0x59, 0x47, 0x37, 0x00, 0xba, 0xb3, 0x65, 0x7b, 0xf6, 0xcd, 0xab, - 0x95, 0x1c, 0x63, 0x27, 0xd7, 0x3d, 0x80, 0xbb, 0xfa, 0xcd, 0x2d, 0xdd, 0x98, 0xa8, 0x05, 0xa9, - 0xb3, 0xe4, 0xaf, 0x08, 0x83, 0xa1, 0xa6, 0xf7, 0xbd, 0x78, 0xac, 0xc1, 0xd4, 0x01, 0x71, 0x4c, - 0x9b, 0x9c, 0xe0, 0xba, 0x54, 0x11, 0x81, 0x31, 0x72, 0x81, 0x54, 0xa8, 0xed, 0xc0, 0x7c, 0xa8, - 0x16, 0x61, 0x90, 0x49, 0x62, 0x80, 0x02, 0xf5, 0x30, 0x8b, 0xd7, 0x60, 0xea, 0x69, 0x87, 0x71, - 0x72, 0x40, 0x7c, 0x5b, 0x23, 0xd2, 0x56, 0x20,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 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, + // 1697 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0x3d, 0x6c, 0x1b, 0x47, + 0x16, 0xf6, 0x92, 0xd4, 0x0f, 0x9f, 0x44, 0xfd, 0x8c, 0x24, 0x9b, 0x47, 0xfd, 0x51, 0x2b, 0x4b, + 0xa6, 0x21, 0x8b, 0xb4, 0xe4, 0x9f, 0x3b, 0xf8, 0x70, 0xf0, 0x59, 0x82, 0xcf, 0xf2, 0x9d, 0x71, + 0x50, 0x56, 0x4e, 0x8a, 0x34, 0xc4, 0x70, 0x39, 0x22, 0xc7, 0x5a, 0xee, 0xac, 0xb9, 0x43, 0xc1, + 0x52, 0x97, 0x14, 0x01, 0x52, 0x07, 0x48, 0x52, 0x25, 0x69, 0x8d, 0x20, 0x6d, 0x1a, 0x03, 0x41, + 0x90, 0x2a, 0x65, 0x80, 0x00, 0x29, 0x8d, 0xc0, 0x08, 0xe0, 0x2a, 0x45, 0x0c, 0xa4, 0x0f, 0x76, + 0x76, 0xf6, 0x8f, 0xe4, 0x92, 0x34, 0xac, 0xca, 0x1d, 0xf7, 0xcd, 0x9b, 0xef, 0x7d, 0xf3, 0xde, + 0xbc, 0x99, 0xf7, 0x86, 0xb0, 0x66, 0x35, 0x19, 0x67, 0x25, 0xc2, 0xeb, 0x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, 0x5c, 0xe9, 0x5d, 0x47, 0x88, 0x56, 0x40, 0x7e, 0xba, 0x50, 0x49, 0x09, 0x05, 0xae, + 0xd0, 0xc3, 0xe1, 0xb8, 0x59, 0x23, 0x5c, 0xe2, 0xa4, 0x3c, 0x1c, 0x57, 0xea, 0xe3, 0x48, 0x25, + 0x81, 0x33, 0xe4, 0xe1, 0xb8, 0x42, 0x81, 0x33, 0x0f, 0x69, 0x0b, 0xd7, 0x48, 0xd9, 0xa6, 0xa7, + 0x24, 0x3b, 0x9c, 0x57, 0x0a, 0x43, 0xda, 0xa8, 0x23, 0x38, 0xa0, 0xa7, 0x04, 0x2d, 0x02, 0x88, + 0x41, 0xce, 0x8e, 0x88, 0x99, 0x1d, 0xc9, 0x2b, 0x85, 0xb4, 0x26, 0xd4, 0x1f, 0x3a, 0x82, 0x9d, + 0x09, 0x18, 0x7f, 0xdc, 0x22, 0xcd, 0x93, 0xf2, 0x21, 0x35, 0x38, 0x69, 0xaa, 0x4f, 0x15, 0xc8, + 0x76, 0x7a, 0xc8, 0xb6, 0x98, 0x69, 0x13, 0xf4, 0x1f, 0x18, 0x0f, 0x85, 0xc7, 0xce, 0x2a, 0xf9, + 0x64, 0x61, 0x6c, 0x5b, 0x2d, 0x76, 0xdd, 0x47, 0xc5, 0x10, 0x84, 0x16, 0x99, 0x87, 0xd6, 0x61, + 0xd2, 0x24, 0x4f, 0x78, 0x39, 0x44, 0x2c, 0x21, 0x88, 0x65, 0x1c, 0xf1, 0xbe, 0x47, 0xce, 0xe1, + 0xce, 0x19, 0xc7, 0x86, 0xbb, 0xb2, 0xa4, 0x58, 0x59, 0x5a, 0x48, 0x9c, 0xa5, 0xa9, 0xbf, 0x28, + 0x30, 0xed, 0x70, 0x15, 0x91, 0xf1, 0xe3, 0x38, 0x0b, 0xa9, 0x48, 0xf0, 0xc4, 0x97, 0x23, 0xb5, + 0x0d, 0xc6, 0xfd, 0x58, 0x89, 0x2f, 0x74, 0x1e, 0x86, 0x5c, 0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8, 0xf7, 0xce, 0xae, 0xa5, 0xc6, 0xcd, 0x1e, 0x1b, 0xbf, 0x47, 0x2d, 0x96, 0xdb, 0x78, 0x8d, + 0xba, 0x43, 0xbd, 0x22, 0x98, 0xae, 0xa3, 0x8b, 0xf1, 0x0e, 0x0b, 0x51, 0x7a, 0xa6, 0xc0, 0xdf, + 0x62, 0x2f, 0x55, 0xf4, 0xf7, 0x01, 0x22, 0xdc, 0xed, 0x1a, 0xce, 0xdd, 0x78, 0xbd, 0x4b, 0xad, + 0xcf, 0xe9, 0x1a, 0xe2, 0x1e, 0xb9, 0xfd, 0x76, 0x76, 0x7f, 0x7c, 0xb1, 0xa4, 0xfc, 0xf4, 0x62, + 0x49, 0xf9, 0xf5, 0xc5, 0x92, 0xf2, 0xfe, 0x8d, 0xd0, 0x1f, 0x0d, 0x56, 0xf3, 0xc4, 0x6e, 0x60, + 0x4e, 0x75, 0x03, 0x57, 0x6c, 0xf7, 0xab, 0xd4, 0xf9, 0xa0, 0xff, 0x4f, 0xc2, 0xeb, 0x95, 0x61, + 0x21, 0xbf, 0xf6, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0x8b, 0xf1, 0x98, 0xe6, 0x18, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2270,6 +2576,7 @@ type BeaconChainClient interface { AttestationPool(ctx context.Context, in *types.Empty, opts ...grpc.CallOption) (*AttestationPoolResponse, error) ListBlocks(ctx context.Context, in *ListBlocksRequest, opts ...grpc.CallOption) (*ListBlocksResponse, error) GetChainHead(ctx context.Context, in *types.Empty, opts ...grpc.CallOption) (*ChainHead, error) + ListBeaconCommittees(ctx context.Context, in *ListCommitteesRequest, opts ...grpc.CallOption) (*BeaconCommittees, error) ListValidatorBalances(ctx context.Context, in *GetValidatorBalancesRequest, opts ...grpc.CallOption) (*ValidatorBalances, error) GetValidators(ctx context.Context, in *GetValidatorsRequest, opts ...grpc.CallOption) (*Validators, error) GetValidatorActiveSetChanges(ctx context.Context, in *GetValidatorActiveSetChangesRequest, opts ...grpc.CallOption) (*ActiveSetChanges, error) @@ -2322,6 +2629,15 @@ func (c *beaconChainClient) GetChainHead(ctx context.Context, in *types.Empty, o return out, nil } +func (c *beaconChainClient) ListBeaconCommittees(ctx context.Context, in *ListCommitteesRequest, opts ...grpc.CallOption) (*BeaconCommittees, error) { + out := new(BeaconCommittees) + err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.BeaconChain/ListBeaconCommittees", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *beaconChainClient) ListValidatorBalances(ctx context.Context, in *GetValidatorBalancesRequest, opts ...grpc.CallOption) (*ValidatorBalances, error) { out := new(ValidatorBalances) err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.BeaconChain/ListValidatorBalances", in, out, opts...) @@ -2382,6 +2698,7 @@ type BeaconChainServer interface { AttestationPool(context.Context, *types.Empty) (*AttestationPoolResponse, error) ListBlocks(context.Context, *ListBlocksRequest) (*ListBlocksResponse, error) GetChainHead(context.Context, *types.Empty) (*ChainHead, error) + ListBeaconCommittees(context.Context, *ListCommitteesRequest) (*BeaconCommittees, error) ListValidatorBalances(context.Context, *GetValidatorBalancesRequest) (*ValidatorBalances, error) GetValidators(context.Context, *GetValidatorsRequest) (*Validators, error) GetValidatorActiveSetChanges(context.Context, *GetValidatorActiveSetChangesRequest) (*ActiveSetChanges, error) @@ -2466,6 +2783,24 @@ func _BeaconChain_GetChainHead_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _BeaconChain_ListBeaconCommittees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListCommitteesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BeaconChainServer).ListBeaconCommittees(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ethereum.eth.v1alpha1.BeaconChain/ListBeaconCommittees", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BeaconChainServer).ListBeaconCommittees(ctx, req.(*ListCommitteesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _BeaconChain_ListValidatorBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetValidatorBalancesRequest) if err := dec(in); err != nil { @@ -2594,6 +2929,10 @@ var _BeaconChain_serviceDesc = grpc.ServiceDesc{ MethodName: "GetChainHead", Handler: _BeaconChain_GetChainHead_Handler, }, + { + MethodName: "ListBeaconCommittees", + Handler: _BeaconChain_ListBeaconCommittees_Handler, + }, { MethodName: "ListValidatorBalances", Handler: _BeaconChain_ListValidatorBalances_Handler, @@ -2932,7 +3271,7 @@ func (m *ChainHead) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *GetValidatorBalancesRequest) Marshal() (dAtA []byte, err error) { +func (m *ListCommitteesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -2942,7 +3281,7 @@ func (m *GetValidatorBalancesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *ListCommitteesRequest) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2996,14 +3335,14 @@ func (m *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *GetValidatorBalancesRequest_Epoch) MarshalTo(dAtA []byte) (int, error) { +func (m *ListCommitteesRequest_Epoch) MarshalTo(dAtA []byte) (int, error) { i := 0 dAtA[i] = 0x8 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.Epoch)) return i, nil } -func (m *GetValidatorBalancesRequest_Genesis) MarshalTo(dAtA []byte) (int, error) { +func (m *ListCommitteesRequest_Genesis) MarshalTo(dAtA []byte) (int, error) { i := 0 dAtA[i] = 0x10 i++ @@ -3015,7 +3354,7 @@ func (m *GetValidatorBalancesRequest_Genesis) MarshalTo(dAtA []byte) (int, error i++ return i, nil } -func (m *ValidatorBalances) Marshal() (dAtA []byte, err error) { +func (m *BeaconCommittees) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -3025,7 +3364,7 @@ func (m *ValidatorBalances) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { +func (m *BeaconCommittees) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -3035,8 +3374,8 @@ func (m *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.Epoch)) } - if len(m.Balances) > 0 { - for _, msg := range m.Balances { + if len(m.Committees) > 0 { + for _, msg := range m.Committees { dAtA[i] = 0x12 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(msg.Size())) @@ -3064,7 +3403,7 @@ func (m *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *ValidatorBalances_Balance) Marshal() (dAtA []byte, err error) { +func (m *BeaconCommittees_CommitteeItem) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -3074,7 +3413,177 @@ func (m *ValidatorBalances_Balance) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ValidatorBalances_Balance) MarshalTo(dAtA []byte) (int, error) { +func (m *BeaconCommittees_CommitteeItem) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Committee) > 0 { + dAtA7 := make([]byte, len(m.Committee)*10) + var j6 int + for _, num := range m.Committee { + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + dAtA[i] = 0xa + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(j6)) + i += copy(dAtA[i:], dAtA7[:j6]) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *GetValidatorBalancesRequest) 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 *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.QueryFilter != nil { + nn8, err := m.QueryFilter.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn8 + } + if len(m.PublicKeys) > 0 { + for _, b := range m.PublicKeys { + dAtA[i] = 0x1a + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } + } + if len(m.Indices) > 0 { + dAtA10 := make([]byte, len(m.Indices)*10) + var j9 int + for _, num := range m.Indices { + for num >= 1<<7 { + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j9++ + } + dAtA10[j9] = uint8(num) + j9++ + } + dAtA[i] = 0x22 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(j9)) + i += copy(dAtA[i:], dAtA10[:j9]) + } + if m.PageSize != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.PageSize)) + } + if len(m.PageToken) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.PageToken))) + i += copy(dAtA[i:], m.PageToken) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *GetValidatorBalancesRequest_Epoch) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x8 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.Epoch)) + return i, nil +} +func (m *GetValidatorBalancesRequest_Genesis) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x10 + i++ + if m.Genesis { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + return i, nil +} +func (m *ValidatorBalances) 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 *ValidatorBalances) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Epoch != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.Epoch)) + } + if len(m.Balances) > 0 { + for _, msg := range m.Balances { + dAtA[i] = 0x12 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.NextPageToken) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.NextPageToken))) + i += copy(dAtA[i:], m.NextPageToken) + } + if m.TotalSize != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.TotalSize)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ValidatorBalances_Balance) 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 *ValidatorBalances_Balance) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -3117,11 +3626,11 @@ func (m *GetValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn6, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn11, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn6 + i += nn11 } if m.PageSize != 0 { dAtA[i] = 0x18 @@ -3224,11 +3733,11 @@ func (m *GetValidatorActiveSetChangesRequest) MarshalTo(dAtA []byte) (int, error var l int _ = l if m.QueryFilter != nil { - nn7, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn12, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn7 + i += nn12 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -3371,11 +3880,11 @@ func (m *ListValidatorAssignmentsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn8, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn13, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn8 + i += nn13 } if len(m.PublicKeys) > 0 { for _, b := range m.PublicKeys { @@ -3386,21 +3895,21 @@ func (m *ListValidatorAssignmentsRequest) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Indices) > 0 { - dAtA10 := make([]byte, len(m.Indices)*10) - var j9 int + dAtA15 := make([]byte, len(m.Indices)*10) + var j14 int for _, num := range m.Indices { for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j9++ + j14++ } - dAtA10[j9] = uint8(num) - j9++ + dAtA15[j14] = uint8(num) + j14++ } dAtA[i] = 0x22 i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j9)) - i += copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j14)) + i += copy(dAtA[i:], dAtA15[:j14]) } if m.PageSize != 0 { dAtA[i] = 0x28 @@ -3503,21 +4012,21 @@ func (m *ValidatorAssignments_CommitteeAssignment) MarshalTo(dAtA []byte) (int, var l int _ = l if len(m.BeaconCommittees) > 0 { - dAtA12 := make([]byte, len(m.BeaconCommittees)*10) - var j11 int + dAtA17 := make([]byte, len(m.BeaconCommittees)*10) + var j16 int for _, num := range m.BeaconCommittees { for num >= 1<<7 { - dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) + dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j11++ + j16++ } - dAtA12[j11] = uint8(num) - j11++ + dAtA17[j16] = uint8(num) + j16++ } dAtA[i] = 0xa i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j11)) - i += copy(dAtA[i:], dAtA12[:j11]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j16)) + i += copy(dAtA[i:], dAtA17[:j16]) } if m.CommitteeIndex != 0 { dAtA[i] = 0x10 @@ -3562,11 +4071,11 @@ func (m *GetValidatorParticipationRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn13, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn18, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn13 + i += nn18 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -3627,11 +4136,11 @@ func (m *ValidatorParticipationResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.Participation.Size())) - n14, err := m.Participation.MarshalTo(dAtA[i:]) + n19, err := m.Participation.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n19 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -3902,7 +4411,7 @@ func (m *ChainHead) Size() (n int) { return n } -func (m *GetValidatorBalancesRequest) Size() (n int) { +func (m *ListCommitteesRequest) Size() (n int) { if m == nil { return 0 } @@ -3937,7 +4446,7 @@ func (m *GetValidatorBalancesRequest) Size() (n int) { return n } -func (m *GetValidatorBalancesRequest_Epoch) Size() (n int) { +func (m *ListCommitteesRequest_Epoch) Size() (n int) { if m == nil { return 0 } @@ -3946,7 +4455,7 @@ func (m *GetValidatorBalancesRequest_Epoch) Size() (n int) { n += 1 + sovBeaconChain(uint64(m.Epoch)) return n } -func (m *GetValidatorBalancesRequest_Genesis) Size() (n int) { +func (m *ListCommitteesRequest_Genesis) Size() (n int) { if m == nil { return 0 } @@ -3955,7 +4464,7 @@ func (m *GetValidatorBalancesRequest_Genesis) Size() (n int) { n += 2 return n } -func (m *ValidatorBalances) Size() (n int) { +func (m *BeaconCommittees) Size() (n int) { if m == nil { return 0 } @@ -3964,8 +4473,8 @@ func (m *ValidatorBalances) Size() (n int) { if m.Epoch != 0 { n += 1 + sovBeaconChain(uint64(m.Epoch)) } - if len(m.Balances) > 0 { - for _, e := range m.Balances { + if len(m.Committees) > 0 { + for _, e := range m.Committees { l = e.Size() n += 1 + l + sovBeaconChain(uint64(l)) } @@ -3983,21 +4492,18 @@ func (m *ValidatorBalances) Size() (n int) { return n } -func (m *ValidatorBalances_Balance) Size() (n int) { +func (m *BeaconCommittees_CommitteeItem) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.PublicKey) - if l > 0 { - n += 1 + l + sovBeaconChain(uint64(l)) - } - if m.Index != 0 { - n += 1 + sovBeaconChain(uint64(m.Index)) - } - if m.Balance != 0 { - n += 1 + sovBeaconChain(uint64(m.Balance)) + if len(m.Committee) > 0 { + l = 0 + for _, e := range m.Committee { + l += sovBeaconChain(uint64(e)) + } + n += 1 + sovBeaconChain(uint64(l)) + l } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -4005,7 +4511,7 @@ func (m *ValidatorBalances_Balance) Size() (n int) { return n } -func (m *GetValidatorsRequest) Size() (n int) { +func (m *GetValidatorBalancesRequest) Size() (n int) { if m == nil { return 0 } @@ -4014,6 +4520,19 @@ func (m *GetValidatorsRequest) Size() (n int) { if m.QueryFilter != nil { n += m.QueryFilter.Size() } + if len(m.PublicKeys) > 0 { + for _, b := range m.PublicKeys { + l = len(b) + n += 1 + l + sovBeaconChain(uint64(l)) + } + } + if len(m.Indices) > 0 { + l = 0 + for _, e := range m.Indices { + l += sovBeaconChain(uint64(e)) + } + n += 1 + sovBeaconChain(uint64(l)) + l + } if m.PageSize != 0 { n += 1 + sovBeaconChain(uint64(m.PageSize)) } @@ -4027,7 +4546,7 @@ func (m *GetValidatorsRequest) Size() (n int) { return n } -func (m *GetValidatorsRequest_Epoch) Size() (n int) { +func (m *GetValidatorBalancesRequest_Epoch) Size() (n int) { if m == nil { return 0 } @@ -4036,7 +4555,7 @@ func (m *GetValidatorsRequest_Epoch) Size() (n int) { n += 1 + sovBeaconChain(uint64(m.Epoch)) return n } -func (m *GetValidatorsRequest_Genesis) Size() (n int) { +func (m *GetValidatorBalancesRequest_Genesis) Size() (n int) { if m == nil { return 0 } @@ -4045,7 +4564,7 @@ func (m *GetValidatorsRequest_Genesis) Size() (n int) { n += 2 return n } -func (m *Validators) Size() (n int) { +func (m *ValidatorBalances) Size() (n int) { if m == nil { return 0 } @@ -4054,8 +4573,8 @@ func (m *Validators) Size() (n int) { if m.Epoch != 0 { n += 1 + sovBeaconChain(uint64(m.Epoch)) } - if len(m.Validators) > 0 { - for _, e := range m.Validators { + if len(m.Balances) > 0 { + for _, e := range m.Balances { l = e.Size() n += 1 + l + sovBeaconChain(uint64(l)) } @@ -4073,7 +4592,29 @@ func (m *Validators) Size() (n int) { return n } -func (m *GetValidatorActiveSetChangesRequest) Size() (n int) { +func (m *ValidatorBalances_Balance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovBeaconChain(uint64(l)) + } + if m.Index != 0 { + n += 1 + sovBeaconChain(uint64(m.Index)) + } + if m.Balance != 0 { + n += 1 + sovBeaconChain(uint64(m.Balance)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetValidatorsRequest) Size() (n int) { if m == nil { return 0 } @@ -4082,13 +4623,20 @@ func (m *GetValidatorActiveSetChangesRequest) Size() (n int) { if m.QueryFilter != nil { n += m.QueryFilter.Size() } + if m.PageSize != 0 { + n += 1 + sovBeaconChain(uint64(m.PageSize)) + } + l = len(m.PageToken) + if l > 0 { + n += 1 + l + sovBeaconChain(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } return n } -func (m *GetValidatorActiveSetChangesRequest_Epoch) Size() (n int) { +func (m *GetValidatorsRequest_Epoch) Size() (n int) { if m == nil { return 0 } @@ -4097,7 +4645,7 @@ func (m *GetValidatorActiveSetChangesRequest_Epoch) Size() (n int) { n += 1 + sovBeaconChain(uint64(m.Epoch)) return n } -func (m *GetValidatorActiveSetChangesRequest_Genesis) Size() (n int) { +func (m *GetValidatorsRequest_Genesis) Size() (n int) { if m == nil { return 0 } @@ -4106,7 +4654,68 @@ func (m *GetValidatorActiveSetChangesRequest_Genesis) Size() (n int) { n += 2 return n } -func (m *ActiveSetChanges) Size() (n int) { +func (m *Validators) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Epoch != 0 { + n += 1 + sovBeaconChain(uint64(m.Epoch)) + } + if len(m.Validators) > 0 { + for _, e := range m.Validators { + l = e.Size() + n += 1 + l + sovBeaconChain(uint64(l)) + } + } + l = len(m.NextPageToken) + if l > 0 { + n += 1 + l + sovBeaconChain(uint64(l)) + } + if m.TotalSize != 0 { + n += 1 + sovBeaconChain(uint64(m.TotalSize)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetValidatorActiveSetChangesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.QueryFilter != nil { + n += m.QueryFilter.Size() + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetValidatorActiveSetChangesRequest_Epoch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovBeaconChain(uint64(m.Epoch)) + return n +} +func (m *GetValidatorActiveSetChangesRequest_Genesis) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 2 + return n +} +func (m *ActiveSetChanges) Size() (n int) { if m == nil { return 0 } @@ -5357,6 +5966,548 @@ func (m *ChainHead) Unmarshal(dAtA []byte) error { } return nil } +func (m *ListCommitteesRequest) 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 ErrIntOverflowBeaconChain + } + 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: ListCommitteesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListCommitteesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.QueryFilter = &ListCommitteesRequest_Epoch{v} + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Genesis", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.QueryFilter = &ListCommitteesRequest_Genesis{b} + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKeys = append(m.PublicKeys, make([]byte, postIndex-iNdEx)) + copy(m.PublicKeys[len(m.PublicKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Indices = append(m.Indices, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Indices) == 0 { + m.Indices = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Indices = append(m.Indices, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Indices", wireType) + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PageSize", wireType) + } + m.PageSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PageSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PageToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PageToken = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBeaconChain(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBeaconChain + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBeaconChain + } + 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 *BeaconCommittees) 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 ErrIntOverflowBeaconChain + } + 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: BeaconCommittees: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BeaconCommittees: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Committees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Committees = append(m.Committees, &BeaconCommittees_CommitteeItem{}) + if err := m.Committees[len(m.Committees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextPageToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextPageToken = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSize", wireType) + } + m.TotalSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalSize |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBeaconChain(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBeaconChain + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBeaconChain + } + 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 *BeaconCommittees_CommitteeItem) 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 ErrIntOverflowBeaconChain + } + 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: CommitteeItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitteeItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Committee = append(m.Committee, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthBeaconChain + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthBeaconChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Committee) == 0 { + m.Committee = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Committee = append(m.Committee, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Committee", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipBeaconChain(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBeaconChain + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBeaconChain + } + 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 *GetValidatorBalancesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index f5aa6220d758..1a57ad50e0d7 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -275,15 +275,15 @@ message ListCommitteesRequest { } message BeaconCommittees { - message Committee { + message CommitteeItem { // A committee of validator indices that need to attest to beacon blocks. - repeated uint64 = 1; + repeated uint64 committee = 1; } // The epoch for which the committees in the response belong to. uint64 epoch = 1; // A list of committees of validators for given epoch. - repeated Committee committees = 2; + repeated CommitteeItem committees = 2; // A pagination token returned from a previous call // that indicates from where the listing should continue. diff --git a/proto/eth/v1alpha1/node.pb.go b/proto/eth/v1alpha1/node.pb.go index 647805e30f3d..2ba95ac9b419 100755 --- a/proto/eth/v1alpha1/node.pb.go +++ b/proto/eth/v1alpha1/node.pb.go @@ -6,13 +6,12 @@ package eth import ( context "context" fmt "fmt" - io "io" - math "math" - proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/eth/v1alpha1/validator.pb.go b/proto/eth/v1alpha1/validator.pb.go index 4fb145895295..d4f83587b8da 100755 --- a/proto/eth/v1alpha1/validator.pb.go +++ b/proto/eth/v1alpha1/validator.pb.go @@ -7,14 +7,13 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" - io "io" - math "math" - _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + io "io" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/sharding/p2p/v1/messages.pb.go b/proto/sharding/p2p/v1/messages.pb.go index 61228b93def4..ba268c5f4bac 100644 --- a/proto/sharding/p2p/v1/messages.pb.go +++ b/proto/sharding/p2p/v1/messages.pb.go @@ -5,10 +5,9 @@ package ethereum_sharding_p2p_v1 import ( fmt "fmt" + proto "github.com/gogo/protobuf/proto" io "io" math "math" - - proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. From ec296e72074f0a57c91f733da7cfd0e68944b321 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 14:55:14 -0600 Subject: [PATCH 38/82] beacon committees fetch from archive --- beacon-chain/rpc/beacon_chain_server.go | 126 +++++++++--------------- beacon-chain/rpc/helpers.go | 86 ++++++++++++++++ 2 files changed, 134 insertions(+), 78 deletions(-) create mode 100644 beacon-chain/rpc/helpers.go diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index 57cb0d02926f..037ee0f0520e 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -2,12 +2,14 @@ package rpc import ( "context" - "fmt" "sort" "time" ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" @@ -19,11 +21,8 @@ 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" - "google.golang.org/grpc/status" ) // BeaconChainServer defines a server implementation of the gRPC Beacon Chain service, @@ -253,6 +252,51 @@ func (bs *BeaconChainServer) ListBeaconCommittees( params.BeaconConfig().MaxPageSize, ) } + + headState := bs.headFetcher.HeadState() + var requestingGenesis bool + var startSlot uint64 + switch q := req.QueryFilter.(type) { + case *ethpb.ListCommitteesRequest_Epoch: + startSlot = helpers.StartSlot(q.Epoch) + case *ethpb.ListCommitteesRequest_Genesis: + requestingGenesis = q.Genesis + default: + startSlot = headState.Slot + } + + var attesterSeed [32]byte + var committeeCount uint64 + var activeIndices []uint64 + if requestingGenesis { + activeIndices, err := helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) + if err != nil { + return nil, err + } + } else if startSlot == headState.Slot { + + } else { + // Otherwise, we request archival data. + + } + + // If current epoch, compute. Otherwise, fetch from archive. + 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, err + } + } + } return nil, nil } @@ -705,80 +749,6 @@ func (bs *BeaconChainServer) ListValidatorAssignments( }, nil } -// Computes validator assignments for an epoch and validator index using archived committee -// information, archived balances, and a set of active validators. -func archivedValidatorCommittee( - epoch uint64, - validatorIndex uint64, - archivedInfo *ethpb.ArchivedCommitteeInfo, - activeIndices []uint64, - archivedBalances []uint64, -) ([]uint64, uint64, uint64, uint64, error) { - committeeCount := archivedInfo.CommitteeCount - 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++ { - 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, 0, errors.Wrap(err, "could not compute committee") - } - for _, index := range committee { - if validatorIndex == index { - proposerSlot, _ := proposerIndexToSlot[validatorIndex] - return committee, i, slot, proposerSlot, nil - } - } - } - } - 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, // it returns the information about validator's participation rate in voting on the proof of stake // rules based on their balance compared to the total active validator balance. diff --git a/beacon-chain/rpc/helpers.go b/beacon-chain/rpc/helpers.go new file mode 100644 index 000000000000..228915d91c85 --- /dev/null +++ b/beacon-chain/rpc/helpers.go @@ -0,0 +1,86 @@ +package rpc + +import ( + "fmt" + + "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + 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/params" +) + +// Computes validator assignments for an epoch and validator index using archived committee +// information, archived balances, and a set of active validators. +func archivedValidatorCommittee( + epoch uint64, + validatorIndex uint64, + archivedInfo *ethpb.ArchivedCommitteeInfo, + activeIndices []uint64, + archivedBalances []uint64, +) ([]uint64, uint64, uint64, uint64, error) { + committeeCount := archivedInfo.CommitteeCount + 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++ { + 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, 0, errors.Wrap(err, "could not compute committee") + } + for _, index := range committee { + if validatorIndex == index { + proposerSlot, _ := proposerIndexToSlot[validatorIndex] + return committee, i, slot, proposerSlot, nil + } + } + } + } + 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 + } + } +} From 3259f797f397dc745fd5edb39276e9760367912b Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 15:05:35 -0600 Subject: [PATCH 39/82] full list beacon committees implementation --- beacon-chain/rpc/beacon_chain_server.go | 40 ++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index 037ee0f0520e..f38288770e85 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -268,19 +268,37 @@ func (bs *BeaconChainServer) ListBeaconCommittees( var attesterSeed [32]byte var committeeCount uint64 var activeIndices []uint64 - if requestingGenesis { - activeIndices, err := helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) + var err error + if requestingGenesis || startSlot != headState.Slot { + activeIndices, err = helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) if err != nil { return nil, err } - } else if startSlot == headState.Slot { - + archivedCommitteeInfo, err := bs.beaconDB.ArchivedCommitteeInfo(ctx, helpers.SlotToEpoch(startSlot)) + if err != nil { + return nil, err + } + attesterSeed = bytesutil.ToBytes32(archivedCommitteeInfo.AttesterSeed) + committeeCount = archivedCommitteeInfo.CommitteeCount } else { - // Otherwise, we request archival data. - + // Otherwise, we use data from the current epoch. + currentEpoch := helpers.SlotToEpoch(headState.Slot) + activeIndices, err = helpers.ActiveValidatorIndices(headState, currentEpoch) + if err != nil { + return nil, err + } + committeeCount, err = helpers.CommitteeCountAtSlot(headState, headState.Slot) + if err != nil { + return nil, err + } + attesterSeed, err = helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) + if err != nil { + return nil, err + } } // If current epoch, compute. Otherwise, fetch from archive. + committees := make([]*ethpb.BeaconCommittees_CommitteeItem, 0) 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 { @@ -295,9 +313,17 @@ func (bs *BeaconChainServer) ListBeaconCommittees( if err != nil { return nil, err } + committees = append(committees, ðpb.BeaconCommittees_CommitteeItem{ + Committee: committee, + }) } } - return nil, nil + return ðpb.BeaconCommittees{ + Epoch: helpers.SlotToEpoch(startSlot), + Committees: committees, + NextPageToken: "", + TotalSize: int32(len(committees)), + }, nil } // ListValidatorBalances retrieves the validator balances for a given set of public keys. From 8a517cf18560ace06e0094039eb93c69745bd49a Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 15:14:04 -0600 Subject: [PATCH 40/82] list beacon committees added more useful fields --- beacon-chain/rpc/beacon_chain_server.go | 10 +- proto/eth/v1alpha1/beacon_chain.pb.go | 298 +++++++++++++++--------- proto/eth/v1alpha1/beacon_chain.proto | 11 +- 3 files changed, 200 insertions(+), 119 deletions(-) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index f38288770e85..df982e65c043 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -315,14 +315,16 @@ func (bs *BeaconChainServer) ListBeaconCommittees( } committees = append(committees, ðpb.BeaconCommittees_CommitteeItem{ Committee: committee, + Slot: slot, }) } } return ðpb.BeaconCommittees{ - Epoch: helpers.SlotToEpoch(startSlot), - Committees: committees, - NextPageToken: "", - TotalSize: int32(len(committees)), + Epoch: helpers.SlotToEpoch(startSlot), + ActiveValidatorCount: uint64(len(activeIndices)), + Committees: committees, + NextPageToken: "", + TotalSize: int32(len(committees)), }, nil } diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index f1b06d236b8b..a4a154adc29f 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -874,8 +874,9 @@ func _ListCommitteesRequest_OneofSizer(msg proto.Message) (n int) { type BeaconCommittees struct { Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` Committees []*BeaconCommittees_CommitteeItem `protobuf:"bytes,2,rep,name=committees,proto3" json:"committees,omitempty"` - NextPageToken string `protobuf:"bytes,3,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` - TotalSize int32 `protobuf:"varint,4,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` + ActiveValidatorCount uint64 `protobuf:"varint,3,opt,name=active_validator_count,json=activeValidatorCount,proto3" json:"active_validator_count,omitempty"` + NextPageToken string `protobuf:"bytes,4,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` + TotalSize int32 `protobuf:"varint,5,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -928,6 +929,13 @@ func (m *BeaconCommittees) GetCommittees() []*BeaconCommittees_CommitteeItem { return nil } +func (m *BeaconCommittees) GetActiveValidatorCount() uint64 { + if m != nil { + return m.ActiveValidatorCount + } + return 0 +} + func (m *BeaconCommittees) GetNextPageToken() string { if m != nil { return m.NextPageToken @@ -944,6 +952,7 @@ func (m *BeaconCommittees) GetTotalSize() int32 { type BeaconCommittees_CommitteeItem struct { Committee []uint64 `protobuf:"varint,1,rep,packed,name=committee,proto3" json:"committee,omitempty"` + Slot uint64 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -989,6 +998,13 @@ func (m *BeaconCommittees_CommitteeItem) GetCommittee() []uint64 { return nil } +func (m *BeaconCommittees_CommitteeItem) GetSlot() uint64 { + if m != nil { + return m.Slot + } + return 0 +} + type GetValidatorBalancesRequest struct { // Types that are valid to be assigned to QueryFilter: // *GetValidatorBalancesRequest_Epoch @@ -2450,114 +2466,116 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ - // 1697 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0x3d, 0x6c, 0x1b, 0x47, - 0x16, 0xf6, 0x92, 0xd4, 0x0f, 0x9f, 0x44, 0xfd, 0x8c, 0x24, 0x9b, 0x47, 0xfd, 0x51, 0x2b, 0x4b, - 0xa6, 0x21, 0x8b, 0xb4, 0xe4, 0x9f, 0x3b, 0xf8, 0x70, 0xf0, 0x59, 0x82, 0xcf, 0xf2, 0x9d, 0x71, - 0x50, 0x56, 0x4e, 0x8a, 0x34, 0xc4, 0x70, 0x39, 0x22, 0xc7, 0x5a, 0xee, 0xac, 0xb9, 0x43, 0xc1, - 0x52, 0x97, 0x14, 0x01, 0x52, 0x07, 0x48, 0x52, 0x25, 0x69, 0x8d, 0x20, 0x6d, 0x1a, 0x03, 0x41, - 0x90, 0x2a, 0x65, 0x80, 0x00, 0x29, 0x8d, 0xc0, 0x08, 0xe0, 0x2a, 0x45, 0x0c, 0xa4, 0x0f, 0x76, - 0x76, 0xf6, 0x8f, 0xe4, 0x92, 0x34, 0xac, 0xca, 0x1d, 0xf7, 0xcd, 0x9b, 0xef, 0x7d, 0xf3, 0xde, - 0xbc, 0x99, 0xf7, 0x86, 0xb0, 0x66, 0x35, 0x19, 0x67, 0x25, 0xc2, 0xeb, 0xa5, 0xe3, 0x2d, 0x6c, - 0x58, 0x75, 0xbc, 0x55, 0xaa, 0x10, 0xac, 0x33, 0xb3, 0xac, 0xd7, 0x31, 0x35, 0x8b, 0x62, 0x1c, - 0xcd, 0x11, 0x5e, 0x27, 0x4d, 0xd2, 0x6a, 0x14, 0x09, 0xaf, 0x17, 0x3d, 0xcd, 0xdc, 0x66, 0x8d, - 0xf2, 0x7a, 0xab, 0x52, 0xd4, 0x59, 0xa3, 0x54, 0x63, 0x35, 0x56, 0x12, 0xda, 0x95, 0xd6, 0xa1, - 0xf8, 0x72, 0xa1, 0x9d, 0x5f, 0x2e, 0x4a, 0x6e, 0xa1, 0xc6, 0x58, 0xcd, 0x20, 0x25, 0x6c, 0xd1, - 0x12, 0x36, 0x4d, 0xc6, 0x31, 0xa7, 0xcc, 0xb4, 0xe5, 0xe8, 0xbc, 0x1c, 0xf5, 0x31, 0x48, 0xc3, - 0xe2, 0x27, 0x72, 0xf0, 0x62, 0x17, 0x9e, 0x98, 0x73, 0x62, 0xbb, 0x18, 0x52, 0xab, 0xc7, 0x6a, - 0x2a, 0x06, 0xd3, 0x8f, 0xa4, 0x9a, 0xda, 0x45, 0xed, 0x18, 0x1b, 0x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, 0x4a, - 0xf3, 0x3e, 0xcf, 0x34, 0x91, 0xfe, 0x54, 0x60, 0xca, 0xcd, 0x86, 0x60, 0xad, 0x68, 0x36, 0xb2, - 0x48, 0x6f, 0x89, 0xef, 0x02, 0xe8, 0xbe, 0x4e, 0x36, 0x21, 0x12, 0xec, 0x46, 0xcf, 0x04, 0x0b, - 0x20, 0x8b, 0xfe, 0xcf, 0xfb, 0x9c, 0x34, 0xb4, 0x10, 0x50, 0xb7, 0xbc, 0x4b, 0xf6, 0xcf, 0xbb, - 0x54, 0x5b, 0xde, 0xe5, 0x36, 0x21, 0x13, 0xb1, 0x81, 0x16, 0x20, 0xed, 0x5b, 0x11, 0xc7, 0x41, - 0x4a, 0x0b, 0x04, 0xea, 0xef, 0x0a, 0xcc, 0xdf, 0x23, 0xfc, 0x3d, 0xef, 0xfa, 0xdb, 0xc1, 0x06, - 0x36, 0xf5, 0xb7, 0x37, 0xce, 0x5f, 0x27, 0x60, 0xba, 0x63, 0xb1, 0x31, 0x81, 0x7e, 0x00, 0xa3, - 0x15, 0xa9, 0x21, 0xc3, 0x7c, 0x35, 0x26, 0xcc, 0x1d, 0x88, 0x45, 0xf9, 0x43, 0xf3, 0x11, 0xce, - 0x2a, 0xbe, 0x47, 0x30, 0x22, 0xb1, 0x9d, 0x43, 0x35, 0xf0, 0x73, 0xf7, 0x43, 0xd5, 0x71, 0x72, - 0xda, 0x77, 0xb2, 0xb3, 0x4e, 0x6a, 0x56, 0xc9, 0x13, 0x79, 0x9e, 0xba, 0x1f, 0x8e, 0xe7, 0x25, - 0x4b, 0x79, 0x88, 0x7a, 0x9f, 0xea, 0xa7, 0x0a, 0xcc, 0x86, 0x77, 0xc7, 0x1b, 0x6d, 0x8b, 0x48, - 0x18, 0x93, 0x3d, 0xc3, 0x98, 0xea, 0x1b, 0x46, 0x05, 0x20, 0x60, 0x15, 0x13, 0xbf, 0x7f, 0x03, - 0xf8, 0x65, 0x9d, 0x17, 0xc1, 0x7c, 0xbf, 0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18, 0x00, - 0x00, + // 1730 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xbb, 0x6f, 0x1b, 0x47, + 0x1a, 0xf7, 0xf2, 0x21, 0x89, 0x9f, 0x44, 0x3d, 0x46, 0x94, 0xcd, 0xa3, 0x5e, 0xd4, 0xca, 0x92, + 0x69, 0xc8, 0x26, 0x2d, 0xf9, 0x71, 0x07, 0x1f, 0x0e, 0x3e, 0x49, 0xf0, 0x59, 0xbe, 0x33, 0x0e, + 0xca, 0xca, 0x49, 0x91, 0x86, 0x58, 0x2e, 0x47, 0xe4, 0x5a, 0xcb, 0x9d, 0x35, 0x77, 0x28, 0x58, + 0xea, 0x92, 0x22, 0x40, 0xea, 0x00, 0x49, 0xaa, 0x24, 0xad, 0x11, 0xa4, 0x4d, 0x63, 0x20, 0x09, + 0x52, 0xa5, 0x0c, 0x10, 0x20, 0xa5, 0x11, 0x18, 0x01, 0x5c, 0xa5, 0x88, 0xff, 0x82, 0x60, 0x67, + 0x66, 0x5f, 0xe4, 0x2e, 0x49, 0xc3, 0xaa, 0xdc, 0x71, 0xbf, 0xf9, 0xe6, 0xf7, 0xfd, 0xe6, 0x7b, + 0xcc, 0x7c, 0x33, 0x84, 0x35, 0xab, 0x4d, 0x28, 0xa9, 0x60, 0xda, 0xac, 0x1c, 0x6f, 0xaa, 0x86, + 0xd5, 0x54, 0x37, 0x2b, 0x35, 0xac, 0x6a, 0xc4, 0xac, 0x6a, 0x4d, 0x55, 0x37, 0xcb, 0x6c, 0x1c, + 0xcd, 0x61, 0xda, 0xc4, 0x6d, 0xdc, 0x69, 0x95, 0x31, 0x6d, 0x96, 0x5d, 0xcd, 0xc2, 0xd5, 0x86, + 0x4e, 0x9b, 0x9d, 0x5a, 0x59, 0x23, 0xad, 0x4a, 0x83, 0x34, 0x48, 0x85, 0x69, 0xd7, 0x3a, 0x87, + 0xec, 0x8b, 0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e, 0xdf, 0x61, 0xc5, 0xc1, 0xf3, 0x55, 0xcc, 0x38, 0x2b, 0x97, 0xff, 0x98, 0x84, 0xcc, + 0xae, 0xb3, 0x85, 0xec, 0x61, 0xb5, 0x8e, 0xae, 0x01, 0x74, 0x57, 0xcb, 0xce, 0xcc, 0xab, 0xe7, + 0xcb, 0x59, 0xdb, 0x3e, 0xbd, 0xea, 0x00, 0xdc, 0x96, 0xaf, 0x6f, 0xc9, 0x4a, 0xa6, 0xe6, 0x95, + 0xce, 0xa2, 0x3b, 0xc3, 0x0f, 0x86, 0x18, 0x3e, 0x70, 0xe2, 0xb1, 0x06, 0x93, 0x87, 0xba, 0xa9, + 0x1a, 0xfa, 0x29, 0xae, 0x73, 0x15, 0x16, 0x18, 0x25, 0xeb, 0x49, 0x99, 0xda, 0x2e, 0xe4, 0x7c, + 0xb5, 0x00, 0x83, 0x54, 0x1c, 0x03, 0xe4, 0xa9, 0xfb, 0x55, 0xbc, 0x06, 0x93, 0x8f, 0x3a, 0x36, + 0xd5, 0x0f, 0x75, 0xd7, 0x56, 0x9a, 0xdb, 0xf2, 0xa4, 0xae, 0x2d, 0x5f, 0x2d, 0x60, 0x6b, 0x24, + 0xd6, 0x96, 0xa7, 0xee, 0xdb, 0xba, 0x05, 0x17, 0xac, 0x36, 0x3e, 0xd6, 0x49, 0xc7, 0xae, 0x76, + 0x19, 0x1d, 0x65, 0x46, 0xe7, 0xdc, 0xe1, 0xff, 0x86, 0x8c, 0x3f, 0x84, 0xc5, 0x88, 0x79, 0x01, + 0x16, 0x63, 0x71, 0x2c, 0x0a, 0x3d, 0x80, 0x1e, 0x1b, 0xf9, 0xa5, 0x04, 0x73, 0x4e, 0x7a, 0xed, + 0x92, 0x56, 0x4b, 0xa7, 0x14, 0x63, 0xaf, 0x76, 0xbc, 0x7a, 0x90, 0xc2, 0xf5, 0x50, 0x80, 0xd1, + 0x06, 0x36, 0xb1, 0xad, 0xdb, 0x2c, 0x66, 0x63, 0x7b, 0xe7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6, 0x3b, 0x2c, 0x40, 0xe9, 0x99, 0x04, + 0x7f, 0x8b, 0x3d, 0x54, 0xd1, 0xdf, 0x87, 0x88, 0x70, 0xd4, 0x31, 0x5c, 0xb8, 0xf9, 0x7a, 0x87, + 0xda, 0x80, 0xdd, 0x35, 0xc0, 0x3d, 0x74, 0xfa, 0xed, 0xec, 0xfe, 0xf4, 0x62, 0x49, 0xfa, 0xf9, + 0xc5, 0x92, 0xf4, 0xdb, 0x8b, 0x25, 0xe9, 0xfd, 0x9b, 0x81, 0xbf, 0x2c, 0xac, 0xf6, 0x89, 0xdd, + 0x52, 0xa9, 0xae, 0x19, 0x6a, 0xcd, 0xe6, 0x5f, 0x95, 0xde, 0xbf, 0x06, 0xfe, 0x89, 0x69, 0xb3, + 0x36, 0xc2, 0xe4, 0xd7, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x25, 0xd4, 0x3e, 0x2e, 0x30, 0x19, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3386,14 +3404,19 @@ func (m *BeaconCommittees) MarshalTo(dAtA []byte) (int, error) { i += n } } + if m.ActiveValidatorCount != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.ActiveValidatorCount)) + } if len(m.NextPageToken) > 0 { - dAtA[i] = 0x1a + dAtA[i] = 0x22 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.NextPageToken))) i += copy(dAtA[i:], m.NextPageToken) } if m.TotalSize != 0 { - dAtA[i] = 0x20 + dAtA[i] = 0x28 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.TotalSize)) } @@ -3435,6 +3458,11 @@ func (m *BeaconCommittees_CommitteeItem) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintBeaconChain(dAtA, i, uint64(j6)) i += copy(dAtA[i:], dAtA7[:j6]) } + if m.Slot != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintBeaconChain(dAtA, i, uint64(m.Slot)) + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -4479,6 +4507,9 @@ func (m *BeaconCommittees) Size() (n int) { n += 1 + l + sovBeaconChain(uint64(l)) } } + if m.ActiveValidatorCount != 0 { + n += 1 + sovBeaconChain(uint64(m.ActiveValidatorCount)) + } l = len(m.NextPageToken) if l > 0 { n += 1 + l + sovBeaconChain(uint64(l)) @@ -4505,6 +4536,9 @@ func (m *BeaconCommittees_CommitteeItem) Size() (n int) { } n += 1 + sovBeaconChain(uint64(l)) + l } + if m.Slot != 0 { + n += 1 + sovBeaconChain(uint64(m.Slot)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -6303,6 +6337,25 @@ func (m *BeaconCommittees) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ActiveValidatorCount", wireType) + } + m.ActiveValidatorCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ActiveValidatorCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NextPageToken", wireType) } @@ -6334,7 +6387,7 @@ func (m *BeaconCommittees) Unmarshal(dAtA []byte) error { } m.NextPageToken = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TotalSize", wireType) } @@ -6483,6 +6536,25 @@ func (m *BeaconCommittees_CommitteeItem) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field Committee", wireType) } + case 2: + 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 ErrIntOverflowBeaconChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Slot |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipBeaconChain(dAtA[iNdEx:]) diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index 1a57ad50e0d7..adbac8e516d8 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -278,6 +278,9 @@ message BeaconCommittees { message CommitteeItem { // A committee of validator indices that need to attest to beacon blocks. repeated uint64 committee = 1; + + // The slot at which the committee is assigned to. + uint64 slot = 2; } // The epoch for which the committees in the response belong to. uint64 epoch = 1; @@ -285,12 +288,16 @@ message BeaconCommittees { // A list of committees of validators for given epoch. repeated CommitteeItem committees = 2; + + // The number of active validators at the given epoch. + uint64 active_validator_count = 3; + // A pagination token returned from a previous call // that indicates from where the listing should continue. - string next_page_token = 3; + string next_page_token = 4; // Total count of committees matching the request filter. - int32 total_size = 4; + int32 total_size = 5; } message GetValidatorBalancesRequest { From be31ef3c2fbd7efc50214c1a3d79f08b90514081 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 15:16:29 -0600 Subject: [PATCH 41/82] actually paginate --- beacon-chain/rpc/beacon_chain_server.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon_chain_server.go index df982e65c043..7cc523265011 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon_chain_server.go @@ -319,12 +319,18 @@ func (bs *BeaconChainServer) ListBeaconCommittees( }) } } + + numCommittees := len(committees) + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numCommittees) + if err != nil { + return nil, err + } return ðpb.BeaconCommittees{ Epoch: helpers.SlotToEpoch(startSlot), ActiveValidatorCount: uint64(len(activeIndices)), - Committees: committees, - NextPageToken: "", - TotalSize: int32(len(committees)), + Committees: committees[start:end], + TotalSize: int32(numCommittees), + NextPageToken: nextPageToken, }, nil } From 88893da786e9bd49a1f84f4c1fe723bdc687fcbc Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 15:42:09 -0600 Subject: [PATCH 42/82] attester server split into subpackage --- beacon-chain/rpc/BUILD.bazel | 66 +------------------ beacon-chain/rpc/attester/BUILD.bazel | 49 ++++++++++++++ .../rpc/{ => attester}/attester_server.go | 9 ++- .../{ => attester}/attester_server_test.go | 11 ++-- beacon-chain/rpc/beacon/BUILD.bazel | 48 ++++++++++++++ .../rpc/{ => beacon}/beacon_chain_server.go | 2 +- .../{ => beacon}/beacon_chain_server_test.go | 2 +- beacon-chain/rpc/node/BUILD.bazel | 35 ++++++++++ beacon-chain/rpc/{ => node}/node_server.go | 2 +- .../rpc/{ => node}/node_server_test.go | 2 +- beacon-chain/rpc/proposer/BUILD.bazel | 55 ++++++++++++++++ .../rpc/{ => proposer}/proposer_server.go | 2 +- .../{ => proposer}/proposer_server_test.go | 2 +- beacon-chain/rpc/validator/BUILD.bazel | 56 ++++++++++++++++ .../rpc/{ => validator}/validator_server.go | 2 +- .../{ => validator}/validator_server_test.go | 2 +- 16 files changed, 267 insertions(+), 78 deletions(-) create mode 100644 beacon-chain/rpc/attester/BUILD.bazel rename beacon-chain/rpc/{ => attester}/attester_server.go (97%) rename beacon-chain/rpc/{ => attester}/attester_server_test.go (96%) create mode 100644 beacon-chain/rpc/beacon/BUILD.bazel rename beacon-chain/rpc/{ => beacon}/beacon_chain_server.go (99%) rename beacon-chain/rpc/{ => beacon}/beacon_chain_server_test.go (99%) create mode 100644 beacon-chain/rpc/node/BUILD.bazel rename beacon-chain/rpc/{ => node}/node_server.go (99%) rename beacon-chain/rpc/{ => node}/node_server_test.go (99%) create mode 100644 beacon-chain/rpc/proposer/BUILD.bazel rename beacon-chain/rpc/{ => proposer}/proposer_server.go (99%) rename beacon-chain/rpc/{ => proposer}/proposer_server_test.go (99%) create mode 100644 beacon-chain/rpc/validator/BUILD.bazel rename beacon-chain/rpc/{ => validator}/validator_server.go (99%) rename beacon-chain/rpc/{ => validator}/validator_server_test.go (99%) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 9db6c567de72..b523a2fbc6e1 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -2,28 +2,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = [ - "attester_server.go", - "beacon_chain_server.go", - "node_server.go", - "proposer_server.go", - "service.go", - "validator_server.go", - ], + srcs = ["service.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc", visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", - "//beacon-chain/core/blocks:go_default_library", - "//beacon-chain/core/epoch:go_default_library", - "//beacon-chain/core/helpers:go_default_library", - "//beacon-chain/core/state:go_default_library", - "//beacon-chain/core/state/interop:go_default_library", - "//beacon-chain/core/validators:go_default_library", "//beacon-chain/db:go_default_library", - "//beacon-chain/db/filters:go_default_library", "//beacon-chain/operations:go_default_library", "//beacon-chain/p2p:go_default_library", "//beacon-chain/powchain:go_default_library", @@ -31,79 +17,31 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/bytesutil:go_default_library", - "//shared/hashutil:go_default_library", - "//shared/pagination:go_default_library", "//shared/params:go_default_library", "//shared/traceutil:go_default_library", - "//shared/trieutil:go_default_library", - "//shared/version:go_default_library", - "@com_github_gogo_protobuf//proto:go_default_library", - "@com_github_gogo_protobuf//types:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library", "@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library", - "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@io_opencensus_go//plugin/ocgrpc:go_default_library", - "@io_opencensus_go//trace:go_default_library", "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//credentials:go_default_library", "@org_golang_google_grpc//reflection:go_default_library", - "@org_golang_google_grpc//status:go_default_library", ], ) go_test( name = "go_default_test", size = "medium", - srcs = [ - "attester_server_test.go", - "beacon_chain_server_test.go", - "node_server_test.go", - "proposer_server_test.go", - "service_test.go", - "validator_server_test.go", - ], + srcs = ["service_test.go"], embed = [":go_default_library"], deps = [ "//beacon-chain/blockchain/testing:go_default_library", - "//beacon-chain/cache:go_default_library", - "//beacon-chain/cache/depositcache:go_default_library", - "//beacon-chain/core/blocks:go_default_library", - "//beacon-chain/core/helpers:go_default_library", - "//beacon-chain/core/state:go_default_library", - "//beacon-chain/db:go_default_library", - "//beacon-chain/db/testing:go_default_library", - "//beacon-chain/operations/testing:go_default_library", - "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/powchain/testing:go_default_library", - "//beacon-chain/rpc/testing:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/rpc/v1:go_default_library", - "//proto/eth/v1alpha1:go_default_library", - "//shared/bls:go_default_library", - "//shared/bytesutil:go_default_library", - "//shared/event:go_default_library", - "//shared/featureconfig:go_default_library", - "//shared/hashutil:go_default_library", - "//shared/params:go_default_library", "//shared/testutil:go_default_library", - "//shared/trieutil:go_default_library", - "//shared/version:go_default_library", - "@com_github_ethereum_go_ethereum//common: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", - "@com_github_prysmaticlabs_go_ssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//reflection:go_default_library", ], ) diff --git a/beacon-chain/rpc/attester/BUILD.bazel b/beacon-chain/rpc/attester/BUILD.bazel new file mode 100644 index 000000000000..2c1b76d67482 --- /dev/null +++ b/beacon-chain/rpc/attester/BUILD.bazel @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["attester_server.go"], + importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/blockchain:go_default_library", + "//beacon-chain/cache:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/state:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/operations:go_default_library", + "//beacon-chain/p2p:go_default_library", + "//beacon-chain/sync:go_default_library", + "//proto/beacon/rpc/v1:go_default_library", + "//proto/eth/v1alpha1: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", + "@com_github_sirupsen_logrus//:go_default_library", + "@io_opencensus_go//trace:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["attester_server_test.go"], + embed = [":go_default_library"], + deps = [ + "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/cache:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/db/testing:go_default_library", + "//beacon-chain/operations/testing:go_default_library", + "//beacon-chain/p2p/testing:go_default_library", + "//beacon-chain/sync/initial-sync/testing:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/beacon/rpc/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/featureconfig:go_default_library", + "//shared/params:go_default_library", + "@com_github_gogo_protobuf//proto:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", + ], +) diff --git a/beacon-chain/rpc/attester_server.go b/beacon-chain/rpc/attester/attester_server.go similarity index 97% rename from beacon-chain/rpc/attester_server.go rename to beacon-chain/rpc/attester/attester_server.go index 344a406bda2d..a61e5252ae9e 100644 --- a/beacon-chain/rpc/attester_server.go +++ b/beacon-chain/rpc/attester/attester_server.go @@ -1,4 +1,4 @@ -package rpc +package attester import ( "context" @@ -16,11 +16,18 @@ 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/sirupsen/logrus" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) +var log logrus.FieldLogger + +func init() { + log = logrus.WithField("prefix", "rpc/attester") +} + // AttesterServer defines a server implementation of the gRPC Attester service, // providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks. type AttesterServer struct { diff --git a/beacon-chain/rpc/attester_server_test.go b/beacon-chain/rpc/attester/attester_server_test.go similarity index 96% rename from beacon-chain/rpc/attester_server_test.go rename to beacon-chain/rpc/attester/attester_server_test.go index dc61b2900ae6..e03eae9a9491 100644 --- a/beacon-chain/rpc/attester_server_test.go +++ b/beacon-chain/rpc/attester/attester_server_test.go @@ -1,4 +1,4 @@ -package rpc +package attester import ( "context" @@ -14,6 +14,7 @@ import ( dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" mockOps "github.com/prysmaticlabs/prysm/beacon-chain/operations/testing" mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" + mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" 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" @@ -115,7 +116,7 @@ func TestRequestAttestation_OK(t *testing.T) { beaconState.BlockRoots[2*params.BeaconConfig().SlotsPerEpoch] = justifiedRoot[:] attesterServer := &AttesterServer{ p2p: &mockp2p.MockBroadcaster{}, - syncChecker: &mockSyncChecker{false}, + syncChecker: &mockSync.Sync{IsSyncing: false}, attestationCache: cache.NewAttestationCache(), headFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, attReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, @@ -149,7 +150,7 @@ func TestRequestAttestation_OK(t *testing.T) { func TestRequestAttestation_SyncNotReady(t *testing.T) { as := &AttesterServer{ - syncChecker: &mockSyncChecker{syncing: true}, + syncChecker: &mockSync.Sync{IsSyncing: true}, } _, err := as.RequestAttestation(context.Background(), &pb.AttestationRequest{}) if strings.Contains(err.Error(), "syncing to latest head") { @@ -211,7 +212,7 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { attestationCache: cache.NewAttestationCache(), headFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, attReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, - syncChecker: &mockSyncChecker{false}, + syncChecker: &mockSync.Sync{IsSyncing: false}, } req := &pb.AttestationRequest{ @@ -252,7 +253,7 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { ctx := context.Background() server := &AttesterServer{ attestationCache: cache.NewAttestationCache(), - syncChecker: &mockSyncChecker{false}, + syncChecker: &mockSync.Sync{IsSyncing: false}, } req := &pb.AttestationRequest{ diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel new file mode 100644 index 000000000000..ce7c90cf3bc1 --- /dev/null +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -0,0 +1,48 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["beacon_chain_server.go"], + importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/blockchain:go_default_library", + "//beacon-chain/core/epoch:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/validators:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/db/filters:go_default_library", + "//beacon-chain/operations:go_default_library", + "//beacon-chain/powchain:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/bytesutil:go_default_library", + "//shared/hashutil:go_default_library", + "//shared/pagination:go_default_library", + "//shared/params:go_default_library", + "@com_github_gogo_protobuf//types:go_default_library", + "@com_github_pkg_errors//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["beacon_chain_server_test.go"], + embed = [":go_default_library"], + deps = [ + "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/db/testing:go_default_library", + "//beacon-chain/operations/testing:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/params:go_default_library", + "@com_github_gogo_protobuf//proto:go_default_library", + "@com_github_gogo_protobuf//types:go_default_library", + "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", + ], +) diff --git a/beacon-chain/rpc/beacon_chain_server.go b/beacon-chain/rpc/beacon/beacon_chain_server.go similarity index 99% rename from beacon-chain/rpc/beacon_chain_server.go rename to beacon-chain/rpc/beacon/beacon_chain_server.go index bc3b136dc484..f8ad7e1749d3 100644 --- a/beacon-chain/rpc/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server.go @@ -1,4 +1,4 @@ -package rpc +package beacon import ( "context" diff --git a/beacon-chain/rpc/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go similarity index 99% rename from beacon-chain/rpc/beacon_chain_server_test.go rename to beacon-chain/rpc/beacon/beacon_chain_server_test.go index 7f25a4d4a683..410f54ebe90e 100644 --- a/beacon-chain/rpc/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server_test.go @@ -1,4 +1,4 @@ -package rpc +package beacon import ( "bytes" diff --git a/beacon-chain/rpc/node/BUILD.bazel b/beacon-chain/rpc/node/BUILD.bazel new file mode 100644 index 000000000000..863b5049963a --- /dev/null +++ b/beacon-chain/rpc/node/BUILD.bazel @@ -0,0 +1,35 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["node_server.go"], + importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/blockchain:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/sync:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/version:go_default_library", + "@com_github_gogo_protobuf//types:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["node_server_test.go"], + embed = [":go_default_library"], + deps = [ + "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/db/testing:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/version:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_gogo_protobuf//types:go_default_library", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//reflection:go_default_library", + ], +) diff --git a/beacon-chain/rpc/node_server.go b/beacon-chain/rpc/node/node_server.go similarity index 99% rename from beacon-chain/rpc/node_server.go rename to beacon-chain/rpc/node/node_server.go index a98626c7b688..38c8bdc3a367 100644 --- a/beacon-chain/rpc/node_server.go +++ b/beacon-chain/rpc/node/node_server.go @@ -1,4 +1,4 @@ -package rpc +package node import ( "context" diff --git a/beacon-chain/rpc/node_server_test.go b/beacon-chain/rpc/node/node_server_test.go similarity index 99% rename from beacon-chain/rpc/node_server_test.go rename to beacon-chain/rpc/node/node_server_test.go index 2f42efc40d36..38fce023190a 100644 --- a/beacon-chain/rpc/node_server_test.go +++ b/beacon-chain/rpc/node/node_server_test.go @@ -1,4 +1,4 @@ -package rpc +package node import ( "bytes" diff --git a/beacon-chain/rpc/proposer/BUILD.bazel b/beacon-chain/rpc/proposer/BUILD.bazel new file mode 100644 index 000000000000..13659d8dfafb --- /dev/null +++ b/beacon-chain/rpc/proposer/BUILD.bazel @@ -0,0 +1,55 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["proposer_server.go"], + importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/blockchain:go_default_library", + "//beacon-chain/cache/depositcache:go_default_library", + "//beacon-chain/core/blocks:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/state:go_default_library", + "//beacon-chain/core/state/interop:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/operations:go_default_library", + "//beacon-chain/powchain:go_default_library", + "//beacon-chain/sync:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/beacon/rpc/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/bytesutil:go_default_library", + "//shared/hashutil:go_default_library", + "//shared/params:go_default_library", + "//shared/trieutil:go_default_library", + "@com_github_pkg_errors//:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", + "@io_opencensus_go//trace:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["proposer_server_test.go"], + embed = [":go_default_library"], + deps = [ + "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/cache/depositcache:go_default_library", + "//beacon-chain/core/blocks:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/state:go_default_library", + "//beacon-chain/db/testing:go_default_library", + "//beacon-chain/powchain/testing:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/hashutil:go_default_library", + "//shared/params:go_default_library", + "//shared/testutil:go_default_library", + "//shared/trieutil:go_default_library", + "@com_github_gogo_protobuf//proto:go_default_library", + "@com_github_prysmaticlabs_go_ssz//:go_default_library", + ], +) diff --git a/beacon-chain/rpc/proposer_server.go b/beacon-chain/rpc/proposer/proposer_server.go similarity index 99% rename from beacon-chain/rpc/proposer_server.go rename to beacon-chain/rpc/proposer/proposer_server.go index 2a38c6f63b79..060ba413552a 100644 --- a/beacon-chain/rpc/proposer_server.go +++ b/beacon-chain/rpc/proposer/proposer_server.go @@ -1,4 +1,4 @@ -package rpc +package proposer import ( "context" diff --git a/beacon-chain/rpc/proposer_server_test.go b/beacon-chain/rpc/proposer/proposer_server_test.go similarity index 99% rename from beacon-chain/rpc/proposer_server_test.go rename to beacon-chain/rpc/proposer/proposer_server_test.go index dca74ca14680..59ad1d39f72b 100644 --- a/beacon-chain/rpc/proposer_server_test.go +++ b/beacon-chain/rpc/proposer/proposer_server_test.go @@ -1,4 +1,4 @@ -package rpc +package proposer import ( "context" diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel new file mode 100644 index 000000000000..fc8713bf7b93 --- /dev/null +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -0,0 +1,56 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["validator_server.go"], + importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator", + visibility = ["//visibility:public"], + deps = [ + "//beacon-chain/blockchain:go_default_library", + "//beacon-chain/cache/depositcache:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/state:go_default_library", + "//beacon-chain/db:go_default_library", + "//beacon-chain/powchain:go_default_library", + "//beacon-chain/sync:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/beacon/rpc/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/bytesutil:go_default_library", + "//shared/params:go_default_library", + "@com_github_gogo_protobuf//types:go_default_library", + "@com_github_pkg_errors//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["validator_server_test.go"], + embed = [":go_default_library"], + deps = [ + "//beacon-chain/blockchain/testing:go_default_library", + "//beacon-chain/cache/depositcache:go_default_library", + "//beacon-chain/core/blocks:go_default_library", + "//beacon-chain/core/helpers:go_default_library", + "//beacon-chain/core/state:go_default_library", + "//beacon-chain/db/testing:go_default_library", + "//beacon-chain/powchain/testing:go_default_library", + "//beacon-chain/rpc/testing:go_default_library", + "//proto/beacon/p2p/v1:go_default_library", + "//proto/beacon/rpc/v1:go_default_library", + "//proto/eth/v1alpha1:go_default_library", + "//shared/bls:go_default_library", + "//shared/bytesutil:go_default_library", + "//shared/event:go_default_library", + "//shared/params:go_default_library", + "//shared/testutil:go_default_library", + "//shared/trieutil: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_ssz//:go_default_library", + "@com_github_sirupsen_logrus//hooks/test:go_default_library", + ], +) diff --git a/beacon-chain/rpc/validator_server.go b/beacon-chain/rpc/validator/validator_server.go similarity index 99% rename from beacon-chain/rpc/validator_server.go rename to beacon-chain/rpc/validator/validator_server.go index fd25536a5cad..3981fb63d798 100644 --- a/beacon-chain/rpc/validator_server.go +++ b/beacon-chain/rpc/validator/validator_server.go @@ -1,4 +1,4 @@ -package rpc +package validator import ( "context" diff --git a/beacon-chain/rpc/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go similarity index 99% rename from beacon-chain/rpc/validator_server_test.go rename to beacon-chain/rpc/validator/validator_server_test.go index a44721d08aa3..d215ea9be535 100644 --- a/beacon-chain/rpc/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -1,4 +1,4 @@ -package rpc +package validator import ( "context" From 780a1307979f48039d79229f3a6595f165ba75e8 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 15:45:16 -0600 Subject: [PATCH 43/82] attester impl split up successfully --- beacon-chain/rpc/BUILD.bazel | 1 + beacon-chain/rpc/attester/attester_server.go | 36 +++++++-------- .../rpc/attester/attester_server_test.go | 44 +++++++++---------- beacon-chain/rpc/service.go | 17 +++---- 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index b523a2fbc6e1..a01cfc29585f 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -13,6 +13,7 @@ go_library( "//beacon-chain/operations:go_default_library", "//beacon-chain/p2p:go_default_library", "//beacon-chain/powchain:go_default_library", + "//beacon-chain/rpc/attester:go_default_library", "//beacon-chain/sync:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", diff --git a/beacon-chain/rpc/attester/attester_server.go b/beacon-chain/rpc/attester/attester_server.go index a61e5252ae9e..6e21a3d60aaf 100644 --- a/beacon-chain/rpc/attester/attester_server.go +++ b/beacon-chain/rpc/attester/attester_server.go @@ -31,13 +31,13 @@ func init() { // AttesterServer defines a server implementation of the gRPC Attester service, // providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks. type AttesterServer struct { - p2p p2p.Broadcaster - beaconDB db.Database - operationsHandler operations.Handler - attReceiver blockchain.AttestationReceiver - headFetcher blockchain.HeadFetcher - attestationCache *cache.AttestationCache - syncChecker sync.Checker + P2p p2p.Broadcaster + BeaconDB db.Database + OperationsHandler operations.Handler + AttReceiver blockchain.AttestationReceiver + HeadFetcher blockchain.HeadFetcher + AttestationCache *cache.AttestationCache + SyncChecker sync.Checker } // SubmitAttestation is a function called by an attester in a sharding validator to vote @@ -51,11 +51,11 @@ func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Atte go func() { ctx = trace.NewContext(context.Background(), trace.FromContext(ctx)) attCopy := proto.Clone(att).(*ethpb.Attestation) - if err := as.attReceiver.ReceiveAttestation(ctx, att); err != nil { + if err := as.AttReceiver.ReceiveAttestation(ctx, att); err != nil { log.WithError(err).Error("could not receive attestation in chain service") return } - if err := as.operationsHandler.HandleAttestation(ctx, attCopy); err != nil { + if err := as.OperationsHandler.HandleAttestation(ctx, attCopy); err != nil { log.WithError(err).Error("could not handle attestation in operations service") return } @@ -74,11 +74,11 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest trace.Int64Attribute("committeeIndex", int64(req.CommitteeIndex)), ) - if as.syncChecker.Syncing() { + if as.SyncChecker.Syncing() { return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") } - res, err := as.attestationCache.Get(ctx, req) + res, err := as.AttestationCache.Get(ctx, req) if err != nil { return nil, err } @@ -87,9 +87,9 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest return res, nil } - if err := as.attestationCache.MarkInProgress(req); err != nil { + if err := as.AttestationCache.MarkInProgress(req); err != nil { if err == cache.ErrAlreadyInProgress { - res, err := as.attestationCache.Get(ctx, req) + res, err := as.AttestationCache.Get(ctx, req) if err != nil { return nil, err } @@ -102,17 +102,17 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest return nil, err } defer func() { - if err := as.attestationCache.MarkNotInProgress(req); err != nil { + if err := as.AttestationCache.MarkNotInProgress(req); err != nil { log.WithError(err).Error("Failed to mark cache not in progress") } }() - headState := as.headFetcher.HeadState() - headRoot := as.headFetcher.HeadRoot() + 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) + headState, err = as.BeaconDB.HeadState(ctx) if err != nil { return nil, err } @@ -146,7 +146,7 @@ func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.Attest }, } - if err := as.attestationCache.Put(ctx, req, res); err != nil { + if err := as.AttestationCache.Put(ctx, req, res); err != nil { return nil, err } diff --git a/beacon-chain/rpc/attester/attester_server_test.go b/beacon-chain/rpc/attester/attester_server_test.go index e03eae9a9491..a40cf160b986 100644 --- a/beacon-chain/rpc/attester/attester_server_test.go +++ b/beacon-chain/rpc/attester/attester_server_test.go @@ -28,12 +28,12 @@ func TestSubmitAttestation_OK(t *testing.T) { ctx := context.Background() attesterServer := &AttesterServer{ - headFetcher: &mock.ChainService{}, - attReceiver: &mock.ChainService{}, - operationsHandler: &mockOps.Operations{}, - p2p: &mockp2p.MockBroadcaster{}, - beaconDB: db, - attestationCache: cache.NewAttestationCache(), + HeadFetcher: &mock.ChainService{}, + AttReceiver: &mock.ChainService{}, + OperationsHandler: &mockOps.Operations{}, + P2p: &mockp2p.MockBroadcaster{}, + BeaconDB: db, + AttestationCache: cache.NewAttestationCache(), } head := ðpb.BeaconBlock{ Slot: 999, @@ -115,11 +115,11 @@ func TestRequestAttestation_OK(t *testing.T) { beaconState.BlockRoots[1*params.BeaconConfig().SlotsPerEpoch] = targetRoot[:] beaconState.BlockRoots[2*params.BeaconConfig().SlotsPerEpoch] = justifiedRoot[:] attesterServer := &AttesterServer{ - p2p: &mockp2p.MockBroadcaster{}, - syncChecker: &mockSync.Sync{IsSyncing: false}, - attestationCache: cache.NewAttestationCache(), - headFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, - attReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, + P2p: &mockp2p.MockBroadcaster{}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + AttestationCache: cache.NewAttestationCache(), + HeadFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, + AttReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, } req := &pb.AttestationRequest{ @@ -150,7 +150,7 @@ func TestRequestAttestation_OK(t *testing.T) { func TestRequestAttestation_SyncNotReady(t *testing.T) { as := &AttesterServer{ - syncChecker: &mockSync.Sync{IsSyncing: true}, + SyncChecker: &mockSync.Sync{IsSyncing: true}, } _, err := as.RequestAttestation(context.Background(), &pb.AttestationRequest{}) if strings.Contains(err.Error(), "syncing to latest head") { @@ -208,11 +208,11 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { beaconState.BlockRoots[1*params.BeaconConfig().SlotsPerEpoch] = epochBoundaryRoot[:] beaconState.BlockRoots[2*params.BeaconConfig().SlotsPerEpoch] = justifiedBlockRoot[:] attesterServer := &AttesterServer{ - p2p: &mockp2p.MockBroadcaster{}, - attestationCache: cache.NewAttestationCache(), - headFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, - attReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, - syncChecker: &mockSync.Sync{IsSyncing: false}, + P2p: &mockp2p.MockBroadcaster{}, + AttestationCache: cache.NewAttestationCache(), + HeadFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, + AttReceiver: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } req := &pb.AttestationRequest{ @@ -252,8 +252,8 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { ctx := context.Background() server := &AttesterServer{ - attestationCache: cache.NewAttestationCache(), - syncChecker: &mockSync.Sync{IsSyncing: false}, + AttestationCache: cache.NewAttestationCache(), + SyncChecker: &mockSync.Sync{IsSyncing: false}, } req := &pb.AttestationRequest{ @@ -265,7 +265,7 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { Target: ðpb.Checkpoint{Epoch: 55}, } - if err := server.attestationCache.MarkInProgress(req); err != nil { + if err := server.AttestationCache.MarkInProgress(req); err != nil { t.Fatal(err) } @@ -287,10 +287,10 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { go func() { defer wg.Done() - if err := server.attestationCache.Put(ctx, req, res); err != nil { + if err := server.AttestationCache.Put(ctx, req, res); err != nil { t.Error(err) } - if err := server.attestationCache.MarkNotInProgress(req); err != nil { + if err := server.AttestationCache.MarkNotInProgress(req); err != nil { t.Error(err) } }() diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index 8a46dd1fc51b..6444d63dbaaa 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -18,6 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" + att "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" "github.com/prysmaticlabs/prysm/beacon-chain/sync" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" @@ -178,14 +179,14 @@ func (s *Service) Start() { pendingDepositsFetcher: s.pendingDepositFetcher, syncChecker: s.syncService, } - attesterServer := &AttesterServer{ - p2p: s.p2p, - beaconDB: s.beaconDB, - operationsHandler: s.operationsHandler, - attReceiver: s.attestationReceiver, - headFetcher: s.headFetcher, - attestationCache: cache.NewAttestationCache(), - syncChecker: s.syncService, + attesterServer := &att.AttesterServer{ + P2p: s.p2p, + BeaconDB: s.beaconDB, + OperationsHandler: s.operationsHandler, + AttReceiver: s.attestationReceiver, + HeadFetcher: s.headFetcher, + AttestationCache: cache.NewAttestationCache(), + SyncChecker: s.syncService, } validatorServer := &ValidatorServer{ ctx: s.ctx, From 47d0b969b907cd534ffbc3ecae335ce0e5d34929 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 16:03:22 -0600 Subject: [PATCH 44/82] validator cleaned up --- beacon-chain/rpc/BUILD.bazel | 1 + beacon-chain/rpc/node/BUILD.bazel | 1 + beacon-chain/rpc/node/node_server.go | 16 +- beacon-chain/rpc/node/node_server_test.go | 33 +-- beacon-chain/rpc/proposer/BUILD.bazel | 1 + beacon-chain/rpc/proposer/proposer_server.go | 67 +++--- .../rpc/proposer/proposer_server_test.go | 164 +++++++------- beacon-chain/rpc/service.go | 38 ++-- beacon-chain/rpc/validator/BUILD.bazel | 2 + .../rpc/validator/validator_server.go | 76 ++++--- .../rpc/validator/validator_server_test.go | 203 +++++++++--------- 11 files changed, 306 insertions(+), 296 deletions(-) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index a01cfc29585f..5fdc9031671c 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -14,6 +14,7 @@ go_library( "//beacon-chain/p2p:go_default_library", "//beacon-chain/powchain:go_default_library", "//beacon-chain/rpc/attester:go_default_library", + "//beacon-chain/rpc/node:go_default_library", "//beacon-chain/sync:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", diff --git a/beacon-chain/rpc/node/BUILD.bazel b/beacon-chain/rpc/node/BUILD.bazel index 863b5049963a..d131217dfd4f 100644 --- a/beacon-chain/rpc/node/BUILD.bazel +++ b/beacon-chain/rpc/node/BUILD.bazel @@ -25,6 +25,7 @@ go_test( deps = [ "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/db/testing:go_default_library", + "//beacon-chain/sync/initial-sync/testing:go_default_library", "//proto/eth/v1alpha1:go_default_library", "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", diff --git a/beacon-chain/rpc/node/node_server.go b/beacon-chain/rpc/node/node_server.go index 38c8bdc3a367..13965dc77447 100644 --- a/beacon-chain/rpc/node/node_server.go +++ b/beacon-chain/rpc/node/node_server.go @@ -19,26 +19,26 @@ import ( // providing RPC endpoints for verifying a beacon node's sync status, genesis and // version information, and services the node implements and runs. type NodeServer struct { - syncChecker sync.Checker - server *grpc.Server - beaconDB db.Database - genesisTimeFetcher blockchain.GenesisTimeFetcher + SyncChecker sync.Checker + Server *grpc.Server + BeaconDB db.Database + GenesisTimeFetcher blockchain.GenesisTimeFetcher } // GetSyncStatus checks the current network sync status of the node. func (ns *NodeServer) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncStatus, error) { return ðpb.SyncStatus{ - Syncing: ns.syncChecker.Syncing(), + Syncing: ns.SyncChecker.Syncing(), }, nil } // GetGenesis fetches genesis chain information of Ethereum 2.0. func (ns *NodeServer) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genesis, error) { - contractAddr, err := ns.beaconDB.DepositContractAddress(ctx) + contractAddr, err := ns.BeaconDB.DepositContractAddress(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve contract address from db: %v", err) } - genesisTime := ns.genesisTimeFetcher.GenesisTime() + genesisTime := ns.GenesisTimeFetcher.GenesisTime() gt, err := ptypes.TimestampProto(genesisTime) if err != nil { return nil, status.Errorf(codes.Internal, "could not convert genesis time to proto: %v", err) @@ -62,7 +62,7 @@ func (ns *NodeServer) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.V // PERMISSION_DENIED. The server may also support fetching services by grpc // reflection. func (ns *NodeServer) ListImplementedServices(ctx context.Context, _ *ptypes.Empty) (*ethpb.ImplementedServices, error) { - serviceInfo := ns.server.GetServiceInfo() + serviceInfo := ns.Server.GetServiceInfo() serviceNames := make([]string, 0, len(serviceInfo)) for svc := range serviceInfo { serviceNames = append(serviceNames, svc) diff --git a/beacon-chain/rpc/node/node_server_test.go b/beacon-chain/rpc/node/node_server_test.go index 38fce023190a..34955cc1c89a 100644 --- a/beacon-chain/rpc/node/node_server_test.go +++ b/beacon-chain/rpc/node/node_server_test.go @@ -10,43 +10,32 @@ import ( ptypes "github.com/gogo/protobuf/types" mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/version" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) -type mockSyncChecker struct { - syncing bool -} - -func (m *mockSyncChecker) Syncing() bool { - return m.syncing -} - -func (m *mockSyncChecker) Status() error { - return nil -} - func TestNodeServer_GetSyncStatus(t *testing.T) { - mSync := &mockSyncChecker{false} + mSync := &mockSync.Sync{IsSyncing: false} ns := &NodeServer{ - syncChecker: mSync, + SyncChecker: mSync, } res, err := ns.GetSyncStatus(context.Background(), &ptypes.Empty{}) if err != nil { t.Fatal(err) } - if res.Syncing != mSync.syncing { - t.Errorf("Wanted GetSyncStatus() = %v, received %v", mSync.syncing, res.Syncing) + if !res.Syncing { + t.Errorf("Wanted GetSyncStatus() = %v, received %v", false, res.Syncing) } - mSync.syncing = true + ns.SyncChecker = &mockSync.Sync{IsSyncing: true} res, err = ns.GetSyncStatus(context.Background(), &ptypes.Empty{}) if err != nil { t.Fatal(err) } - if res.Syncing != mSync.syncing { - t.Errorf("Wanted GetSyncStatus() = %v, received %v", mSync.syncing, res.Syncing) + if res.Syncing { + t.Errorf("Wanted GetSyncStatus() = %v, received %v", true, res.Syncing) } } @@ -59,8 +48,8 @@ func TestNodeServer_GetGenesis(t *testing.T) { t.Fatal(err) } ns := &NodeServer{ - beaconDB: db, - genesisTimeFetcher: &mock.ChainService{Genesis: time.Unix(0, 0)}, + BeaconDB: db, + GenesisTimeFetcher: &mock.ChainService{Genesis: time.Unix(0, 0)}, } res, err := ns.GetGenesis(context.Background(), &ptypes.Empty{}) if err != nil { @@ -93,7 +82,7 @@ func TestNodeServer_GetVersion(t *testing.T) { func TestNodeServer_GetImplementedServices(t *testing.T) { server := grpc.NewServer() ns := &NodeServer{ - server: server, + Server: server, } ethpb.RegisterNodeServer(server, ns) reflection.Register(server) diff --git a/beacon-chain/rpc/proposer/BUILD.bazel b/beacon-chain/rpc/proposer/BUILD.bazel index 13659d8dfafb..db471e6a0190 100644 --- a/beacon-chain/rpc/proposer/BUILD.bazel +++ b/beacon-chain/rpc/proposer/BUILD.bazel @@ -25,6 +25,7 @@ go_library( "//shared/trieutil:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@io_opencensus_go//trace:go_default_library", "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//status:go_default_library", diff --git a/beacon-chain/rpc/proposer/proposer_server.go b/beacon-chain/rpc/proposer/proposer_server.go index 060ba413552a..72a57dfe1785 100644 --- a/beacon-chain/rpc/proposer/proposer_server.go +++ b/beacon-chain/rpc/proposer/proposer_server.go @@ -24,27 +24,34 @@ import ( "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/trieutil" + "github.com/sirupsen/logrus" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) +var log logrus.FieldLogger + +func init() { + log = logrus.WithField("prefix", "rpc/proposer") +} + // ProposerServer defines a server implementation of the gRPC Proposer service, // providing RPC endpoints for computing state transitions and state roots, proposing // beacon blocks to a beacon node, and more. type ProposerServer struct { - beaconDB db.Database - headFetcher blockchain.HeadFetcher - blockReceiver blockchain.BlockReceiver - mockEth1Votes bool - chainStartFetcher powchain.ChainStartFetcher - eth1InfoFetcher powchain.ChainInfoFetcher - eth1BlockFetcher powchain.POWBlockFetcher - pool operations.Pool - canonicalStateChan chan *pbp2p.BeaconState - depositFetcher depositcache.DepositFetcher - pendingDepositsFetcher depositcache.PendingDepositsFetcher - syncChecker sync.Checker + BeaconDB db.Database + HeadFetcher blockchain.HeadFetcher + BlockReceiver blockchain.BlockReceiver + MockEth1Votes bool + ChainStartFetcher powchain.ChainStartFetcher + Eth1InfoFetcher powchain.ChainInfoFetcher + Eth1BlockFetcher powchain.POWBlockFetcher + Pool operations.Pool + CanonicalStateChan chan *pbp2p.BeaconState + DepositFetcher depositcache.DepositFetcher + PendingDepositsFetcher depositcache.PendingDepositsFetcher + SyncChecker sync.Checker } // RequestBlock is called by a proposer during its assigned slot to request a block to sign @@ -54,12 +61,12 @@ func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest defer span.End() span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot))) - if ps.syncChecker.Syncing() { + if ps.SyncChecker.Syncing() { return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") } // Retrieve the parent block as the current head of the canonical chain - parent := ps.headFetcher.HeadBlock() + parent := ps.HeadFetcher.HeadBlock() parentRoot, err := ssz.SigningRoot(parent) if err != nil { @@ -78,7 +85,7 @@ func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest } // Pack aggregated attestations which have not been included in the beacon chain. - atts, err := ps.pool.AttestationPool(ctx, req.Slot) + atts, err := ps.Pool.AttestationPool(ctx, req.Slot) if err != nil { return nil, errors.Wrap(err, "could not get pending attestations") } @@ -126,7 +133,7 @@ func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlo } log.WithField("blockRoot", fmt.Sprintf("%#x", bytesutil.Trunc(root[:]))).Debugf( "Block proposal received via RPC") - if err := ps.blockReceiver.ReceiveBlock(ctx, blk); err != nil { + if err := ps.BlockReceiver.ReceiveBlock(ctx, blk); err != nil { return nil, errors.Wrap(err, "could not process beacon block") } @@ -140,15 +147,15 @@ func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlo // - Subtract that eth1block.number by ETH1_FOLLOW_DISTANCE. // - This is the eth1block to use for the block proposal. func (ps *ProposerServer) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth1Data, error) { - if ps.mockEth1Votes || !ps.eth1InfoFetcher.IsConnectedToETH1() { + if ps.MockEth1Votes || !ps.Eth1InfoFetcher.IsConnectedToETH1() { return ps.mockETH1DataVote(slot) } - eth1VotingPeriodStartTime, _ := ps.eth1InfoFetcher.Eth2GenesisPowchainInfo() + eth1VotingPeriodStartTime, _ := ps.Eth1InfoFetcher.Eth2GenesisPowchainInfo() eth1VotingPeriodStartTime += (slot - (slot % params.BeaconConfig().SlotsPerEth1VotingPeriod)) * params.BeaconConfig().SecondsPerSlot // Look up most recent block up to timestamp - blockNumber, err := ps.eth1BlockFetcher.BlockNumberByTimestamp(ctx, eth1VotingPeriodStartTime) + blockNumber, err := ps.Eth1BlockFetcher.BlockNumberByTimestamp(ctx, eth1VotingPeriodStartTime) if err != nil { return nil, errors.Wrap(err, "could not get block number from timestamp") } @@ -169,7 +176,7 @@ func (ps *ProposerServer) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), // ) slotInVotingPeriod := slot % params.BeaconConfig().SlotsPerEth1VotingPeriod - headState := ps.headFetcher.HeadState() + headState := ps.HeadFetcher.HeadState() enc, err := ssz.Marshal(helpers.SlotToEpoch(slot) + slotInVotingPeriod) if err != nil { return nil, err @@ -186,7 +193,7 @@ func (ps *ProposerServer) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) // computeStateRoot computes the state root after a block has been processed through a state transition and // returns it to the validator client. func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.BeaconBlock) ([]byte, error) { - beaconState, err := ps.beaconDB.HeadState(ctx) + beaconState, err := ps.BeaconDB.HeadState(ctx) if err != nil { return nil, errors.Wrap(err, "could not retrieve beacon state") } @@ -210,23 +217,23 @@ func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.Bea // enough support, then use that vote for basis of determining deposits, otherwise use current state // eth1data. func (ps *ProposerServer) deposits(ctx context.Context, currentVote *ethpb.Eth1Data) ([]*ethpb.Deposit, error) { - if ps.mockEth1Votes || !ps.eth1InfoFetcher.IsConnectedToETH1() { + if ps.MockEth1Votes || !ps.Eth1InfoFetcher.IsConnectedToETH1() { return []*ethpb.Deposit{}, nil } // Need to fetch if the deposits up to the state's latest eth 1 data matches // the number of all deposits in this RPC call. If not, then we return nil. - beaconState := ps.headFetcher.HeadState() + beaconState := ps.HeadFetcher.HeadState() canonicalEth1Data, latestEth1DataHeight, err := ps.canonicalEth1Data(ctx, beaconState, currentVote) if err != nil { return nil, err } - _, genesisEth1Block := ps.eth1InfoFetcher.Eth2GenesisPowchainInfo() + _, genesisEth1Block := ps.Eth1InfoFetcher.Eth2GenesisPowchainInfo() if genesisEth1Block.Cmp(latestEth1DataHeight) == 0 { return []*ethpb.Deposit{}, nil } - upToEth1DataDeposits := ps.depositFetcher.AllDeposits(ctx, latestEth1DataHeight) + upToEth1DataDeposits := ps.DepositFetcher.AllDeposits(ctx, latestEth1DataHeight) depositData := [][]byte{} for _, dep := range upToEth1DataDeposits { depHash, err := ssz.HashTreeRoot(dep.Data) @@ -241,7 +248,7 @@ func (ps *ProposerServer) deposits(ctx context.Context, currentVote *ethpb.Eth1D return nil, errors.Wrap(err, "could not generate historical deposit trie from deposits") } - allPendingContainers := ps.pendingDepositsFetcher.PendingContainers(ctx, latestEth1DataHeight) + allPendingContainers := ps.PendingDepositsFetcher.PendingContainers(ctx, latestEth1DataHeight) // Deposits need to be received in order of merkle index root, so this has to make sure // deposits are sorted from lowest to highest. @@ -288,7 +295,7 @@ func (ps *ProposerServer) canonicalEth1Data(ctx context.Context, beaconState *pb canonicalEth1Data = beaconState.Eth1Data eth1BlockHash = bytesutil.ToBytes32(beaconState.Eth1Data.BlockHash) } - _, latestEth1DataHeight, err := ps.eth1BlockFetcher.BlockExists(ctx, eth1BlockHash) + _, latestEth1DataHeight, err := ps.Eth1BlockFetcher.BlockExists(ctx, eth1BlockHash) if err != nil { return nil, nil, errors.Wrap(err, "could not fetch eth1data height") } @@ -302,14 +309,14 @@ func (ps *ProposerServer) canonicalEth1Data(ctx context.Context, beaconState *pb func (ps *ProposerServer) defaultEth1DataResponse(ctx context.Context, currentHeight *big.Int) (*ethpb.Eth1Data, error) { eth1FollowDistance := int64(params.BeaconConfig().Eth1FollowDistance) ancestorHeight := big.NewInt(0).Sub(currentHeight, big.NewInt(eth1FollowDistance)) - blockHash, err := ps.eth1BlockFetcher.BlockHashByHeight(ctx, ancestorHeight) + blockHash, err := ps.Eth1BlockFetcher.BlockHashByHeight(ctx, ancestorHeight) if err != nil { return nil, errors.Wrap(err, "could not fetch ETH1_FOLLOW_DISTANCE ancestor") } // Fetch all historical deposits up to an ancestor height. - depositsTillHeight, depositRoot := ps.depositFetcher.DepositsNumberAndRootAtHeight(ctx, ancestorHeight) + depositsTillHeight, depositRoot := ps.DepositFetcher.DepositsNumberAndRootAtHeight(ctx, ancestorHeight) if depositsTillHeight == 0 { - return ps.chainStartFetcher.ChainStartEth1Data(), nil + return ps.ChainStartFetcher.ChainStartEth1Data(), nil } return ðpb.Eth1Data{ DepositRoot: depositRoot[:], diff --git a/beacon-chain/rpc/proposer/proposer_server_test.go b/beacon-chain/rpc/proposer/proposer_server_test.go index 59ad1d39f72b..ed228c0a9c7e 100644 --- a/beacon-chain/rpc/proposer/proposer_server_test.go +++ b/beacon-chain/rpc/proposer/proposer_server_test.go @@ -58,19 +58,19 @@ func TestProposeBlock_OK(t *testing.T) { } proposerServer := &ProposerServer{ - beaconDB: db, - chainStartFetcher: &mockPOW.POWChain{}, - eth1InfoFetcher: &mockPOW.POWChain{}, - eth1BlockFetcher: &mockPOW.POWChain{}, - blockReceiver: &mock.ChainService{}, - headFetcher: &mock.ChainService{}, + BeaconDB: db, + ChainStartFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + Eth1BlockFetcher: &mockPOW.POWChain{}, + BlockReceiver: &mock.ChainService{}, + HeadFetcher: &mock.ChainService{}, } req := ðpb.BeaconBlock{ Slot: 5, ParentRoot: []byte("parent-hash"), Body: ðpb.BeaconBlockBody{}, } - if err := proposerServer.beaconDB.SaveBlock(ctx, req); err != nil { + if err := proposerServer.BeaconDB.SaveBlock(ctx, req); err != nil { t.Fatal(err) } if _, err := proposerServer.ProposeBlock(context.Background(), req); err != nil { @@ -114,10 +114,10 @@ func TestComputeStateRoot_OK(t *testing.T) { } proposerServer := &ProposerServer{ - beaconDB: db, - chainStartFetcher: &mockPOW.POWChain{}, - eth1InfoFetcher: &mockPOW.POWChain{}, - eth1BlockFetcher: &mockPOW.POWChain{}, + BeaconDB: db, + ChainStartFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + Eth1BlockFetcher: &mockPOW.POWChain{}, } req := ðpb.BeaconBlock{ @@ -198,11 +198,11 @@ func TestPendingDeposits_Eth1DataVoteOK(t *testing.T) { } bs := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, } // It should also return the recent deposits after their follow window. @@ -347,13 +347,13 @@ func TestPendingDeposits_OutsideEth1FollowWindow(t *testing.T) { } bs := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, } deposits, err := bs.deposits(ctx, ðpb.Eth1Data{}) @@ -491,13 +491,13 @@ func TestPendingDeposits_FollowsCorrectEth1Block(t *testing.T) { } bs := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, } deposits, err := bs.deposits(ctx, ðpb.Eth1Data{}) @@ -608,13 +608,13 @@ func TestPendingDeposits_CantReturnBelowStateEth1DepositIndex(t *testing.T) { } bs := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, } // It should also return the recent deposits after their follow window. @@ -717,13 +717,13 @@ func TestPendingDeposits_CantReturnMoreThanMax(t *testing.T) { } bs := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, } // It should also return the recent deposits after their follow window. @@ -824,13 +824,13 @@ func TestPendingDeposits_CantReturnMoreDepositCount(t *testing.T) { } bs := &ProposerServer{ - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, } // It should also return the recent deposits after their follow window. @@ -859,11 +859,11 @@ func TestEth1Data_EmptyVotesFetchBlockHashFailure(t *testing.T) { HashesByHeight: make(map[int][]byte), } proposerServer := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - blockReceiver: &mock.ChainService{State: beaconState}, - headFetcher: &mock.ChainService{State: beaconState}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + BlockReceiver: &mock.ChainService{State: beaconState}, + HeadFetcher: &mock.ChainService{State: beaconState}, } want := "could not fetch ETH1_FOLLOW_DISTANCE ancestor" if _, err := proposerServer.eth1Data(context.Background(), beaconState.Slot+1); !strings.Contains(err.Error(), want) { @@ -914,11 +914,11 @@ func TestDefaultEth1Data_NoBlockExists(t *testing.T) { }, } proposerServer := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, } defEth1Data := ðpb.Eth1Data{ @@ -956,10 +956,10 @@ func TestEth1Data(t *testing.T) { }, } ps := &ProposerServer{ - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositcache.NewDepositCache(), + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositcache.NewDepositCache(), } ctx := context.Background() @@ -987,9 +987,9 @@ func TestEth1Data_MockEnabled(t *testing.T) { // ) ctx := context.Background() ps := &ProposerServer{ - headFetcher: &mock.ChainService{State: &pbp2p.BeaconState{}}, - beaconDB: db, - mockEth1Votes: true, + HeadFetcher: &mock.ChainService{State: &pbp2p.BeaconState{}}, + BeaconDB: db, + MockEth1Votes: true, } headBlockRoot := [32]byte{1, 2, 3} headState := &pbp2p.BeaconState{ @@ -1089,13 +1089,13 @@ func Benchmark_Eth1Data(b *testing.B) { HashesByHeight: hashesByHeight, } proposerServer := &ProposerServer{ - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, } b.ResetTimer() for i := 0; i < b.N; i++ { @@ -1190,13 +1190,13 @@ func TestDeposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t *testing } bs := &ProposerServer{ - blockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - headFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, - chainStartFetcher: p, - eth1InfoFetcher: p, - eth1BlockFetcher: p, - depositFetcher: depositCache, - pendingDepositsFetcher: depositCache, + BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + Eth1BlockFetcher: p, + DepositFetcher: depositCache, + PendingDepositsFetcher: depositCache, } // It should also return the recent deposits after their follow window. diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index 6444d63dbaaa..d9b626d24d4c 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -19,6 +19,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" att "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" + ns "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node" + val "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator" "github.com/prysmaticlabs/prysm/beacon-chain/sync" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" @@ -188,25 +190,25 @@ func (s *Service) Start() { AttestationCache: cache.NewAttestationCache(), SyncChecker: s.syncService, } - validatorServer := &ValidatorServer{ - ctx: s.ctx, - beaconDB: s.beaconDB, - headFetcher: s.headFetcher, - forkFetcher: s.forkFetcher, - canonicalStateChan: s.canonicalStateChan, - blockFetcher: s.powChainService, - chainStartFetcher: s.chainStartFetcher, - eth1InfoFetcher: s.powChainService, - depositFetcher: s.depositFetcher, - syncChecker: s.syncService, - stateFeedListener: s.stateFeedListener, - chainStartChan: make(chan time.Time), + validatorServer := &val.ValidatorServer{ + Ctx: s.ctx, + BeaconDB: s.beaconDB, + HeadFetcher: s.headFetcher, + ForkFetcher: s.forkFetcher, + CanonicalStateChan: s.canonicalStateChan, + BlockFetcher: s.powChainService, + ChainStartFetcher: s.chainStartFetcher, + Eth1InfoFetcher: s.powChainService, + DepositFetcher: s.depositFetcher, + SyncChecker: s.syncService, + StateFeedListener: s.stateFeedListener, + ChainStartChan: make(chan time.Time), } - nodeServer := &NodeServer{ - beaconDB: s.beaconDB, - server: s.grpcServer, - syncChecker: s.syncService, - genesisTimeFetcher: s.genesisTimeFetcher, + nodeServer := &ns.NodeServer{ + BeaconDB: s.beaconDB, + Server: s.grpcServer, + SyncChecker: s.syncService, + GenesisTimeFetcher: s.genesisTimeFetcher, } beaconChainServer := &BeaconChainServer{ beaconDB: s.beaconDB, diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index fc8713bf7b93..c737ec2d6675 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -20,6 +20,7 @@ go_library( "//shared/params:go_default_library", "@com_github_gogo_protobuf//types:go_default_library", "@com_github_pkg_errors//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//status:go_default_library", ], @@ -38,6 +39,7 @@ go_test( "//beacon-chain/db/testing:go_default_library", "//beacon-chain/powchain/testing:go_default_library", "//beacon-chain/rpc/testing:go_default_library", + "//beacon-chain/sync/initial-sync/testing:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", diff --git a/beacon-chain/rpc/validator/validator_server.go b/beacon-chain/rpc/validator/validator_server.go index 3981fb63d798..8a4cc273dd70 100644 --- a/beacon-chain/rpc/validator/validator_server.go +++ b/beacon-chain/rpc/validator/validator_server.go @@ -7,40 +7,46 @@ import ( ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/beacon-chain/sync" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/db" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" + "github.com/prysmaticlabs/prysm/beacon-chain/sync" 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" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" + "github.com/sirupsen/logrus" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) +var log logrus.FieldLogger + +func init() { + log = logrus.WithField("prefix", "rpc/validator") +} + // ValidatorServer defines a server implementation of the gRPC Validator service, // providing RPC endpoints for obtaining validator assignments per epoch, the slots // and committees in which particular validators need to perform their responsibilities, // and more. type ValidatorServer struct { - ctx context.Context - beaconDB db.Database - headFetcher blockchain.HeadFetcher - forkFetcher blockchain.ForkFetcher - canonicalStateChan chan *pbp2p.BeaconState - blockFetcher powchain.POWBlockFetcher - depositFetcher depositcache.DepositFetcher - chainStartFetcher powchain.ChainStartFetcher - eth1InfoFetcher powchain.ChainInfoFetcher - syncChecker sync.Checker - stateFeedListener blockchain.ChainFeeds - chainStartChan chan time.Time + Ctx context.Context + BeaconDB db.Database + HeadFetcher blockchain.HeadFetcher + ForkFetcher blockchain.ForkFetcher + CanonicalStateChan chan *pbp2p.BeaconState + BlockFetcher powchain.POWBlockFetcher + DepositFetcher depositcache.DepositFetcher + ChainStartFetcher powchain.ChainStartFetcher + Eth1InfoFetcher powchain.ChainInfoFetcher + SyncChecker sync.Checker + StateFeedListener blockchain.ChainFeeds + ChainStartChan chan time.Time } // WaitForActivation checks if a validator public key exists in the active validator registry of the current @@ -79,7 +85,7 @@ func (vs *ValidatorServer) WaitForActivation(req *pb.ValidatorActivationRequest, } case <-stream.Context().Done(): return errors.New("stream context closed, exiting gorutine") - case <-vs.ctx.Done(): + case <-vs.Ctx.Done(): return errors.New("rpc context closed, exiting goroutine") } } @@ -87,7 +93,7 @@ func (vs *ValidatorServer) WaitForActivation(req *pb.ValidatorActivationRequest, // ValidatorIndex is called by a validator to get its index location in the beacon state. func (vs *ValidatorServer) ValidatorIndex(ctx context.Context, req *pb.ValidatorIndexRequest) (*pb.ValidatorIndexResponse, error) { - index, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(req.PublicKey)) + index, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(req.PublicKey)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) } @@ -104,7 +110,7 @@ func (vs *ValidatorServer) ValidatorPerformance( ctx context.Context, req *pb.ValidatorPerformanceRequest, ) (*pb.ValidatorPerformanceResponse, error) { var err error - headState := vs.headFetcher.HeadState() + headState := vs.HeadFetcher.HeadState() // Advance state with empty transitions up to the requested epoch start slot. if req.Slot > headState.Slot { headState, err = state.ProcessSlots(ctx, headState, req.Slot) @@ -116,7 +122,7 @@ func (vs *ValidatorServer) ValidatorPerformance( balances := make([]uint64, len(req.PublicKeys)) missingValidators := make([][]byte, 0) for i, key := range req.PublicKeys { - index, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(key)) + index, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(key)) if err != nil || !ok { missingValidators = append(missingValidators, key) balances[i] = 0 @@ -152,12 +158,12 @@ func (vs *ValidatorServer) ValidatorPerformance( // 3.) The slot at which the committee is assigned. // 4.) The bool signaling if the validator is expected to propose a block at the assigned slot. func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error) { - if vs.syncChecker.Syncing() { + if vs.SyncChecker.Syncing() { return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") } var err error - s := vs.headFetcher.HeadState() + s := vs.HeadFetcher.HeadState() // Advance state with empty transitions up to the requested epoch start slot. if epochStartSlot := helpers.StartSlot(req.EpochStart); s.Slot < epochStartSlot { s, err = state.ProcessSlots(ctx, s, epochStartSlot) @@ -177,7 +183,7 @@ func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.Assi Status: pb.ValidatorStatus_UNKNOWN_STATUS, } - idx, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) if err != nil { return nil, err } @@ -226,7 +232,7 @@ func (vs *ValidatorServer) assignment(idx uint64, beaconState *pbp2p.BeaconState func (vs *ValidatorServer) ValidatorStatus( ctx context.Context, req *pb.ValidatorIndexRequest) (*pb.ValidatorStatusResponse, error) { - headState := vs.headFetcher.HeadState() + headState := vs.HeadFetcher.HeadState() return vs.validatorStatus(ctx, req.PublicKey, headState), nil } @@ -235,7 +241,7 @@ func (vs *ValidatorServer) ValidatorStatus( func (vs *ValidatorServer) multipleValidatorStatus( ctx context.Context, pubkeys [][]byte) (bool, []*pb.ValidatorActivationResponse_Status, error) { - headState := vs.headFetcher.HeadState() + headState := vs.HeadFetcher.HeadState() if headState == nil { return false, nil, nil } @@ -292,7 +298,7 @@ func (vs *ValidatorServer) ExitedValidators( // DomainData fetches the current domain version information from the beacon state. func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainRequest) (*pb.DomainResponse, error) { - fork := vs.forkFetcher.CurrentFork() + fork := vs.ForkFetcher.CurrentFork() dv := helpers.Domain(fork, request.Epoch, request.Domain) return &pb.DomainResponse{ SignatureDomain: dv, @@ -300,7 +306,7 @@ func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainReq } func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { - if !vs.eth1InfoFetcher.IsConnectedToETH1() { + if !vs.Eth1InfoFetcher.IsConnectedToETH1() { vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) if err != nil { return &pb.ValidatorStatusResponse{ @@ -317,7 +323,7 @@ func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, h return statusResp } - _, eth1BlockNumBigInt := vs.depositFetcher.DepositByPubkey(ctx, pubKey) + _, eth1BlockNumBigInt := vs.DepositFetcher.DepositByPubkey(ctx, pubKey) if eth1BlockNumBigInt == nil { return &pb.ValidatorStatusResponse{ Status: pb.ValidatorStatus_UNKNOWN_STATUS, @@ -371,7 +377,7 @@ func (vs *ValidatorServer) retrieveStatusFromState(ctx context.Context, pubKey [ if headState == nil { return pb.ValidatorStatus(0), 0, errors.New("head state does not exist") } - idx, ok, err := vs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) if err != nil { return pb.ValidatorStatus(0), 0, err } @@ -409,7 +415,7 @@ func (vs *ValidatorServer) assignmentStatus(validatorIdx uint64, beaconState *pb // CanonicalHead of the current beacon chain. This method is requested on-demand // by a validator when it is their time to propose or attest. func (vs *ValidatorServer) CanonicalHead(ctx context.Context, req *ptypes.Empty) (*ethpb.BeaconBlock, error) { - return vs.headFetcher.HeadBlock(), nil + return vs.HeadFetcher.HeadBlock(), nil } // WaitForChainStart queries the logs of the Deposit Contract in order to verify the beacon chain @@ -417,7 +423,7 @@ func (vs *ValidatorServer) CanonicalHead(ctx context.Context, req *ptypes.Empty) // subscribes to an event stream triggered by the powchain service whenever the ChainStart log does // occur in the Deposit Contract on ETH 1.0. func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.ValidatorService_WaitForChainStartServer) error { - head, err := vs.beaconDB.HeadState(context.Background()) + head, err := vs.BeaconDB.HeadState(context.Background()) if err != nil { return err } @@ -429,11 +435,11 @@ func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.Valida return stream.Send(res) } - sub := vs.stateFeedListener.StateInitializedFeed().Subscribe(vs.chainStartChan) + sub := vs.StateFeedListener.StateInitializedFeed().Subscribe(vs.ChainStartChan) defer sub.Unsubscribe() for { select { - case chainStartTime := <-vs.chainStartChan: + case chainStartTime := <-vs.ChainStartChan: log.Info("Sending genesis time notification to connected validator clients") res := &pb.ChainStartResponse{ Started: true, @@ -442,7 +448,7 @@ func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.Valida return stream.Send(res) case <-sub.Err(): return errors.New("subscriber closed, exiting goroutine") - case <-vs.ctx.Done(): + case <-vs.Ctx.Done(): return errors.New("rpc context closed, exiting goroutine") } } @@ -450,7 +456,7 @@ func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.Valida func (vs *ValidatorServer) depositBlockSlot(ctx context.Context, currentSlot uint64, eth1BlockNumBigInt *big.Int, beaconState *pbp2p.BeaconState) (uint64, error) { - blockTimeStamp, err := vs.blockFetcher.BlockTimeByHeight(ctx, eth1BlockNumBigInt) + blockTimeStamp, err := vs.BlockFetcher.BlockTimeByHeight(ctx, eth1BlockNumBigInt) if err != nil { return 0, err } diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go index d215ea9be535..2abeb3aac631 100644 --- a/beacon-chain/rpc/validator/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -24,6 +24,7 @@ import ( mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" internal "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing" mockRPC "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing" + mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" 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" @@ -50,7 +51,7 @@ func TestValidatorIndex_OK(t *testing.T) { } validatorServer := &ValidatorServer{ - beaconDB: db, + BeaconDB: db, } req := &pb.ValidatorIndexRequest{ @@ -82,9 +83,9 @@ func TestNextEpochCommitteeAssignment_WrongPubkeyLength(t *testing.T) { } validatorServer := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, - syncChecker: &mockSyncChecker{false}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } req := &pb.AssignmentRequest{ PublicKeys: [][]byte{{1}}, @@ -112,9 +113,9 @@ func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { } vs := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, - syncChecker: &mockSyncChecker{false}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } pubKey := make([]byte, 96) @@ -166,9 +167,9 @@ func TestCommitteeAssignment_OK(t *testing.T) { } vs := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - syncChecker: &mockSyncChecker{false}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } // Test the first validator in registry. @@ -241,9 +242,9 @@ func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { } vs := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - syncChecker: &mockSyncChecker{false}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } // Test the first validator in registry. @@ -296,9 +297,9 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { } vs := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - syncChecker: &mockSyncChecker{false}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, } pubkey0 := deposits[0].Data.PublicKey @@ -321,7 +322,7 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { func TestCommitteeAssignment_SyncNotReady(t *testing.T) { vs := &ValidatorServer{ - syncChecker: &mockSyncChecker{syncing: true}, + SyncChecker: &mockSync.Sync{IsSyncing: true}, } _, err := vs.CommitteeAssignment(context.Background(), &pb.AssignmentRequest{}) if strings.Contains(err.Error(), "syncing to latest head") { @@ -356,13 +357,13 @@ func TestValidatorStatus_DepositReceived(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - depositFetcher: depositCache, - blockFetcher: p, - headFetcher: &mockChain.ChainService{ + BeaconDB: db, + DepositFetcher: depositCache, + BlockFetcher: p, + HeadFetcher: &mockChain.ChainService{ State: &pbp2p.BeaconState{}, }, - eth1InfoFetcher: p, + Eth1InfoFetcher: p, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -432,12 +433,12 @@ func TestValidatorStatus_PendingActive(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - blockFetcher: p, - eth1InfoFetcher: p, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -508,12 +509,12 @@ func TestValidatorStatus_Active(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - blockFetcher: p, - eth1InfoFetcher: p, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -588,12 +589,12 @@ func TestValidatorStatus_InitiatedExit(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - blockFetcher: p, - eth1InfoFetcher: p, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -658,12 +659,12 @@ func TestValidatorStatus_Withdrawable(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - blockFetcher: p, - eth1InfoFetcher: p, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -728,12 +729,12 @@ func TestValidatorStatus_ExitedSlashed(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - eth1InfoFetcher: p, - depositFetcher: depositCache, - blockFetcher: p, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + BlockFetcher: p, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -799,12 +800,12 @@ func TestValidatorStatus_Exited(t *testing.T) { }, } vs := &ValidatorServer{ - beaconDB: db, - chainStartFetcher: p, - eth1InfoFetcher: p, - blockFetcher: p, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + BlockFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, @@ -824,9 +825,9 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) { pubKey := []byte{'A'} depositCache := depositcache.NewDepositCache() vs := &ValidatorServer{ - depositFetcher: depositCache, - eth1InfoFetcher: &mockPOW.POWChain{}, - headFetcher: &mockChain.ChainService{ + DepositFetcher: depositCache, + Eth1InfoFetcher: &mockPOW.POWChain{}, + HeadFetcher: &mockChain.ChainService{ State: &pbp2p.BeaconState{ Slot: 0, }, @@ -864,14 +865,14 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) vs := &ValidatorServer{ - beaconDB: db, - ctx: ctx, - chainStartFetcher: &mockPOW.POWChain{}, - blockFetcher: &mockPOW.POWChain{}, - eth1InfoFetcher: &mockPOW.POWChain{}, - canonicalStateChan: make(chan *pbp2p.BeaconState, 1), - depositFetcher: depositcache.NewDepositCache(), - headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + BeaconDB: db, + Ctx: ctx, + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + DepositFetcher: depositcache.NewDepositCache(), + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } req := &pb.ValidatorActivationRequest{ PublicKeys: [][]byte{[]byte("A")}, @@ -968,14 +969,14 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { t.Fatalf("could not save validator index: %v", err) } vs := &ValidatorServer{ - beaconDB: db, - ctx: context.Background(), - canonicalStateChan: make(chan *pbp2p.BeaconState, 1), - chainStartFetcher: &mockPOW.POWChain{}, - blockFetcher: &mockPOW.POWChain{}, - eth1InfoFetcher: &mockPOW.POWChain{}, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + BeaconDB: db, + Ctx: context.Background(), + CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } req := &pb.ValidatorActivationRequest{ PublicKeys: [][]byte{pubKey1, pubKey2}, @@ -1082,14 +1083,14 @@ func TestMultipleValidatorStatus_OK(t *testing.T) { t.Fatalf("could not save validator index: %v", err) } vs := &ValidatorServer{ - beaconDB: db, - ctx: context.Background(), - canonicalStateChan: make(chan *pbp2p.BeaconState, 1), - chainStartFetcher: &mockPOW.POWChain{}, - blockFetcher: &mockPOW.POWChain{}, - eth1InfoFetcher: &mockPOW.POWChain{}, - depositFetcher: depositCache, - headFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + BeaconDB: db, + Ctx: context.Background(), + CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } activeExists, response, err := vs.multipleValidatorStatus(context.Background(), pubKeys) if err != nil { @@ -1121,12 +1122,12 @@ func TestWaitForChainStart_ContextClosed(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) validatorServer := &ValidatorServer{ - ctx: ctx, - chainStartFetcher: &mockPOW.FaultyMockPOWChain{ + Ctx: ctx, + ChainStartFetcher: &mockPOW.FaultyMockPOWChain{ ChainFeed: new(event.Feed), }, - stateFeedListener: &mockChain.ChainService{}, - beaconDB: db, + StateFeedListener: &mockChain.ChainService{}, + BeaconDB: db, } exitRoutine := make(chan bool) @@ -1156,12 +1157,12 @@ func TestWaitForChainStart_AlreadyStarted(t *testing.T) { } validatorServer := &ValidatorServer{ - ctx: context.Background(), - chainStartFetcher: &mockPOW.POWChain{ + Ctx: context.Background(), + ChainStartFetcher: &mockPOW.POWChain{ ChainFeed: new(event.Feed), }, - stateFeedListener: &mockChain.ChainService{}, - beaconDB: db, + StateFeedListener: &mockChain.ChainService{}, + BeaconDB: db, } ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -1183,13 +1184,13 @@ func TestWaitForChainStart_NotStartedThenLogFired(t *testing.T) { hook := logTest.NewGlobal() validatorServer := &ValidatorServer{ - ctx: context.Background(), - chainStartChan: make(chan time.Time, 1), - chainStartFetcher: &mockPOW.FaultyMockPOWChain{ + Ctx: context.Background(), + ChainStartChan: make(chan time.Time, 1), + ChainStartFetcher: &mockPOW.FaultyMockPOWChain{ ChainFeed: new(event.Feed), }, - stateFeedListener: &mockChain.ChainService{}, - beaconDB: db, + StateFeedListener: &mockChain.ChainService{}, + BeaconDB: db, } exitRoutine := make(chan bool) ctrl := gomock.NewController(t) @@ -1207,7 +1208,7 @@ func TestWaitForChainStart_NotStartedThenLogFired(t *testing.T) { } <-exitRoutine }(t) - validatorServer.chainStartChan <- time.Unix(0, 0) + validatorServer.ChainStartChan <- time.Unix(0, 0) exitRoutine <- true testutil.AssertLogsContain(t, hook, "Sending genesis time") } @@ -1251,8 +1252,8 @@ func BenchmarkAssignment(b *testing.B) { } vs := &ValidatorServer{ - beaconDB: db, - headFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } // Set up request for 100 public keys at a time From 16489aa790b77ac3c78346001b78c370a5a9ec41 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 16:08:30 -0600 Subject: [PATCH 45/82] all packages isolated --- beacon-chain/rpc/BUILD.bazel | 2 + .../rpc/beacon/beacon_chain_server.go | 87 +++++++------ .../rpc/beacon/beacon_chain_server_test.go | 114 +++++++++--------- beacon-chain/rpc/service.go | 15 +-- 4 files changed, 110 insertions(+), 108 deletions(-) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 5fdc9031671c..e7d31066b760 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -14,7 +14,9 @@ go_library( "//beacon-chain/p2p:go_default_library", "//beacon-chain/powchain:go_default_library", "//beacon-chain/rpc/attester:go_default_library", + "//beacon-chain/rpc/beacon:go_default_library", "//beacon-chain/rpc/node:go_default_library", + "//beacon-chain/rpc/validator:go_default_library", "//beacon-chain/sync:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", diff --git a/beacon-chain/rpc/beacon/beacon_chain_server.go b/beacon-chain/rpc/beacon/beacon_chain_server.go index f8ad7e1749d3..fc6a5933489c 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server.go @@ -30,16 +30,16 @@ import ( // providing RPC endpoints to access data relevant to the Ethereum 2.0 phase 0 // beacon chain. type BeaconChainServer struct { - beaconDB db.Database - ctx context.Context - chainStartFetcher powchain.ChainStartFetcher - headFetcher blockchain.HeadFetcher - finalizationFetcher blockchain.FinalizationFetcher - stateFeedListener blockchain.ChainFeeds - pool operations.Pool - incomingAttestation chan *ethpb.Attestation - canonicalStateChan chan *pbp2p.BeaconState - chainStartChan chan time.Time + BeaconDB db.Database + Ctx context.Context + ChainStartFetcher powchain.ChainStartFetcher + HeadFetcher blockchain.HeadFetcher + FinalizationFetcher blockchain.FinalizationFetcher + StateFeedListener blockchain.ChainFeeds + Pool operations.Pool + IncomingAttestation chan *ethpb.Attestation + CanonicalStateChan chan *pbp2p.BeaconState + ChainStartChan chan time.Time } // sortableAttestations implements the Sort interface to sort attestations @@ -69,27 +69,27 @@ func (bs *BeaconChainServer) ListAttestations( var err error switch q := req.QueryFilter.(type) { case *ethpb.ListAttestationsRequest_HeadBlockRoot: - atts, err = bs.beaconDB.Attestations(ctx, filters.NewFilter().SetHeadBlockRoot(q.HeadBlockRoot)) + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetHeadBlockRoot(q.HeadBlockRoot)) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } case *ethpb.ListAttestationsRequest_SourceEpoch: - atts, err = bs.beaconDB.Attestations(ctx, filters.NewFilter().SetSourceEpoch(q.SourceEpoch)) + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceEpoch(q.SourceEpoch)) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } case *ethpb.ListAttestationsRequest_SourceRoot: - atts, err = bs.beaconDB.Attestations(ctx, filters.NewFilter().SetSourceRoot(q.SourceRoot)) + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceRoot(q.SourceRoot)) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } case *ethpb.ListAttestationsRequest_TargetEpoch: - atts, err = bs.beaconDB.Attestations(ctx, filters.NewFilter().SetTargetEpoch(q.TargetEpoch)) + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetEpoch(q.TargetEpoch)) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } case *ethpb.ListAttestationsRequest_TargetRoot: - atts, err = bs.beaconDB.Attestations(ctx, filters.NewFilter().SetTargetRoot(q.TargetRoot)) + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetRoot(q.TargetRoot)) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } @@ -123,8 +123,7 @@ func (bs *BeaconChainServer) ListAttestations( func (bs *BeaconChainServer) AttestationPool( ctx context.Context, _ *ptypes.Empty, ) (*ethpb.AttestationPoolResponse, error) { - - atts, err := bs.pool.AttestationPoolNoVerify(ctx) + atts, err := bs.Pool.AttestationPoolNoVerify(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) } @@ -152,7 +151,7 @@ func (bs *BeaconChainServer) ListBlocks( startSlot := q.Epoch * params.BeaconConfig().SlotsPerEpoch endSlot := startSlot + params.BeaconConfig().SlotsPerEpoch - 1 - blks, err := bs.beaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot)) + blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot)) if err != nil { return nil, status.Errorf(codes.Internal, "failed to get blocks: %v", err) } @@ -174,7 +173,7 @@ func (bs *BeaconChainServer) ListBlocks( }, nil case *ethpb.ListBlocksRequest_Root: - blk, err := bs.beaconDB.Block(ctx, bytesutil.ToBytes32(q.Root)) + blk, err := bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(q.Root)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve block: %v", err) } @@ -189,7 +188,7 @@ func (bs *BeaconChainServer) ListBlocks( }, nil case *ethpb.ListBlocksRequest_Slot: - blks, err := bs.beaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(q.Slot).SetEndSlot(q.Slot)) + blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(q.Slot).SetEndSlot(q.Slot)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve blocks for slot %d: %v", q.Slot, err) } @@ -220,13 +219,13 @@ func (bs *BeaconChainServer) ListBlocks( // This includes the head block slot and root as well as information about // the most recent finalized and justified slots. func (bs *BeaconChainServer) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) { - finalizedCheckpoint := bs.headFetcher.HeadState().FinalizedCheckpoint - justifiedCheckpoint := bs.headFetcher.HeadState().CurrentJustifiedCheckpoint - prevJustifiedCheckpoint := bs.headFetcher.HeadState().PreviousJustifiedCheckpoint + finalizedCheckpoint := bs.HeadFetcher.HeadState().FinalizedCheckpoint + justifiedCheckpoint := bs.HeadFetcher.HeadState().CurrentJustifiedCheckpoint + prevJustifiedCheckpoint := bs.HeadFetcher.HeadState().PreviousJustifiedCheckpoint return ðpb.ChainHead{ - BlockRoot: bs.headFetcher.HeadRoot(), - BlockSlot: bs.headFetcher.HeadSlot(), + BlockRoot: bs.HeadFetcher.HeadRoot(), + BlockSlot: bs.HeadFetcher.HeadSlot(), FinalizedBlockRoot: finalizedCheckpoint.Root, FinalizedSlot: finalizedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, JustifiedBlockRoot: justifiedCheckpoint.Root, @@ -251,7 +250,7 @@ func (bs *BeaconChainServer) ListValidatorBalances( res := make([]*ethpb.ValidatorBalances_Balance, 0) filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() var requestingGenesis bool var epoch uint64 switch q := req.QueryFilter.(type) { @@ -267,12 +266,12 @@ func (bs *BeaconChainServer) ListValidatorBalances( var err error validators := headState.Validators if requestingGenesis { - balances, err = bs.beaconDB.ArchivedBalances(ctx, 0 /* genesis epoch */) + balances, err = bs.BeaconDB.ArchivedBalances(ctx, 0 /* genesis epoch */) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) } } else if !requestingGenesis && epoch < helpers.CurrentEpoch(headState) { - balances, err = bs.beaconDB.ArchivedBalances(ctx, epoch) + balances, err = bs.BeaconDB.ArchivedBalances(ctx, epoch) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) } @@ -286,7 +285,7 @@ func (bs *BeaconChainServer) ListValidatorBalances( continue } - index, ok, err := bs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) } @@ -362,7 +361,7 @@ func (bs *BeaconChainServer) GetValidators( req.PageSize, params.BeaconConfig().MaxPageSize) } - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() requestedEpoch := helpers.CurrentEpoch(headState) switch q := req.QueryFilter.(type) { case *ethpb.GetValidatorsRequest_Genesis: @@ -373,7 +372,7 @@ func (bs *BeaconChainServer) GetValidators( requestedEpoch = q.Epoch } - finalizedEpoch := bs.finalizationFetcher.FinalizedCheckpt().Epoch + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch validators := headState.Validators if requestedEpoch < finalizedEpoch { stopIdx := len(validators) @@ -408,7 +407,7 @@ func (bs *BeaconChainServer) GetValidators( func (bs *BeaconChainServer) GetValidatorActiveSetChanges( ctx context.Context, req *ethpb.GetValidatorActiveSetChangesRequest, ) (*ethpb.ActiveSetChanges, error) { - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() requestedEpoch := helpers.CurrentEpoch(headState) switch q := req.QueryFilter.(type) { case *ethpb.GetValidatorActiveSetChangesRequest_Genesis: @@ -422,11 +421,11 @@ func (bs *BeaconChainServer) GetValidatorActiveSetChanges( activatedIndices := make([]uint64, 0) slashedIndices := make([]uint64, 0) exitedIndices := make([]uint64, 0) - finalizedEpoch := bs.finalizationFetcher.FinalizedCheckpt().Epoch + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch var err error if requestedEpoch < finalizedEpoch { - archivedChanges, err := bs.beaconDB.ArchivedActiveValidatorChanges(ctx, requestedEpoch) + archivedChanges, err := bs.BeaconDB.ArchivedActiveValidatorChanges(ctx, requestedEpoch) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch archived active validator changes: %v", err) } @@ -467,7 +466,7 @@ func (bs *BeaconChainServer) GetValidatorActiveSetChanges( func (bs *BeaconChainServer) GetValidatorQueue( ctx context.Context, _ *ptypes.Empty, ) (*ethpb.ValidatorQueue, error) { - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() // Queue the validators whose eligible to activate and sort them by activation eligibility epoch number. // Additionally, determine those validators queued to exit awaitingExit := make([]uint64, 0) @@ -557,7 +556,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( } var res []*ethpb.ValidatorAssignments_CommitteeAssignment - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. filteredIndices := make([]uint64, 0) requestedEpoch := helpers.CurrentEpoch(headState) @@ -573,7 +572,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( // Filter out assignments by public keys. for _, pubKey := range req.PublicKeys { - index, ok, err := bs.beaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) } @@ -605,7 +604,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( return nil, err } - shouldFetchFromArchive := requestedEpoch < bs.finalizationFetcher.FinalizedCheckpt().Epoch + shouldFetchFromArchive := requestedEpoch < bs.FinalizationFetcher.FinalizedCheckpt().Epoch for _, index := range filteredIndices[start:end] { if int(index) >= len(headState.Validators) { @@ -613,7 +612,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( index, len(headState.Validators)) } if shouldFetchFromArchive { - archivedInfo, err := bs.beaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) + archivedInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) if err != nil { return nil, status.Errorf( codes.Internal, @@ -628,7 +627,7 @@ func (bs *BeaconChainServer) ListValidatorAssignments( requestedEpoch, ) } - archivedBalances, err := bs.beaconDB.ArchivedBalances(ctx, requestedEpoch) + archivedBalances, err := bs.BeaconDB.ArchivedBalances(ctx, requestedEpoch) if err != nil { return nil, status.Errorf( codes.Internal, @@ -765,7 +764,7 @@ func archivedProposerIndex(activeIndices []uint64, activeBalances []uint64, seed func (bs *BeaconChainServer) GetValidatorParticipation( ctx context.Context, req *ethpb.GetValidatorParticipationRequest, ) (*ethpb.ValidatorParticipationResponse, error) { - headState := bs.headFetcher.HeadState() + headState := bs.HeadFetcher.HeadState() currentEpoch := helpers.SlotToEpoch(headState.Slot) var requestedEpoch uint64 @@ -788,7 +787,7 @@ func (bs *BeaconChainServer) GetValidatorParticipation( // If the request is from genesis or another past epoch, we look into our archived // data to find it and return it if it exists. if isGenesis { - participation, err := bs.beaconDB.ArchivedValidatorParticipation(ctx, 0) + participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, 0) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) } @@ -801,14 +800,14 @@ func (bs *BeaconChainServer) GetValidatorParticipation( Participation: participation, }, nil } else if requestedEpoch < helpers.SlotToEpoch(headState.Slot) { - participation, err := bs.beaconDB.ArchivedValidatorParticipation(ctx, requestedEpoch) + participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, requestedEpoch) if err != nil { return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) } if participation == nil { return nil, status.Errorf(codes.NotFound, "could not find archival data for epoch %d", requestedEpoch) } - finalizedEpoch := bs.finalizationFetcher.FinalizedCheckpt().Epoch + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch // If the epoch we requested is <= the finalized epoch, we consider it finalized as well. finalized := requestedEpoch <= finalizedEpoch return ðpb.ValidatorParticipationResponse{ diff --git a/beacon-chain/rpc/beacon/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go index 410f54ebe90e..68f3e683d727 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server_test.go @@ -46,7 +46,7 @@ func TestBeaconChainServer_ListAttestationsNoPagination(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ @@ -128,7 +128,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ @@ -201,7 +201,7 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } tests := []struct { @@ -358,7 +358,7 @@ func TestBeaconChainServer_ListAttestationsPaginationOutOfRange(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } req := ðpb.ListAttestationsRequest{ @@ -409,7 +409,7 @@ func TestBeaconChainServer_ListAttestationsDefaultPageSize(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } req := ðpb.ListAttestationsRequest{ @@ -436,7 +436,7 @@ func TestBeaconChainServer_AttestationPool(t *testing.T) { Slot: 10, } bs := &BeaconChainServer{ - pool: &mockOps.Operations{ + Pool: &mockOps.Operations{ Attestations: []*ethpb.Attestation{ { Data: ðpb.AttestationData{ @@ -450,7 +450,7 @@ func TestBeaconChainServer_AttestationPool(t *testing.T) { }, }, }, - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ Block: block, }, } @@ -458,7 +458,7 @@ func TestBeaconChainServer_AttestationPool(t *testing.T) { if err != nil { t.Fatal(err) } - want, _ := bs.pool.AttestationPoolNoVerify(ctx) + want, _ := bs.Pool.AttestationPoolNoVerify(ctx) if !reflect.DeepEqual(res.Attestations, want) { t.Errorf("Wanted AttestationPool() = %v, received %v", want, res.Attestations) } @@ -476,7 +476,7 @@ func TestBeaconChainServer_ListValidatorBalances_PaginationOutOfRange(t *testing } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, } @@ -515,8 +515,8 @@ func TestBeaconChainServer_ListValidatorBalances_NoPagination(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{State: headState}, + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: headState}, } tests := []struct { @@ -597,7 +597,7 @@ func TestBeaconChainServer_ListValidatorBalances_Pagination(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, } @@ -663,8 +663,8 @@ func TestBeaconChainServer_ListValidatorBalances_OutOfRange(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{State: headState}, + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: headState}, } req := ðpb.GetValidatorBalancesRequest{Indices: []uint64{uint64(1)}} @@ -690,8 +690,8 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive(t *testing.T) { newerBalances[i] = balances[i] * 2 } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch * 3, Validators: validators, @@ -735,8 +735,8 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive_NewValidatorNotFoun newValidators, newBalances := setupValidators(t, db, 200) bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch * 3, Validators: newValidators, @@ -765,10 +765,10 @@ func TestBeaconChainServer_GetValidators_NoPagination(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -798,10 +798,10 @@ func TestBeaconChainServer_GetValidators_Pagination(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -867,10 +867,10 @@ func TestBeaconChainServer_GetValidators_PaginationOutOfRange(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -906,10 +906,10 @@ func TestBeaconChainServer_GetValidators_DefaultPageSize(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -942,12 +942,12 @@ func TestBeaconChainServer_GetValidators_FromOldEpoch(t *testing.T) { } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ Validators: validators, }, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 200, }, @@ -1014,10 +1014,10 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges(t *testing.T) { } } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 0}, }, } @@ -1088,11 +1088,11 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T t.Fatal(err) } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: headState, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ // Pick an epoch far in the future so that we trigger fetching from the archive. FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 100}, }, @@ -1159,7 +1159,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingActivation(t *testing.T) { }, } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, } @@ -1212,7 +1212,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingExit(t *testing.T) { }, } bs := &BeaconChainServer{ - headFetcher: &mock.ChainService{ + HeadFetcher: &mock.ChainService{ State: headState, }, } @@ -1249,8 +1249,8 @@ func TestBeaconChainServer_ListAssignmentsInputOutOfRange(t *testing.T) { t.Fatal(err) } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: headState, }, } @@ -1327,11 +1327,11 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: s, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -1426,11 +1426,11 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing // We tell the beacon chain server that our finalized epoch is 10 so that when // we request assignments for epoch 0, it looks within the archived data. bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: s, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 10, }, @@ -1529,11 +1529,11 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: s, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -1606,11 +1606,11 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: s, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: 0, }, @@ -1702,11 +1702,11 @@ func TestBeaconChainServer_GetValidatorsParticipation_FromArchive(t *testing.T) } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{Slot: helpers.StartSlot(epoch + 1)}, }, - finalizationFetcher: &mock.ChainService{ + FinalizationFetcher: &mock.ChainService{ FinalizedCheckPoint: ðpb.Checkpoint{ Epoch: epoch + 1, }, @@ -1782,8 +1782,8 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) } bs := &BeaconChainServer{ - beaconDB: db, - headFetcher: &mock.ChainService{State: s}, + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: s}, } res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{}) @@ -1825,7 +1825,7 @@ func TestBeaconChainServer_ListBlocksPagination(t *testing.T) { } bs := &BeaconChainServer{ - beaconDB: db, + BeaconDB: db, } tests := []struct { @@ -1901,7 +1901,7 @@ func TestBeaconChainServer_ListBlocksErrors(t *testing.T) { defer dbTest.TeardownDB(t, db) ctx := context.Background() - bs := &BeaconChainServer{beaconDB: db} + bs := &BeaconChainServer{BeaconDB: db} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) @@ -1975,7 +1975,7 @@ func TestBeaconChainServer_GetChainHead(t *testing.T) { FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 1, Root: []byte{'C'}}, } - bs := &BeaconChainServer{headFetcher: &mock.ChainService{State: s}} + bs := &BeaconChainServer{HeadFetcher: &mock.ChainService{State: s}} head, err := bs.GetChainHead(context.Background(), nil) if err != nil { diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index d9b626d24d4c..ff1befa704c2 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -19,6 +19,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" att "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" + bs "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon" ns "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node" val "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator" "github.com/prysmaticlabs/prysm/beacon-chain/sync" @@ -210,13 +211,13 @@ func (s *Service) Start() { SyncChecker: s.syncService, GenesisTimeFetcher: s.genesisTimeFetcher, } - beaconChainServer := &BeaconChainServer{ - beaconDB: s.beaconDB, - pool: s.attestationsPool, - headFetcher: s.headFetcher, - finalizationFetcher: s.finalizationFetcher, - chainStartFetcher: s.chainStartFetcher, - canonicalStateChan: s.canonicalStateChan, + beaconChainServer := &bs.BeaconChainServer{ + BeaconDB: s.beaconDB, + Pool: s.attestationsPool, + HeadFetcher: s.headFetcher, + FinalizationFetcher: s.finalizationFetcher, + ChainStartFetcher: s.chainStartFetcher, + CanonicalStateChan: s.canonicalStateChan, } pb.RegisterProposerServiceServer(s.grpcServer, proposerServer) pb.RegisterAttesterServiceServer(s.grpcServer, attesterServer) From 70ab2c8c63b529b6bbf8e528180453d89afc893c Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 16:55:51 -0600 Subject: [PATCH 46/82] include proposer --- beacon-chain/rpc/BUILD.bazel | 1 + beacon-chain/rpc/service.go | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index e7d31066b760..c181661cce19 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -16,6 +16,7 @@ go_library( "//beacon-chain/rpc/attester:go_default_library", "//beacon-chain/rpc/beacon:go_default_library", "//beacon-chain/rpc/node:go_default_library", + "//beacon-chain/rpc/proposer:go_default_library", "//beacon-chain/rpc/validator:go_default_library", "//beacon-chain/sync:go_default_library", "//proto/beacon/p2p/v1:go_default_library", diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index ff1befa704c2..69eaa885838c 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -21,6 +21,7 @@ import ( att "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" bs "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon" ns "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node" + prop "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer" val "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator" "github.com/prysmaticlabs/prysm/beacon-chain/sync" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" @@ -168,19 +169,19 @@ func (s *Service) Start() { } s.grpcServer = grpc.NewServer(opts...) - proposerServer := &ProposerServer{ - beaconDB: s.beaconDB, - headFetcher: s.headFetcher, - blockReceiver: s.blockReceiver, - chainStartFetcher: s.chainStartFetcher, - eth1InfoFetcher: s.powChainService, - eth1BlockFetcher: s.powChainService, - mockEth1Votes: s.mockEth1Votes, - pool: s.attestationsPool, - canonicalStateChan: s.canonicalStateChan, - depositFetcher: s.depositFetcher, - pendingDepositsFetcher: s.pendingDepositFetcher, - syncChecker: s.syncService, + proposerServer := &prop.ProposerServer{ + BeaconDB: s.beaconDB, + HeadFetcher: s.headFetcher, + BlockReceiver: s.blockReceiver, + ChainStartFetcher: s.chainStartFetcher, + Eth1InfoFetcher: s.powChainService, + Eth1BlockFetcher: s.powChainService, + MockEth1Votes: s.mockEth1Votes, + Pool: s.attestationsPool, + CanonicalStateChan: s.canonicalStateChan, + DepositFetcher: s.depositFetcher, + PendingDepositsFetcher: s.pendingDepositFetcher, + SyncChecker: s.syncService, } attesterServer := &att.AttesterServer{ P2p: s.p2p, From 2beddda524e2f7f2330b0fc480c3d385ef189152 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 17:05:31 -0600 Subject: [PATCH 47/82] proper naming --- beacon-chain/rpc/attester/attester_server.go | 8 +- .../rpc/attester/attester_server_test.go | 10 +- .../rpc/beacon/beacon_chain_server.go | 24 +-- .../rpc/beacon/beacon_chain_server_test.go | 140 +++++++++--------- beacon-chain/rpc/node/node_server.go | 12 +- beacon-chain/rpc/node/node_server_test.go | 8 +- beacon-chain/rpc/proposer/proposer_server.go | 20 +-- .../rpc/proposer/proposer_server_test.go | 28 ++-- beacon-chain/rpc/service.go | 20 +-- .../rpc/validator/validator_server.go | 34 ++--- .../rpc/validator/validator_server_test.go | 56 +++---- 11 files changed, 180 insertions(+), 180 deletions(-) diff --git a/beacon-chain/rpc/attester/attester_server.go b/beacon-chain/rpc/attester/attester_server.go index e5a921bcb57c..b144d5174f2a 100644 --- a/beacon-chain/rpc/attester/attester_server.go +++ b/beacon-chain/rpc/attester/attester_server.go @@ -28,9 +28,9 @@ func init() { log = logrus.WithField("prefix", "rpc/attester") } -// AttesterServer defines a server implementation of the gRPC Attester service, +// Server defines a server implementation of the gRPC Attester service, // providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks. -type AttesterServer struct { +type Server struct { P2p p2p.Broadcaster BeaconDB db.Database OperationsHandler operations.Handler @@ -42,7 +42,7 @@ type AttesterServer struct { // SubmitAttestation is a function called by an attester in a sharding validator to vote // on a block via an attestation object as defined in the Ethereum Serenity specification. -func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Attestation) (*pb.AttestResponse, error) { +func (as *Server) SubmitAttestation(ctx context.Context, att *ethpb.Attestation) (*pb.AttestResponse, error) { root, err := ssz.HashTreeRoot(att.Data) if err != nil { return nil, errors.Wrap(err, "failed to hash tree root attestation") @@ -66,7 +66,7 @@ func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Atte // RequestAttestation requests that the beacon node produce an IndexedAttestation, // with a blank signature field, which the validator will then sign. -func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.AttestationRequest) (*ethpb.AttestationData, error) { +func (as *Server) RequestAttestation(ctx context.Context, req *pb.AttestationRequest) (*ethpb.AttestationData, error) { ctx, span := trace.StartSpan(ctx, "AttesterServer.RequestAttestation") defer span.End() span.AddAttributes( diff --git a/beacon-chain/rpc/attester/attester_server_test.go b/beacon-chain/rpc/attester/attester_server_test.go index a40cf160b986..b0c640da9acc 100644 --- a/beacon-chain/rpc/attester/attester_server_test.go +++ b/beacon-chain/rpc/attester/attester_server_test.go @@ -27,7 +27,7 @@ func TestSubmitAttestation_OK(t *testing.T) { defer dbutil.TeardownDB(t, db) ctx := context.Background() - attesterServer := &AttesterServer{ + attesterServer := &Server{ HeadFetcher: &mock.ChainService{}, AttReceiver: &mock.ChainService{}, OperationsHandler: &mockOps.Operations{}, @@ -114,7 +114,7 @@ func TestRequestAttestation_OK(t *testing.T) { beaconState.BlockRoots[1] = blockRoot[:] beaconState.BlockRoots[1*params.BeaconConfig().SlotsPerEpoch] = targetRoot[:] beaconState.BlockRoots[2*params.BeaconConfig().SlotsPerEpoch] = justifiedRoot[:] - attesterServer := &AttesterServer{ + attesterServer := &Server{ P2p: &mockp2p.MockBroadcaster{}, SyncChecker: &mockSync.Sync{IsSyncing: false}, AttestationCache: cache.NewAttestationCache(), @@ -149,7 +149,7 @@ func TestRequestAttestation_OK(t *testing.T) { } func TestRequestAttestation_SyncNotReady(t *testing.T) { - as := &AttesterServer{ + as := &Server{ SyncChecker: &mockSync.Sync{IsSyncing: true}, } _, err := as.RequestAttestation(context.Background(), &pb.AttestationRequest{}) @@ -207,7 +207,7 @@ func TestAttestationDataAtSlot_handlesFarAwayJustifiedEpoch(t *testing.T) { beaconState.BlockRoots[1] = blockRoot[:] beaconState.BlockRoots[1*params.BeaconConfig().SlotsPerEpoch] = epochBoundaryRoot[:] beaconState.BlockRoots[2*params.BeaconConfig().SlotsPerEpoch] = justifiedBlockRoot[:] - attesterServer := &AttesterServer{ + attesterServer := &Server{ P2p: &mockp2p.MockBroadcaster{}, AttestationCache: cache.NewAttestationCache(), HeadFetcher: &mock.ChainService{State: beaconState, Root: blockRoot[:]}, @@ -251,7 +251,7 @@ func TestAttestationDataAtSlot_handlesInProgressRequest(t *testing.T) { }() ctx := context.Background() - server := &AttesterServer{ + server := &Server{ AttestationCache: cache.NewAttestationCache(), SyncChecker: &mockSync.Sync{IsSyncing: false}, } diff --git a/beacon-chain/rpc/beacon/beacon_chain_server.go b/beacon-chain/rpc/beacon/beacon_chain_server.go index fc6a5933489c..2f347f88debd 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server.go @@ -26,10 +26,10 @@ import ( "google.golang.org/grpc/status" ) -// BeaconChainServer defines a server implementation of the gRPC Beacon Chain service, +// Server defines a server implementation of the gRPC Beacon Chain service, // providing RPC endpoints to access data relevant to the Ethereum 2.0 phase 0 // beacon chain. -type BeaconChainServer struct { +type Server struct { BeaconDB db.Database Ctx context.Context ChainStartFetcher powchain.ChainStartFetcher @@ -58,7 +58,7 @@ func (s sortableAttestations) Less(i, j int) bool { // 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 // criteria should be used. -func (bs *BeaconChainServer) ListAttestations( +func (bs *Server) ListAttestations( ctx context.Context, req *ethpb.ListAttestationsRequest, ) (*ethpb.ListAttestationsResponse, error) { if int(req.PageSize) > params.BeaconConfig().MaxPageSize { @@ -120,7 +120,7 @@ func (bs *BeaconChainServer) ListAttestations( // Refer to the ethereum 2.0 specification for more details on how // attestations are processed and when they are no longer valid. // https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestations -func (bs *BeaconChainServer) AttestationPool( +func (bs *Server) AttestationPool( ctx context.Context, _ *ptypes.Empty, ) (*ethpb.AttestationPoolResponse, error) { atts, err := bs.Pool.AttestationPoolNoVerify(ctx) @@ -138,7 +138,7 @@ func (bs *BeaconChainServer) AttestationPool( // provided as the filter criteria. The server may return an empty list when // no blocks in their database match the filter criteria. This RPC should // not return NOT_FOUND. Only one filter criteria should be used. -func (bs *BeaconChainServer) ListBlocks( +func (bs *Server) ListBlocks( ctx context.Context, req *ethpb.ListBlocksRequest, ) (*ethpb.ListBlocksResponse, error) { if int(req.PageSize) > params.BeaconConfig().MaxPageSize { @@ -218,7 +218,7 @@ func (bs *BeaconChainServer) ListBlocks( // // This includes the head block slot and root as well as information about // the most recent finalized and justified slots. -func (bs *BeaconChainServer) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) { +func (bs *Server) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) { finalizedCheckpoint := bs.HeadFetcher.HeadState().FinalizedCheckpoint justifiedCheckpoint := bs.HeadFetcher.HeadState().CurrentJustifiedCheckpoint prevJustifiedCheckpoint := bs.HeadFetcher.HeadState().PreviousJustifiedCheckpoint @@ -238,7 +238,7 @@ func (bs *BeaconChainServer) GetChainHead(ctx context.Context, _ *ptypes.Empty) // ListValidatorBalances retrieves the validator balances for a given set of public keys. // An optional Epoch parameter is provided to request historical validator balances from // archived, persistent data. -func (bs *BeaconChainServer) ListValidatorBalances( +func (bs *Server) ListValidatorBalances( ctx context.Context, req *ethpb.GetValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) { @@ -352,7 +352,7 @@ func (bs *BeaconChainServer) ListValidatorBalances( // GetValidators retrieves the current list of active validators with an optional historical epoch flag to // to retrieve validator set in time. -func (bs *BeaconChainServer) GetValidators( +func (bs *Server) GetValidators( ctx context.Context, req *ethpb.GetValidatorsRequest, ) (*ethpb.Validators, error) { @@ -404,7 +404,7 @@ func (bs *BeaconChainServer) GetValidators( // // This data includes any activations, voluntary exits, and involuntary // ejections. -func (bs *BeaconChainServer) GetValidatorActiveSetChanges( +func (bs *Server) GetValidatorActiveSetChanges( ctx context.Context, req *ethpb.GetValidatorActiveSetChangesRequest, ) (*ethpb.ActiveSetChanges, error) { headState := bs.HeadFetcher.HeadState() @@ -463,7 +463,7 @@ func (bs *BeaconChainServer) GetValidatorActiveSetChanges( } // GetValidatorQueue retrieves the current validator queue information. -func (bs *BeaconChainServer) GetValidatorQueue( +func (bs *Server) GetValidatorQueue( ctx context.Context, _ *ptypes.Empty, ) (*ethpb.ValidatorQueue, error) { headState := bs.HeadFetcher.HeadState() @@ -547,7 +547,7 @@ func (bs *BeaconChainServer) GetValidatorQueue( // ListValidatorAssignments retrieves the validator assignments for a given epoch, // optional validator indices or public keys may be included to filter validator assignments. -func (bs *BeaconChainServer) ListValidatorAssignments( +func (bs *Server) ListValidatorAssignments( ctx context.Context, req *ethpb.ListValidatorAssignmentsRequest, ) (*ethpb.ValidatorAssignments, error) { if int(req.PageSize) > params.BeaconConfig().MaxPageSize { @@ -761,7 +761,7 @@ func archivedProposerIndex(activeIndices []uint64, activeBalances []uint64, seed // GetValidatorParticipation retrieves the validator participation information for a given epoch, // it returns the information about validator's participation rate in voting on the proof of stake // rules based on their balance compared to the total active validator balance. -func (bs *BeaconChainServer) GetValidatorParticipation( +func (bs *Server) GetValidatorParticipation( ctx context.Context, req *ethpb.GetValidatorParticipationRequest, ) (*ethpb.ValidatorParticipationResponse, error) { headState := bs.HeadFetcher.HeadState() diff --git a/beacon-chain/rpc/beacon/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go index 68f3e683d727..88795c0029fb 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server_test.go @@ -23,7 +23,7 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" ) -func TestBeaconChainServer_ListAttestationsNoPagination(t *testing.T) { +func TestServer_ListAttestationsNoPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -45,7 +45,7 @@ func TestBeaconChainServer_ListAttestationsNoPagination(t *testing.T) { atts = append(atts, attExample) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -63,7 +63,7 @@ func TestBeaconChainServer_ListAttestationsNoPagination(t *testing.T) { } } -func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { +func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -127,7 +127,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -178,7 +178,7 @@ func TestBeaconChainServer_ListAttestations_FiltersCorrectly(t *testing.T) { } } -func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { +func TestServer_ListAttestationsPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -200,7 +200,7 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { atts = append(atts, attExample) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -336,7 +336,7 @@ func TestBeaconChainServer_ListAttestationsPagination(t *testing.T) { } } -func TestBeaconChainServer_ListAttestationsPaginationOutOfRange(t *testing.T) { +func TestServer_ListAttestationsPaginationOutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -357,7 +357,7 @@ func TestBeaconChainServer_ListAttestationsPaginationOutOfRange(t *testing.T) { atts = append(atts, attExample) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -374,9 +374,9 @@ func TestBeaconChainServer_ListAttestationsPaginationOutOfRange(t *testing.T) { } } -func TestBeaconChainServer_ListAttestationsExceedsMaxPageSize(t *testing.T) { +func TestServer_ListAttestationsExceedsMaxPageSize(t *testing.T) { ctx := context.Background() - bs := &BeaconChainServer{} + bs := &Server{} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) @@ -386,7 +386,7 @@ func TestBeaconChainServer_ListAttestationsExceedsMaxPageSize(t *testing.T) { } } -func TestBeaconChainServer_ListAttestationsDefaultPageSize(t *testing.T) { +func TestServer_ListAttestationsDefaultPageSize(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -408,7 +408,7 @@ func TestBeaconChainServer_ListAttestationsDefaultPageSize(t *testing.T) { atts = append(atts, attExample) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -430,12 +430,12 @@ func TestBeaconChainServer_ListAttestationsDefaultPageSize(t *testing.T) { } } -func TestBeaconChainServer_AttestationPool(t *testing.T) { +func TestServer_AttestationPool(t *testing.T) { ctx := context.Background() block := ðpb.BeaconBlock{ Slot: 10, } - bs := &BeaconChainServer{ + bs := &Server{ Pool: &mockOps.Operations{ Attestations: []*ethpb.Attestation{ { @@ -464,7 +464,7 @@ func TestBeaconChainServer_AttestationPool(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances_PaginationOutOfRange(t *testing.T) { +func TestServer_ListValidatorBalances_PaginationOutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -475,7 +475,7 @@ func TestBeaconChainServer_ListValidatorBalances_PaginationOutOfRange(t *testing t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -488,8 +488,8 @@ func TestBeaconChainServer_ListValidatorBalances_PaginationOutOfRange(t *testing } } -func TestBeaconChainServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { - bs := &BeaconChainServer{} +func TestServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf( @@ -503,7 +503,7 @@ func TestBeaconChainServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T } } -func TestBeaconChainServer_ListValidatorBalances_NoPagination(t *testing.T) { +func TestServer_ListValidatorBalances_NoPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -514,7 +514,7 @@ func TestBeaconChainServer_ListValidatorBalances_NoPagination(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{State: headState}, } @@ -584,7 +584,7 @@ func TestBeaconChainServer_ListValidatorBalances_NoPagination(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances_Pagination(t *testing.T) { +func TestServer_ListValidatorBalances_Pagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -596,7 +596,7 @@ func TestBeaconChainServer_ListValidatorBalances_Pagination(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -652,7 +652,7 @@ func TestBeaconChainServer_ListValidatorBalances_Pagination(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances_OutOfRange(t *testing.T) { +func TestServer_ListValidatorBalances_OutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) setupValidators(t, db, 1) @@ -662,7 +662,7 @@ func TestBeaconChainServer_ListValidatorBalances_OutOfRange(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{State: headState}, } @@ -674,7 +674,7 @@ func TestBeaconChainServer_ListValidatorBalances_OutOfRange(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances_FromArchive(t *testing.T) { +func TestServer_ListValidatorBalances_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -689,7 +689,7 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive(t *testing.T) { for i := 0; i < len(newerBalances); i++ { newerBalances[i] = balances[i] * 2 } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ @@ -722,7 +722,7 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive(t *testing.T) { } } -func TestBeaconChainServer_ListValidatorBalances_FromArchive_NewValidatorNotFound(t *testing.T) { +func TestServer_ListValidatorBalances_FromArchive_NewValidatorNotFound(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -734,7 +734,7 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive_NewValidatorNotFoun } newValidators, newBalances := setupValidators(t, db, 200) - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ @@ -754,7 +754,7 @@ func TestBeaconChainServer_ListValidatorBalances_FromArchive_NewValidatorNotFoun } } -func TestBeaconChainServer_GetValidators_NoPagination(t *testing.T) { +func TestServer_GetValidators_NoPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -764,7 +764,7 @@ func TestBeaconChainServer_GetValidators_NoPagination(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -785,7 +785,7 @@ func TestBeaconChainServer_GetValidators_NoPagination(t *testing.T) { } } -func TestBeaconChainServer_GetValidators_Pagination(t *testing.T) { +func TestServer_GetValidators_Pagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -797,7 +797,7 @@ func TestBeaconChainServer_GetValidators_Pagination(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -855,7 +855,7 @@ func TestBeaconChainServer_GetValidators_Pagination(t *testing.T) { } } -func TestBeaconChainServer_GetValidators_PaginationOutOfRange(t *testing.T) { +func TestServer_GetValidators_PaginationOutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -866,7 +866,7 @@ func TestBeaconChainServer_GetValidators_PaginationOutOfRange(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -884,8 +884,8 @@ func TestBeaconChainServer_GetValidators_PaginationOutOfRange(t *testing.T) { } } -func TestBeaconChainServer_GetValidators_ExceedsMaxPageSize(t *testing.T) { - bs := &BeaconChainServer{} +func TestServer_GetValidators_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) @@ -895,7 +895,7 @@ func TestBeaconChainServer_GetValidators_ExceedsMaxPageSize(t *testing.T) { } } -func TestBeaconChainServer_GetValidators_DefaultPageSize(t *testing.T) { +func TestServer_GetValidators_DefaultPageSize(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -905,7 +905,7 @@ func TestBeaconChainServer_GetValidators_DefaultPageSize(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -929,7 +929,7 @@ func TestBeaconChainServer_GetValidators_DefaultPageSize(t *testing.T) { } } -func TestBeaconChainServer_GetValidators_FromOldEpoch(t *testing.T) { +func TestServer_GetValidators_FromOldEpoch(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -941,7 +941,7 @@ func TestBeaconChainServer_GetValidators_FromOldEpoch(t *testing.T) { } } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{ Validators: validators, @@ -981,7 +981,7 @@ func TestBeaconChainServer_GetValidators_FromOldEpoch(t *testing.T) { } } -func TestBeaconChainServer_GetValidatorActiveSetChanges(t *testing.T) { +func TestServer_GetValidatorActiveSetChanges(t *testing.T) { ctx := context.Background() validators := make([]*ethpb.Validator, 6) headState := &pbp2p.BeaconState{ @@ -1013,7 +1013,7 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges(t *testing.T) { ExitEpoch: exitEpoch, } } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -1047,7 +1047,7 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges(t *testing.T) { } } -func TestBeaconChainServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T) { +func TestServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -1087,7 +1087,7 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T if err := db.SaveArchivedActiveValidatorChanges(ctx, 5, archivedChanges); err != nil { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: headState, @@ -1135,7 +1135,7 @@ func TestBeaconChainServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T } } -func TestBeaconChainServer_GetValidatorQueue_PendingActivation(t *testing.T) { +func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) { headState := &pbp2p.BeaconState{ Validators: []*ethpb.Validator{ { @@ -1158,7 +1158,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingActivation(t *testing.T) { Epoch: 0, }, } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -1185,7 +1185,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingActivation(t *testing.T) { } } -func TestBeaconChainServer_GetValidatorQueue_PendingExit(t *testing.T) { +func TestServer_GetValidatorQueue_PendingExit(t *testing.T) { headState := &pbp2p.BeaconState{ Validators: []*ethpb.Validator{ { @@ -1211,7 +1211,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingExit(t *testing.T) { Epoch: 0, }, } - bs := &BeaconChainServer{ + bs := &Server{ HeadFetcher: &mock.ChainService{ State: headState, }, @@ -1238,7 +1238,7 @@ func TestBeaconChainServer_GetValidatorQueue_PendingExit(t *testing.T) { } } -func TestBeaconChainServer_ListAssignmentsInputOutOfRange(t *testing.T) { +func TestServer_ListAssignmentsInputOutOfRange(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1248,7 +1248,7 @@ func TestBeaconChainServer_ListAssignmentsInputOutOfRange(t *testing.T) { if err != nil { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: headState, @@ -1266,8 +1266,8 @@ func TestBeaconChainServer_ListAssignmentsInputOutOfRange(t *testing.T) { } } -func TestBeaconChainServer_ListAssignmentsExceedsMaxPageSize(t *testing.T) { - bs := &BeaconChainServer{} +func TestServer_ListAssignmentsExceedsMaxPageSize(t *testing.T) { + bs := &Server{} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) @@ -1280,7 +1280,7 @@ func TestBeaconChainServer_ListAssignmentsExceedsMaxPageSize(t *testing.T) { } } -func TestBeaconChainServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T) { +func TestServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1326,7 +1326,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: s, @@ -1372,7 +1372,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T } } -func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing.T) { +func TestServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1425,7 +1425,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing // We tell the beacon chain server that our finalized epoch is 10 so that when // we request assignments for epoch 0, it looks within the archived data. - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: s, @@ -1495,7 +1495,7 @@ func TestBeaconChainServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing } } -func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *testing.T) { +func TestServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *testing.T) { helpers.ClearAllCaches() db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1528,7 +1528,7 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: s, @@ -1572,7 +1572,7 @@ func TestBeaconChainServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *t } } -func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination(t *testing.T) { +func TestServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination(t *testing.T) { helpers.ClearAllCaches() db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1605,7 +1605,7 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: s, @@ -1687,7 +1687,7 @@ func TestBeaconChainServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination } } -func TestBeaconChainServer_GetValidatorsParticipation_FromArchive(t *testing.T) { +func TestServer_GetValidatorsParticipation_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -1701,7 +1701,7 @@ func TestBeaconChainServer_GetValidatorsParticipation_FromArchive(t *testing.T) t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{ State: &pbp2p.BeaconState{Slot: helpers.StartSlot(epoch + 1)}, @@ -1746,7 +1746,7 @@ func TestBeaconChainServer_GetValidatorsParticipation_FromArchive(t *testing.T) } } -func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) { +func TestServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) { helpers.ClearAllCaches() db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -1781,7 +1781,7 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) CurrentJustifiedCheckpoint: ðpb.Checkpoint{}, } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, HeadFetcher: &mock.ChainService{State: s}, } @@ -1802,7 +1802,7 @@ func TestBeaconChainServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) } } -func TestBeaconChainServer_ListBlocksPagination(t *testing.T) { +func TestServer_ListBlocksPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() @@ -1824,7 +1824,7 @@ func TestBeaconChainServer_ListBlocksPagination(t *testing.T) { t.Fatal(err) } - bs := &BeaconChainServer{ + bs := &Server{ BeaconDB: db, } @@ -1896,12 +1896,12 @@ func TestBeaconChainServer_ListBlocksPagination(t *testing.T) { } } -func TestBeaconChainServer_ListBlocksErrors(t *testing.T) { +func TestServer_ListBlocksErrors(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() - bs := &BeaconChainServer{BeaconDB: db} + bs := &Server{BeaconDB: db} exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) @@ -1968,14 +1968,14 @@ func TestBeaconChainServer_ListBlocksErrors(t *testing.T) { } } -func TestBeaconChainServer_GetChainHead(t *testing.T) { +func TestServer_GetChainHead(t *testing.T) { s := &pbp2p.BeaconState{ PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: []byte{'A'}}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: []byte{'B'}}, FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 1, Root: []byte{'C'}}, } - bs := &BeaconChainServer{HeadFetcher: &mock.ChainService{State: s}} + bs := &Server{HeadFetcher: &mock.ChainService{State: s}} head, err := bs.GetChainHead(context.Background(), nil) if err != nil { diff --git a/beacon-chain/rpc/node/node_server.go b/beacon-chain/rpc/node/node_server.go index 13965dc77447..a1634ab551be 100644 --- a/beacon-chain/rpc/node/node_server.go +++ b/beacon-chain/rpc/node/node_server.go @@ -15,10 +15,10 @@ import ( "google.golang.org/grpc/status" ) -// NodeServer defines a server implementation of the gRPC Node service, +// Server defines a server implementation of the gRPC Node service, // providing RPC endpoints for verifying a beacon node's sync status, genesis and // version information, and services the node implements and runs. -type NodeServer struct { +type Server struct { SyncChecker sync.Checker Server *grpc.Server BeaconDB db.Database @@ -26,14 +26,14 @@ type NodeServer struct { } // GetSyncStatus checks the current network sync status of the node. -func (ns *NodeServer) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncStatus, error) { +func (ns *Server) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncStatus, error) { return ðpb.SyncStatus{ Syncing: ns.SyncChecker.Syncing(), }, nil } // GetGenesis fetches genesis chain information of Ethereum 2.0. -func (ns *NodeServer) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genesis, error) { +func (ns *Server) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genesis, error) { contractAddr, err := ns.BeaconDB.DepositContractAddress(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve contract address from db: %v", err) @@ -50,7 +50,7 @@ func (ns *NodeServer) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.G } // GetVersion checks the version information of the beacon node. -func (ns *NodeServer) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.Version, error) { +func (ns *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.Version, error) { return ðpb.Version{ Version: version.GetVersion(), }, nil @@ -61,7 +61,7 @@ func (ns *NodeServer) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.V // Any service not present in this list may return UNIMPLEMENTED or // PERMISSION_DENIED. The server may also support fetching services by grpc // reflection. -func (ns *NodeServer) ListImplementedServices(ctx context.Context, _ *ptypes.Empty) (*ethpb.ImplementedServices, error) { +func (ns *Server) ListImplementedServices(ctx context.Context, _ *ptypes.Empty) (*ethpb.ImplementedServices, error) { serviceInfo := ns.Server.GetServiceInfo() serviceNames := make([]string, 0, len(serviceInfo)) for svc := range serviceInfo { diff --git a/beacon-chain/rpc/node/node_server_test.go b/beacon-chain/rpc/node/node_server_test.go index 34955cc1c89a..be0cdbb1cfc8 100644 --- a/beacon-chain/rpc/node/node_server_test.go +++ b/beacon-chain/rpc/node/node_server_test.go @@ -19,7 +19,7 @@ import ( func TestNodeServer_GetSyncStatus(t *testing.T) { mSync := &mockSync.Sync{IsSyncing: false} - ns := &NodeServer{ + ns := &Server{ SyncChecker: mSync, } res, err := ns.GetSyncStatus(context.Background(), &ptypes.Empty{}) @@ -47,7 +47,7 @@ func TestNodeServer_GetGenesis(t *testing.T) { if err := db.SaveDepositContractAddress(ctx, addr); err != nil { t.Fatal(err) } - ns := &NodeServer{ + ns := &Server{ BeaconDB: db, GenesisTimeFetcher: &mock.ChainService{Genesis: time.Unix(0, 0)}, } @@ -69,7 +69,7 @@ func TestNodeServer_GetGenesis(t *testing.T) { func TestNodeServer_GetVersion(t *testing.T) { v := version.GetVersion() - ns := &NodeServer{} + ns := &Server{} res, err := ns.GetVersion(context.Background(), &ptypes.Empty{}) if err != nil { t.Fatal(err) @@ -81,7 +81,7 @@ func TestNodeServer_GetVersion(t *testing.T) { func TestNodeServer_GetImplementedServices(t *testing.T) { server := grpc.NewServer() - ns := &NodeServer{ + ns := &Server{ Server: server, } ethpb.RegisterNodeServer(server, ns) diff --git a/beacon-chain/rpc/proposer/proposer_server.go b/beacon-chain/rpc/proposer/proposer_server.go index 72a57dfe1785..32096613412e 100644 --- a/beacon-chain/rpc/proposer/proposer_server.go +++ b/beacon-chain/rpc/proposer/proposer_server.go @@ -36,10 +36,10 @@ func init() { log = logrus.WithField("prefix", "rpc/proposer") } -// ProposerServer defines a server implementation of the gRPC Proposer service, +// Server defines a server implementation of the gRPC Proposer service, // providing RPC endpoints for computing state transitions and state roots, proposing // beacon blocks to a beacon node, and more. -type ProposerServer struct { +type Server struct { BeaconDB db.Database HeadFetcher blockchain.HeadFetcher BlockReceiver blockchain.BlockReceiver @@ -56,7 +56,7 @@ type ProposerServer struct { // RequestBlock is called by a proposer during its assigned slot to request a block to sign // by passing in the slot and the signed randao reveal of the slot. -func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest) (*ethpb.BeaconBlock, error) { +func (ps *Server) RequestBlock(ctx context.Context, req *pb.BlockRequest) (*ethpb.BeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "ProposerServer.RequestBlock") defer span.End() span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot))) @@ -126,7 +126,7 @@ func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest // ProposeBlock is called by a proposer during its assigned slot to create a block in an attempt // to get it processed by the beacon node as the canonical head. -func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlock) (*pb.ProposeResponse, error) { +func (ps *Server) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlock) (*pb.ProposeResponse, error) { root, err := ssz.SigningRoot(blk) if err != nil { return nil, errors.Wrap(err, "could not tree hash block") @@ -146,7 +146,7 @@ func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlo // - Determine the most recent eth1 block before that timestamp. // - Subtract that eth1block.number by ETH1_FOLLOW_DISTANCE. // - This is the eth1block to use for the block proposal. -func (ps *ProposerServer) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth1Data, error) { +func (ps *Server) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth1Data, error) { if ps.MockEth1Votes || !ps.Eth1InfoFetcher.IsConnectedToETH1() { return ps.mockETH1DataVote(slot) } @@ -163,7 +163,7 @@ func (ps *ProposerServer) eth1Data(ctx context.Context, slot uint64) (*ethpb.Eth return ps.defaultEth1DataResponse(ctx, blockNumber) } -func (ps *ProposerServer) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) { +func (ps *Server) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) { log.Warn("Beacon Node is no longer connected to an ETH1 Chain, so " + "ETH1 Data votes are now mocked.") // If a mock eth1 data votes is specified, we use the following for the @@ -192,7 +192,7 @@ func (ps *ProposerServer) mockETH1DataVote(slot uint64) (*ethpb.Eth1Data, error) // computeStateRoot computes the state root after a block has been processed through a state transition and // returns it to the validator client. -func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.BeaconBlock) ([]byte, error) { +func (ps *Server) computeStateRoot(ctx context.Context, block *ethpb.BeaconBlock) ([]byte, error) { beaconState, err := ps.BeaconDB.HeadState(ctx) if err != nil { return nil, errors.Wrap(err, "could not retrieve beacon state") @@ -216,7 +216,7 @@ func (ps *ProposerServer) computeStateRoot(ctx context.Context, block *ethpb.Bea // this eth1data has enough support to be considered for deposits inclusion. If current vote has // enough support, then use that vote for basis of determining deposits, otherwise use current state // eth1data. -func (ps *ProposerServer) deposits(ctx context.Context, currentVote *ethpb.Eth1Data) ([]*ethpb.Deposit, error) { +func (ps *Server) deposits(ctx context.Context, currentVote *ethpb.Eth1Data) ([]*ethpb.Deposit, error) { if ps.MockEth1Votes || !ps.Eth1InfoFetcher.IsConnectedToETH1() { return []*ethpb.Deposit{}, nil } @@ -278,7 +278,7 @@ func (ps *ProposerServer) deposits(ctx context.Context, currentVote *ethpb.Eth1D } // canonicalEth1Data determines the canonical eth1data and eth1 block height to use for determining deposits. -func (ps *ProposerServer) canonicalEth1Data(ctx context.Context, beaconState *pbp2p.BeaconState, currentVote *ethpb.Eth1Data) (*ethpb.Eth1Data, *big.Int, error) { +func (ps *Server) canonicalEth1Data(ctx context.Context, beaconState *pbp2p.BeaconState, currentVote *ethpb.Eth1Data) (*ethpb.Eth1Data, *big.Int, error) { var eth1BlockHash [32]byte // Add in current vote, to get accurate vote tally @@ -306,7 +306,7 @@ func (ps *ProposerServer) canonicalEth1Data(ctx context.Context, beaconState *pb // default into returning the latest deposit root and the block // hash of eth1 block hash that is FOLLOW_DISTANCE back from its // latest block. -func (ps *ProposerServer) defaultEth1DataResponse(ctx context.Context, currentHeight *big.Int) (*ethpb.Eth1Data, error) { +func (ps *Server) defaultEth1DataResponse(ctx context.Context, currentHeight *big.Int) (*ethpb.Eth1Data, error) { eth1FollowDistance := int64(params.BeaconConfig().Eth1FollowDistance) ancestorHeight := big.NewInt(0).Sub(currentHeight, big.NewInt(eth1FollowDistance)) blockHash, err := ps.Eth1BlockFetcher.BlockHashByHeight(ctx, ancestorHeight) diff --git a/beacon-chain/rpc/proposer/proposer_server_test.go b/beacon-chain/rpc/proposer/proposer_server_test.go index ed228c0a9c7e..5d780457d033 100644 --- a/beacon-chain/rpc/proposer/proposer_server_test.go +++ b/beacon-chain/rpc/proposer/proposer_server_test.go @@ -57,7 +57,7 @@ func TestProposeBlock_OK(t *testing.T) { t.Fatalf("Could not save genesis state: %v", err) } - proposerServer := &ProposerServer{ + proposerServer := &Server{ BeaconDB: db, ChainStartFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -113,7 +113,7 @@ func TestComputeStateRoot_OK(t *testing.T) { t.Fatalf("Could not save genesis state: %v", err) } - proposerServer := &ProposerServer{ + proposerServer := &Server{ BeaconDB: db, ChainStartFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -197,7 +197,7 @@ func TestPendingDeposits_Eth1DataVoteOK(t *testing.T) { t.Fatal(err) } - bs := &ProposerServer{ + bs := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -346,7 +346,7 @@ func TestPendingDeposits_OutsideEth1FollowWindow(t *testing.T) { t.Fatal(err) } - bs := &ProposerServer{ + bs := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -490,7 +490,7 @@ func TestPendingDeposits_FollowsCorrectEth1Block(t *testing.T) { depositCache.InsertPendingDeposit(ctx, dp.Deposit, dp.Block, dp.Index, depositTrie.Root()) } - bs := &ProposerServer{ + bs := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -607,7 +607,7 @@ func TestPendingDeposits_CantReturnBelowStateEth1DepositIndex(t *testing.T) { depositCache.InsertPendingDeposit(ctx, dp.Deposit, big.NewInt(int64(dp.Index)), dp.Index, depositTrie.Root()) } - bs := &ProposerServer{ + bs := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -716,7 +716,7 @@ func TestPendingDeposits_CantReturnMoreThanMax(t *testing.T) { depositCache.InsertPendingDeposit(ctx, dp.Deposit, big.NewInt(int64(dp.Index)), dp.Index, depositTrie.Root()) } - bs := &ProposerServer{ + bs := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -823,7 +823,7 @@ func TestPendingDeposits_CantReturnMoreDepositCount(t *testing.T) { depositCache.InsertPendingDeposit(ctx, dp.Deposit, big.NewInt(int64(dp.Index)), dp.Index, depositTrie.Root()) } - bs := &ProposerServer{ + bs := &Server{ BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, ChainStartFetcher: p, @@ -858,7 +858,7 @@ func TestEth1Data_EmptyVotesFetchBlockHashFailure(t *testing.T) { p := &mockPOW.FaultyMockPOWChain{ HashesByHeight: make(map[int][]byte), } - proposerServer := &ProposerServer{ + proposerServer := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -913,7 +913,7 @@ func TestDefaultEth1Data_NoBlockExists(t *testing.T) { 476: []byte("hash1024"), }, } - proposerServer := &ProposerServer{ + proposerServer := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -955,7 +955,7 @@ func TestEth1Data(t *testing.T) { DepositCount: 55, }, } - ps := &ProposerServer{ + ps := &Server{ ChainStartFetcher: p, Eth1InfoFetcher: p, Eth1BlockFetcher: p, @@ -986,7 +986,7 @@ func TestEth1Data_MockEnabled(t *testing.T) { // BlockHash = hash(hash(current_epoch + slot_in_voting_period)), // ) ctx := context.Background() - ps := &ProposerServer{ + ps := &Server{ HeadFetcher: &mock.ChainService{State: &pbp2p.BeaconState{}}, BeaconDB: db, MockEth1Votes: true, @@ -1088,7 +1088,7 @@ func Benchmark_Eth1Data(b *testing.B) { LatestBlockNumber: big.NewInt(int64(currentHeight)), HashesByHeight: hashesByHeight, } - proposerServer := &ProposerServer{ + proposerServer := &Server{ BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, ChainStartFetcher: p, @@ -1189,7 +1189,7 @@ func TestDeposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t *testing depositCache.InsertPendingDeposit(ctx, dp.Deposit, big.NewInt(int64(dp.Index)), dp.Index, depositTrie.Root()) } - bs := &ProposerServer{ + bs := &Server{ BlockReceiver: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, HeadFetcher: &mock.ChainService{State: beaconState, Root: blkRoot[:]}, ChainStartFetcher: p, diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index 69eaa885838c..45ce8ddeba0a 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -18,11 +18,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" - att "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" - bs "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon" - ns "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node" - prop "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer" - val "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator" + "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester" + "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon" + "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node" + "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer" + "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator" "github.com/prysmaticlabs/prysm/beacon-chain/sync" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" @@ -169,7 +169,7 @@ func (s *Service) Start() { } s.grpcServer = grpc.NewServer(opts...) - proposerServer := &prop.ProposerServer{ + proposerServer := &proposer.Server{ BeaconDB: s.beaconDB, HeadFetcher: s.headFetcher, BlockReceiver: s.blockReceiver, @@ -183,7 +183,7 @@ func (s *Service) Start() { PendingDepositsFetcher: s.pendingDepositFetcher, SyncChecker: s.syncService, } - attesterServer := &att.AttesterServer{ + attesterServer := &attester.Server{ P2p: s.p2p, BeaconDB: s.beaconDB, OperationsHandler: s.operationsHandler, @@ -192,7 +192,7 @@ func (s *Service) Start() { AttestationCache: cache.NewAttestationCache(), SyncChecker: s.syncService, } - validatorServer := &val.ValidatorServer{ + validatorServer := &validator.Server{ Ctx: s.ctx, BeaconDB: s.beaconDB, HeadFetcher: s.headFetcher, @@ -206,13 +206,13 @@ func (s *Service) Start() { StateFeedListener: s.stateFeedListener, ChainStartChan: make(chan time.Time), } - nodeServer := &ns.NodeServer{ + nodeServer := &node.Server{ BeaconDB: s.beaconDB, Server: s.grpcServer, SyncChecker: s.syncService, GenesisTimeFetcher: s.genesisTimeFetcher, } - beaconChainServer := &bs.BeaconChainServer{ + beaconChainServer := &beacon.Server{ BeaconDB: s.beaconDB, Pool: s.attestationsPool, HeadFetcher: s.headFetcher, diff --git a/beacon-chain/rpc/validator/validator_server.go b/beacon-chain/rpc/validator/validator_server.go index 8a4cc273dd70..f9daca1d0ee0 100644 --- a/beacon-chain/rpc/validator/validator_server.go +++ b/beacon-chain/rpc/validator/validator_server.go @@ -30,11 +30,11 @@ func init() { log = logrus.WithField("prefix", "rpc/validator") } -// ValidatorServer defines a server implementation of the gRPC Validator service, +// Server defines a server implementation of the gRPC Validator service, // providing RPC endpoints for obtaining validator assignments per epoch, the slots // and committees in which particular validators need to perform their responsibilities, // and more. -type ValidatorServer struct { +type Server struct { Ctx context.Context BeaconDB db.Database HeadFetcher blockchain.HeadFetcher @@ -52,7 +52,7 @@ type ValidatorServer struct { // WaitForActivation checks if a validator public key exists in the active validator registry of the current // beacon state, if not, then it creates a stream which listens for canonical states which contain // the validator with the public key as an active validator record. -func (vs *ValidatorServer) WaitForActivation(req *pb.ValidatorActivationRequest, stream pb.ValidatorService_WaitForActivationServer) error { +func (vs *Server) WaitForActivation(req *pb.ValidatorActivationRequest, stream pb.ValidatorService_WaitForActivationServer) error { activeValidatorExists, validatorStatuses, err := vs.multipleValidatorStatus(stream.Context(), req.PublicKeys) if err != nil { return err @@ -92,7 +92,7 @@ func (vs *ValidatorServer) WaitForActivation(req *pb.ValidatorActivationRequest, } // ValidatorIndex is called by a validator to get its index location in the beacon state. -func (vs *ValidatorServer) ValidatorIndex(ctx context.Context, req *pb.ValidatorIndexRequest) (*pb.ValidatorIndexResponse, error) { +func (vs *Server) ValidatorIndex(ctx context.Context, req *pb.ValidatorIndexRequest) (*pb.ValidatorIndexResponse, error) { index, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(req.PublicKey)) if err != nil { return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) @@ -106,7 +106,7 @@ func (vs *ValidatorServer) ValidatorIndex(ctx context.Context, req *pb.Validator // ValidatorPerformance reports the validator's latest balance along with other important metrics on // rewards and penalties throughout its lifecycle in the beacon chain. -func (vs *ValidatorServer) ValidatorPerformance( +func (vs *Server) ValidatorPerformance( ctx context.Context, req *pb.ValidatorPerformanceRequest, ) (*pb.ValidatorPerformanceResponse, error) { var err error @@ -157,7 +157,7 @@ func (vs *ValidatorServer) ValidatorPerformance( // 2.) The shard to which the committee is assigned. // 3.) The slot at which the committee is assigned. // 4.) The bool signaling if the validator is expected to propose a block at the assigned slot. -func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error) { +func (vs *Server) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error) { if vs.SyncChecker.Syncing() { return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") } @@ -206,7 +206,7 @@ func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.Assi }, nil } -func (vs *ValidatorServer) assignment(idx uint64, beaconState *pbp2p.BeaconState, epoch uint64) (*pb.AssignmentResponse_ValidatorAssignment, error) { +func (vs *Server) assignment(idx uint64, beaconState *pbp2p.BeaconState, epoch uint64) (*pb.AssignmentResponse_ValidatorAssignment, error) { committee, committeeIndex, aSlot, pSlot, err := helpers.CommitteeAssignment(beaconState, epoch, idx) if err != nil { return nil, err @@ -229,7 +229,7 @@ func (vs *ValidatorServer) assignment(idx uint64, beaconState *pbp2p.BeaconState // WITHDRAWABLE - validator's deposit can be withdrawn after lock up period. // EXITED - validator has exited, means the deposit has been withdrawn. // EXITED_SLASHED - validator was forcefully exited due to slashing. -func (vs *ValidatorServer) ValidatorStatus( +func (vs *Server) ValidatorStatus( ctx context.Context, req *pb.ValidatorIndexRequest) (*pb.ValidatorStatusResponse, error) { headState := vs.HeadFetcher.HeadState() @@ -238,7 +238,7 @@ func (vs *ValidatorServer) ValidatorStatus( // multipleValidatorStatus returns the validator status response for the set of validators // requested by their pub keys. -func (vs *ValidatorServer) multipleValidatorStatus( +func (vs *Server) multipleValidatorStatus( ctx context.Context, pubkeys [][]byte) (bool, []*pb.ValidatorActivationResponse_Status, error) { headState := vs.HeadFetcher.HeadState() @@ -270,7 +270,7 @@ func (vs *ValidatorServer) multipleValidatorStatus( // ExitedValidators queries validator statuses for a give list of validators // and returns a filtered list of validator keys that are exited. -func (vs *ValidatorServer) ExitedValidators( +func (vs *Server) ExitedValidators( ctx context.Context, req *pb.ExitedValidatorsRequest) (*pb.ExitedValidatorsResponse, error) { @@ -297,7 +297,7 @@ func (vs *ValidatorServer) ExitedValidators( } // DomainData fetches the current domain version information from the beacon state. -func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainRequest) (*pb.DomainResponse, error) { +func (vs *Server) DomainData(ctx context.Context, request *pb.DomainRequest) (*pb.DomainResponse, error) { fork := vs.ForkFetcher.CurrentFork() dv := helpers.Domain(fork, request.Epoch, request.Domain) return &pb.DomainResponse{ @@ -305,7 +305,7 @@ func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainReq }, nil } -func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { +func (vs *Server) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { if !vs.Eth1InfoFetcher.IsConnectedToETH1() { vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) if err != nil { @@ -372,7 +372,7 @@ func (vs *ValidatorServer) validatorStatus(ctx context.Context, pubKey []byte, h } } -func (vs *ValidatorServer) retrieveStatusFromState(ctx context.Context, pubKey []byte, +func (vs *Server) retrieveStatusFromState(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) (pb.ValidatorStatus, uint64, error) { if headState == nil { return pb.ValidatorStatus(0), 0, errors.New("head state does not exist") @@ -387,7 +387,7 @@ func (vs *ValidatorServer) retrieveStatusFromState(ctx context.Context, pubKey [ return vs.assignmentStatus(uint64(idx), headState), uint64(idx), nil } -func (vs *ValidatorServer) assignmentStatus(validatorIdx uint64, beaconState *pbp2p.BeaconState) pb.ValidatorStatus { +func (vs *Server) assignmentStatus(validatorIdx uint64, beaconState *pbp2p.BeaconState) pb.ValidatorStatus { var status pb.ValidatorStatus v := beaconState.Validators[validatorIdx] epoch := helpers.CurrentEpoch(beaconState) @@ -414,7 +414,7 @@ func (vs *ValidatorServer) assignmentStatus(validatorIdx uint64, beaconState *pb // CanonicalHead of the current beacon chain. This method is requested on-demand // by a validator when it is their time to propose or attest. -func (vs *ValidatorServer) CanonicalHead(ctx context.Context, req *ptypes.Empty) (*ethpb.BeaconBlock, error) { +func (vs *Server) CanonicalHead(ctx context.Context, req *ptypes.Empty) (*ethpb.BeaconBlock, error) { return vs.HeadFetcher.HeadBlock(), nil } @@ -422,7 +422,7 @@ func (vs *ValidatorServer) CanonicalHead(ctx context.Context, req *ptypes.Empty) // has started its runtime and validators begin their responsibilities. If it has not, it then // subscribes to an event stream triggered by the powchain service whenever the ChainStart log does // occur in the Deposit Contract on ETH 1.0. -func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.ValidatorService_WaitForChainStartServer) error { +func (vs *Server) WaitForChainStart(req *ptypes.Empty, stream pb.ValidatorService_WaitForChainStartServer) error { head, err := vs.BeaconDB.HeadState(context.Background()) if err != nil { return err @@ -454,7 +454,7 @@ func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.Valida } } -func (vs *ValidatorServer) depositBlockSlot(ctx context.Context, currentSlot uint64, +func (vs *Server) depositBlockSlot(ctx context.Context, currentSlot uint64, eth1BlockNumBigInt *big.Int, beaconState *pbp2p.BeaconState) (uint64, error) { blockTimeStamp, err := vs.BlockFetcher.BlockTimeByHeight(ctx, eth1BlockNumBigInt) if err != nil { diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go index 2abeb3aac631..5a03ec28bf45 100644 --- a/beacon-chain/rpc/validator/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -50,14 +50,14 @@ func TestValidatorIndex_OK(t *testing.T) { t.Fatalf("Could not save validator index: %v", err) } - validatorServer := &ValidatorServer{ + Server := &Server{ BeaconDB: db, } req := &pb.ValidatorIndexRequest{ PublicKey: pubKey, } - if _, err := validatorServer.ValidatorIndex(context.Background(), req); err != nil { + if _, err := Server.ValidatorIndex(context.Background(), req); err != nil { t.Errorf("Could not get validator index: %v", err) } } @@ -82,7 +82,7 @@ func TestNextEpochCommitteeAssignment_WrongPubkeyLength(t *testing.T) { t.Fatalf("Could not get signing root %v", err) } - validatorServer := &ValidatorServer{ + Server := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, SyncChecker: &mockSync.Sync{IsSyncing: false}, @@ -92,7 +92,7 @@ func TestNextEpochCommitteeAssignment_WrongPubkeyLength(t *testing.T) { EpochStart: 0, } want := fmt.Sprintf("expected public key to have length %d", params.BeaconConfig().BLSPubkeyLength) - if _, err := validatorServer.CommitteeAssignment(context.Background(), req); err != nil && !strings.Contains(err.Error(), want) { + if _, err := Server.CommitteeAssignment(context.Background(), req); err != nil && !strings.Contains(err.Error(), want) { t.Errorf("Expected %v, received %v", want, err) } } @@ -112,7 +112,7 @@ func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { t.Fatalf("Could not get signing root %v", err) } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, SyncChecker: &mockSync.Sync{IsSyncing: false}, @@ -166,7 +166,7 @@ func TestCommitteeAssignment_OK(t *testing.T) { } } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, SyncChecker: &mockSync.Sync{IsSyncing: false}, @@ -241,7 +241,7 @@ func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { } } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, SyncChecker: &mockSync.Sync{IsSyncing: false}, @@ -296,7 +296,7 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { } } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, SyncChecker: &mockSync.Sync{IsSyncing: false}, @@ -321,7 +321,7 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { } func TestCommitteeAssignment_SyncNotReady(t *testing.T) { - vs := &ValidatorServer{ + vs := &Server{ SyncChecker: &mockSync.Sync{IsSyncing: true}, } _, err := vs.CommitteeAssignment(context.Background(), &pb.AssignmentRequest{}) @@ -356,7 +356,7 @@ func TestValidatorStatus_DepositReceived(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, DepositFetcher: depositCache, BlockFetcher: p, @@ -432,7 +432,7 @@ func TestValidatorStatus_PendingActive(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, BlockFetcher: p, @@ -508,7 +508,7 @@ func TestValidatorStatus_Active(t *testing.T) { int(params.BeaconConfig().Eth1FollowDistance): uint64(timestamp), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, BlockFetcher: p, @@ -588,7 +588,7 @@ func TestValidatorStatus_InitiatedExit(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, BlockFetcher: p, @@ -658,7 +658,7 @@ func TestValidatorStatus_Withdrawable(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, BlockFetcher: p, @@ -728,7 +728,7 @@ func TestValidatorStatus_ExitedSlashed(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, Eth1InfoFetcher: p, @@ -799,7 +799,7 @@ func TestValidatorStatus_Exited(t *testing.T) { 0: uint64(height), }, } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, ChainStartFetcher: p, Eth1InfoFetcher: p, @@ -824,7 +824,7 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) { defer dbutil.TeardownDB(t, db) pubKey := []byte{'A'} depositCache := depositcache.NewDepositCache() - vs := &ValidatorServer{ + vs := &Server{ DepositFetcher: depositCache, Eth1InfoFetcher: &mockPOW.POWChain{}, HeadFetcher: &mockChain.ChainService{ @@ -864,7 +864,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { } ctx, cancel := context.WithCancel(context.Background()) - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, Ctx: ctx, ChainStartFetcher: &mockPOW.POWChain{}, @@ -968,7 +968,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey2), 1); err != nil { t.Fatalf("could not save validator index: %v", err) } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, Ctx: context.Background(), CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), @@ -1082,7 +1082,7 @@ func TestMultipleValidatorStatus_OK(t *testing.T) { if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[2]), 2); err != nil { t.Fatalf("could not save validator index: %v", err) } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, Ctx: context.Background(), CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), @@ -1121,7 +1121,7 @@ func TestWaitForChainStart_ContextClosed(t *testing.T) { ctx := context.Background() ctx, cancel := context.WithCancel(context.Background()) - validatorServer := &ValidatorServer{ + Server := &Server{ Ctx: ctx, ChainStartFetcher: &mockPOW.FaultyMockPOWChain{ ChainFeed: new(event.Feed), @@ -1135,7 +1135,7 @@ func TestWaitForChainStart_ContextClosed(t *testing.T) { defer ctrl.Finish() mockStream := mockRPC.NewMockValidatorService_WaitForChainStartServer(ctrl) go func(tt *testing.T) { - if err := validatorServer.WaitForChainStart(&ptypes.Empty{}, mockStream); !strings.Contains(err.Error(), "context closed") { + if err := Server.WaitForChainStart(&ptypes.Empty{}, mockStream); !strings.Contains(err.Error(), "context closed") { tt.Errorf("Could not call RPC method: %v", err) } <-exitRoutine @@ -1156,7 +1156,7 @@ func TestWaitForChainStart_AlreadyStarted(t *testing.T) { t.Fatal(err) } - validatorServer := &ValidatorServer{ + Server := &Server{ Ctx: context.Background(), ChainStartFetcher: &mockPOW.POWChain{ ChainFeed: new(event.Feed), @@ -1173,7 +1173,7 @@ func TestWaitForChainStart_AlreadyStarted(t *testing.T) { GenesisTime: uint64(time.Unix(0, 0).Unix()), }, ).Return(nil) - if err := validatorServer.WaitForChainStart(&ptypes.Empty{}, mockStream); err != nil { + if err := Server.WaitForChainStart(&ptypes.Empty{}, mockStream); err != nil { t.Errorf("Could not call RPC method: %v", err) } } @@ -1183,7 +1183,7 @@ func TestWaitForChainStart_NotStartedThenLogFired(t *testing.T) { defer dbutil.TeardownDB(t, db) hook := logTest.NewGlobal() - validatorServer := &ValidatorServer{ + Server := &Server{ Ctx: context.Background(), ChainStartChan: make(chan time.Time, 1), ChainStartFetcher: &mockPOW.FaultyMockPOWChain{ @@ -1203,12 +1203,12 @@ func TestWaitForChainStart_NotStartedThenLogFired(t *testing.T) { }, ).Return(nil) go func(tt *testing.T) { - if err := validatorServer.WaitForChainStart(&ptypes.Empty{}, mockStream); err != nil { + if err := Server.WaitForChainStart(&ptypes.Empty{}, mockStream); err != nil { tt.Errorf("Could not call RPC method: %v", err) } <-exitRoutine }(t) - validatorServer.ChainStartChan <- time.Unix(0, 0) + Server.ChainStartChan <- time.Unix(0, 0) exitRoutine <- true testutil.AssertLogsContain(t, hook, "Sending genesis time") } @@ -1251,7 +1251,7 @@ func BenchmarkAssignment(b *testing.B) { } } - vs := &ValidatorServer{ + vs := &Server{ BeaconDB: db, HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, } From 386e90ba8ba8c4c1deb2865aaa99a2ebc6c70262 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 17:06:06 -0600 Subject: [PATCH 48/82] test fix --- beacon-chain/rpc/node/node_server_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/node/node_server_test.go b/beacon-chain/rpc/node/node_server_test.go index be0cdbb1cfc8..3fd0cf6f675f 100644 --- a/beacon-chain/rpc/node/node_server_test.go +++ b/beacon-chain/rpc/node/node_server_test.go @@ -26,7 +26,7 @@ func TestNodeServer_GetSyncStatus(t *testing.T) { if err != nil { t.Fatal(err) } - if !res.Syncing { + if res.Syncing { t.Errorf("Wanted GetSyncStatus() = %v, received %v", false, res.Syncing) } ns.SyncChecker = &mockSync.Sync{IsSyncing: true} @@ -34,7 +34,7 @@ func TestNodeServer_GetSyncStatus(t *testing.T) { if err != nil { t.Fatal(err) } - if res.Syncing { + if !res.Syncing { t.Errorf("Wanted GetSyncStatus() = %v, received %v", true, res.Syncing) } } From 018f2c609089dc27dff784b4156d72732cd84c74 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 17:09:03 -0600 Subject: [PATCH 49/82] proper viz --- beacon-chain/rpc/attester/BUILD.bazel | 2 +- beacon-chain/rpc/beacon/BUILD.bazel | 2 +- beacon-chain/rpc/node/BUILD.bazel | 2 +- beacon-chain/rpc/proposer/BUILD.bazel | 2 +- beacon-chain/rpc/validator/BUILD.bazel | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/beacon-chain/rpc/attester/BUILD.bazel b/beacon-chain/rpc/attester/BUILD.bazel index 2c1b76d67482..9d31ee5e7c80 100644 --- a/beacon-chain/rpc/attester/BUILD.bazel +++ b/beacon-chain/rpc/attester/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "go_default_library", srcs = ["attester_server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester", - visibility = ["//visibility:public"], + visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache:go_default_library", diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index ce7c90cf3bc1..3cb39e32d592 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "go_default_library", srcs = ["beacon_chain_server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon", - visibility = ["//visibility:public"], + visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/epoch:go_default_library", diff --git a/beacon-chain/rpc/node/BUILD.bazel b/beacon-chain/rpc/node/BUILD.bazel index d131217dfd4f..f8567290a9fd 100644 --- a/beacon-chain/rpc/node/BUILD.bazel +++ b/beacon-chain/rpc/node/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "go_default_library", srcs = ["node_server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node", - visibility = ["//visibility:public"], + visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/db:go_default_library", diff --git a/beacon-chain/rpc/proposer/BUILD.bazel b/beacon-chain/rpc/proposer/BUILD.bazel index db471e6a0190..fceeb69bc30f 100644 --- a/beacon-chain/rpc/proposer/BUILD.bazel +++ b/beacon-chain/rpc/proposer/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "go_default_library", srcs = ["proposer_server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer", - visibility = ["//visibility:public"], + visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index c737ec2d6675..0c2653282e1f 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "go_default_library", srcs = ["validator_server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator", - visibility = ["//visibility:public"], + visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", From f028119aae0ef2137faf3fe5f60f525c3a42f392 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 17:26:26 -0600 Subject: [PATCH 50/82] naming --- beacon-chain/rpc/beacon/beacon_chain_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/rpc/beacon/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go index 88795c0029fb..2fafda1bfc20 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server_test.go @@ -1802,7 +1802,7 @@ func TestServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) { } } -func TestServer_ListBlocksPagination(t *testing.T) { +func TestServer_ListBlocks_Pagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) ctx := context.Background() From 1392f118a0066a19d1e5faf5d9cceba24df91e2e Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 20:19:44 -0600 Subject: [PATCH 51/82] resolved timeout due to config values --- beacon-chain/rpc/validator/validator_server_test.go | 8 ++++---- proto/eth/v1alpha1/slasher.pb.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go index 5a03ec28bf45..a7486000ba5f 100644 --- a/beacon-chain/rpc/validator/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -101,7 +101,7 @@ func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { db := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, db) ctx := context.Background() - deposits, _, _ := testutil.SetupInitialDeposits(t, params.BeaconConfig().MinGenesisActiveValidatorCount) + deposits, _, _ := testutil.SetupInitialDeposits(t, 10) beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { t.Fatalf("Could not setup genesis state: %v", err) @@ -136,7 +136,7 @@ func TestCommitteeAssignment_OK(t *testing.T) { ctx := context.Background() genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 + depChainStart := uint64(64) deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) @@ -209,7 +209,7 @@ func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { ctx := context.Background() genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 + depChainStart := uint64(64) deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) @@ -267,7 +267,7 @@ func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { ctx := context.Background() genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := params.BeaconConfig().MinGenesisActiveValidatorCount / 16 + depChainStart := uint64(64) deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) if err != nil { diff --git a/proto/eth/v1alpha1/slasher.pb.go b/proto/eth/v1alpha1/slasher.pb.go index bea45b2430d6..655f144a5e7e 100755 --- a/proto/eth/v1alpha1/slasher.pb.go +++ b/proto/eth/v1alpha1/slasher.pb.go @@ -818,7 +818,7 @@ func (m *EpochSpanMap) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if len(m.EpochSpanMap) > 0 { - for k, _ := range m.EpochSpanMap { + for k := range m.EpochSpanMap { dAtA[i] = 0xa i++ v := m.EpochSpanMap[k] From e9d3b0538b2c8a88d56d081e668a1c37135f9e98 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 20:24:48 -0600 Subject: [PATCH 52/82] init use minimal --- beacon-chain/rpc/attester/attester_server_test.go | 5 +++++ beacon-chain/rpc/beacon/beacon_chain_server_test.go | 5 +++++ beacon-chain/rpc/validator/validator_server_test.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/beacon-chain/rpc/attester/attester_server_test.go b/beacon-chain/rpc/attester/attester_server_test.go index b0c640da9acc..f6dcc7278d74 100644 --- a/beacon-chain/rpc/attester/attester_server_test.go +++ b/beacon-chain/rpc/attester/attester_server_test.go @@ -22,6 +22,11 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" ) +func init() { + // Use minimal config to reduce test setup time. + params.OverrideBeaconConfig(params.MinimalSpecConfig()) +} + func TestSubmitAttestation_OK(t *testing.T) { db := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, db) diff --git a/beacon-chain/rpc/beacon/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go index 2fafda1bfc20..b26d7a811f4f 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server_test.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server_test.go @@ -23,6 +23,11 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" ) +func init() { + // Use minimal config to reduce test setup time. + params.OverrideBeaconConfig(params.MinimalSpecConfig()) +} + func TestServer_ListAttestationsNoPagination(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go index a7486000ba5f..075f6c322ad7 100644 --- a/beacon-chain/rpc/validator/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -37,6 +37,11 @@ import ( logTest "github.com/sirupsen/logrus/hooks/test" ) +func init() { + // Use minimal config to reduce test setup time. + params.OverrideBeaconConfig(params.MinimalSpecConfig()) +} + func TestValidatorIndex_OK(t *testing.T) { db := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, db) From 629320dcf5f2a9e18008d00e95392b4c9d3c8374 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 20:43:07 -0600 Subject: [PATCH 53/82] added all subfiles --- beacon-chain/rpc/beacon/assignments.go | 229 +++++ beacon-chain/rpc/beacon/attestations.go | 104 +++ .../rpc/beacon/beacon_chain_server.go | 801 ------------------ beacon-chain/rpc/beacon/blocks.go | 117 +++ beacon-chain/rpc/beacon/validators.go | 399 +++++++++ 5 files changed, 849 insertions(+), 801 deletions(-) create mode 100644 beacon-chain/rpc/beacon/assignments.go create mode 100644 beacon-chain/rpc/beacon/attestations.go create mode 100644 beacon-chain/rpc/beacon/blocks.go create mode 100644 beacon-chain/rpc/beacon/validators.go diff --git a/beacon-chain/rpc/beacon/assignments.go b/beacon-chain/rpc/beacon/assignments.go new file mode 100644 index 000000000000..7d65b905812e --- /dev/null +++ b/beacon-chain/rpc/beacon/assignments.go @@ -0,0 +1,229 @@ +package beacon + +import ( + "context" + "fmt" + + "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + 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" + "google.golang.org/grpc/status" +) + +// ListValidatorAssignments retrieves the validator assignments for a given epoch, +// optional validator indices or public keys may be included to filter validator assignments. +func (bs *Server) ListValidatorAssignments( + ctx context.Context, req *ethpb.ListValidatorAssignmentsRequest, +) (*ethpb.ValidatorAssignments, error) { + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + + var res []*ethpb.ValidatorAssignments_CommitteeAssignment + headState := bs.HeadFetcher.HeadState() + filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. + filteredIndices := make([]uint64, 0) + requestedEpoch := helpers.CurrentEpoch(headState) + + switch q := req.QueryFilter.(type) { + case *ethpb.ListValidatorAssignmentsRequest_Genesis: + if q.Genesis { + requestedEpoch = 0 + } + case *ethpb.ListValidatorAssignmentsRequest_Epoch: + requestedEpoch = q.Epoch + } + + // Filter out assignments by public keys. + for _, pubKey := range req.PublicKeys { + index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) + } + if !ok { + return nil, status.Errorf(codes.NotFound, "could not find validator index for public key %#x not found", pubKey) + } + filtered[index] = true + filteredIndices = append(filteredIndices, index) + } + + // Filter out assignments by validator indices. + for _, index := range req.Indices { + if !filtered[index] { + filteredIndices = append(filteredIndices, index) + } + } + + activeIndices, err := helpers.ActiveValidatorIndices(headState, requestedEpoch) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve active validator indices: %v", err) + } + if len(filteredIndices) == 0 { + // If no filter was specified, return assignments from active validator indices with pagination. + filteredIndices = activeIndices + } + + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), len(filteredIndices)) + if err != nil { + return nil, err + } + + shouldFetchFromArchive := requestedEpoch < bs.FinalizationFetcher.FinalizedCheckpt().Epoch + + for _, index := range filteredIndices[start:end] { + if int(index) >= len(headState.Validators) { + return nil, status.Errorf(codes.InvalidArgument, "validator index %d >= validator count %d", + index, len(headState.Validators)) + } + if shouldFetchFromArchive { + archivedInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) + if err != nil { + return nil, status.Errorf( + codes.Internal, + "could not retrieve archived committee info for epoch %d", + requestedEpoch, + ) + } + if archivedInfo == nil { + return nil, status.Errorf( + codes.NotFound, + "no archival committee info found for epoch %d", + requestedEpoch, + ) + } + archivedBalances, err := bs.BeaconDB.ArchivedBalances(ctx, requestedEpoch) + if err != nil { + return nil, status.Errorf( + codes.Internal, + "could not retrieve archived balances for epoch %d", + requestedEpoch, + ) + } + 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 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 + } + 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{ + Epoch: requestedEpoch, + Assignments: res, + NextPageToken: nextPageToken, + TotalSize: int32(len(filteredIndices)), + }, nil +} + +// Computes validator assignments for an epoch and validator index using archived committee +// information, archived balances, and a set of active validators. +func archivedValidatorCommittee( + epoch uint64, + validatorIndex uint64, + archivedInfo *ethpb.ArchivedCommitteeInfo, + activeIndices []uint64, + archivedBalances []uint64, +) ([]uint64, uint64, uint64, uint64, error) { + committeeCount := archivedInfo.CommitteeCount + 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++ { + 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, 0, errors.Wrap(err, "could not compute committee") + } + for _, index := range committee { + if validatorIndex == index { + proposerSlot, _ := proposerIndexToSlot[validatorIndex] + return committee, i, slot, proposerSlot, nil + } + } + } + } + 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 + } + } +} diff --git a/beacon-chain/rpc/beacon/attestations.go b/beacon-chain/rpc/beacon/attestations.go new file mode 100644 index 000000000000..2a62252bcb8f --- /dev/null +++ b/beacon-chain/rpc/beacon/attestations.go @@ -0,0 +1,104 @@ +package beacon + +import ( + "context" + "sort" + + ptypes "github.com/gogo/protobuf/types" + "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/pagination" + "github.com/prysmaticlabs/prysm/shared/params" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// sortableAttestations implements the Sort interface to sort attestations +// 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.Slot < s[j].Data.Slot +} + +// ListAttestations retrieves attestations by block root, slot, or epoch. +// 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 +// criteria should be used. +func (bs *Server) ListAttestations( + ctx context.Context, req *ethpb.ListAttestationsRequest, +) (*ethpb.ListAttestationsResponse, error) { + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + var atts []*ethpb.Attestation + var err error + switch q := req.QueryFilter.(type) { + case *ethpb.ListAttestationsRequest_HeadBlockRoot: + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetHeadBlockRoot(q.HeadBlockRoot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + case *ethpb.ListAttestationsRequest_SourceEpoch: + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceEpoch(q.SourceEpoch)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + case *ethpb.ListAttestationsRequest_SourceRoot: + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceRoot(q.SourceRoot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + case *ethpb.ListAttestationsRequest_TargetEpoch: + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetEpoch(q.TargetEpoch)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + case *ethpb.ListAttestationsRequest_TargetRoot: + atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetRoot(q.TargetRoot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + default: + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + // We sort attestations according to the Sortable interface. + sort.Sort(sortableAttestations(atts)) + numAttestations := len(atts) + + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numAttestations) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not paginate attestations: %v", err) + } + return ðpb.ListAttestationsResponse{ + Attestations: atts[start:end], + TotalSize: int32(numAttestations), + NextPageToken: nextPageToken, + }, nil +} + +// AttestationPool retrieves pending attestations. +// +// The server returns a list of attestations that have been seen but not +// yet processed. Pool attestations eventually expire as the slot +// advances, so an attestation missing from this request does not imply +// that it was included in a block. The attestation may have expired. +// Refer to the ethereum 2.0 specification for more details on how +// attestations are processed and when they are no longer valid. +// https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestations +func (bs *Server) AttestationPool( + ctx context.Context, _ *ptypes.Empty, +) (*ethpb.AttestationPoolResponse, error) { + atts, err := bs.Pool.AttestationPoolNoVerify(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) + } + return ðpb.AttestationPoolResponse{ + Attestations: atts, + }, nil +} diff --git a/beacon-chain/rpc/beacon/beacon_chain_server.go b/beacon-chain/rpc/beacon/beacon_chain_server.go index 2f347f88debd..c26705b109a6 100644 --- a/beacon-chain/rpc/beacon/beacon_chain_server.go +++ b/beacon-chain/rpc/beacon/beacon_chain_server.go @@ -2,28 +2,14 @@ package beacon import ( "context" - "fmt" - "sort" "time" - ptypes "github.com/gogo/protobuf/types" - "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" - "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/db" - "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/beacon-chain/operations" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" 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" - "google.golang.org/grpc/status" ) // Server defines a server implementation of the gRPC Beacon Chain service, @@ -41,790 +27,3 @@ type Server struct { CanonicalStateChan chan *pbp2p.BeaconState ChainStartChan chan time.Time } - -// sortableAttestations implements the Sort interface to sort attestations -// 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.Slot < s[j].Data.Slot -} - -// ListAttestations retrieves attestations by block root, slot, or epoch. -// 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 -// criteria should be used. -func (bs *Server) ListAttestations( - ctx context.Context, req *ethpb.ListAttestationsRequest, -) (*ethpb.ListAttestationsResponse, error) { - if int(req.PageSize) > params.BeaconConfig().MaxPageSize { - return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", - req.PageSize, params.BeaconConfig().MaxPageSize) - } - var atts []*ethpb.Attestation - var err error - switch q := req.QueryFilter.(type) { - case *ethpb.ListAttestationsRequest_HeadBlockRoot: - atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetHeadBlockRoot(q.HeadBlockRoot)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - case *ethpb.ListAttestationsRequest_SourceEpoch: - atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceEpoch(q.SourceEpoch)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - case *ethpb.ListAttestationsRequest_SourceRoot: - atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetSourceRoot(q.SourceRoot)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - case *ethpb.ListAttestationsRequest_TargetEpoch: - atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetEpoch(q.TargetEpoch)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - case *ethpb.ListAttestationsRequest_TargetRoot: - atts, err = bs.BeaconDB.Attestations(ctx, filters.NewFilter().SetTargetRoot(q.TargetRoot)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - default: - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - // We sort attestations according to the Sortable interface. - sort.Sort(sortableAttestations(atts)) - numAttestations := len(atts) - - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numAttestations) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not paginate attestations: %v", err) - } - return ðpb.ListAttestationsResponse{ - Attestations: atts[start:end], - TotalSize: int32(numAttestations), - NextPageToken: nextPageToken, - }, nil -} - -// AttestationPool retrieves pending attestations. -// -// The server returns a list of attestations that have been seen but not -// yet processed. Pool attestations eventually expire as the slot -// advances, so an attestation missing from this request does not imply -// that it was included in a block. The attestation may have expired. -// Refer to the ethereum 2.0 specification for more details on how -// attestations are processed and when they are no longer valid. -// https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestations -func (bs *Server) AttestationPool( - ctx context.Context, _ *ptypes.Empty, -) (*ethpb.AttestationPoolResponse, error) { - atts, err := bs.Pool.AttestationPoolNoVerify(ctx) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch attestations: %v", err) - } - return ðpb.AttestationPoolResponse{ - Attestations: atts, - }, nil -} - -// ListBlocks retrieves blocks by root, slot, or epoch. -// -// The server may return multiple blocks in the case that a slot or epoch is -// provided as the filter criteria. The server may return an empty list when -// no blocks in their database match the filter criteria. This RPC should -// not return NOT_FOUND. Only one filter criteria should be used. -func (bs *Server) ListBlocks( - ctx context.Context, req *ethpb.ListBlocksRequest, -) (*ethpb.ListBlocksResponse, error) { - if int(req.PageSize) > params.BeaconConfig().MaxPageSize { - return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", - req.PageSize, params.BeaconConfig().MaxPageSize) - } - - switch q := req.QueryFilter.(type) { - case *ethpb.ListBlocksRequest_Epoch: - startSlot := q.Epoch * params.BeaconConfig().SlotsPerEpoch - endSlot := startSlot + params.BeaconConfig().SlotsPerEpoch - 1 - - blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot)) - if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get blocks: %v", err) - } - - numBlks := len(blks) - if numBlks == 0 { - return ðpb.ListBlocksResponse{Blocks: make([]*ethpb.BeaconBlock, 0), TotalSize: 0}, nil - } - - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numBlks) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not paginate blocks: %v", err) - } - - return ðpb.ListBlocksResponse{ - Blocks: blks[start:end], - TotalSize: int32(numBlks), - NextPageToken: nextPageToken, - }, nil - - case *ethpb.ListBlocksRequest_Root: - blk, err := bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(q.Root)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve block: %v", err) - } - - if blk == nil { - return ðpb.ListBlocksResponse{Blocks: []*ethpb.BeaconBlock{}, TotalSize: 0}, nil - } - - return ðpb.ListBlocksResponse{ - Blocks: []*ethpb.BeaconBlock{blk}, - TotalSize: 1, - }, nil - - case *ethpb.ListBlocksRequest_Slot: - blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(q.Slot).SetEndSlot(q.Slot)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve blocks for slot %d: %v", q.Slot, err) - } - - numBlks := len(blks) - if numBlks == 0 { - return ðpb.ListBlocksResponse{Blocks: []*ethpb.BeaconBlock{}, TotalSize: 0}, nil - } - - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numBlks) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not paginate blocks: %v", err) - } - - return ðpb.ListBlocksResponse{ - Blocks: blks[start:end], - TotalSize: int32(numBlks), - NextPageToken: nextPageToken, - }, nil - } - - return nil, status.Errorf(codes.InvalidArgument, "must satisfy one of the filter requirement") -} - -// GetChainHead retrieves information about the head of the beacon chain from -// the view of the beacon chain node. -// -// This includes the head block slot and root as well as information about -// the most recent finalized and justified slots. -func (bs *Server) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) { - finalizedCheckpoint := bs.HeadFetcher.HeadState().FinalizedCheckpoint - justifiedCheckpoint := bs.HeadFetcher.HeadState().CurrentJustifiedCheckpoint - prevJustifiedCheckpoint := bs.HeadFetcher.HeadState().PreviousJustifiedCheckpoint - - return ðpb.ChainHead{ - BlockRoot: bs.HeadFetcher.HeadRoot(), - BlockSlot: bs.HeadFetcher.HeadSlot(), - FinalizedBlockRoot: finalizedCheckpoint.Root, - FinalizedSlot: finalizedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, - JustifiedBlockRoot: justifiedCheckpoint.Root, - JustifiedSlot: justifiedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, - PreviousJustifiedBlockRoot: prevJustifiedCheckpoint.Root, - PreviousJustifiedSlot: prevJustifiedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, - }, nil -} - -// ListValidatorBalances retrieves the validator balances for a given set of public keys. -// An optional Epoch parameter is provided to request historical validator balances from -// archived, persistent data. -func (bs *Server) ListValidatorBalances( - ctx context.Context, - req *ethpb.GetValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) { - - if int(req.PageSize) > params.BeaconConfig().MaxPageSize { - return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", - req.PageSize, params.BeaconConfig().MaxPageSize) - } - - res := make([]*ethpb.ValidatorBalances_Balance, 0) - filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. - - headState := bs.HeadFetcher.HeadState() - var requestingGenesis bool - var epoch uint64 - switch q := req.QueryFilter.(type) { - case *ethpb.GetValidatorBalancesRequest_Epoch: - epoch = q.Epoch - case *ethpb.GetValidatorBalancesRequest_Genesis: - requestingGenesis = q.Genesis - default: - epoch = helpers.CurrentEpoch(headState) - } - - var balances []uint64 - var err error - validators := headState.Validators - if requestingGenesis { - balances, err = bs.BeaconDB.ArchivedBalances(ctx, 0 /* genesis epoch */) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) - } - } else if !requestingGenesis && epoch < helpers.CurrentEpoch(headState) { - balances, err = bs.BeaconDB.ArchivedBalances(ctx, epoch) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) - } - } else { - balances = headState.Balances - } - - for _, pubKey := range req.PublicKeys { - // Skip empty public key - if len(pubKey) == 0 { - continue - } - - index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) - } - if !ok { - return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", pubKey) - } - - filtered[index] = true - - if int(index) >= len(balances) { - return nil, status.Errorf(codes.OutOfRange, "validator index %d >= balance list %d", - index, len(balances)) - } - - res = append(res, ðpb.ValidatorBalances_Balance{ - PublicKey: pubKey, - Index: index, - Balance: balances[index], - }) - } - - for _, index := range req.Indices { - if int(index) >= len(balances) { - if epoch <= helpers.CurrentEpoch(headState) { - return nil, status.Errorf(codes.OutOfRange, "validator index %d does not exist in historical balances", - index) - } - return nil, status.Errorf(codes.OutOfRange, "validator index %d >= balance list %d", - index, len(balances)) - } - - if !filtered[index] { - res = append(res, ðpb.ValidatorBalances_Balance{ - PublicKey: validators[index].PublicKey, - Index: index, - Balance: balances[index], - }) - } - } - - if len(req.Indices) == 0 && len(req.PublicKeys) == 0 { - // return everything. - for i := 0; i < len(headState.Balances); i++ { - res = append(res, ðpb.ValidatorBalances_Balance{ - PublicKey: headState.Validators[i].PublicKey, - Index: uint64(i), - Balance: balances[i], - }) - } - } - - balancesCount := len(res) - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), balancesCount) - if err != nil { - return nil, err - } - return ðpb.ValidatorBalances{ - Epoch: epoch, - Balances: res[start:end], - TotalSize: int32(balancesCount), - NextPageToken: nextPageToken, - }, nil -} - -// GetValidators retrieves the current list of active validators with an optional historical epoch flag to -// to retrieve validator set in time. -func (bs *Server) GetValidators( - ctx context.Context, - req *ethpb.GetValidatorsRequest, -) (*ethpb.Validators, error) { - if int(req.PageSize) > params.BeaconConfig().MaxPageSize { - return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", - req.PageSize, params.BeaconConfig().MaxPageSize) - } - - headState := bs.HeadFetcher.HeadState() - requestedEpoch := helpers.CurrentEpoch(headState) - switch q := req.QueryFilter.(type) { - case *ethpb.GetValidatorsRequest_Genesis: - if q.Genesis { - requestedEpoch = 0 - } - case *ethpb.GetValidatorsRequest_Epoch: - requestedEpoch = q.Epoch - } - - finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch - validators := headState.Validators - if requestedEpoch < finalizedEpoch { - stopIdx := len(validators) - for idx, val := range validators { - // The first time we see a validator with an activation epoch > the requested epoch, - // we know this validator is from the future relative to what the request wants. - if val.ActivationEpoch > requestedEpoch { - stopIdx = idx - break - } - } - validators = validators[:stopIdx] - } - - validatorCount := len(validators) - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), validatorCount) - if err != nil { - return nil, err - } - - return ðpb.Validators{ - Validators: validators[start:end], - TotalSize: int32(validatorCount), - NextPageToken: nextPageToken, - }, nil -} - -// GetValidatorActiveSetChanges retrieves the active set changes for a given epoch. -// -// This data includes any activations, voluntary exits, and involuntary -// ejections. -func (bs *Server) GetValidatorActiveSetChanges( - ctx context.Context, req *ethpb.GetValidatorActiveSetChangesRequest, -) (*ethpb.ActiveSetChanges, error) { - headState := bs.HeadFetcher.HeadState() - requestedEpoch := helpers.CurrentEpoch(headState) - switch q := req.QueryFilter.(type) { - case *ethpb.GetValidatorActiveSetChangesRequest_Genesis: - if q.Genesis { - requestedEpoch = 0 - } - case *ethpb.GetValidatorActiveSetChangesRequest_Epoch: - requestedEpoch = q.Epoch - } - - activatedIndices := make([]uint64, 0) - slashedIndices := make([]uint64, 0) - exitedIndices := make([]uint64, 0) - finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch - var err error - - if requestedEpoch < finalizedEpoch { - archivedChanges, err := bs.BeaconDB.ArchivedActiveValidatorChanges(ctx, requestedEpoch) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch archived active validator changes: %v", err) - } - activatedIndices = archivedChanges.Activated - slashedIndices = archivedChanges.Slashed - exitedIndices = archivedChanges.Exited - } else { - activatedIndices = validators.ActivatedValidatorIndices(headState) - slashedIndices = validators.SlashedValidatorIndices(headState) - exitedIndices, err = validators.ExitedValidatorIndices(headState) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not determine exited validator indices: %v", err) - } - } - - // We retrieve the public keys for the indices. - activatedKeys := make([][]byte, len(activatedIndices)) - slashedKeys := make([][]byte, len(slashedIndices)) - exitedKeys := make([][]byte, len(exitedIndices)) - for i, idx := range activatedIndices { - activatedKeys[i] = headState.Validators[idx].PublicKey - } - for i, idx := range slashedIndices { - slashedKeys[i] = headState.Validators[idx].PublicKey - } - for i, idx := range exitedIndices { - exitedKeys[i] = headState.Validators[idx].PublicKey - } - return ðpb.ActiveSetChanges{ - Epoch: requestedEpoch, - ActivatedPublicKeys: activatedKeys, - ExitedPublicKeys: exitedKeys, - SlashedPublicKeys: slashedKeys, - }, nil -} - -// GetValidatorQueue retrieves the current validator queue information. -func (bs *Server) GetValidatorQueue( - ctx context.Context, _ *ptypes.Empty, -) (*ethpb.ValidatorQueue, error) { - headState := bs.HeadFetcher.HeadState() - // Queue the validators whose eligible to activate and sort them by activation eligibility epoch number. - // Additionally, determine those validators queued to exit - awaitingExit := make([]uint64, 0) - exitEpochs := make([]uint64, 0) - activationQ := make([]uint64, 0) - for idx, validator := range headState.Validators { - eligibleActivated := validator.ActivationEligibilityEpoch != params.BeaconConfig().FarFutureEpoch - canBeActive := validator.ActivationEpoch >= helpers.DelayedActivationExitEpoch(headState.FinalizedCheckpoint.Epoch) - if eligibleActivated && canBeActive { - activationQ = append(activationQ, uint64(idx)) - } - if validator.ExitEpoch != params.BeaconConfig().FarFutureEpoch { - exitEpochs = append(exitEpochs, validator.ExitEpoch) - awaitingExit = append(awaitingExit, uint64(idx)) - } - } - sort.Slice(activationQ, func(i, j int) bool { - return headState.Validators[i].ActivationEligibilityEpoch < headState.Validators[j].ActivationEligibilityEpoch - }) - sort.Slice(awaitingExit, func(i, j int) bool { - return headState.Validators[i].WithdrawableEpoch < headState.Validators[j].WithdrawableEpoch - }) - - // Only activate just enough validators according to the activation churn limit. - activationQueueChurn := len(activationQ) - churnLimit, err := helpers.ValidatorChurnLimit(headState) - if err != nil { - return nil, errors.Wrap(err, "could not get churn limit") - } - - exitQueueEpoch := uint64(0) - for _, i := range exitEpochs { - if exitQueueEpoch < i { - exitQueueEpoch = i - } - } - exitQueueChurn := 0 - for _, val := range headState.Validators { - if val.ExitEpoch == exitQueueEpoch { - exitQueueChurn++ - } - } - // Prevent churn limit from causing index out of bound issues. - if int(churnLimit) < activationQueueChurn { - activationQueueChurn = int(churnLimit) - } - if int(churnLimit) < exitQueueChurn { - // If we are above the churn limit, we simply increase the churn by one. - exitQueueEpoch++ - exitQueueChurn = int(churnLimit) - } - - // We use the exit queue churn to determine if we have passed a churn limit. - minEpoch := exitQueueEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay - exitQueueIndices := make([]uint64, 0) - for _, valIdx := range awaitingExit { - if headState.Validators[valIdx].WithdrawableEpoch < minEpoch { - exitQueueIndices = append(exitQueueIndices, valIdx) - } - } - - // Get the public keys for the validators in the queues up to the allowed churn limits. - activationQueueKeys := make([][]byte, len(activationQ)) - exitQueueKeys := make([][]byte, len(exitQueueIndices)) - for i, idx := range activationQ { - activationQueueKeys[i] = headState.Validators[idx].PublicKey - } - for i, idx := range exitQueueIndices { - exitQueueKeys[i] = headState.Validators[idx].PublicKey - } - - return ðpb.ValidatorQueue{ - ChurnLimit: churnLimit, - ActivationPublicKeys: activationQueueKeys, - ExitPublicKeys: exitQueueKeys, - }, nil -} - -// ListValidatorAssignments retrieves the validator assignments for a given epoch, -// optional validator indices or public keys may be included to filter validator assignments. -func (bs *Server) ListValidatorAssignments( - ctx context.Context, req *ethpb.ListValidatorAssignmentsRequest, -) (*ethpb.ValidatorAssignments, error) { - if int(req.PageSize) > params.BeaconConfig().MaxPageSize { - return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", - req.PageSize, params.BeaconConfig().MaxPageSize) - } - - var res []*ethpb.ValidatorAssignments_CommitteeAssignment - headState := bs.HeadFetcher.HeadState() - filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. - filteredIndices := make([]uint64, 0) - requestedEpoch := helpers.CurrentEpoch(headState) - - switch q := req.QueryFilter.(type) { - case *ethpb.ListValidatorAssignmentsRequest_Genesis: - if q.Genesis { - requestedEpoch = 0 - } - case *ethpb.ListValidatorAssignmentsRequest_Epoch: - requestedEpoch = q.Epoch - } - - // Filter out assignments by public keys. - for _, pubKey := range req.PublicKeys { - index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) - } - if !ok { - return nil, status.Errorf(codes.NotFound, "could not find validator index for public key %#x not found", pubKey) - } - filtered[index] = true - filteredIndices = append(filteredIndices, index) - } - - // Filter out assignments by validator indices. - for _, index := range req.Indices { - if !filtered[index] { - filteredIndices = append(filteredIndices, index) - } - } - - activeIndices, err := helpers.ActiveValidatorIndices(headState, requestedEpoch) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not retrieve active validator indices: %v", err) - } - if len(filteredIndices) == 0 { - // If no filter was specified, return assignments from active validator indices with pagination. - filteredIndices = activeIndices - } - - start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), len(filteredIndices)) - if err != nil { - return nil, err - } - - shouldFetchFromArchive := requestedEpoch < bs.FinalizationFetcher.FinalizedCheckpt().Epoch - - for _, index := range filteredIndices[start:end] { - if int(index) >= len(headState.Validators) { - return nil, status.Errorf(codes.InvalidArgument, "validator index %d >= validator count %d", - index, len(headState.Validators)) - } - if shouldFetchFromArchive { - archivedInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) - if err != nil { - return nil, status.Errorf( - codes.Internal, - "could not retrieve archived committee info for epoch %d", - requestedEpoch, - ) - } - if archivedInfo == nil { - return nil, status.Errorf( - codes.NotFound, - "no archival committee info found for epoch %d", - requestedEpoch, - ) - } - archivedBalances, err := bs.BeaconDB.ArchivedBalances(ctx, requestedEpoch) - if err != nil { - return nil, status.Errorf( - codes.Internal, - "could not retrieve archived balances for epoch %d", - requestedEpoch, - ) - } - 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 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 - } - 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{ - Epoch: requestedEpoch, - Assignments: res, - NextPageToken: nextPageToken, - TotalSize: int32(len(filteredIndices)), - }, nil -} - -// Computes validator assignments for an epoch and validator index using archived committee -// information, archived balances, and a set of active validators. -func archivedValidatorCommittee( - epoch uint64, - validatorIndex uint64, - archivedInfo *ethpb.ArchivedCommitteeInfo, - activeIndices []uint64, - archivedBalances []uint64, -) ([]uint64, uint64, uint64, uint64, error) { - committeeCount := archivedInfo.CommitteeCount - 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++ { - 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, 0, errors.Wrap(err, "could not compute committee") - } - for _, index := range committee { - if validatorIndex == index { - proposerSlot, _ := proposerIndexToSlot[validatorIndex] - return committee, i, slot, proposerSlot, nil - } - } - } - } - 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, -// it returns the information about validator's participation rate in voting on the proof of stake -// rules based on their balance compared to the total active validator balance. -func (bs *Server) GetValidatorParticipation( - ctx context.Context, req *ethpb.GetValidatorParticipationRequest, -) (*ethpb.ValidatorParticipationResponse, error) { - headState := bs.HeadFetcher.HeadState() - currentEpoch := helpers.SlotToEpoch(headState.Slot) - - var requestedEpoch uint64 - var isGenesis bool - switch q := req.QueryFilter.(type) { - case *ethpb.GetValidatorParticipationRequest_Genesis: - isGenesis = q.Genesis - case *ethpb.GetValidatorParticipationRequest_Epoch: - requestedEpoch = q.Epoch - default: - requestedEpoch = currentEpoch - } - - if requestedEpoch > helpers.SlotToEpoch(headState.Slot) { - return nil, status.Errorf( - codes.FailedPrecondition, - "cannot request data from an epoch in the future: req.Epoch %d, currentEpoch %d", requestedEpoch, currentEpoch, - ) - } - // If the request is from genesis or another past epoch, we look into our archived - // data to find it and return it if it exists. - if isGenesis { - participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, 0) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) - } - if participation == nil { - return nil, status.Error(codes.NotFound, "could not find archival data for epoch 0") - } - return ðpb.ValidatorParticipationResponse{ - Epoch: 0, - Finalized: true, - Participation: participation, - }, nil - } else if requestedEpoch < helpers.SlotToEpoch(headState.Slot) { - participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, requestedEpoch) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) - } - if participation == nil { - return nil, status.Errorf(codes.NotFound, "could not find archival data for epoch %d", requestedEpoch) - } - finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch - // If the epoch we requested is <= the finalized epoch, we consider it finalized as well. - finalized := requestedEpoch <= finalizedEpoch - return ðpb.ValidatorParticipationResponse{ - Epoch: requestedEpoch, - Finalized: finalized, - Participation: participation, - }, nil - } - // Else if the request is for the current epoch, we compute validator participation - // right away and return the result based on the head state. - participation, err := epoch.ComputeValidatorParticipation(headState) - if err != nil { - return nil, status.Errorf(codes.Internal, "could not compute participation: %v", err) - } - return ðpb.ValidatorParticipationResponse{ - Epoch: currentEpoch, - Finalized: false, // The current epoch can never be finalized. - Participation: participation, - }, nil -} diff --git a/beacon-chain/rpc/beacon/blocks.go b/beacon-chain/rpc/beacon/blocks.go new file mode 100644 index 000000000000..8da75adcdcb5 --- /dev/null +++ b/beacon-chain/rpc/beacon/blocks.go @@ -0,0 +1,117 @@ +package beacon + +import ( + "context" + + ptypes "github.com/gogo/protobuf/types" + "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/pagination" + "github.com/prysmaticlabs/prysm/shared/params" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// ListBlocks retrieves blocks by root, slot, or epoch. +// +// The server may return multiple blocks in the case that a slot or epoch is +// provided as the filter criteria. The server may return an empty list when +// no blocks in their database match the filter criteria. This RPC should +// not return NOT_FOUND. Only one filter criteria should be used. +func (bs *Server) ListBlocks( + ctx context.Context, req *ethpb.ListBlocksRequest, +) (*ethpb.ListBlocksResponse, error) { + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + + switch q := req.QueryFilter.(type) { + case *ethpb.ListBlocksRequest_Epoch: + startSlot := q.Epoch * params.BeaconConfig().SlotsPerEpoch + endSlot := startSlot + params.BeaconConfig().SlotsPerEpoch - 1 + + blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to get blocks: %v", err) + } + + numBlks := len(blks) + if numBlks == 0 { + return ðpb.ListBlocksResponse{Blocks: make([]*ethpb.BeaconBlock, 0), TotalSize: 0}, nil + } + + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numBlks) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not paginate blocks: %v", err) + } + + return ðpb.ListBlocksResponse{ + Blocks: blks[start:end], + TotalSize: int32(numBlks), + NextPageToken: nextPageToken, + }, nil + + case *ethpb.ListBlocksRequest_Root: + blk, err := bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(q.Root)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve block: %v", err) + } + + if blk == nil { + return ðpb.ListBlocksResponse{Blocks: []*ethpb.BeaconBlock{}, TotalSize: 0}, nil + } + + return ðpb.ListBlocksResponse{ + Blocks: []*ethpb.BeaconBlock{blk}, + TotalSize: 1, + }, nil + + case *ethpb.ListBlocksRequest_Slot: + blks, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartSlot(q.Slot).SetEndSlot(q.Slot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve blocks for slot %d: %v", q.Slot, err) + } + + numBlks := len(blks) + if numBlks == 0 { + return ðpb.ListBlocksResponse{Blocks: []*ethpb.BeaconBlock{}, TotalSize: 0}, nil + } + + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numBlks) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not paginate blocks: %v", err) + } + + return ðpb.ListBlocksResponse{ + Blocks: blks[start:end], + TotalSize: int32(numBlks), + NextPageToken: nextPageToken, + }, nil + } + + return nil, status.Errorf(codes.InvalidArgument, "must satisfy one of the filter requirement") +} + +// GetChainHead retrieves information about the head of the beacon chain from +// the view of the beacon chain node. +// +// This includes the head block slot and root as well as information about +// the most recent finalized and justified slots. +func (bs *Server) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error) { + finalizedCheckpoint := bs.HeadFetcher.HeadState().FinalizedCheckpoint + justifiedCheckpoint := bs.HeadFetcher.HeadState().CurrentJustifiedCheckpoint + prevJustifiedCheckpoint := bs.HeadFetcher.HeadState().PreviousJustifiedCheckpoint + + return ðpb.ChainHead{ + BlockRoot: bs.HeadFetcher.HeadRoot(), + BlockSlot: bs.HeadFetcher.HeadSlot(), + FinalizedBlockRoot: finalizedCheckpoint.Root, + FinalizedSlot: finalizedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, + JustifiedBlockRoot: justifiedCheckpoint.Root, + JustifiedSlot: justifiedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, + PreviousJustifiedBlockRoot: prevJustifiedCheckpoint.Root, + PreviousJustifiedSlot: prevJustifiedCheckpoint.Epoch * params.BeaconConfig().SlotsPerEpoch, + }, nil +} diff --git a/beacon-chain/rpc/beacon/validators.go b/beacon-chain/rpc/beacon/validators.go new file mode 100644 index 000000000000..2a2afe321fe1 --- /dev/null +++ b/beacon-chain/rpc/beacon/validators.go @@ -0,0 +1,399 @@ +package beacon + +import ( + "context" + "sort" + + ptypes "github.com/gogo/protobuf/types" + "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/pagination" + "github.com/prysmaticlabs/prysm/shared/params" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// ListValidatorBalances retrieves the validator balances for a given set of public keys. +// An optional Epoch parameter is provided to request historical validator balances from +// archived, persistent data. +func (bs *Server) ListValidatorBalances( + ctx context.Context, + req *ethpb.GetValidatorBalancesRequest) (*ethpb.ValidatorBalances, error) { + + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + + res := make([]*ethpb.ValidatorBalances_Balance, 0) + filtered := map[uint64]bool{} // track filtered validators to prevent duplication in the response. + + headState := bs.HeadFetcher.HeadState() + var requestingGenesis bool + var epoch uint64 + switch q := req.QueryFilter.(type) { + case *ethpb.GetValidatorBalancesRequest_Epoch: + epoch = q.Epoch + case *ethpb.GetValidatorBalancesRequest_Genesis: + requestingGenesis = q.Genesis + default: + epoch = helpers.CurrentEpoch(headState) + } + + var balances []uint64 + var err error + validators := headState.Validators + if requestingGenesis { + balances, err = bs.BeaconDB.ArchivedBalances(ctx, 0 /* genesis epoch */) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) + } + } else if !requestingGenesis && epoch < helpers.CurrentEpoch(headState) { + balances, err = bs.BeaconDB.ArchivedBalances(ctx, epoch) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "could not retrieve balances for epoch %d", epoch) + } + } else { + balances = headState.Balances + } + + for _, pubKey := range req.PublicKeys { + // Skip empty public key + if len(pubKey) == 0 { + continue + } + + index, ok, err := bs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err) + } + if !ok { + return nil, status.Errorf(codes.Internal, "could not find validator index for public key %#x not found", pubKey) + } + + filtered[index] = true + + if int(index) >= len(balances) { + return nil, status.Errorf(codes.OutOfRange, "validator index %d >= balance list %d", + index, len(balances)) + } + + res = append(res, ðpb.ValidatorBalances_Balance{ + PublicKey: pubKey, + Index: index, + Balance: balances[index], + }) + } + + for _, index := range req.Indices { + if int(index) >= len(balances) { + if epoch <= helpers.CurrentEpoch(headState) { + return nil, status.Errorf(codes.OutOfRange, "validator index %d does not exist in historical balances", + index) + } + return nil, status.Errorf(codes.OutOfRange, "validator index %d >= balance list %d", + index, len(balances)) + } + + if !filtered[index] { + res = append(res, ðpb.ValidatorBalances_Balance{ + PublicKey: validators[index].PublicKey, + Index: index, + Balance: balances[index], + }) + } + } + + if len(req.Indices) == 0 && len(req.PublicKeys) == 0 { + // return everything. + for i := 0; i < len(headState.Balances); i++ { + res = append(res, ðpb.ValidatorBalances_Balance{ + PublicKey: headState.Validators[i].PublicKey, + Index: uint64(i), + Balance: balances[i], + }) + } + } + + balancesCount := len(res) + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), balancesCount) + if err != nil { + return nil, err + } + return ðpb.ValidatorBalances{ + Epoch: epoch, + Balances: res[start:end], + TotalSize: int32(balancesCount), + NextPageToken: nextPageToken, + }, nil +} + +// GetValidators retrieves the current list of active validators with an optional historical epoch flag to +// to retrieve validator set in time. +func (bs *Server) GetValidators( + ctx context.Context, + req *ethpb.GetValidatorsRequest, +) (*ethpb.Validators, error) { + if int(req.PageSize) > params.BeaconConfig().MaxPageSize { + return nil, status.Errorf(codes.InvalidArgument, "requested page size %d can not be greater than max size %d", + req.PageSize, params.BeaconConfig().MaxPageSize) + } + + headState := bs.HeadFetcher.HeadState() + requestedEpoch := helpers.CurrentEpoch(headState) + switch q := req.QueryFilter.(type) { + case *ethpb.GetValidatorsRequest_Genesis: + if q.Genesis { + requestedEpoch = 0 + } + case *ethpb.GetValidatorsRequest_Epoch: + requestedEpoch = q.Epoch + } + + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch + validators := headState.Validators + if requestedEpoch < finalizedEpoch { + stopIdx := len(validators) + for idx, val := range validators { + // The first time we see a validator with an activation epoch > the requested epoch, + // we know this validator is from the future relative to what the request wants. + if val.ActivationEpoch > requestedEpoch { + stopIdx = idx + break + } + } + validators = validators[:stopIdx] + } + + validatorCount := len(validators) + start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), validatorCount) + if err != nil { + return nil, err + } + + return ðpb.Validators{ + Validators: validators[start:end], + TotalSize: int32(validatorCount), + NextPageToken: nextPageToken, + }, nil +} + +// GetValidatorActiveSetChanges retrieves the active set changes for a given epoch. +// +// This data includes any activations, voluntary exits, and involuntary +// ejections. +func (bs *Server) GetValidatorActiveSetChanges( + ctx context.Context, req *ethpb.GetValidatorActiveSetChangesRequest, +) (*ethpb.ActiveSetChanges, error) { + headState := bs.HeadFetcher.HeadState() + requestedEpoch := helpers.CurrentEpoch(headState) + switch q := req.QueryFilter.(type) { + case *ethpb.GetValidatorActiveSetChangesRequest_Genesis: + if q.Genesis { + requestedEpoch = 0 + } + case *ethpb.GetValidatorActiveSetChangesRequest_Epoch: + requestedEpoch = q.Epoch + } + + activatedIndices := make([]uint64, 0) + slashedIndices := make([]uint64, 0) + exitedIndices := make([]uint64, 0) + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch + var err error + + if requestedEpoch < finalizedEpoch { + archivedChanges, err := bs.BeaconDB.ArchivedActiveValidatorChanges(ctx, requestedEpoch) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch archived active validator changes: %v", err) + } + activatedIndices = archivedChanges.Activated + slashedIndices = archivedChanges.Slashed + exitedIndices = archivedChanges.Exited + } else { + activatedIndices = validators.ActivatedValidatorIndices(headState) + slashedIndices = validators.SlashedValidatorIndices(headState) + exitedIndices, err = validators.ExitedValidatorIndices(headState) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not determine exited validator indices: %v", err) + } + } + + // We retrieve the public keys for the indices. + activatedKeys := make([][]byte, len(activatedIndices)) + slashedKeys := make([][]byte, len(slashedIndices)) + exitedKeys := make([][]byte, len(exitedIndices)) + for i, idx := range activatedIndices { + activatedKeys[i] = headState.Validators[idx].PublicKey + } + for i, idx := range slashedIndices { + slashedKeys[i] = headState.Validators[idx].PublicKey + } + for i, idx := range exitedIndices { + exitedKeys[i] = headState.Validators[idx].PublicKey + } + return ðpb.ActiveSetChanges{ + Epoch: requestedEpoch, + ActivatedPublicKeys: activatedKeys, + ExitedPublicKeys: exitedKeys, + SlashedPublicKeys: slashedKeys, + }, nil +} + +// GetValidatorParticipation retrieves the validator participation information for a given epoch, +// it returns the information about validator's participation rate in voting on the proof of stake +// rules based on their balance compared to the total active validator balance. +func (bs *Server) GetValidatorParticipation( + ctx context.Context, req *ethpb.GetValidatorParticipationRequest, +) (*ethpb.ValidatorParticipationResponse, error) { + headState := bs.HeadFetcher.HeadState() + currentEpoch := helpers.SlotToEpoch(headState.Slot) + + var requestedEpoch uint64 + var isGenesis bool + switch q := req.QueryFilter.(type) { + case *ethpb.GetValidatorParticipationRequest_Genesis: + isGenesis = q.Genesis + case *ethpb.GetValidatorParticipationRequest_Epoch: + requestedEpoch = q.Epoch + default: + requestedEpoch = currentEpoch + } + + if requestedEpoch > helpers.SlotToEpoch(headState.Slot) { + return nil, status.Errorf( + codes.FailedPrecondition, + "cannot request data from an epoch in the future: req.Epoch %d, currentEpoch %d", requestedEpoch, currentEpoch, + ) + } + // If the request is from genesis or another past epoch, we look into our archived + // data to find it and return it if it exists. + if isGenesis { + participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, 0) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) + } + if participation == nil { + return nil, status.Error(codes.NotFound, "could not find archival data for epoch 0") + } + return ðpb.ValidatorParticipationResponse{ + Epoch: 0, + Finalized: true, + Participation: participation, + }, nil + } else if requestedEpoch < helpers.SlotToEpoch(headState.Slot) { + participation, err := bs.BeaconDB.ArchivedValidatorParticipation(ctx, requestedEpoch) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not fetch archived participation: %v", err) + } + if participation == nil { + return nil, status.Errorf(codes.NotFound, "could not find archival data for epoch %d", requestedEpoch) + } + finalizedEpoch := bs.FinalizationFetcher.FinalizedCheckpt().Epoch + // If the epoch we requested is <= the finalized epoch, we consider it finalized as well. + finalized := requestedEpoch <= finalizedEpoch + return ðpb.ValidatorParticipationResponse{ + Epoch: requestedEpoch, + Finalized: finalized, + Participation: participation, + }, nil + } + // Else if the request is for the current epoch, we compute validator participation + // right away and return the result based on the head state. + participation, err := epoch.ComputeValidatorParticipation(headState) + if err != nil { + return nil, status.Errorf(codes.Internal, "could not compute participation: %v", err) + } + return ðpb.ValidatorParticipationResponse{ + Epoch: currentEpoch, + Finalized: false, // The current epoch can never be finalized. + Participation: participation, + }, nil +} + +// GetValidatorQueue retrieves the current validator queue information. +func (bs *Server) GetValidatorQueue( + ctx context.Context, _ *ptypes.Empty, +) (*ethpb.ValidatorQueue, error) { + headState := bs.HeadFetcher.HeadState() + // Queue the validators whose eligible to activate and sort them by activation eligibility epoch number. + // Additionally, determine those validators queued to exit + awaitingExit := make([]uint64, 0) + exitEpochs := make([]uint64, 0) + activationQ := make([]uint64, 0) + for idx, validator := range headState.Validators { + eligibleActivated := validator.ActivationEligibilityEpoch != params.BeaconConfig().FarFutureEpoch + canBeActive := validator.ActivationEpoch >= helpers.DelayedActivationExitEpoch(headState.FinalizedCheckpoint.Epoch) + if eligibleActivated && canBeActive { + activationQ = append(activationQ, uint64(idx)) + } + if validator.ExitEpoch != params.BeaconConfig().FarFutureEpoch { + exitEpochs = append(exitEpochs, validator.ExitEpoch) + awaitingExit = append(awaitingExit, uint64(idx)) + } + } + sort.Slice(activationQ, func(i, j int) bool { + return headState.Validators[i].ActivationEligibilityEpoch < headState.Validators[j].ActivationEligibilityEpoch + }) + sort.Slice(awaitingExit, func(i, j int) bool { + return headState.Validators[i].WithdrawableEpoch < headState.Validators[j].WithdrawableEpoch + }) + + // Only activate just enough validators according to the activation churn limit. + activationQueueChurn := len(activationQ) + churnLimit, err := helpers.ValidatorChurnLimit(headState) + if err != nil { + return nil, errors.Wrap(err, "could not get churn limit") + } + + exitQueueEpoch := uint64(0) + for _, i := range exitEpochs { + if exitQueueEpoch < i { + exitQueueEpoch = i + } + } + exitQueueChurn := 0 + for _, val := range headState.Validators { + if val.ExitEpoch == exitQueueEpoch { + exitQueueChurn++ + } + } + // Prevent churn limit from causing index out of bound issues. + if int(churnLimit) < activationQueueChurn { + activationQueueChurn = int(churnLimit) + } + if int(churnLimit) < exitQueueChurn { + // If we are above the churn limit, we simply increase the churn by one. + exitQueueEpoch++ + exitQueueChurn = int(churnLimit) + } + + // We use the exit queue churn to determine if we have passed a churn limit. + minEpoch := exitQueueEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay + exitQueueIndices := make([]uint64, 0) + for _, valIdx := range awaitingExit { + if headState.Validators[valIdx].WithdrawableEpoch < minEpoch { + exitQueueIndices = append(exitQueueIndices, valIdx) + } + } + + // Get the public keys for the validators in the queues up to the allowed churn limits. + activationQueueKeys := make([][]byte, len(activationQ)) + exitQueueKeys := make([][]byte, len(exitQueueIndices)) + for i, idx := range activationQ { + activationQueueKeys[i] = headState.Validators[idx].PublicKey + } + for i, idx := range exitQueueIndices { + exitQueueKeys[i] = headState.Validators[idx].PublicKey + } + + return ðpb.ValidatorQueue{ + ChurnLimit: churnLimit, + ActivationPublicKeys: activationQueueKeys, + ExitPublicKeys: exitQueueKeys, + }, nil +} From 64a256cd39849e01566705b914d432a8bff72d7b Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 20:43:40 -0600 Subject: [PATCH 54/82] subfile split and gazelle --- beacon-chain/rpc/beacon/BUILD.bazel | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index 3cb39e32d592..a5457ff4ba10 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -2,7 +2,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["beacon_chain_server.go"], + srcs = [ + "assignments.go", + "attestations.go", + "beacon_chain_server.go", + "blocks.go", + "validators.go", + ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon", visibility = ["//beacon-chain:__subpackages__"], deps = [ From 7526b5b3fc921837391d67477b3fa51970e74e57 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 20:55:39 -0600 Subject: [PATCH 55/82] shards --- beacon-chain/rpc/beacon/BUILD.bazel | 8 +- beacon-chain/rpc/beacon/assignments_test.go | 468 ++++ beacon-chain/rpc/beacon/attestations_test.go | 460 ++++ .../rpc/beacon/beacon_chain_server_test.go | 2046 ----------------- beacon-chain/rpc/beacon/blocks_test.go | 181 ++ beacon-chain/rpc/beacon/validators_test.go | 989 ++++++++ beacon-chain/rpc/proposer/BUILD.bazel | 1 + beacon-chain/rpc/validator/BUILD.bazel | 1 + 8 files changed, 2107 insertions(+), 2047 deletions(-) create mode 100644 beacon-chain/rpc/beacon/assignments_test.go create mode 100644 beacon-chain/rpc/beacon/attestations_test.go delete mode 100644 beacon-chain/rpc/beacon/beacon_chain_server_test.go create mode 100644 beacon-chain/rpc/beacon/blocks_test.go create mode 100644 beacon-chain/rpc/beacon/validators_test.go diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index a5457ff4ba10..56c13582c39f 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -35,8 +35,14 @@ go_library( go_test( name = "go_default_test", - srcs = ["beacon_chain_server_test.go"], + srcs = [ + "assignments_test.go", + "attestations_test.go", + "blocks_test.go", + "validators_test.go", + ], embed = [":go_default_library"], + shard_count = 4, deps = [ "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/core/helpers:go_default_library", diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go new file mode 100644 index 000000000000..225c359cbeac --- /dev/null +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -0,0 +1,468 @@ +package beacon + +import ( + "context" + "fmt" + "reflect" + "strconv" + "strings" + "testing" + + "github.com/prysmaticlabs/go-ssz" + + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" +) + +func TestServer_ListAssignments_InputOutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + setupValidators(t, db, 1) + headState, err := db.HeadState(ctx) + if err != nil { + t.Fatal(err) + } + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + wanted := fmt.Sprintf("page start %d >= list %d", 0, 0) + if _, err := bs.ListValidatorAssignments( + context.Background(), + ðpb.ListValidatorAssignmentsRequest{ + QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, + }, + ); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListAssignments_Pagination_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) + req := ðpb.ListValidatorAssignmentsRequest{ + PageToken: strconv.Itoa(0), + PageSize: exceedsMax, + } + if _, err := bs.ListValidatorAssignments(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + count := 1000 + validators := make([]*ethpb.Validator, 0, count) + for i := 0; i < count; i++ { + 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: pubKey[:], + ExitEpoch: 0, + }) + } else { + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) + } + } + + blk := ðpb.BeaconBlock{ + Slot: 0, + } + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { + t.Fatal(err) + } + + s := &pbp2p.BeaconState{ + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + if err := db.SaveState(ctx, s, blockRoot); err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: s, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + 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. + 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) + } + wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, + }) + } + + if !reflect.DeepEqual(res.Assignments[0], wanted[207]) { + t.Error("Did not receive wanted assignments") + } +} + +func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + count := 1000 + validators := make([]*ethpb.Validator, 0, count) + balances := make([]uint64, count) + for i := 0; i < count; i++ { + 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: pubKey[:], + ExitEpoch: 0, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) + } else { + validators = append(validators, ðpb.Validator{ + PublicKey: pubKey[:], + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + }) + } + balances[i] = params.BeaconConfig().MaxEffectiveBalance + } + + blk := ðpb.BeaconBlock{ + Slot: 0, + } + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { + t.Fatal(err) + } + + s := &pbp2p.BeaconState{ + Validators: validators, + Balances: balances, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + } + if err := db.SaveState(ctx, s, blockRoot); err != nil { + t.Fatal(err) + } + + // We tell the beacon chain server that our finalized epoch is 10 so that when + // we request assignments for epoch 0, it looks within the archived data. + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: s, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 10, + }, + }, + } + + // We then store archived data into the DB. + currentEpoch := helpers.CurrentEpoch(s) + committeeCount, err := helpers.CommitteeCountAtSlot(s, helpers.StartSlot(currentEpoch)) + if err != nil { + t.Fatal(err) + } + proposerSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconProposer) + if err != nil { + t.Fatal(err) + } + attesterSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) + if err != nil { + t.Fatal(err) + } + 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.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) + } + if !reflect.DeepEqual(res.Assignments, wanted) { + t.Error("Did not receive wanted assignments") + } +} + +func TestServer_ListAssignments_FilterPubkeysIndices_NoPagination(t *testing.T) { + helpers.ClearAllCaches() + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + count := 100 + 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 { + t.Fatal(err) + } + validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) + } + + blk := ðpb.BeaconBlock{ + Slot: 0, + } + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { + t.Fatal(err) + } + + s := &pbp2p.BeaconState{ + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + if err := db.SaveState(ctx, s, blockRoot); err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: s, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + req := ðpb.ListValidatorAssignmentsRequest{PublicKeys: [][]byte{{1}, {2}}, Indices: []uint64{2, 3}} + res, err := bs.ListValidatorAssignments(context.Background(), req) + 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[1:4] { + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) + if err != nil { + t.Fatal(err) + } + wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, + }) + } + + if !reflect.DeepEqual(res.Assignments, wanted) { + t.Error("Did not receive wanted assignments") + } +} + +func TestServer_ListAssignments_CanFilterPubkeysIndices_WithPagination(t *testing.T) { + helpers.ClearAllCaches() + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + count := 100 + 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 { + t.Fatal(err) + } + validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) + } + + blk := ðpb.BeaconBlock{ + Slot: 0, + } + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { + t.Fatal(err) + } + + s := &pbp2p.BeaconState{ + Validators: validators, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} + if err := db.SaveState(ctx, s, blockRoot); err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: s, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + req := ðpb.ListValidatorAssignmentsRequest{Indices: []uint64{1, 2, 3, 4, 5, 6}, PageSize: 2, PageToken: "1"} + res, err := bs.ListValidatorAssignments(context.Background(), req) + if err != nil { + t.Fatal(err) + } + + // Construct the wanted assignments. + var assignments []*ethpb.ValidatorAssignments_CommitteeAssignment + + activeIndices, err := helpers.ActiveValidatorIndices(s, 0) + if err != nil { + t.Fatal(err) + } + for _, index := range activeIndices[3:5] { + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) + if err != nil { + t.Fatal(err) + } + assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, + }) + } + + wantedRes := ðpb.ValidatorAssignments{ + Assignments: assignments, + TotalSize: int32(len(req.Indices)), + NextPageToken: "2", + } + + if !reflect.DeepEqual(res, wantedRes) { + t.Error("Did not get wanted assignments") + } + + // Test the wrap around scenario. + assignments = nil + req = ðpb.ListValidatorAssignmentsRequest{Indices: []uint64{1, 2, 3, 4, 5, 6}, PageSize: 5, PageToken: "1"} + res, err = bs.ListValidatorAssignments(context.Background(), req) + if err != nil { + t.Fatal(err) + } + + for _, index := range activeIndices[6:7] { + committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) + if err != nil { + t.Fatal(err) + } + assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ + BeaconCommittees: committee, + CommitteeIndex: committeeIndex, + AttesterSlot: attesterSlot, + ProposerSlot: proposerSlot, + PublicKey: s.Validators[index].PublicKey, + }) + } + + wantedRes = ðpb.ValidatorAssignments{ + Assignments: assignments, + TotalSize: int32(len(req.Indices)), + NextPageToken: "2", + } + + if !reflect.DeepEqual(res, wantedRes) { + t.Error("Did not receive wanted assignments") + } +} diff --git a/beacon-chain/rpc/beacon/attestations_test.go b/beacon-chain/rpc/beacon/attestations_test.go new file mode 100644 index 000000000000..ffc21f6eaaa4 --- /dev/null +++ b/beacon-chain/rpc/beacon/attestations_test.go @@ -0,0 +1,460 @@ +package beacon + +import ( + "context" + "fmt" + "reflect" + "strconv" + "strings" + "testing" + + "github.com/gogo/protobuf/proto" + ptypes "github.com/gogo/protobuf/types" + "github.com/prysmaticlabs/go-bitfield" + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + mockOps "github.com/prysmaticlabs/prysm/beacon-chain/operations/testing" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" +) + +func TestServer_ListAttestations_NoPagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + count := uint64(10) + atts := make([]*ethpb.Attestation, 0, count) + for i := uint64(0); i < count; i++ { + attExample := ðpb.Attestation{ + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: i, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1), + } + if err := db.SaveAttestation(ctx, attExample); err != nil { + t.Fatal(err) + } + atts = append(atts, attExample) + } + + bs := &Server{ + BeaconDB: db, + } + + received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + }) + if err != nil { + t.Fatal(err) + } + + if !reflect.DeepEqual(atts, received.Attestations) { + t.Fatalf("incorrect attestations response: wanted %v, received %v", atts, received.Attestations) + } +} + +func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + someRoot := []byte{1, 2, 3} + sourceRoot := []byte{4, 5, 6} + sourceEpoch := uint64(5) + targetRoot := []byte{7, 8, 9} + targetEpoch := uint64(7) + + unknownRoot := []byte{1, 1, 1} + atts := []*ethpb.Attestation{ + { + Data: ðpb.AttestationData{ + BeaconBlockRoot: someRoot, + Source: ðpb.Checkpoint{ + Root: sourceRoot, + Epoch: sourceEpoch, + }, + Target: ðpb.Checkpoint{ + Root: targetRoot, + Epoch: targetEpoch, + }, + Slot: 3, + }, + AggregationBits: bitfield.Bitlist{0b11}, + }, + { + Data: ðpb.AttestationData{ + BeaconBlockRoot: unknownRoot, + Source: ðpb.Checkpoint{ + Root: sourceRoot, + Epoch: sourceEpoch, + }, + Target: ðpb.Checkpoint{ + Root: targetRoot, + Epoch: targetEpoch, + }, + Slot: 4, + }, + AggregationBits: bitfield.Bitlist{0b11}, + }, + { + Data: ðpb.AttestationData{ + BeaconBlockRoot: someRoot, + Source: ðpb.Checkpoint{ + Root: unknownRoot, + Epoch: sourceEpoch, + }, + Target: ðpb.Checkpoint{ + Root: unknownRoot, + Epoch: targetEpoch, + }, + Slot: 5, + }, + AggregationBits: bitfield.Bitlist{0b11}, + }, + } + + if err := db.SaveAttestations(ctx, atts); err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + } + + received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{HeadBlockRoot: someRoot}, + }) + if err != nil { + t.Fatal(err) + } + if len(received.Attestations) != 2 { + t.Errorf("Wanted 2 matching attestations with root %#x, received %d", someRoot, len(received.Attestations)) + } + received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_SourceEpoch{SourceEpoch: sourceEpoch}, + }) + if err != nil { + t.Fatal(err) + } + if len(received.Attestations) != 3 { + t.Errorf("Wanted 3 matching attestations with source epoch %d, received %d", sourceEpoch, len(received.Attestations)) + } + received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_SourceRoot{SourceRoot: sourceRoot}, + }) + if err != nil { + t.Fatal(err) + } + if len(received.Attestations) != 2 { + t.Errorf("Wanted 2 matching attestations with source root %#x, received %d", sourceRoot, len(received.Attestations)) + } + received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_TargetEpoch{TargetEpoch: targetEpoch}, + }) + if err != nil { + t.Fatal(err) + } + if len(received.Attestations) != 3 { + t.Errorf("Wanted 3 matching attestations with target epoch %d, received %d", targetEpoch, len(received.Attestations)) + } + received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_TargetRoot{TargetRoot: targetRoot}, + }) + if err != nil { + t.Fatal(err) + } + if len(received.Attestations) != 2 { + t.Errorf("Wanted 2 matching attestations with target root %#x, received %d", targetRoot, len(received.Attestations)) + } +} + +func TestServer_ListAttestations_Pagination_CustomPageParameters(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + count := uint64(100) + atts := make([]*ethpb.Attestation, 0, count) + for i := uint64(0); i < count; i++ { + attExample := ðpb.Attestation{ + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: i, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1), + } + if err := db.SaveAttestation(ctx, attExample); err != nil { + t.Fatal(err) + } + atts = append(atts, attExample) + } + + bs := &Server{ + BeaconDB: db, + } + + tests := []struct { + req *ethpb.ListAttestationsRequest + res *ethpb.ListAttestationsResponse + }{ + { + req: ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + PageToken: strconv.Itoa(1), + PageSize: 3, + }, + res: ðpb.ListAttestationsResponse{ + Attestations: []*ethpb.Attestation{ + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 3, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 4, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 5, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + }, + NextPageToken: strconv.Itoa(2), + TotalSize: int32(count)}}, + { + req: ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + PageToken: strconv.Itoa(10), + PageSize: 5, + }, + res: ðpb.ListAttestationsResponse{ + Attestations: []*ethpb.Attestation{ + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 50, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 51, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 52, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 53, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 54, + }, AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + }, + NextPageToken: strconv.Itoa(11), + TotalSize: int32(count)}}, + { + req: ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + PageToken: strconv.Itoa(33), + PageSize: 3, + }, + res: ðpb.ListAttestationsResponse{ + Attestations: []*ethpb.Attestation{ + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 99, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + }, + NextPageToken: strconv.Itoa(34), + TotalSize: int32(count)}}, + { + req: ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + PageSize: 2, + }, + res: ðpb.ListAttestationsResponse{ + Attestations: []*ethpb.Attestation{ + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1)}, + {Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: 1, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1), + }, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: int32(count)}}, + } + for _, test := range tests { + res, err := bs.ListAttestations(ctx, test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Incorrect attestations response, wanted %v, received %v", test.res, res) + } + } +} + +func TestServer_ListAttestations_Pagination_OutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + count := uint64(1) + atts := make([]*ethpb.Attestation, 0, count) + for i := uint64(0); i < count; i++ { + attExample := ðpb.Attestation{ + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: i, + }, + AggregationBits: bitfield.Bitlist{0b11}, + } + if err := db.SaveAttestation(ctx, attExample); err != nil { + t.Fatal(err) + } + atts = append(atts, attExample) + } + + bs := &Server{ + BeaconDB: db, + } + + req := ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + PageToken: strconv.Itoa(1), + PageSize: 100, + } + wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(atts)) + if _, err := bs.ListAttestations(ctx, req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListAttestations_Pagination_ExceedsMaxPageSize(t *testing.T) { + ctx := context.Background() + bs := &Server{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) + req := ðpb.ListAttestationsRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.ListAttestations(ctx, req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListAttestations_Pagination_DefaultPageSize(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + count := uint64(params.BeaconConfig().DefaultPageSize) + atts := make([]*ethpb.Attestation, 0, count) + for i := uint64(0); i < count; i++ { + attExample := ðpb.Attestation{ + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("root"), + Slot: i, + }, + AggregationBits: bitfield.Bitlist{0b11}, + CustodyBits: bitfield.NewBitlist(1), + } + if err := db.SaveAttestation(ctx, attExample); err != nil { + t.Fatal(err) + } + atts = append(atts, attExample) + } + + bs := &Server{ + BeaconDB: db, + } + + req := ðpb.ListAttestationsRequest{ + QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ + HeadBlockRoot: []byte("root"), + }, + } + res, err := bs.ListAttestations(ctx, req) + if err != nil { + t.Fatal(err) + } + + i := 0 + j := params.BeaconConfig().DefaultPageSize + if !reflect.DeepEqual(res.Attestations, atts[i:j]) { + t.Log(res.Attestations, atts[i:j]) + t.Error("Incorrect attestations response") + } +} + +func TestServer_AttestationPool(t *testing.T) { + ctx := context.Background() + block := ðpb.BeaconBlock{ + Slot: 10, + } + bs := &Server{ + Pool: &mockOps.Operations{ + Attestations: []*ethpb.Attestation{ + { + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("1"), + }, + }, + { + Data: ðpb.AttestationData{ + BeaconBlockRoot: []byte("2"), + }, + }, + }, + }, + HeadFetcher: &mock.ChainService{ + Block: block, + }, + } + res, err := bs.AttestationPool(ctx, &ptypes.Empty{}) + if err != nil { + t.Fatal(err) + } + want, _ := bs.Pool.AttestationPoolNoVerify(ctx) + if !reflect.DeepEqual(res.Attestations, want) { + t.Errorf("Wanted AttestationPool() = %v, received %v", want, res.Attestations) + } +} diff --git a/beacon-chain/rpc/beacon/beacon_chain_server_test.go b/beacon-chain/rpc/beacon/beacon_chain_server_test.go deleted file mode 100644 index b26d7a811f4f..000000000000 --- a/beacon-chain/rpc/beacon/beacon_chain_server_test.go +++ /dev/null @@ -1,2046 +0,0 @@ -package beacon - -import ( - "bytes" - "context" - "fmt" - "reflect" - "strconv" - "strings" - "testing" - - "github.com/gogo/protobuf/proto" - ptypes "github.com/gogo/protobuf/types" - "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/go-ssz" - mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - "github.com/prysmaticlabs/prysm/beacon-chain/db" - dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - mockOps "github.com/prysmaticlabs/prysm/beacon-chain/operations/testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/params" -) - -func init() { - // Use minimal config to reduce test setup time. - params.OverrideBeaconConfig(params.MinimalSpecConfig()) -} - -func TestServer_ListAttestationsNoPagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - count := uint64(10) - atts := make([]*ethpb.Attestation, 0, count) - for i := uint64(0); i < count; i++ { - attExample := ðpb.Attestation{ - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: i, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1), - } - if err := db.SaveAttestation(ctx, attExample); err != nil { - t.Fatal(err) - } - atts = append(atts, attExample) - } - - bs := &Server{ - BeaconDB: db, - } - - received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - }) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(atts, received.Attestations) { - t.Fatalf("incorrect attestations response: wanted %v, received %v", atts, received.Attestations) - } -} - -func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - someRoot := []byte{1, 2, 3} - sourceRoot := []byte{4, 5, 6} - sourceEpoch := uint64(5) - targetRoot := []byte{7, 8, 9} - targetEpoch := uint64(7) - - unknownRoot := []byte{1, 1, 1} - atts := []*ethpb.Attestation{ - { - Data: ðpb.AttestationData{ - BeaconBlockRoot: someRoot, - Source: ðpb.Checkpoint{ - Root: sourceRoot, - Epoch: sourceEpoch, - }, - Target: ðpb.Checkpoint{ - Root: targetRoot, - Epoch: targetEpoch, - }, - Slot: 3, - }, - AggregationBits: bitfield.Bitlist{0b11}, - }, - { - Data: ðpb.AttestationData{ - BeaconBlockRoot: unknownRoot, - Source: ðpb.Checkpoint{ - Root: sourceRoot, - Epoch: sourceEpoch, - }, - Target: ðpb.Checkpoint{ - Root: targetRoot, - Epoch: targetEpoch, - }, - Slot: 4, - }, - AggregationBits: bitfield.Bitlist{0b11}, - }, - { - Data: ðpb.AttestationData{ - BeaconBlockRoot: someRoot, - Source: ðpb.Checkpoint{ - Root: unknownRoot, - Epoch: sourceEpoch, - }, - Target: ðpb.Checkpoint{ - Root: unknownRoot, - Epoch: targetEpoch, - }, - Slot: 5, - }, - AggregationBits: bitfield.Bitlist{0b11}, - }, - } - - if err := db.SaveAttestations(ctx, atts); err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - } - - received, err := bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{HeadBlockRoot: someRoot}, - }) - if err != nil { - t.Fatal(err) - } - if len(received.Attestations) != 2 { - t.Errorf("Wanted 2 matching attestations with root %#x, received %d", someRoot, len(received.Attestations)) - } - received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_SourceEpoch{SourceEpoch: sourceEpoch}, - }) - if err != nil { - t.Fatal(err) - } - if len(received.Attestations) != 3 { - t.Errorf("Wanted 3 matching attestations with source epoch %d, received %d", sourceEpoch, len(received.Attestations)) - } - received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_SourceRoot{SourceRoot: sourceRoot}, - }) - if err != nil { - t.Fatal(err) - } - if len(received.Attestations) != 2 { - t.Errorf("Wanted 2 matching attestations with source root %#x, received %d", sourceRoot, len(received.Attestations)) - } - received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_TargetEpoch{TargetEpoch: targetEpoch}, - }) - if err != nil { - t.Fatal(err) - } - if len(received.Attestations) != 3 { - t.Errorf("Wanted 3 matching attestations with target epoch %d, received %d", targetEpoch, len(received.Attestations)) - } - received, err = bs.ListAttestations(ctx, ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_TargetRoot{TargetRoot: targetRoot}, - }) - if err != nil { - t.Fatal(err) - } - if len(received.Attestations) != 2 { - t.Errorf("Wanted 2 matching attestations with target root %#x, received %d", targetRoot, len(received.Attestations)) - } -} - -func TestServer_ListAttestationsPagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - count := uint64(100) - atts := make([]*ethpb.Attestation, 0, count) - for i := uint64(0); i < count; i++ { - attExample := ðpb.Attestation{ - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: i, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1), - } - if err := db.SaveAttestation(ctx, attExample); err != nil { - t.Fatal(err) - } - atts = append(atts, attExample) - } - - bs := &Server{ - BeaconDB: db, - } - - tests := []struct { - req *ethpb.ListAttestationsRequest - res *ethpb.ListAttestationsResponse - }{ - { - req: ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - PageToken: strconv.Itoa(1), - PageSize: 3, - }, - res: ðpb.ListAttestationsResponse{ - Attestations: []*ethpb.Attestation{ - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 3, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 4, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 5, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - }, - NextPageToken: strconv.Itoa(2), - TotalSize: int32(count)}}, - { - req: ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - PageToken: strconv.Itoa(10), - PageSize: 5, - }, - res: ðpb.ListAttestationsResponse{ - Attestations: []*ethpb.Attestation{ - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 50, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 51, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 52, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 53, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 54, - }, AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - }, - NextPageToken: strconv.Itoa(11), - TotalSize: int32(count)}}, - { - req: ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - PageToken: strconv.Itoa(33), - PageSize: 3, - }, - res: ðpb.ListAttestationsResponse{ - Attestations: []*ethpb.Attestation{ - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 99, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - }, - NextPageToken: strconv.Itoa(34), - TotalSize: int32(count)}}, - { - req: ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - PageSize: 2, - }, - res: ðpb.ListAttestationsResponse{ - Attestations: []*ethpb.Attestation{ - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1)}, - {Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: 1, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1), - }, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: int32(count)}}, - } - for _, test := range tests { - res, err := bs.ListAttestations(ctx, test.req) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(res, test.res) { - t.Errorf("Incorrect attestations response, wanted %v, received %v", test.res, res) - } - } -} - -func TestServer_ListAttestationsPaginationOutOfRange(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - count := uint64(1) - atts := make([]*ethpb.Attestation, 0, count) - for i := uint64(0); i < count; i++ { - attExample := ðpb.Attestation{ - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: i, - }, - AggregationBits: bitfield.Bitlist{0b11}, - } - if err := db.SaveAttestation(ctx, attExample); err != nil { - t.Fatal(err) - } - atts = append(atts, attExample) - } - - bs := &Server{ - BeaconDB: db, - } - - req := ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - PageToken: strconv.Itoa(1), - PageSize: 100, - } - wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(atts)) - if _, err := bs.ListAttestations(ctx, req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListAttestationsExceedsMaxPageSize(t *testing.T) { - ctx := context.Background() - bs := &Server{} - exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) - - wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) - req := ðpb.ListAttestationsRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} - if _, err := bs.ListAttestations(ctx, req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListAttestationsDefaultPageSize(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - count := uint64(params.BeaconConfig().DefaultPageSize) - atts := make([]*ethpb.Attestation, 0, count) - for i := uint64(0); i < count; i++ { - attExample := ðpb.Attestation{ - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("root"), - Slot: i, - }, - AggregationBits: bitfield.Bitlist{0b11}, - CustodyBits: bitfield.NewBitlist(1), - } - if err := db.SaveAttestation(ctx, attExample); err != nil { - t.Fatal(err) - } - atts = append(atts, attExample) - } - - bs := &Server{ - BeaconDB: db, - } - - req := ðpb.ListAttestationsRequest{ - QueryFilter: ðpb.ListAttestationsRequest_HeadBlockRoot{ - HeadBlockRoot: []byte("root"), - }, - } - res, err := bs.ListAttestations(ctx, req) - if err != nil { - t.Fatal(err) - } - - i := 0 - j := params.BeaconConfig().DefaultPageSize - if !reflect.DeepEqual(res.Attestations, atts[i:j]) { - t.Log(res.Attestations, atts[i:j]) - t.Error("Incorrect attestations response") - } -} - -func TestServer_AttestationPool(t *testing.T) { - ctx := context.Background() - block := ðpb.BeaconBlock{ - Slot: 10, - } - bs := &Server{ - Pool: &mockOps.Operations{ - Attestations: []*ethpb.Attestation{ - { - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("1"), - }, - }, - { - Data: ðpb.AttestationData{ - BeaconBlockRoot: []byte("2"), - }, - }, - }, - }, - HeadFetcher: &mock.ChainService{ - Block: block, - }, - } - res, err := bs.AttestationPool(ctx, &ptypes.Empty{}) - if err != nil { - t.Fatal(err) - } - want, _ := bs.Pool.AttestationPoolNoVerify(ctx) - if !reflect.DeepEqual(res.Attestations, want) { - t.Errorf("Wanted AttestationPool() = %v, received %v", want, res.Attestations) - } -} - -func TestServer_ListValidatorBalances_PaginationOutOfRange(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - setupValidators(t, db, 3) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - - req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 100} - wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(headState.Balances)) - if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { - bs := &Server{} - exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) - - wanted := fmt.Sprintf( - "requested page size %d can not be greater than max size %d", - exceedsMax, - params.BeaconConfig().MaxPageSize, - ) - req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} - if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListValidatorBalances_NoPagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - setupValidators(t, db, 100) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{State: headState}, - } - - tests := []struct { - req *ethpb.GetValidatorBalancesRequest - res *ethpb.ValidatorBalances - }{ - {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{99}}}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 99, PublicKey: []byte{99}, Balance: 99}, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: 1, - }, - }, - {req: ðpb.GetValidatorBalancesRequest{Indices: []uint64{1, 2, 3}}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 1, PublicKey: []byte{1}, Balance: 1}, - {Index: 2, PublicKey: []byte{2}, Balance: 2}, - {Index: 3, PublicKey: []byte{3}, Balance: 3}, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: 3, - }, - }, - {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{10}, {11}, {12}}}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 10, PublicKey: []byte{10}, Balance: 10}, - {Index: 11, PublicKey: []byte{11}, Balance: 11}, - {Index: 12, PublicKey: []byte{12}, Balance: 12}, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: 3, - }}, - {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{2}, {3}}, Indices: []uint64{3, 4}}, // Duplication - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 2, PublicKey: []byte{2}, Balance: 2}, - {Index: 3, PublicKey: []byte{3}, Balance: 3}, - {Index: 4, PublicKey: []byte{4}, Balance: 4}, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: 3, - }}, - {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{}}, Indices: []uint64{3, 4}}, // Public key has a blank value - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {Index: 3, PublicKey: []byte{3}, Balance: 3}, - {Index: 4, PublicKey: []byte{4}, Balance: 4}, - }, - NextPageToken: strconv.Itoa(1), - TotalSize: 2, - }}, - } - for _, test := range tests { - res, err := bs.ListValidatorBalances(context.Background(), test.req) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(res, test.res) { - t.Errorf("Expected %v, received %v", test.res, res) - } - } -} - -func TestServer_ListValidatorBalances_Pagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - count := 1000 - setupValidators(t, db, count) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - - tests := []struct { - req *ethpb.GetValidatorBalancesRequest - res *ethpb.ValidatorBalances - }{ - {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 3}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {PublicKey: []byte{3}, Index: 3, Balance: uint64(3)}, - {PublicKey: []byte{4}, Index: 4, Balance: uint64(4)}, - {PublicKey: []byte{5}, Index: 5, Balance: uint64(5)}}, - NextPageToken: strconv.Itoa(2), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(10), PageSize: 5}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {PublicKey: []byte{50}, Index: 50, Balance: uint64(50)}, - {PublicKey: []byte{51}, Index: 51, Balance: uint64(51)}, - {PublicKey: []byte{52}, Index: 52, Balance: uint64(52)}, - {PublicKey: []byte{53}, Index: 53, Balance: uint64(53)}, - {PublicKey: []byte{54}, Index: 54, Balance: uint64(54)}}, - NextPageToken: strconv.Itoa(11), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(33), PageSize: 3}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {PublicKey: []byte{99}, Index: 99, Balance: uint64(99)}, - {PublicKey: []byte{100}, Index: 100, Balance: uint64(100)}, - {PublicKey: []byte{101}, Index: 101, Balance: uint64(101)}, - }, - NextPageToken: strconv.Itoa(34), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorBalancesRequest{PageSize: 2}, - res: ðpb.ValidatorBalances{ - Balances: []*ethpb.ValidatorBalances_Balance{ - {PublicKey: []byte{0}, Index: 0, Balance: uint64(0)}, - {PublicKey: []byte{1}, Index: 1, Balance: uint64(1)}}, - NextPageToken: strconv.Itoa(1), - TotalSize: int32(count)}}, - } - for _, test := range tests { - res, err := bs.ListValidatorBalances(context.Background(), test.req) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(res, test.res) { - t.Errorf("Expected %v, received %v", test.res, res) - } - } -} - -func TestServer_ListValidatorBalances_OutOfRange(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - setupValidators(t, db, 1) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{State: headState}, - } - - req := ðpb.GetValidatorBalancesRequest{Indices: []uint64{uint64(1)}} - wanted := "does not exist" - if _, err := bs.ListValidatorBalances(context.Background(), req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListValidatorBalances_FromArchive(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - epoch := uint64(0) - validators, balances := setupValidators(t, db, 100) - - if err := db.SaveArchivedBalances(ctx, epoch, balances); err != nil { - t.Fatal(err) - } - - newerBalances := make([]uint64, len(balances)) - for i := 0; i < len(newerBalances); i++ { - newerBalances[i] = balances[i] * 2 - } - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: &pbp2p.BeaconState{ - Slot: params.BeaconConfig().SlotsPerEpoch * 3, - Validators: validators, - Balances: newerBalances, - }, - }, - } - - req := ðpb.GetValidatorBalancesRequest{ - QueryFilter: ðpb.GetValidatorBalancesRequest_Epoch{Epoch: 0}, - Indices: []uint64{uint64(1)}, - } - res, err := bs.ListValidatorBalances(context.Background(), req) - if err != nil { - t.Fatal(err) - } - // We should expect a response containing the old balance from epoch 0, - // not the new balance from the current state. - want := []*ethpb.ValidatorBalances_Balance{ - { - PublicKey: validators[1].PublicKey, - Index: 1, - Balance: balances[1], - }, - } - if !reflect.DeepEqual(want, res.Balances) { - t.Errorf("Wanted %v, received %v", want, res.Balances) - } -} - -func TestServer_ListValidatorBalances_FromArchive_NewValidatorNotFound(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - epoch := uint64(0) - _, balances := setupValidators(t, db, 100) - - if err := db.SaveArchivedBalances(ctx, epoch, balances); err != nil { - t.Fatal(err) - } - - newValidators, newBalances := setupValidators(t, db, 200) - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: &pbp2p.BeaconState{ - Slot: params.BeaconConfig().SlotsPerEpoch * 3, - Validators: newValidators, - Balances: newBalances, - }, - }, - } - - req := ðpb.GetValidatorBalancesRequest{ - QueryFilter: ðpb.GetValidatorBalancesRequest_Epoch{Epoch: 0}, - Indices: []uint64{1, 150, 161}, - } - if _, err := bs.ListValidatorBalances(context.Background(), req); !strings.Contains(err.Error(), "does not exist") { - t.Errorf("Wanted out of range error for including newer validators in the arguments, received %v", err) - } -} - -func TestServer_GetValidators_NoPagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - validators, _ := setupValidators(t, db, 100) - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - received, err := bs.GetValidators(context.Background(), ðpb.GetValidatorsRequest{}) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(validators, received.Validators) { - t.Fatal("Incorrect respond of validators") - } -} - -func TestServer_GetValidators_Pagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - count := 100 - setupValidators(t, db, count) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - tests := []struct { - req *ethpb.GetValidatorsRequest - res *ethpb.Validators - }{ - {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(1), PageSize: 3}, - res: ðpb.Validators{ - Validators: []*ethpb.Validator{ - {PublicKey: []byte{3}}, - {PublicKey: []byte{4}}, - {PublicKey: []byte{5}}}, - NextPageToken: strconv.Itoa(2), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(10), PageSize: 5}, - res: ðpb.Validators{ - Validators: []*ethpb.Validator{ - {PublicKey: []byte{50}}, - {PublicKey: []byte{51}}, - {PublicKey: []byte{52}}, - {PublicKey: []byte{53}}, - {PublicKey: []byte{54}}}, - NextPageToken: strconv.Itoa(11), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(33), PageSize: 3}, - res: ðpb.Validators{ - Validators: []*ethpb.Validator{ - {PublicKey: []byte{99}}}, - NextPageToken: strconv.Itoa(34), - TotalSize: int32(count)}}, - {req: ðpb.GetValidatorsRequest{PageSize: 2}, - res: ðpb.Validators{ - Validators: []*ethpb.Validator{ - {PublicKey: []byte{0}}, - {PublicKey: []byte{1}}}, - NextPageToken: strconv.Itoa(1), - TotalSize: int32(count)}}, - } - for _, test := range tests { - res, err := bs.GetValidators(context.Background(), test.req) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(res, test.res) { - t.Error("Incorrect respond of validators") - } - } -} - -func TestServer_GetValidators_PaginationOutOfRange(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - count := 1 - validators, _ := setupValidators(t, db, count) - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - req := ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(1), PageSize: 100} - wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(validators)) - if _, err := bs.GetValidators(context.Background(), req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_GetValidators_ExceedsMaxPageSize(t *testing.T) { - bs := &Server{} - exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) - - wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) - req := ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} - if _, err := bs.GetValidators(context.Background(), req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_GetValidators_DefaultPageSize(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - validators, _ := setupValidators(t, db, 1000) - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - req := ðpb.GetValidatorsRequest{} - res, err := bs.GetValidators(context.Background(), req) - if err != nil { - t.Fatal(err) - } - - i := 0 - j := params.BeaconConfig().DefaultPageSize - if !reflect.DeepEqual(res.Validators, validators[i:j]) { - t.Error("Incorrect respond of validators") - } -} - -func TestServer_GetValidators_FromOldEpoch(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - numEpochs := 30 - validators := make([]*ethpb.Validator, numEpochs) - for i := 0; i < numEpochs; i++ { - validators[i] = ðpb.Validator{ - ActivationEpoch: uint64(i), - } - } - - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: &pbp2p.BeaconState{ - Validators: validators, - }, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 200, - }, - }, - } - - req := ðpb.GetValidatorsRequest{ - QueryFilter: ðpb.GetValidatorsRequest_Genesis{ - Genesis: true, - }, - } - res, err := bs.GetValidators(context.Background(), req) - if err != nil { - t.Fatal(err) - } - if len(res.Validators) != 1 { - t.Errorf("Wanted 1 validator at genesis, received %d", len(res.Validators)) - } - - req = ðpb.GetValidatorsRequest{ - QueryFilter: ðpb.GetValidatorsRequest_Epoch{ - Epoch: 20, - }, - } - res, err = bs.GetValidators(context.Background(), req) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(res.Validators, validators[:21]) { - t.Errorf("Incorrect number of validators, wanted %d received %d", 20, len(res.Validators)) - } -} - -func TestServer_GetValidatorActiveSetChanges(t *testing.T) { - ctx := context.Background() - validators := make([]*ethpb.Validator, 6) - headState := &pbp2p.BeaconState{ - Slot: 0, - Validators: validators, - } - for i := 0; i < len(validators); i++ { - activationEpoch := params.BeaconConfig().FarFutureEpoch - withdrawableEpoch := params.BeaconConfig().FarFutureEpoch - exitEpoch := params.BeaconConfig().FarFutureEpoch - slashed := false - // Mark indices divisible by two as activated. - if i%2 == 0 { - activationEpoch = helpers.DelayedActivationExitEpoch(0) - } else if i%3 == 0 { - // Mark indices divisible by 3 as slashed. - withdrawableEpoch = params.BeaconConfig().EpochsPerSlashingsVector - slashed = true - } else if i%5 == 0 { - // Mark indices divisible by 5 as exited. - exitEpoch = 0 - withdrawableEpoch = params.BeaconConfig().MinValidatorWithdrawabilityDelay - } - headState.Validators[i] = ðpb.Validator{ - ActivationEpoch: activationEpoch, - PublicKey: []byte(strconv.Itoa(i)), - WithdrawableEpoch: withdrawableEpoch, - Slashed: slashed, - ExitEpoch: exitEpoch, - } - } - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 0}, - }, - } - res, err := bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{}) - if err != nil { - t.Fatal(err) - } - wantedActive := [][]byte{ - []byte("0"), - []byte("2"), - []byte("4"), - } - wantedSlashed := [][]byte{ - []byte("3"), - } - wantedExited := [][]byte{ - []byte("5"), - } - wanted := ðpb.ActiveSetChanges{ - Epoch: 0, - ActivatedPublicKeys: wantedActive, - ExitedPublicKeys: wantedExited, - SlashedPublicKeys: wantedSlashed, - } - if !proto.Equal(wanted, res) { - t.Errorf("Wanted %v, received %v", wanted, res) - } -} - -func TestServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - validators := make([]*ethpb.Validator, 6) - headState := &pbp2p.BeaconState{ - Slot: 0, - Validators: validators, - } - activatedIndices := make([]uint64, 0) - slashedIndices := make([]uint64, 0) - exitedIndices := make([]uint64, 0) - for i := 0; i < len(validators); i++ { - // Mark indices divisible by two as activated. - if i%2 == 0 { - activatedIndices = append(activatedIndices, uint64(i)) - } else if i%3 == 0 { - // Mark indices divisible by 3 as slashed. - slashedIndices = append(slashedIndices, uint64(i)) - } else if i%5 == 0 { - // Mark indices divisible by 5 as exited. - exitedIndices = append(exitedIndices, uint64(i)) - } - headState.Validators[i] = ðpb.Validator{ - PublicKey: []byte(strconv.Itoa(i)), - } - } - archivedChanges := ðpb.ArchivedActiveSetChanges{ - Activated: activatedIndices, - Exited: exitedIndices, - Slashed: slashedIndices, - } - // We store the changes during the genesis epoch. - if err := db.SaveArchivedActiveValidatorChanges(ctx, 0, archivedChanges); err != nil { - t.Fatal(err) - } - // We store the same changes during epoch 5 for further testing. - if err := db.SaveArchivedActiveValidatorChanges(ctx, 5, archivedChanges); err != nil { - t.Fatal(err) - } - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: headState, - }, - FinalizationFetcher: &mock.ChainService{ - // Pick an epoch far in the future so that we trigger fetching from the archive. - FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 100}, - }, - } - res, err := bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{ - QueryFilter: ðpb.GetValidatorActiveSetChangesRequest_Genesis{Genesis: true}, - }) - if err != nil { - t.Fatal(err) - } - wantedActive := [][]byte{ - []byte("0"), - []byte("2"), - []byte("4"), - } - wantedSlashed := [][]byte{ - []byte("3"), - } - wantedExited := [][]byte{ - []byte("5"), - } - wanted := ðpb.ActiveSetChanges{ - Epoch: 0, - ActivatedPublicKeys: wantedActive, - ExitedPublicKeys: wantedExited, - SlashedPublicKeys: wantedSlashed, - } - if !proto.Equal(wanted, res) { - t.Errorf("Wanted %v, received %v", wanted, res) - } - res, err = bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{ - QueryFilter: ðpb.GetValidatorActiveSetChangesRequest_Epoch{Epoch: 5}, - }) - if err != nil { - t.Fatal(err) - } - wanted.Epoch = 5 - if !proto.Equal(wanted, res) { - t.Errorf("Wanted %v, received %v", wanted, res) - } -} - -func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) { - headState := &pbp2p.BeaconState{ - Validators: []*ethpb.Validator{ - { - ActivationEpoch: helpers.DelayedActivationExitEpoch(0), - ActivationEligibilityEpoch: 3, - PublicKey: []byte("3"), - }, - { - ActivationEpoch: helpers.DelayedActivationExitEpoch(0), - ActivationEligibilityEpoch: 2, - PublicKey: []byte("2"), - }, - { - ActivationEpoch: helpers.DelayedActivationExitEpoch(0), - ActivationEligibilityEpoch: 1, - PublicKey: []byte("1"), - }, - }, - FinalizedCheckpoint: ðpb.Checkpoint{ - Epoch: 0, - }, - } - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - res, err := bs.GetValidatorQueue(context.Background(), &ptypes.Empty{}) - if err != nil { - t.Fatal(err) - } - // We verify the keys are properly sorted by the validators' activation eligibility epoch. - wanted := [][]byte{ - []byte("1"), - []byte("2"), - []byte("3"), - } - wantChurn, err := helpers.ValidatorChurnLimit(headState) - if err != nil { - t.Fatal(err) - } - if res.ChurnLimit != wantChurn { - t.Errorf("Wanted churn %d, received %d", wantChurn, res.ChurnLimit) - } - if !reflect.DeepEqual(res.ActivationPublicKeys, wanted) { - t.Errorf("Wanted %v, received %v", wanted, res.ActivationPublicKeys) - } -} - -func TestServer_GetValidatorQueue_PendingExit(t *testing.T) { - headState := &pbp2p.BeaconState{ - Validators: []*ethpb.Validator{ - { - ActivationEpoch: 0, - ExitEpoch: 4, - WithdrawableEpoch: 3, - PublicKey: []byte("3"), - }, - { - ActivationEpoch: 0, - ExitEpoch: 4, - WithdrawableEpoch: 2, - PublicKey: []byte("2"), - }, - { - ActivationEpoch: 0, - ExitEpoch: 4, - WithdrawableEpoch: 1, - PublicKey: []byte("1"), - }, - }, - FinalizedCheckpoint: ðpb.Checkpoint{ - Epoch: 0, - }, - } - bs := &Server{ - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - res, err := bs.GetValidatorQueue(context.Background(), &ptypes.Empty{}) - if err != nil { - t.Fatal(err) - } - // We verify the keys are properly sorted by the validators' withdrawable epoch. - wanted := [][]byte{ - []byte("1"), - []byte("2"), - []byte("3"), - } - wantChurn, err := helpers.ValidatorChurnLimit(headState) - if err != nil { - t.Fatal(err) - } - if res.ChurnLimit != wantChurn { - t.Errorf("Wanted churn %d, received %d", wantChurn, res.ChurnLimit) - } - if !reflect.DeepEqual(res.ExitPublicKeys, wanted) { - t.Errorf("Wanted %v, received %v", wanted, res.ExitPublicKeys) - } -} - -func TestServer_ListAssignmentsInputOutOfRange(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - setupValidators(t, db, 1) - headState, err := db.HeadState(ctx) - if err != nil { - t.Fatal(err) - } - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: headState, - }, - } - - wanted := fmt.Sprintf("page start %d >= list %d", 0, 0) - if _, err := bs.ListValidatorAssignments( - context.Background(), - ðpb.ListValidatorAssignmentsRequest{ - QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, - }, - ); err != nil && !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListAssignmentsExceedsMaxPageSize(t *testing.T) { - bs := &Server{} - exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) - - wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) - req := ðpb.ListValidatorAssignmentsRequest{ - PageToken: strconv.Itoa(0), - PageSize: exceedsMax, - } - if _, err := bs.ListValidatorAssignments(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } -} - -func TestServer_ListAssignmentsDefaultPageSize_NoArchive(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - count := 1000 - validators := make([]*ethpb.Validator, 0, count) - for i := 0; i < count; i++ { - 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: pubKey[:], - ExitEpoch: 0, - }) - } else { - validators = append(validators, ðpb.Validator{ - PublicKey: pubKey[:], - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, - }) - } - } - - blk := ðpb.BeaconBlock{ - Slot: 0, - } - blockRoot, err := ssz.SigningRoot(blk) - if err != nil { - t.Fatal(err) - } - if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { - t.Fatal(err) - } - - s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} - if err := db.SaveState(ctx, s, blockRoot); err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: s, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - 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. - 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) - } - wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ - BeaconCommittees: committee, - CommitteeIndex: committeeIndex, - AttesterSlot: attesterSlot, - ProposerSlot: proposerSlot, - PublicKey: s.Validators[index].PublicKey, - }) - } - - if !reflect.DeepEqual(res.Assignments[0], wanted[207]) { - t.Error("Did not receive wanted assignments") - } -} - -func TestServer_ListAssignmentsDefaultPageSize_FromArchive(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - count := 1000 - validators := make([]*ethpb.Validator, 0, count) - balances := make([]uint64, count) - for i := 0; i < count; i++ { - 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: pubKey[:], - ExitEpoch: 0, - EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, - }) - } else { - validators = append(validators, ðpb.Validator{ - PublicKey: pubKey[:], - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, - }) - } - balances[i] = params.BeaconConfig().MaxEffectiveBalance - } - - blk := ðpb.BeaconBlock{ - Slot: 0, - } - blockRoot, err := ssz.SigningRoot(blk) - if err != nil { - t.Fatal(err) - } - if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { - t.Fatal(err) - } - - s := &pbp2p.BeaconState{ - Validators: validators, - Balances: balances, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - } - if err := db.SaveState(ctx, s, blockRoot); err != nil { - t.Fatal(err) - } - - // We tell the beacon chain server that our finalized epoch is 10 so that when - // we request assignments for epoch 0, it looks within the archived data. - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: s, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 10, - }, - }, - } - - // We then store archived data into the DB. - currentEpoch := helpers.CurrentEpoch(s) - committeeCount, err := helpers.CommitteeCountAtSlot(s, helpers.StartSlot(currentEpoch)) - if err != nil { - t.Fatal(err) - } - proposerSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconProposer) - if err != nil { - t.Fatal(err) - } - attesterSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconAttester) - if err != nil { - t.Fatal(err) - } - 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.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) - } - if !reflect.DeepEqual(res.Assignments, wanted) { - t.Error("Did not receive wanted assignments") - } -} - -func TestServer_ListAssignmentsFilterPubkeysIndices_NoPagination(t *testing.T) { - helpers.ClearAllCaches() - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - count := 100 - 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 { - t.Fatal(err) - } - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) - } - - blk := ðpb.BeaconBlock{ - Slot: 0, - } - blockRoot, err := ssz.SigningRoot(blk) - if err != nil { - t.Fatal(err) - } - if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { - t.Fatal(err) - } - - s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} - if err := db.SaveState(ctx, s, blockRoot); err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: s, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - req := ðpb.ListValidatorAssignmentsRequest{PublicKeys: [][]byte{{1}, {2}}, Indices: []uint64{2, 3}} - res, err := bs.ListValidatorAssignments(context.Background(), req) - 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[1:4] { - committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) - if err != nil { - t.Fatal(err) - } - wanted = append(wanted, ðpb.ValidatorAssignments_CommitteeAssignment{ - BeaconCommittees: committee, - CommitteeIndex: committeeIndex, - AttesterSlot: attesterSlot, - ProposerSlot: proposerSlot, - PublicKey: s.Validators[index].PublicKey, - }) - } - - if !reflect.DeepEqual(res.Assignments, wanted) { - t.Error("Did not receive wanted assignments") - } -} - -func TestServer_ListAssignmentsCanFilterPubkeysIndices_WithPagination(t *testing.T) { - helpers.ClearAllCaches() - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - count := 100 - 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 { - t.Fatal(err) - } - validators = append(validators, ðpb.Validator{PublicKey: []byte{byte(i)}, ExitEpoch: params.BeaconConfig().FarFutureEpoch}) - } - - blk := ðpb.BeaconBlock{ - Slot: 0, - } - blockRoot, err := ssz.SigningRoot(blk) - if err != nil { - t.Fatal(err) - } - if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { - t.Fatal(err) - } - - s := &pbp2p.BeaconState{ - Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)} - if err := db.SaveState(ctx, s, blockRoot); err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: s, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: 0, - }, - }, - } - - req := ðpb.ListValidatorAssignmentsRequest{Indices: []uint64{1, 2, 3, 4, 5, 6}, PageSize: 2, PageToken: "1"} - res, err := bs.ListValidatorAssignments(context.Background(), req) - if err != nil { - t.Fatal(err) - } - - // Construct the wanted assignments. - var assignments []*ethpb.ValidatorAssignments_CommitteeAssignment - - activeIndices, err := helpers.ActiveValidatorIndices(s, 0) - if err != nil { - t.Fatal(err) - } - for _, index := range activeIndices[3:5] { - committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) - if err != nil { - t.Fatal(err) - } - assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ - BeaconCommittees: committee, - CommitteeIndex: committeeIndex, - AttesterSlot: attesterSlot, - ProposerSlot: proposerSlot, - PublicKey: s.Validators[index].PublicKey, - }) - } - - wantedRes := ðpb.ValidatorAssignments{ - Assignments: assignments, - TotalSize: int32(len(req.Indices)), - NextPageToken: "2", - } - - if !reflect.DeepEqual(res, wantedRes) { - t.Error("Did not get wanted assignments") - } - - // Test the wrap around scenario. - assignments = nil - req = ðpb.ListValidatorAssignmentsRequest{Indices: []uint64{1, 2, 3, 4, 5, 6}, PageSize: 5, PageToken: "1"} - res, err = bs.ListValidatorAssignments(context.Background(), req) - if err != nil { - t.Fatal(err) - } - - for _, index := range activeIndices[6:7] { - committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) - if err != nil { - t.Fatal(err) - } - assignments = append(assignments, ðpb.ValidatorAssignments_CommitteeAssignment{ - BeaconCommittees: committee, - CommitteeIndex: committeeIndex, - AttesterSlot: attesterSlot, - ProposerSlot: proposerSlot, - PublicKey: s.Validators[index].PublicKey, - }) - } - - wantedRes = ðpb.ValidatorAssignments{ - Assignments: assignments, - TotalSize: int32(len(req.Indices)), - NextPageToken: "2", - } - - if !reflect.DeepEqual(res, wantedRes) { - t.Error("Did not receive wanted assignments") - } -} - -func TestServer_GetValidatorsParticipation_FromArchive(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - epoch := uint64(4) - part := ðpb.ValidatorParticipation{ - GlobalParticipationRate: 1.0, - VotedEther: 20, - EligibleEther: 20, - } - if err := db.SaveArchivedValidatorParticipation(ctx, epoch, part); err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{ - State: &pbp2p.BeaconState{Slot: helpers.StartSlot(epoch + 1)}, - }, - FinalizationFetcher: &mock.ChainService{ - FinalizedCheckPoint: ðpb.Checkpoint{ - Epoch: epoch + 1, - }, - }, - } - if _, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ - QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{ - Epoch: epoch + 2, - }, - }); err == nil { - t.Error("Expected error when requesting future epoch, received nil") - } - // We request data from epoch 0, which we didn't archive, so we should expect an error. - if _, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ - QueryFilter: ðpb.GetValidatorParticipationRequest_Genesis{ - Genesis: true, - }, - }); err == nil { - t.Error("Expected error when data from archive is not found, received nil") - } - - want := ðpb.ValidatorParticipationResponse{ - Epoch: epoch, - Finalized: true, - Participation: part, - } - res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ - QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{ - Epoch: epoch, - }, - }) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(want, res) { - t.Errorf("Wanted %v, received %v", want, res) - } -} - -func TestServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) { - helpers.ClearAllCaches() - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - - ctx := context.Background() - epoch := uint64(1) - attestedBalance := uint64(1) - validatorCount := uint64(100) - - 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 - } - - atts := []*pbp2p.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} - - s := &pbp2p.BeaconState{ - Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, - Validators: validators, - Balances: balances, - BlockRoots: make([][]byte, 128), - Slashings: []uint64{0, 1e9, 1e9}, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - CurrentEpochAttestations: atts, - FinalizedCheckpoint: ðpb.Checkpoint{}, - JustificationBits: bitfield.Bitvector4{0x00}, - CurrentJustifiedCheckpoint: ðpb.Checkpoint{}, - } - - bs := &Server{ - BeaconDB: db, - HeadFetcher: &mock.ChainService{State: s}, - } - - res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{}) - if err != nil { - t.Fatal(err) - } - - wanted := ðpb.ValidatorParticipation{ - VotedEther: attestedBalance, - EligibleEther: validatorCount * params.BeaconConfig().MaxEffectiveBalance, - GlobalParticipationRate: float32(attestedBalance) / float32(validatorCount*params.BeaconConfig().MaxEffectiveBalance), - } - - if !reflect.DeepEqual(res.Participation, wanted) { - t.Error("Incorrect validator participation respond") - } -} - -func TestServer_ListBlocks_Pagination(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - count := uint64(100) - blks := make([]*ethpb.BeaconBlock, count) - for i := uint64(0); i < count; i++ { - b := ðpb.BeaconBlock{ - Slot: i, - } - blks[i] = b - } - if err := db.SaveBlocks(ctx, blks); err != nil { - t.Fatal(err) - } - - root6, err := ssz.SigningRoot(ðpb.BeaconBlock{Slot: 6}) - if err != nil { - t.Fatal(err) - } - - bs := &Server{ - BeaconDB: db, - } - - tests := []struct { - req *ethpb.ListBlocksRequest - res *ethpb.ListBlocksResponse - }{ - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(0), - QueryFilter: ðpb.ListBlocksRequest_Slot{Slot: 5}, - PageSize: 3}, - res: ðpb.ListBlocksResponse{ - Blocks: []*ethpb.BeaconBlock{{Slot: 5}}, - NextPageToken: strconv.Itoa(1), - TotalSize: 1}}, - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(0), - QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]}, - PageSize: 3}, - res: ðpb.ListBlocksResponse{ - Blocks: []*ethpb.BeaconBlock{{Slot: 6}}, - TotalSize: 1}}, - {req: ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]}}, - res: ðpb.ListBlocksResponse{ - Blocks: []*ethpb.BeaconBlock{{Slot: 6}}, - TotalSize: 1}}, - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(0), - QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 0}, - PageSize: 100}, - res: ðpb.ListBlocksResponse{ - Blocks: blks[0:params.BeaconConfig().SlotsPerEpoch], - NextPageToken: strconv.Itoa(1), - TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(1), - QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 5}, - PageSize: 3}, - res: ðpb.ListBlocksResponse{ - Blocks: blks[43:46], - NextPageToken: strconv.Itoa(2), - TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(1), - QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 11}, - PageSize: 7}, - res: ðpb.ListBlocksResponse{ - Blocks: blks[95:96], - NextPageToken: strconv.Itoa(2), - TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, - {req: ðpb.ListBlocksRequest{ - PageToken: strconv.Itoa(0), - QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 12}, - PageSize: 4}, - res: ðpb.ListBlocksResponse{ - Blocks: blks[96:100], - NextPageToken: strconv.Itoa(1), - TotalSize: int32(params.BeaconConfig().SlotsPerEpoch / 2)}}, - } - - for _, test := range tests { - res, err := bs.ListBlocks(ctx, test.req) - if err != nil { - t.Fatal(err) - } - if !proto.Equal(res, test.res) { - t.Errorf("Incorrect blocks response, wanted %d, received %d", len(test.res.Blocks), len(res.Blocks)) - } - } -} - -func TestServer_ListBlocksErrors(t *testing.T) { - db := dbTest.SetupDB(t) - defer dbTest.TeardownDB(t, db) - ctx := context.Background() - - bs := &Server{BeaconDB: db} - exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) - - wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) - req := ðpb.ListBlocksRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} - if _, err := bs.ListBlocks(ctx, req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } - - wanted = "must satisfy one of the filter requirement" - req = ðpb.ListBlocksRequest{} - if _, err := bs.ListBlocks(ctx, req); !strings.Contains(err.Error(), wanted) { - t.Errorf("Expected error %v, received %v", wanted, err) - } - - req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{}} - res, err := bs.ListBlocks(ctx, req) - if err != nil { - t.Fatal(err) - } - if len(res.Blocks) != 0 { - t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) - } - if res.TotalSize != 0 { - t.Errorf("wanted total size 0, got size %d", res.TotalSize) - } - - req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Slot{}} - res, err = bs.ListBlocks(ctx, req) - if err != nil { - t.Fatal(err) - } - if len(res.Blocks) != 0 { - t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) - } - if res.TotalSize != 0 { - t.Errorf("wanted total size 0, got size %d", res.TotalSize) - - } - - req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: []byte{'A'}}} - res, err = bs.ListBlocks(ctx, req) - if err != nil { - t.Fatal(err) - } - if len(res.Blocks) != 0 { - t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) - } - if res.TotalSize != 0 { - t.Errorf("wanted total size 0, got size %d", res.TotalSize) - - } - - req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: []byte{'A'}}} - res, err = bs.ListBlocks(ctx, req) - if err != nil { - t.Fatal(err) - } - if len(res.Blocks) != 0 { - t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) - } - if res.TotalSize != 0 { - t.Errorf("wanted total size 0, got size %d", res.TotalSize) - - } -} - -func TestServer_GetChainHead(t *testing.T) { - s := &pbp2p.BeaconState{ - PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: []byte{'A'}}, - CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: []byte{'B'}}, - FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 1, Root: []byte{'C'}}, - } - - bs := &Server{HeadFetcher: &mock.ChainService{State: s}} - - head, err := bs.GetChainHead(context.Background(), nil) - if err != nil { - t.Fatal(err) - } - if head.PreviousJustifiedSlot != 3*params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Wanted PreviousJustifiedSlot: %d, got: %d", - 3*params.BeaconConfig().SlotsPerEpoch, head.PreviousJustifiedSlot) - } - if head.JustifiedSlot != 2*params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Wanted JustifiedSlot: %d, got: %d", - 2*params.BeaconConfig().SlotsPerEpoch, head.JustifiedSlot) - } - if head.FinalizedSlot != 1*params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Wanted FinalizedSlot: %d, got: %d", - 1*params.BeaconConfig().SlotsPerEpoch, head.FinalizedSlot) - } - if !bytes.Equal([]byte{'A'}, head.PreviousJustifiedBlockRoot) { - t.Errorf("Wanted PreviousJustifiedBlockRoot: %v, got: %v", - []byte{'A'}, head.PreviousJustifiedBlockRoot) - } - if !bytes.Equal([]byte{'B'}, head.JustifiedBlockRoot) { - t.Errorf("Wanted JustifiedBlockRoot: %v, got: %v", - []byte{'B'}, head.JustifiedBlockRoot) - } - if !bytes.Equal([]byte{'C'}, head.FinalizedBlockRoot) { - t.Errorf("Wanted FinalizedBlockRoot: %v, got: %v", - []byte{'C'}, head.FinalizedBlockRoot) - } -} - -func setupValidators(t *testing.T, db db.Database, count int) ([]*ethpb.Validator, []uint64) { - ctx := context.Background() - balances := make([]uint64, count) - 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 { - t.Fatal(err) - } - balances[i] = uint64(i) - validators = append(validators, ðpb.Validator{ - PublicKey: []byte{byte(i)}, - }) - } - blk := ðpb.BeaconBlock{ - Slot: 0, - } - blockRoot, err := ssz.SigningRoot(blk) - if err != nil { - t.Fatal(err) - } - if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { - t.Fatal(err) - } - if err := db.SaveState( - context.Background(), - &pbp2p.BeaconState{Validators: validators, Balances: balances}, - blockRoot, - ); err != nil { - t.Fatal(err) - } - return validators, balances -} diff --git a/beacon-chain/rpc/beacon/blocks_test.go b/beacon-chain/rpc/beacon/blocks_test.go new file mode 100644 index 000000000000..ece95cf348f9 --- /dev/null +++ b/beacon-chain/rpc/beacon/blocks_test.go @@ -0,0 +1,181 @@ +package beacon + +import ( + "context" + "fmt" + "strconv" + "strings" + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/prysmaticlabs/go-ssz" + dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" +) + +func TestServer_ListBlocks_Pagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + count := uint64(100) + blks := make([]*ethpb.BeaconBlock, count) + for i := uint64(0); i < count; i++ { + b := ðpb.BeaconBlock{ + Slot: i, + } + blks[i] = b + } + if err := db.SaveBlocks(ctx, blks); err != nil { + t.Fatal(err) + } + + root6, err := ssz.SigningRoot(ðpb.BeaconBlock{Slot: 6}) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + } + + tests := []struct { + req *ethpb.ListBlocksRequest + res *ethpb.ListBlocksResponse + }{ + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(0), + QueryFilter: ðpb.ListBlocksRequest_Slot{Slot: 5}, + PageSize: 3}, + res: ðpb.ListBlocksResponse{ + Blocks: []*ethpb.BeaconBlock{{Slot: 5}}, + NextPageToken: strconv.Itoa(1), + TotalSize: 1}}, + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(0), + QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]}, + PageSize: 3}, + res: ðpb.ListBlocksResponse{ + Blocks: []*ethpb.BeaconBlock{{Slot: 6}}, + TotalSize: 1}}, + {req: ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: root6[:]}}, + res: ðpb.ListBlocksResponse{ + Blocks: []*ethpb.BeaconBlock{{Slot: 6}}, + TotalSize: 1}}, + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(0), + QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 0}, + PageSize: 100}, + res: ðpb.ListBlocksResponse{ + Blocks: blks[0:params.BeaconConfig().SlotsPerEpoch], + NextPageToken: strconv.Itoa(1), + TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(1), + QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 5}, + PageSize: 3}, + res: ðpb.ListBlocksResponse{ + Blocks: blks[43:46], + NextPageToken: strconv.Itoa(2), + TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(1), + QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 11}, + PageSize: 7}, + res: ðpb.ListBlocksResponse{ + Blocks: blks[95:96], + NextPageToken: strconv.Itoa(2), + TotalSize: int32(params.BeaconConfig().SlotsPerEpoch)}}, + {req: ðpb.ListBlocksRequest{ + PageToken: strconv.Itoa(0), + QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: 12}, + PageSize: 4}, + res: ðpb.ListBlocksResponse{ + Blocks: blks[96:100], + NextPageToken: strconv.Itoa(1), + TotalSize: int32(params.BeaconConfig().SlotsPerEpoch / 2)}}, + } + + for _, test := range tests { + res, err := bs.ListBlocks(ctx, test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Incorrect blocks response, wanted %d, received %d", len(test.res.Blocks), len(res.Blocks)) + } + } +} + +func TestServer_ListBlocks_Errors(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + + bs := &Server{BeaconDB: db} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) + req := ðpb.ListBlocksRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.ListBlocks(ctx, req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } + + wanted = "must satisfy one of the filter requirement" + req = ðpb.ListBlocksRequest{} + if _, err := bs.ListBlocks(ctx, req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } + + req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{}} + res, err := bs.ListBlocks(ctx, req) + if err != nil { + t.Fatal(err) + } + if len(res.Blocks) != 0 { + t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) + } + if res.TotalSize != 0 { + t.Errorf("wanted total size 0, got size %d", res.TotalSize) + } + + req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Slot{}} + res, err = bs.ListBlocks(ctx, req) + if err != nil { + t.Fatal(err) + } + if len(res.Blocks) != 0 { + t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) + } + if res.TotalSize != 0 { + t.Errorf("wanted total size 0, got size %d", res.TotalSize) + + } + + req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: []byte{'A'}}} + res, err = bs.ListBlocks(ctx, req) + if err != nil { + t.Fatal(err) + } + if len(res.Blocks) != 0 { + t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) + } + if res.TotalSize != 0 { + t.Errorf("wanted total size 0, got size %d", res.TotalSize) + + } + + req = ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Root{Root: []byte{'A'}}} + res, err = bs.ListBlocks(ctx, req) + if err != nil { + t.Fatal(err) + } + if len(res.Blocks) != 0 { + t.Errorf("wanted empty list, got a list of %d", len(res.Blocks)) + } + if res.TotalSize != 0 { + t.Errorf("wanted total size 0, got size %d", res.TotalSize) + + } +} diff --git a/beacon-chain/rpc/beacon/validators_test.go b/beacon-chain/rpc/beacon/validators_test.go new file mode 100644 index 000000000000..539d084bb718 --- /dev/null +++ b/beacon-chain/rpc/beacon/validators_test.go @@ -0,0 +1,989 @@ +package beacon + +import ( + "bytes" + "context" + "fmt" + "reflect" + "strconv" + "strings" + "testing" + + "github.com/gogo/protobuf/proto" + ptypes "github.com/gogo/protobuf/types" + "github.com/prysmaticlabs/go-bitfield" + "github.com/prysmaticlabs/go-ssz" + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/beacon-chain/db" + dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" +) + +func init() { + // Use minimal config to reduce test setup time. + params.OverrideBeaconConfig(params.MinimalSpecConfig()) +} + +func TestServer_ListValidatorBalances_PaginationOutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + setupValidators(t, db, 3) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 100} + wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(headState.Balances)) + if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf( + "requested page size %d can not be greater than max size %d", + exceedsMax, + params.BeaconConfig().MaxPageSize, + ) + req := ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.ListValidatorBalances(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListValidatorBalances_NoPagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + setupValidators(t, db, 100) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: headState}, + } + + tests := []struct { + req *ethpb.GetValidatorBalancesRequest + res *ethpb.ValidatorBalances + }{ + {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{99}}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 99, PublicKey: []byte{99}, Balance: 99}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 1, + }, + }, + {req: ðpb.GetValidatorBalancesRequest{Indices: []uint64{1, 2, 3}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 1, PublicKey: []byte{1}, Balance: 1}, + {Index: 2, PublicKey: []byte{2}, Balance: 2}, + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, + }, + }, + {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{10}, {11}, {12}}}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 10, PublicKey: []byte{10}, Balance: 10}, + {Index: 11, PublicKey: []byte{11}, Balance: 11}, + {Index: 12, PublicKey: []byte{12}, Balance: 12}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, + }}, + {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{2}, {3}}, Indices: []uint64{3, 4}}, // Duplication + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 2, PublicKey: []byte{2}, Balance: 2}, + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + {Index: 4, PublicKey: []byte{4}, Balance: 4}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 3, + }}, + {req: ðpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{}}, Indices: []uint64{3, 4}}, // Public key has a blank value + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {Index: 3, PublicKey: []byte{3}, Balance: 3}, + {Index: 4, PublicKey: []byte{4}, Balance: 4}, + }, + NextPageToken: strconv.Itoa(1), + TotalSize: 2, + }}, + } + for _, test := range tests { + res, err := bs.ListValidatorBalances(context.Background(), test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Expected %v, received %v", test.res, res) + } + } +} + +func TestServer_ListValidatorBalances_Pagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + count := 1000 + setupValidators(t, db, count) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + tests := []struct { + req *ethpb.GetValidatorBalancesRequest + res *ethpb.ValidatorBalances + }{ + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 3}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{3}, Index: 3, Balance: uint64(3)}, + {PublicKey: []byte{4}, Index: 4, Balance: uint64(4)}, + {PublicKey: []byte{5}, Index: 5, Balance: uint64(5)}}, + NextPageToken: strconv.Itoa(2), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(10), PageSize: 5}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{50}, Index: 50, Balance: uint64(50)}, + {PublicKey: []byte{51}, Index: 51, Balance: uint64(51)}, + {PublicKey: []byte{52}, Index: 52, Balance: uint64(52)}, + {PublicKey: []byte{53}, Index: 53, Balance: uint64(53)}, + {PublicKey: []byte{54}, Index: 54, Balance: uint64(54)}}, + NextPageToken: strconv.Itoa(11), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(33), PageSize: 3}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{99}, Index: 99, Balance: uint64(99)}, + {PublicKey: []byte{100}, Index: 100, Balance: uint64(100)}, + {PublicKey: []byte{101}, Index: 101, Balance: uint64(101)}, + }, + NextPageToken: strconv.Itoa(34), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorBalancesRequest{PageSize: 2}, + res: ðpb.ValidatorBalances{ + Balances: []*ethpb.ValidatorBalances_Balance{ + {PublicKey: []byte{0}, Index: 0, Balance: uint64(0)}, + {PublicKey: []byte{1}, Index: 1, Balance: uint64(1)}}, + NextPageToken: strconv.Itoa(1), + TotalSize: int32(count)}}, + } + for _, test := range tests { + res, err := bs.ListValidatorBalances(context.Background(), test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Expected %v, received %v", test.res, res) + } + } +} + +func TestServer_ListValidatorBalances_OutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + setupValidators(t, db, 1) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: headState}, + } + + req := ðpb.GetValidatorBalancesRequest{Indices: []uint64{uint64(1)}} + wanted := "does not exist" + if _, err := bs.ListValidatorBalances(context.Background(), req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListValidatorBalances_FromArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + epoch := uint64(0) + validators, balances := setupValidators(t, db, 100) + + if err := db.SaveArchivedBalances(ctx, epoch, balances); err != nil { + t.Fatal(err) + } + + newerBalances := make([]uint64, len(balances)) + for i := 0; i < len(newerBalances); i++ { + newerBalances[i] = balances[i] * 2 + } + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: &pbp2p.BeaconState{ + Slot: params.BeaconConfig().SlotsPerEpoch * 3, + Validators: validators, + Balances: newerBalances, + }, + }, + } + + req := ðpb.GetValidatorBalancesRequest{ + QueryFilter: ðpb.GetValidatorBalancesRequest_Epoch{Epoch: 0}, + Indices: []uint64{uint64(1)}, + } + res, err := bs.ListValidatorBalances(context.Background(), req) + if err != nil { + t.Fatal(err) + } + // We should expect a response containing the old balance from epoch 0, + // not the new balance from the current state. + want := []*ethpb.ValidatorBalances_Balance{ + { + PublicKey: validators[1].PublicKey, + Index: 1, + Balance: balances[1], + }, + } + if !reflect.DeepEqual(want, res.Balances) { + t.Errorf("Wanted %v, received %v", want, res.Balances) + } +} + +func TestServer_ListValidatorBalances_FromArchive_NewValidatorNotFound(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + epoch := uint64(0) + _, balances := setupValidators(t, db, 100) + + if err := db.SaveArchivedBalances(ctx, epoch, balances); err != nil { + t.Fatal(err) + } + + newValidators, newBalances := setupValidators(t, db, 200) + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: &pbp2p.BeaconState{ + Slot: params.BeaconConfig().SlotsPerEpoch * 3, + Validators: newValidators, + Balances: newBalances, + }, + }, + } + + req := ðpb.GetValidatorBalancesRequest{ + QueryFilter: ðpb.GetValidatorBalancesRequest_Epoch{Epoch: 0}, + Indices: []uint64{1, 150, 161}, + } + if _, err := bs.ListValidatorBalances(context.Background(), req); !strings.Contains(err.Error(), "does not exist") { + t.Errorf("Wanted out of range error for including newer validators in the arguments, received %v", err) + } +} + +func TestServer_GetValidators_NoPagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + validators, _ := setupValidators(t, db, 100) + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + received, err := bs.GetValidators(context.Background(), ðpb.GetValidatorsRequest{}) + if err != nil { + t.Fatal(err) + } + + if !reflect.DeepEqual(validators, received.Validators) { + t.Fatal("Incorrect respond of validators") + } +} + +func TestServer_GetValidators_Pagination(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + count := 100 + setupValidators(t, db, count) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + tests := []struct { + req *ethpb.GetValidatorsRequest + res *ethpb.Validators + }{ + {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(1), PageSize: 3}, + res: ðpb.Validators{ + Validators: []*ethpb.Validator{ + {PublicKey: []byte{3}}, + {PublicKey: []byte{4}}, + {PublicKey: []byte{5}}}, + NextPageToken: strconv.Itoa(2), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(10), PageSize: 5}, + res: ðpb.Validators{ + Validators: []*ethpb.Validator{ + {PublicKey: []byte{50}}, + {PublicKey: []byte{51}}, + {PublicKey: []byte{52}}, + {PublicKey: []byte{53}}, + {PublicKey: []byte{54}}}, + NextPageToken: strconv.Itoa(11), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(33), PageSize: 3}, + res: ðpb.Validators{ + Validators: []*ethpb.Validator{ + {PublicKey: []byte{99}}}, + NextPageToken: strconv.Itoa(34), + TotalSize: int32(count)}}, + {req: ðpb.GetValidatorsRequest{PageSize: 2}, + res: ðpb.Validators{ + Validators: []*ethpb.Validator{ + {PublicKey: []byte{0}}, + {PublicKey: []byte{1}}}, + NextPageToken: strconv.Itoa(1), + TotalSize: int32(count)}}, + } + for _, test := range tests { + res, err := bs.GetValidators(context.Background(), test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Error("Incorrect respond of validators") + } + } +} + +func TestServer_GetValidators_PaginationOutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + count := 1 + validators, _ := setupValidators(t, db, count) + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + req := ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(1), PageSize: 100} + wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, len(validators)) + if _, err := bs.GetValidators(context.Background(), req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_GetValidators_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf("requested page size %d can not be greater than max size %d", exceedsMax, params.BeaconConfig().MaxPageSize) + req := ðpb.GetValidatorsRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.GetValidators(context.Background(), req); !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_GetValidators_DefaultPageSize(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + validators, _ := setupValidators(t, db, 1000) + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 0, + }, + }, + } + + req := ðpb.GetValidatorsRequest{} + res, err := bs.GetValidators(context.Background(), req) + if err != nil { + t.Fatal(err) + } + + i := 0 + j := params.BeaconConfig().DefaultPageSize + if !reflect.DeepEqual(res.Validators, validators[i:j]) { + t.Error("Incorrect respond of validators") + } +} + +func TestServer_GetValidators_FromOldEpoch(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + numEpochs := 30 + validators := make([]*ethpb.Validator, numEpochs) + for i := 0; i < numEpochs; i++ { + validators[i] = ðpb.Validator{ + ActivationEpoch: uint64(i), + } + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: &pbp2p.BeaconState{ + Validators: validators, + }, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: 200, + }, + }, + } + + req := ðpb.GetValidatorsRequest{ + QueryFilter: ðpb.GetValidatorsRequest_Genesis{ + Genesis: true, + }, + } + res, err := bs.GetValidators(context.Background(), req) + if err != nil { + t.Fatal(err) + } + if len(res.Validators) != 1 { + t.Errorf("Wanted 1 validator at genesis, received %d", len(res.Validators)) + } + + req = ðpb.GetValidatorsRequest{ + QueryFilter: ðpb.GetValidatorsRequest_Epoch{ + Epoch: 20, + }, + } + res, err = bs.GetValidators(context.Background(), req) + if err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(res.Validators, validators[:21]) { + t.Errorf("Incorrect number of validators, wanted %d received %d", 20, len(res.Validators)) + } +} + +func TestServer_GetValidatorActiveSetChanges(t *testing.T) { + ctx := context.Background() + validators := make([]*ethpb.Validator, 6) + headState := &pbp2p.BeaconState{ + Slot: 0, + Validators: validators, + } + for i := 0; i < len(validators); i++ { + activationEpoch := params.BeaconConfig().FarFutureEpoch + withdrawableEpoch := params.BeaconConfig().FarFutureEpoch + exitEpoch := params.BeaconConfig().FarFutureEpoch + slashed := false + // Mark indices divisible by two as activated. + if i%2 == 0 { + activationEpoch = helpers.DelayedActivationExitEpoch(0) + } else if i%3 == 0 { + // Mark indices divisible by 3 as slashed. + withdrawableEpoch = params.BeaconConfig().EpochsPerSlashingsVector + slashed = true + } else if i%5 == 0 { + // Mark indices divisible by 5 as exited. + exitEpoch = 0 + withdrawableEpoch = params.BeaconConfig().MinValidatorWithdrawabilityDelay + } + headState.Validators[i] = ðpb.Validator{ + ActivationEpoch: activationEpoch, + PublicKey: []byte(strconv.Itoa(i)), + WithdrawableEpoch: withdrawableEpoch, + Slashed: slashed, + ExitEpoch: exitEpoch, + } + } + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 0}, + }, + } + res, err := bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{}) + if err != nil { + t.Fatal(err) + } + wantedActive := [][]byte{ + []byte("0"), + []byte("2"), + []byte("4"), + } + wantedSlashed := [][]byte{ + []byte("3"), + } + wantedExited := [][]byte{ + []byte("5"), + } + wanted := ðpb.ActiveSetChanges{ + Epoch: 0, + ActivatedPublicKeys: wantedActive, + ExitedPublicKeys: wantedExited, + SlashedPublicKeys: wantedSlashed, + } + if !proto.Equal(wanted, res) { + t.Errorf("Wanted %v, received %v", wanted, res) + } +} + +func TestServer_GetValidatorActiveSetChanges_FromArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + validators := make([]*ethpb.Validator, 6) + headState := &pbp2p.BeaconState{ + Slot: 0, + Validators: validators, + } + activatedIndices := make([]uint64, 0) + slashedIndices := make([]uint64, 0) + exitedIndices := make([]uint64, 0) + for i := 0; i < len(validators); i++ { + // Mark indices divisible by two as activated. + if i%2 == 0 { + activatedIndices = append(activatedIndices, uint64(i)) + } else if i%3 == 0 { + // Mark indices divisible by 3 as slashed. + slashedIndices = append(slashedIndices, uint64(i)) + } else if i%5 == 0 { + // Mark indices divisible by 5 as exited. + exitedIndices = append(exitedIndices, uint64(i)) + } + headState.Validators[i] = ðpb.Validator{ + PublicKey: []byte(strconv.Itoa(i)), + } + } + archivedChanges := ðpb.ArchivedActiveSetChanges{ + Activated: activatedIndices, + Exited: exitedIndices, + Slashed: slashedIndices, + } + // We store the changes during the genesis epoch. + if err := db.SaveArchivedActiveValidatorChanges(ctx, 0, archivedChanges); err != nil { + t.Fatal(err) + } + // We store the same changes during epoch 5 for further testing. + if err := db.SaveArchivedActiveValidatorChanges(ctx, 5, archivedChanges); err != nil { + t.Fatal(err) + } + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: headState, + }, + FinalizationFetcher: &mock.ChainService{ + // Pick an epoch far in the future so that we trigger fetching from the archive. + FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 100}, + }, + } + res, err := bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{ + QueryFilter: ðpb.GetValidatorActiveSetChangesRequest_Genesis{Genesis: true}, + }) + if err != nil { + t.Fatal(err) + } + wantedActive := [][]byte{ + []byte("0"), + []byte("2"), + []byte("4"), + } + wantedSlashed := [][]byte{ + []byte("3"), + } + wantedExited := [][]byte{ + []byte("5"), + } + wanted := ðpb.ActiveSetChanges{ + Epoch: 0, + ActivatedPublicKeys: wantedActive, + ExitedPublicKeys: wantedExited, + SlashedPublicKeys: wantedSlashed, + } + if !proto.Equal(wanted, res) { + t.Errorf("Wanted %v, received %v", wanted, res) + } + res, err = bs.GetValidatorActiveSetChanges(ctx, ðpb.GetValidatorActiveSetChangesRequest{ + QueryFilter: ðpb.GetValidatorActiveSetChangesRequest_Epoch{Epoch: 5}, + }) + if err != nil { + t.Fatal(err) + } + wanted.Epoch = 5 + if !proto.Equal(wanted, res) { + t.Errorf("Wanted %v, received %v", wanted, res) + } +} + +func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) { + headState := &pbp2p.BeaconState{ + Validators: []*ethpb.Validator{ + { + ActivationEpoch: helpers.DelayedActivationExitEpoch(0), + ActivationEligibilityEpoch: 3, + PublicKey: []byte("3"), + }, + { + ActivationEpoch: helpers.DelayedActivationExitEpoch(0), + ActivationEligibilityEpoch: 2, + PublicKey: []byte("2"), + }, + { + ActivationEpoch: helpers.DelayedActivationExitEpoch(0), + ActivationEligibilityEpoch: 1, + PublicKey: []byte("1"), + }, + }, + FinalizedCheckpoint: ðpb.Checkpoint{ + Epoch: 0, + }, + } + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + res, err := bs.GetValidatorQueue(context.Background(), &ptypes.Empty{}) + if err != nil { + t.Fatal(err) + } + // We verify the keys are properly sorted by the validators' activation eligibility epoch. + wanted := [][]byte{ + []byte("1"), + []byte("2"), + []byte("3"), + } + wantChurn, err := helpers.ValidatorChurnLimit(headState) + if err != nil { + t.Fatal(err) + } + if res.ChurnLimit != wantChurn { + t.Errorf("Wanted churn %d, received %d", wantChurn, res.ChurnLimit) + } + if !reflect.DeepEqual(res.ActivationPublicKeys, wanted) { + t.Errorf("Wanted %v, received %v", wanted, res.ActivationPublicKeys) + } +} + +func TestServer_GetValidatorQueue_PendingExit(t *testing.T) { + headState := &pbp2p.BeaconState{ + Validators: []*ethpb.Validator{ + { + ActivationEpoch: 0, + ExitEpoch: 4, + WithdrawableEpoch: 3, + PublicKey: []byte("3"), + }, + { + ActivationEpoch: 0, + ExitEpoch: 4, + WithdrawableEpoch: 2, + PublicKey: []byte("2"), + }, + { + ActivationEpoch: 0, + ExitEpoch: 4, + WithdrawableEpoch: 1, + PublicKey: []byte("1"), + }, + }, + FinalizedCheckpoint: ðpb.Checkpoint{ + Epoch: 0, + }, + } + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + res, err := bs.GetValidatorQueue(context.Background(), &ptypes.Empty{}) + if err != nil { + t.Fatal(err) + } + // We verify the keys are properly sorted by the validators' withdrawable epoch. + wanted := [][]byte{ + []byte("1"), + []byte("2"), + []byte("3"), + } + wantChurn, err := helpers.ValidatorChurnLimit(headState) + if err != nil { + t.Fatal(err) + } + if res.ChurnLimit != wantChurn { + t.Errorf("Wanted churn %d, received %d", wantChurn, res.ChurnLimit) + } + if !reflect.DeepEqual(res.ExitPublicKeys, wanted) { + t.Errorf("Wanted %v, received %v", wanted, res.ExitPublicKeys) + } +} + +func TestServer_GetValidatorsParticipation_FromArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + ctx := context.Background() + epoch := uint64(4) + part := ðpb.ValidatorParticipation{ + GlobalParticipationRate: 1.0, + VotedEther: 20, + EligibleEther: 20, + } + if err := db.SaveArchivedValidatorParticipation(ctx, epoch, part); err != nil { + t.Fatal(err) + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{ + State: &pbp2p.BeaconState{Slot: helpers.StartSlot(epoch + 1)}, + }, + FinalizationFetcher: &mock.ChainService{ + FinalizedCheckPoint: ðpb.Checkpoint{ + Epoch: epoch + 1, + }, + }, + } + if _, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ + QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{ + Epoch: epoch + 2, + }, + }); err == nil { + t.Error("Expected error when requesting future epoch, received nil") + } + // We request data from epoch 0, which we didn't archive, so we should expect an error. + if _, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ + QueryFilter: ðpb.GetValidatorParticipationRequest_Genesis{ + Genesis: true, + }, + }); err == nil { + t.Error("Expected error when data from archive is not found, received nil") + } + + want := ðpb.ValidatorParticipationResponse{ + Epoch: epoch, + Finalized: true, + Participation: part, + } + res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{ + QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{ + Epoch: epoch, + }, + }) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(want, res) { + t.Errorf("Wanted %v, received %v", want, res) + } +} + +func TestServer_GetValidatorsParticipation_CurrentEpoch(t *testing.T) { + helpers.ClearAllCaches() + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + ctx := context.Background() + epoch := uint64(1) + attestedBalance := uint64(1) + validatorCount := uint64(100) + + 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 + } + + atts := []*pbp2p.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}}} + + s := &pbp2p.BeaconState{ + Slot: epoch*params.BeaconConfig().SlotsPerEpoch + 1, + Validators: validators, + Balances: balances, + BlockRoots: make([][]byte, 128), + Slashings: []uint64{0, 1e9, 1e9}, + RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + CurrentEpochAttestations: atts, + FinalizedCheckpoint: ðpb.Checkpoint{}, + JustificationBits: bitfield.Bitvector4{0x00}, + CurrentJustifiedCheckpoint: ðpb.Checkpoint{}, + } + + bs := &Server{ + BeaconDB: db, + HeadFetcher: &mock.ChainService{State: s}, + } + + res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{}) + if err != nil { + t.Fatal(err) + } + + wanted := ðpb.ValidatorParticipation{ + VotedEther: attestedBalance, + EligibleEther: validatorCount * params.BeaconConfig().MaxEffectiveBalance, + GlobalParticipationRate: float32(attestedBalance) / float32(validatorCount*params.BeaconConfig().MaxEffectiveBalance), + } + + if !reflect.DeepEqual(res.Participation, wanted) { + t.Error("Incorrect validator participation respond") + } +} + +func TestServer_GetChainHead(t *testing.T) { + s := &pbp2p.BeaconState{ + PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: []byte{'A'}}, + CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: []byte{'B'}}, + FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 1, Root: []byte{'C'}}, + } + + bs := &Server{HeadFetcher: &mock.ChainService{State: s}} + + head, err := bs.GetChainHead(context.Background(), nil) + if err != nil { + t.Fatal(err) + } + if head.PreviousJustifiedSlot != 3*params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Wanted PreviousJustifiedSlot: %d, got: %d", + 3*params.BeaconConfig().SlotsPerEpoch, head.PreviousJustifiedSlot) + } + if head.JustifiedSlot != 2*params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Wanted JustifiedSlot: %d, got: %d", + 2*params.BeaconConfig().SlotsPerEpoch, head.JustifiedSlot) + } + if head.FinalizedSlot != 1*params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Wanted FinalizedSlot: %d, got: %d", + 1*params.BeaconConfig().SlotsPerEpoch, head.FinalizedSlot) + } + if !bytes.Equal([]byte{'A'}, head.PreviousJustifiedBlockRoot) { + t.Errorf("Wanted PreviousJustifiedBlockRoot: %v, got: %v", + []byte{'A'}, head.PreviousJustifiedBlockRoot) + } + if !bytes.Equal([]byte{'B'}, head.JustifiedBlockRoot) { + t.Errorf("Wanted JustifiedBlockRoot: %v, got: %v", + []byte{'B'}, head.JustifiedBlockRoot) + } + if !bytes.Equal([]byte{'C'}, head.FinalizedBlockRoot) { + t.Errorf("Wanted FinalizedBlockRoot: %v, got: %v", + []byte{'C'}, head.FinalizedBlockRoot) + } +} + +func setupValidators(t *testing.T, db db.Database, count int) ([]*ethpb.Validator, []uint64) { + ctx := context.Background() + balances := make([]uint64, count) + 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 { + t.Fatal(err) + } + balances[i] = uint64(i) + validators = append(validators, ðpb.Validator{ + PublicKey: []byte{byte(i)}, + }) + } + blk := ðpb.BeaconBlock{ + Slot: 0, + } + blockRoot, err := ssz.SigningRoot(blk) + if err != nil { + t.Fatal(err) + } + if err := db.SaveHeadBlockRoot(ctx, blockRoot); err != nil { + t.Fatal(err) + } + if err := db.SaveState( + context.Background(), + &pbp2p.BeaconState{Validators: validators, Balances: balances}, + blockRoot, + ); err != nil { + t.Fatal(err) + } + return validators, balances +} diff --git a/beacon-chain/rpc/proposer/BUILD.bazel b/beacon-chain/rpc/proposer/BUILD.bazel index fceeb69bc30f..089516899381 100644 --- a/beacon-chain/rpc/proposer/BUILD.bazel +++ b/beacon-chain/rpc/proposer/BUILD.bazel @@ -36,6 +36,7 @@ go_test( name = "go_default_test", srcs = ["proposer_server_test.go"], embed = [":go_default_library"], + shard_count = 4, deps = [ "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index 0c2653282e1f..dc9e7eb7c852 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -30,6 +30,7 @@ go_test( name = "go_default_test", srcs = ["validator_server_test.go"], embed = [":go_default_library"], + shard_count = 4, deps = [ "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", From c5d1879ec6ecce9f3b1a580ac3f71470113eca03 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 22:49:49 -0600 Subject: [PATCH 56/82] validator folder --- beacon-chain/rpc/service_test.go | 2 +- beacon-chain/rpc/validator/BUILD.bazel | 12 +- beacon-chain/rpc/validator/assignments.go | 84 ++ .../rpc/validator/assignments_test.go | 290 ++++++ beacon-chain/rpc/validator/status.go | 188 ++++ beacon-chain/rpc/validator/status_test.go | 643 +++++++++++++ .../rpc/validator/validator_server.go | 253 +---- .../rpc/validator/validator_server_test.go | 891 ------------------ 8 files changed, 1220 insertions(+), 1143 deletions(-) create mode 100644 beacon-chain/rpc/validator/assignments.go create mode 100644 beacon-chain/rpc/validator/assignments_test.go create mode 100644 beacon-chain/rpc/validator/status.go create mode 100644 beacon-chain/rpc/validator/status_test.go diff --git a/beacon-chain/rpc/service_test.go b/beacon-chain/rpc/service_test.go index ae20d8cd8739..c7d6fb96659c 100644 --- a/beacon-chain/rpc/service_test.go +++ b/beacon-chain/rpc/service_test.go @@ -47,7 +47,7 @@ func TestRPC_BadEndpoint(t *testing.T) { rpcService := NewService(context.Background(), &Config{ Port: "ralph merkle!!!", - SyncService: &mockSync.Sync{IsSyncing: false}, + SyncService: &mockSync.Sync{IsSyncing: true}, BlockReceiver: &mock.ChainService{}, AttestationReceiver: &mock.ChainService{}, HeadFetcher: &mock.ChainService{}, diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index dc9e7eb7c852..faff21662edf 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -2,7 +2,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["validator_server.go"], + srcs = [ + "assignments.go", + "status.go", + "validator_server.go", + ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator", visibility = ["//beacon-chain:__subpackages__"], deps = [ @@ -28,7 +32,11 @@ go_library( go_test( name = "go_default_test", - srcs = ["validator_server_test.go"], + srcs = [ + "assignments_test.go", + "status_test.go", + "validator_server_test.go", + ], embed = [":go_default_library"], shard_count = 4, deps = [ diff --git a/beacon-chain/rpc/validator/assignments.go b/beacon-chain/rpc/validator/assignments.go new file mode 100644 index 000000000000..21edd146f047 --- /dev/null +++ b/beacon-chain/rpc/validator/assignments.go @@ -0,0 +1,84 @@ +package validator + +import ( + "context" + + "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/beacon-chain/core/state" + pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// CommitteeAssignment returns the committee assignment response from a given validator public key. +// The committee assignment response contains the following fields for the current and previous epoch: +// 1.) The list of validators in the committee. +// 2.) The shard to which the committee is assigned. +// 3.) The slot at which the committee is assigned. +// 4.) The bool signaling if the validator is expected to propose a block at the assigned slot. +func (vs *Server) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error) { + if vs.SyncChecker.Syncing() { + return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") + } + + var err error + s := vs.HeadFetcher.HeadState() + // Advance state with empty transitions up to the requested epoch start slot. + if epochStartSlot := helpers.StartSlot(req.EpochStart); s.Slot < epochStartSlot { + s, err = state.ProcessSlots(ctx, s, epochStartSlot) + if err != nil { + return nil, errors.Wrapf(err, "could not process slots up to %d", epochStartSlot) + } + } + + var assignments []*pb.AssignmentResponse_ValidatorAssignment + for _, pubKey := range req.PublicKeys { + if ctx.Err() != nil { + return nil, ctx.Err() + } + // Default assignment + assignment := &pb.AssignmentResponse_ValidatorAssignment{ + PublicKey: pubKey, + Status: pb.ValidatorStatus_UNKNOWN_STATUS, + } + + idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + if err != nil { + return nil, err + } + if ok { + status := vs.assignmentStatus(uint64(idx), s) + assignment.Status = status + if status == pb.ValidatorStatus_ACTIVE { + assignment, err = vs.assignment(uint64(idx), s, req.EpochStart) + if err != nil { + return nil, err + } + assignment.PublicKey = pubKey + } + } + assignments = append(assignments, assignment) + } + + return &pb.AssignmentResponse{ + ValidatorAssignment: assignments, + }, nil +} + +func (vs *Server) assignment(idx uint64, beaconState *pbp2p.BeaconState, epoch uint64) (*pb.AssignmentResponse_ValidatorAssignment, error) { + 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, + CommitteeIndex: committeeIndex, + AttesterSlot: aSlot, + ProposerSlot: pSlot, + Status: status, + }, nil +} diff --git a/beacon-chain/rpc/validator/assignments_test.go b/beacon-chain/rpc/validator/assignments_test.go new file mode 100644 index 000000000000..a4e90f5b01f7 --- /dev/null +++ b/beacon-chain/rpc/validator/assignments_test.go @@ -0,0 +1,290 @@ +package validator + +import ( + "context" + "fmt" + "strings" + "sync" + "testing" + + "github.com/prysmaticlabs/go-ssz" + mockChain "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + blk "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/beacon-chain/core/state" + dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" + pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/params" + "github.com/prysmaticlabs/prysm/shared/testutil" +) + +func TestCommitteeAssignment_NextEpoch_WrongPubkeyLength(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + helpers.ClearAllCaches() + + deposits, _, _ := testutil.SetupInitialDeposits(t, 8) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) + if err != nil { + t.Fatal(err) + } + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + Server := &Server{ + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + } + req := &pb.AssignmentRequest{ + PublicKeys: [][]byte{{1}}, + EpochStart: 0, + } + want := fmt.Sprintf("expected public key to have length %d", params.BeaconConfig().BLSPubkeyLength) + if _, err := Server.CommitteeAssignment(context.Background(), req); err != nil && !strings.Contains(err.Error(), want) { + t.Errorf("Expected %v, received %v", want, err) + } +} + +func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + deposits, _, _ := testutil.SetupInitialDeposits(t, 10) + beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) + if err != nil { + t.Fatalf("Could not setup genesis state: %v", err) + } + genesis := blk.NewGenesisBlock([]byte{}) + genesisRoot, err := ssz.SigningRoot(genesis) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + vs := &Server{ + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + } + + pubKey := make([]byte, 96) + req := &pb.AssignmentRequest{ + PublicKeys: [][]byte{pubKey}, + EpochStart: 0, + } + want := fmt.Sprintf("validator %#x does not exist", req.PublicKeys[0]) + if _, err := vs.CommitteeAssignment(ctx, req); err != nil && !strings.Contains(err.Error(), want) { + t.Errorf("Expected %v, received %v", want, err) + } +} + +func TestCommitteeAssignment_OK(t *testing.T) { + helpers.ClearAllCaches() + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + genesis := blk.NewGenesisBlock([]byte{}) + depChainStart := uint64(64) + + deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) + if err != nil { + t.Fatalf("Could not setup genesis state: %v", err) + } + genesisRoot, err := ssz.SigningRoot(genesis) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + var wg sync.WaitGroup + numOfValidators := int(depChainStart) + errs := make(chan error, numOfValidators) + for i := 0; i < len(deposits); i++ { + wg.Add(1) + go func(index int) { + errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) + wg.Done() + }(i) + } + wg.Wait() + close(errs) + for err := range errs { + if err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + } + + vs := &Server{ + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + } + + // Test the first validator in registry. + req := &pb.AssignmentRequest{ + PublicKeys: [][]byte{deposits[0].Data.PublicKey}, + EpochStart: 0, + } + res, err := vs.CommitteeAssignment(context.Background(), req) + if err != nil { + t.Fatalf("Could not call epoch committee assignment %v", err) + } + if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Assigned slot %d can't be higher than %d", + res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) + } + + // Test the last validator in registry. + lastValidatorIndex := depChainStart - 1 + req = &pb.AssignmentRequest{ + PublicKeys: [][]byte{deposits[lastValidatorIndex].Data.PublicKey}, + EpochStart: 0, + } + res, err = vs.CommitteeAssignment(context.Background(), req) + if err != nil { + t.Fatalf("Could not call epoch committee assignment %v", err) + } + if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { + t.Errorf("Assigned slot %d can't be higher than %d", + res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) + } +} + +func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { + helpers.ClearAllCaches() + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + genesis := blk.NewGenesisBlock([]byte{}) + depChainStart := uint64(64) + + deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) + if err != nil { + t.Fatalf("Could not setup genesis state: %v", err) + } + state.Slot = 5 // Set state to non-epoch start slot. + + genesisRoot, err := ssz.SigningRoot(genesis) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + var wg sync.WaitGroup + numOfValidators := int(depChainStart) + errs := make(chan error, numOfValidators) + for i := 0; i < len(deposits); i++ { + wg.Add(1) + go func(index int) { + errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) + wg.Done() + }(i) + } + wg.Wait() + close(errs) + for err := range errs { + if err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + } + + vs := &Server{ + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + } + + // Test the first validator in registry. + req := &pb.AssignmentRequest{ + PublicKeys: [][]byte{deposits[0].Data.PublicKey}, + EpochStart: 0, + } + res, err := vs.CommitteeAssignment(context.Background(), req) + if err != nil { + t.Fatal(err) + } + if len(res.ValidatorAssignment) != 1 { + t.Error("Expected 1 assignment") + } +} + +func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + genesis := blk.NewGenesisBlock([]byte{}) + depChainStart := uint64(64) + deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) + state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) + if err != nil { + t.Fatalf("Could not setup genesis state: %v", err) + } + genesisRoot, err := ssz.SigningRoot(genesis) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + var wg sync.WaitGroup + numOfValidators := int(depChainStart) + errs := make(chan error, numOfValidators) + for i := 0; i < numOfValidators; i++ { + wg.Add(1) + go func(index int) { + errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) + wg.Done() + }(i) + } + wg.Wait() + close(errs) + for err := range errs { + if err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + } + + vs := &Server{ + BeaconDB: db, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + SyncChecker: &mockSync.Sync{IsSyncing: false}, + } + + pubkey0 := deposits[0].Data.PublicKey + pubkey1 := deposits[1].Data.PublicKey + + // Test the first validator in registry. + req := &pb.AssignmentRequest{ + PublicKeys: [][]byte{pubkey0, pubkey1}, + EpochStart: 0, + } + res, err := vs.CommitteeAssignment(context.Background(), req) + if err != nil { + t.Fatalf("Could not call epoch committee assignment %v", err) + } + + if len(res.ValidatorAssignment) != 2 { + t.Fatalf("expected 2 assignments but got %d", len(res.ValidatorAssignment)) + } +} + +func TestCommitteeAssignment_SyncNotReady(t *testing.T) { + vs := &Server{ + SyncChecker: &mockSync.Sync{IsSyncing: true}, + } + _, err := vs.CommitteeAssignment(context.Background(), &pb.AssignmentRequest{}) + if strings.Contains(err.Error(), "syncing to latest head") { + t.Error("Did not get wanted error") + } +} diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go new file mode 100644 index 000000000000..183ea0cd4dfb --- /dev/null +++ b/beacon-chain/rpc/validator/status.go @@ -0,0 +1,188 @@ +package validator + +import ( + "context" + "errors" + "math/big" + "time" + + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/params" +) + +// ValidatorStatus returns the validator status of the current epoch. +// The status response can be one of the following: +// PENDING_ACTIVE - validator is waiting to get activated. +// ACTIVE - validator is active. +// INITIATED_EXIT - validator has initiated an an exit request. +// WITHDRAWABLE - validator's deposit can be withdrawn after lock up period. +// EXITED - validator has exited, means the deposit has been withdrawn. +// EXITED_SLASHED - validator was forcefully exited due to slashing. +func (vs *Server) ValidatorStatus( + ctx context.Context, + req *pb.ValidatorIndexRequest) (*pb.ValidatorStatusResponse, error) { + headState := vs.HeadFetcher.HeadState() + return vs.validatorStatus(ctx, req.PublicKey, headState), nil +} + +// multipleValidatorStatus returns the validator status response for the set of validators +// requested by their pub keys. +func (vs *Server) multipleValidatorStatus( + ctx context.Context, + pubkeys [][]byte, +) (bool, []*pb.ValidatorActivationResponse_Status, error) { + headState := vs.HeadFetcher.HeadState() + if headState == nil { + return false, nil, nil + } + activeValidatorExists := false + statusResponses := make([]*pb.ValidatorActivationResponse_Status, len(pubkeys)) + for i, key := range pubkeys { + if ctx.Err() != nil { + return false, nil, ctx.Err() + } + status := vs.validatorStatus(ctx, key, headState) + if status == nil { + continue + } + resp := &pb.ValidatorActivationResponse_Status{ + Status: status, + PublicKey: key, + } + statusResponses[i] = resp + if status.Status == pb.ValidatorStatus_ACTIVE { + activeValidatorExists = true + } + } + + return activeValidatorExists, statusResponses, nil +} +func (vs *Server) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { + if !vs.Eth1InfoFetcher.IsConnectedToETH1() { + vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) + if err != nil { + return &pb.ValidatorStatusResponse{ + Status: pb.ValidatorStatus_UNKNOWN_STATUS, + ActivationEpoch: params.BeaconConfig().FarFutureEpoch, + } + } + statusResp := &pb.ValidatorStatusResponse{ + Status: vStatus, + } + if vStatus == pb.ValidatorStatus_ACTIVE { + statusResp.ActivationEpoch = headState.Validators[idx].ActivationEpoch + } + return statusResp + } + + _, eth1BlockNumBigInt := vs.DepositFetcher.DepositByPubkey(ctx, pubKey) + if eth1BlockNumBigInt == nil { + return &pb.ValidatorStatusResponse{ + Status: pb.ValidatorStatus_UNKNOWN_STATUS, + ActivationEpoch: params.BeaconConfig().FarFutureEpoch, + } + } + + statusResp := &pb.ValidatorStatusResponse{ + Status: pb.ValidatorStatus_DEPOSIT_RECEIVED, + ActivationEpoch: params.BeaconConfig().FarFutureEpoch, + Eth1DepositBlockNumber: eth1BlockNumBigInt.Uint64(), + } + + depositBlockSlot, err := vs.depositBlockSlot(ctx, headState.Slot, eth1BlockNumBigInt, headState) + if err != nil { + return statusResp + } + statusResp.DepositInclusionSlot = depositBlockSlot + vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) + if err != nil { + return statusResp + } + statusResp.Status = vStatus + + if vStatus == pb.ValidatorStatus_ACTIVE { + statusResp.ActivationEpoch = headState.Validators[idx].ActivationEpoch + return statusResp + } + + var queuePosition uint64 + var lastActivatedValidatorIdx uint64 + for j := len(headState.Validators) - 1; j >= 0; j-- { + if helpers.IsActiveValidator(headState.Validators[j], helpers.CurrentEpoch(headState)) { + lastActivatedValidatorIdx = uint64(j) + break + } + } + // Our position in the activation queue is the above index - our validator index. + queuePosition = uint64(idx) - lastActivatedValidatorIdx + return &pb.ValidatorStatusResponse{ + Status: vStatus, + Eth1DepositBlockNumber: eth1BlockNumBigInt.Uint64(), + PositionInActivationQueue: queuePosition, + DepositInclusionSlot: depositBlockSlot, + ActivationEpoch: headState.Validators[idx].ActivationEpoch, + } +} + +func (vs *Server) retrieveStatusFromState(ctx context.Context, pubKey []byte, + headState *pbp2p.BeaconState) (pb.ValidatorStatus, uint64, error) { + if headState == nil { + return pb.ValidatorStatus(0), 0, errors.New("head state does not exist") + } + idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) + if err != nil { + return pb.ValidatorStatus(0), 0, err + } + if !ok { + return pb.ValidatorStatus(0), 0, errors.New("pubkey does not exist") + } + return vs.assignmentStatus(uint64(idx), headState), uint64(idx), nil +} + +func (vs *Server) assignmentStatus(validatorIdx uint64, beaconState *pbp2p.BeaconState) pb.ValidatorStatus { + var status pb.ValidatorStatus + v := beaconState.Validators[validatorIdx] + epoch := helpers.CurrentEpoch(beaconState) + farFutureEpoch := params.BeaconConfig().FarFutureEpoch + + if epoch < v.ActivationEpoch { + status = pb.ValidatorStatus_PENDING_ACTIVE + } else if v.ExitEpoch == farFutureEpoch { + status = pb.ValidatorStatus_ACTIVE + } else if epoch >= v.WithdrawableEpoch { + status = pb.ValidatorStatus_WITHDRAWABLE + } else if v.Slashed && epoch >= v.ExitEpoch { + status = pb.ValidatorStatus_EXITED_SLASHED + } else if epoch >= v.ExitEpoch { + status = pb.ValidatorStatus_EXITED + } else if v.ExitEpoch != farFutureEpoch { + status = pb.ValidatorStatus_INITIATED_EXIT + } else { + status = pb.ValidatorStatus_UNKNOWN_STATUS + } + + return status +} + +func (vs *Server) depositBlockSlot(ctx context.Context, currentSlot uint64, + eth1BlockNumBigInt *big.Int, beaconState *pbp2p.BeaconState) (uint64, error) { + blockTimeStamp, err := vs.BlockFetcher.BlockTimeByHeight(ctx, eth1BlockNumBigInt) + if err != nil { + return 0, err + } + followTime := time.Duration(params.BeaconConfig().Eth1FollowDistance*params.BeaconConfig().GoerliBlockTime) * time.Second + eth1UnixTime := time.Unix(int64(blockTimeStamp), 0).Add(followTime) + + votingPeriodSlots := helpers.StartSlot(params.BeaconConfig().SlotsPerEth1VotingPeriod / params.BeaconConfig().SlotsPerEpoch) + votingPeriodSeconds := time.Duration(votingPeriodSlots*params.BeaconConfig().SecondsPerSlot) * time.Second + timeToInclusion := eth1UnixTime.Add(votingPeriodSeconds) + + eth2Genesis := time.Unix(int64(beaconState.GenesisTime), 0) + eth2TimeDifference := timeToInclusion.Sub(eth2Genesis).Seconds() + depositBlockSlot := uint64(eth2TimeDifference) / params.BeaconConfig().SecondsPerSlot + + return depositBlockSlot, nil +} diff --git a/beacon-chain/rpc/validator/status_test.go b/beacon-chain/rpc/validator/status_test.go new file mode 100644 index 000000000000..3b36ea3f4f32 --- /dev/null +++ b/beacon-chain/rpc/validator/status_test.go @@ -0,0 +1,643 @@ +package validator + +import ( + "context" + "math/big" + "testing" + "time" + + "github.com/gogo/protobuf/proto" + "github.com/prysmaticlabs/go-ssz" + mockChain "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + "github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache" + blk "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" + 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" + "github.com/prysmaticlabs/prysm/shared/bytesutil" + "github.com/prysmaticlabs/prysm/shared/params" + "github.com/prysmaticlabs/prysm/shared/trieutil" +) + +func TestValidatorStatus_DepositReceived(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + DepositFetcher: depositCache, + BlockFetcher: p, + HeadFetcher: &mockChain.ChainService{ + State: &pbp2p.BeaconState{}, + }, + Eth1InfoFetcher: p, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_DEPOSIT_RECEIVED { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_DEPOSIT_RECEIVED, resp.Status) + } +} + +func TestValidatorStatus_PendingActive(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + if err := db.SaveHeadBlockRoot(ctx, genesisRoot); err != nil { + t.Fatalf("Could not save genesis state: %v", err) + } + // Pending active because activation epoch is still defaulted at far future slot. + state := &pbp2p.BeaconState{ + Validators: []*ethpb.Validator{ + { + ActivationEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKey, + }, + }, + Slot: 5000, + } + if err := db.SaveState(ctx, state, genesisRoot); err != nil { + t.Fatalf("could not save state: %v", err) + } + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_PENDING_ACTIVE { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_PENDING_ACTIVE, resp.Status) + } +} + +func TestValidatorStatus_Active(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + // This test breaks if it doesnt use mainnet config + params.OverrideBeaconConfig(params.MainnetConfig()) + defer params.OverrideBeaconConfig(params.MinimalSpecConfig()) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + + // Active because activation epoch <= current epoch < exit epoch. + activeEpoch := helpers.DelayedActivationExitEpoch(0) + + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + state := &pbp2p.BeaconState{ + GenesisTime: uint64(time.Unix(0, 0).Unix()), + Slot: 10000, + Validators: []*ethpb.Validator{{ + ActivationEpoch: activeEpoch, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKey}, + }} + + timestamp := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + int(params.BeaconConfig().Eth1FollowDistance): uint64(timestamp), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + + expected := &pb.ValidatorStatusResponse{ + Status: pb.ValidatorStatus_ACTIVE, + ActivationEpoch: 5, + DepositInclusionSlot: 2218, + } + if !proto.Equal(resp, expected) { + t.Errorf("Wanted %v, got %v", expected, resp) + } +} + +func TestValidatorStatus_InitiatedExit(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + // Initiated exit because validator exit epoch and withdrawable epoch are not FAR_FUTURE_EPOCH + slot := uint64(10000) + epoch := helpers.SlotToEpoch(slot) + exitEpoch := helpers.DelayedActivationExitEpoch(epoch) + withdrawableEpoch := exitEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + state := &pbp2p.BeaconState{ + Slot: slot, + Validators: []*ethpb.Validator{{ + PublicKey: pubKey, + ActivationEpoch: 0, + ExitEpoch: exitEpoch, + WithdrawableEpoch: withdrawableEpoch}, + }} + + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_INITIATED_EXIT { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_INITIATED_EXIT, resp.Status) + } +} + +func TestValidatorStatus_Withdrawable(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + // Withdrawable exit because current epoch is after validator withdrawable epoch. + slot := uint64(10000) + epoch := helpers.SlotToEpoch(slot) + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + state := &pbp2p.BeaconState{ + Slot: 10000, + Validators: []*ethpb.Validator{{ + WithdrawableEpoch: epoch - 1, + ExitEpoch: epoch - 2, + PublicKey: pubKey}, + }} + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + BlockFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_WITHDRAWABLE { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_WITHDRAWABLE, resp.Status) + } +} + +func TestValidatorStatus_ExitedSlashed(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + // Exit slashed because slashed is true, exit epoch is =< current epoch and withdrawable epoch > epoch . + slot := uint64(10000) + epoch := helpers.SlotToEpoch(slot) + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + + state := &pbp2p.BeaconState{ + Slot: slot, + Validators: []*ethpb.Validator{{ + Slashed: true, + PublicKey: pubKey, + WithdrawableEpoch: epoch + 1}, + }} + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + DepositFetcher: depositCache, + BlockFetcher: p, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_EXITED_SLASHED { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_EXITED_SLASHED, resp.Status) + } +} + +func TestValidatorStatus_Exited(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKey := []byte{'A'} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + // Exit because only exit epoch is =< current epoch. + slot := uint64(10000) + epoch := helpers.SlotToEpoch(slot) + block := blk.NewGenesisBlock([]byte{}) + if err := db.SaveBlock(ctx, block); err != nil { + t.Fatalf("Could not save genesis block: %v", err) + } + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + if err := db.SaveHeadBlockRoot(ctx, genesisRoot); err != nil { + t.Fatalf("Could not save genesis state: %v", err) + } + state := &pbp2p.BeaconState{ + Slot: slot, + Validators: []*ethpb.Validator{{ + PublicKey: pubKey, + WithdrawableEpoch: epoch + 1}, + }} + depData := ðpb.Deposit_Data{ + PublicKey: pubKey, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + vs := &Server{ + BeaconDB: db, + ChainStartFetcher: p, + Eth1InfoFetcher: p, + BlockFetcher: p, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_EXITED { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_EXITED, resp.Status) + } +} + +func TestValidatorStatus_UnknownStatus(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + pubKey := []byte{'A'} + depositCache := depositcache.NewDepositCache() + vs := &Server{ + DepositFetcher: depositCache, + Eth1InfoFetcher: &mockPOW.POWChain{}, + HeadFetcher: &mockChain.ChainService{ + State: &pbp2p.BeaconState{ + Slot: 0, + }, + }, + } + req := &pb.ValidatorIndexRequest{ + PublicKey: pubKey, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + if err != nil { + t.Fatalf("Could not get validator status %v", err) + } + if resp.Status != pb.ValidatorStatus_UNKNOWN_STATUS { + t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_UNKNOWN_STATUS, resp.Status) + } +} + +func TestMultipleValidatorStatus_OK(t *testing.T) { + db := dbutil.SetupDB(t) + defer dbutil.TeardownDB(t, db) + ctx := context.Background() + + pubKeys := [][]byte{{'A'}, {'B'}, {'C'}} + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[0]), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[1]), 0); err != nil { + t.Fatalf("Could not save validator index: %v", err) + } + + beaconState := &pbp2p.BeaconState{ + Slot: 4000, + Validators: []*ethpb.Validator{{ + ActivationEpoch: 0, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[0]}, + { + ActivationEpoch: 0, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[1]}, + { + ActivationEpoch: 0, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[2]}, + }, + } + block := blk.NewGenesisBlock([]byte{}) + genesisRoot, err := ssz.SigningRoot(block) + if err != nil { + t.Fatalf("Could not get signing root %v", err) + } + depData := ðpb.Deposit_Data{ + PublicKey: []byte{'A'}, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + Amount: 10, + } + + dep := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + if err != nil { + t.Fatalf("Could not setup deposit trie: %v", err) + } + depositCache := depositcache.NewDepositCache() + depositCache.InsertDeposit(ctx, dep, big.NewInt(10) /*blockNum*/, 0, depositTrie.Root()) + depData = ðpb.Deposit_Data{ + PublicKey: []byte{'C'}, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + Amount: 10, + } + + dep = ðpb.Deposit{ + Data: depData, + } + depositTrie.InsertIntoTrie(dep.Data.Signature, 15) + depositCache.InsertDeposit(context.Background(), dep, big.NewInt(15), 0, depositTrie.Root()) + + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[0]), 0); err != nil { + t.Fatalf("could not save validator index: %v", err) + } + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[1]), 1); err != nil { + t.Fatalf("could not save validator index: %v", err) + } + if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[2]), 2); err != nil { + t.Fatalf("could not save validator index: %v", err) + } + vs := &Server{ + BeaconDB: db, + Ctx: context.Background(), + CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + ChainStartFetcher: &mockPOW.POWChain{}, + BlockFetcher: &mockPOW.POWChain{}, + Eth1InfoFetcher: &mockPOW.POWChain{}, + DepositFetcher: depositCache, + HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, + } + activeExists, response, err := vs.multipleValidatorStatus(context.Background(), pubKeys) + if err != nil { + t.Fatal(err) + } + if !activeExists { + t.Fatal("No activated validator exists when there was supposed to be 2") + } + if response[0].Status.Status != pb.ValidatorStatus_ACTIVE { + t.Errorf("Validator with pubkey %#x is not activated and instead has this status: %s", + response[0].PublicKey, response[0].Status.Status.String()) + } + + if response[1].Status.Status == pb.ValidatorStatus_ACTIVE { + t.Errorf("Validator with pubkey %#x was activated when not supposed to", + response[1].PublicKey) + } + + if response[2].Status.Status != pb.ValidatorStatus_ACTIVE { + t.Errorf("Validator with pubkey %#x is not activated and instead has this status: %s", + response[2].PublicKey, response[2].Status.Status.String()) + } +} diff --git a/beacon-chain/rpc/validator/validator_server.go b/beacon-chain/rpc/validator/validator_server.go index f9daca1d0ee0..61b20ed3ce7f 100644 --- a/beacon-chain/rpc/validator/validator_server.go +++ b/beacon-chain/rpc/validator/validator_server.go @@ -2,11 +2,14 @@ package validator import ( "context" - "math/big" "time" ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" @@ -18,10 +21,6 @@ import ( pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/params" - "github.com/sirupsen/logrus" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) var log logrus.FieldLogger @@ -151,123 +150,6 @@ func (vs *Server) ValidatorPerformance( }, nil } -// CommitteeAssignment returns the committee assignment response from a given validator public key. -// The committee assignment response contains the following fields for the current and previous epoch: -// 1.) The list of validators in the committee. -// 2.) The shard to which the committee is assigned. -// 3.) The slot at which the committee is assigned. -// 4.) The bool signaling if the validator is expected to propose a block at the assigned slot. -func (vs *Server) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error) { - if vs.SyncChecker.Syncing() { - return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond") - } - - var err error - s := vs.HeadFetcher.HeadState() - // Advance state with empty transitions up to the requested epoch start slot. - if epochStartSlot := helpers.StartSlot(req.EpochStart); s.Slot < epochStartSlot { - s, err = state.ProcessSlots(ctx, s, epochStartSlot) - if err != nil { - return nil, errors.Wrapf(err, "could not process slots up to %d", epochStartSlot) - } - } - - var assignments []*pb.AssignmentResponse_ValidatorAssignment - for _, pubKey := range req.PublicKeys { - if ctx.Err() != nil { - return nil, ctx.Err() - } - // Default assignment - assignment := &pb.AssignmentResponse_ValidatorAssignment{ - PublicKey: pubKey, - Status: pb.ValidatorStatus_UNKNOWN_STATUS, - } - - idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) - if err != nil { - return nil, err - } - if ok { - status := vs.assignmentStatus(uint64(idx), s) - assignment.Status = status - if status == pb.ValidatorStatus_ACTIVE { - assignment, err = vs.assignment(uint64(idx), s, req.EpochStart) - if err != nil { - return nil, err - } - assignment.PublicKey = pubKey - } - } - assignments = append(assignments, assignment) - } - - return &pb.AssignmentResponse{ - ValidatorAssignment: assignments, - }, nil -} - -func (vs *Server) assignment(idx uint64, beaconState *pbp2p.BeaconState, epoch uint64) (*pb.AssignmentResponse_ValidatorAssignment, error) { - 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, - CommitteeIndex: committeeIndex, - AttesterSlot: aSlot, - ProposerSlot: pSlot, - Status: status, - }, nil -} - -// ValidatorStatus returns the validator status of the current epoch. -// The status response can be one of the following: -// PENDING_ACTIVE - validator is waiting to get activated. -// ACTIVE - validator is active. -// INITIATED_EXIT - validator has initiated an an exit request. -// WITHDRAWABLE - validator's deposit can be withdrawn after lock up period. -// EXITED - validator has exited, means the deposit has been withdrawn. -// EXITED_SLASHED - validator was forcefully exited due to slashing. -func (vs *Server) ValidatorStatus( - ctx context.Context, - req *pb.ValidatorIndexRequest) (*pb.ValidatorStatusResponse, error) { - headState := vs.HeadFetcher.HeadState() - return vs.validatorStatus(ctx, req.PublicKey, headState), nil -} - -// multipleValidatorStatus returns the validator status response for the set of validators -// requested by their pub keys. -func (vs *Server) multipleValidatorStatus( - ctx context.Context, - pubkeys [][]byte) (bool, []*pb.ValidatorActivationResponse_Status, error) { - headState := vs.HeadFetcher.HeadState() - if headState == nil { - return false, nil, nil - } - activeValidatorExists := false - statusResponses := make([]*pb.ValidatorActivationResponse_Status, len(pubkeys)) - for i, key := range pubkeys { - if ctx.Err() != nil { - return false, nil, ctx.Err() - } - status := vs.validatorStatus(ctx, key, headState) - if status == nil { - continue - } - resp := &pb.ValidatorActivationResponse_Status{ - Status: status, - PublicKey: key, - } - statusResponses[i] = resp - if status.Status == pb.ValidatorStatus_ACTIVE { - activeValidatorExists = true - } - } - - return activeValidatorExists, statusResponses, nil -} - // ExitedValidators queries validator statuses for a give list of validators // and returns a filtered list of validator keys that are exited. func (vs *Server) ExitedValidators( @@ -305,113 +187,6 @@ func (vs *Server) DomainData(ctx context.Context, request *pb.DomainRequest) (*p }, nil } -func (vs *Server) validatorStatus(ctx context.Context, pubKey []byte, headState *pbp2p.BeaconState) *pb.ValidatorStatusResponse { - if !vs.Eth1InfoFetcher.IsConnectedToETH1() { - vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) - if err != nil { - return &pb.ValidatorStatusResponse{ - Status: pb.ValidatorStatus_UNKNOWN_STATUS, - ActivationEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - statusResp := &pb.ValidatorStatusResponse{ - Status: vStatus, - } - if vStatus == pb.ValidatorStatus_ACTIVE { - statusResp.ActivationEpoch = headState.Validators[idx].ActivationEpoch - } - return statusResp - } - - _, eth1BlockNumBigInt := vs.DepositFetcher.DepositByPubkey(ctx, pubKey) - if eth1BlockNumBigInt == nil { - return &pb.ValidatorStatusResponse{ - Status: pb.ValidatorStatus_UNKNOWN_STATUS, - ActivationEpoch: params.BeaconConfig().FarFutureEpoch, - } - } - - statusResp := &pb.ValidatorStatusResponse{ - Status: pb.ValidatorStatus_DEPOSIT_RECEIVED, - ActivationEpoch: params.BeaconConfig().FarFutureEpoch, - Eth1DepositBlockNumber: eth1BlockNumBigInt.Uint64(), - } - - depositBlockSlot, err := vs.depositBlockSlot(ctx, headState.Slot, eth1BlockNumBigInt, headState) - if err != nil { - return statusResp - } - statusResp.DepositInclusionSlot = depositBlockSlot - vStatus, idx, err := vs.retrieveStatusFromState(ctx, pubKey, headState) - if err != nil { - return statusResp - } - statusResp.Status = vStatus - - if vStatus == pb.ValidatorStatus_ACTIVE { - statusResp.ActivationEpoch = headState.Validators[idx].ActivationEpoch - return statusResp - } - - var queuePosition uint64 - var lastActivatedValidatorIdx uint64 - for j := len(headState.Validators) - 1; j >= 0; j-- { - if helpers.IsActiveValidator(headState.Validators[j], helpers.CurrentEpoch(headState)) { - lastActivatedValidatorIdx = uint64(j) - break - } - } - // Our position in the activation queue is the above index - our validator index. - queuePosition = uint64(idx) - lastActivatedValidatorIdx - return &pb.ValidatorStatusResponse{ - Status: vStatus, - Eth1DepositBlockNumber: eth1BlockNumBigInt.Uint64(), - PositionInActivationQueue: queuePosition, - DepositInclusionSlot: depositBlockSlot, - ActivationEpoch: headState.Validators[idx].ActivationEpoch, - } -} - -func (vs *Server) retrieveStatusFromState(ctx context.Context, pubKey []byte, - headState *pbp2p.BeaconState) (pb.ValidatorStatus, uint64, error) { - if headState == nil { - return pb.ValidatorStatus(0), 0, errors.New("head state does not exist") - } - idx, ok, err := vs.BeaconDB.ValidatorIndex(ctx, bytesutil.ToBytes48(pubKey)) - if err != nil { - return pb.ValidatorStatus(0), 0, err - } - if !ok { - return pb.ValidatorStatus(0), 0, errors.New("pubkey does not exist") - } - return vs.assignmentStatus(uint64(idx), headState), uint64(idx), nil -} - -func (vs *Server) assignmentStatus(validatorIdx uint64, beaconState *pbp2p.BeaconState) pb.ValidatorStatus { - var status pb.ValidatorStatus - v := beaconState.Validators[validatorIdx] - epoch := helpers.CurrentEpoch(beaconState) - farFutureEpoch := params.BeaconConfig().FarFutureEpoch - - if epoch < v.ActivationEpoch { - status = pb.ValidatorStatus_PENDING_ACTIVE - } else if v.ExitEpoch == farFutureEpoch { - status = pb.ValidatorStatus_ACTIVE - } else if epoch >= v.WithdrawableEpoch { - status = pb.ValidatorStatus_WITHDRAWABLE - } else if v.Slashed && epoch >= v.ExitEpoch { - status = pb.ValidatorStatus_EXITED_SLASHED - } else if epoch >= v.ExitEpoch { - status = pb.ValidatorStatus_EXITED - } else if v.ExitEpoch != farFutureEpoch { - status = pb.ValidatorStatus_INITIATED_EXIT - } else { - status = pb.ValidatorStatus_UNKNOWN_STATUS - } - - return status -} - // CanonicalHead of the current beacon chain. This method is requested on-demand // by a validator when it is their time to propose or attest. func (vs *Server) CanonicalHead(ctx context.Context, req *ptypes.Empty) (*ethpb.BeaconBlock, error) { @@ -453,23 +228,3 @@ func (vs *Server) WaitForChainStart(req *ptypes.Empty, stream pb.ValidatorServic } } } - -func (vs *Server) depositBlockSlot(ctx context.Context, currentSlot uint64, - eth1BlockNumBigInt *big.Int, beaconState *pbp2p.BeaconState) (uint64, error) { - blockTimeStamp, err := vs.BlockFetcher.BlockTimeByHeight(ctx, eth1BlockNumBigInt) - if err != nil { - return 0, err - } - followTime := time.Duration(params.BeaconConfig().Eth1FollowDistance*params.BeaconConfig().GoerliBlockTime) * time.Second - eth1UnixTime := time.Unix(int64(blockTimeStamp), 0).Add(followTime) - - votingPeriodSlots := helpers.StartSlot(params.BeaconConfig().SlotsPerEth1VotingPeriod / params.BeaconConfig().SlotsPerEpoch) - votingPeriodSeconds := time.Duration(votingPeriodSlots*params.BeaconConfig().SecondsPerSlot) * time.Second - timeToInclusion := eth1UnixTime.Add(votingPeriodSeconds) - - eth2Genesis := time.Unix(int64(beaconState.GenesisTime), 0) - eth2TimeDifference := timeToInclusion.Sub(eth2Genesis).Seconds() - depositBlockSlot := uint64(eth2TimeDifference) / params.BeaconConfig().SecondsPerSlot - - return depositBlockSlot, nil -} diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/validator_server_test.go index 075f6c322ad7..345b3b171994 100644 --- a/beacon-chain/rpc/validator/validator_server_test.go +++ b/beacon-chain/rpc/validator/validator_server_test.go @@ -11,20 +11,17 @@ import ( "testing" "time" - "github.com/gogo/protobuf/proto" ptypes "github.com/gogo/protobuf/types" "github.com/golang/mock/gomock" "github.com/prysmaticlabs/go-ssz" mockChain "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache" blk "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" internal "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing" mockRPC "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testing" - mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" 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" @@ -67,789 +64,6 @@ func TestValidatorIndex_OK(t *testing.T) { } } -func TestNextEpochCommitteeAssignment_WrongPubkeyLength(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - helpers.ClearAllCaches() - - deposits, _, _ := testutil.SetupInitialDeposits(t, 8) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) - if err != nil { - t.Fatal(err) - } - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - Server := &Server{ - BeaconDB: db, - HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, - } - req := &pb.AssignmentRequest{ - PublicKeys: [][]byte{{1}}, - EpochStart: 0, - } - want := fmt.Sprintf("expected public key to have length %d", params.BeaconConfig().BLSPubkeyLength) - if _, err := Server.CommitteeAssignment(context.Background(), req); err != nil && !strings.Contains(err.Error(), want) { - t.Errorf("Expected %v, received %v", want, err) - } -} - -func TestNextEpochCommitteeAssignment_CantFindValidatorIdx(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - deposits, _, _ := testutil.SetupInitialDeposits(t, 10) - beaconState, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) - if err != nil { - t.Fatalf("Could not setup genesis state: %v", err) - } - genesis := blk.NewGenesisBlock([]byte{}) - genesisRoot, err := ssz.SigningRoot(genesis) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - vs := &Server{ - BeaconDB: db, - HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, - } - - pubKey := make([]byte, 96) - req := &pb.AssignmentRequest{ - PublicKeys: [][]byte{pubKey}, - EpochStart: 0, - } - want := fmt.Sprintf("validator %#x does not exist", req.PublicKeys[0]) - if _, err := vs.CommitteeAssignment(ctx, req); err != nil && !strings.Contains(err.Error(), want) { - t.Errorf("Expected %v, received %v", want, err) - } -} - -func TestCommitteeAssignment_OK(t *testing.T) { - helpers.ClearAllCaches() - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := uint64(64) - - deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) - if err != nil { - t.Fatalf("Could not setup genesis state: %v", err) - } - genesisRoot, err := ssz.SigningRoot(genesis) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - var wg sync.WaitGroup - numOfValidators := int(depChainStart) - errs := make(chan error, numOfValidators) - for i := 0; i < len(deposits); i++ { - wg.Add(1) - go func(index int) { - errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) - wg.Done() - }(i) - } - wg.Wait() - close(errs) - for err := range errs { - if err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - } - - vs := &Server{ - BeaconDB: db, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, - } - - // Test the first validator in registry. - req := &pb.AssignmentRequest{ - PublicKeys: [][]byte{deposits[0].Data.PublicKey}, - EpochStart: 0, - } - res, err := vs.CommitteeAssignment(context.Background(), req) - if err != nil { - t.Fatalf("Could not call epoch committee assignment %v", err) - } - if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Assigned slot %d can't be higher than %d", - res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) - } - - // Test the last validator in registry. - lastValidatorIndex := depChainStart - 1 - req = &pb.AssignmentRequest{ - PublicKeys: [][]byte{deposits[lastValidatorIndex].Data.PublicKey}, - EpochStart: 0, - } - res, err = vs.CommitteeAssignment(context.Background(), req) - if err != nil { - t.Fatalf("Could not call epoch committee assignment %v", err) - } - if res.ValidatorAssignment[0].AttesterSlot > state.Slot+params.BeaconConfig().SlotsPerEpoch { - t.Errorf("Assigned slot %d can't be higher than %d", - res.ValidatorAssignment[0].AttesterSlot, state.Slot+params.BeaconConfig().SlotsPerEpoch) - } -} - -func TestCommitteeAssignment_CurrentEpoch_ShouldNotFail(t *testing.T) { - helpers.ClearAllCaches() - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := uint64(64) - - deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) - if err != nil { - t.Fatalf("Could not setup genesis state: %v", err) - } - state.Slot = 5 // Set state to non-epoch start slot. - - genesisRoot, err := ssz.SigningRoot(genesis) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - var wg sync.WaitGroup - numOfValidators := int(depChainStart) - errs := make(chan error, numOfValidators) - for i := 0; i < len(deposits); i++ { - wg.Add(1) - go func(index int) { - errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) - wg.Done() - }(i) - } - wg.Wait() - close(errs) - for err := range errs { - if err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - } - - vs := &Server{ - BeaconDB: db, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, - } - - // Test the first validator in registry. - req := &pb.AssignmentRequest{ - PublicKeys: [][]byte{deposits[0].Data.PublicKey}, - EpochStart: 0, - } - res, err := vs.CommitteeAssignment(context.Background(), req) - if err != nil { - t.Fatal(err) - } - if len(res.ValidatorAssignment) != 1 { - t.Error("Expected 1 assignment") - } -} - -func TestCommitteeAssignment_MultipleKeys_OK(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - genesis := blk.NewGenesisBlock([]byte{}) - depChainStart := uint64(64) - deposits, _, _ := testutil.SetupInitialDeposits(t, depChainStart) - state, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)}) - if err != nil { - t.Fatalf("Could not setup genesis state: %v", err) - } - genesisRoot, err := ssz.SigningRoot(genesis) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - var wg sync.WaitGroup - numOfValidators := int(depChainStart) - errs := make(chan error, numOfValidators) - for i := 0; i < numOfValidators; i++ { - wg.Add(1) - go func(index int) { - errs <- db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(deposits[index].Data.PublicKey), uint64(index)) - wg.Done() - }(i) - } - wg.Wait() - close(errs) - for err := range errs { - if err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - } - - vs := &Server{ - BeaconDB: db, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - SyncChecker: &mockSync.Sync{IsSyncing: false}, - } - - pubkey0 := deposits[0].Data.PublicKey - pubkey1 := deposits[1].Data.PublicKey - - // Test the first validator in registry. - req := &pb.AssignmentRequest{ - PublicKeys: [][]byte{pubkey0, pubkey1}, - EpochStart: 0, - } - res, err := vs.CommitteeAssignment(context.Background(), req) - if err != nil { - t.Fatalf("Could not call epoch committee assignment %v", err) - } - - if len(res.ValidatorAssignment) != 2 { - t.Fatalf("expected 2 assignments but got %d", len(res.ValidatorAssignment)) - } -} - -func TestCommitteeAssignment_SyncNotReady(t *testing.T) { - vs := &Server{ - SyncChecker: &mockSync.Sync{IsSyncing: true}, - } - _, err := vs.CommitteeAssignment(context.Background(), &pb.AssignmentRequest{}) - if strings.Contains(err.Error(), "syncing to latest head") { - t.Error("Did not get wanted error") - } -} - -func TestValidatorStatus_DepositReceived(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - DepositFetcher: depositCache, - BlockFetcher: p, - HeadFetcher: &mockChain.ChainService{ - State: &pbp2p.BeaconState{}, - }, - Eth1InfoFetcher: p, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_DEPOSIT_RECEIVED { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_DEPOSIT_RECEIVED, resp.Status) - } -} - -func TestValidatorStatus_PendingActive(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - if err := db.SaveHeadBlockRoot(ctx, genesisRoot); err != nil { - t.Fatalf("Could not save genesis state: %v", err) - } - // Pending active because activation epoch is still defaulted at far future slot. - state := &pbp2p.BeaconState{ - Validators: []*ethpb.Validator{ - { - ActivationEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKey, - }, - }, - Slot: 5000, - } - if err := db.SaveState(ctx, state, genesisRoot); err != nil { - t.Fatalf("could not save state: %v", err) - } - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - BlockFetcher: p, - Eth1InfoFetcher: p, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_PENDING_ACTIVE { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_PENDING_ACTIVE, resp.Status) - } -} - -func TestValidatorStatus_Active(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - // This test breaks if it doesnt use mainnet config - params.OverrideBeaconConfig(params.MainnetConfig()) - defer params.OverrideBeaconConfig(params.MinimalSpecConfig()) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - - // Active because activation epoch <= current epoch < exit epoch. - activeEpoch := helpers.DelayedActivationExitEpoch(0) - - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - state := &pbp2p.BeaconState{ - GenesisTime: uint64(time.Unix(0, 0).Unix()), - Slot: 10000, - Validators: []*ethpb.Validator{{ - ActivationEpoch: activeEpoch, - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKey}, - }} - - timestamp := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - int(params.BeaconConfig().Eth1FollowDistance): uint64(timestamp), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - BlockFetcher: p, - Eth1InfoFetcher: p, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - - expected := &pb.ValidatorStatusResponse{ - Status: pb.ValidatorStatus_ACTIVE, - ActivationEpoch: 5, - DepositInclusionSlot: 2218, - } - if !proto.Equal(resp, expected) { - t.Errorf("Wanted %v, got %v", expected, resp) - } -} - -func TestValidatorStatus_InitiatedExit(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - // Initiated exit because validator exit epoch and withdrawable epoch are not FAR_FUTURE_EPOCH - slot := uint64(10000) - epoch := helpers.SlotToEpoch(slot) - exitEpoch := helpers.DelayedActivationExitEpoch(epoch) - withdrawableEpoch := exitEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - state := &pbp2p.BeaconState{ - Slot: slot, - Validators: []*ethpb.Validator{{ - PublicKey: pubKey, - ActivationEpoch: 0, - ExitEpoch: exitEpoch, - WithdrawableEpoch: withdrawableEpoch}, - }} - - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - BlockFetcher: p, - Eth1InfoFetcher: p, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_INITIATED_EXIT { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_INITIATED_EXIT, resp.Status) - } -} - -func TestValidatorStatus_Withdrawable(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - // Withdrawable exit because current epoch is after validator withdrawable epoch. - slot := uint64(10000) - epoch := helpers.SlotToEpoch(slot) - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - state := &pbp2p.BeaconState{ - Slot: 10000, - Validators: []*ethpb.Validator{{ - WithdrawableEpoch: epoch - 1, - ExitEpoch: epoch - 2, - PublicKey: pubKey}, - }} - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - BlockFetcher: p, - Eth1InfoFetcher: p, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_WITHDRAWABLE { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_WITHDRAWABLE, resp.Status) - } -} - -func TestValidatorStatus_ExitedSlashed(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - // Exit slashed because slashed is true, exit epoch is =< current epoch and withdrawable epoch > epoch . - slot := uint64(10000) - epoch := helpers.SlotToEpoch(slot) - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - - state := &pbp2p.BeaconState{ - Slot: slot, - Validators: []*ethpb.Validator{{ - Slashed: true, - PublicKey: pubKey, - WithdrawableEpoch: epoch + 1}, - }} - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - Eth1InfoFetcher: p, - DepositFetcher: depositCache, - BlockFetcher: p, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_EXITED_SLASHED { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_EXITED_SLASHED, resp.Status) - } -} - -func TestValidatorStatus_Exited(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKey := []byte{'A'} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKey), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - // Exit because only exit epoch is =< current epoch. - slot := uint64(10000) - epoch := helpers.SlotToEpoch(slot) - block := blk.NewGenesisBlock([]byte{}) - if err := db.SaveBlock(ctx, block); err != nil { - t.Fatalf("Could not save genesis block: %v", err) - } - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - if err := db.SaveHeadBlockRoot(ctx, genesisRoot); err != nil { - t.Fatalf("Could not save genesis state: %v", err) - } - state := &pbp2p.BeaconState{ - Slot: slot, - Validators: []*ethpb.Validator{{ - PublicKey: pubKey, - WithdrawableEpoch: epoch + 1}, - }} - depData := ðpb.Deposit_Data{ - PublicKey: pubKey, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - } - - deposit := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, deposit, big.NewInt(0) /*blockNum*/, 0, depositTrie.Root()) - height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() - p := &mockPOW.POWChain{ - TimesByHeight: map[int]uint64{ - 0: uint64(height), - }, - } - vs := &Server{ - BeaconDB: db, - ChainStartFetcher: p, - Eth1InfoFetcher: p, - BlockFetcher: p, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: state, Root: genesisRoot[:]}, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_EXITED { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_EXITED, resp.Status) - } -} - -func TestValidatorStatus_UnknownStatus(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - pubKey := []byte{'A'} - depositCache := depositcache.NewDepositCache() - vs := &Server{ - DepositFetcher: depositCache, - Eth1InfoFetcher: &mockPOW.POWChain{}, - HeadFetcher: &mockChain.ChainService{ - State: &pbp2p.BeaconState{ - Slot: 0, - }, - }, - } - req := &pb.ValidatorIndexRequest{ - PublicKey: pubKey, - } - resp, err := vs.ValidatorStatus(context.Background(), req) - if err != nil { - t.Fatalf("Could not get validator status %v", err) - } - if resp.Status != pb.ValidatorStatus_UNKNOWN_STATUS { - t.Errorf("Wanted %v, got %v", pb.ValidatorStatus_UNKNOWN_STATUS, resp.Status) - } -} - func TestWaitForActivation_ContextClosed(t *testing.T) { db := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, db) @@ -1015,111 +229,6 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { } } -func TestMultipleValidatorStatus_OK(t *testing.T) { - db := dbutil.SetupDB(t) - defer dbutil.TeardownDB(t, db) - ctx := context.Background() - - pubKeys := [][]byte{{'A'}, {'B'}, {'C'}} - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[0]), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[1]), 0); err != nil { - t.Fatalf("Could not save validator index: %v", err) - } - - beaconState := &pbp2p.BeaconState{ - Slot: 4000, - Validators: []*ethpb.Validator{{ - ActivationEpoch: 0, - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKeys[0]}, - { - ActivationEpoch: 0, - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKeys[1]}, - { - ActivationEpoch: 0, - ExitEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKeys[2]}, - }, - } - block := blk.NewGenesisBlock([]byte{}) - genesisRoot, err := ssz.SigningRoot(block) - if err != nil { - t.Fatalf("Could not get signing root %v", err) - } - depData := ðpb.Deposit_Data{ - PublicKey: []byte{'A'}, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - Amount: 10, - } - - dep := ðpb.Deposit{ - Data: depData, - } - depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) - if err != nil { - t.Fatal(fmt.Errorf("could not setup deposit trie: %v", err)) - } - depositCache := depositcache.NewDepositCache() - depositCache.InsertDeposit(ctx, dep, big.NewInt(10) /*blockNum*/, 0, depositTrie.Root()) - depData = ðpb.Deposit_Data{ - PublicKey: []byte{'C'}, - Signature: []byte("hi"), - WithdrawalCredentials: []byte("hey"), - Amount: 10, - } - - dep = ðpb.Deposit{ - Data: depData, - } - depositTrie.InsertIntoTrie(dep.Data.Signature, 15) - depositCache.InsertDeposit(context.Background(), dep, big.NewInt(15), 0, depositTrie.Root()) - - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[0]), 0); err != nil { - t.Fatalf("could not save validator index: %v", err) - } - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[1]), 1); err != nil { - t.Fatalf("could not save validator index: %v", err) - } - if err := db.SaveValidatorIndex(ctx, bytesutil.ToBytes48(pubKeys[2]), 2); err != nil { - t.Fatalf("could not save validator index: %v", err) - } - vs := &Server{ - BeaconDB: db, - Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), - ChainStartFetcher: &mockPOW.POWChain{}, - BlockFetcher: &mockPOW.POWChain{}, - Eth1InfoFetcher: &mockPOW.POWChain{}, - DepositFetcher: depositCache, - HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, - } - activeExists, response, err := vs.multipleValidatorStatus(context.Background(), pubKeys) - if err != nil { - t.Fatal(err) - } - if !activeExists { - t.Fatal("No activated validator exists when there was supposed to be 2") - } - if response[0].Status.Status != pb.ValidatorStatus_ACTIVE { - t.Errorf("Validator with pubkey %#x is not activated and instead has this status: %s", - response[0].PublicKey, response[0].Status.Status.String()) - } - - if response[1].Status.Status == pb.ValidatorStatus_ACTIVE { - t.Errorf("Validator with pubkey %#x was activated when not supposed to", - response[1].PublicKey) - } - - if response[2].Status.Status != pb.ValidatorStatus_ACTIVE { - t.Errorf("Validator with pubkey %#x is not activated and instead has this status: %s", - response[2].PublicKey, response[2].Status.Status.String()) - } -} - func TestWaitForChainStart_ContextClosed(t *testing.T) { db := dbutil.SetupDB(t) defer dbutil.TeardownDB(t, db) From adf1dda9bd128171f564a81dc87d7cd6647f2573 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 11 Nov 2019 22:51:17 -0600 Subject: [PATCH 57/82] cleanup val --- beacon-chain/rpc/service_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/rpc/service_test.go b/beacon-chain/rpc/service_test.go index c7d6fb96659c..ae20d8cd8739 100644 --- a/beacon-chain/rpc/service_test.go +++ b/beacon-chain/rpc/service_test.go @@ -47,7 +47,7 @@ func TestRPC_BadEndpoint(t *testing.T) { rpcService := NewService(context.Background(), &Config{ Port: "ralph merkle!!!", - SyncService: &mockSync.Sync{IsSyncing: true}, + SyncService: &mockSync.Sync{IsSyncing: false}, BlockReceiver: &mock.ChainService{}, AttestationReceiver: &mock.ChainService{}, HeadFetcher: &mock.ChainService{}, From a17b4ed31afe293a236f99993f8cbd9c8ca10d9f Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 09:54:54 -0600 Subject: [PATCH 58/82] shay feedback --- beacon-chain/rpc/attester/BUILD.bazel | 4 ++-- beacon-chain/rpc/attester/{attester_server.go => server.go} | 0 .../rpc/attester/{attester_server_test.go => server_test.go} | 0 beacon-chain/rpc/beacon/BUILD.bazel | 2 +- beacon-chain/rpc/beacon/{beacon_chain_server.go => server.go} | 0 beacon-chain/rpc/node/BUILD.bazel | 4 ++-- beacon-chain/rpc/node/{node_server.go => server.go} | 0 beacon-chain/rpc/node/{node_server_test.go => server_test.go} | 0 beacon-chain/rpc/proposer/BUILD.bazel | 4 ++-- beacon-chain/rpc/proposer/{proposer_server.go => server.go} | 0 .../rpc/proposer/{proposer_server_test.go => server_test.go} | 0 beacon-chain/rpc/validator/BUILD.bazel | 4 ++-- beacon-chain/rpc/validator/{validator_server.go => server.go} | 0 .../validator/{validator_server_test.go => server_test.go} | 0 14 files changed, 9 insertions(+), 9 deletions(-) rename beacon-chain/rpc/attester/{attester_server.go => server.go} (100%) rename beacon-chain/rpc/attester/{attester_server_test.go => server_test.go} (100%) rename beacon-chain/rpc/beacon/{beacon_chain_server.go => server.go} (100%) rename beacon-chain/rpc/node/{node_server.go => server.go} (100%) rename beacon-chain/rpc/node/{node_server_test.go => server_test.go} (100%) rename beacon-chain/rpc/proposer/{proposer_server.go => server.go} (100%) rename beacon-chain/rpc/proposer/{proposer_server_test.go => server_test.go} (100%) rename beacon-chain/rpc/validator/{validator_server.go => server.go} (100%) rename beacon-chain/rpc/validator/{validator_server_test.go => server_test.go} (100%) diff --git a/beacon-chain/rpc/attester/BUILD.bazel b/beacon-chain/rpc/attester/BUILD.bazel index 9d31ee5e7c80..82d5324f7077 100644 --- a/beacon-chain/rpc/attester/BUILD.bazel +++ b/beacon-chain/rpc/attester/BUILD.bazel @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["attester_server.go"], + srcs = ["server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/attester", visibility = ["//beacon-chain:__subpackages__"], deps = [ @@ -28,7 +28,7 @@ go_library( go_test( name = "go_default_test", - srcs = ["attester_server_test.go"], + srcs = ["server_test.go"], embed = [":go_default_library"], deps = [ "//beacon-chain/blockchain/testing:go_default_library", diff --git a/beacon-chain/rpc/attester/attester_server.go b/beacon-chain/rpc/attester/server.go similarity index 100% rename from beacon-chain/rpc/attester/attester_server.go rename to beacon-chain/rpc/attester/server.go diff --git a/beacon-chain/rpc/attester/attester_server_test.go b/beacon-chain/rpc/attester/server_test.go similarity index 100% rename from beacon-chain/rpc/attester/attester_server_test.go rename to beacon-chain/rpc/attester/server_test.go diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index 56c13582c39f..80a02aa9b4ab 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -5,8 +5,8 @@ go_library( srcs = [ "assignments.go", "attestations.go", - "beacon_chain_server.go", "blocks.go", + "server.go", "validators.go", ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/beacon", diff --git a/beacon-chain/rpc/beacon/beacon_chain_server.go b/beacon-chain/rpc/beacon/server.go similarity index 100% rename from beacon-chain/rpc/beacon/beacon_chain_server.go rename to beacon-chain/rpc/beacon/server.go diff --git a/beacon-chain/rpc/node/BUILD.bazel b/beacon-chain/rpc/node/BUILD.bazel index f8567290a9fd..fc28cf6991f8 100644 --- a/beacon-chain/rpc/node/BUILD.bazel +++ b/beacon-chain/rpc/node/BUILD.bazel @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["node_server.go"], + srcs = ["server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/node", visibility = ["//beacon-chain:__subpackages__"], deps = [ @@ -20,7 +20,7 @@ go_library( go_test( name = "go_default_test", - srcs = ["node_server_test.go"], + srcs = ["server_test.go"], embed = [":go_default_library"], deps = [ "//beacon-chain/blockchain/testing:go_default_library", diff --git a/beacon-chain/rpc/node/node_server.go b/beacon-chain/rpc/node/server.go similarity index 100% rename from beacon-chain/rpc/node/node_server.go rename to beacon-chain/rpc/node/server.go diff --git a/beacon-chain/rpc/node/node_server_test.go b/beacon-chain/rpc/node/server_test.go similarity index 100% rename from beacon-chain/rpc/node/node_server_test.go rename to beacon-chain/rpc/node/server_test.go diff --git a/beacon-chain/rpc/proposer/BUILD.bazel b/beacon-chain/rpc/proposer/BUILD.bazel index 089516899381..07a7cb3add79 100644 --- a/beacon-chain/rpc/proposer/BUILD.bazel +++ b/beacon-chain/rpc/proposer/BUILD.bazel @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["proposer_server.go"], + srcs = ["server.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/proposer", visibility = ["//beacon-chain:__subpackages__"], deps = [ @@ -34,7 +34,7 @@ go_library( go_test( name = "go_default_test", - srcs = ["proposer_server_test.go"], + srcs = ["server_test.go"], embed = [":go_default_library"], shard_count = 4, deps = [ diff --git a/beacon-chain/rpc/proposer/proposer_server.go b/beacon-chain/rpc/proposer/server.go similarity index 100% rename from beacon-chain/rpc/proposer/proposer_server.go rename to beacon-chain/rpc/proposer/server.go diff --git a/beacon-chain/rpc/proposer/proposer_server_test.go b/beacon-chain/rpc/proposer/server_test.go similarity index 100% rename from beacon-chain/rpc/proposer/proposer_server_test.go rename to beacon-chain/rpc/proposer/server_test.go diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index faff21662edf..9d6e9a3968b5 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -4,8 +4,8 @@ go_library( name = "go_default_library", srcs = [ "assignments.go", + "server.go", "status.go", - "validator_server.go", ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator", visibility = ["//beacon-chain:__subpackages__"], @@ -34,8 +34,8 @@ go_test( name = "go_default_test", srcs = [ "assignments_test.go", + "server_test.go", "status_test.go", - "validator_server_test.go", ], embed = [":go_default_library"], shard_count = 4, diff --git a/beacon-chain/rpc/validator/validator_server.go b/beacon-chain/rpc/validator/server.go similarity index 100% rename from beacon-chain/rpc/validator/validator_server.go rename to beacon-chain/rpc/validator/server.go diff --git a/beacon-chain/rpc/validator/validator_server_test.go b/beacon-chain/rpc/validator/server_test.go similarity index 100% rename from beacon-chain/rpc/validator/validator_server_test.go rename to beacon-chain/rpc/validator/server_test.go From de55d8a3e0363b49ede4c89251b1fba8b0e1237f Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 11:20:59 -0600 Subject: [PATCH 59/82] initial pagination tests passing --- beacon-chain/rpc/beacon/BUILD.bazel | 1 + beacon-chain/rpc/beacon/committees_test.go | 70 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 beacon-chain/rpc/beacon/committees_test.go diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index dab13be04fa3..308a85a69416 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -40,6 +40,7 @@ go_test( "assignments_test.go", "attestations_test.go", "blocks_test.go", + "committees_test.go", "validators_test.go", ], embed = [":go_default_library"], diff --git a/beacon-chain/rpc/beacon/committees_test.go b/beacon-chain/rpc/beacon/committees_test.go new file mode 100644 index 000000000000..3dfe53d283a5 --- /dev/null +++ b/beacon-chain/rpc/beacon/committees_test.go @@ -0,0 +1,70 @@ +package beacon + +import ( + "context" + "fmt" + "strconv" + "strings" + "testing" + + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/shared/params" +) + +func TestServer_ListBeaconCommittees_Pagination_OutOfRange(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + numValidators := 1 + setupValidators(t, db, numValidators) + + headState, err := db.HeadState(context.Background()) + if err != nil { + t.Fatal(err) + } + headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) + for i := 0; i < len(headState.RandaoMixes); i++ { + headState.RandaoMixes[i] = make([]byte, 32) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + numCommittees := uint64(0) + for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ { + var countAtSlot = uint64(numValidators) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize + if countAtSlot > params.BeaconConfig().MaxCommitteesPerSlot { + countAtSlot = params.BeaconConfig().MaxCommitteesPerSlot + } + if countAtSlot == 0 { + countAtSlot = 1 + } + numCommittees += countAtSlot + } + + req := ðpb.ListCommitteesRequest{PageToken: strconv.Itoa(1), PageSize: 100} + wanted := fmt.Sprintf("page start %d >= list %d", req.PageSize, numCommittees) + if _, err := bs.ListBeaconCommittees(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} + +func TestServer_ListBeaconCommittees_Pagination_ExceedsMaxPageSize(t *testing.T) { + bs := &Server{} + exceedsMax := int32(params.BeaconConfig().MaxPageSize + 1) + + wanted := fmt.Sprintf( + "requested page size %d can not be greater than max size %d", + exceedsMax, + params.BeaconConfig().MaxPageSize, + ) + req := ðpb.ListCommitteesRequest{PageToken: strconv.Itoa(0), PageSize: exceedsMax} + if _, err := bs.ListBeaconCommittees(context.Background(), req); err != nil && !strings.Contains(err.Error(), wanted) { + t.Errorf("Expected error %v, received %v", wanted, err) + } +} From 81f61669147fd4ededef868d49d8f996ee1edbb2 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 12:07:26 -0600 Subject: [PATCH 60/82] paginated tests pass --- beacon-chain/rpc/beacon/committees.go | 15 +-- beacon-chain/rpc/beacon/committees_test.go | 140 ++++++++++++++++++++- 2 files changed, 142 insertions(+), 13 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 84273736f64b..94f2f681fc8f 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -2,6 +2,7 @@ package beacon import ( "context" + "fmt" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" @@ -43,7 +44,6 @@ func (bs *Server) ListBeaconCommittees( } var attesterSeed [32]byte - var committeeCount uint64 var activeIndices []uint64 var err error if requestingGenesis || startSlot != headState.Slot { @@ -56,7 +56,6 @@ func (bs *Server) ListBeaconCommittees( return nil, err } attesterSeed = bytesutil.ToBytes32(archivedCommitteeInfo.AttesterSeed) - committeeCount = archivedCommitteeInfo.CommitteeCount } else { // Otherwise, we use data from the current epoch. currentEpoch := helpers.SlotToEpoch(headState.Slot) @@ -64,10 +63,6 @@ func (bs *Server) ListBeaconCommittees( if err != nil { return nil, err } - committeeCount, err = helpers.CommitteeCountAtSlot(headState, headState.Slot) - if err != nil { - return nil, err - } attesterSeed, err = helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { return nil, err @@ -86,7 +81,8 @@ func (bs *Server) ListBeaconCommittees( } for i := uint64(0); i < countAtSlot; i++ { epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot - committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, committeeCount) + totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch + committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) if err != nil { return nil, err } @@ -102,6 +98,11 @@ func (bs *Server) ListBeaconCommittees( if err != nil { return nil, err } + activeIndices, err = helpers.ActiveValidatorIndices(headState, 0) + if err != nil { + return nil, err + } + fmt.Println(activeIndices) return ðpb.BeaconCommittees{ Epoch: helpers.SlotToEpoch(startSlot), ActiveValidatorCount: uint64(len(activeIndices)), diff --git a/beacon-chain/rpc/beacon/committees_test.go b/beacon-chain/rpc/beacon/committees_test.go index 3dfe53d283a5..8491dc80848d 100644 --- a/beacon-chain/rpc/beacon/committees_test.go +++ b/beacon-chain/rpc/beacon/committees_test.go @@ -7,8 +7,12 @@ import ( "strings" "testing" + "github.com/gogo/protobuf/proto" mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/beacon-chain/db" dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" + pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -18,12 +22,7 @@ func TestServer_ListBeaconCommittees_Pagination_OutOfRange(t *testing.T) { defer dbTest.TeardownDB(t, db) numValidators := 1 - setupValidators(t, db, numValidators) - - headState, err := db.HeadState(context.Background()) - if err != nil { - t.Fatal(err) - } + headState := setupActiveValidators(t, db, numValidators) headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) for i := 0; i < len(headState.RandaoMixes); i++ { headState.RandaoMixes[i] = make([]byte, 32) @@ -68,3 +67,132 @@ func TestServer_ListBeaconCommittees_Pagination_ExceedsMaxPageSize(t *testing.T) t.Errorf("Expected error %v, received %v", wanted, err) } } + +func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + numValidators := 64 + headState := setupActiveValidators(t, db, numValidators) + + headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) + for i := 0; i < len(headState.RandaoMixes); i++ { + headState.RandaoMixes[i] = make([]byte, 32) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + activeIndices, err := helpers.ActiveValidatorIndices(headState, 0) + if err != nil { + t.Fatal(err) + } + attesterSeed, err := helpers.Seed(headState, 0, params.BeaconConfig().DomainBeaconAttester) + if err != nil { + t.Fatal(err) + } + wanted := make([]*ethpb.BeaconCommittees_CommitteeItem, 0) + for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ { + var countAtSlot = uint64(numValidators) / 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 + totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch + committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) + if err != nil { + t.Fatal(err) + } + wanted = append(wanted, ðpb.BeaconCommittees_CommitteeItem{ + Committee: committee, + Slot: slot, + }) + } + } + + tests := []struct { + req *ethpb.ListCommitteesRequest + res *ethpb.BeaconCommittees + }{ + { + req: ðpb.ListCommitteesRequest{ + PageToken: strconv.Itoa(1), PageSize: 3, + }, + res: ðpb.BeaconCommittees{ + Epoch: 0, + Committees: wanted[3:6], + ActiveValidatorCount: uint64(numValidators), + NextPageToken: strconv.Itoa(2), + TotalSize: int32(len(wanted)), + }, + }, + //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 3}, + // res: ðpb.ValidatorBalances{ + // Balances: []*ethpb.ValidatorBalances_Balance{ + // {PublicKey: []byte{3}, Index: 3, Balance: uint64(3)}, + // {PublicKey: []byte{4}, Index: 4, Balance: uint64(4)}, + // {PublicKey: []byte{5}, Index: 5, Balance: uint64(5)}}, + // NextPageToken: strconv.Itoa(2), + // TotalSize: int32(count)}}, + //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(10), PageSize: 5}, + // res: ðpb.ValidatorBalances{ + // Balances: []*ethpb.ValidatorBalances_Balance{ + // {PublicKey: []byte{50}, Index: 50, Balance: uint64(50)}, + // {PublicKey: []byte{51}, Index: 51, Balance: uint64(51)}, + // {PublicKey: []byte{52}, Index: 52, Balance: uint64(52)}, + // {PublicKey: []byte{53}, Index: 53, Balance: uint64(53)}, + // {PublicKey: []byte{54}, Index: 54, Balance: uint64(54)}}, + // NextPageToken: strconv.Itoa(11), + // TotalSize: int32(count)}}, + //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(33), PageSize: 3}, + // res: ðpb.ValidatorBalances{ + // Balances: []*ethpb.ValidatorBalances_Balance{ + // {PublicKey: []byte{99}, Index: 99, Balance: uint64(99)}, + // {PublicKey: []byte{100}, Index: 100, Balance: uint64(100)}, + // {PublicKey: []byte{101}, Index: 101, Balance: uint64(101)}, + // }, + // NextPageToken: strconv.Itoa(34), + // TotalSize: int32(count)}}, + //{req: ðpb.GetValidatorBalancesRequest{PageSize: 2}, + // res: ðpb.ValidatorBalances{ + // Balances: []*ethpb.ValidatorBalances_Balance{ + // {PublicKey: []byte{0}, Index: 0, Balance: uint64(0)}, + // {PublicKey: []byte{1}, Index: 1, Balance: uint64(1)}}, + // NextPageToken: strconv.Itoa(1), + // TotalSize: int32(count)}}, + } + for _, test := range tests { + res, err := bs.ListBeaconCommittees(context.Background(), test.req) + if err != nil { + t.Fatal(err) + } + if !proto.Equal(res, test.res) { + t.Errorf("Expected %v, received %v", test.res, res) + } + } +} + +func setupActiveValidators(t *testing.T, db db.Database, count int) *pbp2p.BeaconState { + ctx := context.Background() + balances := make([]uint64, count) + 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 { + t.Fatal(err) + } + balances[i] = uint64(i) + validators = append(validators, ðpb.Validator{ + PublicKey: []byte{byte(i)}, + ActivationEpoch: 0, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + }) + } + return &pbp2p.BeaconState{Validators: validators, Balances: balances} +} From 7f4300e348850abfc4ecacc3b556c0c23643ae80 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 12:08:31 -0600 Subject: [PATCH 61/82] fix bug regarding total count --- beacon-chain/rpc/beacon/assignments.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/beacon/assignments.go b/beacon-chain/rpc/beacon/assignments.go index 7d65b905812e..5f22af8139ca 100644 --- a/beacon-chain/rpc/beacon/assignments.go +++ b/beacon-chain/rpc/beacon/assignments.go @@ -163,7 +163,6 @@ func archivedValidatorCommittee( activeIndices []uint64, archivedBalances []uint64, ) ([]uint64, uint64, uint64, uint64, error) { - committeeCount := archivedInfo.CommitteeCount proposerSeed := bytesutil.ToBytes32(archivedInfo.ProposerSeed) attesterSeed := bytesutil.ToBytes32(archivedInfo.AttesterSeed) @@ -188,7 +187,8 @@ func archivedValidatorCommittee( } for i := uint64(0); i < countAtSlot; i++ { epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot - committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, committeeCount) + totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch + committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) if err != nil { return nil, 0, 0, 0, errors.Wrap(err, "could not compute committee") } From a7dff1216535d41732d0448988cabbe378c6b81e Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 12:17:22 -0600 Subject: [PATCH 62/82] pagination tests pass --- beacon-chain/rpc/beacon/committees_test.go | 61 +++++++++------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees_test.go b/beacon-chain/rpc/beacon/committees_test.go index 8491dc80848d..80614cbbeb28 100644 --- a/beacon-chain/rpc/beacon/committees_test.go +++ b/beacon-chain/rpc/beacon/committees_test.go @@ -72,7 +72,7 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) - numValidators := 64 + numValidators := 128 headState := setupActiveValidators(t, db, numValidators) headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) @@ -116,11 +116,24 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { }) } } + fmt.Println(len(wanted)) tests := []struct { req *ethpb.ListCommitteesRequest res *ethpb.BeaconCommittees }{ + { + req: ðpb.ListCommitteesRequest{ + PageSize: 2, + }, + res: ðpb.BeaconCommittees{ + Epoch: 0, + Committees: wanted[0:2], + ActiveValidatorCount: uint64(numValidators), + NextPageToken: strconv.Itoa(1), + TotalSize: int32(len(wanted)), + }, + }, { req: ðpb.ListCommitteesRequest{ PageToken: strconv.Itoa(1), PageSize: 3, @@ -133,40 +146,18 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { TotalSize: int32(len(wanted)), }, }, - //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(1), PageSize: 3}, - // res: ðpb.ValidatorBalances{ - // Balances: []*ethpb.ValidatorBalances_Balance{ - // {PublicKey: []byte{3}, Index: 3, Balance: uint64(3)}, - // {PublicKey: []byte{4}, Index: 4, Balance: uint64(4)}, - // {PublicKey: []byte{5}, Index: 5, Balance: uint64(5)}}, - // NextPageToken: strconv.Itoa(2), - // TotalSize: int32(count)}}, - //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(10), PageSize: 5}, - // res: ðpb.ValidatorBalances{ - // Balances: []*ethpb.ValidatorBalances_Balance{ - // {PublicKey: []byte{50}, Index: 50, Balance: uint64(50)}, - // {PublicKey: []byte{51}, Index: 51, Balance: uint64(51)}, - // {PublicKey: []byte{52}, Index: 52, Balance: uint64(52)}, - // {PublicKey: []byte{53}, Index: 53, Balance: uint64(53)}, - // {PublicKey: []byte{54}, Index: 54, Balance: uint64(54)}}, - // NextPageToken: strconv.Itoa(11), - // TotalSize: int32(count)}}, - //{req: ðpb.GetValidatorBalancesRequest{PageToken: strconv.Itoa(33), PageSize: 3}, - // res: ðpb.ValidatorBalances{ - // Balances: []*ethpb.ValidatorBalances_Balance{ - // {PublicKey: []byte{99}, Index: 99, Balance: uint64(99)}, - // {PublicKey: []byte{100}, Index: 100, Balance: uint64(100)}, - // {PublicKey: []byte{101}, Index: 101, Balance: uint64(101)}, - // }, - // NextPageToken: strconv.Itoa(34), - // TotalSize: int32(count)}}, - //{req: ðpb.GetValidatorBalancesRequest{PageSize: 2}, - // res: ðpb.ValidatorBalances{ - // Balances: []*ethpb.ValidatorBalances_Balance{ - // {PublicKey: []byte{0}, Index: 0, Balance: uint64(0)}, - // {PublicKey: []byte{1}, Index: 1, Balance: uint64(1)}}, - // NextPageToken: strconv.Itoa(1), - // TotalSize: int32(count)}}, + { + req: ðpb.ListCommitteesRequest{ + PageToken: strconv.Itoa(3), PageSize: 5, + }, + res: ðpb.BeaconCommittees{ + Epoch: 0, + Committees: wanted[15:20], + ActiveValidatorCount: uint64(numValidators), + NextPageToken: strconv.Itoa(4), + TotalSize: int32(len(wanted)), + }, + }, } for _, test := range tests { res, err := bs.ListBeaconCommittees(context.Background(), test.req) From 77e4f96fdea4f9f32cf52505fdbf90165b420334 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 12:20:11 -0600 Subject: [PATCH 63/82] adding final test, archive --- beacon-chain/rpc/beacon/committees_test.go | 60 +++++++++++++++++++++- beacon-chain/rpc/beacon/validators_test.go | 4 +- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees_test.go b/beacon-chain/rpc/beacon/committees_test.go index 80614cbbeb28..3e9917fb3dd1 100644 --- a/beacon-chain/rpc/beacon/committees_test.go +++ b/beacon-chain/rpc/beacon/committees_test.go @@ -116,7 +116,6 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { }) } } - fmt.Println(len(wanted)) tests := []struct { req *ethpb.ListCommitteesRequest @@ -170,6 +169,65 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { } } +func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { + db := dbTest.SetupDB(t) + defer dbTest.TeardownDB(t, db) + + numValidators := 128 + headState := setupActiveValidators(t, db, numValidators) + + headState.RandaoMixes = make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector) + for i := 0; i < len(headState.RandaoMixes); i++ { + headState.RandaoMixes[i] = make([]byte, 32) + } + + bs := &Server{ + HeadFetcher: &mock.ChainService{ + State: headState, + }, + } + + activeIndices, err := helpers.ActiveValidatorIndices(headState, 0) + if err != nil { + t.Fatal(err) + } + attesterSeed, err := helpers.Seed(headState, 0, params.BeaconConfig().DomainBeaconAttester) + if err != nil { + t.Fatal(err) + } + wanted := make([]*ethpb.BeaconCommittees_CommitteeItem, 0) + for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ { + var countAtSlot = uint64(numValidators) / 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 + totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch + committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) + if err != nil { + t.Fatal(err) + } + wanted = append(wanted, ðpb.BeaconCommittees_CommitteeItem{ + Committee: committee, + Slot: slot, + }) + } + } + res, err := bs.ListBeaconCommittees(context.Background(), ðpb.ListCommitteesRequest{ + PageSize: 2, + }) + if err != nil { + t.Fatal(err) + } + if res == nil { + t.Fatal(err) + } +} + func setupActiveValidators(t *testing.T, db db.Database, count int) *pbp2p.BeaconState { ctx := context.Background() balances := make([]uint64, count) diff --git a/beacon-chain/rpc/beacon/validators_test.go b/beacon-chain/rpc/beacon/validators_test.go index 539d084bb718..cc3896cbdb68 100644 --- a/beacon-chain/rpc/beacon/validators_test.go +++ b/beacon-chain/rpc/beacon/validators_test.go @@ -66,7 +66,7 @@ func TestServer_ListValidatorBalances_ExceedsMaxPageSize(t *testing.T) { } } -func TestServer_ListValidatorBalances_NoPagination(t *testing.T) { +func TestServer_ListValidatorBalances_Pagination_Default(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) @@ -147,7 +147,7 @@ func TestServer_ListValidatorBalances_NoPagination(t *testing.T) { } } -func TestServer_ListValidatorBalances_Pagination(t *testing.T) { +func TestServer_ListValidatorBalances_Pagination_CustomPageSizes(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) From 1da9753ad71194c29c7a03654cdcb932a24b14e8 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:37:45 -0600 Subject: [PATCH 64/82] archive test works --- beacon-chain/rpc/beacon/committees.go | 7 ++-- beacon-chain/rpc/beacon/committees_test.go | 48 ++++++++++++++++++---- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 94f2f681fc8f..d3bd6b0413e0 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -2,15 +2,15 @@ package beacon import ( "context" - "fmt" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/pagination" "github.com/prysmaticlabs/prysm/shared/params" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) // ListBeaconCommittees for a given epoch. @@ -102,7 +102,6 @@ func (bs *Server) ListBeaconCommittees( if err != nil { return nil, err } - fmt.Println(activeIndices) return ðpb.BeaconCommittees{ Epoch: helpers.SlotToEpoch(startSlot), ActiveValidatorCount: uint64(len(activeIndices)), diff --git a/beacon-chain/rpc/beacon/committees_test.go b/beacon-chain/rpc/beacon/committees_test.go index 3e9917fb3dd1..e268b734582a 100644 --- a/beacon-chain/rpc/beacon/committees_test.go +++ b/beacon-chain/rpc/beacon/committees_test.go @@ -3,6 +3,7 @@ package beacon import ( "context" "fmt" + "reflect" "strconv" "strings" "testing" @@ -172,6 +173,7 @@ func TestServer_ListBeaconCommittees_Pagination_CustomPageSize(t *testing.T) { func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { db := dbTest.SetupDB(t) defer dbTest.TeardownDB(t, db) + ctx := context.Background() numValidators := 128 headState := setupActiveValidators(t, db, numValidators) @@ -181,7 +183,21 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { headState.RandaoMixes[i] = make([]byte, 32) } + headState.Slot = params.BeaconConfig().SlotsPerEpoch * 10 + + // Store the genesis seed. + seed, err := helpers.Seed(headState, 0, params.BeaconConfig().DomainBeaconAttester) + if err != nil { + t.Fatal(err) + } + if err := db.SaveArchivedCommitteeInfo(ctx, 0, ðpb.ArchivedCommitteeInfo{ + AttesterSeed: seed[:], + }); err != nil { + t.Fatal(err) + } + bs := &Server{ + BeaconDB: db, HeadFetcher: &mock.ChainService{ State: headState, }, @@ -191,10 +207,6 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { if err != nil { t.Fatal(err) } - attesterSeed, err := helpers.Seed(headState, 0, params.BeaconConfig().DomainBeaconAttester) - if err != nil { - t.Fatal(err) - } wanted := make([]*ethpb.BeaconCommittees_CommitteeItem, 0) for slot := uint64(0); slot < params.BeaconConfig().SlotsPerEpoch; slot++ { var countAtSlot = uint64(numValidators) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize @@ -207,7 +219,7 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { for i := uint64(0); i < countAtSlot; i++ { epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch - committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) + committee, err := helpers.ComputeCommittee(activeIndices, seed, epochOffset, totalCount) if err != nil { t.Fatal(err) } @@ -217,15 +229,35 @@ func TestServer_ListBeaconCommittees_FromArchive(t *testing.T) { }) } } - res, err := bs.ListBeaconCommittees(context.Background(), ðpb.ListCommitteesRequest{ - PageSize: 2, + res1, err := bs.ListBeaconCommittees(context.Background(), ðpb.ListCommitteesRequest{ + QueryFilter: ðpb.ListCommitteesRequest_Genesis{ + Genesis: true, + }, + }) + if err != nil { + t.Fatal(err) + } + res2, err := bs.ListBeaconCommittees(context.Background(), ðpb.ListCommitteesRequest{ + QueryFilter: ðpb.ListCommitteesRequest_Epoch{ + Epoch: 0, + }, }) if err != nil { t.Fatal(err) } - if res == nil { + if !reflect.DeepEqual(res1, res2) { t.Fatal(err) } + wantedRes := ðpb.BeaconCommittees{ + Epoch: 0, + Committees: wanted, + ActiveValidatorCount: uint64(numValidators), + NextPageToken: strconv.Itoa(1), + TotalSize: int32(len(wanted)), + } + if !reflect.DeepEqual(wantedRes, res1) { + t.Errorf("Wanted %v, received %v", wantedRes, res1) + } } func setupActiveValidators(t *testing.T, db db.Database, count int) *pbp2p.BeaconState { From df35233f5322e1fa582a5ebb46d015ca4b12cd77 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:43:36 -0600 Subject: [PATCH 65/82] regen protos for archival --- beacon-chain/archiver/service.go | 9 +-- beacon-chain/rpc/beacon/assignments_test.go | 8 +- proto/eth/v1alpha1/archive.pb.go | 90 +++++++-------------- proto/eth/v1alpha1/archive.proto | 3 - proto/eth/v1alpha1/slasher.pb.go | 5 +- proto/eth/v1alpha1/validator.pb.go | 6 +- 6 files changed, 38 insertions(+), 83 deletions(-) diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index 8761e1a7e034..e793922a9d2d 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -69,10 +69,6 @@ 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.CommitteeCountAtSlot(headState, helpers.StartSlot(currentEpoch)) - if err != nil { - return errors.Wrap(err, "could not get committee count") - } proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { return errors.Wrap(err, "could not generate seed") @@ -83,9 +79,8 @@ func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.Beacon } info := ðpb.ArchivedCommitteeInfo{ - ProposerSeed: proposerSeed[:], - AttesterSeed: attesterSeed[:], - CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], } if err := s.beaconDB.SaveArchivedCommitteeInfo(ctx, currentEpoch, info); err != nil { return errors.Wrap(err, "could not archive committee info") diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 225c359cbeac..2814e92b3174 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -65,7 +65,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. defer dbTest.TeardownDB(t, db) ctx := context.Background() - count := 1000 + count := 100 validators := make([]*ethpb.Validator, 0, count) for i := 0; i < count; i++ { var pubKey [48]byte @@ -133,7 +133,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. if err != nil { t.Fatal(err) } - for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { + for _, index := range activeIndices[0:100] { committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) @@ -157,7 +157,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin defer dbTest.TeardownDB(t, db) ctx := context.Background() - count := 1000 + count := 100 validators := make([]*ethpb.Validator, 0, count) balances := make([]uint64, count) for i := 0; i < count; i++ { @@ -249,7 +249,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin if err != nil { t.Fatal(err) } - for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { + for _, index := range activeIndices[0:100] { committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) diff --git a/proto/eth/v1alpha1/archive.pb.go b/proto/eth/v1alpha1/archive.pb.go index 9d19417d855c..382fc1dd2f1b 100755 --- a/proto/eth/v1alpha1/archive.pb.go +++ b/proto/eth/v1alpha1/archive.pb.go @@ -112,7 +112,6 @@ func (m *ArchivedActiveSetChanges) GetAttesterSlashings() []*AttesterSlashing { type ArchivedCommitteeInfo struct { 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"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -165,13 +164,6 @@ func (m *ArchivedCommitteeInfo) GetAttesterSeed() []byte { return nil } -func (m *ArchivedCommitteeInfo) GetCommitteeCount() uint64 { - if m != nil { - return m.CommitteeCount - } - return 0 -} - func init() { proto.RegisterType((*ArchivedActiveSetChanges)(nil), "ethereum.eth.v1alpha1.ArchivedActiveSetChanges") proto.RegisterType((*ArchivedCommitteeInfo)(nil), "ethereum.eth.v1alpha1.ArchivedCommitteeInfo") @@ -180,34 +172,33 @@ func init() { func init() { proto.RegisterFile("proto/eth/v1alpha1/archive.proto", fileDescriptor_afd178f87193e24d) } var fileDescriptor_afd178f87193e24d = []byte{ - // 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, 0xc8, 0xf5, 0x12, 0x94, 0x66, - 0xd3, 0x84, 0xb6, 0xe8, 0x42, 0x57, 0xb7, 0xc1, 0x85, 0x0b, 0x41, 0x52, 0xe8, 0xc2, 0x4d, 0x98, - 0x4c, 0xbe, 0x66, 0x06, 0x93, 0x4c, 0xc8, 0x7c, 0x09, 0x6d, 0x9f, 0xca, 0xc7, 0x70, 0xe9, 0x13, - 0x88, 0xdc, 0x9d, 0x5b, 0x9f, 0x40, 0x32, 0x49, 0x6e, 0x6a, 0x6d, 0xbb, 0xcb, 0x39, 0xdf, 0x39, - 0xe7, 0x3b, 0x33, 0x19, 0xb2, 0x28, 0x2b, 0x85, 0xca, 0x07, 0x14, 0x7e, 0x73, 0xcc, 0xb2, 0x52, - 0xb0, 0x63, 0x9f, 0x55, 0x5c, 0xc8, 0x06, 0x3c, 0x33, 0xa2, 0xfb, 0x80, 0x02, 0x2a, 0xa8, 0x73, - 0x0f, 0x50, 0x78, 0x83, 0xe8, 0xe0, 0x28, 0x95, 0x28, 0xea, 0xd8, 0xe3, 0x2a, 0xf7, 0x53, 0x95, - 0x2a, 0xdf, 0xa8, 0xe3, 0xfa, 0xd2, 0xa0, 0x2e, 0xb5, 0xfd, 0xea, 0x52, 0x0e, 0x5e, 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, 0x7e, 0xbe, 0xdc, 0xd6, 0xfa, 0xe6, 0x48, 0xcb, 0x1b, 0x78, 0xe7, 0x9c, 0x9e, - 0x38, 0xe1, 0xd6, 0xba, 0x2e, 0x40, 0xd2, 0xfa, 0xc6, 0xa6, 0x60, 0xfe, 0xc4, 0x43, 0xbe, 0x75, - 0x9d, 0xd6, 0x77, 0x48, 0x76, 0xf9, 0x50, 0x20, 0xe2, 0xaa, 0x2e, 0xd0, 0x9e, 0x2c, 0x2c, 0x77, - 0x1a, 0xee, 0xac, 0xe9, 0xa0, 0x65, 0xcf, 0x82, 0xef, 0xab, 0xb9, 0xf5, 0x63, 0x35, 0xb7, 0x7e, - 0xad, 0xe6, 0xd6, 0x97, 0x37, 0xb7, 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, + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0xc9, 0xee, 0xd2, 0xd5, 0x71, 0x57, 0xd9, 0x81, 0x95, 0xb0, 0x48, 0x2d, 0x41, 0xb1, + 0x97, 0x4d, 0x68, 0x8b, 0x1e, 0xf4, 0xd4, 0x16, 0x0f, 0x1e, 0x04, 0x49, 0xa1, 0x07, 0x2f, 0x65, + 0x92, 0xbc, 0x66, 0x06, 0x93, 0x4c, 0xc8, 0xbc, 0x84, 0xb6, 0x5f, 0xc0, 0xaf, 0xe6, 0xd1, 0x4f, + 0x20, 0xd2, 0x9b, 0x57, 0x3f, 0x81, 0x64, 0x92, 0x34, 0xb5, 0xb6, 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, 0x24, 0xa1, 0x32, 0x2f, 0x35, 0xf1, 0xd5, 0x09, 0xe2, 0xa7, 0xba, 0x61, 0x56, 0xe7, + 0xdd, 0x9b, 0xf4, 0xc0, 0xd1, 0x5c, 0x86, 0x08, 0x0a, 0xff, 0xe2, 0x3e, 0xf8, 0x2f, 0x77, 0x5c, + 0x37, 0xb4, 0x5c, 0x76, 0xe0, 0x28, 0xeb, 0xab, 0x41, 0x6e, 0x9b, 0xbb, 0x9e, 0xca, 0x38, 0x16, + 0x88, 0x00, 0x1f, 0x92, 0xa5, 0xa4, 0x6f, 0xc8, 0x75, 0x7b, 0x12, 0xd0, 0x97, 0x6d, 0xf4, 0xaf, + 0x26, 0x37, 0xbf, 0x7f, 0x3c, 0xbf, 0x56, 0x6a, 0x73, 0xaf, 0xc4, 0x06, 0xde, 0x5a, 0xa3, 0xa1, + 0xe5, 0x5e, 0xed, 0xd6, 0x05, 0x08, 0xca, 0xbe, 0x76, 0x53, 0xd0, 0x7f, 0xe2, 0x54, 0xdf, 0x6e, + 0x1d, 0x80, 0x60, 0x32, 0xfd, 0xb6, 0xed, 0x1a, 0xdf, 0xb7, 0x5d, 0xe3, 0xe7, 0xb6, 0x6b, 0x7c, + 0x7e, 0xbd, 0xf7, 0xb2, 0xd2, 0x6c, 0xad, 0x62, 0x86, 0xc2, 0x8f, 0x98, 0xa7, 0x2a, 0xe5, 0xfc, + 0xfb, 0x92, 0xde, 0x01, 0x72, 0xaf, 0xa3, 0xfd, 0xd1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x68, + 0x2f, 0x56, 0xa4, 0xd2, 0x02, 0x00, 0x00, } func (m *ArchivedActiveSetChanges) Marshal() (dAtA []byte, err error) { @@ -345,11 +336,6 @@ func (m *ArchivedCommitteeInfo) MarshalTo(dAtA []byte) (int, error) { 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.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -430,9 +416,6 @@ func (m *ArchivedCommitteeInfo) Size() (n int) { if l > 0 { n += 1 + l + sovArchive(uint64(l)) } - if m.CommitteeCount != 0 { - n += 1 + sovArchive(uint64(m.CommitteeCount)) - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -933,25 +916,6 @@ func (m *ArchivedCommitteeInfo) Unmarshal(dAtA []byte) error { m.AttesterSeed = []byte{} } iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CommitteeCount", wireType) - } - m.CommitteeCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowArchive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CommitteeCount |= 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 8699a86e337a..a1cda0dff48c 100644 --- a/proto/eth/v1alpha1/archive.proto +++ b/proto/eth/v1alpha1/archive.proto @@ -42,7 +42,4 @@ message ArchivedCommitteeInfo { // 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; } diff --git a/proto/eth/v1alpha1/slasher.pb.go b/proto/eth/v1alpha1/slasher.pb.go index 9151ccbdeb61..655f144a5e7e 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/eth/v1alpha1/validator.pb.go b/proto/eth/v1alpha1/validator.pb.go index f7b3470e134d..d4f83587b8da 100755 --- a/proto/eth/v1alpha1/validator.pb.go +++ b/proto/eth/v1alpha1/validator.pb.go @@ -624,7 +624,7 @@ func (c *beaconNodeValidatorClient) GetAttestationData(ctx context.Context, in * func (c *beaconNodeValidatorClient) ProposeAttestation(ctx context.Context, in *Attestation, opts ...grpc.CallOption) (*types.Empty, error) { out := new(types.Empty) - err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.BeaconNodeValidator/SubmitAttestation", in, out, opts...) + err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.BeaconNodeValidator/ProposeAttestation", in, out, opts...) if err != nil { return nil, err } @@ -726,7 +726,7 @@ func _BeaconNodeValidator_ProposeAttestation_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethereum.eth.v1alpha1.BeaconNodeValidator/SubmitAttestation", + FullMethod: "/ethereum.eth.v1alpha1.BeaconNodeValidator/ProposeAttestation", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BeaconNodeValidatorServer).ProposeAttestation(ctx, req.(*Attestation)) @@ -755,7 +755,7 @@ var _BeaconNodeValidator_serviceDesc = grpc.ServiceDesc{ Handler: _BeaconNodeValidator_GetAttestationData_Handler, }, { - MethodName: "SubmitAttestation", + MethodName: "ProposeAttestation", Handler: _BeaconNodeValidator_ProposeAttestation_Handler, }, }, From 450b50dc55825fa5430685745ac3d6aa3c73043e Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:44:07 -0600 Subject: [PATCH 66/82] resolve broken test --- beacon-chain/rpc/beacon/assignments_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 2814e92b3174..10ecde78c1f0 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -219,10 +219,6 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin // We then store archived data into the DB. currentEpoch := helpers.CurrentEpoch(s) - committeeCount, err := helpers.CommitteeCountAtSlot(s, helpers.StartSlot(currentEpoch)) - if err != nil { - t.Fatal(err) - } proposerSeed, err := helpers.Seed(s, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { t.Fatal(err) @@ -232,9 +228,8 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin t.Fatal(err) } if err := db.SaveArchivedCommitteeInfo(context.Background(), 0, ðpb.ArchivedCommitteeInfo{ - ProposerSeed: proposerSeed[:], - AttesterSeed: attesterSeed[:], - CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], }); err != nil { t.Fatal(err) } From 632a7a8ee5bccf3fb6c3fff65724edc55a9b0719 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:44:51 -0600 Subject: [PATCH 67/82] test pass --- beacon-chain/rpc/beacon/assignments_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 10ecde78c1f0..6b7376004918 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -65,7 +65,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. defer dbTest.TeardownDB(t, db) ctx := context.Background() - count := 100 + count := 1000 validators := make([]*ethpb.Validator, 0, count) for i := 0; i < count; i++ { var pubKey [48]byte @@ -157,7 +157,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin defer dbTest.TeardownDB(t, db) ctx := context.Background() - count := 100 + count := 1000 validators := make([]*ethpb.Validator, 0, count) balances := make([]uint64, count) for i := 0; i < count; i++ { From a4e5965abca874e5d0284b28377a1052df4aa8c3 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:45:46 -0600 Subject: [PATCH 68/82] broken archive test --- beacon-chain/archiver/service_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/beacon-chain/archiver/service_test.go b/beacon-chain/archiver/service_test.go index 66f5080e327f..ced0766557dd 100644 --- a/beacon-chain/archiver/service_test.go +++ b/beacon-chain/archiver/service_test.go @@ -128,10 +128,6 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { triggerNewHeadEvent(t, svc, [32]byte{}) currentEpoch := helpers.CurrentEpoch(headState) - committeeCount, err := helpers.CommitteeCountAtSlot(headState, helpers.StartSlot(currentEpoch)) - if err != nil { - t.Fatal(err) - } proposerSeed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconProposer) if err != nil { t.Fatal(err) @@ -141,9 +137,8 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) { t.Fatal(err) } wanted := ðpb.ArchivedCommitteeInfo{ - ProposerSeed: proposerSeed[:], - AttesterSeed: attesterSeed[:], - CommitteeCount: committeeCount * params.BeaconConfig().SlotsPerEpoch, + ProposerSeed: proposerSeed[:], + AttesterSeed: attesterSeed[:], } retrieved, err := svc.beaconDB.ArchivedCommitteeInfo(svc.ctx, helpers.CurrentEpoch(headState)) From 8b9b5605666d1a50852cd4a8ab7fe5b645d0e928 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:46:16 -0600 Subject: [PATCH 69/82] rem helpers --- beacon-chain/rpc/helpers.go | 86 ------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 beacon-chain/rpc/helpers.go diff --git a/beacon-chain/rpc/helpers.go b/beacon-chain/rpc/helpers.go deleted file mode 100644 index 228915d91c85..000000000000 --- a/beacon-chain/rpc/helpers.go +++ /dev/null @@ -1,86 +0,0 @@ -package rpc - -import ( - "fmt" - - "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - 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/params" -) - -// Computes validator assignments for an epoch and validator index using archived committee -// information, archived balances, and a set of active validators. -func archivedValidatorCommittee( - epoch uint64, - validatorIndex uint64, - archivedInfo *ethpb.ArchivedCommitteeInfo, - activeIndices []uint64, - archivedBalances []uint64, -) ([]uint64, uint64, uint64, uint64, error) { - committeeCount := archivedInfo.CommitteeCount - 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++ { - 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, 0, errors.Wrap(err, "could not compute committee") - } - for _, index := range committee { - if validatorIndex == index { - proposerSlot, _ := proposerIndexToSlot[validatorIndex] - return committee, i, slot, proposerSlot, nil - } - } - } - } - 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 - } - } -} From ebfeb34c9ba713eb26d70d52db7bda3026d64bf0 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:47:29 -0600 Subject: [PATCH 70/82] gaz --- beacon-chain/rpc/BUILD.bazel | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 00c1aecdbc3a..c181661cce19 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -2,17 +2,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = [ - "helpers.go", - "service.go", - ], + srcs = ["service.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc", visibility = ["//beacon-chain:__subpackages__"], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache:go_default_library", "//beacon-chain/cache/depositcache:go_default_library", - "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/db:go_default_library", "//beacon-chain/operations:go_default_library", "//beacon-chain/p2p:go_default_library", @@ -26,15 +22,12 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/beacon/rpc/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/bytesutil:go_default_library", - "//shared/hashutil:go_default_library", "//shared/params:go_default_library", "//shared/traceutil:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library", "@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library", - "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@io_opencensus_go//plugin/ocgrpc:go_default_library", "@org_golang_google_grpc//:go_default_library", From aeb35571239e63cf87426301013d51a3f04b86ad Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 13:55:12 -0600 Subject: [PATCH 71/82] fix kv test --- beacon-chain/db/kv/archive_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/beacon-chain/db/kv/archive_test.go b/beacon-chain/db/kv/archive_test.go index e995fed48683..7c7ba5214d93 100644 --- a/beacon-chain/db/kv/archive_test.go +++ b/beacon-chain/db/kv/archive_test.go @@ -104,9 +104,8 @@ func TestStore_ArchivedCommitteeInfo(t *testing.T) { ctx := context.Background() someSeed := [32]byte{1, 2, 3} info := ðpb.ArchivedCommitteeInfo{ - ProposerSeed: someSeed[:], - AttesterSeed: someSeed[:], - CommitteeCount: 4096, + ProposerSeed: someSeed[:], + AttesterSeed: someSeed[:], } epoch := uint64(10) if err := db.SaveArchivedCommitteeInfo(ctx, epoch, info); err != nil { From c1db234b16a4f12068fb122267dbd67a39caac15 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 14:00:48 -0600 Subject: [PATCH 72/82] useful gRPC error code standards --- beacon-chain/rpc/beacon/committees.go | 45 +++++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index d3bd6b0413e0..53d3467e500d 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -49,11 +49,21 @@ func (bs *Server) ListBeaconCommittees( if requestingGenesis || startSlot != headState.Slot { activeIndices, err = helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) if err != nil { - return nil, err + return nil, status.Errorf( + codes.Internal, + "could not retrieve active indices for epoch %d: %v", + helpers.SlotToEpoch(startSlot), + err, + ) } archivedCommitteeInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, helpers.SlotToEpoch(startSlot)) if err != nil { - return nil, err + return nil, status.Errorf( + codes.NotFound, + "could not request data for epoch %d, perhaps --archive in the running beacon node is disabled: %v", + helpers.SlotToEpoch(startSlot), + err, + ) } attesterSeed = bytesutil.ToBytes32(archivedCommitteeInfo.AttesterSeed) } else { @@ -61,11 +71,21 @@ func (bs *Server) ListBeaconCommittees( currentEpoch := helpers.SlotToEpoch(headState.Slot) activeIndices, err = helpers.ActiveValidatorIndices(headState, currentEpoch) if err != nil { - return nil, err + return nil, status.Errorf( + codes.Internal, + "could not retrieve active indices for current epoch %d: %v", + currentEpoch, + err, + ) } attesterSeed, err = helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester) if err != nil { - return nil, err + return nil, status.Errorf( + codes.Internal, + "could not retrieve attester seed for current epoch %d: %v", + currentEpoch, + err, + ) } } @@ -84,7 +104,12 @@ func (bs *Server) ListBeaconCommittees( totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount) if err != nil { - return nil, err + return nil, status.Errorf( + codes.Internal, + "could not compute committee for slot %d: %v", + slot, + err, + ) } committees = append(committees, ðpb.BeaconCommittees_CommitteeItem{ Committee: committee, @@ -96,11 +121,11 @@ func (bs *Server) ListBeaconCommittees( numCommittees := len(committees) start, end, nextPageToken, err := pagination.StartAndEndPage(req.PageToken, int(req.PageSize), numCommittees) if err != nil { - return nil, err - } - activeIndices, err = helpers.ActiveValidatorIndices(headState, 0) - if err != nil { - return nil, err + return nil, status.Errorf( + codes.FailedPrecondition, + "could not paginate results: %v", + err, + ) } return ðpb.BeaconCommittees{ Epoch: helpers.SlotToEpoch(startSlot), From 4d6462a5613d1e27d75968e574aa3834875b7fa9 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 14:01:55 -0600 Subject: [PATCH 73/82] format --- beacon-chain/rpc/beacon/committees.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 53d3467e500d..dec46f58e9de 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -3,14 +3,13 @@ package beacon import ( "context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/pagination" "github.com/prysmaticlabs/prysm/shared/params" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) // ListBeaconCommittees for a given epoch. From 24d13e716e1f6bfa0ff2f6921f905753b3359a9c Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 14:22:45 -0600 Subject: [PATCH 74/82] resolved bad test --- beacon-chain/rpc/beacon/assignments_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 6b7376004918..48497797558f 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -133,7 +133,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. if err != nil { t.Fatal(err) } - for _, index := range activeIndices[0:100] { + for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) @@ -147,7 +147,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. }) } - if !reflect.DeepEqual(res.Assignments[0], wanted[207]) { + if !reflect.DeepEqual(res.Assignments, wanted) { t.Error("Did not receive wanted assignments") } } @@ -244,7 +244,7 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_FromArchive(t *testin if err != nil { t.Fatal(err) } - for _, index := range activeIndices[0:100] { + for _, index := range activeIndices[0:params.BeaconConfig().DefaultPageSize] { committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(s, 0, index) if err != nil { t.Fatal(err) From 2fbc45adf9af35af74fa23317b37a9224a0a5154 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 14:34:47 -0600 Subject: [PATCH 75/82] test resolution --- beacon-chain/rpc/beacon/BUILD.bazel | 1 + beacon-chain/rpc/beacon/assignments_test.go | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index 308a85a69416..ada7b8645817 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -58,5 +58,6 @@ go_test( "@com_github_gogo_protobuf//types:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", + "@in_gopkg_d4l3k_messagediff_v1//:go_default_library", ], ) diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 48497797558f..00316edb9390 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/prysmaticlabs/go-ssz" + "gopkg.in/d4l3k/messagediff.v1" mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" @@ -76,14 +77,17 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. // Mark the validators with index divisible by 3 inactive. if i%3 == 0 { validators = append(validators, ðpb.Validator{ - PublicKey: pubKey[:], - ExitEpoch: 0, + PublicKey: pubKey[:], + ExitEpoch: 0, + ActivationEpoch: 0, + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, }) } else { validators = append(validators, ðpb.Validator{ PublicKey: pubKey[:], ExitEpoch: params.BeaconConfig().FarFutureEpoch, EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, + ActivationEpoch: 0, }) } } @@ -120,7 +124,6 @@ func TestServer_ListAssignments_Pagination_DefaultPageSize_NoArchive(t *testing. res, err := bs.ListValidatorAssignments(context.Background(), ðpb.ListValidatorAssignmentsRequest{ QueryFilter: ðpb.ListValidatorAssignmentsRequest_Genesis{Genesis: true}, - PublicKeys: [][]byte{[]byte("311")}, }) if err != nil { t.Fatal(err) From 41004116b81a58ba5f524917b6c469b8f91e325b Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 14:53:42 -0600 Subject: [PATCH 76/82] ux improvements and bug fixes --- beacon-chain/archiver/service.go | 2 +- beacon-chain/node/node.go | 1 + beacon-chain/rpc/beacon/committees.go | 23 +++++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index e793922a9d2d..35823d3079d0 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -157,7 +157,7 @@ func (s *Service) run(ctx context.Context) { log.WithField( "epoch", helpers.CurrentEpoch(headState), - ).Debug("Successfully archived beacon chain data during epoch") + ).Info("Successfully archived beacon chain data during epoch") case <-s.ctx.Done(): log.Debug("Context closed, exiting goroutine") return diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 4bd19cededc8..6aac02530d91 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -516,6 +516,7 @@ func (b *BeaconNode) registerArchiverService(ctx *cli.Context) error { } svc := archiver.NewArchiverService(context.Background(), &archiver.Config{ BeaconDB: b.db, + HeadFetcher: chainService, NewHeadNotifier: chainService, }) return b.services.RegisterService(svc) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index dec46f58e9de..1a420ec43129 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -45,7 +45,7 @@ func (bs *Server) ListBeaconCommittees( var attesterSeed [32]byte var activeIndices []uint64 var err error - if requestingGenesis || startSlot != headState.Slot { + if requestingGenesis || helpers.SlotToEpoch(startSlot) < helpers.SlotToEpoch(headState.Slot) { activeIndices, err = helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) if err != nil { return nil, status.Errorf( @@ -58,14 +58,21 @@ func (bs *Server) ListBeaconCommittees( archivedCommitteeInfo, err := bs.BeaconDB.ArchivedCommitteeInfo(ctx, helpers.SlotToEpoch(startSlot)) if err != nil { return nil, status.Errorf( - codes.NotFound, - "could not request data for epoch %d, perhaps --archive in the running beacon node is disabled: %v", + codes.Internal, + "could not request archival data for epoch %d: %v", helpers.SlotToEpoch(startSlot), err, ) } + if archivedCommitteeInfo == nil { + return nil, status.Errorf( + codes.NotFound, + "could not request data for epoch %d, perhaps --archive in the running beacon node is disabled", + helpers.SlotToEpoch(startSlot), + ) + } attesterSeed = bytesutil.ToBytes32(archivedCommitteeInfo.AttesterSeed) - } else { + } else if !requestingGenesis && helpers.SlotToEpoch(startSlot) == helpers.SlotToEpoch(headState.Slot) { // Otherwise, we use data from the current epoch. currentEpoch := helpers.SlotToEpoch(headState.Slot) activeIndices, err = helpers.ActiveValidatorIndices(headState, currentEpoch) @@ -86,6 +93,14 @@ func (bs *Server) ListBeaconCommittees( err, ) } + } else { + // Otherwise, we are requesting data from the future and we return an error. + return nil, status.Errorf( + codes.FailedPrecondition, + "cannot retrieve information about an epoch in the future, current epoch %d, requesting %d", + helpers.SlotToEpoch(headState.Slot), + helpers.StartSlot(startSlot), + ) } // If current epoch, compute. Otherwise, fetch from archive. From 370db85e368814780ff4a99aaa65175019850f3d Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 15:01:02 -0600 Subject: [PATCH 77/82] complete --- beacon-chain/rpc/beacon/BUILD.bazel | 1 - beacon-chain/rpc/beacon/assignments_test.go | 2 - proto/eth/v1alpha1/beacon_chain.pb.go | 479 +++++++------------- proto/eth/v1alpha1/beacon_chain.proto | 14 +- 4 files changed, 161 insertions(+), 335 deletions(-) diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index ada7b8645817..308a85a69416 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -58,6 +58,5 @@ go_test( "@com_github_gogo_protobuf//types:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", - "@in_gopkg_d4l3k_messagediff_v1//:go_default_library", ], ) diff --git a/beacon-chain/rpc/beacon/assignments_test.go b/beacon-chain/rpc/beacon/assignments_test.go index 00316edb9390..191edfba8083 100644 --- a/beacon-chain/rpc/beacon/assignments_test.go +++ b/beacon-chain/rpc/beacon/assignments_test.go @@ -9,8 +9,6 @@ import ( "testing" "github.com/prysmaticlabs/go-ssz" - "gopkg.in/d4l3k/messagediff.v1" - mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" diff --git a/proto/eth/v1alpha1/beacon_chain.pb.go b/proto/eth/v1alpha1/beacon_chain.pb.go index a4a154adc29f..8f1febfdcca0 100755 --- a/proto/eth/v1alpha1/beacon_chain.pb.go +++ b/proto/eth/v1alpha1/beacon_chain.pb.go @@ -696,10 +696,8 @@ type ListCommitteesRequest struct { // *ListCommitteesRequest_Epoch // *ListCommitteesRequest_Genesis QueryFilter isListCommitteesRequest_QueryFilter `protobuf_oneof:"query_filter"` - PublicKeys [][]byte `protobuf:"bytes,3,rep,name=public_keys,json=publicKeys,proto3" json:"public_keys,omitempty" ssz-size:"?,48"` - Indices []uint64 `protobuf:"varint,4,rep,packed,name=indices,proto3" json:"indices,omitempty"` - PageSize int32 `protobuf:"varint,5,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - PageToken string `protobuf:"bytes,6,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + PageSize int32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -775,20 +773,6 @@ func (m *ListCommitteesRequest) GetGenesis() bool { return false } -func (m *ListCommitteesRequest) GetPublicKeys() [][]byte { - if m != nil { - return m.PublicKeys - } - return nil -} - -func (m *ListCommitteesRequest) GetIndices() []uint64 { - if m != nil { - return m.Indices - } - return nil -} - func (m *ListCommitteesRequest) GetPageSize() int32 { if m != nil { return m.PageSize @@ -2466,116 +2450,115 @@ func init() { } var fileDescriptor_678c88b69c3c78d4 = []byte{ - // 1730 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xbb, 0x6f, 0x1b, 0x47, - 0x1a, 0xf7, 0xf2, 0x21, 0x89, 0x9f, 0x44, 0x3d, 0x46, 0x94, 0xcd, 0xa3, 0x5e, 0xd4, 0xca, 0x92, - 0x69, 0xc8, 0x26, 0x2d, 0xf9, 0x71, 0x07, 0x1f, 0x0e, 0x3e, 0x49, 0xf0, 0x59, 0xbe, 0x33, 0x0e, - 0xca, 0xca, 0x49, 0x91, 0x86, 0x58, 0x2e, 0x47, 0xe4, 0x5a, 0xcb, 0x9d, 0x35, 0x77, 0x28, 0x58, - 0xea, 0x92, 0x22, 0x40, 0xea, 0x00, 0x49, 0xaa, 0x24, 0xad, 0x11, 0xa4, 0x4d, 0x63, 0x20, 0x09, - 0x52, 0xa5, 0x0c, 0x10, 0x20, 0xa5, 0x11, 0x18, 0x01, 0x5c, 0xa5, 0x88, 0xff, 0x82, 0x60, 0x67, - 0x66, 0x5f, 0xe4, 0x2e, 0x49, 0xc3, 0xaa, 0xdc, 0x71, 0xbf, 0xf9, 0xe6, 0xf7, 0xfd, 0xe6, 0x7b, - 0xcc, 0x7c, 0x33, 0x84, 0x35, 0xab, 0x4d, 0x28, 0xa9, 0x60, 0xda, 0xac, 0x1c, 0x6f, 0xaa, 0x86, - 0xd5, 0x54, 0x37, 0x2b, 0x35, 0xac, 0x6a, 0xc4, 0xac, 0x6a, 0x4d, 0x55, 0x37, 0xcb, 0x6c, 0x1c, - 0xcd, 0x61, 0xda, 0xc4, 0x6d, 0xdc, 0x69, 0x95, 0x31, 0x6d, 0x96, 0x5d, 0xcd, 0xc2, 0xd5, 0x86, - 0x4e, 0x9b, 0x9d, 0x5a, 0x59, 0x23, 0xad, 0x4a, 0x83, 0x34, 0x48, 0x85, 0x69, 0xd7, 0x3a, 0x87, - 0xec, 0x8b, 0x43, 0x3b, 0xbf, 0x38, 0x4a, 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xf3, 0x55, 0xcc, 0x38, 0x2b, 0x97, 0xff, 0x98, 0x84, 0xcc, - 0xae, 0xb3, 0x85, 0xec, 0x61, 0xb5, 0x8e, 0xae, 0x01, 0x74, 0x57, 0xcb, 0xce, 0xcc, 0xab, 0xe7, - 0xcb, 0x59, 0xdb, 0x3e, 0xbd, 0xea, 0x00, 0xdc, 0x96, 0xaf, 0x6f, 0xc9, 0x4a, 0xa6, 0xe6, 0x95, - 0xce, 0xa2, 0x3b, 0xc3, 0x0f, 0x86, 0x18, 0x3e, 0x70, 0xe2, 0xb1, 0x06, 0x93, 0x87, 0xba, 0xa9, - 0x1a, 0xfa, 0x29, 0xae, 0x73, 0x15, 0x16, 0x18, 0x25, 0xeb, 0x49, 0x99, 0xda, 0x2e, 0xe4, 0x7c, - 0xb5, 0x00, 0x83, 0x54, 0x1c, 0x03, 0xe4, 0xa9, 0xfb, 0x55, 0xbc, 0x06, 0x93, 0x8f, 0x3a, 0x36, - 0xd5, 0x0f, 0x75, 0xd7, 0x56, 0x9a, 0xdb, 0xf2, 0xa4, 0xae, 0x2d, 0x5f, 0x2d, 0x60, 0x6b, 0x24, - 0xd6, 0x96, 0xa7, 0xee, 0xdb, 0xba, 0x05, 0x17, 0xac, 0x36, 0x3e, 0xd6, 0x49, 0xc7, 0xae, 0x76, - 0x19, 0x1d, 0x65, 0x46, 0xe7, 0xdc, 0xe1, 0xff, 0x86, 0x8c, 0x3f, 0x84, 0xc5, 0x88, 0x79, 0x01, - 0x16, 0x63, 0x71, 0x2c, 0x0a, 0x3d, 0x80, 0x1e, 0x1b, 0xf9, 0xa5, 0x04, 0x73, 0x4e, 0x7a, 0xed, - 0x92, 0x56, 0x4b, 0xa7, 0x14, 0x63, 0xaf, 0x76, 0xbc, 0x7a, 0x90, 0xc2, 0xf5, 0x50, 0x80, 0xd1, - 0x06, 0x36, 0xb1, 0xad, 0xdb, 0x2c, 0x66, 0x63, 0x7b, 0xe7, 0x14, 0x57, 0x80, 0x6e, 0xc0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x99, 0x04, - 0x7f, 0x8b, 0x3d, 0x54, 0xd1, 0xdf, 0x87, 0x88, 0x70, 0xd4, 0x31, 0x5c, 0xb8, 0xf9, 0x7a, 0x87, - 0xda, 0x80, 0xdd, 0x35, 0xc0, 0x3d, 0x74, 0xfa, 0xed, 0xec, 0xfe, 0xf4, 0x62, 0x49, 0xfa, 0xf9, - 0xc5, 0x92, 0xf4, 0xdb, 0x8b, 0x25, 0xe9, 0xfd, 0x9b, 0x81, 0xbf, 0x2c, 0xac, 0xf6, 0x89, 0xdd, - 0x52, 0xa9, 0xae, 0x19, 0x6a, 0xcd, 0xe6, 0x5f, 0x95, 0xde, 0xbf, 0x06, 0xfe, 0x89, 0x69, 0xb3, - 0x36, 0xc2, 0xe4, 0xd7, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x25, 0xd4, 0x3e, 0x2e, 0x30, 0x19, - 0x00, 0x00, + // 1728 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xcd, 0x6f, 0xdb, 0x46, + 0x16, 0x0f, 0xf5, 0x61, 0x5b, 0xcf, 0x96, 0x3f, 0xc6, 0x72, 0xa2, 0x95, 0xbf, 0x64, 0x3a, 0x76, + 0x14, 0x38, 0x91, 0x62, 0xe7, 0x63, 0x17, 0x59, 0x2c, 0xb2, 0xb6, 0x91, 0x8d, 0xb3, 0x1b, 0x2c, + 0x5c, 0x3a, 0xed, 0xa1, 0x17, 0x81, 0xa2, 0xc6, 0x12, 0x63, 0x8a, 0xc3, 0x88, 0x23, 0x23, 0xf6, + 0xad, 0x3d, 0x14, 0xe8, 0xb9, 0x40, 0xdb, 0x53, 0xdb, 0x6b, 0x10, 0xf4, 0xda, 0x4b, 0x80, 0xb6, + 0xe8, 0xa9, 0xc7, 0x02, 0x05, 0x7a, 0x0c, 0x8a, 0xa0, 0x40, 0x4f, 0x3d, 0x34, 0x7f, 0x41, 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, 0xc9, 0x3f, + 0x49, 0x30, 0xe3, 0x70, 0x65, 0x91, 0xf1, 0xe2, 0x98, 0x83, 0x54, 0x28, 0x78, 0xec, 0xc9, 0x91, + 0xda, 0x06, 0xa1, 0x5e, 0xac, 0xd8, 0x13, 0x3a, 0x0f, 0x69, 0xee, 0xfa, 0xa4, 0x10, 0xf3, 0x47, + 0xb4, 0x09, 0x39, 0xdd, 0xd4, 0x8c, 0x4e, 0x1d, 0x57, 0x4d, 0x62, 0x6a, 0xaa, 0x49, 0x4c, 0x5d, + 0x53, 0x0d, 0x16, 0xa1, 0x31, 0x65, 0x56, 0xac, 0xfd, 0x3f, 0xb0, 0x14, 0x0e, 0x42, 0xba, 0x6f, + 0x10, 0x46, 0x06, 0x05, 0xe1, 0x13, 0x09, 0x50, 0x70, 0x63, 0xc2, 0xfd, 0xb7, 0x61, 0x84, 0x25, + 0xe7, 0x20, 0xc7, 0xef, 0xb0, 0xe2, 0xe0, 0xf9, 0x2a, 0xde, 0x38, 0x2b, 0x97, 0x7f, 0x97, 0x84, + 0xcc, 0xae, 0x73, 0x84, 0xec, 0x61, 0xb5, 0x8e, 0xae, 0x01, 0x74, 0x57, 0xcb, 0xce, 0xcc, 0xab, + 0x17, 0xcb, 0x59, 0xdb, 0x3e, 0xbd, 0xea, 0x00, 0xdc, 0x96, 0xaf, 0x6f, 0xc9, 0x4a, 0xa6, 0xe6, + 0x95, 0xce, 0xa2, 0xfb, 0x86, 0x1f, 0x0c, 0xb1, 0x7c, 0xe0, 0xc4, 0x63, 0x0d, 0x26, 0x0f, 0x75, + 0x53, 0x35, 0xf4, 0x53, 0x5c, 0xe7, 0x2a, 0x2c, 0x30, 0x4a, 0xd6, 0x93, 0x32, 0xb5, 0x5d, 0xc8, + 0xf9, 0x6a, 0x01, 0x06, 0xa9, 0x38, 0x06, 0xc8, 0x53, 0xf7, 0xab, 0x78, 0x0d, 0x26, 0x1f, 0x75, + 0x6c, 0xaa, 0x1f, 0xea, 0xae, 0xad,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, 0xd5, 0xa0, 0x17, 0xb7, 0xd9, 0x91, 0x70, 0x80, 0xe9, 0x6e, 0x53, 0x35, 0x1b, 0x6f, + 0x54, 0x6b, 0x3d, 0x8e, 0xf9, 0x3a, 0x01, 0xd3, 0xdd, 0xf8, 0x31, 0xee, 0xb9, 0x07, 0x73, 0xec, + 0x70, 0x52, 0x29, 0xae, 0x57, 0x83, 0x05, 0x9b, 0x88, 0x2f, 0xd8, 0x59, 0xef, 0x8d, 0x7d, 0xbf, + 0x72, 0xb7, 0x01, 0xe1, 0x27, 0x7a, 0x37, 0x4a, 0x9f, 0xb2, 0x9f, 0xe6, 0xea, 0x01, 0x88, 0x5d, + 0x98, 0xb5, 0x0d, 0xd5, 0x6e, 0x76, 0x61, 0xa4, 0xe2, 0x31, 0x66, 0x84, 0x7e, 0x18, 0x04, 0x3f, + 0xc2, 0x5a, 0x37, 0x91, 0x74, 0x1f, 0x10, 0xa1, 0xef, 0x83, 0xc8, 0xcf, 0x25, 0x98, 0xf4, 0x22, + 0xf5, 0x56, 0x07, 0x77, 0x30, 0x5a, 0x86, 0x71, 0xad, 0xd9, 0x69, 0x9b, 0x55, 0x43, 0x6f, 0xe9, + 0x54, 0x38, 0x11, 0x98, 0xe8, 0x81, 0x23, 0x41, 0xf7, 0xc5, 0x25, 0xc0, 0xda, 0xd5, 0x61, 0x5d, + 0x99, 0xf3, 0x5f, 0x09, 0xec, 0xe1, 0x5f, 0xc0, 0x9c, 0x33, 0xac, 0x27, 0x27, 0x1d, 0xe5, 0x00, + 0xfb, 0xdf, 0x25, 0x58, 0x76, 0xae, 0x6a, 0x3f, 0xd7, 0x6c, 0x5b, 0x6f, 0x98, 0x2d, 0x6c, 0xd2, + 0xbf, 0xec, 0x91, 0xfe, 0x6d, 0x12, 0x72, 0x51, 0xfb, 0x8d, 0x49, 0x7b, 0x15, 0xc6, 0x55, 0x5f, + 0x49, 0x1c, 0x0b, 0x77, 0x06, 0x1d, 0x0b, 0x01, 0x5c, 0xbf,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xc8, 0xa0, 0xaf, 0x24, 0x58, 0xe8, 0xd7, 0x90, 0xa2, 0xdb, 0x43, + 0x50, 0x8a, 0xe9, 0x62, 0x63, 0xa3, 0xda, 0xad, 0x2f, 0x6f, 0x32, 0x9e, 0x1b, 0xe8, 0x72, 0xac, + 0xd3, 0xf8, 0xec, 0x6c, 0x63, 0xaa, 0x09, 0x5e, 0xa7, 0x30, 0x13, 0xa4, 0xc0, 0xdb, 0xb3, 0xb8, + 0x7c, 0x5f, 0x1b, 0xe4, 0x2a, 0xf6, 0x7a, 0x5c, 0xd2, 0x07, 0x68, 0x3c, 0x66, 0x66, 0xbe, 0x14, + 0x5f, 0x3a, 0x23, 0x5b, 0x8d, 0x5b, 0x7d, 0x12, 0xbf, 0x4f, 0x2f, 0x56, 0xd8, 0x78, 0x8d, 0xbe, + 0x43, 0xbe, 0xc2, 0x98, 0xae, 0xa3, 0x8b, 0xf1, 0x0e, 0x0b, 0x50, 0x7a, 0x2e, 0xc1, 0xdf, 0x62, + 0x2f, 0x55, 0xf4, 0xf7, 0x21, 0x22, 0x1c, 0x75, 0x0d, 0x17, 0x6e, 0xbe, 0xde, 0xa5, 0x36, 0xe0, + 0x74, 0x0d, 0x70, 0x0f, 0xdd, 0x7e, 0x3b, 0xbb, 0xdf, 0xbf, 0x5c, 0x92, 0x7e, 0x78, 0xb9, 0x24, + 0xfd, 0xfc, 0x72, 0x49, 0x7a, 0xf7, 0x66, 0xe0, 0x2f, 0x06, 0xab, 0x7d, 0x62, 0xb7, 0x54, 0xaa, + 0x6b, 0x86, 0x5a, 0xb3, 0xf9, 0x53, 0xa5, 0xf7, 0x53, 0xfe, 0x3f, 0x31, 0x6d, 0xd6, 0x46, 0x98, + 0xfc, 0xfa, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0xd8, 0xd2, 0xbb, 0xe0, 0x18, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3311,38 +3294,13 @@ func (m *ListCommitteesRequest) MarshalTo(dAtA []byte) (int, error) { } i += nn3 } - if len(m.PublicKeys) > 0 { - for _, b := range m.PublicKeys { - dAtA[i] = 0x1a - i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) - } - } - if len(m.Indices) > 0 { - dAtA5 := make([]byte, len(m.Indices)*10) - var j4 int - for _, num := range m.Indices { - for num >= 1<<7 { - dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j4++ - } - dAtA5[j4] = uint8(num) - j4++ - } - dAtA[i] = 0x22 - i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j4)) - i += copy(dAtA[i:], dAtA5[:j4]) - } if m.PageSize != 0 { - dAtA[i] = 0x28 + dAtA[i] = 0x18 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.PageSize)) } if len(m.PageToken) > 0 { - dAtA[i] = 0x32 + dAtA[i] = 0x22 i++ i = encodeVarintBeaconChain(dAtA, i, uint64(len(m.PageToken))) i += copy(dAtA[i:], m.PageToken) @@ -3442,21 +3400,21 @@ func (m *BeaconCommittees_CommitteeItem) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if len(m.Committee) > 0 { - dAtA7 := make([]byte, len(m.Committee)*10) - var j6 int + dAtA5 := make([]byte, len(m.Committee)*10) + var j4 int for _, num := range m.Committee { for num >= 1<<7 { - dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j6++ + j4++ } - dAtA7[j6] = uint8(num) - j6++ + dAtA5[j4] = uint8(num) + j4++ } dAtA[i] = 0xa i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j6)) - i += copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j4)) + i += copy(dAtA[i:], dAtA5[:j4]) } if m.Slot != 0 { dAtA[i] = 0x10 @@ -3485,11 +3443,11 @@ func (m *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn8, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn6, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn8 + i += nn6 } if len(m.PublicKeys) > 0 { for _, b := range m.PublicKeys { @@ -3500,21 +3458,21 @@ func (m *GetValidatorBalancesRequest) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Indices) > 0 { - dAtA10 := make([]byte, len(m.Indices)*10) - var j9 int + dAtA8 := make([]byte, len(m.Indices)*10) + var j7 int for _, num := range m.Indices { for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j9++ + j7++ } - dAtA10[j9] = uint8(num) - j9++ + dAtA8[j7] = uint8(num) + j7++ } dAtA[i] = 0x22 i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j9)) - i += copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j7)) + i += copy(dAtA[i:], dAtA8[:j7]) } if m.PageSize != 0 { dAtA[i] = 0x28 @@ -3654,11 +3612,11 @@ func (m *GetValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn11, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn9, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn11 + i += nn9 } if m.PageSize != 0 { dAtA[i] = 0x18 @@ -3761,11 +3719,11 @@ func (m *GetValidatorActiveSetChangesRequest) MarshalTo(dAtA []byte) (int, error var l int _ = l if m.QueryFilter != nil { - nn12, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn10, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn12 + i += nn10 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -3908,11 +3866,11 @@ func (m *ListValidatorAssignmentsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn13, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn11, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn13 + i += nn11 } if len(m.PublicKeys) > 0 { for _, b := range m.PublicKeys { @@ -3923,21 +3881,21 @@ func (m *ListValidatorAssignmentsRequest) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Indices) > 0 { - dAtA15 := make([]byte, len(m.Indices)*10) - var j14 int + dAtA13 := make([]byte, len(m.Indices)*10) + var j12 int for _, num := range m.Indices { for num >= 1<<7 { - dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j14++ + j12++ } - dAtA15[j14] = uint8(num) - j14++ + dAtA13[j12] = uint8(num) + j12++ } dAtA[i] = 0x22 i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j14)) - i += copy(dAtA[i:], dAtA15[:j14]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j12)) + i += copy(dAtA[i:], dAtA13[:j12]) } if m.PageSize != 0 { dAtA[i] = 0x28 @@ -4040,21 +3998,21 @@ func (m *ValidatorAssignments_CommitteeAssignment) MarshalTo(dAtA []byte) (int, var l int _ = l if len(m.BeaconCommittees) > 0 { - dAtA17 := make([]byte, len(m.BeaconCommittees)*10) - var j16 int + dAtA15 := make([]byte, len(m.BeaconCommittees)*10) + var j14 int for _, num := range m.BeaconCommittees { for num >= 1<<7 { - dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j16++ + j14++ } - dAtA17[j16] = uint8(num) - j16++ + dAtA15[j14] = uint8(num) + j14++ } dAtA[i] = 0xa i++ - i = encodeVarintBeaconChain(dAtA, i, uint64(j16)) - i += copy(dAtA[i:], dAtA17[:j16]) + i = encodeVarintBeaconChain(dAtA, i, uint64(j14)) + i += copy(dAtA[i:], dAtA15[:j14]) } if m.CommitteeIndex != 0 { dAtA[i] = 0x10 @@ -4099,11 +4057,11 @@ func (m *GetValidatorParticipationRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.QueryFilter != nil { - nn18, err := m.QueryFilter.MarshalTo(dAtA[i:]) + nn16, err := m.QueryFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn18 + i += nn16 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -4164,11 +4122,11 @@ func (m *ValidatorParticipationResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintBeaconChain(dAtA, i, uint64(m.Participation.Size())) - n19, err := m.Participation.MarshalTo(dAtA[i:]) + n17, err := m.Participation.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n17 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -4448,19 +4406,6 @@ func (m *ListCommitteesRequest) Size() (n int) { if m.QueryFilter != nil { n += m.QueryFilter.Size() } - if len(m.PublicKeys) > 0 { - for _, b := range m.PublicKeys { - l = len(b) - n += 1 + l + sovBeaconChain(uint64(l)) - } - } - if len(m.Indices) > 0 { - l = 0 - for _, e := range m.Indices { - l += sovBeaconChain(uint64(e)) - } - n += 1 + sovBeaconChain(uint64(l)) + l - } if m.PageSize != 0 { n += 1 + sovBeaconChain(uint64(m.PageSize)) } @@ -6071,114 +6016,6 @@ func (m *ListCommitteesRequest) Unmarshal(dAtA []byte) error { b := bool(v != 0) m.QueryFilter = &ListCommitteesRequest_Genesis{b} case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublicKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconChain - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBeaconChain - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBeaconChain - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PublicKeys = append(m.PublicKeys, make([]byte, postIndex-iNdEx)) - copy(m.PublicKeys[len(m.PublicKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconChain - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Indices = append(m.Indices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconChain - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthBeaconChain - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthBeaconChain - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Indices) == 0 { - m.Indices = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBeaconChain - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Indices = append(m.Indices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Indices", wireType) - } - case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PageSize", wireType) } @@ -6197,7 +6034,7 @@ func (m *ListCommitteesRequest) Unmarshal(dAtA []byte) error { break } } - case 6: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PageToken", wireType) } diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index adbac8e516d8..cacf0a131fb1 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -256,22 +256,15 @@ message ListCommitteesRequest { // Optional criteria to retrieve genesis data. bool genesis = 2; } - // Validator 48 byte BLS public keys to filter validator indices for the given - // epoch. This field is optional. - repeated bytes public_keys = 3 [(gogoproto.moretags) = "ssz-size:\"?,48\""]; - - // Validator indices to filter validator indices for the given epoch. - // This field is optional. - repeated uint64 indices = 4; // The maximum number of Validators to return in the response. // This field is optional. - int32 page_size = 5; + int32 page_size = 3; // A pagination token returned from a previous call to `GetValidators` // that indicates where this listing should continue from. // This field is optional. - string page_token = 6; + string page_token = 4; } message BeaconCommittees { @@ -288,7 +281,6 @@ message BeaconCommittees { // A list of committees of validators for given epoch. repeated CommitteeItem committees = 2; - // The number of active validators at the given epoch. uint64 active_validator_count = 3; @@ -311,7 +303,7 @@ message GetValidatorBalancesRequest { // Validator 48 byte BLS public keys to filter validators for the given // epoch. repeated bytes public_keys = 3 [(gogoproto.moretags) = "ssz-size:\"?,48\""]; - + // Validator indices to filter validators for the given epoch. repeated uint64 indices = 4; From 0bf626658e4587d16b7fdab9002df1e32e0222bf Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 15:01:57 -0600 Subject: [PATCH 78/82] comments --- beacon-chain/rpc/beacon/committees.go | 3 +-- proto/eth/v1alpha1/beacon_chain.proto | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 1a420ec43129..7676460fee7d 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -14,8 +14,7 @@ import ( // ListBeaconCommittees for a given epoch. // -// This request may specify validator indices or public keys to filter out -// validator beacon chain committees. If no filter criteria is specified, the response returns +// If no filter criteria is specified, the response returns // all beacon committees for the current epoch. The results are paginated by default. func (bs *Server) ListBeaconCommittees( ctx context.Context, diff --git a/proto/eth/v1alpha1/beacon_chain.proto b/proto/eth/v1alpha1/beacon_chain.proto index cacf0a131fb1..67a3128d2c1b 100644 --- a/proto/eth/v1alpha1/beacon_chain.proto +++ b/proto/eth/v1alpha1/beacon_chain.proto @@ -71,8 +71,7 @@ service BeaconChain { // Retrieve the beacon chain committees for a given epoch. // - // This request may specify validator indices or public keys to filter out - // validator beacon chain committees. If no filter criteria is specified, the response returns + // If no filter criteria is specified, the response returns // all beacon committees for the current epoch. The results are paginated by default. rpc ListBeaconCommittees(ListCommitteesRequest) returns (BeaconCommittees) { option (google.api.http) = { From fc979b697aab6b3669a036fdf22c5245be34921e Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 15:02:14 -0600 Subject: [PATCH 79/82] Update beacon-chain/archiver/service.go --- beacon-chain/archiver/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/archiver/service.go b/beacon-chain/archiver/service.go index 35823d3079d0..e793922a9d2d 100644 --- a/beacon-chain/archiver/service.go +++ b/beacon-chain/archiver/service.go @@ -157,7 +157,7 @@ func (s *Service) run(ctx context.Context) { log.WithField( "epoch", helpers.CurrentEpoch(headState), - ).Info("Successfully archived beacon chain data during epoch") + ).Debug("Successfully archived beacon chain data during epoch") case <-s.ctx.Done(): log.Debug("Context closed, exiting goroutine") return From 37f9b748ab3d5b0ac9e6d9dbd7a642317a54e494 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 15:02:31 -0600 Subject: [PATCH 80/82] Update beacon-chain/rpc/beacon/committees.go --- beacon-chain/rpc/beacon/committees.go | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 7676460fee7d..3cf58ab0cd73 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -102,7 +102,6 @@ func (bs *Server) ListBeaconCommittees( ) } - // If current epoch, compute. Otherwise, fetch from archive. committees := make([]*ethpb.BeaconCommittees_CommitteeItem, 0) for slot := startSlot; slot < startSlot+params.BeaconConfig().SlotsPerEpoch; slot++ { var countAtSlot = uint64(len(activeIndices)) / params.BeaconConfig().SlotsPerEpoch / params.BeaconConfig().TargetCommitteeSize From 3ead96011970c516eb4978b5b64589ca0e068004 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 15:13:31 -0600 Subject: [PATCH 81/82] elim bad test --- beacon-chain/rpc/service_test.go | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/beacon-chain/rpc/service_test.go b/beacon-chain/rpc/service_test.go index ae20d8cd8739..56933f431786 100644 --- a/beacon-chain/rpc/service_test.go +++ b/beacon-chain/rpc/service_test.go @@ -42,30 +42,6 @@ func TestLifecycle_OK(t *testing.T) { } -func TestRPC_BadEndpoint(t *testing.T) { - hook := logTest.NewGlobal() - - rpcService := NewService(context.Background(), &Config{ - Port: "ralph merkle!!!", - SyncService: &mockSync.Sync{IsSyncing: false}, - BlockReceiver: &mock.ChainService{}, - AttestationReceiver: &mock.ChainService{}, - HeadFetcher: &mock.ChainService{}, - POWChainService: &mockPOW.POWChain{}, - StateFeedListener: &mock.ChainService{}, - }) - - testutil.AssertLogsDoNotContain(t, hook, "Could not listen to port in Start()") - testutil.AssertLogsDoNotContain(t, hook, "Could not load TLS keys") - testutil.AssertLogsDoNotContain(t, hook, "Could not serve gRPC") - - rpcService.Start() - - testutil.AssertLogsContain(t, hook, "Could not listen to port in Start()") - - rpcService.Stop() -} - func TestStatus_CredentialError(t *testing.T) { credentialErr := errors.New("credentialError") s := &Service{credentialError: credentialErr} From fc526b066ede01cdc721ae90461b42a8140c8e85 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 12 Nov 2019 23:13:52 -0600 Subject: [PATCH 82/82] preston feedback --- beacon-chain/rpc/beacon/committees.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon-chain/rpc/beacon/committees.go b/beacon-chain/rpc/beacon/committees.go index 3cf58ab0cd73..74ecd903a807 100644 --- a/beacon-chain/rpc/beacon/committees.go +++ b/beacon-chain/rpc/beacon/committees.go @@ -44,6 +44,8 @@ func (bs *Server) ListBeaconCommittees( var attesterSeed [32]byte var activeIndices []uint64 var err error + // This is the archival condition, if the requested epoch is < current epoch or if we are + // requesting data from the genesis epoch. if requestingGenesis || helpers.SlotToEpoch(startSlot) < helpers.SlotToEpoch(headState.Slot) { activeIndices, err = helpers.ActiveValidatorIndices(headState, helpers.SlotToEpoch(startSlot)) if err != nil {