From 012d279663b3ffb5e3854dc3f47b89c61931e97e Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 29 Jul 2021 14:45:17 -0700 Subject: [PATCH] Fix duplicated imports (#9304) * Fix duplicated imports * Fix metrics test --- beacon-chain/blockchain/head_test.go | 7 +- beacon-chain/blockchain/metrics_test.go | 5 +- .../blockchain/process_attestation_test.go | 9 ++- beacon-chain/blockchain/process_block.go | 3 +- beacon-chain/blockchain/process_block_test.go | 17 +++-- beacon-chain/blockchain/service_test.go | 14 ++-- beacon-chain/cache/checkpoint_state_test.go | 7 +- beacon-chain/cache/skip_slot_cache_test.go | 4 +- beacon-chain/core/altair/deposit_test.go | 21 +++--- beacon-chain/core/blocks/attestation.go | 3 +- .../blocks/attestation_regression_test.go | 5 +- beacon-chain/core/blocks/attestation_test.go | 31 ++++---- .../core/blocks/attester_slashing_test.go | 5 +- .../core/blocks/block_operations_fuzz_test.go | 45 ++++++------ beacon-chain/core/blocks/deposit.go | 3 +- beacon-chain/core/blocks/deposit_test.go | 25 ++++--- beacon-chain/core/blocks/eth1_data_test.go | 5 +- beacon-chain/core/blocks/exit.go | 3 +- beacon-chain/core/blocks/exit_test.go | 9 ++- .../proposer_slashing_regression_test.go | 3 +- .../core/blocks/proposer_slashing_test.go | 3 +- beacon-chain/core/blocks/randao_test.go | 3 +- beacon-chain/core/epoch/epoch_processing.go | 7 +- .../core/epoch/epoch_processing_fuzz_test.go | 4 +- .../core/epoch/epoch_processing_test.go | 42 +++++------ .../core/epoch/precompute/attestation.go | 12 ++-- .../core/epoch/precompute/attestation_test.go | 21 +++--- .../justification_finalization_test.go | 7 +- .../core/epoch/precompute/new_test.go | 3 +- .../epoch/precompute/reward_penalty_test.go | 25 ++++--- .../core/epoch/precompute/slashing_test.go | 15 ++-- beacon-chain/core/helpers/attestation_test.go | 3 +- beacon-chain/core/helpers/block_test.go | 6 +- beacon-chain/core/helpers/randao_test.go | 8 +-- beacon-chain/core/helpers/signing_root.go | 5 +- .../core/helpers/signing_root_test.go | 4 +- beacon-chain/core/helpers/slot_epoch_test.go | 8 +-- beacon-chain/core/helpers/validators.go | 3 +- beacon-chain/core/state/benchmarks_test.go | 6 +- beacon-chain/core/state/state.go | 17 +++-- .../stateutils/validator_index_map_test.go | 3 +- beacon-chain/db/iface/interface.go | 8 +-- beacon-chain/db/kafka/passthrough.go | 8 +-- beacon-chain/db/kv/encoding.go | 3 +- beacon-chain/db/kv/genesis.go | 8 +-- .../db/kv/migration_state_validators.go | 4 +- beacon-chain/db/kv/state_summary.go | 12 ++-- beacon-chain/db/kv/state_summary_cache.go | 16 ++--- beacon-chain/db/kv/state_summary_test.go | 14 ++-- beacon-chain/interop-cold-start/service.go | 3 +- .../operations/voluntaryexits/service_test.go | 5 +- .../p2p/gossip_scoring_params_test.go | 3 +- beacon-chain/p2p/sender_test.go | 10 +-- .../v1alpha1/beacon/attestations_test.go | 11 ++- .../prysm/v1alpha1/beacon/committees_test.go | 3 +- .../v1alpha1/validator/aggregator_test.go | 5 +- .../prysm/v1alpha1/validator/server_test.go | 13 ++-- .../prysm/v1alpha1/validator/status_test.go | 29 ++++---- beacon-chain/state/genesis/genesis.go | 4 +- beacon-chain/state/phase0.go | 21 +++--- beacon-chain/state/stategen/getter.go | 10 +-- beacon-chain/state/stategen/getter_test.go | 22 +++--- .../state/stategen/hot_state_cache_test.go | 4 +- beacon-chain/state/stategen/migrate_test.go | 6 +- beacon-chain/state/stategen/service.go | 4 +- beacon-chain/state/stategen/setter.go | 4 +- .../stateutil/pending_attestation_root.go | 5 +- .../state/stateutil/state_root_test.go | 5 +- beacon-chain/state/v1/field_roots.go | 6 +- beacon-chain/state/v1/field_trie_helpers.go | 9 ++- beacon-chain/state/v1/getters_attestation.go | 14 ++-- .../state/v1/getters_attestation_test.go | 18 ++--- beacon-chain/state/v1/getters_block_test.go | 14 ++-- beacon-chain/state/v1/getters_misc.go | 8 +-- beacon-chain/state/v1/getters_state.go | 13 ++-- beacon-chain/state/v1/getters_test.go | 12 ++-- .../state/v1/getters_validator_test.go | 4 +- beacon-chain/state/v1/helpers_test.go | 3 +- beacon-chain/state/v1/references_test.go | 23 +++--- beacon-chain/state/v1/setters_attestation.go | 16 ++--- .../state/v1/setters_attestation_test.go | 14 ++-- beacon-chain/state/v1/setters_misc.go | 6 +- beacon-chain/state/v1/state_test.go | 5 +- beacon-chain/state/v1/state_trie.go | 10 +-- beacon-chain/state/v1/state_trie_test.go | 22 +++--- beacon-chain/state/v1/types.go | 4 +- beacon-chain/state/v1/types_test.go | 13 ++-- beacon-chain/state/v1/unsupported_getters.go | 6 +- beacon-chain/state/v1/unsupported_setters.go | 6 +- beacon-chain/state/v2/deprecated_getters.go | 6 +- beacon-chain/state/v2/deprecated_setters.go | 10 +-- .../state/v2/field_root_sync_committee.go | 4 +- beacon-chain/state/v2/field_roots.go | 6 +- beacon-chain/state/v2/getters.go | 25 ++++--- beacon-chain/state/v2/getters_test.go | 4 +- beacon-chain/state/v2/setters.go | 9 ++- beacon-chain/state/v2/state_trie.go | 11 ++- beacon-chain/state/v2/state_trie_test.go | 15 ++-- beacon-chain/state/v2/types.go | 4 +- beacon-chain/sync/rpc_test.go | 8 +-- fuzz/rpc_status_fuzz.go | 3 +- fuzz/state_fuzz.go | 6 +- fuzz/testing/beacon_fuzz_states.go | 6 +- .../v1alpha1/wrapper/beacon_block_test.go | 70 +++++++++---------- .../sync_contribution/naive_test.go | 32 ++++----- shared/aggregation/testing/bitlistutils.go | 7 +- shared/benchutil/pregen.go | 5 +- shared/copyutil/cloners.go | 25 ++++--- shared/copyutil/cloners_test.go | 25 ++++--- shared/depositutil/deposit.go | 9 ++- shared/depositutil/deposit_test.go | 6 +- shared/interop/generate_genesis_state.go | 9 ++- shared/testutil/altair.go | 40 +++++------ shared/testutil/block.go | 13 ++-- shared/testutil/deposits.go | 9 ++- shared/testutil/state.go | 13 ++-- shared/testutil/state_test.go | 4 +- shared/testutil/sync_aggregate.go | 13 ++-- .../shared/phase0/epoch_processing/helpers.go | 6 +- spectest/shared/phase0/finality/runner.go | 5 +- .../shared/phase0/operations/block_header.go | 5 +- spectest/shared/phase0/operations/helpers.go | 5 +- .../phase0/rewards/rewards_penalties.go | 4 +- .../shared/phase0/sanity/block_processing.go | 5 +- .../shared/phase0/sanity/slot_processing.go | 6 +- .../shared/phase0/ssz_static/ssz_static.go | 19 +++-- tools/benchmark-files-gen/main.go | 3 +- tools/exploredb/main.go | 3 +- tools/genesis-state-gen/main.go | 5 +- tools/pcli/main.go | 9 ++- 130 files changed, 644 insertions(+), 723 deletions(-) diff --git a/beacon-chain/blockchain/head_test.go b/beacon-chain/blockchain/head_test.go index ac0797a443..844fa1b551 100644 --- a/beacon-chain/blockchain/head_test.go +++ b/beacon-chain/blockchain/head_test.go @@ -11,7 +11,6 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -60,7 +59,7 @@ func TestSaveHead_Different(t *testing.T) { headState, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, headState.SetSlot(1)) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), ðpb.StateSummary{Slot: 1, Root: newRoot[:]})) require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), headState, newRoot)) require.NoError(t, service.saveHead(context.Background(), newRoot)) @@ -105,7 +104,7 @@ func TestSaveHead_Different_Reorg(t *testing.T) { headState, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, headState.SetSlot(1)) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), ðpb.StateSummary{Slot: 1, Root: newRoot[:]})) require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), headState, newRoot)) require.NoError(t, service.saveHead(context.Background(), newRoot)) @@ -127,7 +126,7 @@ func TestCacheJustifiedStateBalances_CanCache(t *testing.T) { state, _ := testutil.DeterministicGenesisState(t, 100) r := [32]byte{'a'} - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Root: r[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), ðpb.StateSummary{Root: r[:]})) require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), state, r)) require.NoError(t, service.cacheJustifiedStateBalances(context.Background(), r)) require.DeepEqual(t, service.getJustifiedBalances(), state.Balances(), "Incorrect justified balances") diff --git a/beacon-chain/blockchain/metrics_test.go b/beacon-chain/blockchain/metrics_test.go index e625a27b20..dda5f8272d 100644 --- a/beacon-chain/blockchain/metrics_test.go +++ b/beacon-chain/blockchain/metrics_test.go @@ -5,7 +5,6 @@ import ( "testing" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -25,7 +24,7 @@ func TestReportEpochMetrics_BadAttestation(t *testing.T) { require.NoError(t, err) h, err := testutil.NewBeaconState() require.NoError(t, err) - require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 0})) + require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 0})) err = reportEpochMetrics(context.Background(), s, h) require.ErrorContains(t, "attestation with inclusion delay of 0", err) } @@ -36,7 +35,7 @@ func TestReportEpochMetrics_SlashedValidatorOutOfBound(t *testing.T) { require.NoError(t, err) v.Slashed = true require.NoError(t, h.UpdateValidatorAtIndex(0, v)) - require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(ð.AttestationData{})})) + require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(ð.AttestationData{})})) err = reportEpochMetrics(context.Background(), h, h) require.ErrorContains(t, "slot 0 out of bounds", err) } diff --git a/beacon-chain/blockchain/process_attestation_test.go b/beacon-chain/blockchain/process_attestation_test.go index de23601004..599e2d2dec 100644 --- a/beacon-chain/blockchain/process_attestation_test.go +++ b/beacon-chain/blockchain/process_attestation_test.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -61,7 +60,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) { require.NoError(t, err) s, err = testutil.NewBeaconState() require.NoError(t, err) - err = s.SetFork(&statepb.Fork{ + err = s.SetFork(ðpb.Fork{ Epoch: 0, CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -186,7 +185,7 @@ func TestStore_SaveCheckpointState(t *testing.T) { r = bytesutil.ToBytes32([]byte{'A'}) cp1 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)} require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'A'}))) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)})) s1, err := service.getAttPreState(ctx, cp1) require.NoError(t, err) @@ -194,7 +193,7 @@ func TestStore_SaveCheckpointState(t *testing.T) { cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)} require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'B'}))) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)})) s2, err := service.getAttPreState(ctx, cp2) require.NoError(t, err) assert.Equal(t, 2*params.BeaconConfig().SlotsPerEpoch, s2.Slot(), "Unexpected state slot") @@ -218,7 +217,7 @@ func TestStore_SaveCheckpointState(t *testing.T) { service.prevFinalizedCheckpt = ðpb.Checkpoint{Root: r[:]} cp3 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'C'}, 32)} require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'C'}))) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)})) s3, err := service.getAttPreState(ctx, cp3) require.NoError(t, err) assert.Equal(t, s.Slot(), s3.Slot(), "Unexpected state slot") diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index bc941c3c89..571ef53f9f 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -279,7 +278,7 @@ func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed block. if err := s.insertBlockToForkChoiceStore(ctx, b, blockRoot, fCheckpoint, jCheckpoint); err != nil { return err } - if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{ + if err := s.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{ Slot: signed.Block().Slot(), Root: blockRoot[:], }); err != nil { diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index fd1d120546..8d76b0f5d9 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -21,7 +21,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/attestationutil" @@ -60,10 +59,10 @@ func TestStore_OnBlock(t *testing.T) { assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(random))) randomParentRoot, err := random.Block.HashTreeRoot() assert.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]})) require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), randomParentRoot)) randomParentRoot2 := roots[1] - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2})) require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), bytesutil.ToBytes32(randomParentRoot2))) tests := []struct { @@ -256,7 +255,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) { service, err := NewService(ctx, cfg) require.NoError(t, err) - s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) + s, err := v1.InitializeFromProto(ðpb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) require.NoError(t, err) genesisStateRoot := [32]byte{} @@ -273,7 +272,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 1 b.Block.ParentRoot = gRoot[:] - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 1, Root: gRoot[:]})) require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s)) require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0BeaconBlock(b.Block))) } @@ -308,9 +307,9 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) { assert.ErrorContains(t, wanted, err) b.Block.ParentRoot = gRoot[:] - s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1}) + s, err := v1.InitializeFromProto(ðpb.BeaconState{Slot: 1}) require.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 1, Root: gRoot[:]})) require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s)) require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b).Block())) } @@ -763,7 +762,7 @@ func TestFinalizedImpliesNewJustified(t *testing.T) { service, err := NewService(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})}) require.NoError(t, err) service.justifiedCheckpt = test.args.cachedCheckPoint - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)})) genesisState, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, genesisState, bytesutil.ToBytes32(test.want.Root))) @@ -878,7 +877,7 @@ func TestUpdateJustifiedInitSync(t *testing.T) { require.NoError(t, err) require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(gBlk))) require.NoError(t, service.cfg.BeaconDB.SaveGenesisBlockRoot(ctx, gRoot)) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: gRoot[:]})) beaconState, _ := testutil.DeterministicGenesisState(t, 32) require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, beaconState, gRoot)) service.genesisRoot = gRoot diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index 06541946a2..12068a4acf 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -24,8 +24,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -74,20 +72,20 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service { bState, _ := testutil.DeterministicGenesisState(t, 10) pbState, err := v1.ProtobufBeaconState(bState.InnerStateUnsafe()) require.NoError(t, err) - err = beaconDB.SavePowchainData(ctx, &protodb.ETH1ChainData{ + err = beaconDB.SavePowchainData(ctx, ðpb.ETH1ChainData{ BeaconState: pbState, - Trie: &protodb.SparseMerkleTrie{}, - CurrentEth1Data: &protodb.LatestETH1Data{ + Trie: ðpb.SparseMerkleTrie{}, + CurrentEth1Data: ðpb.LatestETH1Data{ BlockHash: make([]byte, 32), }, - ChainstartData: &protodb.ChainStartData{ + ChainstartData: ðpb.ChainStartData{ Eth1Data: ðpb.Eth1Data{ DepositRoot: make([]byte, 32), DepositCount: 0, BlockHash: make([]byte, 32), }, }, - DepositContainers: []*protodb.DepositContainer{}, + DepositContainers: []*ethpb.DepositContainer{}, }) require.NoError(t, err) web3Service, err = powchain.NewService(ctx, &powchain.Web3ServiceConfig{ @@ -507,7 +505,7 @@ func BenchmarkHasBlockForkChoiceStore(b *testing.B) { block := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}} r, err := block.Block.HashTreeRoot() require.NoError(b, err) - bs := &statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}} + bs := ðpb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}} beaconState, err := v1.InitializeFromProto(bs) require.NoError(b, err) require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState)) diff --git a/beacon-chain/cache/checkpoint_state_test.go b/beacon-chain/cache/checkpoint_state_test.go index 8a0c1f5428..6b34eeafde 100644 --- a/beacon-chain/cache/checkpoint_state_test.go +++ b/beacon-chain/cache/checkpoint_state_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -19,7 +18,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { cache := NewCheckpointStateCache() cp1 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)} - st, err := v1.InitializeFromProto(&statepb.BeaconState{ + st, err := v1.InitializeFromProto(ðpb.BeaconState{ GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:], Slot: 64, }) @@ -43,7 +42,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { } cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)} - st2, err := v1.InitializeFromProto(&statepb.BeaconState{ + st2, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 128, }) require.NoError(t, err) @@ -60,7 +59,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { func TestCheckpointStateCache_MaxSize(t *testing.T) { c := NewCheckpointStateCache() - st, err := v1.InitializeFromProto(&statepb.BeaconState{ + st, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, }) require.NoError(t, err) diff --git a/beacon-chain/cache/skip_slot_cache_test.go b/beacon-chain/cache/skip_slot_cache_test.go index 37c0093e3b..89e11d8086 100644 --- a/beacon-chain/cache/skip_slot_cache_test.go +++ b/beacon-chain/cache/skip_slot_cache_test.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/cache" "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -23,7 +23,7 @@ func TestSkipSlotCache_RoundTrip(t *testing.T) { require.NoError(t, c.MarkInProgress(r)) - s, err = v1.InitializeFromProto(&statepb.BeaconState{ + s, err = v1.InitializeFromProto(ðpb.BeaconState{ Slot: 10, }) require.NoError(t, err) diff --git a/beacon-chain/core/altair/deposit_test.go b/beacon-chain/core/altair/deposit_test.go index cd1e18f0d0..6b6bfbfbca 100644 --- a/beacon-chain/core/altair/deposit_test.go +++ b/beacon-chain/core/altair/deposit_test.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -30,11 +29,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -63,7 +62,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) { require.NoError(t, err, "Could not generate proof") deposit.Proof = proof - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Eth1Data: ðpb.Eth1Data{ DepositRoot: []byte{0}, BlockHash: []byte{1}, @@ -88,11 +87,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -145,7 +144,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T) } balances := []uint64{0, 50} root := depositTrie.Root() - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Validators: registry, Balances: balances, Eth1Data: ðpb.Eth1Data{ @@ -173,11 +172,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -215,11 +214,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{ + beaconState, err := stateAltair.InitializeFromProto(ðpb.BeaconStateAltair{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, diff --git a/beacon-chain/core/blocks/attestation.go b/beacon-chain/core/blocks/attestation.go index ee8269c3f4..6fe5af9002 100644 --- a/beacon-chain/core/blocks/attestation.go +++ b/beacon-chain/core/blocks/attestation.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -205,7 +204,7 @@ func ProcessAttestationNoVerifySignature( if err != nil { return nil, err } - pendingAtt := &statepb.PendingAttestation{ + pendingAtt := ðpb.PendingAttestation{ Data: data, AggregationBits: att.AggregationBits, InclusionDelay: beaconState.Slot() - s, diff --git a/beacon-chain/core/blocks/attestation_regression_test.go b/beacon-chain/core/blocks/attestation_regression_test.go index 92503ea65e..7924fb521d 100644 --- a/beacon-chain/core/blocks/attestation_regression_test.go +++ b/beacon-chain/core/blocks/attestation_regression_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -33,7 +32,7 @@ func TestProcessAttestationNoVerifySignature_BeaconFuzzIssue78(t *testing.T) { if err != nil { t.Fatal(err) } - spb := &statepb.BeaconState{} + spb := ðpb.BeaconState{} if err := spb.UnmarshalSSZ(stateData); err != nil { t.Fatal(err) } @@ -73,7 +72,7 @@ func TestVerifyAttestationNoVerifySignature_IncorrectSourceEpoch(t *testing.T) { ckp := beaconState.CurrentJustifiedCheckpoint() copy(ckp.Root, "hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att) assert.NotEqual(t, nil, err) diff --git a/beacon-chain/core/blocks/attestation_test.go b/beacon-chain/core/blocks/attestation_test.go index 6ed491ffc2..60b088d1bb 100644 --- a/beacon-chain/core/blocks/attestation_test.go +++ b/beacon-chain/core/blocks/attestation_test.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/aggregation" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" @@ -69,7 +68,7 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { pfc := beaconState.PreviousJustifiedCheckpoint() pfc.Root = []byte("hello-world") require.NoError(t, beaconState.SetPreviousJustifiedCheckpoint(pfc)) - require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendPreviousEpochAttestations(ðpb.PendingAttestation{})) want := fmt.Sprintf( "expected target epoch (%d) to be the previous epoch (%d) or the current epoch (%d)", @@ -102,7 +101,7 @@ func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = []byte("hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) want := "source check point not equal to current justified checkpoint" _, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) @@ -140,7 +139,7 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { pfc := beaconState.PreviousJustifiedCheckpoint() pfc.Root = []byte("hello-world") require.NoError(t, beaconState.SetPreviousJustifiedCheckpoint(pfc)) - require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendPreviousEpochAttestations(ðpb.PendingAttestation{})) want := "source check point not equal to previous justified checkpoint" _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) @@ -176,7 +175,7 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = []byte("hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) expected := "failed to verify aggregation bitfield: wanted participants bitfield length 3, got: 4" _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) @@ -201,7 +200,7 @@ func TestProcessAttestations_OK(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) @@ -243,7 +242,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = bytesutil.PadTo([]byte("hello-world"), 32) require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) @@ -306,7 +305,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) @@ -396,7 +395,7 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) { ckp := beaconState.CurrentJustifiedCheckpoint() copy(ckp.Root, "hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) _, err = blocks.ProcessAttestationNoVerifySignature(context.TODO(), beaconState, att) assert.NoError(t, err) @@ -427,7 +426,7 @@ func TestVerifyAttestationNoVerifySignature_OK(t *testing.T) { ckp := beaconState.CurrentJustifiedCheckpoint() copy(ckp.Root, "hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att) assert.NoError(t, err) @@ -453,7 +452,7 @@ func TestVerifyAttestationNoVerifySignature_BadAttIdx(t *testing.T) { ckp := beaconState.CurrentJustifiedCheckpoint() copy(ckp.Root, "hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{})) err := blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att) require.ErrorContains(t, "committee index 100 >= committee count 1", err) } @@ -467,7 +466,7 @@ func TestConvertToIndexed_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 5, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -525,10 +524,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 5, Validators: validators, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ Epoch: 0, CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -676,7 +675,7 @@ func TestVerifyAttestations_HandlesPlannedFork(t *testing.T) { require.NoError(t, err) require.NoError(t, st.SetSlot(35)) require.NoError(t, st.SetValidators(validators)) - require.NoError(t, st.SetFork(&statepb.Fork{ + require.NoError(t, st.SetFork(ðpb.Fork{ Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -803,7 +802,7 @@ func TestRetrieveAttestationSignatureSet_AcrossFork(t *testing.T) { require.NoError(t, err) require.NoError(t, st.SetSlot(5)) require.NoError(t, st.SetValidators(validators)) - require.NoError(t, st.SetFork(&statepb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}})) + require.NoError(t, st.SetFork(ðpb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}})) comm1, err := helpers.BeaconCommitteeFromState(st, 1 /*slot*/, 0 /*committeeIndex*/) require.NoError(t, err) diff --git a/beacon-chain/core/blocks/attester_slashing_test.go b/beacon-chain/core/blocks/attester_slashing_test.go index 4163613329..2132684b97 100644 --- a/beacon-chain/core/blocks/attester_slashing_test.go +++ b/beacon-chain/core/blocks/attester_slashing_test.go @@ -10,7 +10,6 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -47,7 +46,7 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) { var registry []*ethpb.Validator currentSlot := types.Slot(0) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Slot: currentSlot, }) @@ -66,7 +65,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) var registry []*ethpb.Validator currentSlot := types.Slot(0) - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Slot: currentSlot, }) diff --git a/beacon-chain/core/blocks/block_operations_fuzz_test.go b/beacon-chain/core/blocks/block_operations_fuzz_test.go index 6ba4b16366..af14dd1508 100644 --- a/beacon-chain/core/blocks/block_operations_fuzz_test.go +++ b/beacon-chain/core/blocks/block_operations_fuzz_test.go @@ -10,7 +10,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -19,7 +18,7 @@ import ( func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) ctx := context.Background() - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} att := ð.Attestation{} for i := 0; i < 10000; i++ { @@ -34,7 +33,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { func TestFuzzProcessBlockHeader_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} block := ð.SignedBeaconBlock{} for i := 0; i < 10000; i++ { @@ -106,7 +105,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { for i := 0; i < 100000; i++ { fuzzer.Fuzz(eth1data) fuzzer.Fuzz(&stateVotes) - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1DataVotes: stateVotes, }) require.NoError(t, err) @@ -118,7 +117,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} block := ð.BeaconBlock{} for i := 0; i < 10000; i++ { @@ -133,7 +132,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { func TestFuzzProcessRandao_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} b := ð.SignedBeaconBlock{} for i := 0; i < 10000; i++ { @@ -150,7 +149,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) { func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} blockBody := ð.BeaconBlockBody{} for i := 0; i < 10000; i++ { @@ -167,7 +166,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { func TestFuzzProcessProposerSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} p := ð.ProposerSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -184,7 +183,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) { func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} proposerSlashing := ð.ProposerSlashing{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -198,7 +197,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} a := ð.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -215,7 +214,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} attesterSlashing := ð.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -252,7 +251,7 @@ func TestFuzzslashableAttesterIndices_10000(t *testing.T) { func TestFuzzProcessAttestations_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} b := ð.SignedBeaconBlock{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -269,7 +268,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) { func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} b := ð.SignedBeaconBlock{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -286,7 +285,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { func TestFuzzProcessAttestation_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} attestation := ð.Attestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -303,7 +302,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) { func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} idxAttestation := ð.IndexedAttestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -318,7 +317,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { func TestFuzzVerifyAttestation_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} attestation := ð.Attestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -333,7 +332,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) { func TestFuzzProcessDeposits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} deposits := make([]*eth.Deposit, 100) ctx := context.Background() for i := 0; i < 10000; i++ { @@ -352,7 +351,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) { func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} deposit := ð.Deposit{} ctx := context.Background() @@ -370,7 +369,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { func TestFuzzProcessDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} deposit := ð.Deposit{} for i := 0; i < 10000; i++ { @@ -387,7 +386,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) { func TestFuzzverifyDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} deposit := ð.Deposit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -401,7 +400,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) { func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} e := ð.SignedVoluntaryExit{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -418,7 +417,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} e := ð.SignedVoluntaryExit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -437,7 +436,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) { ve := ð.SignedVoluntaryExit{} val, err := v1.NewValidator(ðpb.Validator{}) _ = err - fork := &statepb.Fork{} + fork := ðpb.Fork{} var slot types.Slot for i := 0; i < 10000; i++ { diff --git a/beacon-chain/core/blocks/deposit.go b/beacon-chain/core/blocks/deposit.go index 05e86bb746..b6c5a07b36 100644 --- a/beacon-chain/core/blocks/deposit.go +++ b/beacon-chain/core/blocks/deposit.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/depositutil" @@ -258,7 +257,7 @@ func verifyDepositDataWithDomain(ctx context.Context, deps []*ethpb.Deposit, dom } pks[i] = dpk sigs[i] = dep.Data.Signature - depositMessage := &statepb.DepositMessage{ + depositMessage := ðpb.DepositMessage{ PublicKey: dep.Data.PublicKey, WithdrawalCredentials: dep.Data.WithdrawalCredentials, Amount: dep.Data.Amount, diff --git a/beacon-chain/core/blocks/deposit_test.go b/beacon-chain/core/blocks/deposit_test.go index 91c5f454bf..280fbd7e72 100644 --- a/beacon-chain/core/blocks/deposit_test.go +++ b/beacon-chain/core/blocks/deposit_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -40,11 +39,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -80,7 +79,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) { Deposits: []*ethpb.Deposit{deposit}, }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1Data: ðpb.Eth1Data{ DepositRoot: []byte{0}, BlockHash: []byte{1}, @@ -111,11 +110,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -174,7 +173,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T) } balances := []uint64{0, 50} root := depositTrie.Root() - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: ðpb.Eth1Data{ @@ -202,11 +201,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -244,11 +243,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -299,11 +298,11 @@ func TestPreGenesisDeposits_SkipInvalidDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, diff --git a/beacon-chain/core/blocks/eth1_data_test.go b/beacon-chain/core/blocks/eth1_data_test.go index ffe6010dc6..88ed2bfae5 100644 --- a/beacon-chain/core/blocks/eth1_data_test.go +++ b/beacon-chain/core/blocks/eth1_data_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -71,7 +70,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) { c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength params.OverrideBeaconConfig(c) - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1DataVotes: tt.stateVotes, }) require.NoError(t, err) @@ -161,7 +160,7 @@ func TestAreEth1DataEqual(t *testing.T) { } func TestProcessEth1Data_SetsCorrectly(t *testing.T) { - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Eth1DataVotes: []*ethpb.Eth1Data{}, }) require.NoError(t, err) diff --git a/beacon-chain/core/blocks/exit.go b/beacon-chain/core/blocks/exit.go index b94c05e421..db63ba0ff0 100644 --- a/beacon-chain/core/blocks/exit.go +++ b/beacon-chain/core/blocks/exit.go @@ -10,7 +10,6 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -90,7 +89,7 @@ func ProcessVoluntaryExits( func VerifyExitAndSignature( validator state.ReadOnlyValidator, currentSlot types.Slot, - fork *statepb.Fork, + fork *ethpb.Fork, signed *ethpb.SignedVoluntaryExit, genesisRoot []byte, ) error { diff --git a/beacon-chain/core/blocks/exit_test.go b/beacon-chain/core/blocks/exit_test.go index c4a6a9c715..7c2759bb56 100644 --- a/beacon-chain/core/blocks/exit_test.go +++ b/beacon-chain/core/blocks/exit_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -31,7 +30,7 @@ func TestProcessVoluntaryExits_NotActiveLongEnoughToExit(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, }, } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Slot: 10, }) @@ -61,7 +60,7 @@ func TestProcessVoluntaryExits_ExitAlreadySubmitted(t *testing.T) { ExitEpoch: 10, }, } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Slot: 0, }) @@ -93,9 +92,9 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) { ActivationEpoch: 0, }, } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, diff --git a/beacon-chain/core/blocks/proposer_slashing_regression_test.go b/beacon-chain/core/blocks/proposer_slashing_regression_test.go index 8119953985..d0e2ebb54a 100644 --- a/beacon-chain/core/blocks/proposer_slashing_regression_test.go +++ b/beacon-chain/core/blocks/proposer_slashing_regression_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -19,7 +18,7 @@ import ( func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) { file, err := ioutil.ReadFile("testdata/beaconfuzz_91_beacon.ssz") require.NoError(t, err) - rawState := &statepb.BeaconState{} + rawState := ðpb.BeaconState{} err = rawState.UnmarshalSSZ(file) require.NoError(t, err) diff --git a/beacon-chain/core/blocks/proposer_slashing_test.go b/beacon-chain/core/blocks/proposer_slashing_test.go index 32b87c7068..76b669b4ce 100644 --- a/beacon-chain/core/blocks/proposer_slashing_test.go +++ b/beacon-chain/core/blocks/proposer_slashing_test.go @@ -12,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -118,7 +117,7 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: registry, Slot: currentSlot, }) diff --git a/beacon-chain/core/blocks/randao_test.go b/beacon-chain/core/blocks/randao_test.go index 7e34922c2f..7b5584328a 100644 --- a/beacon-chain/core/blocks/randao_test.go +++ b/beacon-chain/core/blocks/randao_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -27,7 +26,7 @@ func TestProcessRandao_IncorrectProposerFailsVerification(t *testing.T) { binary.LittleEndian.PutUint64(buf, uint64(epoch)) domain, err := helpers.Domain(beaconState.Fork(), epoch, params.BeaconConfig().DomainRandao, beaconState.GenesisValidatorRoot()) require.NoError(t, err) - root, err := (&statepb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot() + root, err := (ðpb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot() require.NoError(t, err) // We make the previous validator's index sign the message instead of the proposer. epochSignature := privKeys[proposerIdx-1].Sign(root[:]) diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 95648d7c61..03438e0eb6 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -14,7 +14,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -56,7 +55,7 @@ func (s sortableIndices) Less(i, j int) bool { // Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei minimum to avoid divisions by zero. // """ // return get_total_balance(state, get_unslashed_attesting_indices(state, attestations)) -func AttestingBalance(state state.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) (uint64, error) { +func AttestingBalance(state state.ReadOnlyBeaconState, atts []*ethpb.PendingAttestation) (uint64, error) { indices, err := UnslashedAttestingIndices(state, atts) if err != nil { return 0, errors.Wrap(err, "could not get attesting indices") @@ -378,7 +377,7 @@ func ProcessHistoricalRootsUpdate(state state.BeaconState) (state.BeaconState, e // Set historical root accumulator. epochsPerHistoricalRoot := params.BeaconConfig().SlotsPerHistoricalRoot.DivSlot(params.BeaconConfig().SlotsPerEpoch) if nextEpoch.Mod(uint64(epochsPerHistoricalRoot)) == 0 { - historicalBatch := &statepb.HistoricalBatch{ + historicalBatch := ðpb.HistoricalBatch{ BlockRoots: state.BlockRoots(), StateRoots: state.StateRoots(), } @@ -461,7 +460,7 @@ func ProcessFinalUpdates(state state.BeaconState) (state.BeaconState, error) { // for a in attestations: // output = output.union(get_attesting_indices(state, a.data, a.aggregation_bits)) // return set(filter(lambda index: not state.validators[index].slashed, output)) -func UnslashedAttestingIndices(state state.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) ([]types.ValidatorIndex, error) { +func UnslashedAttestingIndices(state state.ReadOnlyBeaconState, atts []*ethpb.PendingAttestation) ([]types.ValidatorIndex, error) { var setIndices []types.ValidatorIndex seen := make(map[uint64]bool) diff --git a/beacon-chain/core/epoch/epoch_processing_fuzz_test.go b/beacon-chain/core/epoch/epoch_processing_fuzz_test.go index b4ee66c2e7..6cc4115c67 100644 --- a/beacon-chain/core/epoch/epoch_processing_fuzz_test.go +++ b/beacon-chain/core/epoch/epoch_processing_fuzz_test.go @@ -5,13 +5,13 @@ import ( fuzz "github.com/google/gofuzz" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestFuzzFinalUpdates_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - base := &statepb.BeaconState{} + base := ðpb.BeaconState{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(base) diff --git a/beacon-chain/core/epoch/epoch_processing_test.go b/beacon-chain/core/epoch/epoch_processing_test.go index b15785cac9..de1a9a9334 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -21,9 +20,9 @@ import ( func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { // Generate 2 attestations. - atts := make([]*statepb.PendingAttestation, 2) + atts := make([]*ethpb.PendingAttestation, 2) for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{Source: ðpb.Checkpoint{Root: make([]byte, 32)}, Target: ðpb.Checkpoint{Epoch: 0, Root: make([]byte, 32)}, }, @@ -39,7 +38,7 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } @@ -68,9 +67,9 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { // Generate 5 of the same attestations. - atts := make([]*statepb.PendingAttestation, 5) + atts := make([]*ethpb.PendingAttestation, 5) for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{Source: ðpb.Checkpoint{Root: make([]byte, 32)}, Target: ðpb.Checkpoint{Epoch: 0}}, AggregationBits: bitfield.Bitlist{0x00, 0xFF, 0xFF, 0xFF}, @@ -85,7 +84,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } @@ -105,9 +104,9 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { func TestAttestingBalance_CorrectBalance(t *testing.T) { helpers.ClearCache() // Generate 2 attestations. - atts := make([]*statepb.PendingAttestation, 2) + atts := make([]*ethpb.PendingAttestation, 2) for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -128,7 +127,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { } balances[i] = params.BeaconConfig().MaxEffectiveBalance } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 2, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -145,7 +144,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { } func TestProcessSlashings_NotSlashed(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{Slashed: true}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -161,11 +160,11 @@ func TestProcessSlashings_NotSlashed(t *testing.T) { func TestProcessSlashings_SlashedLess(t *testing.T) { tests := []struct { - state *statepb.BeaconState + state *ethpb.BeaconState want uint64 }{ { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -179,7 +178,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -195,7 +194,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(32000000000), // 32 * 1e9 - 500000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -211,7 +210,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -231,6 +230,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { original := proto.Clone(tt.state) s, err := v1.InitializeFromProto(tt.state) require.NoError(t, err) + helpers.ClearCache() newState, err := epoch.ProcessSlashings(s) require.NoError(t, err) assert.Equal(t, tt.want, newState.Balances()[0], "ProcessSlashings({%v}) = newState; newState.Balances[0] = %d", original, newState.Balances()[0]) @@ -277,7 +277,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { } func TestProcessRegistryUpdates_NoRotation(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 5 * params.BeaconConfig().SlotsPerEpoch, Validators: []*ethpb.Validator{ {ExitEpoch: params.BeaconConfig().MaxSeedLookahead}, @@ -299,7 +299,7 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) { } func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 5 * params.BeaconConfig().SlotsPerEpoch, FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 6, Root: make([]byte, 32)}, } @@ -331,7 +331,7 @@ func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) { } func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 5 * params.BeaconConfig().SlotsPerEpoch, Validators: []*ethpb.Validator{ {ExitEpoch: params.BeaconConfig().MaxSeedLookahead, @@ -351,7 +351,7 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) { } func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{ { @@ -378,7 +378,7 @@ func TestProcessRegistryUpdates_CanExits(t *testing.T) { e := types.Epoch(5) exitEpoch := helpers.ActivationExitEpoch(e) minWithdrawalDelay := params.BeaconConfig().MinValidatorWithdrawabilityDelay - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(e)), Validators: []*ethpb.Validator{ { diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index c247557bb4..579a4e92a9 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -8,7 +8,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -69,7 +69,7 @@ func ProcessAttestations( } // AttestedCurrentEpoch returns true if attestation `a` attested once in current epoch and/or epoch boundary block. -func AttestedCurrentEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, error) { +func AttestedCurrentEpoch(s state.ReadOnlyBeaconState, a *ethpb.PendingAttestation) (bool, bool, error) { currentEpoch := helpers.CurrentEpoch(s) var votedCurrentEpoch, votedTarget bool // Did validator vote current epoch. @@ -87,7 +87,7 @@ func AttestedCurrentEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttesta } // AttestedPrevEpoch returns true if attestation `a` attested once in previous epoch and epoch boundary block and/or the same head. -func AttestedPrevEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, bool, error) { +func AttestedPrevEpoch(s state.ReadOnlyBeaconState, a *ethpb.PendingAttestation) (bool, bool, bool, error) { prevEpoch := helpers.PrevEpoch(s) var votedPrevEpoch, votedTarget, votedHead bool // Did validator vote previous epoch. @@ -115,7 +115,7 @@ func AttestedPrevEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttestatio } // SameTarget returns true if attestation `a` attested to the same target block in state. -func SameTarget(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation, e types.Epoch) (bool, error) { +func SameTarget(state state.ReadOnlyBeaconState, a *ethpb.PendingAttestation, e types.Epoch) (bool, error) { r, err := helpers.BlockRoot(state, e) if err != nil { return false, err @@ -127,7 +127,7 @@ func SameTarget(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation, } // SameHead returns true if attestation `a` attested to the same block by attestation slot in state. -func SameHead(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, error) { +func SameHead(state state.ReadOnlyBeaconState, a *ethpb.PendingAttestation) (bool, error) { r, err := helpers.BlockRootAtSlot(state, a.Data.Slot) if err != nil { return false, err @@ -139,7 +139,7 @@ func SameHead(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (b } // UpdateValidator updates pre computed validator store. -func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *statepb.PendingAttestation, aSlot types.Slot) []*Validator { +func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *ethpb.PendingAttestation, aSlot types.Slot) []*Validator { inclusionSlot := aSlot + a.InclusionDelay for _, i := range indices { diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index d2088a69b5..6eb29d431f 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -21,7 +20,7 @@ func TestUpdateValidator_Works(t *testing.T) { vp := []*precompute.Validator{{}, {InclusionSlot: e}, {}, {InclusionSlot: e}, {}, {InclusionSlot: e}} record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true, IsPrevEpochAttester: true, IsPrevEpochTargetAttester: true, IsPrevEpochHeadAttester: true} - a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} + a := ðpb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} // Indices 1 3 and 5 attested vp = precompute.UpdateValidator(vp, record, []uint64{1, 3, 5}, a, 100) @@ -37,7 +36,7 @@ func TestUpdateValidator_InclusionOnlyCountsPrevEpoch(t *testing.T) { e := params.BeaconConfig().FarFutureSlot vp := []*precompute.Validator{{InclusionSlot: e}} record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true} - a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} + a := ðpb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} // Verify inclusion info doesnt get updated. vp = precompute.UpdateValidator(vp, record, []uint64{0}, a, 100) @@ -80,12 +79,12 @@ func TestSameHead(t *testing.T) { br[0] = r[:] require.NoError(t, beaconState.SetBlockRoots(br)) att.Data.BeaconBlockRoot = r[:] - same, err := precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data}) + same, err := precompute.SameHead(beaconState, ðpb.PendingAttestation{Data: att.Data}) require.NoError(t, err) assert.Equal(t, true, same, "Head in state does not match head in attestation") newRoot := [32]byte{'B'} att.Data.BeaconBlockRoot = newRoot[:] - same, err = precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data}) + same, err = precompute.SameHead(beaconState, ðpb.PendingAttestation{Data: att.Data}) require.NoError(t, err) assert.Equal(t, false, same, "Head in state matches head in attestation") } @@ -100,12 +99,12 @@ func TestSameTarget(t *testing.T) { br[0] = r[:] require.NoError(t, beaconState.SetBlockRoots(br)) att.Data.Target.Root = r[:] - same, err := precompute.SameTarget(beaconState, &statepb.PendingAttestation{Data: att.Data}, 0) + same, err := precompute.SameTarget(beaconState, ðpb.PendingAttestation{Data: att.Data}, 0) require.NoError(t, err) assert.Equal(t, true, same, "Head in state does not match head in attestation") newRoot := [32]byte{'B'} att.Data.Target.Root = newRoot[:] - same, err = precompute.SameTarget(beaconState, &statepb.PendingAttestation{Data: att.Data}, 0) + same, err = precompute.SameTarget(beaconState, ðpb.PendingAttestation{Data: att.Data}, 0) require.NoError(t, err) assert.Equal(t, false, same, "Head in state matches head in attestation") } @@ -121,7 +120,7 @@ func TestAttestedPrevEpoch(t *testing.T) { require.NoError(t, beaconState.SetBlockRoots(br)) att.Data.Target.Root = r[:] att.Data.BeaconBlockRoot = r[:] - votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &statepb.PendingAttestation{Data: att.Data}) + votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, ðpb.PendingAttestation{Data: att.Data}) require.NoError(t, err) assert.Equal(t, true, votedEpoch, "Did not vote epoch") assert.Equal(t, true, votedTarget, "Did not vote target") @@ -140,7 +139,7 @@ func TestAttestedCurrentEpoch(t *testing.T) { require.NoError(t, beaconState.SetBlockRoots(br)) att.Data.Target.Root = r[:] att.Data.BeaconBlockRoot = r[:] - votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &statepb.PendingAttestation{Data: att.Data}) + votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, ðpb.PendingAttestation{Data: att.Data}) require.NoError(t, err) assert.Equal(t, true, votedEpoch, "Did not vote epoch") assert.Equal(t, true, votedTarget, "Did not vote target") @@ -170,9 +169,9 @@ func TestProcessAttestations(t *testing.T) { require.NoError(t, beaconState.SetBlockRoots(br)) att2.Data.Target.Root = newRt[:] att2.Data.BeaconBlockRoot = newRt[:] - err := beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1}) + err := beaconState.AppendPreviousEpochAttestations(ðpb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1}) require.NoError(t, err) - err = beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1}) + err = beaconState.AppendCurrentEpochAttestations(ðpb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1}) require.NoError(t, err) pVals := make([]*precompute.Validator, validators) diff --git a/beacon-chain/core/epoch/precompute/justification_finalization_test.go b/beacon-chain/core/epoch/precompute/justification_finalization_test.go index e4a70831df..b02711085b 100644 --- a/beacon-chain/core/epoch/precompute/justification_finalization_test.go +++ b/beacon-chain/core/epoch/precompute/justification_finalization_test.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -21,7 +20,7 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 0, @@ -58,7 +57,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 0, @@ -95,7 +94,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 0, diff --git a/beacon-chain/core/epoch/precompute/new_test.go b/beacon-chain/core/epoch/precompute/new_test.go index 0603c7cf55..4d8b4d40c9 100644 --- a/beacon-chain/core/epoch/precompute/new_test.go +++ b/beacon-chain/core/epoch/precompute/new_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -15,7 +14,7 @@ import ( func TestNew(t *testing.T) { ffe := params.BeaconConfig().FarFutureEpoch - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch, // Validator 0 is slashed // Validator 1 is withdrawable diff --git a/beacon-chain/core/epoch/precompute/reward_penalty_test.go b/beacon-chain/core/epoch/precompute/reward_penalty_test.go index cebeaa5e43..8ccc63a0c6 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -12,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -23,9 +22,9 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+3, validatorCount) - atts := make([]*statepb.PendingAttestation, 3) + atts := make([]*ethpb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -62,10 +61,10 @@ func TestAttestationDeltaPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*statepb.PendingAttestation, 3) + atts := make([]*ethpb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -146,10 +145,10 @@ func TestAttestationDeltas_ZeroEpoch(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*statepb.PendingAttestation, 3) + atts := make([]*ethpb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -182,10 +181,10 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*statepb.PendingAttestation, 3) + atts := make([]*ethpb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -215,9 +214,9 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing. e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+3, validatorCount) - atts := make([]*statepb.PendingAttestation, 3) + atts := make([]*ethpb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { - atts[i] = &statepb.PendingAttestation{ + atts[i] = ðpb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -259,7 +258,7 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing. } } -func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState { +func buildState(slot types.Slot, validatorCount uint64) *ethpb.BeaconState { validators := make([]*ethpb.Validator, validatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -285,7 +284,7 @@ func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState { for i := 0; i < len(latestRandaoMixes); i++ { latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:] } - return &statepb.BeaconState{ + return ðpb.BeaconState{ Slot: slot, Balances: validatorBalances, Validators: validators, diff --git a/beacon-chain/core/epoch/precompute/slashing_test.go b/beacon-chain/core/epoch/precompute/slashing_test.go index de5f82f143..946e702c22 100644 --- a/beacon-chain/core/epoch/precompute/slashing_test.go +++ b/beacon-chain/core/epoch/precompute/slashing_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -15,7 +14,7 @@ import ( ) func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) { - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{Slashed: true}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -30,7 +29,7 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) { } func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) { - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -46,11 +45,11 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) { func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { tests := []struct { - state *statepb.BeaconState + state *ethpb.BeaconState want uint64 }{ { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -64,7 +63,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -80,7 +79,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(32000000000), // 32 * 1e9 - 500000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -96,7 +95,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index a7107c6027..2a538cba87 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -98,7 +97,7 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) { } } - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ Validators: validators, Slot: 200, BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), diff --git a/beacon-chain/core/helpers/block_test.go b/beacon-chain/core/helpers/block_test.go index 0a77234dba..dab2ad73d4 100644 --- a/beacon-chain/core/helpers/block_test.go +++ b/beacon-chain/core/helpers/block_test.go @@ -8,7 +8,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -20,7 +20,7 @@ func TestBlockRootAtSlot_CorrectBlockRoot(t *testing.T) { for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ { blockRoots = append(blockRoots, []byte{byte(i)}) } - s := &statepb.BeaconState{ + s := ðpb.BeaconState{ BlockRoots: blockRoots, } @@ -77,7 +77,7 @@ func TestBlockRootAtSlot_OutOfBounds(t *testing.T) { for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ { blockRoots = append(blockRoots, []byte{byte(i)}) } - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ BlockRoots: blockRoots, } diff --git a/beacon-chain/core/helpers/randao_test.go b/beacon-chain/core/helpers/randao_test.go index 411413ba55..c73c544673 100644 --- a/beacon-chain/core/helpers/randao_test.go +++ b/beacon-chain/core/helpers/randao_test.go @@ -6,7 +6,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -20,7 +20,7 @@ func TestRandaoMix_OK(t *testing.T) { binary.LittleEndian.PutUint64(intInBytes, uint64(i)) randaoMixes[i] = intInBytes } - state, err := v1.InitializeFromProto(&statepb.BeaconState{RandaoMixes: randaoMixes}) + state, err := v1.InitializeFromProto(ðpb.BeaconState{RandaoMixes: randaoMixes}) require.NoError(t, err) tests := []struct { epoch types.Epoch @@ -54,7 +54,7 @@ func TestRandaoMix_CopyOK(t *testing.T) { binary.LittleEndian.PutUint64(intInBytes, uint64(i)) randaoMixes[i] = intInBytes } - state, err := v1.InitializeFromProto(&statepb.BeaconState{RandaoMixes: randaoMixes}) + state, err := v1.InitializeFromProto(ðpb.BeaconState{RandaoMixes: randaoMixes}) require.NoError(t, err) tests := []struct { epoch types.Epoch @@ -95,7 +95,7 @@ func TestGenerateSeed_OK(t *testing.T) { randaoMixes[i] = intInBytes } slot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().MinSeedLookahead * 10)) - state, err := v1.InitializeFromProto(&statepb.BeaconState{ + state, err := v1.InitializeFromProto(ðpb.BeaconState{ RandaoMixes: randaoMixes, Slot: slot, }) diff --git a/beacon-chain/core/helpers/signing_root.go b/beacon-chain/core/helpers/signing_root.go index 2401ed7754..38927d2c4f 100644 --- a/beacon-chain/core/helpers/signing_root.go +++ b/beacon-chain/core/helpers/signing_root.go @@ -6,7 +6,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -57,7 +56,7 @@ func signingData(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, er if err != nil { return [32]byte{}, err } - container := &statepb.SigningData{ + container := ðpb.SigningData{ ObjectRoot: objRoot[:], Domain: domain, } @@ -210,7 +209,7 @@ func domain(domainType [DomainByteLength]byte, forkDataRoot []byte) []byte { // genesis_validators_root=genesis_validators_root, // )) func computeForkDataRoot(version, root []byte) ([32]byte, error) { - r, err := (&statepb.ForkData{ + r, err := (ðpb.ForkData{ CurrentVersion: version, GenesisValidatorsRoot: root, }).HashTreeRoot() diff --git a/beacon-chain/core/helpers/signing_root_test.go b/beacon-chain/core/helpers/signing_root_test.go index 968d48abd7..0a7a19bf17 100644 --- a/beacon-chain/core/helpers/signing_root_test.go +++ b/beacon-chain/core/helpers/signing_root_test.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -109,7 +109,7 @@ func TestSigningRoot_ComputeForkDigest(t *testing.T) { func TestFuzzverifySigningRoot_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} pubkey := [48]byte{} sig := [96]byte{} domain := [4]byte{} diff --git a/beacon-chain/core/helpers/slot_epoch_test.go b/beacon-chain/core/helpers/slot_epoch_test.go index 75f165e001..83958f0d96 100644 --- a/beacon-chain/core/helpers/slot_epoch_test.go +++ b/beacon-chain/core/helpers/slot_epoch_test.go @@ -7,7 +7,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -42,7 +42,7 @@ func TestCurrentEpoch_OK(t *testing.T) { {slot: 200, epoch: 6}, } for _, tt := range tests { - state, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(ðpb.BeaconState{Slot: tt.slot}) require.NoError(t, err) assert.Equal(t, tt.epoch, CurrentEpoch(state), "ActiveCurrentEpoch(%d)", state.Slot()) } @@ -58,7 +58,7 @@ func TestPrevEpoch_OK(t *testing.T) { {slot: 2 * params.BeaconConfig().SlotsPerEpoch, epoch: 1}, } for _, tt := range tests { - state, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(ðpb.BeaconState{Slot: tt.slot}) require.NoError(t, err) assert.Equal(t, tt.epoch, PrevEpoch(state), "ActivePrevEpoch(%d)", state.Slot()) } @@ -76,7 +76,7 @@ func TestNextEpoch_OK(t *testing.T) { {slot: 200, epoch: types.Epoch(200/params.BeaconConfig().SlotsPerEpoch + 1)}, } for _, tt := range tests { - state, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(ðpb.BeaconState{Slot: tt.slot}) require.NoError(t, err) assert.Equal(t, tt.epoch, NextEpoch(state), "NextEpoch(%d)", state.Slot()) } diff --git a/beacon-chain/core/helpers/validators.go b/beacon-chain/core/helpers/validators.go index 09e2d46071..e0b48763bb 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -7,7 +7,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -285,7 +284,7 @@ func ComputeProposerIndex(bState state.ReadOnlyValidators, activeIndices []types // epoch = get_current_epoch(state) if epoch is None else epoch // fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version // return compute_domain(domain_type, fork_version, state.genesis_validators_root) -func Domain(fork *statepb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) { +func Domain(fork *ethpb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) { if fork == nil { return []byte{}, errors.New("nil fork or domain type") } diff --git a/beacon-chain/core/state/benchmarks_test.go b/beacon-chain/core/state/benchmarks_test.go index 86045206b1..0843fe9cad 100644 --- a/beacon-chain/core/state/benchmarks_test.go +++ b/beacon-chain/core/state/benchmarks_test.go @@ -8,7 +8,7 @@ import ( coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/benchutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -146,7 +146,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - require.NoError(b, proto.Unmarshal(protoObject, &statepb.BeaconState{})) + require.NoError(b, proto.Unmarshal(protoObject, ðpb.BeaconState{})) } }) @@ -154,7 +154,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - sszState := &statepb.BeaconState{} + sszState := ðpb.BeaconState{} require.NoError(b, sszState.UnmarshalSSZ(sszObject)) } }) diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index dff991b7ab..2fd919d205 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -12,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -114,13 +113,13 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState, return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err) } - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ // Misc fields. Slot: 0, GenesisTime: genesisTime, GenesisValidatorsRoot: genesisValidatorsRoot[:], - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, @@ -152,8 +151,8 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState, BlockRoots: blockRoots, StateRoots: stateRoots, Slashings: slashings, - CurrentEpochAttestations: []*statepb.PendingAttestation{}, - PreviousEpochAttestations: []*statepb.PendingAttestation{}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{}, // Eth1 data. Eth1Data: eth1Data, @@ -184,10 +183,10 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState, // EmptyGenesisState returns an empty beacon state object. func EmptyGenesisState() (state.BeaconState, error) { - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ // Misc fields. Slot: 0, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, @@ -198,8 +197,8 @@ func EmptyGenesisState() (state.BeaconState, error) { JustificationBits: []byte{0}, HistoricalRoots: [][]byte{}, - CurrentEpochAttestations: []*statepb.PendingAttestation{}, - PreviousEpochAttestations: []*statepb.PendingAttestation{}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{}, // Eth1 data. Eth1Data: ðpb.Eth1Data{}, diff --git a/beacon-chain/core/state/stateutils/validator_index_map_test.go b/beacon-chain/core/state/stateutils/validator_index_map_test.go index 6efd29455c..863185d9f3 100644 --- a/beacon-chain/core/state/stateutils/validator_index_map_test.go +++ b/beacon-chain/core/state/stateutils/validator_index_map_test.go @@ -7,14 +7,13 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestValidatorIndexMap_OK(t *testing.T) { - base := &statepb.BeaconState{ + base := ðpb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: []byte("zero"), diff --git a/beacon-chain/db/iface/interface.go b/beacon-chain/db/iface/interface.go index 1788ae609f..4d5bf05d4f 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -13,7 +13,7 @@ import ( slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" "github.com/prysmaticlabs/prysm/beacon-chain/state" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/backuputil" @@ -36,7 +36,7 @@ type ReadOnlyDatabase interface { State(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error) GenesisState(ctx context.Context) (state.BeaconState, error) HasState(ctx context.Context, blockRoot [32]byte) bool - StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) + StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) HasStateSummary(ctx context.Context, blockRoot [32]byte) bool HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([]state.ReadOnlyBeaconState, error) // Slashing operations. @@ -73,8 +73,8 @@ type NoHeadAccessDatabase interface { SaveStates(ctx context.Context, states []state.ReadOnlyBeaconState, blockRoots [][32]byte) error DeleteState(ctx context.Context, blockRoot [32]byte) error DeleteStates(ctx context.Context, blockRoots [][32]byte) error - SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error - SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error + SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error + SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error // Slashing operations. SaveProposerSlashing(ctx context.Context, slashing *eth.ProposerSlashing) error SaveAttesterSlashing(ctx context.Context, slashing *eth.AttesterSlashing) error diff --git a/beacon-chain/db/kafka/passthrough.go b/beacon-chain/db/kafka/passthrough.go index ace7f17b1a..94d01faf72 100644 --- a/beacon-chain/db/kafka/passthrough.go +++ b/beacon-chain/db/kafka/passthrough.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/beacon-chain/state" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" ) @@ -70,7 +70,7 @@ func (e Exporter) State(ctx context.Context, blockRoot [32]byte) (state.BeaconSt } // StateSummary -- passthrough. -func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { +func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) { return e.db.StateSummary(ctx, blockRoot) } @@ -145,12 +145,12 @@ func (e Exporter) SaveState(ctx context.Context, st state.ReadOnlyBeaconState, b } // SaveStateSummary -- passthrough. -func (e Exporter) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error { +func (e Exporter) SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error { return e.db.SaveStateSummary(ctx, summary) } // SaveStateSummaries -- passthrough. -func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error { +func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error { return e.db.SaveStateSummaries(ctx, summaries) } diff --git a/beacon-chain/db/kv/encoding.go b/beacon-chain/db/kv/encoding.go index 3d32649dfc..2d156e4e02 100644 --- a/beacon-chain/db/kv/encoding.go +++ b/beacon-chain/db/kv/encoding.go @@ -8,7 +8,6 @@ import ( fastssz "github.com/ferranbt/fastssz" "github.com/golang/snappy" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "go.opencensus.io/trace" "google.golang.org/protobuf/proto" ) @@ -53,7 +52,7 @@ func encode(ctx context.Context, msg proto.Message) ([]byte, error) { // isSSZStorageFormat returns true if the object type should be saved in SSZ encoded format. func isSSZStorageFormat(obj interface{}) bool { switch obj.(type) { - case *statepb.BeaconState: + case *ethpb.BeaconState: return true case *ethpb.SignedBeaconBlock: return true diff --git a/beacon-chain/db/kv/genesis.go b/beacon-chain/db/kv/genesis.go index ba85fb922c..049cf0629c 100644 --- a/beacon-chain/db/kv/genesis.go +++ b/beacon-chain/db/kv/genesis.go @@ -12,7 +12,7 @@ import ( dbIface "github.com/prysmaticlabs/prysm/beacon-chain/db/iface" "github.com/prysmaticlabs/prysm/beacon-chain/state" statev1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -34,7 +34,7 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState state.BeaconSt if err := s.SaveState(ctx, genesisState, genesisBlkRoot); err != nil { return errors.Wrap(err, "could not save genesis state") } - if err := s.SaveStateSummary(ctx, &statepb.StateSummary{ + if err := s.SaveStateSummary(ctx, ðpb.StateSummary{ Slot: 0, Root: genesisBlkRoot[:], }); err != nil { @@ -47,7 +47,6 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState state.BeaconSt if err := s.SaveGenesisBlockRoot(ctx, genesisBlkRoot); err != nil { return errors.Wrap(err, "could not save genesis block root") } - return nil } @@ -57,7 +56,7 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error { if err != nil { return err } - st := &statepb.BeaconState{} + st := ðpb.BeaconState{} if err := st.UnmarshalSSZ(b); err != nil { return err } @@ -90,7 +89,6 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error { return fmt.Errorf("loaded genesis fork version (%#x) does not match config genesis "+ "fork version (%#x)", gs.Fork().CurrentVersion, params.BeaconConfig().GenesisForkVersion) } - return s.SaveGenesisData(ctx, gs) } diff --git a/beacon-chain/db/kv/migration_state_validators.go b/beacon-chain/db/kv/migration_state_validators.go index 77546e3c60..c55cbc84df 100644 --- a/beacon-chain/db/kv/migration_state_validators.go +++ b/beacon-chain/db/kv/migration_state_validators.go @@ -5,7 +5,7 @@ import ( "context" "github.com/golang/snappy" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -63,7 +63,7 @@ func migrateStateValidators(tx *bolt.Tx) error { ctx := context.Background() c := stateBkt.Cursor() for k, v := c.First(); k != nil; k, v = c.Next() { - state := &statepb.BeaconState{} + state := ðpb.BeaconState{} if decodeErr := decode(ctx, v, state); decodeErr != nil { return decodeErr } diff --git a/beacon-chain/db/kv/state_summary.go b/beacon-chain/db/kv/state_summary.go index a89fc6a285..443291f06f 100644 --- a/beacon-chain/db/kv/state_summary.go +++ b/beacon-chain/db/kv/state_summary.go @@ -3,22 +3,22 @@ package kv import ( "context" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) // SaveStateSummary saves a state summary object to the DB. -func (s *Store) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error { +func (s *Store) SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummary") defer span.End() - return s.SaveStateSummaries(ctx, []*statepb.StateSummary{summary}) + return s.SaveStateSummaries(ctx, []*ethpb.StateSummary{summary}) } // SaveStateSummaries saves state summary objects to the DB. -func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error { +func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummaries") defer span.End() @@ -38,7 +38,7 @@ func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.Sta } // StateSummary returns the state summary object from the db using input block root. -func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { +func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.StateSummary") defer span.End() @@ -53,7 +53,7 @@ func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb. if len(enc) == 0 { return nil, nil } - summary := &statepb.StateSummary{} + summary := ðpb.StateSummary{} if err := decode(ctx, enc, summary); err != nil { return nil, err } diff --git a/beacon-chain/db/kv/state_summary_cache.go b/beacon-chain/db/kv/state_summary_cache.go index b69f9ad2e8..c696374b45 100644 --- a/beacon-chain/db/kv/state_summary_cache.go +++ b/beacon-chain/db/kv/state_summary_cache.go @@ -3,26 +3,26 @@ package kv import ( "sync" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) const stateSummaryCachePruneCount = 128 // stateSummaryCache caches state summary object. type stateSummaryCache struct { - initSyncStateSummaries map[[32]byte]*statepb.StateSummary + initSyncStateSummaries map[[32]byte]*ethpb.StateSummary initSyncStateSummariesLock sync.RWMutex } // newStateSummaryCache creates a new state summary cache. func newStateSummaryCache() *stateSummaryCache { return &stateSummaryCache{ - initSyncStateSummaries: make(map[[32]byte]*statepb.StateSummary), + initSyncStateSummaries: make(map[[32]byte]*ethpb.StateSummary), } } // put saves a state summary to the initial sync state summaries cache. -func (c *stateSummaryCache) put(r [32]byte, b *statepb.StateSummary) { +func (c *stateSummaryCache) put(r [32]byte, b *ethpb.StateSummary) { c.initSyncStateSummariesLock.Lock() defer c.initSyncStateSummariesLock.Unlock() c.initSyncStateSummaries[r] = b @@ -39,7 +39,7 @@ func (c *stateSummaryCache) has(r [32]byte) bool { // get retrieves a state summary from the initial sync state summaries cache using the root of // the block. -func (c *stateSummaryCache) get(r [32]byte) *statepb.StateSummary { +func (c *stateSummaryCache) get(r [32]byte) *ethpb.StateSummary { c.initSyncStateSummariesLock.RLock() defer c.initSyncStateSummariesLock.RUnlock() b := c.initSyncStateSummaries[r] @@ -55,11 +55,11 @@ func (c *stateSummaryCache) len() int { // GetAll retrieves all the beacon state summaries from the initial sync state summaries cache, the returned // state summaries are unordered. -func (c *stateSummaryCache) getAll() []*statepb.StateSummary { +func (c *stateSummaryCache) getAll() []*ethpb.StateSummary { c.initSyncStateSummariesLock.RLock() defer c.initSyncStateSummariesLock.RUnlock() - summaries := make([]*statepb.StateSummary, 0, len(c.initSyncStateSummaries)) + summaries := make([]*ethpb.StateSummary, 0, len(c.initSyncStateSummaries)) for _, b := range c.initSyncStateSummaries { summaries = append(summaries, b) } @@ -70,5 +70,5 @@ func (c *stateSummaryCache) getAll() []*statepb.StateSummary { func (c *stateSummaryCache) clear() { c.initSyncStateSummariesLock.Lock() defer c.initSyncStateSummariesLock.Unlock() - c.initSyncStateSummaries = make(map[[32]byte]*statepb.StateSummary) + c.initSyncStateSummaries = make(map[[32]byte]*ethpb.StateSummary) } diff --git a/beacon-chain/db/kv/state_summary_test.go b/beacon-chain/db/kv/state_summary_test.go index 27d8a87663..698fba3c21 100644 --- a/beacon-chain/db/kv/state_summary_test.go +++ b/beacon-chain/db/kv/state_summary_test.go @@ -5,7 +5,7 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -16,7 +16,7 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) { ctx := context.Background() r1 := bytesutil.ToBytes32([]byte{'A'}) r2 := bytesutil.ToBytes32([]byte{'B'}) - s1 := &statepb.StateSummary{Slot: 1, Root: r1[:]} + s1 := ðpb.StateSummary{Slot: 1, Root: r1[:]} // State summary should not exist yet. require.Equal(t, false, db.HasStateSummary(ctx, r1), "State summary should not be saved") @@ -28,7 +28,7 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) { assert.DeepEqual(t, s1, saved, "State summary does not equal") // Save a new state summary. - s2 := &statepb.StateSummary{Slot: 2, Root: r2[:]} + s2 := ðpb.StateSummary{Slot: 2, Root: r2[:]} // State summary should not exist yet. require.Equal(t, false, db.HasStateSummary(ctx, r2), "State summary should not be saved") @@ -43,18 +43,18 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) { func TestStateSummary_CacheToDB(t *testing.T) { db := setupDB(t) - summaries := make([]*statepb.StateSummary, stateSummaryCachePruneCount-1) + summaries := make([]*ethpb.StateSummary, stateSummaryCachePruneCount-1) for i := range summaries { - summaries[i] = &statepb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)} + summaries[i] = ðpb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)} } require.NoError(t, db.SaveStateSummaries(context.Background(), summaries)) require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount-1) - require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}})) + require.NoError(t, db.SaveStateSummary(context.Background(), ðpb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}})) require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount) - require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}})) + require.NoError(t, db.SaveStateSummary(context.Background(), ðpb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}})) require.Equal(t, db.stateSummaryCache.len(), 1) for i := range summaries { diff --git a/beacon-chain/interop-cold-start/service.go b/beacon-chain/interop-cold-start/service.go index f1cf2f7349..f1bd9f060f 100644 --- a/beacon-chain/interop-cold-start/service.go +++ b/beacon-chain/interop-cold-start/service.go @@ -16,7 +16,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/slotutil" @@ -62,7 +61,7 @@ func NewService(ctx context.Context, cfg *Config) *Service { if err != nil { log.Fatalf("Could not read pre-loaded state: %v", err) } - genesisState := &statepb.BeaconState{} + genesisState := ðpb.BeaconState{} if err := genesisState.UnmarshalSSZ(data); err != nil { log.Fatalf("Could not unmarshal pre-loaded state: %v", err) } diff --git a/beacon-chain/operations/voluntaryexits/service_test.go b/beacon-chain/operations/voluntaryexits/service_test.go index 5ad626177a..36ce58041f 100644 --- a/beacon-chain/operations/voluntaryexits/service_test.go +++ b/beacon-chain/operations/voluntaryexits/service_test.go @@ -8,7 +8,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -270,7 +269,7 @@ func TestPool_InsertVoluntaryExit(t *testing.T) { p := &Pool{ pending: tt.fields.pending, } - s, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{Validators: validators}) + s, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{Validators: validators}) require.NoError(t, err) p.InsertVoluntaryExit(ctx, s, tt.args.exit) if len(p.pending) != len(tt.want) { @@ -521,7 +520,7 @@ func TestPool_PendingExits(t *testing.T) { p := &Pool{ pending: tt.fields.pending, } - s, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}}) + s, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}}) require.NoError(t, err) if got := p.PendingExits(s, tt.args.slot, tt.fields.noLimit); !reflect.DeepEqual(got, tt.want) { t.Errorf("PendingExits() = %v, want %v", got, tt.want) diff --git a/beacon-chain/p2p/gossip_scoring_params_test.go b/beacon-chain/p2p/gossip_scoring_params_test.go index 305c3bb846..f421e74d86 100644 --- a/beacon-chain/p2p/gossip_scoring_params_test.go +++ b/beacon-chain/p2p/gossip_scoring_params_test.go @@ -7,7 +7,6 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -26,7 +25,7 @@ func TestCorrect_ActiveValidatorsCount(t *testing.T) { ctx: context.Background(), cfg: &Config{DB: db}, } - bState, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { + bState, err := testutil.NewBeaconState(func(state *ethpb.BeaconState) error { validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ diff --git a/beacon-chain/p2p/sender_test.go b/beacon-chain/p2p/sender_test.go index 8760e87c9d..7ec394d32d 100644 --- a/beacon-chain/p2p/sender_test.go +++ b/beacon-chain/p2p/sender_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/libp2p/go-libp2p-core/network" testp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" @@ -26,7 +26,7 @@ func TestService_Send(t *testing.T) { cfg: &Config{}, } - msg := &statepb.Fork{ + msg := ðpb.Fork{ CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr"), Epoch: 55, @@ -36,12 +36,12 @@ func TestService_Send(t *testing.T) { var wg sync.WaitGroup wg.Add(1) topic := "/testing/1" - RPCTopicMappings[topic] = new(statepb.Fork) + RPCTopicMappings[topic] = new(ethpb.Fork) defer func() { delete(RPCTopicMappings, topic) }() p2.SetStreamHandler(topic+"/ssz_snappy", func(stream network.Stream) { - rcvd := &statepb.Fork{} + rcvd := ðpb.Fork{} require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd)) _, err := svc.Encoding().EncodeWithMaxLength(stream, rcvd) require.NoError(t, err) @@ -54,7 +54,7 @@ func TestService_Send(t *testing.T) { testutil.WaitTimeout(&wg, 1*time.Second) - rcvd := &statepb.Fork{} + rcvd := ðpb.Fork{} require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd)) if !proto.Equal(rcvd, msg) { t.Errorf("Expected identical message to be received. got %v want %v", rcvd, msg) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index f953a2eb91..5f9183b675 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -20,7 +20,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" @@ -40,7 +39,7 @@ func TestServer_ListAttestations_NoResults(t *testing.T) { db := dbTest.SetupDB(t) ctx := context.Background() - st, err := v1.InitializeFromProto(&statepb.BeaconState{ + st, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -68,7 +67,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) { db := dbTest.SetupDB(t) ctx := context.Background() - st, err := v1.InitializeFromProto(&statepb.BeaconState{ + st, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -564,13 +563,13 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { HeadFetcher: &chainMock.ChainService{State: state}, StateGen: stategen.New(db), } - err := db.SaveStateSummary(ctx, &statepb.StateSummary{ + err := db.SaveStateSummary(ctx, ðpb.StateSummary{ Root: targetRoot1[:], Slot: 1, }) require.NoError(t, err) - err = db.SaveStateSummary(ctx, &statepb.StateSummary{ + err = db.SaveStateSummary(ctx, ðpb.StateSummary{ Root: targetRoot2[:], Slot: 2, }) @@ -664,7 +663,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) { }, StateGen: stategen.New(db), } - err = db.SaveStateSummary(ctx, &statepb.StateSummary{ + err = db.SaveStateSummary(ctx, ðpb.StateSummary{ Root: blockRoot[:], Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)), }) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go index cfb04519a9..2b9ee29dd1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go @@ -12,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -162,7 +161,7 @@ func TestRetrieveCommitteesForRoot(t *testing.T) { require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot)) require.NoError(t, db.SaveState(ctx, headState, gRoot)) - stateSummary := &statepb.StateSummary{ + stateSummary := ðpb.StateSummary{ Slot: 0, Root: gRoot[:], } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go index 9dd38c6fae..c317b19f0c 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go @@ -15,7 +15,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -45,7 +44,7 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) { func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) { ctx := context.Background() - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) require.NoError(t, err) @@ -67,7 +66,7 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) { func TestSubmitAggregateAndProof_IsAggregatorAndNoAtts(t *testing.T) { ctx := context.Background() - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ {PublicKey: pubKey(0)}, diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index 964600480c..bebd0d1ee6 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -15,7 +15,6 @@ import ( mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" @@ -52,7 +51,7 @@ func TestValidatorIndex_OK(t *testing.T) { func TestWaitForActivation_ContextClosed(t *testing.T) { ctx := context.Background() - beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ + beaconState, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{}, }) @@ -70,7 +69,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), DepositFetcher: depositCache, HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } @@ -108,7 +107,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { pubKey1 := priv1.PublicKey().Marshal() pubKey2 := priv2.PublicKey().Marshal() - beaconState := &statepb.BeaconState{ + beaconState := ðpb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -146,7 +145,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { require.NoError(t, err) vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -197,7 +196,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) { pubKey2 := priv2.PublicKey().Marshal() pubKey3 := priv3.PublicKey().Marshal() - beaconState := &statepb.BeaconState{ + beaconState := ðpb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -226,7 +225,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) { require.NoError(t, err) vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]}, } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go index 4196e80b37..4ce6f28ce5 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go @@ -16,7 +16,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -45,7 +44,7 @@ func TestValidatorStatus_DepositedEth1(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{}) + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{}) require.NoError(t, err) vs := &Server{ DepositFetcher: depositCache, @@ -88,7 +87,7 @@ func TestValidatorStatus_Deposited(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: pubKey1, @@ -138,7 +137,7 @@ func TestValidatorStatus_PartiallyDeposited(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: pubKey1, @@ -253,7 +252,7 @@ func TestValidatorStatus_Active(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ GenesisTime: uint64(time.Unix(0, 0).Unix()), Slot: 10000, Validators: []*ethpb.Validator{{ @@ -307,7 +306,7 @@ func TestValidatorStatus_Exiting(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ Slot: slot, Validators: []*ethpb.Validator{{ PublicKey: pubKey, @@ -365,7 +364,7 @@ func TestValidatorStatus_Slashing(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &statepb.BeaconState{ + state := ðpb.BeaconState{ Slot: slot, Validators: []*ethpb.Validator{{ Slashed: true, @@ -473,7 +472,7 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) { depositCache, err := depositcache.New() require.NoError(t, err) - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -498,7 +497,7 @@ func TestActivationStatus_OK(t *testing.T) { deposits, _, err := testutil.DeterministicDepositsAndKeys(4) require.NoError(t, err) pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey} - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -537,7 +536,7 @@ func TestActivationStatus_OK(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -692,7 +691,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { deposits[4].Data.PublicKey, deposits[5].Data.PublicKey, } - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -741,7 +740,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -792,7 +791,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { slot := types.Slot(10000) epoch := helpers.SlotToEpoch(slot) pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4), pubKey(5), pubKey(6), pubKey(7)} - beaconState := &statepb.BeaconState{ + beaconState := ðpb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -837,7 +836,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *statepb.BeaconState, 1), + CanonicalStateChan: make(chan *ethpb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -903,7 +902,7 @@ func TestValidatorStatus_Invalid(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{}) + stateObj, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{}) require.NoError(t, err) vs := &Server{ DepositFetcher: depositCache, diff --git a/beacon-chain/state/genesis/genesis.go b/beacon-chain/state/genesis/genesis.go index 4a497c480b..ff4c65fe67 100644 --- a/beacon-chain/state/genesis/genesis.go +++ b/beacon-chain/state/genesis/genesis.go @@ -5,7 +5,7 @@ import ( "github.com/golang/snappy" state "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -27,7 +27,7 @@ func State(name string) (*state.BeaconState, error) { // load a compressed ssz state file into a beacon state struct. func load(b []byte) (*state.BeaconState, error) { - st := &statepb.BeaconState{} + st := ðpb.BeaconState{} b, err := snappy.Decode(nil /*dst*/, b) if err != nil { return nil, err diff --git a/beacon-chain/state/phase0.go b/beacon-chain/state/phase0.go index 40d913142e..c727701f2c 100644 --- a/beacon-chain/state/phase0.go +++ b/beacon-chain/state/phase0.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/go-bitfield" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // BeaconState has read and write access to beacon state methods. @@ -39,7 +38,7 @@ type ReadOnlyBeaconState interface { GenesisTime() uint64 GenesisValidatorRoot() []byte Slot() types.Slot - Fork() *statepb.Fork + Fork() *ethpb.Fork LatestBlockHeader() *ethpb.BeaconBlockHeader HistoricalRoots() [][]byte Slashings() []uint64 @@ -61,7 +60,7 @@ type WriteOnlyBeaconState interface { SetGenesisTime(val uint64) error SetGenesisValidatorRoot(val []byte) error SetSlot(val types.Slot) error - SetFork(val *statepb.Fork) error + SetFork(val *ethpb.Fork) error SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error SetHistoricalRoots(val [][]byte) error SetSlashings(val []uint64) error @@ -139,8 +138,8 @@ type ReadOnlyEth1Data interface { // ReadOnlyAttestations defines a struct which only has read access to attestations methods. type ReadOnlyAttestations interface { - PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) - CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) + PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) + CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) } // WriteOnlyBlockRoots defines a struct which only has write access to block roots methods. @@ -194,8 +193,8 @@ type WriteOnlyCheckpoint interface { // WriteOnlyAttestations defines a struct which only has write access to attestations methods. type WriteOnlyAttestations interface { - AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error - AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error + AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error + AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error RotateAttestations() error } @@ -209,10 +208,10 @@ type FutureForkStub interface { PreviousEpochParticipation() ([]byte, error) InactivityScores() ([]uint64, error) SetInactivityScores(val []uint64) error - CurrentSyncCommittee() (*statepb.SyncCommittee, error) - SetCurrentSyncCommittee(val *statepb.SyncCommittee) error + CurrentSyncCommittee() (*ethpb.SyncCommittee, error) + SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error SetPreviousParticipationBits(val []byte) error SetCurrentParticipationBits(val []byte) error - NextSyncCommittee() (*statepb.SyncCommittee, error) - SetNextSyncCommittee(val *statepb.SyncCommittee) error + NextSyncCommittee() (*ethpb.SyncCommittee, error) + SetNextSyncCommittee(val *ethpb.SyncCommittee) error } diff --git a/beacon-chain/state/stategen/getter.go b/beacon-chain/state/stategen/getter.go index c5f7adf9c7..831bc63c1c 100644 --- a/beacon-chain/state/stategen/getter.go +++ b/beacon-chain/state/stategen/getter.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" @@ -111,8 +111,8 @@ func (s *State) StateBySlot(ctx context.Context, slot types.Slot) (state.BeaconS // This returns the state summary object of a given block root, it first checks the cache // then checks the DB. An error is returned if state summary object is nil. -func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { - var summary *statepb.StateSummary +func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) { + var summary *ethpb.StateSummary var err error summary, err = s.beaconDB.StateSummary(ctx, blockRoot) @@ -127,13 +127,13 @@ func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*statepb. } // RecoverStateSummary recovers state summary object of a given block root by using the saved block in DB. -func (s *State) RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { +func (s *State) RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) { if s.beaconDB.HasBlock(ctx, blockRoot) { b, err := s.beaconDB.Block(ctx, blockRoot) if err != nil { return nil, err } - summary := &statepb.StateSummary{Slot: b.Block().Slot(), Root: blockRoot[:]} + summary := ðpb.StateSummary{Slot: b.Block().Slot(), Root: blockRoot[:]} if err := s.beaconDB.SaveStateSummary(ctx, summary); err != nil { return nil, err } diff --git a/beacon-chain/state/stategen/getter_test.go b/beacon-chain/state/stategen/getter_test.go index 912ad7f1d1..a66e2ddc6e 100644 --- a/beacon-chain/state/stategen/getter_test.go +++ b/beacon-chain/state/stategen/getter_test.go @@ -7,7 +7,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -50,7 +50,7 @@ func TestStateByRoot_HotStateUsingEpochBoundaryCacheNoReplay(t *testing.T) { blk := testutil.NewBeaconBlock() blkRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: blkRoot[:]})) require.NoError(t, service.epochBoundaryStateCache.put(blkRoot, beaconState)) loadedState, err := service.StateByRoot(ctx, blkRoot) require.NoError(t, err) @@ -76,7 +76,7 @@ func TestStateByRoot_HotStateUsingEpochBoundaryCacheWithReplay(t *testing.T) { require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(targetBlock))) targetRoot, err := targetBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) loadedState, err := service.StateByRoot(ctx, targetRoot) require.NoError(t, err) assert.Equal(t, targetSlot, loadedState.Slot(), "Did not correctly load state") @@ -90,7 +90,7 @@ func TestStateByRoot_HotStateCached(t *testing.T) { beaconState, _ := testutil.DeterministicGenesisState(t, 32) r := [32]byte{'A'} - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: r[:]})) service.hotStateCache.put(r, beaconState) loadedState, err := service.StateByRoot(ctx, r) @@ -124,7 +124,7 @@ func TestStateByRootInitialSync_UseCache(t *testing.T) { beaconState, _ := testutil.DeterministicGenesisState(t, 32) r := [32]byte{'A'} - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Root: r[:]})) service.hotStateCache.put(r, beaconState) loadedState, err := service.StateByRootInitialSync(ctx, r) @@ -152,7 +152,7 @@ func TestStateByRootInitialSync_CanProcessUpTo(t *testing.T) { targetRoot, err := targetBlk.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(targetBlk))) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) loadedState, err := service.StateByRootInitialSync(ctx, targetRoot) require.NoError(t, err) @@ -186,7 +186,7 @@ func TestStateBySlot_ColdState(t *testing.T) { require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, bRoot)) r := [32]byte{} - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: service.slotsPerArchivedPoint, Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: service.slotsPerArchivedPoint, Root: r[:]})) slot := types.Slot(20) loadedState, err := service.StateBySlot(ctx, slot) @@ -243,7 +243,7 @@ func TestLoadeStateByRoot_FinalizedState(t *testing.T) { assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 0, Root: gRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 0, Root: gRoot[:]})) service.finalizedInfo.state = beaconState service.finalizedInfo.slot = beaconState.Slot() @@ -273,7 +273,7 @@ func TestLoadeStateByRoot_EpochBoundaryStateCanProcess(t *testing.T) { require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) blkRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 10, Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 10, Root: blkRoot[:]})) // This tests where hot state was not cached and needs processing. loadedState, err := service.loadStateByRoot(ctx, blkRoot) @@ -299,7 +299,7 @@ func TestLoadeStateByRoot_FromDBBoundaryCase(t *testing.T) { require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) blkRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 10, Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 10, Root: blkRoot[:]})) // This tests where hot state was not cached and needs processing. loadedState, err := service.loadStateByRoot(ctx, blkRoot) @@ -345,7 +345,7 @@ func TestLoadeStateBySlot_CanReplayBlock(t *testing.T) { require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) r1, err := b1.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: r1[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 1, Root: r1[:]})) service.hotStateCache.put(bytesutil.ToBytes32(b1.Block.ParentRoot), genesis) loadedState, err := service.loadStateBySlot(ctx, 2) diff --git a/beacon-chain/state/stategen/hot_state_cache_test.go b/beacon-chain/state/stategen/hot_state_cache_test.go index 5fa998b8a1..421f87e338 100644 --- a/beacon-chain/state/stategen/hot_state_cache_test.go +++ b/beacon-chain/state/stategen/hot_state_cache_test.go @@ -5,7 +5,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -17,7 +17,7 @@ func TestHotStateCache_RoundTrip(t *testing.T) { assert.Equal(t, state.BeaconState(nil), s) assert.Equal(t, false, c.has(root), "Empty cache has an object") - s, err := v1.InitializeFromProto(&statepb.BeaconState{ + s, err := v1.InitializeFromProto(ðpb.BeaconState{ Slot: 10, }) require.NoError(t, err) diff --git a/beacon-chain/state/stategen/migrate_test.go b/beacon-chain/state/stategen/migrate_test.go index 60eaa8aa81..b642a3a2df 100644 --- a/beacon-chain/state/stategen/migrate_test.go +++ b/beacon-chain/state/stategen/migrate_test.go @@ -7,7 +7,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -84,14 +84,14 @@ func TestMigrateToCold_RegeneratePath(t *testing.T) { r1, err := b1.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: r1[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 1, Root: r1[:]})) b4, err := testutil.GenerateFullBlock(beaconState, pks, testutil.DefaultBlockGenConfig(), 4) require.NoError(t, err) r4, err := b4.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b4))) - require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 4, Root: r4[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{Slot: 4, Root: r4[:]})) service.finalizedInfo = &finalizedInfo{ slot: 0, root: genesisStateRoot, diff --git a/beacon-chain/state/stategen/service.go b/beacon-chain/state/stategen/service.go index 76007feeb0..38e8cf57ad 100644 --- a/beacon-chain/state/stategen/service.go +++ b/beacon-chain/state/stategen/service.go @@ -11,7 +11,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db" "github.com/prysmaticlabs/prysm/beacon-chain/state" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -33,7 +33,7 @@ type StateManager interface { StateByRoot(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error) StateByRootInitialSync(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error) StateBySlot(ctx context.Context, slot types.Slot) (state.BeaconState, error) - RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) + RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) SaveState(ctx context.Context, root [32]byte, st state.BeaconState) error ForceCheckpoint(ctx context.Context, root []byte) error EnableSaveHotStateToDB(_ context.Context) diff --git a/beacon-chain/state/stategen/setter.go b/beacon-chain/state/stategen/setter.go index 32a3094420..ffe7999db4 100644 --- a/beacon-chain/state/stategen/setter.go +++ b/beacon-chain/state/stategen/setter.go @@ -6,7 +6,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" @@ -80,7 +80,7 @@ func (s *State) saveStateByRoot(ctx context.Context, blockRoot [32]byte, st stat } // On an intermediate slots, save state summary. - if err := s.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{ + if err := s.beaconDB.SaveStateSummary(ctx, ðpb.StateSummary{ Slot: st.Slot(), Root: blockRoot[:], }); err != nil { diff --git a/beacon-chain/state/stateutil/pending_attestation_root.go b/beacon-chain/state/stateutil/pending_attestation_root.go index 8d69dbecca..83818db9a8 100644 --- a/beacon-chain/state/stateutil/pending_attestation_root.go +++ b/beacon-chain/state/stateutil/pending_attestation_root.go @@ -5,7 +5,6 @@ import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/htrutils" "github.com/prysmaticlabs/prysm/shared/params" @@ -13,7 +12,7 @@ import ( // PendingAttRootWithHasher describes a method from which the hash tree root // of a pending attestation is returned. -func PendingAttRootWithHasher(hasher htrutils.HashFn, att *statepb.PendingAttestation) ([32]byte, error) { +func PendingAttRootWithHasher(hasher htrutils.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) { var fieldRoots [][32]byte // Bitfield. @@ -43,7 +42,7 @@ func PendingAttRootWithHasher(hasher htrutils.HashFn, att *statepb.PendingAttest // PendingAttEncKey returns the encoded key in bytes of input `pendingAttestation`, // the returned key bytes can be used for caching purposes. -func PendingAttEncKey(att *statepb.PendingAttestation) []byte { +func PendingAttEncKey(att *ethpb.PendingAttestation) []byte { enc := make([]byte, 2192) if att != nil { diff --git a/beacon-chain/state/stateutil/state_root_test.go b/beacon-chain/state/stateutil/state_root_test.go index 54833b09d1..801b3fa30f 100644 --- a/beacon-chain/state/stateutil/state_root_test.go +++ b/beacon-chain/state/stateutil/state_root_test.go @@ -7,7 +7,6 @@ import ( "testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -16,7 +15,7 @@ import ( func TestState_FieldCount(t *testing.T) { count := params.BeaconConfig().BeaconStateFieldCount - typ := reflect.TypeOf(statepb.BeaconState{}) + typ := reflect.TypeOf(ethpb.BeaconState{}) numFields := 0 for i := 0; i < typ.NumField(); i++ { if typ.Field(i).Name == "state" || @@ -59,7 +58,7 @@ func BenchmarkHashTreeRoot_Generic_300000(b *testing.B) { } } -func setupGenesisState(tb testing.TB, count uint64) *statepb.BeaconState { +func setupGenesisState(tb testing.TB, count uint64) *ethpb.BeaconState { genesisState, _, err := interop.GenerateGenesisState(context.Background(), 0, 1) require.NoError(tb, err, "Could not generate genesis beacon state") for i := uint64(1); i < count; i++ { diff --git a/beacon-chain/state/v1/field_roots.go b/beacon-chain/state/v1/field_roots.go index 7ec0e660b5..3c62592dac 100644 --- a/beacon-chain/state/v1/field_roots.go +++ b/beacon-chain/state/v1/field_roots.go @@ -8,7 +8,7 @@ import ( "github.com/dgraph-io/ristretto" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -49,14 +49,14 @@ type stateRootHasher struct { // computeFieldRoots returns the hash tree root computations of every field in // the beacon state as a list of 32 byte roots. -func computeFieldRoots(ctx context.Context, state *statepb.BeaconState) ([][]byte, error) { +func computeFieldRoots(ctx context.Context, state *ethpb.BeaconState) ([][]byte, error) { if featureconfig.Get().EnableSSZCache { return cachedHasher.computeFieldRootsWithHasher(ctx, state) } return nocachedHasher.computeFieldRootsWithHasher(ctx, state) } -func (h *stateRootHasher) computeFieldRootsWithHasher(ctx context.Context, state *statepb.BeaconState) ([][]byte, error) { +func (h *stateRootHasher) computeFieldRootsWithHasher(ctx context.Context, state *ethpb.BeaconState) ([][]byte, error) { ctx, span := trace.StartSpan(ctx, "beaconState.computeFieldRootsWithHasher") defer span.End() diff --git a/beacon-chain/state/v1/field_trie_helpers.go b/beacon-chain/state/v1/field_trie_helpers.go index 31d651bcd5..5b898565e0 100644 --- a/beacon-chain/state/v1/field_trie_helpers.go +++ b/beacon-chain/state/v1/field_trie_helpers.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/hashutil" ) @@ -53,10 +52,10 @@ func fieldConverters(field fieldIndex, indices []uint64, elements interface{}, c } return stateutil.HandleValidatorSlice(val, indices, convertAll) case previousEpochAttestations, currentEpochAttestations: - val, ok := elements.([]*statepb.PendingAttestation) + val, ok := elements.([]*ethpb.PendingAttestation) if !ok { return nil, errors.Errorf("Wanted type of %v but got %v", - reflect.TypeOf([]*statepb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name()) + reflect.TypeOf([]*ethpb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name()) } return handlePendingAttestation(val, indices, convertAll) default: @@ -103,14 +102,14 @@ func HandleEth1DataSlice(val []*ethpb.Eth1Data, indices []uint64, convertAll boo return roots, nil } -func handlePendingAttestation(val []*statepb.PendingAttestation, indices []uint64, convertAll bool) ([][32]byte, error) { +func handlePendingAttestation(val []*ethpb.PendingAttestation, indices []uint64, convertAll bool) ([][32]byte, error) { length := len(indices) if convertAll { length = len(val) } roots := make([][32]byte, 0, length) hasher := hashutil.CustomSHA256Hasher() - rootCreator := func(input *statepb.PendingAttestation) error { + rootCreator := func(input *ethpb.PendingAttestation) error { newRoot, err := stateutil.PendingAttRootWithHasher(hasher, input) if err != nil { return err diff --git a/beacon-chain/state/v1/getters_attestation.go b/beacon-chain/state/v1/getters_attestation.go index d0186fba9b..ee04b4b044 100644 --- a/beacon-chain/state/v1/getters_attestation.go +++ b/beacon-chain/state/v1/getters_attestation.go @@ -7,14 +7,14 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" "github.com/prysmaticlabs/prysm/shared/params" ) // PreviousEpochAttestations corresponding to blocks on the beacon chain. -func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) { +func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { if !b.hasInnerState() { return nil, nil } @@ -30,7 +30,7 @@ func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation // previousEpochAttestations corresponding to blocks on the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) previousEpochAttestations() []*statepb.PendingAttestation { +func (b *BeaconState) previousEpochAttestations() []*ethpb.PendingAttestation { if !b.hasInnerState() { return nil } @@ -39,7 +39,7 @@ func (b *BeaconState) previousEpochAttestations() []*statepb.PendingAttestation } // CurrentEpochAttestations corresponding to blocks on the beacon chain. -func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) { +func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { if !b.hasInnerState() { return nil, nil } @@ -55,7 +55,7 @@ func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, // currentEpochAttestations corresponding to blocks on the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) currentEpochAttestations() []*statepb.PendingAttestation { +func (b *BeaconState) currentEpochAttestations() []*ethpb.PendingAttestation { if !b.hasInnerState() { return nil } @@ -63,7 +63,7 @@ func (b *BeaconState) currentEpochAttestations() []*statepb.PendingAttestation { return b.safeCopyPendingAttestationSlice(b.state.CurrentEpochAttestations) } -func (h *stateRootHasher) epochAttestationsRoot(atts []*statepb.PendingAttestation) ([32]byte, error) { +func (h *stateRootHasher) epochAttestationsRoot(atts []*ethpb.PendingAttestation) ([32]byte, error) { max := uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().MaxAttestations if uint64(len(atts)) > max { return [32]byte{}, fmt.Errorf("epoch attestation exceeds max length %d", max) @@ -99,7 +99,7 @@ func (h *stateRootHasher) epochAttestationsRoot(atts []*statepb.PendingAttestati return res, nil } -func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *statepb.PendingAttestation) ([32]byte, error) { +func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) { if att == nil { return [32]byte{}, errors.New("nil pending attestation") } diff --git a/beacon-chain/state/v1/getters_attestation_test.go b/beacon-chain/state/v1/getters_attestation_test.go index f79142f629..b054c841b9 100644 --- a/beacon-chain/state/v1/getters_attestation_test.go +++ b/beacon-chain/state/v1/getters_attestation_test.go @@ -3,19 +3,19 @@ package v1 import ( "testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_PreviousEpochAttestations(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) atts, err := s.PreviousEpochAttestations() require.NoError(t, err) - require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts) + require.DeepEqual(t, []*ethpb.PendingAttestation(nil), atts) - want := []*statepb.PendingAttestation{{ProposerIndex: 100}} - s, err = InitializeFromProto(&statepb.BeaconState{PreviousEpochAttestations: want}) + want := []*ethpb.PendingAttestation{{ProposerIndex: 100}} + s, err = InitializeFromProto(ðpb.BeaconState{PreviousEpochAttestations: want}) require.NoError(t, err) got, err := s.PreviousEpochAttestations() require.NoError(t, err) @@ -27,14 +27,14 @@ func TestBeaconState_PreviousEpochAttestations(t *testing.T) { } func TestBeaconState_CurrentEpochAttestations(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) atts, err := s.CurrentEpochAttestations() require.NoError(t, err) - require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts) + require.DeepEqual(t, []*ethpb.PendingAttestation(nil), atts) - want := []*statepb.PendingAttestation{{ProposerIndex: 101}} - s, err = InitializeFromProto(&statepb.BeaconState{CurrentEpochAttestations: want}) + want := []*ethpb.PendingAttestation{{ProposerIndex: 101}} + s, err = InitializeFromProto(ðpb.BeaconState{CurrentEpochAttestations: want}) require.NoError(t, err) got, err := s.CurrentEpochAttestations() require.NoError(t, err) diff --git a/beacon-chain/state/v1/getters_block_test.go b/beacon-chain/state/v1/getters_block_test.go index 617751219e..eec1ec9c51 100644 --- a/beacon-chain/state/v1/getters_block_test.go +++ b/beacon-chain/state/v1/getters_block_test.go @@ -3,20 +3,20 @@ package v1 import ( "testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_LatestBlockHeader(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) got := s.LatestBlockHeader() require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got) want := &v1alpha1.BeaconBlockHeader{Slot: 100} - s, err = InitializeFromProto(&statepb.BeaconState{LatestBlockHeader: want}) + s, err = InitializeFromProto(ðpb.BeaconState{LatestBlockHeader: want}) require.NoError(t, err) got = s.LatestBlockHeader() require.DeepEqual(t, want, got) @@ -27,13 +27,13 @@ func TestBeaconState_LatestBlockHeader(t *testing.T) { } func TestBeaconState_BlockRoots(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) got := s.BlockRoots() require.DeepEqual(t, ([][]byte)(nil), got) want := [][]byte{{'a'}} - s, err = InitializeFromProto(&statepb.BeaconState{BlockRoots: want}) + s, err = InitializeFromProto(ðpb.BeaconState{BlockRoots: want}) require.NoError(t, err) got = s.BlockRoots() require.DeepEqual(t, want, got) @@ -44,14 +44,14 @@ func TestBeaconState_BlockRoots(t *testing.T) { } func TestBeaconState_BlockRootAtIndex(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) got, err := s.BlockRootAtIndex(0) require.NoError(t, err) require.DeepEqual(t, ([]byte)(nil), got) r := [][]byte{{'a'}} - s, err = InitializeFromProto(&statepb.BeaconState{BlockRoots: r}) + s, err = InitializeFromProto(ðpb.BeaconState{BlockRoots: r}) require.NoError(t, err) got, err = s.BlockRootAtIndex(0) require.NoError(t, err) diff --git a/beacon-chain/state/v1/getters_misc.go b/beacon-chain/state/v1/getters_misc.go index 08cf335d28..88bd2d068e 100644 --- a/beacon-chain/state/v1/getters_misc.go +++ b/beacon-chain/state/v1/getters_misc.go @@ -4,7 +4,7 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" @@ -92,7 +92,7 @@ func (b *BeaconState) slot() types.Slot { } // Fork version of the beacon chain. -func (b *BeaconState) Fork() *statepb.Fork { +func (b *BeaconState) Fork() *ethpb.Fork { if !b.hasInnerState() { return nil } @@ -108,7 +108,7 @@ func (b *BeaconState) Fork() *statepb.Fork { // fork version of the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) fork() *statepb.Fork { +func (b *BeaconState) fork() *ethpb.Fork { if !b.hasInnerState() { return nil } @@ -120,7 +120,7 @@ func (b *BeaconState) fork() *statepb.Fork { copy(prevVersion, b.state.Fork.PreviousVersion) currVersion := make([]byte, len(b.state.Fork.CurrentVersion)) copy(currVersion, b.state.Fork.CurrentVersion) - return &statepb.Fork{ + return ðpb.Fork{ PreviousVersion: prevVersion, CurrentVersion: currVersion, Epoch: b.state.Fork.Epoch, diff --git a/beacon-chain/state/v1/getters_state.go b/beacon-chain/state/v1/getters_state.go index 7a9ca2e095..82418b3928 100644 --- a/beacon-chain/state/v1/getters_state.go +++ b/beacon-chain/state/v1/getters_state.go @@ -7,7 +7,6 @@ import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // InnerStateUnsafe returns the pointer value of the underlying @@ -27,7 +26,7 @@ func (b *BeaconState) CloneInnerState() interface{} { b.lock.RLock() defer b.lock.RUnlock() - return &statepb.BeaconState{ + return ðpb.BeaconState{ GenesisTime: b.genesisTime(), GenesisValidatorsRoot: b.genesisValidatorRoot(), Slot: b.slot(), @@ -118,10 +117,10 @@ func (b *BeaconState) MarshalSSZ() ([]byte, error) { // ProtobufBeaconState transforms an input into beacon state in the form of protobuf. // Error is returned if the input is not type protobuf beacon state. -func ProtobufBeaconState(s interface{}) (*statepb.BeaconState, error) { - pbState, ok := s.(*statepb.BeaconState) +func ProtobufBeaconState(s interface{}) (*ethpb.BeaconState, error) { + pbState, ok := s.(*ethpb.BeaconState) if !ok { - return nil, errors.New("input is not type statepb.BeaconState") + return nil, errors.New("input is not type ethpb.BeaconState") } return pbState, nil } @@ -153,12 +152,12 @@ func (b *BeaconState) safeCopyBytesAtIndex(input [][]byte, idx uint64) ([]byte, return root, nil } -func (b *BeaconState) safeCopyPendingAttestationSlice(input []*statepb.PendingAttestation) []*statepb.PendingAttestation { +func (b *BeaconState) safeCopyPendingAttestationSlice(input []*ethpb.PendingAttestation) []*ethpb.PendingAttestation { if input == nil { return nil } - res := make([]*statepb.PendingAttestation, len(input)) + res := make([]*ethpb.PendingAttestation, len(input)) for i := 0; i < len(res); i++ { res[i] = copyutil.CopyPendingAttestation(input[i]) } diff --git a/beacon-chain/state/v1/getters_test.go b/beacon-chain/state/v1/getters_test.go index 0cd7d11065..73db5f82a7 100644 --- a/beacon-chain/state/v1/getters_test.go +++ b/beacon-chain/state/v1/getters_test.go @@ -7,13 +7,13 @@ import ( types "github.com/prysmaticlabs/eth2-types" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_SlotDataRace(t *testing.T) { - headState, err := InitializeFromProto(&statepb.BeaconState{Slot: 1}) + headState, err := InitializeFromProto(ðpb.BeaconState{Slot: 1}) require.NoError(t, err) wg := sync.WaitGroup{} @@ -81,7 +81,7 @@ func TestNilState_NoPanic(t *testing.T) { func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) { c1 := ð.Checkpoint{Epoch: 1} c2 := ð.Checkpoint{Epoch: 2} - beaconState, err := InitializeFromProto(&statepb.BeaconState{CurrentJustifiedCheckpoint: c1}) + beaconState, err := InitializeFromProto(ðpb.BeaconState{CurrentJustifiedCheckpoint: c1}) require.NoError(t, err) require.Equal(t, true, beaconState.MatchCurrentJustifiedCheckpoint(c1)) require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c2)) @@ -94,7 +94,7 @@ func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) { func TestBeaconState_MatchPreviousJustifiedCheckpt(t *testing.T) { c1 := ð.Checkpoint{Epoch: 1} c2 := ð.Checkpoint{Epoch: 2} - beaconState, err := InitializeFromProto(&statepb.BeaconState{PreviousJustifiedCheckpoint: c1}) + beaconState, err := InitializeFromProto(ðpb.BeaconState{PreviousJustifiedCheckpoint: c1}) require.NoError(t, err) require.NoError(t, err) require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c1)) @@ -106,7 +106,7 @@ func TestBeaconState_MatchPreviousJustifiedCheckpt(t *testing.T) { } func TestBeaconState_MarshalSSZ_NilState(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) s.state = nil _, err = s.MarshalSSZ() @@ -204,7 +204,7 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - s, err := InitializeFromProto(&statepb.BeaconState{}) + s, err := InitializeFromProto(ðpb.BeaconState{}) require.NoError(t, err) nKey := keyCreator([]byte{'A'}) tt.modifyFunc(s, nKey) diff --git a/beacon-chain/state/v1/getters_validator_test.go b/beacon-chain/state/v1/getters_validator_test.go index 1e6d6e4dcb..54e1828ba8 100644 --- a/beacon-chain/state/v1/getters_validator_test.go +++ b/beacon-chain/state/v1/getters_validator_test.go @@ -4,13 +4,13 @@ import ( "testing" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_ValidatorAtIndexReadOnly_HandlesNilSlice(t *testing.T) { - st, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ + st, err := v1.InitializeFromProtoUnsafe(ðpb.BeaconState{ Validators: nil, }) require.NoError(t, err) diff --git a/beacon-chain/state/v1/helpers_test.go b/beacon-chain/state/v1/helpers_test.go index 485af12e1d..e97578d460 100644 --- a/beacon-chain/state/v1/helpers_test.go +++ b/beacon-chain/state/v1/helpers_test.go @@ -4,12 +4,11 @@ import ( "testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) func Test_handlePendingAttestation_OutOfRange(t *testing.T) { - items := make([]*statepb.PendingAttestation, 1) + items := make([]*ethpb.PendingAttestation, 1) indices := []uint64{3} _, err := handlePendingAttestation(items, indices, false) assert.ErrorContains(t, "index 3 greater than number of pending attestations 1", err) diff --git a/beacon-chain/state/v1/references_test.go b/beacon-chain/state/v1/references_test.go index 59ec23e214..635e20cd42 100644 --- a/beacon-chain/state/v1/references_test.go +++ b/beacon-chain/state/v1/references_test.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/go-bitfield" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -20,7 +19,7 @@ import ( func TestStateReferenceSharing_Finalizer(t *testing.T) { // This test showcases the logic on a the RandaoMixes field with the GC finalizer. - a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{RandaoMixes: [][]byte{[]byte("foo")}}) + a, err := InitializeFromProtoUnsafe(ðpb.BeaconState{RandaoMixes: [][]byte{[]byte("foo")}}) require.NoError(t, err) assert.Equal(t, uint(1), a.sharedFieldReferences[randaoMixes].Refs(), "Expected a single reference for RANDAO mixes") @@ -46,7 +45,7 @@ func TestStateReferenceSharing_Finalizer(t *testing.T) { func TestStateReferenceCopy_NoUnexpectedRootsMutation(t *testing.T) { root1, root2 := bytesutil.ToBytes32([]byte("foo")), bytesutil.ToBytes32([]byte("bar")) - a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ + a, err := InitializeFromProtoUnsafe(ðpb.BeaconState{ BlockRoots: [][]byte{ root1[:], }, @@ -117,7 +116,7 @@ func TestStateReferenceCopy_NoUnexpectedRootsMutation(t *testing.T) { func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) { val1, val2 := []byte("foo"), []byte("bar") - a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ + a, err := InitializeFromProtoUnsafe(ðpb.BeaconState{ RandaoMixes: [][]byte{ val1, }, @@ -164,7 +163,7 @@ func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) { } func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { - assertAttFound := func(vals []*statepb.PendingAttestation, val uint64) { + assertAttFound := func(vals []*ethpb.PendingAttestation, val uint64) { for i := range vals { if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) { return @@ -173,7 +172,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { t.Log(string(debug.Stack())) t.Fatalf("Expected attestation not found (%v), want: %v", vals, val) } - assertAttNotFound := func(vals []*statepb.PendingAttestation, val uint64) { + assertAttNotFound := func(vals []*ethpb.PendingAttestation, val uint64) { for i := range vals { if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) { t.Log(string(debug.Stack())) @@ -183,13 +182,13 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { } } - a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{}) + a, err := InitializeFromProtoUnsafe(ðpb.BeaconState{}) require.NoError(t, err) assertRefCount(t, a, previousEpochAttestations, 1) assertRefCount(t, a, currentEpochAttestations, 1) // Update initial state. - atts := []*statepb.PendingAttestation{ + atts := []*ethpb.PendingAttestation{ {AggregationBits: bitfield.NewBitlist(1)}, {AggregationBits: bitfield.NewBitlist(2)}, } @@ -248,9 +247,9 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { assertAttNotFound(b.state.GetPreviousEpochAttestations(), 2) // Mutator should only affect calling state: a. - applyToEveryAttestation := func(state *statepb.BeaconState) { + applyToEveryAttestation := func(state *ethpb.BeaconState) { // One MUST copy on write. - atts = make([]*statepb.PendingAttestation, len(state.CurrentEpochAttestations)) + atts = make([]*ethpb.PendingAttestation, len(state.CurrentEpochAttestations)) copy(atts, state.CurrentEpochAttestations) state.CurrentEpochAttestations = atts for i := range state.GetCurrentEpochAttestations() { @@ -259,7 +258,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { state.CurrentEpochAttestations[i] = att } - atts = make([]*statepb.PendingAttestation, len(state.PreviousEpochAttestations)) + atts = make([]*ethpb.PendingAttestation, len(state.PreviousEpochAttestations)) copy(atts, state.PreviousEpochAttestations) state.PreviousEpochAttestations = atts for i := range state.GetPreviousEpochAttestations() { @@ -293,7 +292,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { } func TestValidatorReferences_RemainsConsistent(t *testing.T) { - a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ + a, err := InitializeFromProtoUnsafe(ðpb.BeaconState{ Validators: []*ethpb.Validator{ {PublicKey: []byte{'A'}}, {PublicKey: []byte{'B'}}, diff --git a/beacon-chain/state/v1/setters_attestation.go b/beacon-chain/state/v1/setters_attestation.go index b124b0d865..da423c3c76 100644 --- a/beacon-chain/state/v1/setters_attestation.go +++ b/beacon-chain/state/v1/setters_attestation.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -18,11 +18,11 @@ func (b *BeaconState) RotateAttestations() error { defer b.lock.Unlock() b.setPreviousEpochAttestations(b.currentEpochAttestations()) - b.setCurrentEpochAttestations([]*statepb.PendingAttestation{}) + b.setCurrentEpochAttestations([]*ethpb.PendingAttestation{}) return nil } -func (b *BeaconState) setPreviousEpochAttestations(val []*statepb.PendingAttestation) { +func (b *BeaconState) setPreviousEpochAttestations(val []*ethpb.PendingAttestation) { b.sharedFieldReferences[previousEpochAttestations].MinusRef() b.sharedFieldReferences[previousEpochAttestations] = stateutil.NewRef(1) @@ -31,7 +31,7 @@ func (b *BeaconState) setPreviousEpochAttestations(val []*statepb.PendingAttesta b.rebuildTrie[previousEpochAttestations] = true } -func (b *BeaconState) setCurrentEpochAttestations(val []*statepb.PendingAttestation) { +func (b *BeaconState) setCurrentEpochAttestations(val []*ethpb.PendingAttestation) { b.sharedFieldReferences[currentEpochAttestations].MinusRef() b.sharedFieldReferences[currentEpochAttestations] = stateutil.NewRef(1) @@ -42,7 +42,7 @@ func (b *BeaconState) setCurrentEpochAttestations(val []*statepb.PendingAttestat // AppendCurrentEpochAttestations for the beacon state. Appends the new value // to the the end of list. -func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error { +func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error { if !b.hasInnerState() { return ErrNilInnerState } @@ -57,7 +57,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttesta if b.sharedFieldReferences[currentEpochAttestations].Refs() > 1 { // Copy elements in underlying array by reference. - atts = make([]*statepb.PendingAttestation, len(b.state.CurrentEpochAttestations)) + atts = make([]*ethpb.PendingAttestation, len(b.state.CurrentEpochAttestations)) copy(atts, b.state.CurrentEpochAttestations) b.sharedFieldReferences[currentEpochAttestations].MinusRef() b.sharedFieldReferences[currentEpochAttestations] = stateutil.NewRef(1) @@ -71,7 +71,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttesta // AppendPreviousEpochAttestations for the beacon state. Appends the new value // to the the end of list. -func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error { +func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error { if !b.hasInnerState() { return ErrNilInnerState } @@ -85,7 +85,7 @@ func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttest } if b.sharedFieldReferences[previousEpochAttestations].Refs() > 1 { - atts = make([]*statepb.PendingAttestation, len(b.state.PreviousEpochAttestations)) + atts = make([]*ethpb.PendingAttestation, len(b.state.PreviousEpochAttestations)) copy(atts, b.state.PreviousEpochAttestations) b.sharedFieldReferences[previousEpochAttestations].MinusRef() b.sharedFieldReferences[previousEpochAttestations] = stateutil.NewRef(1) diff --git a/beacon-chain/state/v1/setters_attestation_test.go b/beacon-chain/state/v1/setters_attestation_test.go index 299201c7d6..688f245e2b 100644 --- a/beacon-chain/state/v1/setters_attestation_test.go +++ b/beacon-chain/state/v1/setters_attestation_test.go @@ -6,17 +6,17 @@ import ( types "github.com/prysmaticlabs/eth2-types" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_RotateAttestations(t *testing.T) { - st, err := InitializeFromProto(&statepb.BeaconState{ + st, err := InitializeFromProto(ðpb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, }) require.NoError(t, err) @@ -40,10 +40,10 @@ func TestAppendBeyondIndicesLimit(t *testing.T) { for i := 0; i < len(mockrandaoMixes); i++ { mockrandaoMixes[i] = zeroHash[:] } - st, err := InitializeFromProto(&statepb.BeaconState{ + st, err := InitializeFromProto(ðpb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, + CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, Validators: []*eth.Validator{}, Eth1Data: ð.Eth1Data{}, BlockRoots: mockblockRoots, diff --git a/beacon-chain/state/v1/setters_misc.go b/beacon-chain/state/v1/setters_misc.go index a4bfe081a2..70972fc490 100644 --- a/beacon-chain/state/v1/setters_misc.go +++ b/beacon-chain/state/v1/setters_misc.go @@ -4,7 +4,7 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/hashutil" "google.golang.org/protobuf/proto" ) @@ -71,14 +71,14 @@ func (b *BeaconState) SetSlot(val types.Slot) error { } // SetFork version for the beacon chain. -func (b *BeaconState) SetFork(val *statepb.Fork) error { +func (b *BeaconState) SetFork(val *ethpb.Fork) error { if !b.hasInnerState() { return ErrNilInnerState } b.lock.Lock() defer b.lock.Unlock() - fk, ok := proto.Clone(val).(*statepb.Fork) + fk, ok := proto.Clone(val).(*ethpb.Fork) if !ok { return errors.New("proto.Clone did not return a fork proto") } diff --git a/beacon-chain/state/v1/state_test.go b/beacon-chain/state/v1/state_test.go index 88948c46e6..0f9e059649 100644 --- a/beacon-chain/state/v1/state_test.go +++ b/beacon-chain/state/v1/state_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -60,7 +59,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) { WithdrawableEpoch: 1, }) } - st, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ + st, err := InitializeFromProtoUnsafe(ðpb.BeaconState{ Validators: vals, }) assert.NoError(t, err) @@ -102,6 +101,6 @@ func TestStateTrie_IsNil(t *testing.T) { emptyProto := &BeaconState{state: nil} assert.Equal(t, true, emptyProto.IsNil()) - nonNilState := &BeaconState{state: &statepb.BeaconState{}} + nonNilState := &BeaconState{state: ðpb.BeaconState{}} assert.Equal(t, false, nonNilState.IsNil()) } diff --git a/beacon-chain/state/v1/state_trie.go b/beacon-chain/state/v1/state_trie.go index 0fbfc3d236..e8053210c8 100644 --- a/beacon-chain/state/v1/state_trie.go +++ b/beacon-chain/state/v1/state_trie.go @@ -12,7 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" @@ -30,13 +30,13 @@ var ( ) // InitializeFromProto the beacon state from a protobuf representation. -func InitializeFromProto(st *statepb.BeaconState) (*BeaconState, error) { - return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconState)) +func InitializeFromProto(st *ethpb.BeaconState) (*BeaconState, error) { + return InitializeFromProtoUnsafe(proto.Clone(st).(*ethpb.BeaconState)) } // InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer // and sets it as the inner state of the BeaconState type. -func InitializeFromProtoUnsafe(st *statepb.BeaconState) (*BeaconState, error) { +func InitializeFromProtoUnsafe(st *ethpb.BeaconState) (*BeaconState, error) { if st == nil { return nil, errors.New("received nil state") } @@ -89,7 +89,7 @@ func (b *BeaconState) Copy() state.BeaconState { defer b.lock.RUnlock() fieldCount := params.BeaconConfig().BeaconStateFieldCount dst := &BeaconState{ - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ // Primitive types, safe to copy. GenesisTime: b.state.GenesisTime, Slot: b.state.Slot, diff --git a/beacon-chain/state/v1/state_trie_test.go b/beacon-chain/state/v1/state_trie_test.go index 116c19d592..ddf482cd2e 100644 --- a/beacon-chain/state/v1/state_trie_test.go +++ b/beacon-chain/state/v1/state_trie_test.go @@ -10,7 +10,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -24,7 +24,7 @@ func TestInitializeFromProto(t *testing.T) { require.NoError(t, err) type test struct { name string - state *statepb.BeaconState + state *ethpb.BeaconState error string } initTests := []test{ @@ -35,14 +35,14 @@ func TestInitializeFromProto(t *testing.T) { }, { name: "nil validators", - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &statepb.BeaconState{}, + state: ðpb.BeaconState{}, }, { name: "full state", @@ -67,7 +67,7 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { require.NoError(t, err) type test struct { name string - state *statepb.BeaconState + state *ethpb.BeaconState error string } initTests := []test{ @@ -78,14 +78,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { }, { name: "nil validators", - state: &statepb.BeaconState{ + state: ðpb.BeaconState{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &statepb.BeaconState{}, + state: ðpb.BeaconState{}, }, { name: "full state", @@ -256,11 +256,11 @@ func TestBeaconState_AppendValidator_DoesntMutateCopy(t *testing.T) { } func TestBeaconState_ToProto(t *testing.T) { - source, err := testutil.NewBeaconState(testutil.FillRootsNaturalOpt, func(state *statepb.BeaconState) error { + source, err := testutil.NewBeaconState(testutil.FillRootsNaturalOpt, func(state *ethpb.BeaconState) error { state.GenesisTime = 1 state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorroot"), 32) state.Slot = 2 - state.Fork = &statepb.Fork{ + state.Fork = ðpb.Fork{ PreviousVersion: bytesutil.PadTo([]byte("123"), 4), CurrentVersion: bytesutil.PadTo([]byte("456"), 4), Epoch: 3, @@ -299,7 +299,7 @@ func TestBeaconState_ToProto(t *testing.T) { state.Balances = []uint64{14} state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)} state.Slashings = []uint64{15} - state.PreviousEpochAttestations = []*statepb.PendingAttestation{{ + state.PreviousEpochAttestations = []*ethpb.PendingAttestation{{ AggregationBits: bitfield.Bitlist{16}, Data: ð.AttestationData{ Slot: 17, @@ -317,7 +317,7 @@ func TestBeaconState_ToProto(t *testing.T) { InclusionDelay: 21, ProposerIndex: 22, }} - state.CurrentEpochAttestations = []*statepb.PendingAttestation{{ + state.CurrentEpochAttestations = []*ethpb.PendingAttestation{{ AggregationBits: bitfield.Bitlist{23}, Data: ð.AttestationData{ Slot: 24, diff --git a/beacon-chain/state/v1/types.go b/beacon-chain/state/v1/types.go index 03bf8be41c..3c1818ac77 100644 --- a/beacon-chain/state/v1/types.go +++ b/beacon-chain/state/v1/types.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -79,7 +79,7 @@ var ErrNilInnerState = errors.New("nil inner state") // BeaconState defines a struct containing utilities for the Ethereum Beacon Chain state, defining // getters and setters for its respective values and helpful functions such as HashTreeRoot(). type BeaconState struct { - state *statepb.BeaconState + state *ethpb.BeaconState lock sync.RWMutex dirtyFields map[fieldIndex]bool dirtyIndices map[fieldIndex][]uint64 diff --git a/beacon-chain/state/v1/types_test.go b/beacon-chain/state/v1/types_test.go index df7cb918a4..9ad7fb94ba 100644 --- a/beacon-chain/state/v1/types_test.go +++ b/beacon-chain/state/v1/types_test.go @@ -8,7 +8,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" @@ -24,8 +23,8 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) { genesis := setupGenesisState(t, 64) customState, err := v1.InitializeFromProto(genesis) require.NoError(t, err) - cloned, ok := proto.Clone(genesis).(*statepb.BeaconState) - assert.Equal(t, true, ok, "Object is not of type *statepb.BeaconState") + cloned, ok := proto.Clone(genesis).(*ethpb.BeaconState) + assert.Equal(t, true, ok, "Object is not of type *ethpb.BeaconState") custom := customState.CloneInnerState() assert.DeepSSZEqual(t, cloned, custom) @@ -51,7 +50,7 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) { assert.Equal(t, r1, r2, "Mismatched roots") } -func setupGenesisState(tb testing.TB, count uint64) *statepb.BeaconState { +func setupGenesisState(tb testing.TB, count uint64) *ethpb.BeaconState { genesisState, _, err := interop.GenerateGenesisState(context.Background(), 0, count) require.NoError(tb, err, "Could not generate genesis beacon state") for i := uint64(1); i < count; i++ { @@ -126,8 +125,8 @@ func BenchmarkStateClone_Proto(b *testing.B) { genesis := setupGenesisState(b, 64) b.StartTimer() for i := 0; i < b.N; i++ { - _, ok := proto.Clone(genesis).(*statepb.BeaconState) - assert.Equal(b, true, ok, "Entity is not of type *statepb.BeaconState") + _, ok := proto.Clone(genesis).(*ethpb.BeaconState) + assert.Equal(b, true, ok, "Entity is not of type *ethpb.BeaconState") } } @@ -214,7 +213,7 @@ func TestForkManualCopy_OK(t *testing.T) { genesis := setupGenesisState(t, 64) a, err := v1.InitializeFromProto(genesis) require.NoError(t, err) - wantedFork := &statepb.Fork{ + wantedFork := ðpb.Fork{ PreviousVersion: []byte{'a', 'b', 'c'}, CurrentVersion: []byte{'d', 'e', 'f'}, Epoch: 0, diff --git a/beacon-chain/state/v1/unsupported_getters.go b/beacon-chain/state/v1/unsupported_getters.go index 7793601b7c..00030e837c 100644 --- a/beacon-chain/state/v1/unsupported_getters.go +++ b/beacon-chain/state/v1/unsupported_getters.go @@ -2,7 +2,7 @@ package v1 import ( "github.com/pkg/errors" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // CurrentEpochParticipation is not supported for phase 0 beacon state. @@ -21,11 +21,11 @@ func (b *BeaconState) InactivityScores() ([]uint64, error) { } // CurrentSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) { +func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) { return nil, errors.New("CurrentSyncCommittee is not supported for phase 0 beacon state") } // NextSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) NextSyncCommittee() (*statepb.SyncCommittee, error) { +func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) { return nil, errors.New("NextSyncCommittee is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v1/unsupported_setters.go b/beacon-chain/state/v1/unsupported_setters.go index 6eeb928205..57cacdf3b4 100644 --- a/beacon-chain/state/v1/unsupported_setters.go +++ b/beacon-chain/state/v1/unsupported_setters.go @@ -2,7 +2,7 @@ package v1 import ( "github.com/pkg/errors" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // AppendCurrentParticipationBits is not supported for phase 0 beacon state. @@ -21,12 +21,12 @@ func (b *BeaconState) AppendInactivityScore(s uint64) error { } // SetCurrentSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error { +func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error { return errors.New("SetCurrentSyncCommittee is not supported for phase 0 beacon state") } // SetNextSyncCommittee is not supported for phase 0 beacon state. -func (b *BeaconState) SetNextSyncCommittee(val *statepb.SyncCommittee) error { +func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error { return errors.New("SetNextSyncCommittee is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v2/deprecated_getters.go b/beacon-chain/state/v2/deprecated_getters.go index 46c1a7da58..087b01a7f3 100644 --- a/beacon-chain/state/v2/deprecated_getters.go +++ b/beacon-chain/state/v2/deprecated_getters.go @@ -2,15 +2,15 @@ package v2 import ( "github.com/pkg/errors" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // PreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) { +func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("PreviousEpochAttestations is not supported for hard fork 1 beacon state") } // CurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) { +func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) { return nil, errors.New("CurrentEpochAttestations is not supported for hard fork 1 beacon state") } diff --git a/beacon-chain/state/v2/deprecated_setters.go b/beacon-chain/state/v2/deprecated_setters.go index 0784eee8fa..8766c684e1 100644 --- a/beacon-chain/state/v2/deprecated_setters.go +++ b/beacon-chain/state/v2/deprecated_setters.go @@ -3,26 +3,26 @@ package v2 import ( "github.com/pkg/errors" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) // SetPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetPreviousEpochAttestations(val []*statepb.PendingAttestation) error { +func (b *BeaconState) SetPreviousEpochAttestations(val []*ethpb.PendingAttestation) error { return errors.New("SetPreviousEpochAttestations is not supported for hard fork 1 beacon state") } // SetCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetCurrentEpochAttestations(val []*statepb.PendingAttestation) error { +func (b *BeaconState) SetCurrentEpochAttestations(val []*ethpb.PendingAttestation) error { return errors.New("SetCurrentEpochAttestations is not supported for hard fork 1 beacon state") } // AppendCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error { +func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error { return errors.New("AppendCurrentEpochAttestations is not supported for hard fork 1 beacon state") } // AppendPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error { +func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error { return errors.New("AppendPreviousEpochAttestations is not supported for hard fork 1 beacon state") } diff --git a/beacon-chain/state/v2/field_root_sync_committee.go b/beacon-chain/state/v2/field_root_sync_committee.go index 37e5172f62..611a9d118d 100644 --- a/beacon-chain/state/v2/field_root_sync_committee.go +++ b/beacon-chain/state/v2/field_root_sync_committee.go @@ -1,7 +1,7 @@ package v2 import ( - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" ) @@ -9,7 +9,7 @@ import ( // syncCommitteeRoot computes the HashTreeRoot Merkleization of a commitee root. // a SyncCommitteeRoot struct according to the eth2 // Simple Serialize specification. -func syncCommitteeRoot(committee *statepb.SyncCommittee) ([32]byte, error) { +func syncCommitteeRoot(committee *ethpb.SyncCommittee) ([32]byte, error) { hasher := hashutil.CustomSHA256Hasher() var fieldRoots [][32]byte if committee == nil { diff --git a/beacon-chain/state/v2/field_roots.go b/beacon-chain/state/v2/field_roots.go index 63e3a628d0..49c23f0511 100644 --- a/beacon-chain/state/v2/field_roots.go +++ b/beacon-chain/state/v2/field_roots.go @@ -7,7 +7,7 @@ import ( "github.com/dgraph-io/ristretto" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -47,14 +47,14 @@ type stateRootHasher struct { // computeFieldRoots returns the hash tree root computations of every field in // the beacon state as a list of 32 byte roots. -func computeFieldRoots(state *statepb.BeaconStateAltair) ([][]byte, error) { +func computeFieldRoots(state *ethpb.BeaconStateAltair) ([][]byte, error) { if featureconfig.Get().EnableSSZCache { return cachedHasher.computeFieldRootsWithHasher(state) } return nocachedHasher.computeFieldRootsWithHasher(state) } -func (h *stateRootHasher) computeFieldRootsWithHasher(state *statepb.BeaconStateAltair) ([][]byte, error) { +func (h *stateRootHasher) computeFieldRootsWithHasher(state *ethpb.BeaconStateAltair) ([][]byte, error) { if state == nil { return nil, errors.New("nil state") } diff --git a/beacon-chain/state/v2/getters.go b/beacon-chain/state/v2/getters.go index ed919ce700..39fefa88f0 100644 --- a/beacon-chain/state/v2/getters.go +++ b/beacon-chain/state/v2/getters.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -35,7 +34,7 @@ func (b *BeaconState) CloneInnerState() interface{} { b.lock.RLock() defer b.lock.RUnlock() - return &statepb.BeaconStateAltair{ + return ðpb.BeaconStateAltair{ GenesisTime: b.genesisTime(), GenesisValidatorsRoot: b.genesisValidatorRoot(), Slot: b.slot(), @@ -166,7 +165,7 @@ func (b *BeaconState) slot() types.Slot { } // Fork version of the beacon chain. -func (b *BeaconState) Fork() *statepb.Fork { +func (b *BeaconState) Fork() *ethpb.Fork { if !b.hasInnerState() { return nil } @@ -182,7 +181,7 @@ func (b *BeaconState) Fork() *statepb.Fork { // fork version of the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) fork() *statepb.Fork { +func (b *BeaconState) fork() *ethpb.Fork { if !b.hasInnerState() { return nil } @@ -194,7 +193,7 @@ func (b *BeaconState) fork() *statepb.Fork { copy(prevVersion, b.state.Fork.PreviousVersion) currVersion := make([]byte, len(b.state.Fork.CurrentVersion)) copy(currVersion, b.state.Fork.CurrentVersion) - return &statepb.Fork{ + return ðpb.Fork{ PreviousVersion: prevVersion, CurrentVersion: currVersion, Epoch: b.state.Fork.Epoch, @@ -979,7 +978,7 @@ func (b *BeaconState) FinalizedCheckpointEpoch() types.Epoch { // currentSyncCommittee of the current sync committee in beacon chain state. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) currentSyncCommittee() *statepb.SyncCommittee { +func (b *BeaconState) currentSyncCommittee() *ethpb.SyncCommittee { if !b.hasInnerState() { return nil } @@ -989,7 +988,7 @@ func (b *BeaconState) currentSyncCommittee() *statepb.SyncCommittee { // nextSyncCommittee of the next sync committee in beacon chain state. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) nextSyncCommittee() *statepb.SyncCommittee { +func (b *BeaconState) nextSyncCommittee() *ethpb.SyncCommittee { if !b.hasInnerState() { return nil } @@ -998,7 +997,7 @@ func (b *BeaconState) nextSyncCommittee() *statepb.SyncCommittee { } // CurrentSyncCommittee of the current sync committee in beacon chain state. -func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) { +func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) { if !b.hasInnerState() { return nil, nil } @@ -1014,7 +1013,7 @@ func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) { } // NextSyncCommittee of the next sync committee in beacon chain state. -func (b *BeaconState) NextSyncCommittee() (*statepb.SyncCommittee, error) { +func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) { if !b.hasInnerState() { return nil, nil } @@ -1156,8 +1155,8 @@ func (b *BeaconState) MarshalSSZ() ([]byte, error) { // ProtobufBeaconState transforms an input into beacon state hard fork 1 in the form of protobuf. // Error is returned if the input is not type protobuf beacon state. -func ProtobufBeaconState(s interface{}) (*statepb.BeaconStateAltair, error) { - pbState, ok := s.(*statepb.BeaconStateAltair) +func ProtobufBeaconState(s interface{}) (*ethpb.BeaconStateAltair, error) { + pbState, ok := s.(*ethpb.BeaconStateAltair) if !ok { return nil, errors.New("input is not type pb.BeaconStateAltair") } @@ -1170,11 +1169,11 @@ func (b *BeaconState) Version() int { } // CopySyncCommittee copies the provided sync committee object. -func CopySyncCommittee(data *statepb.SyncCommittee) *statepb.SyncCommittee { +func CopySyncCommittee(data *ethpb.SyncCommittee) *ethpb.SyncCommittee { if data == nil { return nil } - return &statepb.SyncCommittee{ + return ðpb.SyncCommittee{ Pubkeys: bytesutil.Copy2dBytes(data.Pubkeys), AggregatePubkey: bytesutil.SafeCopyBytes(data.AggregatePubkey), } diff --git a/beacon-chain/state/v2/getters_test.go b/beacon-chain/state/v2/getters_test.go index 179246a414..f71b9ebf85 100644 --- a/beacon-chain/state/v2/getters_test.go +++ b/beacon-chain/state/v2/getters_test.go @@ -5,12 +5,12 @@ import ( "sync" "testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_SlotDataRace(t *testing.T) { - headState, err := InitializeFromProto(&statepb.BeaconStateAltair{Slot: 1}) + headState, err := InitializeFromProto(ðpb.BeaconStateAltair{Slot: 1}) require.NoError(t, err) wg := sync.WaitGroup{} diff --git a/beacon-chain/state/v2/setters.go b/beacon-chain/state/v2/setters.go index 1b3698ff6a..9f2f9dcc38 100644 --- a/beacon-chain/state/v2/setters.go +++ b/beacon-chain/state/v2/setters.go @@ -8,7 +8,6 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -69,14 +68,14 @@ func (b *BeaconState) SetSlot(val types.Slot) error { } // SetFork version for the beacon chain. -func (b *BeaconState) SetFork(val *statepb.Fork) error { +func (b *BeaconState) SetFork(val *ethpb.Fork) error { if !b.hasInnerState() { return ErrNilInnerState } b.lock.Lock() defer b.lock.Unlock() - fk, ok := proto.Clone(val).(*statepb.Fork) + fk, ok := proto.Clone(val).(*ethpb.Fork) if !ok { return errors.New("proto.Clone did not return a fork proto") } @@ -704,7 +703,7 @@ func (b *BeaconState) SetFinalizedCheckpoint(val *ethpb.Checkpoint) error { } // SetCurrentSyncCommittee for the beacon state. -func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error { +func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error { if !b.hasInnerState() { return ErrNilInnerState } @@ -717,7 +716,7 @@ func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error } // SetNextSyncCommittee for the beacon state. -func (b *BeaconState) SetNextSyncCommittee(val *statepb.SyncCommittee) error { +func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error { if !b.hasInnerState() { return ErrNilInnerState } diff --git a/beacon-chain/state/v2/state_trie.go b/beacon-chain/state/v2/state_trie.go index b1f4900b16..002b2b7a60 100644 --- a/beacon-chain/state/v2/state_trie.go +++ b/beacon-chain/state/v2/state_trie.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" @@ -20,13 +20,13 @@ import ( ) // InitializeFromProto the beacon state from a protobuf representation. -func InitializeFromProto(st *statepb.BeaconStateAltair) (*BeaconState, error) { - return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconStateAltair)) +func InitializeFromProto(st *ethpb.BeaconStateAltair) (*BeaconState, error) { + return InitializeFromProtoUnsafe(proto.Clone(st).(*ethpb.BeaconStateAltair)) } // InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer // and sets it as the inner state of the BeaconState type. -func InitializeFromProtoUnsafe(st *statepb.BeaconStateAltair) (*BeaconState, error) { +func InitializeFromProtoUnsafe(st *ethpb.BeaconStateAltair) (*BeaconState, error) { if st == nil { return nil, errors.New("received nil state") } @@ -80,7 +80,7 @@ func (b *BeaconState) Copy() state.BeaconState { fieldCount := params.BeaconConfig().BeaconStateAltairFieldCount dst := &BeaconState{ - state: &statepb.BeaconStateAltair{ + state: ðpb.BeaconStateAltair{ // Primitive types, safe to copy. GenesisTime: b.state.GenesisTime, Slot: b.state.Slot, @@ -355,7 +355,6 @@ func (b *BeaconState) recomputeFieldTrie(index fieldIndex, elements interface{}) if err != nil { return [32]byte{}, err } - b.dirtyIndices[index] = []uint64{} return root, nil } diff --git a/beacon-chain/state/v2/state_trie_test.go b/beacon-chain/state/v2/state_trie_test.go index d58f81020e..2aabc08be3 100644 --- a/beacon-chain/state/v2/state_trie_test.go +++ b/beacon-chain/state/v2/state_trie_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,7 +44,7 @@ func TestValidatorMap_DistinctCopy(t *testing.T) { func TestInitializeFromProto(t *testing.T) { type test struct { name string - state *statepb.BeaconStateAltair + state *ethpb.BeaconStateAltair error string } initTests := []test{ @@ -56,14 +55,14 @@ func TestInitializeFromProto(t *testing.T) { }, { name: "nil validators", - state: &statepb.BeaconStateAltair{ + state: ðpb.BeaconStateAltair{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &statepb.BeaconStateAltair{}, + state: ðpb.BeaconStateAltair{}, }, // TODO: Add full state. Blocked by testutil migration. } @@ -98,7 +97,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) { WithdrawableEpoch: 1, }) } - st, err := InitializeFromProtoUnsafe(&statepb.BeaconStateAltair{ + st, err := InitializeFromProtoUnsafe(ðpb.BeaconStateAltair{ Validators: vals, }) assert.NoError(t, err) @@ -136,7 +135,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) { func TestInitializeFromProtoUnsafe(t *testing.T) { type test struct { name string - state *statepb.BeaconStateAltair + state *ethpb.BeaconStateAltair error string } initTests := []test{ @@ -147,14 +146,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { }, { name: "nil validators", - state: &statepb.BeaconStateAltair{ + state: ðpb.BeaconStateAltair{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &statepb.BeaconStateAltair{}, + state: ðpb.BeaconStateAltair{}, }, // TODO: Add full state. Blocked by testutil migration. } diff --git a/beacon-chain/state/v2/types.go b/beacon-chain/state/v2/types.go index f949b5e65b..1d01f6cbd0 100644 --- a/beacon-chain/state/v2/types.go +++ b/beacon-chain/state/v2/types.go @@ -5,7 +5,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -76,7 +76,7 @@ var ErrNilInnerState = errors.New("nil inner state") // BeaconState defines a struct containing utilities for the eth2 chain state, defining // getters and setters for its respective values and helpful functions such as HashTreeRoot(). type BeaconState struct { - state *statepb.BeaconStateAltair + state *ethpb.BeaconStateAltair lock sync.RWMutex dirtyFields map[fieldIndex]interface{} dirtyIndices map[fieldIndex][]uint64 diff --git a/beacon-chain/sync/rpc_test.go b/beacon-chain/sync/rpc_test.go index 7b868263cd..f53a716f5e 100644 --- a/beacon-chain/sync/rpc_test.go +++ b/beacon-chain/sync/rpc_test.go @@ -12,7 +12,7 @@ import ( prysmP2P "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -58,7 +58,7 @@ func TestRegisterRPC_ReceivesValidMessage(t *testing.T) { wg.Add(1) topic := "/testing/foobar/1" handler := func(ctx context.Context, msg interface{}, stream libp2pcore.Stream) error { - m, ok := msg.(*statepb.Fork) + m, ok := msg.(*ethpb.Fork) if !ok { t.Error("Object is not of type *pb.TestSimpleMessage") } @@ -67,14 +67,14 @@ func TestRegisterRPC_ReceivesValidMessage(t *testing.T) { return nil } - prysmP2P.RPCTopicMappings[topic] = new(statepb.Fork) + prysmP2P.RPCTopicMappings[topic] = new(ethpb.Fork) // Cleanup Topic mappings defer func() { delete(prysmP2P.RPCTopicMappings, topic) }() r.registerRPC(topic, handler) - p2p.ReceiveRPC(topic, &statepb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")}) + p2p.ReceiveRPC(topic, ðpb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")}) if testutil.WaitTimeout(&wg, time.Second) { t.Fatal("Did not receive RPC in 1 second") diff --git a/fuzz/rpc_status_fuzz.go b/fuzz/rpc_status_fuzz.go index 792884e777..0000f8a48f 100644 --- a/fuzz/rpc_status_fuzz.go +++ b/fuzz/rpc_status_fuzz.go @@ -13,7 +13,6 @@ import ( regularsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/sirupsen/logrus" ) @@ -53,7 +52,7 @@ func init() { Chain: &mock.ChainService{ Root: bytesutil.PadTo([]byte("root"), 32), FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 4, Root: make([]byte, 32)}, - Fork: &statepb.Fork{CurrentVersion: []byte("foo")}, + Fork: ðpb.Fork{CurrentVersion: []byte("foo")}, }, StateNotifier: (&mock.ChainService{}).StateNotifier(), OperationNotifier: (&mock.ChainService{}).OperationNotifier(), diff --git a/fuzz/state_fuzz.go b/fuzz/state_fuzz.go index 79c388b884..dd688b3529 100644 --- a/fuzz/state_fuzz.go +++ b/fuzz/state_fuzz.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" stateutil "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -21,7 +21,7 @@ func init() { // BeaconStateFuzz -- func BeaconStateFuzz(input []byte) { params.UseMainnetConfig() - st := &statepb.BeaconState{} + st := ðpb.BeaconState{} if err := st.UnmarshalSSZ(input); err != nil { return } @@ -43,7 +43,7 @@ func BeaconStateFuzz(input []byte) { } func validateStateHTR(s *v1.BeaconState) { - rawState, ok := s.InnerStateUnsafe().(*statepb.BeaconState) + rawState, ok := s.InnerStateUnsafe().(*ethpb.BeaconState) if !ok { panic("non valid type assertion") } diff --git a/fuzz/testing/beacon_fuzz_states.go b/fuzz/testing/beacon_fuzz_states.go index a931dd092a..7cf517b12b 100644 --- a/fuzz/testing/beacon_fuzz_states.go +++ b/fuzz/testing/beacon_fuzz_states.go @@ -5,7 +5,7 @@ import ( "os" "strconv" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" ) @@ -13,7 +13,7 @@ const fileBase = "0-11-0/mainnet/beaconstate" const fileBaseENV = "BEACONSTATES_PATH" // BeaconFuzzState returns a beacon state by ID using the beacon-fuzz corpora. -func BeaconFuzzState(ID uint64) (*statepb.BeaconState, error) { +func BeaconFuzzState(ID uint64) (*ethpb.BeaconState, error) { base := fileBase // Using an environment variable allows a host image to specify the path when only the binary // executable was uploaded (without the runfiles). i.e. fuzzit's platform. @@ -31,7 +31,7 @@ func BeaconFuzzState(ID uint64) (*statepb.BeaconState, error) { if err != nil { return nil, err } - st := &statepb.BeaconState{} + st := ðpb.BeaconState{} if err := st.UnmarshalSSZ(b); err != nil { return nil, err } diff --git a/proto/prysm/v1alpha1/wrapper/beacon_block_test.go b/proto/prysm/v1alpha1/wrapper/beacon_block_test.go index f7bbf5b839..c560bc4e1c 100644 --- a/proto/prysm/v1alpha1/wrapper/beacon_block_test.go +++ b/proto/prysm/v1alpha1/wrapper/beacon_block_test.go @@ -5,7 +5,7 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -16,7 +16,7 @@ import ( func TestAltairSignedBeaconBlock_Signature(t *testing.T) { sig := []byte{0x11, 0x22} - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: &prysmv2.BeaconBlockAltair{}, Signature: sig}) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{}, Signature: sig}) require.NoError(t, err) if !bytes.Equal(sig, wsb.Signature()) { @@ -25,8 +25,8 @@ func TestAltairSignedBeaconBlock_Signature(t *testing.T) { } func TestAltairSignedBeaconBlock_Block(t *testing.T) { - blk := &prysmv2.BeaconBlockAltair{Slot: 54} - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: blk}) + blk := ðpb.BeaconBlockAltair{Slot: 54} + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: blk}) require.NoError(t, err) assert.DeepEqual(t, blk, wsb.Block().Proto()) @@ -36,7 +36,7 @@ func TestAltairSignedBeaconBlock_IsNil(t *testing.T) { _, err := wrapper.WrappedAltairSignedBeaconBlock(nil) require.Equal(t, wrapper.ErrNilObjectWrapped, err) - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: &prysmv2.BeaconBlockAltair{}}) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{}}) require.NoError(t, err) assert.Equal(t, false, wsb.IsNil()) @@ -47,8 +47,8 @@ func TestAltairSignedBeaconBlock_Copy(t *testing.T) { } func TestAltairSignedBeaconBlock_Proto(t *testing.T) { - sb := &prysmv2.SignedBeaconBlockAltair{ - Block: &prysmv2.BeaconBlockAltair{Slot: 66}, + sb := ðpb.SignedBeaconBlockAltair{ + Block: ðpb.BeaconBlockAltair{Slot: 66}, Signature: []byte{0x11, 0x22}, } wsb, err := wrapper.WrappedAltairSignedBeaconBlock(sb) @@ -58,7 +58,7 @@ func TestAltairSignedBeaconBlock_Proto(t *testing.T) { } func TestAltairSignedBeaconBlock_PbPhase0Block(t *testing.T) { - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: &prysmv2.BeaconBlockAltair{}}) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{}}) require.NoError(t, err) if _, err := wsb.PbPhase0Block(); err != wrapper.ErrUnsupportedPhase0Block { @@ -67,8 +67,8 @@ func TestAltairSignedBeaconBlock_PbPhase0Block(t *testing.T) { } func TestAltairSignedBeaconBlock_PbAltairBlock(t *testing.T) { - sb := &prysmv2.SignedBeaconBlockAltair{ - Block: &prysmv2.BeaconBlockAltair{Slot: 66}, + sb := ðpb.SignedBeaconBlockAltair{ + Block: ðpb.BeaconBlockAltair{Slot: 66}, Signature: []byte{0x11, 0x22}, } wsb, err := wrapper.WrappedAltairSignedBeaconBlock(sb) @@ -80,7 +80,7 @@ func TestAltairSignedBeaconBlock_PbAltairBlock(t *testing.T) { } func TestAltairSignedBeaconBlock_MarshalSSZTo(t *testing.T) { - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(testutil.HydrateSignedBeaconBlockAltair(&prysmv2.SignedBeaconBlockAltair{})) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(testutil.HydrateSignedBeaconBlockAltair(ðpb.SignedBeaconBlockAltair{})) assert.NoError(t, err) b := []byte{} @@ -90,7 +90,7 @@ func TestAltairSignedBeaconBlock_MarshalSSZTo(t *testing.T) { } func TestAltairSignedBeaconBlock_SSZ(t *testing.T) { - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(testutil.HydrateSignedBeaconBlockAltair(&prysmv2.SignedBeaconBlockAltair{})) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(testutil.HydrateSignedBeaconBlockAltair(ðpb.SignedBeaconBlockAltair{})) assert.NoError(t, err) b, err := wsb.MarshalSSZ() @@ -103,7 +103,7 @@ func TestAltairSignedBeaconBlock_SSZ(t *testing.T) { } func TestAltairSignedBeaconBlock_Version(t *testing.T) { - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: &prysmv2.BeaconBlockAltair{}}) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{}}) require.NoError(t, err) assert.Equal(t, version.Altair, wsb.Version()) @@ -111,7 +111,7 @@ func TestAltairSignedBeaconBlock_Version(t *testing.T) { func TestAltairBeaconBlock_Slot(t *testing.T) { slot := types.Slot(546) - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{Slot: slot}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{Slot: slot}) require.NoError(t, err) assert.Equal(t, slot, wb.Slot()) @@ -119,7 +119,7 @@ func TestAltairBeaconBlock_Slot(t *testing.T) { func TestAltairBeaconBlock_ProposerIndex(t *testing.T) { pi := types.ValidatorIndex(555) - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{ProposerIndex: pi}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{ProposerIndex: pi}) require.NoError(t, err) assert.Equal(t, pi, wb.ProposerIndex()) @@ -127,7 +127,7 @@ func TestAltairBeaconBlock_ProposerIndex(t *testing.T) { func TestAltairBeaconBlock_ParentRoot(t *testing.T) { root := []byte{0xAA, 0xBF, 0x33, 0x01} - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{ParentRoot: root}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{ParentRoot: root}) require.NoError(t, err) assert.DeepEqual(t, root, wb.ParentRoot()) @@ -135,15 +135,15 @@ func TestAltairBeaconBlock_ParentRoot(t *testing.T) { func TestAltairBeaconBlock_StateRoot(t *testing.T) { root := []byte{0xAA, 0xBF, 0x33, 0x01} - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{StateRoot: root}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{StateRoot: root}) require.NoError(t, err) assert.DeepEqual(t, root, wb.StateRoot()) } func TestAltairBeaconBlock_Body(t *testing.T) { - body := &prysmv2.BeaconBlockBodyAltair{Graffiti: []byte{0x44}} - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{Body: body}) + body := ðpb.BeaconBlockBodyAltair{Graffiti: []byte{0x44}} + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{Body: body}) require.NoError(t, err) assert.Equal(t, body, wb.Body().Proto()) @@ -153,14 +153,14 @@ func TestAltairBeaconBlock_IsNil(t *testing.T) { _, err := wrapper.WrappedAltairBeaconBlock(nil) require.Equal(t, wrapper.ErrNilObjectWrapped, err) - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{}) require.NoError(t, err) assert.Equal(t, false, wb.IsNil()) } func TestAltairBeaconBlock_HashTreeRoot(t *testing.T) { - wb, err := wrapper.WrappedAltairBeaconBlock(testutil.HydrateBeaconBlockAltair(&prysmv2.BeaconBlockAltair{})) + wb, err := wrapper.WrappedAltairBeaconBlock(testutil.HydrateBeaconBlockAltair(ðpb.BeaconBlockAltair{})) require.NoError(t, err) rt, err := wb.HashTreeRoot() @@ -169,7 +169,7 @@ func TestAltairBeaconBlock_HashTreeRoot(t *testing.T) { } func TestAltairBeaconBlock_Proto(t *testing.T) { - blk := &prysmv2.BeaconBlockAltair{ProposerIndex: 234} + blk := ðpb.BeaconBlockAltair{ProposerIndex: 234} wb, err := wrapper.WrappedAltairBeaconBlock(blk) require.NoError(t, err) @@ -177,7 +177,7 @@ func TestAltairBeaconBlock_Proto(t *testing.T) { } func TestAltairBeaconBlock_SSZ(t *testing.T) { - wb, err := wrapper.WrappedAltairBeaconBlock(testutil.HydrateBeaconBlockAltair(&prysmv2.BeaconBlockAltair{})) + wb, err := wrapper.WrappedAltairBeaconBlock(testutil.HydrateBeaconBlockAltair(ðpb.BeaconBlockAltair{})) assert.NoError(t, err) b, err := wb.MarshalSSZ() @@ -190,7 +190,7 @@ func TestAltairBeaconBlock_SSZ(t *testing.T) { } func TestAltairBeaconBlock_Version(t *testing.T) { - wb, err := wrapper.WrappedAltairBeaconBlock(&prysmv2.BeaconBlockAltair{}) + wb, err := wrapper.WrappedAltairBeaconBlock(ðpb.BeaconBlockAltair{}) require.NoError(t, err) assert.Equal(t, version.Altair, wb.Version()) @@ -198,7 +198,7 @@ func TestAltairBeaconBlock_Version(t *testing.T) { func TestAltairBeaconBlockBody_RandaoReveal(t *testing.T) { root := []byte{0xAA, 0xBF, 0x33, 0x01} - wbb, err := wrapper.WrappedAltairBeaconBlockBody(&prysmv2.BeaconBlockBodyAltair{RandaoReveal: root}) + wbb, err := wrapper.WrappedAltairBeaconBlockBody(ðpb.BeaconBlockBodyAltair{RandaoReveal: root}) require.NoError(t, err) assert.DeepEqual(t, root, wbb.RandaoReveal()) @@ -206,7 +206,7 @@ func TestAltairBeaconBlockBody_RandaoReveal(t *testing.T) { func TestAltairBeaconBlockBody_Eth1Data(t *testing.T) { data := &v1alpha1.Eth1Data{} - body := &prysmv2.BeaconBlockBodyAltair{ + body := ðpb.BeaconBlockBodyAltair{ Eth1Data: data, } wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) @@ -216,7 +216,7 @@ func TestAltairBeaconBlockBody_Eth1Data(t *testing.T) { func TestAltairBeaconBlockBody_Graffiti(t *testing.T) { graffiti := []byte{0x66, 0xAA} - body := &prysmv2.BeaconBlockBodyAltair{Graffiti: graffiti} + body := ðpb.BeaconBlockBodyAltair{Graffiti: graffiti} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -229,7 +229,7 @@ func TestAltairBeaconBlockBody_ProposerSlashings(t *testing.T) { Signature: []byte{0x11, 0x20}, }}, } - body := &prysmv2.BeaconBlockBodyAltair{ProposerSlashings: ps} + body := ðpb.BeaconBlockBodyAltair{ProposerSlashings: ps} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -240,7 +240,7 @@ func TestAltairBeaconBlockBody_AttesterSlashings(t *testing.T) { as := []*v1alpha1.AttesterSlashing{ {Attestation_1: &v1alpha1.IndexedAttestation{Signature: []byte{0x11}}}, } - body := &prysmv2.BeaconBlockBodyAltair{AttesterSlashings: as} + body := ðpb.BeaconBlockBodyAltair{AttesterSlashings: as} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -250,7 +250,7 @@ func TestAltairBeaconBlockBody_AttesterSlashings(t *testing.T) { func TestAltairBeaconBlockBody_Attestations(t *testing.T) { atts := []*v1alpha1.Attestation{{Signature: []byte{0x88}}} - body := &prysmv2.BeaconBlockBodyAltair{Attestations: atts} + body := ðpb.BeaconBlockBodyAltair{Attestations: atts} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -261,7 +261,7 @@ func TestAltairBeaconBlockBody_Deposits(t *testing.T) { deposits := []*v1alpha1.Deposit{ {Proof: [][]byte{{0x54, 0x10}}}, } - body := &prysmv2.BeaconBlockBodyAltair{Deposits: deposits} + body := ðpb.BeaconBlockBodyAltair{Deposits: deposits} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -272,7 +272,7 @@ func TestAltairBeaconBlockBody_VoluntaryExits(t *testing.T) { exits := []*v1alpha1.SignedVoluntaryExit{ {Exit: &v1alpha1.VoluntaryExit{Epoch: 54}}, } - body := &prysmv2.BeaconBlockBodyAltair{VoluntaryExits: exits} + body := ðpb.BeaconBlockBodyAltair{VoluntaryExits: exits} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) @@ -283,14 +283,14 @@ func TestAltairBeaconBlockBody_IsNil(t *testing.T) { _, err := wrapper.WrappedAltairBeaconBlockBody(nil) require.Equal(t, wrapper.ErrNilObjectWrapped, err) - wbb, err := wrapper.WrappedAltairBeaconBlockBody(&prysmv2.BeaconBlockBodyAltair{}) + wbb, err := wrapper.WrappedAltairBeaconBlockBody(ðpb.BeaconBlockBodyAltair{}) require.NoError(t, err) assert.Equal(t, false, wbb.IsNil()) } func TestAltairBeaconBlockBody_HashTreeRoot(t *testing.T) { - wb, err := wrapper.WrappedAltairBeaconBlockBody(testutil.HydrateBeaconBlockBodyAltair(&prysmv2.BeaconBlockBodyAltair{})) + wb, err := wrapper.WrappedAltairBeaconBlockBody(testutil.HydrateBeaconBlockBodyAltair(ðpb.BeaconBlockBodyAltair{})) assert.NoError(t, err) rt, err := wb.HashTreeRoot() @@ -299,7 +299,7 @@ func TestAltairBeaconBlockBody_HashTreeRoot(t *testing.T) { } func TestAltairBeaconBlockBody_Proto(t *testing.T) { - body := &prysmv2.BeaconBlockBodyAltair{Graffiti: []byte{0x66, 0xAA}} + body := ðpb.BeaconBlockBodyAltair{Graffiti: []byte{0x66, 0xAA}} wbb, err := wrapper.WrappedAltairBeaconBlockBody(body) require.NoError(t, err) diff --git a/shared/aggregation/sync_contribution/naive_test.go b/shared/aggregation/sync_contribution/naive_test.go index d3c7daa2b7..3fbf5827aa 100644 --- a/shared/aggregation/sync_contribution/naive_test.go +++ b/shared/aggregation/sync_contribution/naive_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/prysmaticlabs/go-bitfield" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/aggregation" aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" "github.com/prysmaticlabs/prysm/shared/bls" @@ -17,19 +17,19 @@ import ( func TestAggregateAttestations_aggregate(t *testing.T) { tests := []struct { - a1 *prysmv2.SyncCommitteeContribution - a2 *prysmv2.SyncCommitteeContribution - want *prysmv2.SyncCommitteeContribution + a1 *ethpb.SyncCommitteeContribution + a2 *ethpb.SyncCommitteeContribution + want *ethpb.SyncCommitteeContribution }{ { - a1: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x02}, Signature: bls.NewAggregateSignature().Marshal()}, - a2: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x01}, Signature: bls.NewAggregateSignature().Marshal()}, - want: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x03}}, + a1: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x02}, Signature: bls.NewAggregateSignature().Marshal()}, + a2: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x01}, Signature: bls.NewAggregateSignature().Marshal()}, + want: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x03}}, }, { - a1: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x01}, Signature: bls.NewAggregateSignature().Marshal()}, - a2: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x02}, Signature: bls.NewAggregateSignature().Marshal()}, - want: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x03}}, + a1: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x01}, Signature: bls.NewAggregateSignature().Marshal()}, + a2: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x02}, Signature: bls.NewAggregateSignature().Marshal()}, + want: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x03}}, }, } for _, tt := range tests { @@ -41,16 +41,16 @@ func TestAggregateAttestations_aggregate(t *testing.T) { func TestAggregateAttestations_aggregate_OverlapFails(t *testing.T) { tests := []struct { - a1 *prysmv2.SyncCommitteeContribution - a2 *prysmv2.SyncCommitteeContribution + a1 *ethpb.SyncCommitteeContribution + a2 *ethpb.SyncCommitteeContribution }{ { - a1: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x1F}}, - a2: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x11}}, + a1: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x1F}}, + a2: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x11}}, }, { - a1: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0xFF, 0x85}}, - a2: &prysmv2.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x13, 0x8F}}, + a1: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0xFF, 0x85}}, + a2: ðpb.SyncCommitteeContribution{AggregationBits: bitfield.Bitvector128{0x13, 0x8F}}, }, } for _, tt := range tests { diff --git a/shared/aggregation/testing/bitlistutils.go b/shared/aggregation/testing/bitlistutils.go index bd65f44896..ddcbc37055 100644 --- a/shared/aggregation/testing/bitlistutils.go +++ b/shared/aggregation/testing/bitlistutils.go @@ -7,7 +7,6 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/timeutils" ) @@ -94,10 +93,10 @@ func MakeAttestationsFromBitlists(bl []bitfield.Bitlist) []*ethpb.Attestation { } // MakeSyncContributionsFromBitVector creates list of sync contributions from list of bitvector. -func MakeSyncContributionsFromBitVector(bl []bitfield.Bitvector128) []*prysmv2.SyncCommitteeContribution { - c := make([]*prysmv2.SyncCommitteeContribution, len(bl)) +func MakeSyncContributionsFromBitVector(bl []bitfield.Bitvector128) []*ethpb.SyncCommitteeContribution { + c := make([]*ethpb.SyncCommitteeContribution, len(bl)) for i, b := range bl { - c[i] = &prysmv2.SyncCommitteeContribution{ + c[i] = ðpb.SyncCommitteeContribution{ Slot: types.Slot(1), SubcommitteeIndex: 2, AggregationBits: b, diff --git a/shared/benchutil/pregen.go b/shared/benchutil/pregen.go index d127274666..00df49690d 100644 --- a/shared/benchutil/pregen.go +++ b/shared/benchutil/pregen.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -50,7 +49,7 @@ func PreGenState1Epoch() (state.BeaconState, error) { if err != nil { return nil, err } - beaconState := &statepb.BeaconState{} + beaconState := ðpb.BeaconState{} if err := beaconState.UnmarshalSSZ(beaconBytes); err != nil { return nil, err } @@ -67,7 +66,7 @@ func PreGenstateFullEpochs() (state.BeaconState, error) { if err != nil { return nil, err } - beaconState := &statepb.BeaconState{} + beaconState := ðpb.BeaconState{} if err := beaconState.UnmarshalSSZ(beaconBytes); err != nil { return nil, err } diff --git a/shared/copyutil/cloners.go b/shared/copyutil/cloners.go index 2f50a3d29a..8b50867ae3 100644 --- a/shared/copyutil/cloners.go +++ b/shared/copyutil/cloners.go @@ -2,7 +2,6 @@ package copyutil import ( ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" ) @@ -112,22 +111,22 @@ func CopyBeaconBlockBody(body *ethpb.BeaconBlockBody) *ethpb.BeaconBlockBody { } // CopySignedBeaconBlockAltair copies the provided SignedBeaconBlock. -func CopySignedBeaconBlockAltair(sigBlock *prysmv2.SignedBeaconBlockAltair) *prysmv2.SignedBeaconBlockAltair { +func CopySignedBeaconBlockAltair(sigBlock *ethpb.SignedBeaconBlockAltair) *ethpb.SignedBeaconBlockAltair { if sigBlock == nil { return nil } - return &prysmv2.SignedBeaconBlockAltair{ + return ðpb.SignedBeaconBlockAltair{ Block: CopyBeaconBlockAltair(sigBlock.Block), Signature: bytesutil.SafeCopyBytes(sigBlock.Signature), } } // CopyBeaconBlockAltair copies the provided BeaconBlock. -func CopyBeaconBlockAltair(block *prysmv2.BeaconBlockAltair) *prysmv2.BeaconBlockAltair { +func CopyBeaconBlockAltair(block *ethpb.BeaconBlockAltair) *ethpb.BeaconBlockAltair { if block == nil { return nil } - return &prysmv2.BeaconBlockAltair{ + return ðpb.BeaconBlockAltair{ Slot: block.Slot, ProposerIndex: block.ProposerIndex, ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot), @@ -137,11 +136,11 @@ func CopyBeaconBlockAltair(block *prysmv2.BeaconBlockAltair) *prysmv2.BeaconBloc } // CopyBeaconBlockBodyAltair copies the provided BeaconBlockBody. -func CopyBeaconBlockBodyAltair(body *prysmv2.BeaconBlockBodyAltair) *prysmv2.BeaconBlockBodyAltair { +func CopyBeaconBlockBodyAltair(body *ethpb.BeaconBlockBodyAltair) *ethpb.BeaconBlockBodyAltair { if body == nil { return nil } - return &prysmv2.BeaconBlockBodyAltair{ + return ðpb.BeaconBlockBodyAltair{ RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal), Eth1Data: CopyETH1Data(body.Eth1Data), Graffiti: bytesutil.SafeCopyBytes(body.Graffiti), @@ -329,11 +328,11 @@ func CopyValidator(val *ethpb.Validator) *ethpb.Validator { } // CopySyncCommitteeMessage copies the provided sync committee message object. -func CopySyncCommitteeMessage(s *prysmv2.SyncCommitteeMessage) *prysmv2.SyncCommitteeMessage { +func CopySyncCommitteeMessage(s *ethpb.SyncCommitteeMessage) *ethpb.SyncCommitteeMessage { if s == nil { return nil } - return &prysmv2.SyncCommitteeMessage{ + return ðpb.SyncCommitteeMessage{ Slot: s.Slot, BlockRoot: bytesutil.SafeCopyBytes(s.BlockRoot), ValidatorIndex: s.ValidatorIndex, @@ -342,11 +341,11 @@ func CopySyncCommitteeMessage(s *prysmv2.SyncCommitteeMessage) *prysmv2.SyncComm } // CopySyncCommitteeContribution copies the provided sync committee contribution object. -func CopySyncCommitteeContribution(c *prysmv2.SyncCommitteeContribution) *prysmv2.SyncCommitteeContribution { +func CopySyncCommitteeContribution(c *ethpb.SyncCommitteeContribution) *ethpb.SyncCommitteeContribution { if c == nil { return nil } - return &prysmv2.SyncCommitteeContribution{ + return ðpb.SyncCommitteeContribution{ Slot: c.Slot, BlockRoot: bytesutil.SafeCopyBytes(c.BlockRoot), SubcommitteeIndex: c.SubcommitteeIndex, @@ -356,11 +355,11 @@ func CopySyncCommitteeContribution(c *prysmv2.SyncCommitteeContribution) *prysmv } // CopySyncAggregate copies the provided sync aggregate object. -func CopySyncAggregate(a *prysmv2.SyncAggregate) *prysmv2.SyncAggregate { +func CopySyncAggregate(a *ethpb.SyncAggregate) *ethpb.SyncAggregate { if a == nil { return nil } - return &prysmv2.SyncAggregate{ + return ðpb.SyncAggregate{ SyncCommitteeBits: bytesutil.SafeCopyBytes(a.SyncCommitteeBits), SyncCommitteeSignature: bytesutil.SafeCopyBytes(a.SyncCommitteeSignature), } diff --git a/shared/copyutil/cloners_test.go b/shared/copyutil/cloners_test.go index fe75018835..ffc4789a1d 100644 --- a/shared/copyutil/cloners_test.go +++ b/shared/copyutil/cloners_test.go @@ -6,7 +6,6 @@ import ( "testing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) @@ -487,8 +486,8 @@ func genValidator() *ethpb.Validator { } } -func genSyncCommitteeContribution() *prysmv2.SyncCommitteeContribution { - return &prysmv2.SyncCommitteeContribution{ +func genSyncCommitteeContribution() *ethpb.SyncCommitteeContribution { + return ðpb.SyncCommitteeContribution{ Slot: 12333, BlockRoot: bytes(), SubcommitteeIndex: 4444, @@ -497,15 +496,15 @@ func genSyncCommitteeContribution() *prysmv2.SyncCommitteeContribution { } } -func genSyncAggregate() *prysmv2.SyncAggregate { - return &prysmv2.SyncAggregate{ +func genSyncAggregate() *ethpb.SyncAggregate { + return ðpb.SyncAggregate{ SyncCommitteeBits: bytes(), SyncCommitteeSignature: bytes(), } } -func genBeaconBlockBodyAltair() *prysmv2.BeaconBlockBodyAltair { - return &prysmv2.BeaconBlockBodyAltair{ +func genBeaconBlockBodyAltair() *ethpb.BeaconBlockBodyAltair { + return ðpb.BeaconBlockBodyAltair{ RandaoReveal: bytes(), Eth1Data: genEth1Data(), Graffiti: bytes(), @@ -518,8 +517,8 @@ func genBeaconBlockBodyAltair() *prysmv2.BeaconBlockBodyAltair { } } -func genBeaconBlockAltair() *prysmv2.BeaconBlockAltair { - return &prysmv2.BeaconBlockAltair{ +func genBeaconBlockAltair() *ethpb.BeaconBlockAltair { + return ðpb.BeaconBlockAltair{ Slot: 123455, ProposerIndex: 55433, ParentRoot: bytes(), @@ -528,15 +527,15 @@ func genBeaconBlockAltair() *prysmv2.BeaconBlockAltair { } } -func genSignedBeaconBlockAltair() *prysmv2.SignedBeaconBlockAltair { - return &prysmv2.SignedBeaconBlockAltair{ +func genSignedBeaconBlockAltair() *ethpb.SignedBeaconBlockAltair { + return ðpb.SignedBeaconBlockAltair{ Block: genBeaconBlockAltair(), Signature: bytes(), } } -func genSyncCommitteeMessage() *prysmv2.SyncCommitteeMessage { - return &prysmv2.SyncCommitteeMessage{ +func genSyncCommitteeMessage() *ethpb.SyncCommitteeMessage { + return ðpb.SyncCommitteeMessage{ Slot: 424555, BlockRoot: bytes(), ValidatorIndex: 5443, diff --git a/shared/depositutil/deposit.go b/shared/depositutil/deposit.go index d7d801f72a..b62fc40fac 100644 --- a/shared/depositutil/deposit.go +++ b/shared/depositutil/deposit.go @@ -6,7 +6,6 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -29,7 +28,7 @@ import ( // // See: https://github.com/ethereum/eth2.0-specs/blob/master/specs/validator/0_beacon-chain-validator.md#submit-deposit func DepositInput(depositKey, withdrawalKey bls.SecretKey, amountInGwei uint64) (*ethpb.Deposit_Data, [32]byte, error) { - depositMessage := &statepb.DepositMessage{ + depositMessage := ðpb.DepositMessage{ PublicKey: depositKey.PublicKey().Marshal(), WithdrawalCredentials: WithdrawalCredentialsHash(withdrawalKey), Amount: amountInGwei, @@ -48,7 +47,7 @@ func DepositInput(depositKey, withdrawalKey bls.SecretKey, amountInGwei uint64) if err != nil { return nil, [32]byte{}, err } - root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (ðpb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, [32]byte{}, err } @@ -93,7 +92,7 @@ func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error { if err != nil { return errors.Wrap(err, "could not convert bytes to signature") } - di := &statepb.DepositMessage{ + di := ðpb.DepositMessage{ PublicKey: ddCopy.PublicKey, WithdrawalCredentials: ddCopy.WithdrawalCredentials, Amount: ddCopy.Amount, @@ -102,7 +101,7 @@ func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error { if err != nil { return errors.Wrap(err, "could not get signing root") } - signingData := &statepb.SigningData{ + signingData := ðpb.SigningData{ ObjectRoot: root[:], Domain: domain, } diff --git a/shared/depositutil/deposit_test.go b/shared/depositutil/deposit_test.go index e2486edc62..ad83792569 100644 --- a/shared/depositutil/deposit_test.go +++ b/shared/depositutil/deposit_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/depositutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -25,7 +25,7 @@ func TestDepositInput_GeneratesPb(t *testing.T) { sig, err := bls.SignatureFromBytes(result.Signature) require.NoError(t, err) - testData := &statepb.DepositMessage{ + testData := ðpb.DepositMessage{ PublicKey: result.PublicKey, WithdrawalCredentials: result.WithdrawalCredentials, Amount: result.Amount, @@ -38,7 +38,7 @@ func TestDepositInput_GeneratesPb(t *testing.T) { nil, /*genesisValidatorsRoot*/ ) require.NoError(t, err) - root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (ðpb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() require.NoError(t, err) assert.Equal(t, true, sig.Verify(k1.PublicKey(), root[:])) } diff --git a/shared/interop/generate_genesis_state.go b/shared/interop/generate_genesis_state.go index 59637e4b87..678c6e5996 100644 --- a/shared/interop/generate_genesis_state.go +++ b/shared/interop/generate_genesis_state.go @@ -11,7 +11,6 @@ import ( coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/mputil" @@ -28,7 +27,7 @@ var ( // GenerateGenesisState deterministically given a genesis time and number of validators. // If a genesis time of 0 is supplied it is set to the current time. -func GenerateGenesisState(ctx context.Context, genesisTime, numValidators uint64) (*statepb.BeaconState, []*ethpb.Deposit, error) { +func GenerateGenesisState(ctx context.Context, genesisTime, numValidators uint64) (*ethpb.BeaconState, []*ethpb.Deposit, error) { privKeys, pubKeys, err := DeterministicallyGenerateKeys(0 /*startIndex*/, numValidators) if err != nil { return nil, nil, errors.Wrapf(err, "could not deterministically generate keys for %d validators", numValidators) @@ -44,7 +43,7 @@ func GenerateGenesisState(ctx context.Context, genesisTime, numValidators uint64 // deposit data items and their corresponding roots. func GenerateGenesisStateFromDepositData( ctx context.Context, genesisTime uint64, depositData []*ethpb.Deposit_Data, depositDataRoots [][]byte, -) (*statepb.BeaconState, []*ethpb.Deposit, error) { +) (*ethpb.BeaconState, []*ethpb.Deposit, error) { trie, err := trieutil.GenerateTrieFromItems(depositDataRoots, params.BeaconConfig().DepositContractTreeDepth) if err != nil { return nil, nil, errors.Wrap(err, "could not generate Merkle trie for deposit proofs") @@ -154,7 +153,7 @@ func depositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey) ([]* // Generates a deposit data item from BLS keys and signs the hash tree root of the data. func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Deposit_Data, error) { - depositMessage := &statepb.DepositMessage{ + depositMessage := ðpb.DepositMessage{ PublicKey: pubKey.Marshal(), WithdrawalCredentials: withdrawalCredentialsHash(pubKey.Marshal()), Amount: params.BeaconConfig().MaxEffectiveBalance, @@ -167,7 +166,7 @@ func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Depo if err != nil { return nil, err } - root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (ðpb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, err } diff --git a/shared/testutil/altair.go b/shared/testutil/altair.go index 6784ade89a..4780afa3b4 100644 --- a/shared/testutil/altair.go +++ b/shared/testutil/altair.go @@ -16,8 +16,6 @@ import ( v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -129,13 +127,13 @@ func buildGenesisBeaconState(genesisTime uint64, preState state.BeaconStateAltai if err != nil { return nil, err } - state := &statepb.BeaconStateAltair{ + state := ðpb.BeaconStateAltair{ // Misc fields. Slot: 0, GenesisTime: genesisTime, GenesisValidatorsRoot: genesisValidatorsRoot[:], - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, @@ -177,14 +175,14 @@ func buildGenesisBeaconState(genesisTime uint64, preState state.BeaconStateAltai Eth1DepositIndex: preState.Eth1DepositIndex(), } - bodyRoot, err := (&prysmv2.BeaconBlockBodyAltair{ + bodyRoot, err := (ðpb.BeaconBlockBodyAltair{ RandaoReveal: make([]byte, 96), Eth1Data: ðpb.Eth1Data{ DepositRoot: make([]byte, 32), BlockHash: make([]byte, 32), }, Graffiti: make([]byte, 32), - SyncAggregate: &prysmv2.SyncAggregate{ + SyncAggregate: ðpb.SyncAggregate{ SyncCommitteeBits: make([]byte, len(bitfield.NewBitvector512())), SyncCommitteeSignature: make([]byte, 96), }, @@ -203,11 +201,11 @@ func buildGenesisBeaconState(genesisTime uint64, preState state.BeaconStateAltai for i := uint64(0); i < params.BeaconConfig().SyncCommitteeSize; i++ { pubKeys = append(pubKeys, bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength)) } - state.CurrentSyncCommittee = &statepb.SyncCommittee{ + state.CurrentSyncCommittee = ðpb.SyncCommittee{ Pubkeys: pubKeys, AggregatePubkey: bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength), } - state.NextSyncCommittee = &statepb.SyncCommittee{ + state.NextSyncCommittee = ðpb.SyncCommittee{ Pubkeys: bytesutil.Copy2dBytes(pubKeys), AggregatePubkey: bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength), } @@ -216,10 +214,10 @@ func buildGenesisBeaconState(genesisTime uint64, preState state.BeaconStateAltai } func emptyGenesisState() (state.BeaconStateAltair, error) { - state := &statepb.BeaconStateAltair{ + state := ðpb.BeaconStateAltair{ // Misc fields. Slot: 0, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().AltairForkVersion, Epoch: 0, @@ -243,12 +241,12 @@ func emptyGenesisState() (state.BeaconStateAltair, error) { } // NewBeaconBlockAltair creates a beacon block with minimum marshalable fields. -func NewBeaconBlockAltair() *prysmv2.SignedBeaconBlockAltair { - return &prysmv2.SignedBeaconBlockAltair{ - Block: &prysmv2.BeaconBlockAltair{ +func NewBeaconBlockAltair() *ethpb.SignedBeaconBlockAltair { + return ðpb.SignedBeaconBlockAltair{ + Block: ðpb.BeaconBlockAltair{ ParentRoot: make([]byte, 32), StateRoot: make([]byte, 32), - Body: &prysmv2.BeaconBlockBodyAltair{ + Body: ðpb.BeaconBlockBodyAltair{ RandaoReveal: make([]byte, 96), Eth1Data: ðpb.Eth1Data{ DepositRoot: make([]byte, 32), @@ -260,7 +258,7 @@ func NewBeaconBlockAltair() *prysmv2.SignedBeaconBlockAltair { Deposits: []*ethpb.Deposit{}, ProposerSlashings: []*ethpb.ProposerSlashing{}, VoluntaryExits: []*ethpb.SignedVoluntaryExit{}, - SyncAggregate: &prysmv2.SyncAggregate{ + SyncAggregate: ðpb.SyncAggregate{ SyncCommitteeBits: make([]byte, len(bitfield.NewBitvector512())), SyncCommitteeSignature: make([]byte, 96), }, @@ -273,11 +271,11 @@ func NewBeaconBlockAltair() *prysmv2.SignedBeaconBlockAltair { // BlockSignatureAltair calculates the post-state root of the block and returns the signature. func BlockSignatureAltair( bState state.BeaconStateAltair, - block *prysmv2.BeaconBlockAltair, + block *ethpb.BeaconBlockAltair, privKeys []bls.SecretKey, ) (bls.Signature, error) { var err error - wsb, err := wrapper.WrappedAltairSignedBeaconBlock(&prysmv2.SignedBeaconBlockAltair{Block: block}) + wsb, err := wrapper.WrappedAltairSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: block}) if err != nil { return nil, err } @@ -317,7 +315,7 @@ func GenerateFullBlockAltair( privs []bls.SecretKey, conf *BlockGenConfig, slot types.Slot, -) (*prysmv2.SignedBeaconBlockAltair, error) { +) (*ethpb.SignedBeaconBlockAltair, error) { ctx := context.Background() currentSlot := bState.Slot() if currentSlot > slot { @@ -411,11 +409,11 @@ func GenerateFullBlockAltair( return nil, err } - block := &prysmv2.BeaconBlockAltair{ + block := ðpb.BeaconBlockAltair{ Slot: slot, ParentRoot: parentRoot[:], ProposerIndex: idx, - Body: &prysmv2.BeaconBlockBodyAltair{ + Body: ðpb.BeaconBlockBodyAltair{ Eth1Data: eth1Data, RandaoReveal: reveal, ProposerSlashings: pSlashings, @@ -436,5 +434,5 @@ func GenerateFullBlockAltair( return nil, err } - return &prysmv2.SignedBeaconBlockAltair{Block: block, Signature: signature.Marshal()}, nil + return ðpb.SignedBeaconBlockAltair{Block: block, Signature: signature.Marshal()}, nil } diff --git a/shared/testutil/block.go b/shared/testutil/block.go index 0d931f0dc1..0b6336c90a 100644 --- a/shared/testutil/block.go +++ b/shared/testutil/block.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -507,7 +506,7 @@ func HydrateV1BeaconBlockBody(b *v1.BeaconBlockBody) *v1.BeaconBlockBody { // HydrateSignedBeaconBlockAltair hydrates a signed beacon block with correct field length sizes // to comply with fssz marshalling and unmarshalling rules. -func HydrateSignedBeaconBlockAltair(b *prysmv2.SignedBeaconBlockAltair) *prysmv2.SignedBeaconBlockAltair { +func HydrateSignedBeaconBlockAltair(b *ethpb.SignedBeaconBlockAltair) *ethpb.SignedBeaconBlockAltair { if b.Signature == nil { b.Signature = make([]byte, params.BeaconConfig().BLSSignatureLength) } @@ -517,9 +516,9 @@ func HydrateSignedBeaconBlockAltair(b *prysmv2.SignedBeaconBlockAltair) *prysmv2 // HydrateBeaconBlockAltair hydrates a beacon block with correct field length sizes // to comply with fssz marshalling and unmarshalling rules. -func HydrateBeaconBlockAltair(b *prysmv2.BeaconBlockAltair) *prysmv2.BeaconBlockAltair { +func HydrateBeaconBlockAltair(b *ethpb.BeaconBlockAltair) *ethpb.BeaconBlockAltair { if b == nil { - b = &prysmv2.BeaconBlockAltair{} + b = ðpb.BeaconBlockAltair{} } if b.ParentRoot == nil { b.ParentRoot = make([]byte, 32) @@ -533,9 +532,9 @@ func HydrateBeaconBlockAltair(b *prysmv2.BeaconBlockAltair) *prysmv2.BeaconBlock // HydrateBeaconBlockBodyAltair hydrates a beacon block body with correct field length sizes // to comply with fssz marshalling and unmarshalling rules. -func HydrateBeaconBlockBodyAltair(b *prysmv2.BeaconBlockBodyAltair) *prysmv2.BeaconBlockBodyAltair { +func HydrateBeaconBlockBodyAltair(b *ethpb.BeaconBlockBodyAltair) *ethpb.BeaconBlockBodyAltair { if b == nil { - b = &prysmv2.BeaconBlockBodyAltair{} + b = ðpb.BeaconBlockBodyAltair{} } if b.RandaoReveal == nil { b.RandaoReveal = make([]byte, params.BeaconConfig().BLSSignatureLength) @@ -550,7 +549,7 @@ func HydrateBeaconBlockBodyAltair(b *prysmv2.BeaconBlockBodyAltair) *prysmv2.Bea } } if b.SyncAggregate == nil { - b.SyncAggregate = &prysmv2.SyncAggregate{ + b.SyncAggregate = ðpb.SyncAggregate{ SyncCommitteeBits: make([]byte, 64), SyncCommitteeSignature: make([]byte, 96), } diff --git a/shared/testutil/deposits.go b/shared/testutil/deposits.go index 6aef08ce8a..96bcf84564 100644 --- a/shared/testutil/deposits.go +++ b/shared/testutil/deposits.go @@ -10,7 +10,6 @@ import ( core "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -165,7 +164,7 @@ func signedDeposit( ) (*ethpb.Deposit, error) { withdrawalCreds := hashutil.Hash(withdrawalKey) withdrawalCreds[0] = params.BeaconConfig().BLSWithdrawalPrefixByte - depositMessage := &statepb.DepositMessage{ + depositMessage := ðpb.DepositMessage{ PublicKey: publicKey, Amount: balance, WithdrawalCredentials: withdrawalCreds[:], @@ -180,7 +179,7 @@ func signedDeposit( return nil, errors.Wrap(err, "could not get signing root of deposit data") } - sigRoot, err := (&statepb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() + sigRoot, err := (ðpb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, err } @@ -329,7 +328,7 @@ func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Dep withdrawalCreds := hashutil.Hash(publicKeys[1].Marshal()) withdrawalCreds[0] = params.BeaconConfig().BLSWithdrawalPrefixByte - depositMessage := &statepb.DepositMessage{ + depositMessage := ðpb.DepositMessage{ PublicKey: publicKeys[1].Marshal(), Amount: params.BeaconConfig().MaxEffectiveBalance, WithdrawalCredentials: withdrawalCreds[:], @@ -343,7 +342,7 @@ func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Dep if err != nil { return nil, nil, errors.Wrap(err, "could not get signing root of deposit data") } - sigRoot, err := (&statepb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() + sigRoot, err := (ðpb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, nil, errors.Wrap(err, "could not get signing root of deposit data and domain") } diff --git a/shared/testutil/state.go b/shared/testutil/state.go index eea920e4bd..fe72898487 100644 --- a/shared/testutil/state.go +++ b/shared/testutil/state.go @@ -8,14 +8,13 @@ import ( "github.com/prysmaticlabs/go-bitfield" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" ) // FillRootsNaturalOpt is meant to be used as an option when calling NewBeaconState. // It fills state and block roots with hex representations of natural numbers starting with 0. // Example: 16 becomes 0x00...0f. -func FillRootsNaturalOpt(state *statepb.BeaconState) error { +func FillRootsNaturalOpt(state *ethpb.BeaconState) error { rootsLen := params.MainnetConfig().SlotsPerHistoricalRoot roots := make([][]byte, rootsLen) for i := types.Slot(0); i < rootsLen; i++ { @@ -36,8 +35,8 @@ func FillRootsNaturalOpt(state *statepb.BeaconState) error { } // NewBeaconState creates a beacon state with minimum marshalable fields. -func NewBeaconState(options ...func(state *statepb.BeaconState) error) (*v1.BeaconState, error) { - seed := &statepb.BeaconState{ +func NewBeaconState(options ...func(state *ethpb.BeaconState) error) (*v1.BeaconState, error) { + seed := ðpb.BeaconState{ BlockRoots: filledByteSlice2D(uint64(params.MainnetConfig().SlotsPerHistoricalRoot), 32), StateRoots: filledByteSlice2D(uint64(params.MainnetConfig().SlotsPerHistoricalRoot), 32), Slashings: make([]uint64, params.MainnetConfig().EpochsPerSlashingsVector), @@ -48,7 +47,7 @@ func NewBeaconState(options ...func(state *statepb.BeaconState) error) (*v1.Beac DepositRoot: make([]byte, 32), BlockHash: make([]byte, 32), }, - Fork: &statepb.Fork{ + Fork: ðpb.Fork{ PreviousVersion: make([]byte, 4), CurrentVersion: make([]byte, 4), }, @@ -57,8 +56,8 @@ func NewBeaconState(options ...func(state *statepb.BeaconState) error) (*v1.Beac JustificationBits: bitfield.Bitvector4{0x0}, FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, LatestBlockHeader: HydrateBeaconHeader(ðpb.BeaconBlockHeader{}), - PreviousEpochAttestations: make([]*statepb.PendingAttestation, 0), - CurrentEpochAttestations: make([]*statepb.PendingAttestation, 0), + PreviousEpochAttestations: make([]*ethpb.PendingAttestation, 0), + CurrentEpochAttestations: make([]*ethpb.PendingAttestation, 0), PreviousJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, } diff --git a/shared/testutil/state_test.go b/shared/testutil/state_test.go index 4e01712541..393797723f 100644 --- a/shared/testutil/state_test.go +++ b/shared/testutil/state_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -14,7 +14,7 @@ func TestNewBeaconState(t *testing.T) { require.NoError(t, err) b, err := st.MarshalSSZ() require.NoError(t, err) - got := &statepb.BeaconState{} + got := ðpb.BeaconState{} require.NoError(t, got.UnmarshalSSZ(b)) if !reflect.DeepEqual(st.InnerStateUnsafe(), got) { t.Fatal("State did not match after round trip marshal") diff --git a/shared/testutil/sync_aggregate.go b/shared/testutil/sync_aggregate.go index e84a46cd8b..3f2620a635 100644 --- a/shared/testutil/sync_aggregate.go +++ b/shared/testutil/sync_aggregate.go @@ -6,15 +6,14 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2pType "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/version" ) -func generateSyncAggregate(bState state.BeaconState, privs []bls.SecretKey, parentRoot [32]byte) (*prysmv2.SyncAggregate, error) { +func generateSyncAggregate(bState state.BeaconState, privs []bls.SecretKey, parentRoot [32]byte) (*ethpb.SyncAggregate, error) { st, ok := bState.(state.BeaconStateAltair) if !ok || bState.Version() == version.Phase0 { return nil, errors.Errorf("state cannot be asserted to altair state") @@ -22,7 +21,7 @@ func generateSyncAggregate(bState state.BeaconState, privs []bls.SecretKey, pare nextSlotEpoch := helpers.SlotToEpoch(st.Slot() + 1) currEpoch := helpers.SlotToEpoch(st.Slot()) - var syncCommittee *statepb.SyncCommittee + var syncCommittee *ethpb.SyncCommittee var err error if helpers.SyncCommitteePeriod(currEpoch) == helpers.SyncCommitteePeriod(nextSlotEpoch) { syncCommittee, err = st.CurrentSyncCommittee() @@ -37,7 +36,7 @@ func generateSyncAggregate(bState state.BeaconState, privs []bls.SecretKey, pare } sigs := make([]bls.Signature, 0, len(syncCommittee.Pubkeys)) var bVector []byte - currSize := new(prysmv2.SyncAggregate).SyncCommitteeBits.Len() + currSize := new(ethpb.SyncAggregate).SyncCommitteeBits.Len() switch currSize { case 512: bVector = bitfield.NewBitvector512() @@ -71,8 +70,8 @@ func generateSyncAggregate(bState state.BeaconState, privs []bls.SecretKey, pare } if len(sigs) == 0 { fakeSig := [96]byte{0xC0} - return &prysmv2.SyncAggregate{SyncCommitteeSignature: fakeSig[:], SyncCommitteeBits: bVector}, nil + return ðpb.SyncAggregate{SyncCommitteeSignature: fakeSig[:], SyncCommitteeBits: bVector}, nil } aggSig := bls.AggregateSignatures(sigs) - return &prysmv2.SyncAggregate{SyncCommitteeSignature: aggSig.Marshal(), SyncCommitteeBits: bVector}, nil + return ðpb.SyncAggregate{SyncCommitteeSignature: aggSig.Marshal(), SyncCommitteeBits: bVector}, nil } diff --git a/spectest/shared/phase0/epoch_processing/helpers.go b/spectest/shared/phase0/epoch_processing/helpers.go index a01c4b0903..b1c9c6dd66 100644 --- a/spectest/shared/phase0/epoch_processing/helpers.go +++ b/spectest/shared/phase0/epoch_processing/helpers.go @@ -10,7 +10,7 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -30,7 +30,7 @@ func RunEpochOperationTest( require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - preBeaconStateBase := &statepb.BeaconState{} + preBeaconStateBase := ðpb.BeaconState{} if err := preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } @@ -54,7 +54,7 @@ func RunEpochOperationTest( require.NoError(t, err) postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } diff --git a/spectest/shared/phase0/finality/runner.go b/spectest/shared/phase0/finality/runner.go index 05ccfa1d9a..22f29d25b3 100644 --- a/spectest/shared/phase0/finality/runner.go +++ b/spectest/shared/phase0/finality/runner.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -40,7 +39,7 @@ func RunFinalityTest(t *testing.T, config string) { require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - beaconStateBase := &statepb.BeaconState{} + beaconStateBase := ðpb.BeaconState{} require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") beaconState, err := v1.InitializeFromProto(beaconStateBase) require.NoError(t, err) @@ -71,7 +70,7 @@ func RunFinalityTest(t *testing.T, config string) { require.NoError(t, err) postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") pbState, err := v1.ProtobufBeaconState(beaconState.InnerStateUnsafe()) require.NoError(t, err) diff --git a/spectest/shared/phase0/operations/block_header.go b/spectest/shared/phase0/operations/block_header.go index b0fac121de..a8ec5e1190 100644 --- a/spectest/shared/phase0/operations/block_header.go +++ b/spectest/shared/phase0/operations/block_header.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -36,7 +35,7 @@ func RunBlockHeaderTest(t *testing.T, config string) { require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - preBeaconStateBase := &statepb.BeaconState{} + preBeaconStateBase := ðpb.BeaconState{} require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") preBeaconState, err := v1.InitializeFromProto(preBeaconStateBase) require.NoError(t, err) @@ -62,7 +61,7 @@ func RunBlockHeaderTest(t *testing.T, config string) { postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") pbState, err := v1.ProtobufBeaconState(beaconState.CloneInnerState()) require.NoError(t, err) diff --git a/spectest/shared/phase0/operations/helpers.go b/spectest/shared/phase0/operations/helpers.go index 10377efabd..657508f9cd 100644 --- a/spectest/shared/phase0/operations/helpers.go +++ b/spectest/shared/phase0/operations/helpers.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -36,7 +35,7 @@ func RunBlockOperationTest( require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - preStateBase := &statepb.BeaconState{} + preStateBase := ðpb.BeaconState{} if err := preStateBase.UnmarshalSSZ(preBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } @@ -64,7 +63,7 @@ func RunBlockOperationTest( postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } diff --git a/spectest/shared/phase0/rewards/rewards_penalties.go b/spectest/shared/phase0/rewards/rewards_penalties.go index 14f8abea58..0d1b7f658e 100644 --- a/spectest/shared/phase0/rewards/rewards_penalties.go +++ b/spectest/shared/phase0/rewards/rewards_penalties.go @@ -12,7 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -66,7 +66,7 @@ func runPrecomputeRewardsAndPenaltiesTest(t *testing.T, testFolderPath string) { require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - preBeaconStateBase := &statepb.BeaconState{} + preBeaconStateBase := ðpb.BeaconState{} require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") preBeaconState, err := v1.InitializeFromProto(preBeaconStateBase) require.NoError(t, err) diff --git a/spectest/shared/phase0/sanity/block_processing.go b/spectest/shared/phase0/sanity/block_processing.go index 8e4954ae8c..6e38eb2d1b 100644 --- a/spectest/shared/phase0/sanity/block_processing.go +++ b/spectest/shared/phase0/sanity/block_processing.go @@ -15,7 +15,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -40,7 +39,7 @@ func RunBlockProcessingTest(t *testing.T, config string) { require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - beaconStateBase := &statepb.BeaconState{} + beaconStateBase := ðpb.BeaconState{} require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") beaconState, err := v1.InitializeFromProto(beaconStateBase) require.NoError(t, err) @@ -89,7 +88,7 @@ func RunBlockProcessingTest(t *testing.T, config string) { postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") pbState, err := v1.ProtobufBeaconState(beaconState.InnerStateUnsafe()) require.NoError(t, err) diff --git a/spectest/shared/phase0/sanity/slot_processing.go b/spectest/shared/phase0/sanity/slot_processing.go index c3e2b73eb5..c156d50f9e 100644 --- a/spectest/shared/phase0/sanity/slot_processing.go +++ b/spectest/shared/phase0/sanity/slot_processing.go @@ -8,7 +8,7 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -32,7 +32,7 @@ func RunSlotProcessingTests(t *testing.T, config string) { require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - base := &statepb.BeaconState{} + base := ðpb.BeaconState{} require.NoError(t, base.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") beaconState, err := v1.InitializeFromProto(base) require.NoError(t, err) @@ -47,7 +47,7 @@ func RunSlotProcessingTests(t *testing.T, config string) { require.NoError(t, err) postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &statepb.BeaconState{} + postBeaconState := ðpb.BeaconState{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") postState, err := state.ProcessSlots(context.Background(), beaconState, beaconState.Slot().Add(uint64(slotsCount))) require.NoError(t, err) diff --git a/spectest/shared/phase0/ssz_static/ssz_static.go b/spectest/shared/phase0/ssz_static/ssz_static.go index a7b25744ab..1700daf116 100644 --- a/spectest/shared/phase0/ssz_static/ssz_static.go +++ b/spectest/shared/phase0/ssz_static/ssz_static.go @@ -11,7 +11,6 @@ import ( "github.com/golang/snappy" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -48,9 +47,9 @@ func RunSSZStaticTests(t *testing.T, config string) { // Custom hash tree root for beacon state. var htr func(interface{}) ([32]byte, error) - if _, ok := object.(*statepb.BeaconState); ok { + if _, ok := object.(*ethpb.BeaconState); ok { htr = func(s interface{}) ([32]byte, error) { - beaconState, err := v1.InitializeFromProto(s.(*statepb.BeaconState)) + beaconState, err := v1.InitializeFromProto(s.(*ethpb.BeaconState)) require.NoError(t, err) return beaconState.HashTreeRoot(context.Background()) } @@ -109,13 +108,13 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i case "BeaconBlockHeader": obj = ðpb.BeaconBlockHeader{} case "BeaconState": - obj = &statepb.BeaconState{} + obj = ðpb.BeaconState{} case "Checkpoint": obj = ðpb.Checkpoint{} case "Deposit": obj = ðpb.Deposit{} case "DepositMessage": - obj = &statepb.DepositMessage{} + obj = ðpb.DepositMessage{} case "DepositData": obj = ðpb.Deposit_Data{} case "Eth1Data": @@ -124,15 +123,15 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i t.Skip("Unused type") return nil, nil case "Fork": - obj = &statepb.Fork{} + obj = ðpb.Fork{} case "ForkData": - obj = &statepb.ForkData{} + obj = ðpb.ForkData{} case "HistoricalBatch": - obj = &statepb.HistoricalBatch{} + obj = ðpb.HistoricalBatch{} case "IndexedAttestation": obj = ðpb.IndexedAttestation{} case "PendingAttestation": - obj = &statepb.PendingAttestation{} + obj = ðpb.PendingAttestation{} case "ProposerSlashing": obj = ðpb.ProposerSlashing{} case "SignedAggregateAndProof": @@ -144,7 +143,7 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i case "SignedVoluntaryExit": obj = ðpb.SignedVoluntaryExit{} case "SigningData": - obj = &statepb.SigningData{} + obj = ðpb.SigningData{} case "Validator": obj = ðpb.Validator{} case "VoluntaryExit": diff --git a/tools/benchmark-files-gen/main.go b/tools/benchmark-files-gen/main.go index cc95e5a365..79c9bb7554 100644 --- a/tools/benchmark-files-gen/main.go +++ b/tools/benchmark-files-gen/main.go @@ -15,7 +15,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/benchutil" "github.com/prysmaticlabs/prysm/shared/fileutil" @@ -211,7 +210,7 @@ func genesisBeaconState() (state.BeaconState, error) { if err != nil { return nil, errors.Wrap(err, "cannot read genesis state file") } - genesisState := &statepb.BeaconState{} + genesisState := ðpb.BeaconState{} if err := genesisState.UnmarshalSSZ(beaconBytes); err != nil { return nil, errors.Wrap(err, "cannot unmarshal genesis state file") } diff --git a/tools/exploredb/main.go b/tools/exploredb/main.go index 74a8e8545a..5271e1a2d5 100644 --- a/tools/exploredb/main.go +++ b/tools/exploredb/main.go @@ -21,7 +21,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/kv" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" log "github.com/sirupsen/logrus" "github.com/status-im/keycard-go/hexutils" @@ -421,7 +420,7 @@ func sizeAndCountGeneric(genericItems interface{}, err error) (uint64, uint64) { size += uint64(item.SizeSSZ()) } count = uint64(len(items)) - case []*statepb.PendingAttestation: + case []*ethpb.PendingAttestation: for _, item := range items { size += uint64(item.SizeSSZ()) } diff --git a/tools/genesis-state-gen/main.go b/tools/genesis-state-gen/main.go index 15667c45ee..2ee20606c5 100644 --- a/tools/genesis-state-gen/main.go +++ b/tools/genesis-state-gen/main.go @@ -13,7 +13,6 @@ import ( "github.com/ghodss/yaml" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/fileutil" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" @@ -55,7 +54,7 @@ func main() { if !*useMainnetConfig { params.OverrideBeaconConfig(params.MinimalSpecConfig()) } - var genesisState *statepb.BeaconState + var genesisState *ethpb.BeaconState var err error if *depositJSONFile != "" { inputFile := *depositJSONFile @@ -131,7 +130,7 @@ func main() { } } -func genesisStateFromJSONValidators(r io.Reader, genesisTime uint64) (*statepb.BeaconState, error) { +func genesisStateFromJSONValidators(r io.Reader, genesisTime uint64) (*ethpb.BeaconState, error) { enc, err := ioutil.ReadAll(r) if err != nil { return nil, err diff --git a/tools/pcli/main.go b/tools/pcli/main.go index c789d5184e..04a299177f 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -14,7 +14,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/version" @@ -82,7 +81,7 @@ func main() { case "deposit": data = ðpb.Deposit{} case "deposit_message": - data = &statepb.DepositMessage{} + data = ðpb.DepositMessage{} case "proposer_slashing": data = ðpb.ProposerSlashing{} case "signed_block_header": @@ -92,7 +91,7 @@ func main() { case "voluntary_exit": data = ðpb.VoluntaryExit{} case "state": - data = &statepb.BeaconState{} + data = ðpb.BeaconState{} default: log.Fatal("Invalid type") } @@ -156,7 +155,7 @@ func main() { } preStatePath = text } - preState := &statepb.BeaconState{} + preState := ðpb.BeaconState{} if err := dataFetcher(preStatePath, preState); err != nil { log.Fatal(err) } @@ -188,7 +187,7 @@ func main() { // Diff the state if a post state is provided. if expectedPostStatePath != "" { - expectedState := &statepb.BeaconState{} + expectedState := ðpb.BeaconState{} if err := dataFetcher(expectedPostStatePath, expectedState); err != nil { log.Fatal(err) }