From 2d10bcf179e7d0a2db5c89b8839573c19cabd5cb Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 23 Jul 2021 08:07:40 -0500 Subject: [PATCH] Move State Protos Into V2 Namespace (#9257) * move state protos * regen ssz * edit v1 code * fix imports * building * beacon chain builds * validator and shared builds * fuzz builds * changes * spectest builds * tools build * remove import cycle * generate ssz * pcli * gaz * kafka * gaz --- beacon-chain/blockchain/BUILD.bazel | 5 +- beacon-chain/blockchain/chain_info.go | 8 +- beacon-chain/blockchain/chain_info_test.go | 20 +- beacon-chain/blockchain/head_test.go | 8 +- beacon-chain/blockchain/metrics_test.go | 6 +- .../blockchain/process_attestation_test.go | 10 +- beacon-chain/blockchain/process_block.go | 4 +- beacon-chain/blockchain/process_block_test.go | 18 +- beacon-chain/blockchain/service_test.go | 6 +- beacon-chain/blockchain/testing/BUILD.bazel | 2 +- beacon-chain/blockchain/testing/mock.go | 8 +- beacon-chain/cache/BUILD.bazel | 2 +- beacon-chain/cache/checkpoint_state_test.go | 8 +- beacon-chain/cache/skip_slot_cache_test.go | 4 +- beacon-chain/core/blocks/BUILD.bazel | 4 +- beacon-chain/core/blocks/attestation.go | 4 +- .../blocks/attestation_regression_test.go | 6 +- beacon-chain/core/blocks/attestation_test.go | 32 +- .../core/blocks/attester_slashing_test.go | 6 +- .../core/blocks/block_operations_fuzz_test.go | 46 +- beacon-chain/core/blocks/deposit.go | 4 +- beacon-chain/core/blocks/deposit_test.go | 26 +- beacon-chain/core/blocks/eth1_data_test.go | 6 +- beacon-chain/core/blocks/exit.go | 4 +- beacon-chain/core/blocks/exit_test.go | 10 +- .../proposer_slashing_regression_test.go | 5 +- .../core/blocks/proposer_slashing_test.go | 4 +- beacon-chain/core/blocks/randao_test.go | 4 +- beacon-chain/core/blocks/signature.go | 4 +- beacon-chain/core/epoch/BUILD.bazel | 4 +- beacon-chain/core/epoch/epoch_processing.go | 8 +- .../core/epoch/epoch_processing_fuzz_test.go | 4 +- .../core/epoch/epoch_processing_test.go | 44 +- .../core/epoch/precompute/BUILD.bazel | 4 +- .../core/epoch/precompute/attestation.go | 12 +- .../core/epoch/precompute/attestation_test.go | 22 +- .../justification_finalization_test.go | 8 +- .../core/epoch/precompute/new_test.go | 4 +- .../epoch/precompute/reward_penalty_test.go | 26 +- .../core/epoch/precompute/slashing_test.go | 16 +- beacon-chain/core/helpers/BUILD.bazel | 4 +- beacon-chain/core/helpers/attestation_test.go | 4 +- beacon-chain/core/helpers/block_test.go | 6 +- beacon-chain/core/helpers/committee_test.go | 34 +- beacon-chain/core/helpers/randao_test.go | 8 +- .../core/helpers/rewards_penalties_test.go | 18 +- beacon-chain/core/helpers/signing_root.go | 6 +- .../core/helpers/signing_root_test.go | 4 +- beacon-chain/core/helpers/slot_epoch_test.go | 8 +- beacon-chain/core/helpers/validators.go | 4 +- beacon-chain/core/helpers/validators_test.go | 42 +- beacon-chain/core/state/BUILD.bazel | 6 +- beacon-chain/core/state/benchmarks_test.go | 6 +- beacon-chain/core/state/state.go | 18 +- beacon-chain/core/state/state_test.go | 8 +- .../core/state/stateutils/BUILD.bazel | 2 +- .../stateutils/validator_index_map_test.go | 4 +- beacon-chain/core/state/transition_test.go | 26 +- beacon-chain/core/validators/BUILD.bazel | 2 +- .../core/validators/validator_test.go | 34 +- beacon-chain/db/iface/BUILD.bazel | 2 +- beacon-chain/db/iface/interface.go | 10 +- beacon-chain/db/kafka/BUILD.bazel | 2 +- beacon-chain/db/kafka/passthrough.go | 10 +- beacon-chain/db/kv/BUILD.bazel | 4 +- beacon-chain/db/kv/encoding.go | 4 +- beacon-chain/db/kv/genesis.go | 6 +- beacon-chain/db/kv/state.go | 14 +- 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/BUILD.bazel | 2 +- beacon-chain/interop-cold-start/service.go | 4 +- .../operations/voluntaryexits/BUILD.bazel | 2 +- .../operations/voluntaryexits/service_test.go | 6 +- beacon-chain/p2p/BUILD.bazel | 10 +- beacon-chain/p2p/broadcaster_test.go | 9 +- beacon-chain/p2p/discovery_test.go | 4 +- beacon-chain/p2p/encoder/BUILD.bazel | 2 +- beacon-chain/p2p/encoder/ssz_test.go | 22 +- beacon-chain/p2p/fork.go | 2 +- beacon-chain/p2p/fork_test.go | 2 +- .../p2p/gossip_scoring_params_test.go | 4 +- beacon-chain/p2p/interfaces.go | 4 +- beacon-chain/p2p/peers/BUILD.bazel | 8 +- beacon-chain/p2p/peers/peerdata/BUILD.bazel | 3 +- beacon-chain/p2p/peers/peerdata/store.go | 9 +- beacon-chain/p2p/peers/scorers/BUILD.bazel | 2 - beacon-chain/p2p/peers/scorers/peer_status.go | 2 +- .../p2p/peers/scorers/peer_status_test.go | 2 +- beacon-chain/p2p/peers/status.go | 8 +- beacon-chain/p2p/peers/status_test.go | 4 +- beacon-chain/p2p/rpc_topic_mappings.go | 2 +- beacon-chain/p2p/rpc_topic_mappings_test.go | 2 +- beacon-chain/p2p/sender_test.go | 10 +- beacon-chain/p2p/service.go | 6 +- beacon-chain/p2p/subnets.go | 4 +- beacon-chain/p2p/subnets_test.go | 4 +- beacon-chain/p2p/testing/BUILD.bazel | 4 +- beacon-chain/p2p/testing/fuzz_p2p.go | 9 +- .../p2p/testing/mock_metadataprovider.go | 6 +- .../p2p/testing/mock_peersprovider.go | 2 +- beacon-chain/p2p/testing/p2p.go | 6 +- beacon-chain/p2p/utils.go | 12 +- beacon-chain/rpc/BUILD.bazel | 2 +- beacon-chain/rpc/eth/v1/beacon/BUILD.bazel | 2 +- beacon-chain/rpc/eth/v1/beacon/blocks_test.go | 4 +- beacon-chain/rpc/eth/v1/beacon/pool_test.go | 18 +- beacon-chain/rpc/eth/v1/beacon/state_test.go | 8 +- beacon-chain/rpc/eth/v1/debug/debug.go | 9 +- beacon-chain/rpc/eth/v1/node/BUILD.bazel | 4 +- beacon-chain/rpc/eth/v1/node/node_test.go | 4 +- .../rpc/prysm/v1alpha1/beacon/BUILD.bazel | 4 +- .../v1alpha1/beacon/attestations_test.go | 12 +- .../rpc/prysm/v1alpha1/beacon/blocks_test.go | 6 +- .../prysm/v1alpha1/beacon/committees_test.go | 4 +- .../rpc/prysm/v1alpha1/beacon/server.go | 4 +- .../prysm/v1alpha1/beacon/validators_test.go | 26 +- .../rpc/prysm/v1alpha1/validator/BUILD.bazel | 4 +- .../v1alpha1/validator/aggregator_test.go | 6 +- .../prysm/v1alpha1/validator/attester_test.go | 4 +- .../prysm/v1alpha1/validator/proposer_test.go | 46 +- .../rpc/prysm/v1alpha1/validator/server.go | 4 +- .../prysm/v1alpha1/validator/server_test.go | 14 +- .../prysm/v1alpha1/validator/status_test.go | 30 +- beacon-chain/rpc/service.go | 6 +- beacon-chain/rpc/statefetcher/BUILD.bazel | 2 +- beacon-chain/rpc/statefetcher/fetcher_test.go | 14 +- beacon-chain/state/genesis/BUILD.bazel | 2 +- beacon-chain/state/genesis/genesis.go | 4 +- beacon-chain/state/interface/BUILD.bazel | 2 +- beacon-chain/state/interface/altair.go | 10 +- beacon-chain/state/interface/phase0.go | 22 +- beacon-chain/state/stategen/BUILD.bazel | 4 +- 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/mock.go | 4 +- beacon-chain/state/stategen/replay_test.go | 10 +- beacon-chain/state/stategen/service.go | 4 +- beacon-chain/state/stategen/setter.go | 4 +- beacon-chain/state/stateutil/BUILD.bazel | 4 +- .../stateutil/pending_attestation_root.go | 6 +- .../state/stateutil/state_root_test.go | 6 +- beacon-chain/state/v1/BUILD.bazel | 4 +- beacon-chain/state/v1/field_roots.go | 6 +- beacon-chain/state/v1/field_trie_helpers.go | 10 +- 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 | 14 +- beacon-chain/state/v1/getters_test.go | 12 +- .../state/v1/getters_validator_test.go | 4 +- beacon-chain/state/v1/helpers_test.go | 4 +- beacon-chain/state/v1/references_test.go | 24 +- 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 | 6 +- 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 | 14 +- beacon-chain/state/v1/unsupported_getters.go | 6 +- beacon-chain/state/v1/unsupported_setters.go | 6 +- beacon-chain/state/v2/BUILD.bazel | 4 +- beacon-chain/state/v2/state_trie.go | 8 +- beacon-chain/state/v2/state_trie_test.go | 14 +- beacon-chain/state/v2/types.go | 4 +- beacon-chain/sync/BUILD.bazel | 10 +- beacon-chain/sync/initial-sync/BUILD.bazel | 6 +- .../sync/initial-sync/blocks_fetcher.go | 2 +- .../sync/initial-sync/blocks_fetcher_test.go | 2 +- .../sync/initial-sync/blocks_fetcher_utils.go | 2 +- .../initial-sync/blocks_fetcher_utils_test.go | 2 +- .../sync/initial-sync/initial_sync_test.go | 2 +- .../sync/pending_attestations_queue_test.go | 2 +- .../sync/pending_blocks_queue_test.go | 5 +- .../sync/rpc_beacon_blocks_by_range.go | 2 +- .../sync/rpc_beacon_blocks_by_range_test.go | 11 +- beacon-chain/sync/rpc_metadata.go | 8 +- beacon-chain/sync/rpc_metadata_test.go | 4 +- beacon-chain/sync/rpc_ping_test.go | 4 +- beacon-chain/sync/rpc_send_request.go | 2 +- beacon-chain/sync/rpc_send_request_test.go | 2 +- beacon-chain/sync/rpc_status.go | 2 +- beacon-chain/sync/rpc_status_test.go | 35 +- beacon-chain/sync/rpc_test.go | 8 +- beacon-chain/sync/service_test.go | 6 +- .../sync/validate_beacon_blocks_test.go | 18 +- .../sync/validate_proposer_slashing_test.go | 8 +- .../sync/validate_voluntary_exit_test.go | 8 +- fuzz/BUILD.bazel | 23 +- fuzz/generated.ssz.go | 13 +- fuzz/inputs.go | 4 +- fuzz/rpc_status_fuzz.go | 4 +- fuzz/state_fuzz.go | 6 +- fuzz/testing/BUILD.bazel | 2 +- fuzz/testing/beacon_fuzz_states.go | 6 +- proto/beacon/p2p/BUILD.bazel | 12 - proto/beacon/p2p/v1/wrapper/BUILD.bazel | 14 - proto/eth/v1/generated.ssz.go | 2 +- proto/interfaces/BUILD.bazel | 6 +- .../{block_interface.go => block.go} | 0 .../interface.go => interfaces/metadata.go} | 4 +- proto/prysm/v1alpha1/generated.ssz.go | 2 +- proto/prysm/v2/BUILD.bazel | 24 +- proto/prysm/v2/debug.pb.go | 29 +- proto/prysm/v2/debug.proto | 8 +- proto/prysm/v2/generated.ssz.go | 444 ++++++++++++++++- .../v2/p2p_messages.pb.go} | 4 +- .../v2/p2p_messages.proto} | 9 +- proto/prysm/v2/powchain.pb.go | 24 +- proto/prysm/v2/powchain.proto | 4 +- .../p2p/v1 => prysm/v2/state}/BUILD.bazel | 11 +- .../v2/state/beacon_state.pb.go} | 4 +- .../v2/state/beacon_state.proto} | 10 +- .../v1 => prysm/v2/state}/generated.ssz.go | 446 +----------------- proto/prysm/v2/wrapper/BUILD.bazel | 6 +- .../p2p/v1 => prysm/v2}/wrapper/metadata.go | 4 +- proto/testing/BUILD.bazel | 13 +- shared/benchutil/BUILD.bazel | 2 +- shared/benchutil/pregen.go | 6 +- shared/copyutil/BUILD.bazel | 4 +- shared/copyutil/cloners.go | 6 +- shared/copyutil/cloners_test.go | 6 +- shared/depositutil/BUILD.bazel | 4 +- shared/depositutil/deposit.go | 10 +- shared/depositutil/deposit_test.go | 6 +- shared/htrutils/BUILD.bazel | 4 +- shared/htrutils/htrutils.go | 4 +- shared/htrutils/htrutils_test.go | 4 +- shared/interop/BUILD.bazel | 2 +- shared/interop/generate_genesis_state.go | 10 +- shared/p2putils/BUILD.bazel | 2 +- shared/p2putils/fork.go | 6 +- shared/sszutil/BUILD.bazel | 2 +- shared/sszutil/deep_equal_test.go | 8 +- shared/testutil/BUILD.bazel | 4 +- shared/testutil/deposits.go | 10 +- shared/testutil/state.go | 14 +- shared/testutil/state_test.go | 4 +- .../phase0/epoch_processing/BUILD.bazel | 2 +- .../shared/phase0/epoch_processing/helpers.go | 6 +- spectest/shared/phase0/finality/BUILD.bazel | 2 +- spectest/shared/phase0/finality/runner.go | 6 +- spectest/shared/phase0/operations/BUILD.bazel | 2 +- .../shared/phase0/operations/block_header.go | 6 +- spectest/shared/phase0/operations/helpers.go | 6 +- spectest/shared/phase0/rewards/BUILD.bazel | 2 +- .../phase0/rewards/rewards_penalties.go | 4 +- spectest/shared/phase0/sanity/BUILD.bazel | 2 +- .../shared/phase0/sanity/block_processing.go | 6 +- .../shared/phase0/sanity/slot_processing.go | 6 +- spectest/shared/phase0/ssz_static/BUILD.bazel | 2 +- .../shared/phase0/ssz_static/ssz_static.go | 20 +- tools/benchmark-files-gen/BUILD.bazel | 2 +- tools/benchmark-files-gen/main.go | 4 +- tools/bootnode/BUILD.bazel | 2 +- tools/bootnode/bootnode.go | 2 +- tools/exploredb/BUILD.bazel | 2 +- tools/exploredb/main.go | 4 +- tools/genesis-state-gen/BUILD.bazel | 2 +- tools/genesis-state-gen/main.go | 6 +- tools/pcli/BUILD.bazel | 2 +- tools/pcli/main.go | 10 +- validator/client/BUILD.bazel | 2 +- validator/client/attest_test.go | 4 +- 270 files changed, 1548 insertions(+), 1542 deletions(-) delete mode 100644 proto/beacon/p2p/BUILD.bazel delete mode 100644 proto/beacon/p2p/v1/wrapper/BUILD.bazel rename proto/interfaces/{block_interface.go => block.go} (100%) rename proto/{beacon/p2p/interface.go => interfaces/metadata.go} (82%) rename proto/{beacon/p2p/v1/messages.pb.go => prysm/v2/p2p_messages.pb.go} (99%) rename proto/{beacon/p2p/v1/messages.proto => prysm/v2/p2p_messages.proto} (83%) rename proto/{beacon/p2p/v1 => prysm/v2/state}/BUILD.bazel (91%) rename proto/{beacon/p2p/v1/types.pb.go => prysm/v2/state/beacon_state.pb.go} (99%) rename proto/{beacon/p2p/v1/types.proto => prysm/v2/state/beacon_state.proto} (95%) rename proto/{beacon/p2p/v1 => prysm/v2/state}/generated.ssz.go (84%) mode change 100644 => 100755 rename proto/{beacon/p2p/v1 => prysm/v2}/wrapper/metadata.go (96%) diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index ecad603bb2..d06135799b 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -43,10 +43,10 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", @@ -107,7 +107,6 @@ go_test( "//beacon-chain/powchain:go_default_library", "//beacon-chain/state/stateutil:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", @@ -158,9 +157,9 @@ go_test( "//beacon-chain/db/testing:go_default_library", "//beacon-chain/p2p:go_default_library", "//beacon-chain/powchain:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/blockchain/chain_info.go b/beacon-chain/blockchain/chain_info.go index daf8de943c..e65feb35a2 100644 --- a/beacon-chain/blockchain/chain_info.go +++ b/beacon-chain/blockchain/chain_info.go @@ -8,9 +8,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -55,7 +55,7 @@ type HeadFetcher interface { // ForkFetcher retrieves the current fork information of the Ethereum beacon chain. type ForkFetcher interface { - CurrentFork() *pb.Fork + CurrentFork() *statepb.Fork } // CanonicalFetcher retrieves the current chain's canonical information. @@ -239,12 +239,12 @@ func (s *Service) GenesisValidatorRoot() [32]byte { } // CurrentFork retrieves the latest fork information of the beacon chain. -func (s *Service) CurrentFork() *pb.Fork { +func (s *Service) CurrentFork() *statepb.Fork { s.headLock.RLock() defer s.headLock.RUnlock() if !s.hasHeadState() { - return &pb.Fork{ + return &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, } diff --git a/beacon-chain/blockchain/chain_info_test.go b/beacon-chain/blockchain/chain_info_test.go index 5d115ae300..da375a0d60 100644 --- a/beacon-chain/blockchain/chain_info_test.go +++ b/beacon-chain/blockchain/chain_info_test.go @@ -10,9 +10,9 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -105,7 +105,7 @@ func TestPrevJustifiedCheckpt_GenesisRootOk(t *testing.T) { func TestHeadSlot_CanRetrieve(t *testing.T) { c := &Service{} - s, err := v1.InitializeFromProto(&pb.BeaconState{}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) c.head = &head{slot: 100, state: s} assert.Equal(t, types.Slot(100), c.HeadSlot()) @@ -127,7 +127,7 @@ func TestHeadRoot_UseDB(t *testing.T) { br, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) - require.NoError(t, beaconDB.SaveStateSummary(context.Background(), &pb.StateSummary{Root: br[:]})) + require.NoError(t, beaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Root: br[:]})) require.NoError(t, beaconDB.SaveHeadBlockRoot(context.Background(), br)) r, err := c.HeadRoot(context.Background()) require.NoError(t, err) @@ -137,7 +137,7 @@ func TestHeadRoot_UseDB(t *testing.T) { func TestHeadBlock_CanRetrieve(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 1 - s, err := v1.InitializeFromProto(&pb.BeaconState{}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) c := &Service{} c.head = &head{block: wrapper.WrappedPhase0SignedBeaconBlock(b), state: s} @@ -148,7 +148,7 @@ func TestHeadBlock_CanRetrieve(t *testing.T) { } func TestHeadState_CanRetrieve(t *testing.T) { - s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) require.NoError(t, err) c := &Service{} c.head = &head{state: s} @@ -164,8 +164,8 @@ func TestGenesisTime_CanRetrieve(t *testing.T) { } func TestCurrentFork_CanRetrieve(t *testing.T) { - f := &pb.Fork{Epoch: 999} - s, err := v1.InitializeFromProto(&pb.BeaconState{Fork: f}) + f := &statepb.Fork{Epoch: 999} + s, err := v1.InitializeFromProto(&statepb.BeaconState{Fork: f}) require.NoError(t, err) c := &Service{} c.head = &head{state: s} @@ -175,7 +175,7 @@ func TestCurrentFork_CanRetrieve(t *testing.T) { } func TestCurrentFork_NilHeadSTate(t *testing.T) { - f := &pb.Fork{ + f := &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, } @@ -190,7 +190,7 @@ func TestGenesisValidatorRoot_CanRetrieve(t *testing.T) { c := &Service{} assert.Equal(t, [32]byte{}, c.GenesisValidatorRoot(), "Did not get correct genesis validator root") - s, err := v1.InitializeFromProto(&pb.BeaconState{GenesisValidatorsRoot: []byte{'a'}}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{GenesisValidatorsRoot: []byte{'a'}}) require.NoError(t, err) c.head = &head{state: s} assert.Equal(t, [32]byte{'a'}, c.GenesisValidatorRoot(), "Did not get correct genesis validator root") @@ -204,7 +204,7 @@ func TestHeadETH1Data_Nil(t *testing.T) { func TestHeadETH1Data_CanRetrieve(t *testing.T) { d := ðpb.Eth1Data{DepositCount: 999} - s, err := v1.InitializeFromProto(&pb.BeaconState{Eth1Data: d}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{Eth1Data: d}) require.NoError(t, err) c := &Service{} c.head = &head{state: s} diff --git a/beacon-chain/blockchain/head_test.go b/beacon-chain/blockchain/head_test.go index 753d23d9fd..8a02e23bfb 100644 --- a/beacon-chain/blockchain/head_test.go +++ b/beacon-chain/blockchain/head_test.go @@ -9,10 +9,10 @@ import ( mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -60,7 +60,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(), &pb.StateSummary{Slot: 1, Root: newRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.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 +105,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(), &pb.StateSummary{Slot: 1, Root: newRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.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 +127,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(), &pb.StateSummary{Root: r[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.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 19ba577923..361eb46404 100644 --- a/beacon-chain/blockchain/metrics_test.go +++ b/beacon-chain/blockchain/metrics_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -25,7 +25,7 @@ func TestReportEpochMetrics_BadAttestation(t *testing.T) { require.NoError(t, err) h, err := testutil.NewBeaconState() require.NoError(t, err) - require.NoError(t, h.AppendCurrentEpochAttestations(&pb.PendingAttestation{InclusionDelay: 0})) + require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 0})) err = reportEpochMetrics(context.Background(), s, h) require.ErrorContains(t, "attestation with inclusion delay of 0", err) } @@ -36,7 +36,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(&pb.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(ð.AttestationData{})})) + require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.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 496e7bf21f..9015cc2006 100644 --- a/beacon-chain/blockchain/process_attestation_test.go +++ b/beacon-chain/blockchain/process_attestation_test.go @@ -10,9 +10,9 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -61,7 +61,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) { require.NoError(t, err) s, err = testutil.NewBeaconState() require.NoError(t, err) - err = s.SetFork(&pb.Fork{ + err = s.SetFork(&statepb.Fork{ Epoch: 0, CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -186,7 +186,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, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)})) s1, err := service.getAttPreState(ctx, cp1) require.NoError(t, err) @@ -194,7 +194,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, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 +218,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, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 a0d29730e3..9e3d4c94e1 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -11,10 +11,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -279,7 +279,7 @@ func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed interf if err := s.insertBlockToForkChoiceStore(ctx, b, blockRoot, fCheckpoint, jCheckpoint); err != nil { return err } - if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{ + if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 1548510697..5dc9457091 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -20,10 +20,10 @@ import ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -60,10 +60,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, &pb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2})) require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), bytesutil.ToBytes32(randomParentRoot2))) tests := []struct { @@ -256,7 +256,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) { service, err := NewService(ctx, cfg) require.NoError(t, err) - s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]}) require.NoError(t, err) genesisStateRoot := [32]byte{} @@ -273,7 +273,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, &pb.StateSummary{Slot: 1, Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 +308,9 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) { assert.ErrorContains(t, wanted, err) b.Block.ParentRoot = gRoot[:] - s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 1}) + s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1}) require.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 1, Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 +763,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, &pb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 +878,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, &pb.StateSummary{Root: gRoot[:]})) + require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.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 1a4dc5f523..7a7a1ed830 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -21,13 +21,13 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/powchain" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" protodb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/params" @@ -507,7 +507,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 := &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}} + bs := &statepb.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/blockchain/testing/BUILD.bazel b/beacon-chain/blockchain/testing/BUILD.bazel index 43a5bb9f31..9835c0268d 100644 --- a/beacon-chain/blockchain/testing/BUILD.bazel +++ b/beacon-chain/blockchain/testing/BUILD.bazel @@ -20,9 +20,9 @@ go_library( "//beacon-chain/forkchoice/protoarray:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index af9f641d2e..0f005686ad 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -19,10 +19,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db" "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/params" @@ -42,7 +42,7 @@ type ChainService struct { Genesis time.Time ValidatorsRoot [32]byte CanonicalRoots map[[32]byte]bool - Fork *pb.Fork + Fork *statepb.Fork ETH1Data *ethpb.Eth1Data DB db.Database stateNotifier statefeed.Notifier @@ -259,7 +259,7 @@ func (s *ChainService) HeadState(context.Context) (iface.BeaconState, error) { } // CurrentFork mocks HeadState method in chain service. -func (s *ChainService) CurrentFork() *pb.Fork { +func (s *ChainService) CurrentFork() *statepb.Fork { return s.Fork } diff --git a/beacon-chain/cache/BUILD.bazel b/beacon-chain/cache/BUILD.bazel index 1b73e7fa49..3f1c8d5ec9 100644 --- a/beacon-chain/cache/BUILD.bazel +++ b/beacon-chain/cache/BUILD.bazel @@ -63,8 +63,8 @@ go_test( deps = [ "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/cache/checkpoint_state_test.go b/beacon-chain/cache/checkpoint_state_test.go index ee8bdca142..4b572bcbcd 100644 --- a/beacon-chain/cache/checkpoint_state_test.go +++ b/beacon-chain/cache/checkpoint_state_test.go @@ -6,8 +6,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -19,7 +19,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { cache := NewCheckpointStateCache() cp1 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)} - st, err := v1.InitializeFromProto(&pb.BeaconState{ + st, err := v1.InitializeFromProto(&statepb.BeaconState{ GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:], Slot: 64, }) @@ -43,7 +43,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { } cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)} - st2, err := v1.InitializeFromProto(&pb.BeaconState{ + st2, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 128, }) require.NoError(t, err) @@ -60,7 +60,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) { func TestCheckpointStateCache_MaxSize(t *testing.T) { c := NewCheckpointStateCache() - st, err := v1.InitializeFromProto(&pb.BeaconState{ + st, err := v1.InitializeFromProto(&statepb.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 d8afaa43c5..e11cd443ea 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" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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)) - state, err = v1.InitializeFromProto(&pb.BeaconState{ + state, err = v1.InitializeFromProto(&statepb.BeaconState{ Slot: 10, }) require.NoError(t, err) diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 20fd69cc4d..de688e58b4 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -27,9 +27,9 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", @@ -76,9 +76,9 @@ go_test( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/aggregation:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", diff --git a/beacon-chain/core/blocks/attestation.go b/beacon-chain/core/blocks/attestation.go index 8762a8becb..abdb42dd23 100644 --- a/beacon-chain/core/blocks/attestation.go +++ b/beacon-chain/core/blocks/attestation.go @@ -8,9 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" @@ -205,7 +205,7 @@ func ProcessAttestationNoVerifySignature( if err != nil { return nil, err } - pendingAtt := &pb.PendingAttestation{ + pendingAtt := &statepb.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 a06893507d..d4df8559aa 100644 --- a/beacon-chain/core/blocks/attestation_regression_test.go +++ b/beacon-chain/core/blocks/attestation_regression_test.go @@ -8,8 +8,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -33,7 +33,7 @@ func TestProcessAttestationNoVerifySignature_BeaconFuzzIssue78(t *testing.T) { if err != nil { t.Fatal(err) } - spb := &pb.BeaconState{} + spb := &statepb.BeaconState{} if err := spb.UnmarshalSSZ(stateData); err != nil { t.Fatal(err) } @@ -73,7 +73,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.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 03f0277597..f58fb5da43 100644 --- a/beacon-chain/core/blocks/attestation_test.go +++ b/beacon-chain/core/blocks/attestation_test.go @@ -10,9 +10,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/aggregation" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" @@ -69,7 +69,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{})) want := fmt.Sprintf( "expected target epoch (%d) to be the previous epoch (%d) or the current epoch (%d)", @@ -102,7 +102,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) want := "source check point not equal to current justified checkpoint" _, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) @@ -140,7 +140,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{})) want := "source check point not equal to previous justified checkpoint" _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) @@ -176,7 +176,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.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 +201,7 @@ func TestProcessAttestations_OK(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex) require.NoError(t, err) @@ -243,7 +243,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) @@ -306,7 +306,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { cfc := beaconState.CurrentJustifiedCheckpoint() cfc.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) require.NoError(t, err) @@ -396,7 +396,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) _, err = blocks.ProcessAttestationNoVerifySignature(context.TODO(), beaconState, att) assert.NoError(t, err) @@ -427,7 +427,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att) assert.NoError(t, err) @@ -453,7 +453,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(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) err := blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att) require.ErrorContains(t, "committee index 100 >= committee count 1", err) } @@ -467,7 +467,7 @@ func TestConvertToIndexed_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 5, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -525,10 +525,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 5, Validators: validators, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ Epoch: 0, CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -676,7 +676,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(&pb.Fork{ + require.NoError(t, st.SetFork(&statepb.Fork{ Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: params.BeaconConfig().GenesisForkVersion, @@ -803,7 +803,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(&pb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}})) + require.NoError(t, st.SetFork(&statepb.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 92addf2060..0ce9f65e52 100644 --- a/beacon-chain/core/blocks/attester_slashing_test.go +++ b/beacon-chain/core/blocks/attester_slashing_test.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -47,7 +47,7 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) { var registry []*ethpb.Validator currentSlot := types.Slot(0) - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Slot: currentSlot, }) @@ -66,7 +66,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T) var registry []*ethpb.Validator currentSlot := types.Slot(0) - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.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 6ba4839e70..75001de8aa 100644 --- a/beacon-chain/core/blocks/block_operations_fuzz_test.go +++ b/beacon-chain/core/blocks/block_operations_fuzz_test.go @@ -8,10 +8,10 @@ import ( types "github.com/prysmaticlabs/eth2-types" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -19,7 +19,7 @@ import ( func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) ctx := context.Background() - state := &pb.BeaconState{} + state := &statepb.BeaconState{} att := ð.Attestation{} for i := 0; i < 10000; i++ { @@ -34,7 +34,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { func TestFuzzProcessBlockHeader_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} block := ð.SignedBeaconBlock{} for i := 0; i < 10000; i++ { @@ -106,7 +106,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { for i := 0; i < 100000; i++ { fuzzer.Fuzz(eth1data) fuzzer.Fuzz(&stateVotes) - s, err := v1.InitializeFromProto(&pb.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1DataVotes: stateVotes, }) require.NoError(t, err) @@ -118,7 +118,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) { func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} block := ð.BeaconBlock{} for i := 0; i < 10000; i++ { @@ -133,7 +133,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) { func TestFuzzProcessRandao_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} b := ð.SignedBeaconBlock{} for i := 0; i < 10000; i++ { @@ -150,7 +150,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) { func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} blockBody := ð.BeaconBlockBody{} for i := 0; i < 10000; i++ { @@ -167,7 +167,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) { func TestFuzzProcessProposerSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} p := ð.ProposerSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -184,7 +184,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) { func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} proposerSlashing := ð.ProposerSlashing{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -198,7 +198,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) { func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} a := ð.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -215,7 +215,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) { func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} attesterSlashing := ð.AttesterSlashing{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -252,7 +252,7 @@ func TestFuzzslashableAttesterIndices_10000(t *testing.T) { func TestFuzzProcessAttestations_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} b := ð.SignedBeaconBlock{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -269,7 +269,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) { func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} b := ð.SignedBeaconBlock{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -286,7 +286,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { func TestFuzzProcessAttestation_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} attestation := ð.Attestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -303,7 +303,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) { func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} idxAttestation := ð.IndexedAttestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -318,7 +318,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) { func TestFuzzVerifyAttestation_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} attestation := ð.Attestation{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -333,7 +333,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) { func TestFuzzProcessDeposits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} deposits := make([]*eth.Deposit, 100) ctx := context.Background() for i := 0; i < 10000; i++ { @@ -352,7 +352,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) { func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} deposit := ð.Deposit{} ctx := context.Background() @@ -370,7 +370,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) { func TestFuzzProcessDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} deposit := ð.Deposit{} for i := 0; i < 10000; i++ { @@ -387,7 +387,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) { func TestFuzzverifyDeposit_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} deposit := ð.Deposit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -401,7 +401,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) { func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} e := ð.SignedVoluntaryExit{} ctx := context.Background() for i := 0; i < 10000; i++ { @@ -418,7 +418,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) { func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - state := &pb.BeaconState{} + state := &statepb.BeaconState{} e := ð.SignedVoluntaryExit{} for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) @@ -437,7 +437,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) { ve := ð.SignedVoluntaryExit{} val, err := v1.NewValidator(ðpb.Validator{}) _ = err - fork := &pb.Fork{} + fork := &statepb.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 b62226bb65..c495d183d3 100644 --- a/beacon-chain/core/blocks/deposit.go +++ b/beacon-chain/core/blocks/deposit.go @@ -7,8 +7,8 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/depositutil" @@ -258,7 +258,7 @@ func verifyDepositDataWithDomain(ctx context.Context, deps []*ethpb.Deposit, dom } pks[i] = dpk sigs[i] = dep.Data.Signature - depositMessage := &pb.DepositMessage{ + depositMessage := &statepb.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 b4fda5fc29..dde16e0fe7 100644 --- a/beacon-chain/core/blocks/deposit_test.go +++ b/beacon-chain/core/blocks/deposit_test.go @@ -8,8 +8,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -40,11 +40,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -80,7 +80,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) { Deposits: []*ethpb.Deposit{deposit}, }, } - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ DepositRoot: []byte{0}, BlockHash: []byte{1}, @@ -111,11 +111,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -174,7 +174,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T) } balances := []uint64{0, 50} root := depositTrie.Root() - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: ðpb.Eth1Data{ @@ -202,11 +202,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -244,11 +244,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -299,11 +299,11 @@ func TestPreGenesisDeposits_SkipInvalidDeposit(t *testing.T) { }, } balances := []uint64{0} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Balances: balances, Eth1Data: eth1Data, - Fork: &pb.Fork{ + Fork: &statepb.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 4bd609adb1..113bf70b4a 100644 --- a/beacon-chain/core/blocks/eth1_data_test.go +++ b/beacon-chain/core/blocks/eth1_data_test.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -71,7 +71,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) { c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength params.OverrideBeaconConfig(c) - s, err := v1.InitializeFromProto(&pb.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1DataVotes: tt.stateVotes, }) require.NoError(t, err) @@ -161,7 +161,7 @@ func TestAreEth1DataEqual(t *testing.T) { } func TestProcessEth1Data_SetsCorrectly(t *testing.T) { - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.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 745d8dd2f1..d90036cdb8 100644 --- a/beacon-chain/core/blocks/exit.go +++ b/beacon-chain/core/blocks/exit.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -90,7 +90,7 @@ func ProcessVoluntaryExits( func VerifyExitAndSignature( validator iface.ReadOnlyValidator, currentSlot types.Slot, - fork *pb.Fork, + fork *statepb.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 602931e4e3..01f6a18347 100644 --- a/beacon-chain/core/blocks/exit_test.go +++ b/beacon-chain/core/blocks/exit_test.go @@ -8,8 +8,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -31,7 +31,7 @@ func TestProcessVoluntaryExits_NotActiveLongEnoughToExit(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, }, } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Slot: 10, }) @@ -61,7 +61,7 @@ func TestProcessVoluntaryExits_ExitAlreadySubmitted(t *testing.T) { ExitEpoch: 10, }, } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Slot: 0, }) @@ -93,9 +93,9 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) { ActivationEpoch: 0, }, } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, - Fork: &pb.Fork{ + Fork: &statepb.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 82dc687159..011ce6db97 100644 --- a/beacon-chain/core/blocks/proposer_slashing_regression_test.go +++ b/beacon-chain/core/blocks/proposer_slashing_regression_test.go @@ -6,9 +6,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -20,7 +19,7 @@ import ( func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) { file, err := ioutil.ReadFile("testdata/beaconfuzz_91_beacon.ssz") require.NoError(t, err) - rawState := &pb.BeaconState{} + rawState := &statepb.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 ea55c86d03..dc27f81903 100644 --- a/beacon-chain/core/blocks/proposer_slashing_test.go +++ b/beacon-chain/core/blocks/proposer_slashing_test.go @@ -11,8 +11,8 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -118,7 +118,7 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, Slot: currentSlot, }) diff --git a/beacon-chain/core/blocks/randao_test.go b/beacon-chain/core/blocks/randao_test.go index a8880a7553..d1e33015bc 100644 --- a/beacon-chain/core/blocks/randao_test.go +++ b/beacon-chain/core/blocks/randao_test.go @@ -8,9 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -27,7 +27,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 := (&pb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot() + root, err := (&statepb.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/blocks/signature.go b/beacon-chain/core/blocks/signature.go index 243b562a0f..07c8cb84d6 100644 --- a/beacon-chain/core/blocks/signature.go +++ b/beacon-chain/core/blocks/signature.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" @@ -21,7 +21,7 @@ func signatureSet(signedData, pub, signature, domain []byte) (*bls.SignatureSet, if err != nil { return nil, errors.Wrap(err, "could not convert bytes to public key") } - signingData := &pb.SigningData{ + signingData := &statepb.SigningData{ ObjectRoot: signedData, Domain: domain, } diff --git a/beacon-chain/core/epoch/BUILD.bazel b/beacon-chain/core/epoch/BUILD.bazel index 3db30e8c5e..d4a114efab 100644 --- a/beacon-chain/core/epoch/BUILD.bazel +++ b/beacon-chain/core/epoch/BUILD.bazel @@ -12,8 +12,8 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/copyutil:go_default_library", "//shared/featureconfig:go_default_library", @@ -36,8 +36,8 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index ab0a98cf97..ec38e3f598 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -13,8 +13,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -56,7 +56,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 iface.ReadOnlyBeaconState, atts []*pb.PendingAttestation) (uint64, error) { +func AttestingBalance(state iface.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) (uint64, error) { indices, err := UnslashedAttestingIndices(state, atts) if err != nil { return 0, errors.Wrap(err, "could not get attesting indices") @@ -378,7 +378,7 @@ func ProcessHistoricalRootsUpdate(state iface.BeaconState) (iface.BeaconState, e // Set historical root accumulator. epochsPerHistoricalRoot := params.BeaconConfig().SlotsPerHistoricalRoot.DivSlot(params.BeaconConfig().SlotsPerEpoch) if nextEpoch.Mod(uint64(epochsPerHistoricalRoot)) == 0 { - historicalBatch := &pb.HistoricalBatch{ + historicalBatch := &statepb.HistoricalBatch{ BlockRoots: state.BlockRoots(), StateRoots: state.StateRoots(), } @@ -461,7 +461,7 @@ func ProcessFinalUpdates(state iface.BeaconState) (iface.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 iface.ReadOnlyBeaconState, atts []*pb.PendingAttestation) ([]types.ValidatorIndex, error) { +func UnslashedAttestingIndices(state iface.ReadOnlyBeaconState, atts []*statepb.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 19ffa3386b..97c3f3b2cf 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" - ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestFuzzFinalUpdates_10000(t *testing.T) { fuzzer := fuzz.NewWithSeed(0) - base := ðereum_beacon_p2p_v1.BeaconState{} + base := &statepb.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 67eaefee0e..6eafddd3b9 100644 --- a/beacon-chain/core/epoch/epoch_processing_test.go +++ b/beacon-chain/core/epoch/epoch_processing_test.go @@ -9,9 +9,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -21,9 +21,9 @@ import ( func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { // Generate 2 attestations. - atts := make([]*pb.PendingAttestation, 2) + atts := make([]*statepb.PendingAttestation, 2) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{Source: ðpb.Checkpoint{Root: make([]byte, 32)}, Target: ðpb.Checkpoint{Epoch: 0, Root: make([]byte, 32)}, }, @@ -39,7 +39,7 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } @@ -68,9 +68,9 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) { func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { // Generate 5 of the same attestations. - atts := make([]*pb.PendingAttestation, 5) + atts := make([]*statepb.PendingAttestation, 5) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.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 +85,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), } @@ -105,9 +105,9 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) { func TestAttestingBalance_CorrectBalance(t *testing.T) { helpers.ClearCache() // Generate 2 attestations. - atts := make([]*pb.PendingAttestation, 2) + atts := make([]*statepb.PendingAttestation, 2) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -128,7 +128,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { } balances[i] = params.BeaconConfig().MaxEffectiveBalance } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: 2, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -145,7 +145,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) { } func TestProcessSlashings_NotSlashed(t *testing.T) { - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{Slashed: true}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -161,11 +161,11 @@ func TestProcessSlashings_NotSlashed(t *testing.T) { func TestProcessSlashings_SlashedLess(t *testing.T) { tests := []struct { - state *pb.BeaconState + state *statepb.BeaconState want uint64 }{ { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -179,7 +179,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -195,7 +195,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(32000000000), // 32 * 1e9 - 500000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -211,7 +211,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -277,7 +277,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) { } func TestProcessRegistryUpdates_NoRotation(t *testing.T) { - base := &pb.BeaconState{ + base := &statepb.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 := &pb.BeaconState{ + base := &statepb.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 := &pb.BeaconState{ + base := &statepb.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 := &pb.BeaconState{ + base := &statepb.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 := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(e)), Validators: []*ethpb.Validator{ { diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index 8290c2c165..c2e1c44d1f 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -18,8 +18,8 @@ go_library( deps = [ "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", @@ -45,8 +45,8 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index fa6ce23013..89f7c7d20b 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" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, bool, error) { +func AttestedCurrentEpoch(s iface.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, error) { currentEpoch := helpers.CurrentEpoch(s) var votedCurrentEpoch, votedTarget bool // Did validator vote current epoch. @@ -87,7 +87,7 @@ func AttestedCurrentEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation) } // AttestedPrevEpoch returns true if attestation `a` attested once in previous epoch and epoch boundary block and/or the same head. -func AttestedPrevEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, bool, bool, error) { +func AttestedPrevEpoch(s iface.ReadOnlyBeaconState, a *statepb.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 iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (b } // SameTarget returns true if attestation `a` attested to the same target block in state. -func SameTarget(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation, e types.Epoch) (bool, error) { +func SameTarget(state iface.ReadOnlyBeaconState, a *statepb.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 iface.ReadOnlyBeaconState, a *pb.PendingAttestation, e typ } // SameHead returns true if attestation `a` attested to the same block by attestation slot in state. -func SameHead(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, error) { +func SameHead(state iface.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, error) { r, err := helpers.BlockRootAtSlot(state, a.Data.Slot) if err != nil { return false, err @@ -139,7 +139,7 @@ func SameHead(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, } // UpdateValidator updates pre computed validator store. -func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *pb.PendingAttestation, aSlot types.Slot) []*Validator { +func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *statepb.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 1dd3b93169..3c267f7b70 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -7,8 +7,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -21,7 +21,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 := &pb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} + a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} // Indices 1 3 and 5 attested vp = precompute.UpdateValidator(vp, record, []uint64{1, 3, 5}, a, 100) @@ -37,7 +37,7 @@ func TestUpdateValidator_InclusionOnlyCountsPrevEpoch(t *testing.T) { e := params.BeaconConfig().FarFutureSlot vp := []*precompute.Validator{{InclusionSlot: e}} record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true} - a := &pb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} + a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2} // Verify inclusion info doesnt get updated. vp = precompute.UpdateValidator(vp, record, []uint64{0}, a, 100) @@ -80,12 +80,12 @@ func TestSameHead(t *testing.T) { br[0] = r[:] require.NoError(t, beaconState.SetBlockRoots(br)) att.Data.BeaconBlockRoot = r[:] - same, err := precompute.SameHead(beaconState, &pb.PendingAttestation{Data: att.Data}) + same, err := precompute.SameHead(beaconState, &statepb.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, &pb.PendingAttestation{Data: att.Data}) + same, err = precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data}) require.NoError(t, err) assert.Equal(t, false, same, "Head in state matches head in attestation") } @@ -100,12 +100,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, &pb.PendingAttestation{Data: att.Data}, 0) + same, err := precompute.SameTarget(beaconState, &statepb.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, &pb.PendingAttestation{Data: att.Data}, 0) + same, err = precompute.SameTarget(beaconState, &statepb.PendingAttestation{Data: att.Data}, 0) require.NoError(t, err) assert.Equal(t, false, same, "Head in state matches head in attestation") } @@ -121,7 +121,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, &pb.PendingAttestation{Data: att.Data}) + votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &statepb.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 +140,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, &pb.PendingAttestation{Data: att.Data}) + votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &statepb.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 +170,9 @@ func TestProcessAttestations(t *testing.T) { require.NoError(t, beaconState.SetBlockRoots(br)) att2.Data.Target.Root = newRt[:] att2.Data.BeaconBlockRoot = newRt[:] - err := beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1}) + err := beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1}) require.NoError(t, err) - err = beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1}) + err = beaconState.AppendCurrentEpochAttestations(&statepb.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 ee1138278d..6a13b5fef8 100644 --- a/beacon-chain/core/epoch/precompute/justification_finalization_test.go +++ b/beacon-chain/core/epoch/precompute/justification_finalization_test.go @@ -7,8 +7,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -21,7 +21,7 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 0, @@ -58,7 +58,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{ Epoch: 0, @@ -95,7 +95,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi for i := 0; i < len(blockRoots); i++ { blockRoots[i] = []byte{byte(i)} } - base := &pb.BeaconState{ + base := &statepb.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 4066c6cc98..ab34139f12 100644 --- a/beacon-chain/core/epoch/precompute/new_test.go +++ b/beacon-chain/core/epoch/precompute/new_test.go @@ -6,8 +6,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -15,7 +15,7 @@ import ( func TestNew(t *testing.T) { ffe := params.BeaconConfig().FarFutureEpoch - s, err := v1.InitializeFromProto(&pb.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.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 b6a7b4dbba..99813878e8 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -23,9 +23,9 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+3, validatorCount) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -62,10 +62,10 @@ func TestAttestationDeltaPrecompute(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -146,10 +146,10 @@ func TestAttestationDeltas_ZeroEpoch(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -182,10 +182,10 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) { e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+2, validatorCount) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) var emptyRoot [32]byte for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{ Root: emptyRoot[:], @@ -215,9 +215,9 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing. e := params.BeaconConfig().SlotsPerEpoch validatorCount := uint64(2048) base := buildState(e+3, validatorCount) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -259,7 +259,7 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing. } } -func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState { +func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState { validators := make([]*ethpb.Validator, validatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -285,7 +285,7 @@ func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState { for i := 0; i < len(latestRandaoMixes); i++ { latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:] } - return &pb.BeaconState{ + return &statepb.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 ecc840a6ae..85bfc18dab 100644 --- a/beacon-chain/core/epoch/precompute/slashing_test.go +++ b/beacon-chain/core/epoch/precompute/slashing_test.go @@ -6,8 +6,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -15,7 +15,7 @@ import ( ) func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) { - s, err := v1.InitializeFromProto(&pb.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{Slashed: true}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -30,7 +30,7 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) { } func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) { - s, err := v1.InitializeFromProto(&pb.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{{}}, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance}, @@ -46,11 +46,11 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) { func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { tests := []struct { - state *pb.BeaconState + state *statepb.BeaconState want uint64 }{ { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -64,7 +64,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -80,7 +80,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(32000000000), // 32 * 1e9 - 500000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, @@ -96,7 +96,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) { want: uint64(31000000000), // 32 * 1e9 - 1000000000 }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ {Slashed: true, WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2, diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 222a9d9815..9c28a9731a 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -36,9 +36,9 @@ go_library( deps = [ "//beacon-chain/cache:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", @@ -76,8 +76,8 @@ go_test( "//beacon-chain/cache:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index cb4e88d9ec..47550d3b62 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -98,7 +98,7 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.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 5d8aabf725..340f616717 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{ + s := &statepb.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 := &pb.BeaconState{ + state := &statepb.BeaconState{ BlockRoots: blockRoots, } diff --git a/beacon-chain/core/helpers/committee_test.go b/beacon-chain/core/helpers/committee_test.go index 48f13d760d..7dac355dbb 100644 --- a/beacon-chain/core/helpers/committee_test.go +++ b/beacon-chain/core/helpers/committee_test.go @@ -9,8 +9,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -35,7 +35,7 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 200, BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), @@ -91,7 +91,7 @@ func TestVerifyBitfieldLength_OK(t *testing.T) { func TestCommitteeAssignments_CannotRetrieveFutureEpoch(t *testing.T) { ClearCache() epoch := types.Epoch(1) - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, // Epoch 0. }) require.NoError(t, err) @@ -111,7 +111,7 @@ func TestCommitteeAssignments_NoProposerForSlot0(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2 RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -142,7 +142,7 @@ func TestCommitteeAssignments_CanRetrieve(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2 RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -219,7 +219,7 @@ func TestCommitteeAssignments_CannotRetrieveFuture(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2 RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -243,7 +243,7 @@ func TestCommitteeAssignments_EverySlotHasMin1Proposer(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2 RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -280,7 +280,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: activeRoots, }) @@ -378,7 +378,7 @@ func TestShuffledIndices_ShuffleRightLength(t *testing.T) { } indices[i] = uint64(i) } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -411,7 +411,7 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) { } indices[i] = i } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -435,7 +435,7 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -469,7 +469,7 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -503,7 +503,7 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -538,7 +538,7 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -573,7 +573,7 @@ func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -610,7 +610,7 @@ func TestBeaconCommitteeFromState_UpdateCacheForPreviousEpoch(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -635,7 +635,7 @@ func TestPrecomputeProposerIndices_Ok(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) diff --git a/beacon-chain/core/helpers/randao_test.go b/beacon-chain/core/helpers/randao_test.go index 00755f285e..2c156fd490 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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(&pb.BeaconState{RandaoMixes: randaoMixes}) + state, err := v1.InitializeFromProto(&statepb.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(&pb.BeaconState{RandaoMixes: randaoMixes}) + state, err := v1.InitializeFromProto(&statepb.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(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ RandaoMixes: randaoMixes, Slot: slot, }) diff --git a/beacon-chain/core/helpers/rewards_penalties_test.go b/beacon-chain/core/helpers/rewards_penalties_test.go index f32f8e6e5a..f2033e538e 100644 --- a/beacon-chain/core/helpers/rewards_penalties_test.go +++ b/beacon-chain/core/helpers/rewards_penalties_test.go @@ -5,15 +5,15 @@ import ( types "github.com/prysmaticlabs/eth2-types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestTotalBalance_OK(t *testing.T) { - state, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{Validators: []*ethpb.Validator{ {EffectiveBalance: 27 * 1e9}, {EffectiveBalance: 28 * 1e9}, {EffectiveBalance: 32 * 1e9}, {EffectiveBalance: 40 * 1e9}, }}) @@ -26,7 +26,7 @@ func TestTotalBalance_OK(t *testing.T) { } func TestTotalBalance_ReturnsEffectiveBalanceIncrement(t *testing.T) { - state, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{}}) + state, err := v1.InitializeFromProto(&statepb.BeaconState{Validators: []*ethpb.Validator{}}) require.NoError(t, err) balance := TotalBalance(state, []types.ValidatorIndex{}) @@ -35,7 +35,7 @@ func TestTotalBalance_ReturnsEffectiveBalanceIncrement(t *testing.T) { } func TestTotalActiveBalance_OK(t *testing.T) { - state, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{Validators: []*ethpb.Validator{ { EffectiveBalance: 32 * 1e9, ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -74,7 +74,7 @@ func TestGetBalance_OK(t *testing.T) { {i: 2, b: []uint64{0, 0, 0}}, } for _, test := range tests { - state, err := v1.InitializeFromProto(&pb.BeaconState{Balances: test.b}) + state, err := v1.InitializeFromProto(&statepb.BeaconState{Balances: test.b}) require.NoError(t, err) assert.Equal(t, test.b[test.i], state.Balances()[test.i], "Incorrect Validator balance") } @@ -92,7 +92,7 @@ func TestIncreaseBalance_OK(t *testing.T) { {i: 2, b: []uint64{27 * 1e9, 28 * 1e9, 32 * 1e9}, nb: 33 * 1e9, eb: 65 * 1e9}, } for _, test := range tests { - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: []*ethpb.Validator{ {EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 4}}, Balances: test.b, @@ -116,7 +116,7 @@ func TestDecreaseBalance_OK(t *testing.T) { {i: 3, b: []uint64{27 * 1e9, 28 * 1e9, 1, 28 * 1e9}, nb: 28 * 1e9, eb: 0}, } for _, test := range tests { - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: []*ethpb.Validator{ {EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 3}}, Balances: test.b, @@ -179,7 +179,7 @@ func TestIsInInactivityLeak(t *testing.T) { assert.Equal(t, false, IsInInactivityLeak(prevEpoch, finalizedEpoch), "Wanted inactivity leak false") } -func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState { +func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState { validators := make([]*ethpb.Validator, validatorCount) for i := 0; i < len(validators); i++ { validators[i] = ðpb.Validator{ @@ -205,7 +205,7 @@ func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState { for i := 0; i < len(latestRandaoMixes); i++ { latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:] } - return &pb.BeaconState{ + return &statepb.BeaconState{ Slot: slot, Balances: validatorBalances, Validators: validators, diff --git a/beacon-chain/core/helpers/signing_root.go b/beacon-chain/core/helpers/signing_root.go index 78db9898f7..19edbd3b0c 100644 --- a/beacon-chain/core/helpers/signing_root.go +++ b/beacon-chain/core/helpers/signing_root.go @@ -5,8 +5,8 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -57,7 +57,7 @@ func signingData(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, er if err != nil { return [32]byte{}, err } - container := &pb.SigningData{ + container := &statepb.SigningData{ ObjectRoot: objRoot[:], Domain: domain, } @@ -210,7 +210,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 := (&pb.ForkData{ + r, err := (&statepb.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 39848660ea..3b5a88cdc0 100644 --- a/beacon-chain/core/helpers/signing_root_test.go +++ b/beacon-chain/core/helpers/signing_root_test.go @@ -7,8 +7,8 @@ import ( fuzz "github.com/google/gofuzz" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := ðereum_beacon_p2p_v1.BeaconState{} + state := &statepb.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 137c197425..9ed7b733b8 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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(&pb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(&statepb.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(&pb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(&statepb.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(&pb.BeaconState{Slot: tt.slot}) + state, err := v1.InitializeFromProto(&statepb.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 e2b4991f00..60c3e91148 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -285,7 +285,7 @@ func ComputeProposerIndex(bState iface.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 *pb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) { +func Domain(fork *statepb.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/helpers/validators_test.go b/beacon-chain/core/helpers/validators_test.go index 01c180211c..b9857c0518 100644 --- a/beacon-chain/core/helpers/validators_test.go +++ b/beacon-chain/core/helpers/validators_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/cache" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -45,7 +45,7 @@ func TestIsActiveValidatorUsingTrie_OK(t *testing.T) { {a: 64, b: true}, } val := ðpb.Validator{ActivationEpoch: 10, ExitEpoch: 100} - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{val}}) + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{Validators: []*ethpb.Validator{val}}) require.NoError(t, err) for _, test := range tests { readOnlyVal, err := beaconState.ValidatorAtIndexReadOnly(0) @@ -210,7 +210,7 @@ func TestIsSlashableValidatorUsingTrie_OK(t *testing.T) { } for _, test := range tests { - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{test.validator}}) + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{Validators: []*ethpb.Validator{test.validator}}) require.NoError(t, err) readOnlyVal, err := beaconState.ValidatorAtIndexReadOnly(0) require.NoError(t, err) @@ -234,7 +234,7 @@ func TestBeaconProposerIndex_OK(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 0, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -293,7 +293,7 @@ func TestBeaconProposerIndex_BadState(t *testing.T) { roots[i] = make([]byte, 32) } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: 0, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -317,7 +317,7 @@ func TestComputeProposerIndex_Compatibility(t *testing.T) { } } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) @@ -364,7 +364,7 @@ func TestActiveValidatorCount_Genesis(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -400,7 +400,7 @@ func TestChurnLimit_OK(t *testing.T) { } } - beaconState, err := v1.InitializeFromProto(&pb.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 1, Validators: validators, RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -415,8 +415,8 @@ func TestChurnLimit_OK(t *testing.T) { } func TestDomain_OK(t *testing.T) { - state := &pb.BeaconState{ - Fork: &pb.Fork{ + state := &statepb.BeaconState{ + Fork: &statepb.Fork{ Epoch: 3, PreviousVersion: []byte{0, 0, 0, 2}, CurrentVersion: []byte{0, 0, 0, 3}, @@ -445,7 +445,7 @@ func TestDomain_OK(t *testing.T) { func TestActiveValidatorIndices(t *testing.T) { farFutureEpoch := params.BeaconConfig().FarFutureEpoch type args struct { - state *pb.BeaconState + state *statepb.BeaconState epoch types.Epoch } tests := []struct { @@ -457,7 +457,7 @@ func TestActiveValidatorIndices(t *testing.T) { { name: "all_active_epoch_10", args: args{ - state: &pb.BeaconState{ + state: &statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ { @@ -481,7 +481,7 @@ func TestActiveValidatorIndices(t *testing.T) { { name: "some_active_epoch_10", args: args{ - state: &pb.BeaconState{ + state: &statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ { @@ -505,7 +505,7 @@ func TestActiveValidatorIndices(t *testing.T) { { name: "some_active_with_recent_new_epoch_10", args: args{ - state: &pb.BeaconState{ + state: &statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ { @@ -533,7 +533,7 @@ func TestActiveValidatorIndices(t *testing.T) { { name: "some_active_with_recent_new_epoch_10", args: args{ - state: &pb.BeaconState{ + state: &statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ { @@ -561,7 +561,7 @@ func TestActiveValidatorIndices(t *testing.T) { { name: "some_active_with_recent_new_epoch_10", args: args{ - state: &pb.BeaconState{ + state: &statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ { @@ -698,7 +698,7 @@ func TestComputeProposerIndex(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - bState := &pb.BeaconState{Validators: tt.args.validators} + bState := &statepb.BeaconState{Validators: tt.args.validators} stTrie, err := v1.InitializeFromProtoUnsafe(bState) require.NoError(t, err) got, err := ComputeProposerIndex(stTrie, tt.args.indices, tt.args.seed) @@ -739,20 +739,20 @@ func TestIsIsEligibleForActivation(t *testing.T) { tests := []struct { name string validator *ethpb.Validator - state *pb.BeaconState + state *statepb.BeaconState want bool }{ {"Eligible", ðpb.Validator{ActivationEligibilityEpoch: 1, ActivationEpoch: params.BeaconConfig().FarFutureEpoch}, - &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}}, + &statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}}, true}, {"Not yet finalized", ðpb.Validator{ActivationEligibilityEpoch: 1, ActivationEpoch: params.BeaconConfig().FarFutureEpoch}, - &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}}, + &statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}}, false}, {"Incorrect activation epoch", ðpb.Validator{ActivationEligibilityEpoch: 1}, - &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}}, + &statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}}, false}, } for _, tt := range tests { diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index cea827a83f..1605ee6d73 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -34,9 +34,9 @@ go_library( "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", @@ -76,9 +76,9 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/benchutil:go_default_library", "//shared/bls:go_default_library", @@ -117,7 +117,7 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/benchutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/beacon-chain/core/state/benchmarks_test.go b/beacon-chain/core/state/benchmarks_test.go index bee1752136..81db81ac8b 100644 --- a/beacon-chain/core/state/benchmarks_test.go +++ b/beacon-chain/core/state/benchmarks_test.go @@ -8,8 +8,8 @@ import ( coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/benchutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -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, &pb.BeaconState{})) + require.NoError(b, proto.Unmarshal(protoObject, &statepb.BeaconState{})) } }) @@ -154,7 +154,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - sszState := &pb.BeaconState{} + sszState := &statepb.BeaconState{} require.NoError(b, sszState.UnmarshalSSZ(sszObject)) } }) diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index 99c15ae8b0..d3b1de0748 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -114,13 +114,13 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState, return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err) } - state := &pb.BeaconState{ + state := &statepb.BeaconState{ // Misc fields. Slot: 0, GenesisTime: genesisTime, GenesisValidatorsRoot: genesisValidatorsRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, @@ -152,8 +152,8 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState, BlockRoots: blockRoots, StateRoots: stateRoots, Slashings: slashings, - CurrentEpochAttestations: []*pb.PendingAttestation{}, - PreviousEpochAttestations: []*pb.PendingAttestation{}, + CurrentEpochAttestations: []*statepb.PendingAttestation{}, + PreviousEpochAttestations: []*statepb.PendingAttestation{}, // Eth1 data. Eth1Data: eth1Data, @@ -184,10 +184,10 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState, // EmptyGenesisState returns an empty beacon state object. func EmptyGenesisState() (iface.BeaconState, error) { - state := &pb.BeaconState{ + state := &statepb.BeaconState{ // Misc fields. Slot: 0, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, @@ -198,8 +198,8 @@ func EmptyGenesisState() (iface.BeaconState, error) { JustificationBits: []byte{0}, HistoricalRoots: [][]byte{}, - CurrentEpochAttestations: []*pb.PendingAttestation{}, - PreviousEpochAttestations: []*pb.PendingAttestation{}, + CurrentEpochAttestations: []*statepb.PendingAttestation{}, + PreviousEpochAttestations: []*statepb.PendingAttestation{}, // Eth1 data. Eth1Data: ðpb.Eth1Data{}, diff --git a/beacon-chain/core/state/state_test.go b/beacon-chain/core/state/state_test.go index 89b09c781e..c884501ece 100644 --- a/beacon-chain/core/state/state_test.go +++ b/beacon-chain/core/state/state_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -42,7 +42,7 @@ func TestGenesisBeaconState_OK(t *testing.T) { // Misc fields checks. assert.Equal(t, types.Slot(0), newState.Slot(), "Slot was not correctly initialized") - if !proto.Equal(newState.Fork(), &pb.Fork{ + if !proto.Equal(newState.Fork(), &statepb.Fork{ PreviousVersion: genesisForkVersion, CurrentVersion: genesisForkVersion, Epoch: genesisEpoch, @@ -76,10 +76,10 @@ func TestGenesisBeaconState_OK(t *testing.T) { assert.DeepEqual(t, make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), newState.Slashings(), "Slashings was not correctly initialized") currAtt, err := newState.CurrentEpochAttestations() require.NoError(t, err) - assert.DeepSSZEqual(t, []*pb.PendingAttestation{}, currAtt, "CurrentEpochAttestations was not correctly initialized") + assert.DeepSSZEqual(t, []*statepb.PendingAttestation{}, currAtt, "CurrentEpochAttestations was not correctly initialized") prevAtt, err := newState.CurrentEpochAttestations() require.NoError(t, err) - assert.DeepSSZEqual(t, []*pb.PendingAttestation{}, prevAtt, "PreviousEpochAttestations was not correctly initialized") + assert.DeepSSZEqual(t, []*statepb.PendingAttestation{}, prevAtt, "PreviousEpochAttestations was not correctly initialized") zeroHash := params.BeaconConfig().ZeroHash[:] // History root checks. diff --git a/beacon-chain/core/state/stateutils/BUILD.bazel b/beacon-chain/core/state/stateutils/BUILD.bazel index aeb3099e06..838d00db05 100644 --- a/beacon-chain/core/state/stateutils/BUILD.bazel +++ b/beacon-chain/core/state/stateutils/BUILD.bazel @@ -22,8 +22,8 @@ go_test( deps = [ ":go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", 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 a466884110..a79b8b9b1a 100644 --- a/beacon-chain/core/state/stateutils/validator_index_map_test.go +++ b/beacon-chain/core/state/stateutils/validator_index_map_test.go @@ -6,15 +6,15 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{ + base := &statepb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: []byte("zero"), diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index ec3ad7d444..9a4bd1f496 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -13,9 +13,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -33,7 +33,7 @@ func init() { } func TestExecuteStateTransition_IncorrectSlot(t *testing.T) { - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: 5, } beaconState, err := v1.InitializeFromProto(base) @@ -243,7 +243,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { cp := beaconState.CurrentJustifiedCheckpoint() cp.Root = []byte("hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) _, err = state.VerifyOperationLengths(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) wanted := "number of voluntary exits (17) in block body exceeds allowed threshold of 16" assert.ErrorContains(t, wanted, err) @@ -269,7 +269,7 @@ func createFullBlockWithOperations(t *testing.T) (iface.BeaconState, copy(mockRoot[:], "hello-world") cp.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) proposerSlashIdx := types.ValidatorIndex(3) slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch @@ -445,9 +445,9 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { func TestProcessEpochPrecompute_CanProcess(t *testing.T) { epoch := types.Epoch(1) - atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: make([]byte, 32)}}, InclusionDelay: 1}} + atts := []*statepb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: make([]byte, 32)}}, InclusionDelay: 1}} slashing := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector) - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)) + 1, BlockRoots: make([][]byte, 128), Slashings: slashing, @@ -489,7 +489,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { randaoMixes[i] = params.BeaconConfig().ZeroHash[:] } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Slot: 20, LatestBlockHeader: ðpb.BeaconBlockHeader{}, BlockRoots: make([][]byte, 254), @@ -500,7 +500,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { CurrentJustifiedCheckpoint: ðpb.Checkpoint{ Root: []byte("hello-world"), }, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: []byte{0, 0, 0, 0}, CurrentVersion: []byte{0, 0, 0, 0}, }, @@ -567,7 +567,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { binary.LittleEndian.PutUint64(buf, 0) domain, err := helpers.Domain(s.Fork(), 0, params.BeaconConfig().DomainRandao, s.GenesisValidatorRoot()) require.NoError(b, err) - ctr := &pb.SigningData{ + ctr := &statepb.SigningData{ ObjectRoot: buf, Domain: domain, } @@ -730,7 +730,7 @@ func TestCanProcessEpoch_TrueOnEpochs(t *testing.T) { } for _, tt := range tests { - b := &pb.BeaconState{Slot: tt.slot} + b := &statepb.BeaconState{Slot: tt.slot} s, err := v1.InitializeFromProto(b) require.NoError(t, err) assert.Equal(t, tt.canProcessEpoch, state.CanProcessEpoch(s), "CanProcessEpoch(%d)", tt.slot) @@ -797,7 +797,7 @@ func TestProcessBlock_OverMaxVoluntaryExits(t *testing.T) { } func TestProcessBlock_IncorrectDeposits(t *testing.T) { - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{DepositCount: 100}, Eth1DepositIndex: 98, } @@ -818,7 +818,7 @@ func TestProcessBlock_IncorrectDeposits(t *testing.T) { func TestProcessSlots_SameSlotAsParentState(t *testing.T) { slot := types.Slot(2) - parentState, err := v1.InitializeFromProto(&pb.BeaconState{Slot: slot}) + parentState, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: slot}) require.NoError(t, err) _, err = state.ProcessSlots(context.Background(), parentState, slot) @@ -827,7 +827,7 @@ func TestProcessSlots_SameSlotAsParentState(t *testing.T) { func TestProcessSlots_LowerSlotAsParentState(t *testing.T) { slot := types.Slot(2) - parentState, err := v1.InitializeFromProto(&pb.BeaconState{Slot: slot}) + parentState, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: slot}) require.NoError(t, err) _, err = state.ProcessSlots(context.Background(), parentState, slot-1) diff --git a/beacon-chain/core/validators/BUILD.bazel b/beacon-chain/core/validators/BUILD.bazel index b0d70aa40e..6662c9d397 100644 --- a/beacon-chain/core/validators/BUILD.bazel +++ b/beacon-chain/core/validators/BUILD.bazel @@ -26,8 +26,8 @@ go_test( deps = [ "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/beacon-chain/core/validators/validator_test.go b/beacon-chain/core/validators/validator_test.go index 1321361397..942ccc4c35 100644 --- a/beacon-chain/core/validators/validator_test.go +++ b/beacon-chain/core/validators/validator_test.go @@ -6,8 +6,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -41,7 +41,7 @@ func TestHasVoted_OK(t *testing.T) { func TestInitiateValidatorExit_AlreadyExited(t *testing.T) { exitEpoch := types.Epoch(199) - base := &pb.BeaconState{Validators: []*ethpb.Validator{{ + base := &statepb.BeaconState{Validators: []*ethpb.Validator{{ ExitEpoch: exitEpoch}, }} state, err := v1.InitializeFromProto(base) @@ -56,7 +56,7 @@ func TestInitiateValidatorExit_AlreadyExited(t *testing.T) { func TestInitiateValidatorExit_ProperExit(t *testing.T) { exitedEpoch := types.Epoch(100) idx := types.ValidatorIndex(3) - base := &pb.BeaconState{Validators: []*ethpb.Validator{ + base := &statepb.BeaconState{Validators: []*ethpb.Validator{ {ExitEpoch: exitedEpoch}, {ExitEpoch: exitedEpoch + 1}, {ExitEpoch: exitedEpoch + 2}, @@ -74,7 +74,7 @@ func TestInitiateValidatorExit_ProperExit(t *testing.T) { func TestInitiateValidatorExit_ChurnOverflow(t *testing.T) { exitedEpoch := types.Epoch(100) idx := types.ValidatorIndex(4) - base := &pb.BeaconState{Validators: []*ethpb.Validator{ + base := &statepb.BeaconState{Validators: []*ethpb.Validator{ {ExitEpoch: exitedEpoch + 2}, {ExitEpoch: exitedEpoch + 2}, {ExitEpoch: exitedEpoch + 2}, @@ -110,7 +110,7 @@ func TestSlashValidator_OK(t *testing.T) { balances = append(balances, params.BeaconConfig().MaxEffectiveBalance) } - base := &pb.BeaconState{ + base := &statepb.BeaconState{ Validators: registry, Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), @@ -153,11 +153,11 @@ func TestSlashValidator_OK(t *testing.T) { func TestActivatedValidatorIndices(t *testing.T) { tests := []struct { - state *pb.BeaconState + state *statepb.BeaconState wanted []types.ValidatorIndex }{ { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { ActivationEpoch: 0, @@ -179,7 +179,7 @@ func TestActivatedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{0, 1, 3}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { ActivationEpoch: helpers.ActivationExitEpoch(10), @@ -189,7 +189,7 @@ func TestActivatedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { ActivationEpoch: 0, @@ -210,11 +210,11 @@ func TestActivatedValidatorIndices(t *testing.T) { func TestSlashedValidatorIndices(t *testing.T) { tests := []struct { - state *pb.BeaconState + state *statepb.BeaconState wanted []types.ValidatorIndex }{ { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector, @@ -233,7 +233,7 @@ func TestSlashedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{0, 2}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector, @@ -243,7 +243,7 @@ func TestSlashedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector, @@ -264,11 +264,11 @@ func TestSlashedValidatorIndices(t *testing.T) { func TestExitedValidatorIndices(t *testing.T) { tests := []struct { - state *pb.BeaconState + state *statepb.BeaconState wanted []types.ValidatorIndex }{ { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, @@ -290,7 +290,7 @@ func TestExitedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{0, 2}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, @@ -302,7 +302,7 @@ func TestExitedValidatorIndices(t *testing.T) { wanted: []types.ValidatorIndex{}, }, { - state: &pb.BeaconState{ + state: &statepb.BeaconState{ Validators: []*ethpb.Validator{ { EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, diff --git a/beacon-chain/db/iface/BUILD.bazel b/beacon-chain/db/iface/BUILD.bazel index 82a561d980..57895908d4 100644 --- a/beacon-chain/db/iface/BUILD.bazel +++ b/beacon-chain/db/iface/BUILD.bazel @@ -13,10 +13,10 @@ go_library( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/slasher/types:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/backuputil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/beacon-chain/db/iface/interface.go b/beacon-chain/db/iface/interface.go index 4edd76e8d4..dc69283b02 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -12,10 +12,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/proto/prysm/v2" + v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/backuputil" ) @@ -36,7 +36,7 @@ type ReadOnlyDatabase interface { State(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) GenesisState(ctx context.Context) (iface.BeaconState, error) HasState(ctx context.Context, blockRoot [32]byte) bool - StateSummary(ctx context.Context, blockRoot [32]byte) (*ethereum_beacon_p2p_v1.StateSummary, error) + StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) HasStateSummary(ctx context.Context, blockRoot [32]byte) bool HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([]iface.ReadOnlyBeaconState, error) // Slashing operations. @@ -73,8 +73,8 @@ type NoHeadAccessDatabase interface { SaveStates(ctx context.Context, states []iface.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 *ethereum_beacon_p2p_v1.StateSummary) error - SaveStateSummaries(ctx context.Context, summaries []*ethereum_beacon_p2p_v1.StateSummary) error + SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error + SaveStateSummaries(ctx context.Context, summaries []*statepb.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/BUILD.bazel b/beacon-chain/db/kafka/BUILD.bazel index 3761b234f3..dcf56c1174 100644 --- a/beacon-chain/db/kafka/BUILD.bazel +++ b/beacon-chain/db/kafka/BUILD.bazel @@ -14,10 +14,10 @@ go_library( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/db/iface:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/featureconfig:go_default_library", "//shared/traceutil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", diff --git a/beacon-chain/db/kafka/passthrough.go b/beacon-chain/db/kafka/passthrough.go index 35518aa8b0..1da5dd5c51 100644 --- a/beacon-chain/db/kafka/passthrough.go +++ b/beacon-chain/db/kafka/passthrough.go @@ -8,10 +8,10 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/proto/prysm/v2" + v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // DatabasePath -- passthrough. @@ -70,7 +70,7 @@ func (e Exporter) State(ctx context.Context, blockRoot [32]byte) (iface.BeaconSt } // StateSummary -- passthrough. -func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*pb.StateSummary, error) { +func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { return e.db.StateSummary(ctx, blockRoot) } @@ -145,12 +145,12 @@ func (e Exporter) SaveState(ctx context.Context, st iface.ReadOnlyBeaconState, b } // SaveStateSummary -- passthrough. -func (e Exporter) SaveStateSummary(ctx context.Context, summary *pb.StateSummary) error { +func (e Exporter) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error { return e.db.SaveStateSummary(ctx, summary) } // SaveStateSummaries -- passthrough. -func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSummary) error { +func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error { return e.db.SaveStateSummaries(ctx, summaries) } diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index 9d52cf2032..16d58c3366 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -39,11 +39,11 @@ go_library( "//beacon-chain/state/genesis:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/fileutil:go_default_library", "//shared/params:go_default_library", @@ -92,11 +92,11 @@ go_test( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/db/iface:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/testing:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/db/kv/encoding.go b/beacon-chain/db/kv/encoding.go index 1219c52a30..8e8bce8345 100644 --- a/beacon-chain/db/kv/encoding.go +++ b/beacon-chain/db/kv/encoding.go @@ -7,8 +7,8 @@ import ( fastssz "github.com/ferranbt/fastssz" "github.com/golang/snappy" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "go.opencensus.io/trace" "google.golang.org/protobuf/proto" ) @@ -53,7 +53,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 *pb.BeaconState: + case *statepb.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 4c191e40a0..4e016d7312 100644 --- a/beacon-chain/db/kv/genesis.go +++ b/beacon-chain/db/kv/genesis.go @@ -12,8 +12,8 @@ import ( dbIface "github.com/prysmaticlabs/prysm/beacon-chain/db/iface" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" state "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -34,7 +34,7 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState iface.BeaconSt if err := s.SaveState(ctx, genesisState, genesisBlkRoot); err != nil { return errors.Wrap(err, "could not save genesis state") } - if err := s.SaveStateSummary(ctx, &pbp2p.StateSummary{ + if err := s.SaveStateSummary(ctx, &statepb.StateSummary{ Slot: 0, Root: genesisBlkRoot[:], }); err != nil { @@ -57,7 +57,7 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error { if err != nil { return err } - st := &pbp2p.BeaconState{} + st := &statepb.BeaconState{} if err := st.UnmarshalSSZ(b); err != nil { return err } diff --git a/beacon-chain/db/kv/state.go b/beacon-chain/db/kv/state.go index e2f6565576..b856e867b7 100644 --- a/beacon-chain/db/kv/state.go +++ b/beacon-chain/db/kv/state.go @@ -9,10 +9,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state/genesis" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -25,7 +25,7 @@ import ( func (s *Store) State(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.State") defer span.End() - var st *pb.BeaconState + var st *statepb.BeaconState enc, err := s.stateBytes(ctx, blockRoot) if err != nil { return nil, err @@ -57,7 +57,7 @@ func (s *Store) GenesisState(ctx context.Context) (iface.BeaconState, error) { return cached, nil } - var st *pb.BeaconState + var st *statepb.BeaconState err = s.db.View(func(tx *bolt.Tx) error { // Retrieve genesis block's signing root from blocks bucket, // to look up what the genesis state is. @@ -198,8 +198,8 @@ func (s *Store) DeleteStates(ctx context.Context, blockRoots [][32]byte) error { } // creates state from marshaled proto state bytes. -func createState(ctx context.Context, enc []byte) (*pb.BeaconState, error) { - protoState := &pb.BeaconState{} +func createState(ctx context.Context, enc []byte) (*statepb.BeaconState, error) { + protoState := &statepb.BeaconState{} if err := decode(ctx, enc, protoState); err != nil { return nil, errors.Wrap(err, "failed to unmarshal encoding") } @@ -267,7 +267,7 @@ func slotByBlockRoot(ctx context.Context, tx *bolt.Tx, blockRoot []byte) (types. } return b.Block.Slot, nil } - stateSummary := &pb.StateSummary{} + stateSummary := &statepb.StateSummary{} if err := decode(ctx, enc, stateSummary); err != nil { return 0, err } diff --git a/beacon-chain/db/kv/state_summary.go b/beacon-chain/db/kv/state_summary.go index 9cbbf74610..bf8d1038e3 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pb.StateSummary) error { +func (s *Store) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummary") defer span.End() - return s.SaveStateSummaries(ctx, []*pb.StateSummary{summary}) + return s.SaveStateSummaries(ctx, []*statepb.StateSummary{summary}) } // SaveStateSummaries saves state summary objects to the DB. -func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSummary) error { +func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummaries") defer span.End() @@ -38,7 +38,7 @@ func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSum } // StateSummary returns the state summary object from the db using input block root. -func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*pb.StateSummary, error) { +func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.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) (*pb.State if len(enc) == 0 { return nil, nil } - summary := &pb.StateSummary{} + summary := &statepb.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 b6d7ba3309..601ba98a92 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) const stateSummaryCachePruneCount = 128 // stateSummaryCache caches state summary object. type stateSummaryCache struct { - initSyncStateSummaries map[[32]byte]*pb.StateSummary + initSyncStateSummaries map[[32]byte]*statepb.StateSummary initSyncStateSummariesLock sync.RWMutex } // newStateSummaryCache creates a new state summary cache. func newStateSummaryCache() *stateSummaryCache { return &stateSummaryCache{ - initSyncStateSummaries: make(map[[32]byte]*pb.StateSummary), + initSyncStateSummaries: make(map[[32]byte]*statepb.StateSummary), } } // put saves a state summary to the initial sync state summaries cache. -func (c *stateSummaryCache) put(r [32]byte, b *pb.StateSummary) { +func (c *stateSummaryCache) put(r [32]byte, b *statepb.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) *pb.StateSummary { +func (c *stateSummaryCache) get(r [32]byte) *statepb.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() []*pb.StateSummary { +func (c *stateSummaryCache) getAll() []*statepb.StateSummary { c.initSyncStateSummariesLock.RLock() defer c.initSyncStateSummariesLock.RUnlock() - summaries := make([]*pb.StateSummary, 0, len(c.initSyncStateSummaries)) + summaries := make([]*statepb.StateSummary, 0, len(c.initSyncStateSummaries)) for _, b := range c.initSyncStateSummaries { summaries = append(summaries, b) } @@ -70,5 +70,5 @@ func (c *stateSummaryCache) getAll() []*pb.StateSummary { func (c *stateSummaryCache) clear() { c.initSyncStateSummariesLock.Lock() defer c.initSyncStateSummariesLock.Unlock() - c.initSyncStateSummaries = make(map[[32]byte]*pb.StateSummary) + c.initSyncStateSummaries = make(map[[32]byte]*statepb.StateSummary) } diff --git a/beacon-chain/db/kv/state_summary_test.go b/beacon-chain/db/kv/state_summary_test.go index d6726a02ab..121961df0a 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.StateSummary{Slot: 1, Root: r1[:]} + s1 := &statepb.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 := &pb.StateSummary{Slot: 2, Root: r2[:]} + s2 := &statepb.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([]*pb.StateSummary, stateSummaryCachePruneCount-1) + summaries := make([]*statepb.StateSummary, stateSummaryCachePruneCount-1) for i := range summaries { - summaries[i] = &pb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)} + summaries[i] = &statepb.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(), &pb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}})) + require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}})) require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount) - require.NoError(t, db.SaveStateSummary(context.Background(), &pb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}})) + require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.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/BUILD.bazel b/beacon-chain/interop-cold-start/BUILD.bazel index 3b5c0e5e35..feab63828c 100644 --- a/beacon-chain/interop-cold-start/BUILD.bazel +++ b/beacon-chain/interop-cold-start/BUILD.bazel @@ -14,8 +14,8 @@ go_library( "//beacon-chain/powchain:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared:go_default_library", "//shared/interop:go_default_library", "//shared/slotutil:go_default_library", diff --git a/beacon-chain/interop-cold-start/service.go b/beacon-chain/interop-cold-start/service.go index af2ddf35b6..327a9ca200 100644 --- a/beacon-chain/interop-cold-start/service.go +++ b/beacon-chain/interop-cold-start/service.go @@ -15,8 +15,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/powchain" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/slotutil" @@ -62,7 +62,7 @@ func NewService(ctx context.Context, cfg *Config) *Service { if err != nil { log.Fatalf("Could not read pre-loaded state: %v", err) } - genesisState := &pb.BeaconState{} + genesisState := &statepb.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/BUILD.bazel b/beacon-chain/operations/voluntaryexits/BUILD.bazel index ff5ca5d3ad..766db1f47b 100644 --- a/beacon-chain/operations/voluntaryexits/BUILD.bazel +++ b/beacon-chain/operations/voluntaryexits/BUILD.bazel @@ -29,8 +29,8 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "//shared/testutil/require:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/beacon-chain/operations/voluntaryexits/service_test.go b/beacon-chain/operations/voluntaryexits/service_test.go index 54c1a4af72..1f04250823 100644 --- a/beacon-chain/operations/voluntaryexits/service_test.go +++ b/beacon-chain/operations/voluntaryexits/service_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -270,7 +270,7 @@ func TestPool_InsertVoluntaryExit(t *testing.T) { p := &Pool{ pending: tt.fields.pending, } - s, err := v1.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: validators}) + s, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{Validators: validators}) require.NoError(t, err) p.InsertVoluntaryExit(ctx, s, tt.args.exit) if len(p.pending) != len(tt.want) { @@ -521,7 +521,7 @@ func TestPool_PendingExits(t *testing.T) { p := &Pool{ pending: tt.fields.pending, } - s, err := v1.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}}) + s, err := v1.InitializeFromProtoUnsafe(&statepb.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/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 3a8938d6a3..6ac5d76d29 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -49,11 +49,10 @@ go_library( "//beacon-chain/p2p/peers/scorers:go_default_library", "//beacon-chain/p2p/types:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//shared:go_default_library", "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", @@ -135,10 +134,11 @@ go_test( "//beacon-chain/p2p/peers/scorers:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/p2p/types:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//proto/testing:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", diff --git a/beacon-chain/p2p/broadcaster_test.go b/beacon-chain/p2p/broadcaster_test.go index cd1b2846c4..9491290a74 100644 --- a/beacon-chain/p2p/broadcaster_test.go +++ b/beacon-chain/p2p/broadcaster_test.go @@ -17,9 +17,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" testpb "github.com/prysmaticlabs/prysm/proto/testing" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -45,7 +46,7 @@ func TestService_Broadcast(t *testing.T) { genesisValidatorsRoot: bytesutil.PadTo([]byte{'A'}, 32), } - msg := &pb.Fork{ + msg := &statepb.Fork{ Epoch: 55, CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr"), @@ -76,7 +77,7 @@ func TestService_Broadcast(t *testing.T) { incomingMessage, err := sub.Next(ctx) require.NoError(t, err) - result := &pb.Fork{} + result := &statepb.Fork{} require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result)) if !proto.Equal(result, msg) { tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg) diff --git a/beacon-chain/p2p/discovery_test.go b/beacon-chain/p2p/discovery_test.go index f21dfcc5c2..444a84b0c6 100644 --- a/beacon-chain/p2p/discovery_test.go +++ b/beacon-chain/p2p/discovery_test.go @@ -28,9 +28,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" testp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/iputils" "github.com/prysmaticlabs/prysm/shared/testutil/assert" diff --git a/beacon-chain/p2p/encoder/BUILD.bazel b/beacon-chain/p2p/encoder/BUILD.bazel index 736df8b393..40cdd3554a 100644 --- a/beacon-chain/p2p/encoder/BUILD.bazel +++ b/beacon-chain/p2p/encoder/BUILD.bazel @@ -31,7 +31,7 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/p2p/encoder/ssz_test.go b/beacon-chain/p2p/encoder/ssz_test.go index dd0e84a779..4243c7be1c 100644 --- a/beacon-chain/p2p/encoder/ssz_test.go +++ b/beacon-chain/p2p/encoder/ssz_test.go @@ -10,7 +10,7 @@ import ( gogo "github.com/gogo/protobuf/proto" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -26,7 +26,7 @@ func TestSszNetworkEncoder_RoundTrip(t *testing.T) { func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) { e := &encoder.SszNetworkEncoder{} - att := &pb.Fork{} + att := &statepb.Fork{} data := make([]byte, 32) binary.PutUvarint(data, encoder.MaxGossipSize+32) err := e.DecodeGossip(data, att) @@ -35,14 +35,14 @@ func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) { func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) { buf := new(bytes.Buffer) - msg := &pb.Fork{ + msg := &statepb.Fork{ PreviousVersion: []byte("fooo"), CurrentVersion: []byte("barr"), Epoch: 9001, } _, err := e.EncodeWithMaxLength(buf, msg) require.NoError(t, err) - decoded := &pb.Fork{} + decoded := &statepb.Fork{} require.NoError(t, e.DecodeWithMaxLength(buf, decoded)) if !proto.Equal(decoded, msg) { t.Logf("decoded=%+v\n", decoded) @@ -52,14 +52,14 @@ func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) { func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) { buf := new(bytes.Buffer) - msg := &pb.Fork{ + msg := &statepb.Fork{ PreviousVersion: []byte("fooo"), CurrentVersion: []byte("barr"), Epoch: 9001, } _, err := e.EncodeGossip(buf, msg) require.NoError(t, err) - decoded := &pb.Fork{} + decoded := &statepb.Fork{} require.NoError(t, e.DecodeGossip(buf.Bytes(), decoded)) if !proto.Equal(decoded, msg) { t.Logf("decoded=%+v\n", decoded) @@ -69,7 +69,7 @@ func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) { func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) { buf := new(bytes.Buffer) - msg := &pb.Fork{ + msg := &statepb.Fork{ PreviousVersion: []byte("fooo"), CurrentVersion: []byte("barr"), Epoch: 9001, @@ -86,7 +86,7 @@ func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) { func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) { buf := new(bytes.Buffer) - msg := &pb.Fork{ + msg := &statepb.Fork{ PreviousVersion: []byte("fooo"), CurrentVersion: []byte("barr"), Epoch: 4242, @@ -99,7 +99,7 @@ func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) { params.OverrideBeaconNetworkConfig(c) _, err := e.EncodeGossip(buf, msg) require.NoError(t, err) - decoded := &pb.Fork{} + decoded := &statepb.Fork{} err = e.DecodeWithMaxLength(buf, decoded) wanted := fmt.Sprintf("goes over the provided max limit of %d", maxChunkSize) assert.ErrorContains(t, wanted, err) @@ -121,7 +121,7 @@ func TestSszNetworkEncoder_DecodeWithMultipleFrames(t *testing.T) { if buf.Len() <= 76490 { t.Errorf("buffer smaller than expected, wanted > %d but got %d", 76490, buf.Len()) } - decoded := new(pb.BeaconState) + decoded := new(statepb.BeaconState) err = e.DecodeWithMaxLength(buf, decoded) assert.NoError(t, err) } @@ -144,7 +144,7 @@ func TestSszNetworkEncoder_MaxInt64(t *testing.T) { func TestSszNetworkEncoder_DecodeWithBadSnappyStream(t *testing.T) { st := newBadSnappyStream() e := &encoder.SszNetworkEncoder{} - decoded := new(pb.Fork) + decoded := new(statepb.Fork) err := e.DecodeWithMaxLength(st, decoded) assert.ErrorContains(t, io.EOF.Error(), err) } diff --git a/beacon-chain/p2p/fork.go b/beacon-chain/p2p/fork.go index d4ec3cd826..7bd4ad8eda 100644 --- a/beacon-chain/p2p/fork.go +++ b/beacon-chain/p2p/fork.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enr" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/p2putils" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" diff --git a/beacon-chain/p2p/fork_test.go b/beacon-chain/p2p/fork_test.go index 3df7142a42..44a039dcf3 100644 --- a/beacon-chain/p2p/fork_test.go +++ b/beacon-chain/p2p/fork_test.go @@ -16,7 +16,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/p2putils" "github.com/prysmaticlabs/prysm/shared/params" diff --git a/beacon-chain/p2p/gossip_scoring_params_test.go b/beacon-chain/p2p/gossip_scoring_params_test.go index f0c2c2c9c7..3dd3cdc736 100644 --- a/beacon-chain/p2p/gossip_scoring_params_test.go +++ b/beacon-chain/p2p/gossip_scoring_params_test.go @@ -6,8 +6,8 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -26,7 +26,7 @@ func TestCorrect_ActiveValidatorsCount(t *testing.T) { ctx: context.Background(), cfg: &Config{DB: db}, } - bState, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + bState, err := testutil.NewBeaconState(func(state *statepb.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/interfaces.go b/beacon-chain/p2p/interfaces.go index 9bfaa7f923..e9edff6a43 100644 --- a/beacon-chain/p2p/interfaces.go +++ b/beacon-chain/p2p/interfaces.go @@ -12,7 +12,7 @@ import ( "github.com/multiformats/go-multiaddr" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" + "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "google.golang.org/protobuf/proto" ) @@ -92,6 +92,6 @@ type PeersProvider interface { // MetadataProvider returns the metadata related information for the local peer. type MetadataProvider interface { - Metadata() p2p.Metadata + Metadata() interfaces.Metadata MetadataSeq() uint64 } diff --git a/beacon-chain/p2p/peers/BUILD.bazel b/beacon-chain/p2p/peers/BUILD.bazel index 1d3d0f8f45..c453dbe011 100644 --- a/beacon-chain/p2p/peers/BUILD.bazel +++ b/beacon-chain/p2p/peers/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/p2p/peers/peerdata:go_default_library", "//beacon-chain/p2p/peers/scorers:go_default_library", - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/interfaces:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/params:go_default_library", "//shared/rand:go_default_library", "//shared/timeutils:go_default_library", @@ -36,9 +36,9 @@ go_test( "//beacon-chain/p2p/peers/peerdata:go_default_library", "//beacon-chain/p2p/peers/scorers:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", "//proto/eth/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/p2p/peers/peerdata/BUILD.bazel b/beacon-chain/p2p/peers/peerdata/BUILD.bazel index 3493d81f7e..ec654f1878 100644 --- a/beacon-chain/p2p/peers/peerdata/BUILD.bazel +++ b/beacon-chain/p2p/peers/peerdata/BUILD.bazel @@ -6,8 +6,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata", visibility = ["//beacon-chain:__subpackages__"], deps = [ - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enr:go_default_library", diff --git a/beacon-chain/p2p/peers/peerdata/store.go b/beacon-chain/p2p/peers/peerdata/store.go index 36f45a29a4..03e20c58ca 100644 --- a/beacon-chain/p2p/peers/peerdata/store.go +++ b/beacon-chain/p2p/peers/peerdata/store.go @@ -10,10 +10,9 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v2" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" ) var ( @@ -50,7 +49,7 @@ type PeerData struct { Enr *enr.Record NextValidTime time.Time // Chain related data. - MetaData p2p.Metadata + MetaData interfaces.Metadata ChainState *pb.Status ChainStateLastUpdated time.Time ChainStateValidationError error @@ -59,7 +58,7 @@ type PeerData struct { ProcessedBlocks uint64 BlockProviderUpdated time.Time // Gossip Scoring data. - TopicScores map[string]*pbrpc.TopicScoreSnapshot + TopicScores map[string]*pb.TopicScoreSnapshot GossipScore float64 BehaviourPenalty float64 } diff --git a/beacon-chain/p2p/peers/scorers/BUILD.bazel b/beacon-chain/p2p/peers/scorers/BUILD.bazel index 259e16e4eb..e259bf1f67 100644 --- a/beacon-chain/p2p/peers/scorers/BUILD.bazel +++ b/beacon-chain/p2p/peers/scorers/BUILD.bazel @@ -15,7 +15,6 @@ go_library( "//beacon-chain/p2p/peers/peerdata:go_default_library", "//beacon-chain/p2p/types:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v2:go_default_library", "//shared/featureconfig:go_default_library", "//shared/rand:go_default_library", @@ -41,7 +40,6 @@ go_test( "//beacon-chain/p2p/peers/peerdata:go_default_library", "//beacon-chain/p2p/types:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v2:go_default_library", "//shared/featureconfig:go_default_library", "//shared/rand:go_default_library", diff --git a/beacon-chain/p2p/peers/scorers/peer_status.go b/beacon-chain/p2p/peers/scorers/peer_status.go index e1d17f7060..4f7985a988 100644 --- a/beacon-chain/p2p/peers/scorers/peer_status.go +++ b/beacon-chain/p2p/peers/scorers/peer_status.go @@ -8,7 +8,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/timeutils" ) diff --git a/beacon-chain/p2p/peers/scorers/peer_status_test.go b/beacon-chain/p2p/peers/scorers/peer_status_test.go index f2de11e4c9..df66e08526 100644 --- a/beacon-chain/p2p/peers/scorers/peer_status_test.go +++ b/beacon-chain/p2p/peers/scorers/peer_status_test.go @@ -10,7 +10,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) diff --git a/beacon-chain/p2p/peers/status.go b/beacon-chain/p2p/peers/status.go index 625f71ff4b..be19b459cf 100644 --- a/beacon-chain/p2p/peers/status.go +++ b/beacon-chain/p2p/peers/status.go @@ -38,8 +38,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/timeutils" @@ -230,7 +230,7 @@ func (p *Status) InboundLimit() int { } // SetMetadata sets the metadata of the given remote peer. -func (p *Status) SetMetadata(pid peer.ID, metaData p2p.Metadata) { +func (p *Status) SetMetadata(pid peer.ID, metaData interfaces.Metadata) { p.store.Lock() defer p.store.Unlock() @@ -240,7 +240,7 @@ func (p *Status) SetMetadata(pid peer.ID, metaData p2p.Metadata) { // Metadata returns a copy of the metadata corresponding to the provided // peer id. -func (p *Status) Metadata(pid peer.ID) (p2p.Metadata, error) { +func (p *Status) Metadata(pid peer.ID) (interfaces.Metadata, error) { p.store.RLock() defer p.store.RUnlock() diff --git a/beacon-chain/p2p/peers/status_test.go b/beacon-chain/p2p/peers/status_test.go index dd56a5efe5..5f1fb6c357 100644 --- a/beacon-chain/p2p/peers/status_test.go +++ b/beacon-chain/p2p/peers/status_test.go @@ -16,9 +16,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" diff --git a/beacon-chain/p2p/rpc_topic_mappings.go b/beacon-chain/p2p/rpc_topic_mappings.go index 3b978fd377..357ce5dbcb 100644 --- a/beacon-chain/p2p/rpc_topic_mappings.go +++ b/beacon-chain/p2p/rpc_topic_mappings.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" ) // SchemaVersionV1 specifies the schema version for our rpc protocol ID. diff --git a/beacon-chain/p2p/rpc_topic_mappings_test.go b/beacon-chain/p2p/rpc_topic_mappings_test.go index caa8cd0f9a..6bf81dc4f1 100644 --- a/beacon-chain/p2p/rpc_topic_mappings_test.go +++ b/beacon-chain/p2p/rpc_topic_mappings_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) diff --git a/beacon-chain/p2p/sender_test.go b/beacon-chain/p2p/sender_test.go index 98c321743b..789d18c9f9 100644 --- a/beacon-chain/p2p/sender_test.go +++ b/beacon-chain/p2p/sender_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.Fork{ + msg := &statepb.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(pb.Fork) + RPCTopicMappings[topic] = new(statepb.Fork) defer func() { delete(RPCTopicMappings, topic) }() p2.SetStreamHandler(topic+"/ssz_snappy", func(stream network.Stream) { - rcvd := &pb.Fork{} + rcvd := &statepb.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 := &pb.Fork{} + rcvd := &statepb.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/p2p/service.go b/beacon-chain/p2p/service.go index 4a58aa06f2..01dc51de72 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -26,7 +26,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/runutil" @@ -64,7 +64,7 @@ type Service struct { addrFilter *multiaddr.Filters ipLimiter *leakybucket.Collector privKey *ecdsa.PrivateKey - metaData p2p.Metadata + metaData interfaces.Metadata pubsub *pubsub.PubSub joinedTopics map[string]*pubsub.Topic joinedTopicsLock sync.Mutex @@ -342,7 +342,7 @@ func (s *Service) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { } // Metadata returns a copy of the peer's metadata. -func (s *Service) Metadata() p2p.Metadata { +func (s *Service) Metadata() interfaces.Metadata { return s.metaData.Copy() } diff --git a/beacon-chain/p2p/subnets.go b/beacon-chain/p2p/subnets.go index 87856aa5be..9cd5ac735b 100644 --- a/beacon-chain/p2p/subnets.go +++ b/beacon-chain/p2p/subnets.go @@ -7,10 +7,10 @@ import ( "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enr" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "go.opencensus.io/trace" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/p2p/subnets_test.go b/beacon-chain/p2p/subnets_test.go index 0d75a3c4bf..a91ed27520 100644 --- a/beacon-chain/p2p/subnets_test.go +++ b/beacon-chain/p2p/subnets_test.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/cache" "github.com/prysmaticlabs/prysm/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" diff --git a/beacon-chain/p2p/testing/BUILD.bazel b/beacon-chain/p2p/testing/BUILD.bazel index 50d24dbd1c..d3aa5cd881 100644 --- a/beacon-chain/p2p/testing/BUILD.bazel +++ b/beacon-chain/p2p/testing/BUILD.bazel @@ -21,9 +21,9 @@ go_library( "//beacon-chain/p2p/encoder:go_default_library", "//beacon-chain/p2p/peers:go_default_library", "//beacon-chain/p2p/peers/scorers:go_default_library", - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2:go_default_library", "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enode:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enr:go_default_library", diff --git a/beacon-chain/p2p/testing/fuzz_p2p.go b/beacon-chain/p2p/testing/fuzz_p2p.go index c96e6daa3a..4fc89e278d 100644 --- a/beacon-chain/p2p/testing/fuzz_p2p.go +++ b/beacon-chain/p2p/testing/fuzz_p2p.go @@ -10,12 +10,11 @@ import ( "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/multiformats/go-multiaddr" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "google.golang.org/protobuf/proto" - "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" + "github.com/prysmaticlabs/prysm/proto/interfaces" + ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "google.golang.org/protobuf/proto" ) // FakeP2P stack @@ -75,7 +74,7 @@ func (p *FakeP2P) LeaveTopic(_ string) error { } // Metadata -- fake. -func (p *FakeP2P) Metadata() p2p.Metadata { +func (p *FakeP2P) Metadata() interfaces.Metadata { return nil } diff --git a/beacon-chain/p2p/testing/mock_metadataprovider.go b/beacon-chain/p2p/testing/mock_metadataprovider.go index ea39cf4960..ae7b9485b2 100644 --- a/beacon-chain/p2p/testing/mock_metadataprovider.go +++ b/beacon-chain/p2p/testing/mock_metadataprovider.go @@ -1,16 +1,16 @@ package testing import ( - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // MockMetadataProvider is a fake implementation of the MetadataProvider interface. type MockMetadataProvider struct { - Data p2p.Metadata + Data interfaces.Metadata } // Metadata -- -func (m *MockMetadataProvider) Metadata() p2p.Metadata { +func (m *MockMetadataProvider) Metadata() interfaces.Metadata { return m.Data } diff --git a/beacon-chain/p2p/testing/mock_peersprovider.go b/beacon-chain/p2p/testing/mock_peersprovider.go index b2bbfb083f..4627c75d11 100644 --- a/beacon-chain/p2p/testing/mock_peersprovider.go +++ b/beacon-chain/p2p/testing/mock_peersprovider.go @@ -12,7 +12,7 @@ import ( ma "github.com/multiformats/go-multiaddr" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" log "github.com/sirupsen/logrus" ) diff --git a/beacon-chain/p2p/testing/p2p.go b/beacon-chain/p2p/testing/p2p.go index dca8b2d002..3fe0d71c55 100644 --- a/beacon-chain/p2p/testing/p2p.go +++ b/beacon-chain/p2p/testing/p2p.go @@ -23,7 +23,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" + "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" @@ -39,7 +39,7 @@ type TestP2P struct { DelaySend bool Digest [4]byte peers *peers.Status - LocalMetadata p2p.Metadata + LocalMetadata interfaces.Metadata } // NewTestP2P initializes a new p2p test service. @@ -338,7 +338,7 @@ func (p *TestP2P) ForkDigest() ([4]byte, error) { } // Metadata mocks the peer's metadata. -func (p *TestP2P) Metadata() p2p.Metadata { +func (p *TestP2P) Metadata() interfaces.Metadata { return p.LocalMetadata.Copy() } diff --git a/beacon-chain/p2p/utils.go b/beacon-chain/p2p/utils.go index 457e3e4613..654b934e48 100644 --- a/beacon-chain/p2p/utils.go +++ b/beacon-chain/p2p/utils.go @@ -18,9 +18,9 @@ import ( "github.com/libp2p/go-libp2p-core/crypto" "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/fileutil" "github.com/prysmaticlabs/prysm/shared/iputils" "github.com/sirupsen/logrus" @@ -109,7 +109,7 @@ func privKeyFromFile(path string) (*ecdsa.PrivateKey, error) { // Retrieves node p2p metadata from a set of configuration values // from the p2p service. // TODO: Figure out how to do a v1/v2 check. -func metaDataFromConfig(cfg *Config) (p2p.Metadata, error) { +func metaDataFromConfig(cfg *Config) (interfaces.Metadata, error) { defaultKeyPath := path.Join(cfg.DataDir, metaDataPath) metaDataPath := cfg.MetaDataDir @@ -119,7 +119,7 @@ func metaDataFromConfig(cfg *Config) (p2p.Metadata, error) { return nil, err } if metaDataPath == "" && !defaultMetadataExist { - metaData := &pbp2p.MetaDataV0{ + metaData := &pb.MetaDataV0{ SeqNumber: 0, Attnets: bitfield.NewBitvector64(), } @@ -140,7 +140,7 @@ func metaDataFromConfig(cfg *Config) (p2p.Metadata, error) { log.WithError(err).Error("Error reading metadata from file") return nil, err } - metaData := &pbp2p.MetaDataV0{} + metaData := &pb.MetaDataV0{} if err := proto.Unmarshal(src, metaData); err != nil { return nil, err } diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index d631218909..af104fafab 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -33,10 +33,10 @@ go_library( "//beacon-chain/rpc/statefetcher:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/featureconfig:go_default_library", "//shared/logutil:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel index 48758dd0a2..8909d5d1c1 100644 --- a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel @@ -74,12 +74,12 @@ go_test( "//beacon-chain/rpc/statefetcher:go_default_library", "//beacon-chain/rpc/testutil:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/migration:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/grpcutils:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go index d8d90e348c..c0a97e64b6 100644 --- a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go +++ b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go @@ -10,12 +10,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db" dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/proto/migration" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -53,7 +53,7 @@ func fillDBTestBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) ( } require.NoError(t, beaconDB.SaveBlocks(ctx, blks)) headRoot := bytesutil.ToBytes32(blkContainers[len(blks)-1].BlockRoot) - summary := &p2ppb.StateSummary{ + summary := &statepb.StateSummary{ Root: headRoot[:], Slot: blkContainers[len(blks)-1].Block.Block.Slot, } diff --git a/beacon-chain/rpc/eth/v1/beacon/pool_test.go b/beacon-chain/rpc/eth/v1/beacon/pool_test.go index c1007d9b9c..282b00aa21 100644 --- a/beacon-chain/rpc/eth/v1/beacon/pool_test.go +++ b/beacon-chain/rpc/eth/v1/beacon/pool_test.go @@ -15,10 +15,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/slashings" "github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits" p2pMock "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" "github.com/prysmaticlabs/prysm/proto/migration" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/grpcutils" @@ -378,7 +378,7 @@ func TestSubmitAttesterSlashing_Ok(t *testing.T) { validator := ð.Validator{ PublicKey: keys[0].PublicKey().Marshal(), } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = []*eth.Validator{validator} return nil }) @@ -493,7 +493,7 @@ func TestSubmitProposerSlashing_Ok(t *testing.T) { PublicKey: keys[0].PublicKey().Marshal(), WithdrawableEpoch: eth2types.Epoch(1), } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = []*eth.Validator{validator} return nil }) @@ -593,7 +593,7 @@ func TestSubmitVoluntaryExit_Ok(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: keys[0].PublicKey().Marshal(), } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = []*eth.Validator{validator} // Satisfy activity time required before exiting. state.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().ShardCommitteePeriod)) @@ -639,7 +639,7 @@ func TestSubmitVoluntaryExit_InvalidValidatorIndex(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: keys[0].PublicKey().Marshal(), } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = []*eth.Validator{validator} return nil }) @@ -674,7 +674,7 @@ func TestSubmitVoluntaryExit_InvalidExit(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: keys[0].PublicKey().Marshal(), } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = []*eth.Validator{validator} return nil }) @@ -716,7 +716,7 @@ func TestServer_SubmitAttestations_Ok(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, }, } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = validators state.Slot = 1 state.PreviousJustifiedCheckpoint = ð.Checkpoint{ @@ -821,7 +821,7 @@ func TestServer_SubmitAttestations_ValidAttestationSubmitted(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, }, } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = validators state.Slot = 1 state.PreviousJustifiedCheckpoint = ð.Checkpoint{ @@ -942,7 +942,7 @@ func TestServer_SubmitAttestations_InvalidAttestationHeader(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, }, } - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.Validators = validators state.Slot = 1 state.PreviousJustifiedCheckpoint = ð.Checkpoint{ diff --git a/beacon-chain/rpc/eth/v1/beacon/state_test.go b/beacon-chain/rpc/eth/v1/beacon/state_test.go index a7265976ac..3b3e1c3a80 100644 --- a/beacon-chain/rpc/eth/v1/beacon/state_test.go +++ b/beacon-chain/rpc/eth/v1/beacon/state_test.go @@ -7,9 +7,9 @@ import ( chainMock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/beacon-chain/rpc/testutil" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" sharedtestutil "github.com/prysmaticlabs/prysm/shared/testutil" @@ -92,8 +92,8 @@ func TestGetStateRoot(t *testing.T) { } func TestGetStateFork(t *testing.T) { - fillFork := func(state *pb.BeaconState) error { - state.Fork = &pb.Fork{ + fillFork := func(state *statepb.BeaconState) error { + state.Fork = &statepb.Fork{ PreviousVersion: []byte("prev"), CurrentVersion: []byte("curr"), Epoch: 123, @@ -120,7 +120,7 @@ func TestGetStateFork(t *testing.T) { } func TestGetFinalityCheckpoints(t *testing.T) { - fillCheckpoints := func(state *pb.BeaconState) error { + fillCheckpoints := func(state *statepb.BeaconState) error { state.PreviousJustifiedCheckpoint = ð.Checkpoint{ Root: bytesutil.PadTo([]byte("previous"), 32), Epoch: 113, diff --git a/beacon-chain/rpc/eth/v1/debug/debug.go b/beacon-chain/rpc/eth/v1/debug/debug.go index 5b80c1805d..9971a8d966 100644 --- a/beacon-chain/rpc/eth/v1/debug/debug.go +++ b/beacon-chain/rpc/eth/v1/debug/debug.go @@ -5,6 +5,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/rpc/statefetcher" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" + statepb "github.com/prysmaticlabs/prysm/proto/eth/v1" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -12,7 +13,7 @@ import ( ) // GetBeaconState returns the full beacon state for a given state id. -func (ds *Server) GetBeaconState(ctx context.Context, req *ethpb.StateRequest) (*ethpb.BeaconStateResponse, error) { +func (ds *Server) GetBeaconState(ctx context.Context, req *ethpb.StateRequest) (*statepb.BeaconStateResponse, error) { ctx, span := trace.StartSpan(ctx, "beaconv1.GetBeaconState") defer span.End() @@ -31,13 +32,13 @@ func (ds *Server) GetBeaconState(ctx context.Context, req *ethpb.StateRequest) ( return nil, status.Errorf(codes.Internal, "Could not convert state to proto: %v", err) } - return ðpb.BeaconStateResponse{ + return &statepb.BeaconStateResponse{ Data: protoState, }, nil } // GetBeaconStateSSZ returns the SSZ-serialized version of the full beacon state object for given stateId. -func (ds *Server) GetBeaconStateSSZ(ctx context.Context, req *ethpb.StateRequest) (*ethpb.BeaconStateSSZResponse, error) { +func (ds *Server) GetBeaconStateSSZ(ctx context.Context, req *ethpb.StateRequest) (*statepb.BeaconStateSSZResponse, error) { ctx, span := trace.StartSpan(ctx, "beaconv1.GetBeaconStateSSZ") defer span.End() @@ -56,7 +57,7 @@ func (ds *Server) GetBeaconStateSSZ(ctx context.Context, req *ethpb.StateRequest return nil, status.Errorf(codes.Internal, "Could not marshal state into SSZ: %v", err) } - return ðpb.BeaconStateSSZResponse{Data: sszState}, nil + return &statepb.BeaconStateSSZResponse{Data: sszState}, nil } // ListForkChoiceHeads retrieves the fork choice leaves for the current head. diff --git a/beacon-chain/rpc/eth/v1/node/BUILD.bazel b/beacon-chain/rpc/eth/v1/node/BUILD.bazel index fe89270277..2676e38e22 100644 --- a/beacon-chain/rpc/eth/v1/node/BUILD.bazel +++ b/beacon-chain/rpc/eth/v1/node/BUILD.bazel @@ -44,9 +44,9 @@ go_test( "//beacon-chain/p2p/peers:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", "//proto/eth/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//shared/grpcutils:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/node/node_test.go b/beacon-chain/rpc/eth/v1/node/node_test.go index a00faf1f1e..2e9397949f 100644 --- a/beacon-chain/rpc/eth/v1/node/node_test.go +++ b/beacon-chain/rpc/eth/v1/node/node_test.go @@ -23,9 +23,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" syncmock "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/grpcutils" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel index 719860b98e..5ffcced422 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel @@ -37,9 +37,9 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", @@ -95,10 +95,10 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index 377007cb70..193ab1e5c2 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -19,10 +19,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -40,7 +40,7 @@ func TestServer_ListAttestations_NoResults(t *testing.T) { db := dbTest.SetupDB(t) ctx := context.Background() - st, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + st, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -68,7 +68,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) { db := dbTest.SetupDB(t) ctx := context.Background() - st, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + st, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -564,13 +564,13 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { HeadFetcher: &chainMock.ChainService{State: state}, StateGen: stategen.New(db), } - err := db.SaveStateSummary(ctx, &pbp2p.StateSummary{ + err := db.SaveStateSummary(ctx, &statepb.StateSummary{ Root: targetRoot1[:], Slot: 1, }) require.NoError(t, err) - err = db.SaveStateSummary(ctx, &pbp2p.StateSummary{ + err = db.SaveStateSummary(ctx, &statepb.StateSummary{ Root: targetRoot2[:], Slot: 2, }) @@ -664,7 +664,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) { }, StateGen: stategen.New(db), } - err = db.SaveStateSummary(ctx, &pbp2p.StateSummary{ + err = db.SaveStateSummary(ctx, &statepb.StateSummary{ Root: blockRoot[:], Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)), }) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go index 4eee5d316a..31dbd6100a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go @@ -16,10 +16,10 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/mock" @@ -394,7 +394,7 @@ func TestServer_GetChainHead(t *testing.T) { pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot() require.NoError(t, err) - s, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: pjRoot[:]}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: jRoot[:]}, @@ -484,7 +484,7 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) { pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot() require.NoError(t, err) - s, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 1, PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: pjRoot[:]}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: jRoot[:]}, diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go index c01a8312c2..ce73f681a0 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go @@ -11,9 +11,9 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -162,7 +162,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 := &pbp2p.StateSummary{ + stateSummary := &statepb.StateSummary{ Slot: 0, Root: gRoot[:], } diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go index aa1c7e2fef..8d2ef325e8 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/server.go @@ -19,8 +19,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/powchain" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/beacon-chain/sync" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // Server defines a server implementation of the gRPC Beacon Chain service, @@ -41,7 +41,7 @@ type Server struct { Broadcaster p2p.Broadcaster AttestationsPool attestations.Pool SlashingsPool slashings.PoolManager - CanonicalStateChan chan *pbp2p.BeaconState + CanonicalStateChan chan *statepb.BeaconState ChainStartChan chan time.Time ReceivedAttestationsBuffer chan *ethpb.Attestation CollectedAttestationsBuffer chan []*ethpb.Attestation diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go index 50aede3cea..fd856664ac 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go @@ -20,9 +20,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/params" @@ -1274,7 +1274,7 @@ func TestServer_GetValidatorActiveSetChanges(t *testing.T) { } func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) { - headState, err := v1.InitializeFromProto(&pb.BeaconState{ + headState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: []*ethpb.Validator{ { ActivationEpoch: helpers.ActivationExitEpoch(0), @@ -1373,7 +1373,7 @@ func TestServer_GetValidatorQueue_ExitedValidatorLeavesQueue(t *testing.T) { } func TestServer_GetValidatorQueue_PendingExit(t *testing.T) { - headState, err := v1.InitializeFromProto(&pb.BeaconState{ + headState, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: []*ethpb.Validator{ { ActivationEpoch: 0, @@ -1507,7 +1507,7 @@ func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) { balances[i] = params.BeaconConfig().MaxEffectiveBalance } - atts := []*pb.PendingAttestation{{ + atts := []*statepb.PendingAttestation{{ Data: testutil.HydrateAttestationData(ðpb.AttestationData{}), InclusionDelay: 1, AggregationBits: bitfield.NewBitlist(validatorCount / uint64(params.BeaconConfig().SlotsPerEpoch)), @@ -1524,8 +1524,8 @@ func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) { b.Block.Slot = 16 require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) bRoot, err := b.Block.HashTreeRoot() - require.NoError(t, beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) - require.NoError(t, beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: params.BeaconConfig().ZeroHash[:]})) + require.NoError(t, beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) + require.NoError(t, beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: params.BeaconConfig().ZeroHash[:]})) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, bRoot)) require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, headState, bRoot)) @@ -1586,7 +1586,7 @@ func TestServer_GetValidatorParticipation_OrphanedUntilGenesis(t *testing.T) { balances[i] = params.BeaconConfig().MaxEffectiveBalance } - atts := []*pb.PendingAttestation{{ + atts := []*statepb.PendingAttestation{{ Data: testutil.HydrateAttestationData(ðpb.AttestationData{}), InclusionDelay: 1, AggregationBits: bitfield.NewBitlist(validatorCount / uint64(params.BeaconConfig().SlotsPerEpoch)), @@ -1602,8 +1602,8 @@ func TestServer_GetValidatorParticipation_OrphanedUntilGenesis(t *testing.T) { b := testutil.NewBeaconBlock() require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) bRoot, err := b.Block.HashTreeRoot() - require.NoError(t, beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) - require.NoError(t, beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: params.BeaconConfig().ZeroHash[:]})) + require.NoError(t, beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) + require.NoError(t, beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: params.BeaconConfig().ZeroHash[:]})) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, bRoot)) require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, headState, bRoot)) @@ -1666,9 +1666,9 @@ func TestGetValidatorPerformance_OK(t *testing.T) { headState, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, headState.SetSlot(params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch+1)))) - atts := make([]*pb.PendingAttestation, 3) + atts := make([]*statepb.PendingAttestation, 3) for i := 0; i < len(atts); i++ { - atts[i] = &pb.PendingAttestation{ + atts[i] = &statepb.PendingAttestation{ Data: ðpb.AttestationData{ Target: ðpb.Checkpoint{Root: make([]byte, 32)}, Source: ðpb.Checkpoint{Root: make([]byte, 32)}, @@ -2033,11 +2033,11 @@ func TestServer_GetIndividualVotes_Working(t *testing.T) { require.NoError(t, beaconState.SetBlockRoots(br)) att2.Data.Target.Root = rt[:] att2.Data.BeaconBlockRoot = newRt[:] - err = beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{ + err = beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{ Data: att1.Data, AggregationBits: bf, InclusionDelay: 1, }) require.NoError(t, err) - err = beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{ + err = beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{ Data: att2.Data, AggregationBits: bf, InclusionDelay: 1, }) require.NoError(t, err) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index 9aeed84b04..eaa3a24873 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -35,12 +35,12 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/aggregation:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/bls:go_default_library", @@ -103,11 +103,11 @@ go_test( "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go index 7dd9df0b39..30001b3af5 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go @@ -14,8 +14,8 @@ import ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -45,7 +45,7 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) { func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) { ctx := context.Background() - s, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), }) require.NoError(t, err) @@ -67,7 +67,7 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) { func TestSubmitAggregateAndProof_IsAggregatorAndNoAtts(t *testing.T) { ctx := context.Background() - s, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + s, err := v1.InitializeFromProto(&statepb.BeaconState{ RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), Validators: []*ethpb.Validator{ {PublicKey: pubKey(0)}, diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go index c2d95487f8..10a20182e0 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go @@ -17,9 +17,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -259,7 +259,7 @@ func TestAttestationDataAtSlot_HandlesFarAwayJustifiedEpoch(t *testing.T) { } func TestAttestationDataSlot_handlesInProgressRequest(t *testing.T) { - s := &pbp2p.BeaconState{Slot: 100} + s := &statepb.BeaconState{Slot: 100} state, err := v1.InitializeFromProto(s) require.NoError(t, err) ctx := context.Background() diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index bd786e35ee..85e0e71965 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -20,10 +20,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -373,7 +373,7 @@ func TestProposer_PendingDeposits_OutsideEth1FollowWindow(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -501,7 +501,7 @@ func TestProposer_PendingDeposits_FollowsCorrectEth1Block(t *testing.T) { votes = append(votes, vote) } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: []byte("0x0"), DepositRoot: make([]byte, 32), @@ -712,7 +712,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanMax(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -806,7 +806,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanDepositCount(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -900,7 +900,7 @@ func TestProposer_DepositTrie_UtilizesCachedFinalizedDeposits(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -1010,7 +1010,7 @@ func TestProposer_DepositTrie_RebuildTrie(t *testing.T) { }, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), @@ -1291,7 +1291,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1327,7 +1327,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1363,7 +1363,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(51, earliestValidTime+1, []byte("first")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1400,7 +1400,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(51, earliestValidTime+1, []byte("first")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1437,7 +1437,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(100, latestValidTime, []byte("latest")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1474,7 +1474,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("unknown"), DepositCount: 1}, @@ -1508,7 +1508,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(49, earliestValidTime-1, []byte("before_range")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, }) require.NoError(t, err) @@ -1540,7 +1540,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(101, latestValidTime+1, []byte("after_range")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1574,7 +1574,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(50, earliestValidTime, []byte("earliest")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{}}) require.NoError(t, err) @@ -1604,7 +1604,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(50, earliestValidTime, []byte("earliest")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, }) require.NoError(t, err) @@ -1638,7 +1638,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("first"), DepositCount: 1}, @@ -1674,7 +1674,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { InsertBlock(52, earliestValidTime+2, []byte("second")). InsertBlock(100, latestValidTime, []byte("latest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("no_new_deposits"), DepositCount: 0}, @@ -1707,7 +1707,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { t.Skip() p := mockPOW.NewPOWChain().InsertBlock(50, earliestValidTime, []byte("earliest")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1741,7 +1741,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { // because of earliest block increment in the algorithm. InsertBlock(50, earliestValidTime+1, []byte("first")) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("before_range"), DepositCount: 1}, @@ -1780,7 +1780,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) { depositCache, err := depositcache.New() require.NoError(t, err) - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: slot, Eth1DataVotes: []*ethpb.Eth1Data{ {BlockHash: []byte("earliest"), DepositCount: 1}, @@ -1923,7 +1923,7 @@ func TestProposer_Deposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t GenesisEth1Block: height, } - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Eth1Data: ðpb.Eth1Data{ BlockHash: bytesutil.PadTo([]byte("0x0"), 32), DepositRoot: make([]byte, 32), diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go index fb23d73912..4b91bd72c7 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server.go @@ -23,8 +23,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/powchain" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/beacon-chain/sync" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "google.golang.org/grpc/codes" @@ -43,7 +43,7 @@ type Server struct { ForkFetcher blockchain.ForkFetcher FinalizationFetcher blockchain.FinalizationFetcher TimeFetcher blockchain.TimeFetcher - CanonicalStateChan chan *pbp2p.BeaconState + CanonicalStateChan chan *statepb.BeaconState BlockFetcher powchain.POWBlockFetcher DepositFetcher depositcache.DepositFetcher ChainStartFetcher powchain.ChainStartFetcher diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index a816a47ad5..575caf0bcc 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -14,8 +14,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" @@ -52,7 +52,7 @@ func TestValidatorIndex_OK(t *testing.T) { func TestWaitForActivation_ContextClosed(t *testing.T) { ctx := context.Background() - beaconState, err := v1.InitializeFromProto(&pbp2p.BeaconState{ + beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 0, Validators: []*ethpb.Validator{}, }) @@ -70,7 +70,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.BeaconState, 1), DepositFetcher: depositCache, HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]}, } @@ -108,7 +108,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { pubKey1 := priv1.PublicKey().Marshal() pubKey2 := priv2.PublicKey().Marshal() - beaconState := &pbp2p.BeaconState{ + beaconState := &statepb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -146,7 +146,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { require.NoError(t, err) vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -197,7 +197,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) { pubKey2 := priv2.PublicKey().Marshal() pubKey3 := priv3.PublicKey().Marshal() - beaconState := &pbp2p.BeaconState{ + beaconState := &statepb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -226,7 +226,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) { require.NoError(t, err) vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.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 c733d53ccd..22d8a4ff25 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go @@ -15,8 +15,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -45,7 +45,7 @@ func TestValidatorStatus_DepositedEth1(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{}) + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{}) require.NoError(t, err) vs := &Server{ DepositFetcher: depositCache, @@ -88,7 +88,7 @@ func TestValidatorStatus_Deposited(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: pubKey1, @@ -138,7 +138,7 @@ func TestValidatorStatus_PartiallyDeposited(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ Validators: []*ethpb.Validator{ { PublicKey: pubKey1, @@ -253,7 +253,7 @@ func TestValidatorStatus_Active(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &pbp2p.BeaconState{ + state := &statepb.BeaconState{ GenesisTime: uint64(time.Unix(0, 0).Unix()), Slot: 10000, Validators: []*ethpb.Validator{{ @@ -307,7 +307,7 @@ func TestValidatorStatus_Exiting(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &pbp2p.BeaconState{ + state := &statepb.BeaconState{ Slot: slot, Validators: []*ethpb.Validator{{ PublicKey: pubKey, @@ -365,7 +365,7 @@ func TestValidatorStatus_Slashing(t *testing.T) { genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") - state := &pbp2p.BeaconState{ + state := &statepb.BeaconState{ Slot: slot, Validators: []*ethpb.Validator{{ Slashed: true, @@ -473,7 +473,7 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) { depositCache, err := depositcache.New() require.NoError(t, err) - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ Slot: 0, }) require.NoError(t, err) @@ -498,7 +498,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(&pbp2p.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -537,7 +537,7 @@ func TestActivationStatus_OK(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -692,7 +692,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { deposits[4].Data.PublicKey, deposits[5].Data.PublicKey, } - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -741,7 +741,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -792,7 +792,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 := &pbp2p.BeaconState{ + beaconState := &statepb.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ { @@ -837,7 +837,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { vs := &Server{ Ctx: context.Background(), - CanonicalStateChan: make(chan *pbp2p.BeaconState, 1), + CanonicalStateChan: make(chan *statepb.BeaconState, 1), ChainStartFetcher: &mockPOW.POWChain{}, BlockFetcher: &mockPOW.POWChain{}, Eth1InfoFetcher: &mockPOW.POWChain{}, @@ -903,7 +903,7 @@ func TestValidatorStatus_Invalid(t *testing.T) { 0: uint64(height), }, } - stateObj, err := v1.InitializeFromProtoUnsafe(&pbp2p.BeaconState{}) + stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{}) require.NoError(t, err) vs := &Server{ DepositFetcher: depositCache, diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index cfe76b04ef..29cc792be3 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -37,10 +37,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/rpc/statefetcher" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" chainSync "github.com/prysmaticlabs/prysm/beacon-chain/sync" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpbv1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -62,7 +62,7 @@ type Service struct { cancel context.CancelFunc listener net.Listener grpcServer *grpc.Server - canonicalStateChan chan *pbp2p.BeaconState + canonicalStateChan chan *statepb.BeaconState incomingAttestation chan *ethpbv1alpha1.Attestation credentialError error connectedRPCClients map[net.Addr]bool @@ -116,7 +116,7 @@ func NewService(ctx context.Context, cfg *Config) *Service { cfg: cfg, ctx: ctx, cancel: cancel, - canonicalStateChan: make(chan *pbp2p.BeaconState, params.BeaconConfig().DefaultBufferSize), + canonicalStateChan: make(chan *statepb.BeaconState, params.BeaconConfig().DefaultBufferSize), incomingAttestation: make(chan *ethpbv1alpha1.Attestation, params.BeaconConfig().DefaultBufferSize), connectedRPCClients: make(map[net.Addr]bool), } diff --git a/beacon-chain/rpc/statefetcher/BUILD.bazel b/beacon-chain/rpc/statefetcher/BUILD.bazel index 4bfeff4457..c0f2af9040 100644 --- a/beacon-chain/rpc/statefetcher/BUILD.bazel +++ b/beacon-chain/rpc/statefetcher/BUILD.bazel @@ -25,9 +25,9 @@ go_test( "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/db/testing:go_default_library", "//beacon-chain/state/stategen:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/rpc/statefetcher/fetcher_test.go b/beacon-chain/rpc/statefetcher/fetcher_test.go index 9ac878dcca..efd4ed0756 100644 --- a/beacon-chain/rpc/statefetcher/fetcher_test.go +++ b/beacon-chain/rpc/statefetcher/fetcher_test.go @@ -12,9 +12,9 @@ import ( chainMock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -26,7 +26,7 @@ func TestGetState(t *testing.T) { ctx := context.Background() headSlot := types.Slot(123) - fillSlot := func(state *pb.BeaconState) error { + fillSlot := func(state *statepb.BeaconState) error { state.Slot = headSlot return nil } @@ -60,7 +60,7 @@ func TestGetState(t *testing.T) { r, err := b.Block.HashTreeRoot() require.NoError(t, err) - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.BlockRoots[0] = r[:] return nil }) @@ -68,7 +68,7 @@ func TestGetState(t *testing.T) { stateRoot, err := state.HashTreeRoot(ctx) require.NoError(t, err) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: r[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]})) require.NoError(t, db.SaveGenesisBlockRoot(ctx, r)) require.NoError(t, db.SaveState(ctx, state, r)) @@ -188,7 +188,7 @@ func TestGetStateRoot(t *testing.T) { ctx := context.Background() headSlot := types.Slot(123) - fillSlot := func(state *pb.BeaconState) error { + fillSlot := func(state *statepb.BeaconState) error { state.Slot = headSlot return nil } @@ -219,13 +219,13 @@ func TestGetStateRoot(t *testing.T) { r, err := b.Block.HashTreeRoot() require.NoError(t, err) - state, err := testutil.NewBeaconState(func(state *pb.BeaconState) error { + state, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error { state.BlockRoots[0] = r[:] return nil }) require.NoError(t, err) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: r[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]})) require.NoError(t, db.SaveGenesisBlockRoot(ctx, r)) require.NoError(t, db.SaveState(ctx, state, r)) diff --git a/beacon-chain/state/genesis/BUILD.bazel b/beacon-chain/state/genesis/BUILD.bazel index eb77f79866..de0ef07f05 100644 --- a/beacon-chain/state/genesis/BUILD.bazel +++ b/beacon-chain/state/genesis/BUILD.bazel @@ -8,7 +8,7 @@ go_library( visibility = ["//beacon-chain/db:__subpackages__"], deps = [ "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "@com_github_golang_snappy//:go_default_library", ], diff --git a/beacon-chain/state/genesis/genesis.go b/beacon-chain/state/genesis/genesis.go index 4dcbe60026..e90fdb420d 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pbp2p.BeaconState{} + st := &statepb.BeaconState{} b, err := snappy.Decode(nil /*dst*/, b) if err != nil { return nil, err diff --git a/beacon-chain/state/interface/BUILD.bazel b/beacon-chain/state/interface/BUILD.bazel index 60466d5def..91728aa93c 100644 --- a/beacon-chain/state/interface/BUILD.bazel +++ b/beacon-chain/state/interface/BUILD.bazel @@ -22,9 +22,9 @@ go_library( "//tools/pcli:__pkg__", ], deps = [ - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], diff --git a/beacon-chain/state/interface/altair.go b/beacon-chain/state/interface/altair.go index ab08c39f25..f16acff338 100644 --- a/beacon-chain/state/interface/altair.go +++ b/beacon-chain/state/interface/altair.go @@ -1,14 +1,14 @@ package iface -import pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" +import statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" // BeaconStateAltair has read and write access to beacon state methods. type BeaconStateAltair interface { BeaconState - CurrentSyncCommittee() (*pbp2p.SyncCommittee, error) - NextSyncCommittee() (*pbp2p.SyncCommittee, error) - SetCurrentSyncCommittee(val *pbp2p.SyncCommittee) error - SetNextSyncCommittee(val *pbp2p.SyncCommittee) error + CurrentSyncCommittee() (*statepb.SyncCommittee, error) + NextSyncCommittee() (*statepb.SyncCommittee, error) + SetCurrentSyncCommittee(val *statepb.SyncCommittee) error + SetNextSyncCommittee(val *statepb.SyncCommittee) error CurrentEpochParticipation() ([]byte, error) PreviousEpochParticipation() ([]byte, error) InactivityScores() ([]uint64, error) diff --git a/beacon-chain/state/interface/phase0.go b/beacon-chain/state/interface/phase0.go index a89266f841..f67aea9717 100644 --- a/beacon-chain/state/interface/phase0.go +++ b/beacon-chain/state/interface/phase0.go @@ -8,9 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // BeaconState has read and write access to beacon state methods. @@ -39,7 +39,7 @@ type ReadOnlyBeaconState interface { GenesisTime() uint64 GenesisValidatorRoot() []byte Slot() types.Slot - Fork() *pbp2p.Fork + Fork() *statepb.Fork LatestBlockHeader() *ethpb.BeaconBlockHeader HistoricalRoots() [][]byte Slashings() []uint64 @@ -61,7 +61,7 @@ type WriteOnlyBeaconState interface { SetGenesisTime(val uint64) error SetGenesisValidatorRoot(val []byte) error SetSlot(val types.Slot) error - SetFork(val *pbp2p.Fork) error + SetFork(val *statepb.Fork) error SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error SetHistoricalRoots(val [][]byte) error SetSlashings(val []uint64) error @@ -139,8 +139,8 @@ type ReadOnlyEth1Data interface { // ReadOnlyAttestations defines a struct which only has read access to attestations methods. type ReadOnlyAttestations interface { - PreviousEpochAttestations() ([]*pbp2p.PendingAttestation, error) - CurrentEpochAttestations() ([]*pbp2p.PendingAttestation, error) + PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) + CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) } // WriteOnlyBlockRoots defines a struct which only has write access to block roots methods. @@ -194,8 +194,8 @@ type WriteOnlyCheckpoint interface { // WriteOnlyAttestations defines a struct which only has write access to attestations methods. type WriteOnlyAttestations interface { - AppendCurrentEpochAttestations(val *pbp2p.PendingAttestation) error - AppendPreviousEpochAttestations(val *pbp2p.PendingAttestation) error + AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error + AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error RotateAttestations() error } @@ -209,10 +209,10 @@ type FutureForkStub interface { PreviousEpochParticipation() ([]byte, error) InactivityScores() ([]uint64, error) SetInactivityScores(val []uint64) error - CurrentSyncCommittee() (*pbp2p.SyncCommittee, error) - SetCurrentSyncCommittee(val *pbp2p.SyncCommittee) error + CurrentSyncCommittee() (*statepb.SyncCommittee, error) + SetCurrentSyncCommittee(val *statepb.SyncCommittee) error SetPreviousParticipationBits(val []byte) error SetCurrentParticipationBits(val []byte) error - NextSyncCommittee() (*pbp2p.SyncCommittee, error) - SetNextSyncCommittee(val *pbp2p.SyncCommittee) error + NextSyncCommittee() (*statepb.SyncCommittee, error) + SetNextSyncCommittee(val *statepb.SyncCommittee) error } diff --git a/beacon-chain/state/stategen/BUILD.bazel b/beacon-chain/state/stategen/BUILD.bazel index f0ddc0ce10..24f372167c 100644 --- a/beacon-chain/state/stategen/BUILD.bazel +++ b/beacon-chain/state/stategen/BUILD.bazel @@ -26,8 +26,8 @@ go_library( "//beacon-chain/db:go_default_library", "//beacon-chain/db/filters:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "@com_github_hashicorp_golang_lru//:go_default_library", @@ -60,10 +60,10 @@ go_test( "//beacon-chain/db/testing:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/state/stategen/getter.go b/beacon-chain/state/stategen/getter.go index 0dffff8764..56c8ea8f0d 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" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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) (iface.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) (*pb.StateSummary, error) { - var summary *pb.StateSummary +func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { + var summary *statepb.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) (*pb.State } // 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) (*pb.StateSummary, error) { +func (s *State) RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) { if s.beaconDB.HasBlock(ctx, blockRoot) { b, err := s.beaconDB.Block(ctx, blockRoot) if err != nil { return nil, err } - summary := &pb.StateSummary{Slot: b.Block().Slot(), Root: blockRoot[:]} + summary := &statepb.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 4b4bde11a4..a700c9df84 100644 --- a/beacon-chain/state/stategen/getter_test.go +++ b/beacon-chain/state/stategen/getter_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -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, &pb.StateSummary{Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: service.slotsPerArchivedPoint, Root: r[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: 0, Root: gRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: 10, Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: 10, Root: blkRoot[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: 1, Root: r1[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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 9411238675..0ff2ea5071 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 ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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, iface.BeaconState(nil), state) assert.Equal(t, false, c.has(root), "Empty cache has an object") - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.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 48b6b1403e..0f74ef03cd 100644 --- a/beacon-chain/state/stategen/migrate_test.go +++ b/beacon-chain/state/stategen/migrate_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -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, &pb.StateSummary{Slot: 1, Root: r1[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.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, &pb.StateSummary{Slot: 4, Root: r4[:]})) + require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 4, Root: r4[:]})) service.finalizedInfo = &finalizedInfo{ slot: 0, root: genesisStateRoot, diff --git a/beacon-chain/state/stategen/mock.go b/beacon-chain/state/stategen/mock.go index 12d39b9def..117531e54f 100644 --- a/beacon-chain/state/stategen/mock.go +++ b/beacon-chain/state/stategen/mock.go @@ -5,8 +5,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // MockStateManager is a fake implementation of StateManager. @@ -86,7 +86,7 @@ func (m *MockStateManager) StateBySlot(ctx context.Context, slot types.Slot) (if func (m *MockStateManager) RecoverStateSummary( ctx context.Context, blockRoot [32]byte, -) (*ethereum_beacon_p2p_v1.StateSummary, error) { +) (*statepb.StateSummary, error) { panic("implement me") } diff --git a/beacon-chain/state/stategen/replay_test.go b/beacon-chain/state/stategen/replay_test.go index 683e19cbe4..80ba0d4c24 100644 --- a/beacon-chain/state/stategen/replay_test.go +++ b/beacon-chain/state/stategen/replay_test.go @@ -8,10 +8,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/db" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -40,7 +40,7 @@ func TestReplayBlocks_AllSkipSlots(t *testing.T) { copy(mockRoot[:], "hello-world") cp.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) service := New(beaconDB) targetSlot := params.BeaconConfig().SlotsPerEpoch - 1 @@ -69,7 +69,7 @@ func TestReplayBlocks_SameSlot(t *testing.T) { copy(mockRoot[:], "hello-world") cp.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) service := New(beaconDB) targetSlot := beaconState.Slot() @@ -99,7 +99,7 @@ func TestReplayBlocks_LowerSlotBlock(t *testing.T) { copy(mockRoot[:], "hello-world") cp.Root = mockRoot[:] require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) - require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) + require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{})) service := New(beaconDB) targetSlot := beaconState.Slot() @@ -740,7 +740,7 @@ func TestLoadFinalizedBlocks(t *testing.T) { filteredBlocks, err := s.loadFinalizedBlocks(ctx, 0, 8) require.NoError(t, err) require.Equal(t, 0, len(filteredBlocks)) - require.NoError(t, beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: roots[8][:]})) + require.NoError(t, beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: roots[8][:]})) require.NoError(t, s.beaconDB.SaveFinalizedCheckpoint(ctx, ðpb.Checkpoint{Root: roots[8][:]})) filteredBlocks, err = s.loadFinalizedBlocks(ctx, 0, 8) diff --git a/beacon-chain/state/stategen/service.go b/beacon-chain/state/stategen/service.go index 1e64b59c17..3342750281 100644 --- a/beacon-chain/state/stategen/service.go +++ b/beacon-chain/state/stategen/service.go @@ -11,8 +11,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" @@ -33,7 +33,7 @@ type StateManager interface { StateByRoot(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) StateByRootInitialSync(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) StateBySlot(ctx context.Context, slot types.Slot) (iface.BeaconState, error) - RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*ethereum_beacon_p2p_v1.StateSummary, error) + RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) SaveState(ctx context.Context, root [32]byte, st iface.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 7fbb09c133..f22c557f8e 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" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 ifac } // On an intermediate slots, save state summary. - if err := s.beaconDB.SaveStateSummary(ctx, &pb.StateSummary{ + if err := s.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{ Slot: st.Slot(), Root: blockRoot[:], }); err != nil { diff --git a/beacon-chain/state/stateutil/BUILD.bazel b/beacon-chain/state/stateutil/BUILD.bazel index b046869556..cedb3e4353 100644 --- a/beacon-chain/state/stateutil/BUILD.bazel +++ b/beacon-chain/state/stateutil/BUILD.bazel @@ -27,8 +27,8 @@ go_library( ], deps = [ "//beacon-chain/core/state/stateutils:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", "//shared/htrutils:go_default_library", @@ -52,8 +52,8 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", diff --git a/beacon-chain/state/stateutil/pending_attestation_root.go b/beacon-chain/state/stateutil/pending_attestation_root.go index 60a5f8c110..3f5513c3a2 100644 --- a/beacon-chain/state/stateutil/pending_attestation_root.go +++ b/beacon-chain/state/stateutil/pending_attestation_root.go @@ -4,8 +4,8 @@ import ( "encoding/binary" "github.com/pkg/errors" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/htrutils" "github.com/prysmaticlabs/prysm/shared/params" @@ -13,7 +13,7 @@ import ( // PendingAttRootWithHasher describes a method from which the hash tree root // of a pending attestation is returned. -func PendingAttRootWithHasher(hasher htrutils.HashFn, att *pb.PendingAttestation) ([32]byte, error) { +func PendingAttRootWithHasher(hasher htrutils.HashFn, att *statepb.PendingAttestation) ([32]byte, error) { var fieldRoots [][32]byte // Bitfield. @@ -43,7 +43,7 @@ func PendingAttRootWithHasher(hasher htrutils.HashFn, att *pb.PendingAttestation // PendingAttEncKey returns the encoded key in bytes of input `pendingAttestation`, // the returned key bytes can be used for caching purposes. -func PendingAttEncKey(att *pb.PendingAttestation) []byte { +func PendingAttEncKey(att *statepb.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 ee16a8e55e..10255f9cab 100644 --- a/beacon-chain/state/stateutil/state_root_test.go +++ b/beacon-chain/state/stateutil/state_root_test.go @@ -6,8 +6,8 @@ import ( "strconv" "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -16,7 +16,7 @@ import ( func TestState_FieldCount(t *testing.T) { count := params.BeaconConfig().BeaconStateFieldCount - typ := reflect.TypeOf(pb.BeaconState{}) + typ := reflect.TypeOf(statepb.BeaconState{}) numFields := 0 for i := 0; i < typ.NumField(); i++ { if typ.Field(i).Name == "state" || @@ -59,7 +59,7 @@ func BenchmarkHashTreeRoot_Generic_300000(b *testing.B) { } } -func setupGenesisState(tb testing.TB, count uint64) *pb.BeaconState { +func setupGenesisState(tb testing.TB, count uint64) *statepb.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/BUILD.bazel b/beacon-chain/state/v1/BUILD.bazel index 7acd2c9df7..547a1cae30 100644 --- a/beacon-chain/state/v1/BUILD.bazel +++ b/beacon-chain/state/v1/BUILD.bazel @@ -47,9 +47,9 @@ go_library( deps = [ "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stateutil:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/copyutil:go_default_library", "//shared/featureconfig:go_default_library", @@ -90,8 +90,8 @@ go_test( deps = [ "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stateutil:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/copyutil:go_default_library", "//shared/interop:go_default_library", diff --git a/beacon-chain/state/v1/field_roots.go b/beacon-chain/state/v1/field_roots.go index 0a2e15c21c..66d6877535 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pb.BeaconState) ([][]byte, error) { +func computeFieldRoots(ctx context.Context, state *statepb.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 *pb.BeaconState) ([][]byte, error) { +func (h *stateRootHasher) computeFieldRootsWithHasher(ctx context.Context, state *statepb.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 601cff99f0..40bdd28c39 100644 --- a/beacon-chain/state/v1/field_trie_helpers.go +++ b/beacon-chain/state/v1/field_trie_helpers.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/hashutil" ) @@ -53,10 +53,10 @@ func fieldConverters(field fieldIndex, indices []uint64, elements interface{}, c } return stateutil.HandleValidatorSlice(val, indices, convertAll) case previousEpochAttestations, currentEpochAttestations: - val, ok := elements.([]*pb.PendingAttestation) + val, ok := elements.([]*statepb.PendingAttestation) if !ok { return nil, errors.Errorf("Wanted type of %v but got %v", - reflect.TypeOf([]*pb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name()) + reflect.TypeOf([]*statepb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name()) } return handlePendingAttestation(val, indices, convertAll) default: @@ -103,14 +103,14 @@ func HandleEth1DataSlice(val []*ethpb.Eth1Data, indices []uint64, convertAll boo return roots, nil } -func handlePendingAttestation(val []*pb.PendingAttestation, indices []uint64, convertAll bool) ([][32]byte, error) { +func handlePendingAttestation(val []*statepb.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 *pb.PendingAttestation) error { + rootCreator := func(input *statepb.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 218ab6e9c5..2a8ce0b9a6 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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() ([]*pbp2p.PendingAttestation, error) { +func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) { if !b.hasInnerState() { return nil, nil } @@ -30,7 +30,7 @@ func (b *BeaconState) PreviousEpochAttestations() ([]*pbp2p.PendingAttestation, // previousEpochAttestations corresponding to blocks on the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) previousEpochAttestations() []*pbp2p.PendingAttestation { +func (b *BeaconState) previousEpochAttestations() []*statepb.PendingAttestation { if !b.hasInnerState() { return nil } @@ -39,7 +39,7 @@ func (b *BeaconState) previousEpochAttestations() []*pbp2p.PendingAttestation { } // CurrentEpochAttestations corresponding to blocks on the beacon chain. -func (b *BeaconState) CurrentEpochAttestations() ([]*pbp2p.PendingAttestation, error) { +func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) { if !b.hasInnerState() { return nil, nil } @@ -55,7 +55,7 @@ func (b *BeaconState) CurrentEpochAttestations() ([]*pbp2p.PendingAttestation, e // currentEpochAttestations corresponding to blocks on the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) currentEpochAttestations() []*pbp2p.PendingAttestation { +func (b *BeaconState) currentEpochAttestations() []*statepb.PendingAttestation { if !b.hasInnerState() { return nil } @@ -63,7 +63,7 @@ func (b *BeaconState) currentEpochAttestations() []*pbp2p.PendingAttestation { return b.safeCopyPendingAttestationSlice(b.state.CurrentEpochAttestations) } -func (h *stateRootHasher) epochAttestationsRoot(atts []*pbp2p.PendingAttestation) ([32]byte, error) { +func (h *stateRootHasher) epochAttestationsRoot(atts []*statepb.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 []*pbp2p.PendingAttestation return res, nil } -func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *pbp2p.PendingAttestation) ([32]byte, error) { +func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *statepb.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 ac20ef8757..20062aab24 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_PreviousEpochAttestations(t *testing.T) { - s, err := InitializeFromProto(&pbp2p.BeaconState{}) + s, err := InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) atts, err := s.PreviousEpochAttestations() require.NoError(t, err) - require.DeepEqual(t, []*pbp2p.PendingAttestation(nil), atts) + require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts) - want := []*pbp2p.PendingAttestation{{ProposerIndex: 100}} - s, err = InitializeFromProto(&pbp2p.BeaconState{PreviousEpochAttestations: want}) + want := []*statepb.PendingAttestation{{ProposerIndex: 100}} + s, err = InitializeFromProto(&statepb.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(&pbp2p.BeaconState{}) + s, err := InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) atts, err := s.CurrentEpochAttestations() require.NoError(t, err) - require.DeepEqual(t, []*pbp2p.PendingAttestation(nil), atts) + require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts) - want := []*pbp2p.PendingAttestation{{ProposerIndex: 101}} - s, err = InitializeFromProto(&pbp2p.BeaconState{CurrentEpochAttestations: want}) + want := []*statepb.PendingAttestation{{ProposerIndex: 101}} + s, err = InitializeFromProto(&statepb.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 a29bb2c529..7ffd8be6bd 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_LatestBlockHeader(t *testing.T) { - s, err := InitializeFromProto(&pbp2p.BeaconState{}) + s, err := InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) got := s.LatestBlockHeader() require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got) want := &v1alpha1.BeaconBlockHeader{Slot: 100} - s, err = InitializeFromProto(&pbp2p.BeaconState{LatestBlockHeader: want}) + s, err = InitializeFromProto(&statepb.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(&pbp2p.BeaconState{}) + s, err := InitializeFromProto(&statepb.BeaconState{}) require.NoError(t, err) got := s.BlockRoots() require.DeepEqual(t, ([][]byte)(nil), got) want := [][]byte{{'a'}} - s, err = InitializeFromProto(&pbp2p.BeaconState{BlockRoots: want}) + s, err = InitializeFromProto(&statepb.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(&pbp2p.BeaconState{}) + s, err := InitializeFromProto(&statepb.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(&pbp2p.BeaconState{BlockRoots: r}) + s, err = InitializeFromProto(&statepb.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 6146723acc..14ae470811 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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() *pbp2p.Fork { +func (b *BeaconState) Fork() *statepb.Fork { if !b.hasInnerState() { return nil } @@ -108,7 +108,7 @@ func (b *BeaconState) Fork() *pbp2p.Fork { // fork version of the beacon chain. // This assumes that a lock is already held on BeaconState. -func (b *BeaconState) fork() *pbp2p.Fork { +func (b *BeaconState) fork() *statepb.Fork { if !b.hasInnerState() { return nil } @@ -120,7 +120,7 @@ func (b *BeaconState) fork() *pbp2p.Fork { copy(prevVersion, b.state.Fork.PreviousVersion) currVersion := make([]byte, len(b.state.Fork.CurrentVersion)) copy(currVersion, b.state.Fork.CurrentVersion) - return &pbp2p.Fork{ + return &statepb.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 faca0c953e..8ae0fae9f3 100644 --- a/beacon-chain/state/v1/getters_state.go +++ b/beacon-chain/state/v1/getters_state.go @@ -6,8 +6,8 @@ import ( "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/pkg/errors" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // InnerStateUnsafe returns the pointer value of the underlying @@ -27,7 +27,7 @@ func (b *BeaconState) CloneInnerState() interface{} { b.lock.RLock() defer b.lock.RUnlock() - return &pbp2p.BeaconState{ + return &statepb.BeaconState{ GenesisTime: b.genesisTime(), GenesisValidatorsRoot: b.genesisValidatorRoot(), Slot: b.slot(), @@ -118,10 +118,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{}) (*pbp2p.BeaconState, error) { - pbState, ok := s.(*pbp2p.BeaconState) +func ProtobufBeaconState(s interface{}) (*statepb.BeaconState, error) { + pbState, ok := s.(*statepb.BeaconState) if !ok { - return nil, errors.New("input is not type pb.BeaconState") + return nil, errors.New("input is not type statepb.BeaconState") } return pbState, nil } @@ -153,12 +153,12 @@ func (b *BeaconState) safeCopyBytesAtIndex(input [][]byte, idx uint64) ([]byte, return root, nil } -func (b *BeaconState) safeCopyPendingAttestationSlice(input []*pbp2p.PendingAttestation) []*pbp2p.PendingAttestation { +func (b *BeaconState) safeCopyPendingAttestationSlice(input []*statepb.PendingAttestation) []*statepb.PendingAttestation { if input == nil { return nil } - res := make([]*pbp2p.PendingAttestation, len(input)) + res := make([]*statepb.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 98c8c879d0..8c1ad468e4 100644 --- a/beacon-chain/state/v1/getters_test.go +++ b/beacon-chain/state/v1/getters_test.go @@ -6,14 +6,14 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) func TestBeaconState_SlotDataRace(t *testing.T) { - headState, err := InitializeFromProto(&pb.BeaconState{Slot: 1}) + headState, err := InitializeFromProto(&statepb.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(&pb.BeaconState{CurrentJustifiedCheckpoint: c1}) + beaconState, err := InitializeFromProto(&statepb.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(&pb.BeaconState{PreviousJustifiedCheckpoint: c1}) + beaconState, err := InitializeFromProto(&statepb.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(&pb.BeaconState{}) + s, err := InitializeFromProto(&statepb.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(&pb.BeaconState{}) + s, err := InitializeFromProto(&statepb.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 0556811bc2..714aeed602 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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(&pb.BeaconState{ + st, err := v1.InitializeFromProtoUnsafe(&statepb.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 afb8a32183..58b150dd84 100644 --- a/beacon-chain/state/v1/helpers_test.go +++ b/beacon-chain/state/v1/helpers_test.go @@ -3,13 +3,13 @@ package v1 import ( "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) func Test_handlePendingAttestation_OutOfRange(t *testing.T) { - items := make([]*pb.PendingAttestation, 1) + items := make([]*statepb.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 5db25cee22..887c4f6b2e 100644 --- a/beacon-chain/state/v1/references_test.go +++ b/beacon-chain/state/v1/references_test.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -20,7 +20,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(&p2ppb.BeaconState{RandaoMixes: [][]byte{[]byte("foo")}}) + a, err := InitializeFromProtoUnsafe(&statepb.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 +46,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(&p2ppb.BeaconState{ + a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ BlockRoots: [][]byte{ root1[:], }, @@ -117,7 +117,7 @@ func TestStateReferenceCopy_NoUnexpectedRootsMutation(t *testing.T) { func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) { val1, val2 := []byte("foo"), []byte("bar") - a, err := InitializeFromProtoUnsafe(&p2ppb.BeaconState{ + a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ RandaoMixes: [][]byte{ val1, }, @@ -164,7 +164,7 @@ func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) { } func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { - assertAttFound := func(vals []*p2ppb.PendingAttestation, val uint64) { + assertAttFound := func(vals []*statepb.PendingAttestation, val uint64) { for i := range vals { if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) { return @@ -173,7 +173,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 []*p2ppb.PendingAttestation, val uint64) { + assertAttNotFound := func(vals []*statepb.PendingAttestation, val uint64) { for i := range vals { if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) { t.Log(string(debug.Stack())) @@ -183,13 +183,13 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { } } - a, err := InitializeFromProtoUnsafe(&p2ppb.BeaconState{}) + a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{}) require.NoError(t, err) assertRefCount(t, a, previousEpochAttestations, 1) assertRefCount(t, a, currentEpochAttestations, 1) // Update initial state. - atts := []*p2ppb.PendingAttestation{ + atts := []*statepb.PendingAttestation{ {AggregationBits: bitfield.NewBitlist(1)}, {AggregationBits: bitfield.NewBitlist(2)}, } @@ -248,9 +248,9 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { assertAttNotFound(b.state.GetPreviousEpochAttestations(), 2) // Mutator should only affect calling state: a. - applyToEveryAttestation := func(state *p2ppb.BeaconState) { + applyToEveryAttestation := func(state *statepb.BeaconState) { // One MUST copy on write. - atts = make([]*p2ppb.PendingAttestation, len(state.CurrentEpochAttestations)) + atts = make([]*statepb.PendingAttestation, len(state.CurrentEpochAttestations)) copy(atts, state.CurrentEpochAttestations) state.CurrentEpochAttestations = atts for i := range state.GetCurrentEpochAttestations() { @@ -259,7 +259,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { state.CurrentEpochAttestations[i] = att } - atts = make([]*p2ppb.PendingAttestation, len(state.PreviousEpochAttestations)) + atts = make([]*statepb.PendingAttestation, len(state.PreviousEpochAttestations)) copy(atts, state.PreviousEpochAttestations) state.PreviousEpochAttestations = atts for i := range state.GetPreviousEpochAttestations() { @@ -293,7 +293,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) { } func TestValidatorReferences_RemainsConsistent(t *testing.T) { - a, err := InitializeFromProtoUnsafe(&p2ppb.BeaconState{ + a, err := InitializeFromProtoUnsafe(&statepb.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 80855b77ba..3ebd6c58ae 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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([]*pbp2p.PendingAttestation{}) + b.setCurrentEpochAttestations([]*statepb.PendingAttestation{}) return nil } -func (b *BeaconState) setPreviousEpochAttestations(val []*pbp2p.PendingAttestation) { +func (b *BeaconState) setPreviousEpochAttestations(val []*statepb.PendingAttestation) { b.sharedFieldReferences[previousEpochAttestations].MinusRef() b.sharedFieldReferences[previousEpochAttestations] = stateutil.NewRef(1) @@ -31,7 +31,7 @@ func (b *BeaconState) setPreviousEpochAttestations(val []*pbp2p.PendingAttestati b.rebuildTrie[previousEpochAttestations] = true } -func (b *BeaconState) setCurrentEpochAttestations(val []*pbp2p.PendingAttestation) { +func (b *BeaconState) setCurrentEpochAttestations(val []*statepb.PendingAttestation) { b.sharedFieldReferences[currentEpochAttestations].MinusRef() b.sharedFieldReferences[currentEpochAttestations] = stateutil.NewRef(1) @@ -42,7 +42,7 @@ func (b *BeaconState) setCurrentEpochAttestations(val []*pbp2p.PendingAttestatio // AppendCurrentEpochAttestations for the beacon state. Appends the new value // to the the end of list. -func (b *BeaconState) AppendCurrentEpochAttestations(val *pbp2p.PendingAttestation) error { +func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error { if !b.hasInnerState() { return ErrNilInnerState } @@ -57,7 +57,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *pbp2p.PendingAttestati if b.sharedFieldReferences[currentEpochAttestations].Refs() > 1 { // Copy elements in underlying array by reference. - atts = make([]*pbp2p.PendingAttestation, len(b.state.CurrentEpochAttestations)) + atts = make([]*statepb.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 *pbp2p.PendingAttestati // AppendPreviousEpochAttestations for the beacon state. Appends the new value // to the the end of list. -func (b *BeaconState) AppendPreviousEpochAttestations(val *pbp2p.PendingAttestation) error { +func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error { if !b.hasInnerState() { return ErrNilInnerState } @@ -85,7 +85,7 @@ func (b *BeaconState) AppendPreviousEpochAttestations(val *pbp2p.PendingAttestat } if b.sharedFieldReferences[previousEpochAttestations].Refs() > 1 { - atts = make([]*pbp2p.PendingAttestation, len(b.state.PreviousEpochAttestations)) + atts = make([]*statepb.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 a5ea570d04..1a911663a3 100644 --- a/beacon-chain/state/v1/setters_attestation_test.go +++ b/beacon-chain/state/v1/setters_attestation_test.go @@ -5,18 +5,18 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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(&pb.BeaconState{ + st, err := InitializeFromProto(&statepb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*pb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*pb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, + CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*statepb.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(&pb.BeaconState{ + st, err := InitializeFromProto(&statepb.BeaconState{ Slot: 1, - CurrentEpochAttestations: []*pb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, - PreviousEpochAttestations: []*pb.PendingAttestation{{Data: ð.AttestationData{Slot: 123}}}, + CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: ð.AttestationData{Slot: 456}}}, + PreviousEpochAttestations: []*statepb.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 7c8bb2c7d4..0a0985a901 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pbp2p.Fork) error { +func (b *BeaconState) SetFork(val *statepb.Fork) error { if !b.hasInnerState() { return ErrNilInnerState } b.lock.Lock() defer b.lock.Unlock() - fk, ok := proto.Clone(val).(*pbp2p.Fork) + fk, ok := proto.Clone(val).(*statepb.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 5a3759c691..08e444a1b1 100644 --- a/beacon-chain/state/v1/state_test.go +++ b/beacon-chain/state/v1/state_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -60,7 +60,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) { WithdrawableEpoch: 1, }) } - st, err := InitializeFromProtoUnsafe(&pb.BeaconState{ + st, err := InitializeFromProtoUnsafe(&statepb.BeaconState{ Validators: vals, }) assert.NoError(t, err) @@ -102,6 +102,6 @@ func TestStateTrie_IsNil(t *testing.T) { emptyProto := &BeaconState{state: nil} assert.Equal(t, true, emptyProto.IsNil()) - nonNilState := &BeaconState{state: &pb.BeaconState{}} + nonNilState := &BeaconState{state: &statepb.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 f919d0e7d9..3377c38f9d 100644 --- a/beacon-chain/state/v1/state_trie.go +++ b/beacon-chain/state/v1/state_trie.go @@ -11,8 +11,8 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pbp2p.BeaconState) (*BeaconState, error) { - return InitializeFromProtoUnsafe(proto.Clone(st).(*pbp2p.BeaconState)) +func InitializeFromProto(st *statepb.BeaconState) (*BeaconState, error) { + return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconState)) } // InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer // and sets it as the inner state of the BeaconState type. -func InitializeFromProtoUnsafe(st *pbp2p.BeaconState) (*BeaconState, error) { +func InitializeFromProtoUnsafe(st *statepb.BeaconState) (*BeaconState, error) { if st == nil { return nil, errors.New("received nil state") } @@ -89,7 +89,7 @@ func (b *BeaconState) Copy() iface.BeaconState { defer b.lock.RUnlock() fieldCount := params.BeaconConfig().BeaconStateFieldCount dst := &BeaconState{ - state: &pbp2p.BeaconState{ + state: &statepb.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 afe145c66f..b964cb11e4 100644 --- a/beacon-chain/state/v1/state_trie_test.go +++ b/beacon-chain/state/v1/state_trie_test.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pbp2p.BeaconState + state *statepb.BeaconState error string } initTests := []test{ @@ -35,14 +35,14 @@ func TestInitializeFromProto(t *testing.T) { }, { name: "nil validators", - state: &pbp2p.BeaconState{ + state: &statepb.BeaconState{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &pbp2p.BeaconState{}, + state: &statepb.BeaconState{}, }, { name: "full state", @@ -67,7 +67,7 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { require.NoError(t, err) type test struct { name string - state *pbp2p.BeaconState + state *statepb.BeaconState error string } initTests := []test{ @@ -78,14 +78,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { }, { name: "nil validators", - state: &pbp2p.BeaconState{ + state: &statepb.BeaconState{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &pbp2p.BeaconState{}, + state: &statepb.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 *pbp2p.BeaconState) error { + source, err := testutil.NewBeaconState(testutil.FillRootsNaturalOpt, func(state *statepb.BeaconState) error { state.GenesisTime = 1 state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorroot"), 32) state.Slot = 2 - state.Fork = &pbp2p.Fork{ + state.Fork = &statepb.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 = []*pbp2p.PendingAttestation{{ + state.PreviousEpochAttestations = []*statepb.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 = []*pbp2p.PendingAttestation{{ + state.CurrentEpochAttestations = []*statepb.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 48fabf583a..d273918495 100644 --- a/beacon-chain/state/v1/types.go +++ b/beacon-chain/state/v1/types.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pbp2p.BeaconState + state *statepb.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 3235d85e4e..c91a59a0bc 100644 --- a/beacon-chain/state/v1/types_test.go +++ b/beacon-chain/state/v1/types_test.go @@ -7,8 +7,8 @@ import ( "testing" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" @@ -24,8 +24,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).(*pb.BeaconState) - assert.Equal(t, true, ok, "Object is not of type *pb.BeaconState") + cloned, ok := proto.Clone(genesis).(*statepb.BeaconState) + assert.Equal(t, true, ok, "Object is not of type *statepb.BeaconState") custom := customState.CloneInnerState() assert.DeepSSZEqual(t, cloned, custom) @@ -51,7 +51,7 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) { assert.Equal(t, r1, r2, "Mismatched roots") } -func setupGenesisState(tb testing.TB, count uint64) *pb.BeaconState { +func setupGenesisState(tb testing.TB, count uint64) *statepb.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 +126,8 @@ func BenchmarkStateClone_Proto(b *testing.B) { genesis := setupGenesisState(b, 64) b.StartTimer() for i := 0; i < b.N; i++ { - _, ok := proto.Clone(genesis).(*pb.BeaconState) - assert.Equal(b, true, ok, "Entity is not of type *pb.BeaconState") + _, ok := proto.Clone(genesis).(*statepb.BeaconState) + assert.Equal(b, true, ok, "Entity is not of type *statepb.BeaconState") } } @@ -214,7 +214,7 @@ func TestForkManualCopy_OK(t *testing.T) { genesis := setupGenesisState(t, 64) a, err := v1.InitializeFromProto(genesis) require.NoError(t, err) - wantedFork := &pb.Fork{ + wantedFork := &statepb.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 c60f1d1aaf..3d9fbc08ac 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // 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() (*pbp2p.SyncCommittee, error) { +func (b *BeaconState) CurrentSyncCommittee() (*statepb.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() (*pbp2p.SyncCommittee, error) { +func (b *BeaconState) NextSyncCommittee() (*statepb.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 550629f202..d7bccfaa6d 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // 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 *pbp2p.SyncCommittee) error { +func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.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 *pbp2p.SyncCommittee) error { +func (b *BeaconState) SetNextSyncCommittee(val *statepb.SyncCommittee) error { return errors.New("SetNextSyncCommittee is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v2/BUILD.bazel b/beacon-chain/state/v2/BUILD.bazel index 3714527cf1..88858ed9e9 100644 --- a/beacon-chain/state/v2/BUILD.bazel +++ b/beacon-chain/state/v2/BUILD.bazel @@ -25,8 +25,8 @@ go_library( deps = [ "//beacon-chain/state/stateutil:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", @@ -42,8 +42,8 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/state/v2/state_trie.go b/beacon-chain/state/v2/state_trie.go index 8f54214a09..6f3c1b731d 100644 --- a/beacon-chain/state/v2/state_trie.go +++ b/beacon-chain/state/v2/state_trie.go @@ -5,19 +5,19 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" "google.golang.org/protobuf/proto" ) // InitializeFromProto the beacon state from a protobuf representation. -func InitializeFromProto(st *pbp2p.BeaconStateAltair) (*BeaconState, error) { - return InitializeFromProtoUnsafe(proto.Clone(st).(*pbp2p.BeaconStateAltair)) +func InitializeFromProto(st *statepb.BeaconStateAltair) (*BeaconState, error) { + return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconStateAltair)) } // InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer // and sets it as the inner state of the BeaconState type. -func InitializeFromProtoUnsafe(st *pbp2p.BeaconStateAltair) (*BeaconState, error) { +func InitializeFromProtoUnsafe(st *statepb.BeaconStateAltair) (*BeaconState, error) { if st == nil { return nil, errors.New("received nil state") } diff --git a/beacon-chain/state/v2/state_trie_test.go b/beacon-chain/state/v2/state_trie_test.go index 66ef6a54b5..f80ffa461c 100644 --- a/beacon-chain/state/v2/state_trie_test.go +++ b/beacon-chain/state/v2/state_trie_test.go @@ -4,7 +4,7 @@ import ( "testing" stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -12,7 +12,7 @@ import ( func TestInitializeFromProto(t *testing.T) { type test struct { name string - state *pb.BeaconStateAltair + state *statepb.BeaconStateAltair error string } initTests := []test{ @@ -23,14 +23,14 @@ func TestInitializeFromProto(t *testing.T) { }, { name: "nil validators", - state: &pb.BeaconStateAltair{ + state: &statepb.BeaconStateAltair{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &pb.BeaconStateAltair{}, + state: &statepb.BeaconStateAltair{}, }, // TODO: Add full state. Blocked by testutil migration. } @@ -49,7 +49,7 @@ func TestInitializeFromProto(t *testing.T) { func TestInitializeFromProtoUnsafe(t *testing.T) { type test struct { name string - state *pb.BeaconStateAltair + state *statepb.BeaconStateAltair error string } initTests := []test{ @@ -60,14 +60,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) { }, { name: "nil validators", - state: &pb.BeaconStateAltair{ + state: &statepb.BeaconStateAltair{ Slot: 4, Validators: nil, }, }, { name: "empty state", - state: &pb.BeaconStateAltair{}, + state: &statepb.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 2c26530c46..635630929e 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" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pbp2p.BeaconStateAltair + state *statepb.BeaconStateAltair lock sync.RWMutex dirtyFields map[fieldIndex]interface{} dirtyIndices map[fieldIndex][]uint64 diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 096fb2ff8e..060bd9afd5 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -65,12 +65,11 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//shared:go_default_library", "//shared/abool:go_default_library", "//shared/bls:go_default_library", @@ -161,11 +160,12 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "//proto/beacon/p2p/v1/wrapper:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", + "//proto/prysm/v2/wrapper:go_default_library", "//shared/abool:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index 91103be89b..c8022566bd 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -28,8 +28,8 @@ go_library( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", @@ -72,9 +72,9 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", @@ -121,10 +121,10 @@ go_test( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 03ea679a17..b20d457ad8 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -15,8 +15,8 @@ import ( p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" prysmsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/sirupsen/logrus" diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go index 9d768009dd..34acc87b6a 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -19,10 +19,10 @@ import ( p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go index 0d4287dd19..d4628bc5d9 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go index 2223dc8133..d36e88a765 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go @@ -17,9 +17,9 @@ import ( p2pm "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" diff --git a/beacon-chain/sync/initial-sync/initial_sync_test.go b/beacon-chain/sync/initial-sync/initial_sync_test.go index 9e84eb338e..37dce1c29e 100644 --- a/beacon-chain/sync/initial-sync/initial_sync_test.go +++ b/beacon-chain/sync/initial-sync/initial_sync_test.go @@ -21,9 +21,9 @@ import ( p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" diff --git a/beacon-chain/sync/pending_attestations_queue_test.go b/beacon-chain/sync/pending_attestations_queue_test.go index 48806c572b..c9f211ac27 100644 --- a/beacon-chain/sync/pending_attestations_queue_test.go +++ b/beacon-chain/sync/pending_attestations_queue_test.go @@ -16,9 +16,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" diff --git a/beacon-chain/sync/pending_blocks_queue_test.go b/beacon-chain/sync/pending_blocks_queue_test.go index f6aa409e68..a944116315 100644 --- a/beacon-chain/sync/pending_blocks_queue_test.go +++ b/beacon-chain/sync/pending_blocks_queue_test.go @@ -19,9 +19,10 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" @@ -480,7 +481,7 @@ func TestService_ProcessPendingBlockOnCorrectSlot(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range.go b/beacon-chain/sync/rpc_beacon_blocks_by_range.go index 59f8123195..1f3a13a8a6 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go index 49aa8ca7d0..d701cfb526 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go @@ -20,9 +20,10 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -634,7 +635,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blocks[j]))) j++ } - stateSummaries := make([]*pb.StateSummary, len(blocks)) + stateSummaries := make([]*statepb.StateSummary, len(blocks)) if finalized { if chain.CanonicalRoots == nil { @@ -643,7 +644,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { for i, b := range blocks { bRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) - stateSummaries[i] = &pb.StateSummary{ + stateSummaries[i] = &statepb.StateSummary{ Slot: b.Block.Slot, Root: bRoot[:], } @@ -684,7 +685,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blocks[j]))) j++ } - stateSummaries := make([]*pb.StateSummary, len(blocks)) + stateSummaries := make([]*statepb.StateSummary, len(blocks)) if finalized { if chain.CanonicalRoots == nil { chain.CanonicalRoots = map[[32]byte]bool{} @@ -692,7 +693,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { for i, b := range blocks { bRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) - stateSummaries[i] = &pb.StateSummary{ + stateSummaries[i] = &statepb.StateSummary{ Slot: b.Block.Slot, Root: bRoot[:], } diff --git a/beacon-chain/sync/rpc_metadata.go b/beacon-chain/sync/rpc_metadata.go index 6a3e57251f..33186831ec 100644 --- a/beacon-chain/sync/rpc_metadata.go +++ b/beacon-chain/sync/rpc_metadata.go @@ -7,9 +7,9 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" - p2p2 "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" ) // metaDataHandler reads the incoming metadata rpc request from the peer. @@ -35,7 +35,7 @@ func (s *Service) metaDataHandler(_ context.Context, _ interface{}, stream libp2 return nil } -func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (p2p2.Metadata, error) { +func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (interfaces.Metadata, error) { ctx, cancel := context.WithTimeout(ctx, respTimeout) defer cancel() diff --git a/beacon-chain/sync/rpc_metadata_test.go b/beacon-chain/sync/rpc_metadata_test.go index 69b473581c..044fa5438f 100644 --- a/beacon-chain/sync/rpc_metadata_test.go +++ b/beacon-chain/sync/rpc_metadata_test.go @@ -12,8 +12,8 @@ import ( db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" diff --git a/beacon-chain/sync/rpc_ping_test.go b/beacon-chain/sync/rpc_ping_test.go index d86565ea30..93fbde5748 100644 --- a/beacon-chain/sync/rpc_ping_test.go +++ b/beacon-chain/sync/rpc_ping_test.go @@ -14,8 +14,8 @@ import ( db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" diff --git a/beacon-chain/sync/rpc_send_request.go b/beacon-chain/sync/rpc_send_request.go index 07607dc8e1..5fc8a93054 100644 --- a/beacon-chain/sync/rpc_send_request.go +++ b/beacon-chain/sync/rpc_send_request.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/sync/rpc_send_request_test.go b/beacon-chain/sync/rpc_send_request_test.go index 8852737243..d7aa4cee05 100644 --- a/beacon-chain/sync/rpc_send_request_test.go +++ b/beacon-chain/sync/rpc_send_request_test.go @@ -13,10 +13,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" diff --git a/beacon-chain/sync/rpc_status.go b/beacon-chain/sync/rpc_status.go index ff07428053..4235e1bafa 100644 --- a/beacon-chain/sync/rpc_status.go +++ b/beacon-chain/sync/rpc_status.go @@ -16,7 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/runutil" diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index ea8db61af2..20a6f45697 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -18,13 +18,14 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - p2pWrapper "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper" p2pInterfaces "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" + p2pWrapper "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -45,7 +46,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) { cfg: &Config{ P2P: p1, Chain: &mock.ChainService{ - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -113,7 +114,7 @@ func TestStatusRPCHandler_ConnectsOnGenesis(t *testing.T) { cfg: &Config{ P2P: p1, Chain: &mock.ChainService{ - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -194,7 +195,7 @@ func TestStatusRPCHandler_ReturnsHelloMessage(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -262,7 +263,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { Attnets: bytesutil.PadTo([]byte{'C', 'D'}, 8), }) - st, err := v1.InitializeFromProto(&pb.BeaconState{ + st, err := v1.InitializeFromProto(&statepb.BeaconState{ Slot: 5, }) require.NoError(t, err) @@ -278,7 +279,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { Chain: &mock.ChainService{ State: st, FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 0, Root: finalizedRoot[:]}, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -413,7 +414,7 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -495,7 +496,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -514,7 +515,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -566,11 +567,11 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) { blocksTillHead := makeBlocks(t, 1, 1000, genRoot) require.NoError(t, db.SaveBlocks(context.Background(), blocksTillHead)) - stateSummaries := make([]*pb.StateSummary, len(blocksTillHead)) + stateSummaries := make([]*statepb.StateSummary, len(blocksTillHead)) for i, b := range blocksTillHead { bRoot, err := b.Block().HashTreeRoot() require.NoError(t, err) - stateSummaries[i] = &pb.StateSummary{ + stateSummaries[i] = &statepb.StateSummary{ Slot: b.Block().Slot(), Root: bRoot[:], } @@ -668,7 +669,7 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) { State: nState, FinalizedCheckPoint: remoteFinalizedChkpt, Root: rHeadRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -687,7 +688,7 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) { State: nState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -755,7 +756,7 @@ func TestStatusRPCRequest_BadPeerHandshake(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, @@ -834,7 +835,7 @@ func TestStatusRPC_ValidGenesisMessage(t *testing.T) { State: genesisState, FinalizedCheckPoint: finalizedCheckpt, Root: headRoot[:], - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: params.BeaconConfig().GenesisForkVersion, CurrentVersion: params.BeaconConfig().GenesisForkVersion, }, diff --git a/beacon-chain/sync/rpc_test.go b/beacon-chain/sync/rpc_test.go index 5fa031ba15..804ad8f2d8 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" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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.(*p2ppb.Fork) + m, ok := msg.(*statepb.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(p2ppb.Fork) + prysmP2P.RPCTopicMappings[topic] = new(statepb.Fork) // Cleanup Topic mappings defer func() { delete(prysmP2P.RPCTopicMappings, topic) }() r.registerRPC(topic, handler) - p2p.ReceiveRPC(topic, &p2ppb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")}) + p2p.ReceiveRPC(topic, &statepb.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/beacon-chain/sync/service_test.go b/beacon-chain/sync/service_test.go index 1272bb0d2c..ede81d7ff8 100644 --- a/beacon-chain/sync/service_test.go +++ b/beacon-chain/sync/service_test.go @@ -11,9 +11,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -23,7 +23,7 @@ import ( ) func TestService_StatusZeroEpoch(t *testing.T) { - bState, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 0}) + bState, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 0}) require.NoError(t, err) r := &Service{ cfg: &Config{ diff --git a/beacon-chain/sync/validate_beacon_blocks_test.go b/beacon-chain/sync/validate_beacon_blocks_test.go index d64a34ed84..b4172abe60 100644 --- a/beacon-chain/sync/validate_beacon_blocks_test.go +++ b/beacon-chain/sync/validate_beacon_blocks_test.go @@ -22,9 +22,9 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -49,7 +49,7 @@ func TestValidateBeaconBlockPubSub_InvalidSignature(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) @@ -211,7 +211,7 @@ func TestValidateBeaconBlockPubSub_ValidProposerSignature(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) @@ -274,7 +274,7 @@ func TestValidateBeaconBlockPubSub_WithLookahead(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() // The next block is only 1 epoch ahead so as to not induce a new seed. blkSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(helpers.NextEpoch(copied))) @@ -339,7 +339,7 @@ func TestValidateBeaconBlockPubSub_AdvanceEpochsForState(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() // The next block is at least 2 epochs ahead to induce shuffling and a new seed. blkSlot := params.BeaconConfig().SlotsPerEpoch * 2 @@ -445,7 +445,7 @@ func TestValidateBeaconBlockPubSub_AcceptBlocksFromNearFuture(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) @@ -731,7 +731,7 @@ func TestValidateBeaconBlockPubSub_ParentNotFinalizedDescendant(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) @@ -794,7 +794,7 @@ func TestValidateBeaconBlockPubSub_InvalidParentBlock(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() require.NoError(t, copied.SetSlot(1)) proposerIdx, err := helpers.BeaconProposerIndex(copied) @@ -883,7 +883,7 @@ func TestValidateBeaconBlockPubSub_RejectEvilBlocksFromFuture(t *testing.T) { bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, db.SaveStateSummary(ctx, &pb.StateSummary{Root: bRoot[:]})) + require.NoError(t, db.SaveStateSummary(ctx, &statepb.StateSummary{Root: bRoot[:]})) copied := beaconState.Copy() // The next block is at least 2 epochs ahead to induce shuffling and a new seed. diff --git a/beacon-chain/sync/validate_proposer_slashing_test.go b/beacon-chain/sync/validate_proposer_slashing_test.go index ad968d1591..012c6b4972 100644 --- a/beacon-chain/sync/validate_proposer_slashing_test.go +++ b/beacon-chain/sync/validate_proposer_slashing_test.go @@ -18,10 +18,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,11 +45,11 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, iface.Be } currentSlot := types.Slot(0) - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: validators, Slot: currentSlot, Balances: validatorBalances, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, Epoch: 0, diff --git a/beacon-chain/sync/validate_voluntary_exit_test.go b/beacon-chain/sync/validate_voluntary_exit_test.go index 43ae4a8260..a937d4b8ca 100644 --- a/beacon-chain/sync/validate_voluntary_exit_test.go +++ b/beacon-chain/sync/validate_voluntary_exit_test.go @@ -15,10 +15,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" + v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -38,9 +38,9 @@ func setupValidExit(t *testing.T) (*ethpb.SignedVoluntaryExit, iface.BeaconState ActivationEpoch: 0, }, } - state, err := v1.InitializeFromProto(&pb.BeaconState{ + state, err := v1.InitializeFromProto(&statepb.BeaconState{ Validators: registry, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, diff --git a/fuzz/BUILD.bazel b/fuzz/BUILD.bazel index d2de79faeb..70fa15ad15 100644 --- a/fuzz/BUILD.bazel +++ b/fuzz/BUILD.bazel @@ -15,9 +15,10 @@ ssz_gen_marshal( name = "ssz_generated_files", srcs = ["inputs.go"], includes = [ - "//proto/beacon/p2p/v1:go_default_library", - "@com_github_prysmaticlabs_eth2_types//:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "@com_github_prysmaticlabs_eth2_types//:go_default_library", ], objs = [ "InputBlockWithPrestate", @@ -65,7 +66,8 @@ go_fuzz_test( "//beacon-chain/core/state:go_default_library", "//fuzz/testing:go_default_library", "//shared/params:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//beacon-chain/operations/attestations:go_default_library", @@ -106,7 +108,8 @@ go_fuzz_test( "//beacon-chain/blockchain/testing:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//beacon-chain/cache:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_libp2p_go_libp2p//:go_default_library", @@ -130,7 +133,8 @@ go_fuzz_test( deps = [ "//beacon-chain/p2p/encoder:go_default_library", "//shared/params:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", ] + COMMON_DEPS, ) @@ -145,7 +149,8 @@ go_fuzz_test( importpath = IMPORT_PATH, max_len = 30000000, deps = [ - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//beacon-chain/core/state:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//shared/params:go_default_library", @@ -186,7 +191,8 @@ go_library( "//beacon-chain/sync:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//fuzz/testing:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", @@ -213,7 +219,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/fuzz", visibility = ["//visibility:public"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/prysm/v1alpha1:go_default_library", ] + SSZ_DEPS, # keep ) diff --git a/fuzz/generated.ssz.go b/fuzz/generated.ssz.go index e5a1870145..6799e423db 100644 --- a/fuzz/generated.ssz.go +++ b/fuzz/generated.ssz.go @@ -1,10 +1,11 @@ // Code generated by fastssz. DO NOT EDIT. +// Hash: b0b105d81609a8e5a77ef34c799063f12138f31507c5781512531b5387511926 package fuzz import ( ssz "github.com/ferranbt/fastssz" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // MarshalSSZ ssz marshals the InputBlockWithPrestate object @@ -20,7 +21,7 @@ func (i *InputBlockWithPrestate) MarshalSSZTo(buf []byte) (dst []byte, err error // Offset (0) 'State' dst = ssz.WriteOffset(dst, offset) if i.State == nil { - i.State = new(pb.BeaconState) + i.State = new(statepb.BeaconState) } offset += i.State.SizeSSZ() @@ -60,6 +61,10 @@ func (i *InputBlockWithPrestate) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } + if o0 < 8 { + return ssz.ErrInvalidVariableOffset + } + // Offset (1) 'Block' if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { return ssz.ErrOffset @@ -69,7 +74,7 @@ func (i *InputBlockWithPrestate) UnmarshalSSZ(buf []byte) error { { buf = tail[o0:o1] if i.State == nil { - i.State = new(pb.BeaconState) + i.State = new(statepb.BeaconState) } if err = i.State.UnmarshalSSZ(buf); err != nil { return err @@ -95,7 +100,7 @@ func (i *InputBlockWithPrestate) SizeSSZ() (size int) { // Field (0) 'State' if i.State == nil { - i.State = new(pb.BeaconState) + i.State = new(statepb.BeaconState) } size += i.State.SizeSSZ() diff --git a/fuzz/inputs.go b/fuzz/inputs.go index 4542100d76..1f4f86bcab 100644 --- a/fuzz/inputs.go +++ b/fuzz/inputs.go @@ -1,12 +1,12 @@ package fuzz import ( - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) // InputBlockWithPrestate for fuzz testing beacon blocks. type InputBlockWithPrestate struct { - State *pb.BeaconState + State *statepb.BeaconState Block *ethpb.SignedBeaconBlock } diff --git a/fuzz/rpc_status_fuzz.go b/fuzz/rpc_status_fuzz.go index e067928be5..310cfe3946 100644 --- a/fuzz/rpc_status_fuzz.go +++ b/fuzz/rpc_status_fuzz.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" regularsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/sirupsen/logrus" ) @@ -53,7 +53,7 @@ func init() { Chain: &mock.ChainService{ Root: bytesutil.PadTo([]byte("root"), 32), FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 4, Root: make([]byte, 32)}, - Fork: &pb.Fork{CurrentVersion: []byte("foo")}, + Fork: &statepb.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 8e55d49473..2f3e44c85d 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{} + st := &statepb.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().(*pb.BeaconState) + rawState, ok := s.InnerStateUnsafe().(*statepb.BeaconState) if !ok { panic("non valid type assertion") } diff --git a/fuzz/testing/BUILD.bazel b/fuzz/testing/BUILD.bazel index 3ee17bee33..3184239123 100644 --- a/fuzz/testing/BUILD.bazel +++ b/fuzz/testing/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//fuzz:__pkg__", ], deps = [ - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", ], ) diff --git a/fuzz/testing/beacon_fuzz_states.go b/fuzz/testing/beacon_fuzz_states.go index c1f3b9909b..d24ad0afde 100644 --- a/fuzz/testing/beacon_fuzz_states.go +++ b/fuzz/testing/beacon_fuzz_states.go @@ -5,7 +5,7 @@ import ( "os" "strconv" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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) (*pb.BeaconState, error) { +func BeaconFuzzState(ID uint64) (*statepb.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) (*pb.BeaconState, error) { if err != nil { return nil, err } - st := &pb.BeaconState{} + st := &statepb.BeaconState{} if err := st.UnmarshalSSZ(b); err != nil { return nil, err } diff --git a/proto/beacon/p2p/BUILD.bazel b/proto/beacon/p2p/BUILD.bazel deleted file mode 100644 index 75e9e01dbe..0000000000 --- a/proto/beacon/p2p/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["interface.go"], - importpath = "github.com/prysmaticlabs/prysm/proto/beacon/p2p", - visibility = ["//visibility:public"], - deps = [ - "//proto/beacon/p2p/v1:go_default_library", - "@com_github_prysmaticlabs_go_bitfield//:go_default_library", - ], -) diff --git a/proto/beacon/p2p/v1/wrapper/BUILD.bazel b/proto/beacon/p2p/v1/wrapper/BUILD.bazel deleted file mode 100644 index ccb1c4c112..0000000000 --- a/proto/beacon/p2p/v1/wrapper/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["metadata.go"], - importpath = "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper", - visibility = ["//visibility:public"], - deps = [ - "//proto/beacon/p2p:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", - "@com_github_prysmaticlabs_go_bitfield//:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - ], -) diff --git a/proto/eth/v1/generated.ssz.go b/proto/eth/v1/generated.ssz.go index 22ffbd7083..c2deb27f39 100644 --- a/proto/eth/v1/generated.ssz.go +++ b/proto/eth/v1/generated.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: d88bf8c7704ca0134277d0433309d72a5ca08f331f5390137c627b6bd1f5711b +// Hash: c7ceb4a18b683c97befe3cafe2331dd3c7970bfa6ba67a3ed2db171981e15451 package v1 import ( diff --git a/proto/interfaces/BUILD.bazel b/proto/interfaces/BUILD.bazel index 01b2931107..d84f956be2 100644 --- a/proto/interfaces/BUILD.bazel +++ b/proto/interfaces/BUILD.bazel @@ -2,7 +2,10 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", - srcs = ["block_interface.go"], + srcs = [ + "block.go", + "metadata.go", + ], importpath = "github.com/prysmaticlabs/prysm/proto/interfaces", visibility = ["//visibility:public"], deps = [ @@ -10,6 +13,7 @@ go_library( "//proto/prysm/v2:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", + "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/proto/interfaces/block_interface.go b/proto/interfaces/block.go similarity index 100% rename from proto/interfaces/block_interface.go rename to proto/interfaces/block.go diff --git a/proto/beacon/p2p/interface.go b/proto/interfaces/metadata.go similarity index 82% rename from proto/beacon/p2p/interface.go rename to proto/interfaces/metadata.go index 2206ab903b..0b482cd839 100644 --- a/proto/beacon/p2p/interface.go +++ b/proto/interfaces/metadata.go @@ -1,8 +1,8 @@ -package p2p +package interfaces import ( "github.com/prysmaticlabs/go-bitfield" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" ) // Metadata returns the interface of a p2p metadata type. diff --git a/proto/prysm/v1alpha1/generated.ssz.go b/proto/prysm/v1alpha1/generated.ssz.go index 22ef7b717e..661e9d8209 100644 --- a/proto/prysm/v1alpha1/generated.ssz.go +++ b/proto/prysm/v1alpha1/generated.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: a3416de26c1bcfbb8e5db8be7b8bf3b5aa2ee876b633efefc6e1f55acf0cb02b +// Hash: f5537346cbd4b4b06b242faa9296907d81d065ea79e8993b65370a1ea0381017 package eth import ( diff --git a/proto/prysm/v2/BUILD.bazel b/proto/prysm/v2/BUILD.bazel index 4f1264774e..c8f7140023 100644 --- a/proto/prysm/v2/BUILD.bazel +++ b/proto/prysm/v2/BUILD.bazel @@ -22,20 +22,20 @@ proto_library( name = "proto", srcs = [ "beacon_chain.proto", - "validator.proto", - "finalized_block_root_container.proto", - "powchain.proto", - "keymanager.proto", - "web_api.proto", "debug.proto", + "finalized_block_root_container.proto", "health.proto", + "keymanager.proto", + "powchain.proto", "slasher.proto", + "validator.proto", + "web_api.proto", ":ssz_proto_files", ], visibility = ["//visibility:public"], deps = [ "//proto/eth/ext:proto", - "//proto/beacon/p2p/v1:v1_proto", + "//proto/prysm/v2/state:v1_proto", "//proto/prysm/v1alpha1:proto", "@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_proto", "@com_google_protobuf//:any_proto", @@ -66,6 +66,11 @@ ssz_gen_marshal( "SyncCommitteeContribution", "ContributionAndProof", "SignedContributionAndProof", + "BeaconBlocksByRangeRequest", + "ENRForkID", + "MetaDataV0", + "MetaDataV1", + "Status", ], ) @@ -79,8 +84,8 @@ go_proto_library( visibility = ["//visibility:public"], deps = [ "//proto/eth/ext:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "@com_github_golang_protobuf//proto:go_default_library", "@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_go_proto", "@com_github_prysmaticlabs_eth2_types//:go_default_library", @@ -106,8 +111,8 @@ go_proto_library( visibility = ["//visibility:private"], deps = [ "//proto/eth/ext:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_go_proto", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@go_googleapis//google/api:annotations_go_proto", @@ -133,7 +138,7 @@ go_library( deps = SSZ_DEPS + [ "//proto/eth/ext:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library", "@com_github_grpc_ecosystem_grpc_gateway_v2//utilities:go_default_library", "@io_bazel_rules_go//proto/wkt:empty_go_proto", @@ -157,6 +162,7 @@ ssz_proto_files( name = "ssz_proto_files", srcs = [ "beacon_block.proto", + "p2p_messages.proto", "sync_committee.proto", ], config = select({ diff --git a/proto/prysm/v2/debug.pb.go b/proto/prysm/v2/debug.pb.go index 8c0531749d..586200efdf 100755 --- a/proto/prysm/v2/debug.pb.go +++ b/proto/prysm/v2/debug.pb.go @@ -14,7 +14,6 @@ import ( proto "github.com/golang/protobuf/proto" empty "github.com/golang/protobuf/ptypes/empty" github_com_prysmaticlabs_eth2_types "github.com/prysmaticlabs/eth2-types" - v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" _ "github.com/prysmaticlabs/prysm/proto/eth/ext" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -648,7 +647,7 @@ type DebugPeerResponse struct { PeerId string `protobuf:"bytes,4,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` Enr string `protobuf:"bytes,5,opt,name=enr,proto3" json:"enr,omitempty"` PeerInfo *DebugPeerResponse_PeerInfo `protobuf:"bytes,6,opt,name=peer_info,json=peerInfo,proto3" json:"peer_info,omitempty"` - PeerStatus *v1.Status `protobuf:"bytes,7,opt,name=peer_status,json=peerStatus,proto3" json:"peer_status,omitempty"` + PeerStatus *Status `protobuf:"bytes,7,opt,name=peer_status,json=peerStatus,proto3" json:"peer_status,omitempty"` LastUpdated uint64 `protobuf:"varint,8,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"` ScoreInfo *ScoreInfo `protobuf:"bytes,9,opt,name=score_info,json=scoreInfo,proto3" json:"score_info,omitempty"` } @@ -727,7 +726,7 @@ func (x *DebugPeerResponse) GetPeerInfo() *DebugPeerResponse_PeerInfo { return nil } -func (x *DebugPeerResponse) GetPeerStatus() *v1.Status { +func (x *DebugPeerResponse) GetPeerStatus() *Status { if x != nil { return x.PeerStatus } @@ -919,13 +918,13 @@ type DebugPeerResponse_PeerInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MetadataV0 *v1.MetaDataV0 `protobuf:"bytes,1,opt,name=metadataV0,proto3" json:"metadataV0,omitempty"` - MetadataV1 *v1.MetaDataV1 `protobuf:"bytes,2,opt,name=metadataV1,proto3" json:"metadataV1,omitempty"` - Protocols []string `protobuf:"bytes,3,rep,name=protocols,proto3" json:"protocols,omitempty"` - FaultCount uint64 `protobuf:"varint,4,opt,name=fault_count,json=faultCount,proto3" json:"fault_count,omitempty"` - ProtocolVersion string `protobuf:"bytes,5,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` - AgentVersion string `protobuf:"bytes,6,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"` - PeerLatency uint64 `protobuf:"varint,7,opt,name=peer_latency,json=peerLatency,proto3" json:"peer_latency,omitempty"` + MetadataV0 *MetaDataV0 `protobuf:"bytes,1,opt,name=metadataV0,proto3" json:"metadataV0,omitempty"` + MetadataV1 *MetaDataV1 `protobuf:"bytes,2,opt,name=metadataV1,proto3" json:"metadataV1,omitempty"` + Protocols []string `protobuf:"bytes,3,rep,name=protocols,proto3" json:"protocols,omitempty"` + FaultCount uint64 `protobuf:"varint,4,opt,name=fault_count,json=faultCount,proto3" json:"fault_count,omitempty"` + ProtocolVersion string `protobuf:"bytes,5,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` + AgentVersion string `protobuf:"bytes,6,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"` + PeerLatency uint64 `protobuf:"varint,7,opt,name=peer_latency,json=peerLatency,proto3" json:"peer_latency,omitempty"` } func (x *DebugPeerResponse_PeerInfo) Reset() { @@ -960,14 +959,14 @@ func (*DebugPeerResponse_PeerInfo) Descriptor() ([]byte, []int) { return file_proto_prysm_v2_debug_proto_rawDescGZIP(), []int{9, 0} } -func (x *DebugPeerResponse_PeerInfo) GetMetadataV0() *v1.MetaDataV0 { +func (x *DebugPeerResponse_PeerInfo) GetMetadataV0() *MetaDataV0 { if x != nil { return x.MetadataV0 } return nil } -func (x *DebugPeerResponse_PeerInfo) GetMetadataV1() *v1.MetaDataV1 { +func (x *DebugPeerResponse_PeerInfo) GetMetadataV1() *MetaDataV1 { if x != nil { return x.MetadataV1 } @@ -1314,9 +1313,9 @@ var file_proto_prysm_v2_debug_proto_goTypes = []interface{}{ nil, // 15: ethereum.prysm.v2.ScoreInfo.TopicScoresEntry (v1alpha1.PeerDirection)(0), // 16: ethereum.eth.v1alpha1.PeerDirection (v1alpha1.ConnectionState)(0), // 17: ethereum.eth.v1alpha1.ConnectionState - (*v1.Status)(nil), // 18: ethereum.beacon.p2p.v1.Status - (*v1.MetaDataV0)(nil), // 19: ethereum.beacon.p2p.v1.MetaDataV0 - (*v1.MetaDataV1)(nil), // 20: ethereum.beacon.p2p.v1.MetaDataV1 + (*Status)(nil), // 18: ethereum.beacon.p2p.v1.Status + (*MetaDataV0)(nil), // 19: ethereum.beacon.p2p.v1.MetaDataV0 + (*MetaDataV1)(nil), // 20: ethereum.beacon.p2p.v1.MetaDataV1 (*empty.Empty)(nil), // 21: google.protobuf.Empty (*v1alpha1.PeerRequest)(nil), // 22: ethereum.eth.v1alpha1.PeerRequest } diff --git a/proto/prysm/v2/debug.proto b/proto/prysm/v2/debug.proto index 2ece9bca87..e8d76430ed 100644 --- a/proto/prysm/v2/debug.proto +++ b/proto/prysm/v2/debug.proto @@ -4,7 +4,7 @@ package ethereum.prysm.v2; import "proto/eth/ext/options.proto"; import "proto/prysm/v1alpha1/node.proto"; -import "proto/beacon/p2p/v1/messages.proto"; +import "proto/prysm/v2/p2p_messages.proto"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; @@ -144,8 +144,8 @@ message DebugPeerResponse { message PeerInfo { // Metadata of the peer, containing their bitfield // and sequence number. - ethereum.beacon.p2p.v1.MetaDataV0 metadataV0 = 1; - ethereum.beacon.p2p.v1.MetaDataV1 metadataV1 = 2; + MetaDataV0 metadataV0 = 1; + MetaDataV1 metadataV1 = 2; // List of protocols the peer supports. repeated string protocols = 3; // Number of times peer has been penalised. @@ -170,7 +170,7 @@ message DebugPeerResponse { // Peer Info of the peer containing all relevant metadata. PeerInfo peer_info = 6; // Peer Status of the peer. - ethereum.beacon.p2p.v1.Status peer_status = 7; + Status peer_status = 7; // Last know update time for peer status. uint64 last_updated = 8; // Score Info of the peer. diff --git a/proto/prysm/v2/generated.ssz.go b/proto/prysm/v2/generated.ssz.go index ba9584514e..9d85550107 100644 --- a/proto/prysm/v2/generated.ssz.go +++ b/proto/prysm/v2/generated.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 577b6f3ae5aaaf7838b498df8ada55a81b50923f042ce4decc6d967d480e8167 +// Hash: 1186dae390e9383de59c316019ff3e4e86aaa009d021c3ce1263bd99c7fac1f0 package v2 import ( @@ -797,6 +797,448 @@ func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { return } +// MarshalSSZ ssz marshals the Status object +func (s *Status) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the Status object to a target array +func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'ForkDigest' + if len(s.ForkDigest) != 4 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, s.ForkDigest...) + + // Field (1) 'FinalizedRoot' + if len(s.FinalizedRoot) != 32 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, s.FinalizedRoot...) + + // Field (2) 'FinalizedEpoch' + dst = ssz.MarshalUint64(dst, uint64(s.FinalizedEpoch)) + + // Field (3) 'HeadRoot' + if len(s.HeadRoot) != 32 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, s.HeadRoot...) + + // Field (4) 'HeadSlot' + dst = ssz.MarshalUint64(dst, uint64(s.HeadSlot)) + + return +} + +// UnmarshalSSZ ssz unmarshals the Status object +func (s *Status) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 84 { + return ssz.ErrSize + } + + // Field (0) 'ForkDigest' + if cap(s.ForkDigest) == 0 { + s.ForkDigest = make([]byte, 0, len(buf[0:4])) + } + s.ForkDigest = append(s.ForkDigest, buf[0:4]...) + + // Field (1) 'FinalizedRoot' + if cap(s.FinalizedRoot) == 0 { + s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) + } + s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) + + // Field (2) 'FinalizedEpoch' + s.FinalizedEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[36:44])) + + // Field (3) 'HeadRoot' + if cap(s.HeadRoot) == 0 { + s.HeadRoot = make([]byte, 0, len(buf[44:76])) + } + s.HeadRoot = append(s.HeadRoot, buf[44:76]...) + + // Field (4) 'HeadSlot' + s.HeadSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[76:84])) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the Status object +func (s *Status) SizeSSZ() (size int) { + size = 84 + return +} + +// HashTreeRoot ssz hashes the Status object +func (s *Status) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the Status object with a hasher +func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + + // Field (0) 'ForkDigest' + if len(s.ForkDigest) != 4 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(s.ForkDigest) + + // Field (1) 'FinalizedRoot' + if len(s.FinalizedRoot) != 32 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(s.FinalizedRoot) + + // Field (2) 'FinalizedEpoch' + hh.PutUint64(uint64(s.FinalizedEpoch)) + + // Field (3) 'HeadRoot' + if len(s.HeadRoot) != 32 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(s.HeadRoot) + + // Field (4) 'HeadSlot' + hh.PutUint64(uint64(s.HeadSlot)) + + hh.Merkleize(indx) + return +} + +// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object +func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) +} + +// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array +func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'StartSlot' + dst = ssz.MarshalUint64(dst, uint64(b.StartSlot)) + + // Field (1) 'Count' + dst = ssz.MarshalUint64(dst, b.Count) + + // Field (2) 'Step' + dst = ssz.MarshalUint64(dst, b.Step) + + return +} + +// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object +func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 24 { + return ssz.ErrSize + } + + // Field (0) 'StartSlot' + b.StartSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) + + // Field (1) 'Count' + b.Count = ssz.UnmarshallUint64(buf[8:16]) + + // Field (2) 'Step' + b.Step = ssz.UnmarshallUint64(buf[16:24]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object +func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) { + size = 24 + return +} + +// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object +func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) +} + +// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher +func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + + // Field (0) 'StartSlot' + hh.PutUint64(uint64(b.StartSlot)) + + // Field (1) 'Count' + hh.PutUint64(b.Count) + + // Field (2) 'Step' + hh.PutUint64(b.Step) + + hh.Merkleize(indx) + return +} + +// MarshalSSZ ssz marshals the ENRForkID object +func (e *ENRForkID) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(e) +} + +// MarshalSSZTo ssz marshals the ENRForkID object to a target array +func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'CurrentForkDigest' + if len(e.CurrentForkDigest) != 4 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, e.CurrentForkDigest...) + + // Field (1) 'NextForkVersion' + if len(e.NextForkVersion) != 4 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, e.NextForkVersion...) + + // Field (2) 'NextForkEpoch' + dst = ssz.MarshalUint64(dst, uint64(e.NextForkEpoch)) + + return +} + +// UnmarshalSSZ ssz unmarshals the ENRForkID object +func (e *ENRForkID) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + // Field (0) 'CurrentForkDigest' + if cap(e.CurrentForkDigest) == 0 { + e.CurrentForkDigest = make([]byte, 0, len(buf[0:4])) + } + e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...) + + // Field (1) 'NextForkVersion' + if cap(e.NextForkVersion) == 0 { + e.NextForkVersion = make([]byte, 0, len(buf[4:8])) + } + e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...) + + // Field (2) 'NextForkEpoch' + e.NextForkEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[8:16])) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object +func (e *ENRForkID) SizeSSZ() (size int) { + size = 16 + return +} + +// HashTreeRoot ssz hashes the ENRForkID object +func (e *ENRForkID) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(e) +} + +// HashTreeRootWith ssz hashes the ENRForkID object with a hasher +func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + + // Field (0) 'CurrentForkDigest' + if len(e.CurrentForkDigest) != 4 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(e.CurrentForkDigest) + + // Field (1) 'NextForkVersion' + if len(e.NextForkVersion) != 4 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(e.NextForkVersion) + + // Field (2) 'NextForkEpoch' + hh.PutUint64(uint64(e.NextForkEpoch)) + + hh.Merkleize(indx) + return +} + +// MarshalSSZ ssz marshals the MetaDataV0 object +func (m *MetaDataV0) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(m) +} + +// MarshalSSZTo ssz marshals the MetaDataV0 object to a target array +func (m *MetaDataV0) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'SeqNumber' + dst = ssz.MarshalUint64(dst, m.SeqNumber) + + // Field (1) 'Attnets' + if len(m.Attnets) != 8 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, m.Attnets...) + + return +} + +// UnmarshalSSZ ssz unmarshals the MetaDataV0 object +func (m *MetaDataV0) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + // Field (0) 'SeqNumber' + m.SeqNumber = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'Attnets' + if cap(m.Attnets) == 0 { + m.Attnets = make([]byte, 0, len(buf[8:16])) + } + m.Attnets = append(m.Attnets, buf[8:16]...) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV0 object +func (m *MetaDataV0) SizeSSZ() (size int) { + size = 16 + return +} + +// HashTreeRoot ssz hashes the MetaDataV0 object +func (m *MetaDataV0) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(m) +} + +// HashTreeRootWith ssz hashes the MetaDataV0 object with a hasher +func (m *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + + // Field (0) 'SeqNumber' + hh.PutUint64(m.SeqNumber) + + // Field (1) 'Attnets' + if len(m.Attnets) != 8 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(m.Attnets) + + hh.Merkleize(indx) + return +} + +// MarshalSSZ ssz marshals the MetaDataV1 object +func (m *MetaDataV1) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(m) +} + +// MarshalSSZTo ssz marshals the MetaDataV1 object to a target array +func (m *MetaDataV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'SeqNumber' + dst = ssz.MarshalUint64(dst, m.SeqNumber) + + // Field (1) 'Attnets' + if len(m.Attnets) != 8 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, m.Attnets...) + + // Field (2) 'Syncnets' + if len(m.Syncnets) != 64 { + err = ssz.ErrBytesLength + return + } + dst = append(dst, m.Syncnets...) + + return +} + +// UnmarshalSSZ ssz unmarshals the MetaDataV1 object +func (m *MetaDataV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 80 { + return ssz.ErrSize + } + + // Field (0) 'SeqNumber' + m.SeqNumber = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'Attnets' + if cap(m.Attnets) == 0 { + m.Attnets = make([]byte, 0, len(buf[8:16])) + } + m.Attnets = append(m.Attnets, buf[8:16]...) + + // Field (2) 'Syncnets' + if cap(m.Syncnets) == 0 { + m.Syncnets = make([]byte, 0, len(buf[16:80])) + } + m.Syncnets = append(m.Syncnets, buf[16:80]...) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV1 object +func (m *MetaDataV1) SizeSSZ() (size int) { + size = 80 + return +} + +// HashTreeRoot ssz hashes the MetaDataV1 object +func (m *MetaDataV1) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(m) +} + +// HashTreeRootWith ssz hashes the MetaDataV1 object with a hasher +func (m *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + + // Field (0) 'SeqNumber' + hh.PutUint64(m.SeqNumber) + + // Field (1) 'Attnets' + if len(m.Attnets) != 8 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(m.Attnets) + + // Field (2) 'Syncnets' + if len(m.Syncnets) != 64 { + err = ssz.ErrBytesLength + return + } + hh.PutBytes(m.Syncnets) + + hh.Merkleize(indx) + return +} + // MarshalSSZ ssz marshals the SyncCommitteeMessage object func (s *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(s) diff --git a/proto/beacon/p2p/v1/messages.pb.go b/proto/prysm/v2/p2p_messages.pb.go similarity index 99% rename from proto/beacon/p2p/v1/messages.pb.go rename to proto/prysm/v2/p2p_messages.pb.go index 35075d1434..ba11ff4b32 100755 --- a/proto/beacon/p2p/v1/messages.pb.go +++ b/proto/prysm/v2/p2p_messages.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.15.8 -// source: proto/beacon/p2p/v1/messages.proto +// source: proto/prysm/v2/messages.proto -package ethereum_beacon_p2p_v1 +package v2 import ( reflect "reflect" diff --git a/proto/beacon/p2p/v1/messages.proto b/proto/prysm/v2/p2p_messages.proto similarity index 83% rename from proto/beacon/p2p/v1/messages.proto rename to proto/prysm/v2/p2p_messages.proto index ee9fb29b50..b14ebbdf33 100644 --- a/proto/beacon/p2p/v1/messages.proto +++ b/proto/prysm/v2/p2p_messages.proto @@ -1,10 +1,17 @@ syntax = "proto3"; -package ethereum.beacon.p2p.v1; +package ethereum.prysm.v2; import "google/protobuf/descriptor.proto"; import "proto/eth/ext/options.proto"; +option csharp_namespace = "Ethereum.Prysm.V2"; +option go_package = "github.com/prysmaticlabs/prysm/proto/prysm/v2;v2"; +option java_multiple_files = true; +option java_outer_classname = "P2PMessagesProto"; +option java_package = "org.ethereum.prysm.v2"; +option php_namespace = "Ethereum\\Prysm\\v2"; + message Status { bytes fork_digest = 1 [(ethereum.eth.ext.ssz_size) = "4"]; bytes finalized_root = 2 [(ethereum.eth.ext.ssz_size) = "32"]; diff --git a/proto/prysm/v2/powchain.pb.go b/proto/prysm/v2/powchain.pb.go index 33b4342385..d85573210b 100755 --- a/proto/prysm/v2/powchain.pb.go +++ b/proto/prysm/v2/powchain.pb.go @@ -11,8 +11,8 @@ import ( sync "sync" proto "github.com/golang/protobuf/proto" - v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + state2 "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) @@ -35,7 +35,7 @@ type ETH1ChainData struct { CurrentEth1Data *LatestETH1Data `protobuf:"bytes,1,opt,name=current_eth1_data,json=currentEth1Data,proto3" json:"current_eth1_data,omitempty"` ChainstartData *ChainStartData `protobuf:"bytes,2,opt,name=chainstart_data,json=chainstartData,proto3" json:"chainstart_data,omitempty"` - BeaconState *v1.BeaconState `protobuf:"bytes,3,opt,name=beacon_state,json=beaconState,proto3" json:"beacon_state,omitempty"` + BeaconState *state2.BeaconState `protobuf:"bytes,3,opt,name=beacon_state,json=beaconState,proto3" json:"beacon_state,omitempty"` Trie *SparseMerkleTrie `protobuf:"bytes,4,opt,name=trie,proto3" json:"trie,omitempty"` DepositContainers []*DepositContainer `protobuf:"bytes,5,rep,name=deposit_containers,json=depositContainers,proto3" json:"deposit_containers,omitempty"` } @@ -86,7 +86,7 @@ func (x *ETH1ChainData) GetChainstartData() *ChainStartData { return nil } -func (x *ETH1ChainData) GetBeaconState() *v1.BeaconState { +func (x *ETH1ChainData) GetBeaconState() *state2.BeaconState { if x != nil { return x.BeaconState } @@ -541,15 +541,15 @@ func file_proto_beacon_db_powchain_proto_rawDescGZIP() []byte { var file_proto_beacon_db_powchain_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_proto_beacon_db_powchain_proto_goTypes = []interface{}{ - (*ETH1ChainData)(nil), // 0: prysm.beacon.db.ETH1ChainData - (*LatestETH1Data)(nil), // 1: prysm.beacon.db.LatestETH1Data - (*ChainStartData)(nil), // 2: prysm.beacon.db.ChainStartData - (*SparseMerkleTrie)(nil), // 3: prysm.beacon.db.SparseMerkleTrie - (*TrieLayer)(nil), // 4: prysm.beacon.db.TrieLayer - (*DepositContainer)(nil), // 5: prysm.beacon.db.DepositContainer - (*v1.BeaconState)(nil), // 6: ethereum.beacon.p2p.v1.BeaconState - (*v1alpha1.Eth1Data)(nil), // 7: ethereum.eth.v1alpha1.Eth1Data - (*v1alpha1.Deposit)(nil), // 8: ethereum.eth.v1alpha1.Deposit + (*ETH1ChainData)(nil), // 0: prysm.beacon.db.ETH1ChainData + (*LatestETH1Data)(nil), // 1: prysm.beacon.db.LatestETH1Data + (*ChainStartData)(nil), // 2: prysm.beacon.db.ChainStartData + (*SparseMerkleTrie)(nil), // 3: prysm.beacon.db.SparseMerkleTrie + (*TrieLayer)(nil), // 4: prysm.beacon.db.TrieLayer + (*DepositContainer)(nil), // 5: prysm.beacon.db.DepositContainer + (*state2.BeaconState)(nil), // 6: ethereum.beacon.p2p.v1.BeaconState + (*v1alpha1.Eth1Data)(nil), // 7: ethereum.eth.v1alpha1.Eth1Data + (*v1alpha1.Deposit)(nil), // 8: ethereum.eth.v1alpha1.Deposit } var file_proto_beacon_db_powchain_proto_depIdxs = []int32{ 1, // 0: prysm.beacon.db.ETH1ChainData.current_eth1_data:type_name -> prysm.beacon.db.LatestETH1Data diff --git a/proto/prysm/v2/powchain.proto b/proto/prysm/v2/powchain.proto index ce21294130..0d6601f66e 100644 --- a/proto/prysm/v2/powchain.proto +++ b/proto/prysm/v2/powchain.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package ethereum.prysm.v2; import "proto/prysm/v1alpha1/beacon_block.proto"; -import "proto/beacon/p2p/v1/types.proto"; +import "proto/prysm/v2/state/beacon_state.proto"; option csharp_namespace = "Ethereum.Prysm.V2"; option go_package = "github.com/prysmaticlabs/prysm/proto/prysm/v2;v2"; @@ -17,7 +17,7 @@ option php_namespace = "Ethereum\\Prysm\\v2"; message ETH1ChainData { LatestETH1Data current_eth1_data = 1 ; ChainStartData chainstart_data = 2; - ethereum.beacon.p2p.v1.BeaconState beacon_state = 3; + ethereum.prysm.v2.state.BeaconState beacon_state = 3; SparseMerkleTrie trie = 4; repeated DepositContainer deposit_containers = 5; } diff --git a/proto/beacon/p2p/v1/BUILD.bazel b/proto/prysm/v2/state/BUILD.bazel similarity index 91% rename from proto/beacon/p2p/v1/BUILD.bazel rename to proto/prysm/v2/state/BUILD.bazel index c75f5bba6b..ee020be968 100644 --- a/proto/beacon/p2p/v1/BUILD.bazel +++ b/proto/prysm/v2/state/BUILD.bazel @@ -9,7 +9,7 @@ load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") go_proto_library( name = "v1_go_proto", compiler = "@prysm//:cast_proto_compiler", - importpath = "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1", + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v2/state", proto = ":v1_proto", visibility = ["//visibility:public"], deps = [ @@ -34,11 +34,7 @@ ssz_gen_marshal( "//proto/prysm/v1alpha1:go_default_library", ], objs = [ - "BeaconBlocksByRangeRequest", "DepositMessage", - "ENRForkID", - "MetaDataV0", - "MetaDataV1", "Fork", "ForkData", "HistoricalBatch", @@ -62,8 +58,7 @@ go_library( ssz_proto_files( name = "ssz_proto_files", srcs = [ - "messages.proto", - "types.proto", + "beacon_state.proto", ], config = select({ "//conditions:default": "mainnet", @@ -82,4 +77,4 @@ proto_library( "@com_google_protobuf//:descriptor_proto", "@com_google_protobuf//:timestamp_proto", ], -) +) \ No newline at end of file diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/prysm/v2/state/beacon_state.pb.go similarity index 99% rename from proto/beacon/p2p/v1/types.pb.go rename to proto/prysm/v2/state/beacon_state.pb.go index 6a4d6ebd85..db48614735 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/prysm/v2/state/beacon_state.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.15.8 -// source: proto/beacon/p2p/v1/types.proto +// source: proto/prysm/v2/types.proto -package ethereum_beacon_p2p_v1 +package state import ( reflect "reflect" diff --git a/proto/beacon/p2p/v1/types.proto b/proto/prysm/v2/state/beacon_state.proto similarity index 95% rename from proto/beacon/p2p/v1/types.proto rename to proto/prysm/v2/state/beacon_state.proto index b7f594e4f3..41eadc94e6 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/prysm/v2/state/beacon_state.proto @@ -1,11 +1,19 @@ syntax = "proto3"; -package ethereum.beacon.p2p.v1; + +package ethereum.prysm.v2.state; import "proto/prysm/v1alpha1/attestation.proto"; import "proto/prysm/v1alpha1/beacon_block.proto"; import "proto/prysm/v1alpha1/validator.proto"; import "proto/eth/ext/options.proto"; +option csharp_namespace = "Ethereum.Prysm.V2.State"; +option go_package = "github.com/prysmaticlabs/prysm/proto/prysm/v2/state;state"; +option java_multiple_files = true; +option java_outer_classname = "BeaconStateProto"; +option java_package = "org.ethereum.prysm.v2.state"; +option php_namespace = "Ethereum\\Prysm\\v2\\state"; + message BeaconState { // Versioning [1001-2000] uint64 genesis_time = 1001; diff --git a/proto/beacon/p2p/v1/generated.ssz.go b/proto/prysm/v2/state/generated.ssz.go old mode 100644 new mode 100755 similarity index 84% rename from proto/beacon/p2p/v1/generated.ssz.go rename to proto/prysm/v2/state/generated.ssz.go index 6e6c5dff2f..b89ae67b8f --- a/proto/beacon/p2p/v1/generated.ssz.go +++ b/proto/prysm/v2/state/generated.ssz.go @@ -1,6 +1,6 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: a3ac01ceb824ec218bdaaf4c91efd60c4dd39845bb89200edcfb95f78803bacf -package ethereum_beacon_p2p_v1 +// Hash: b1c3ec79fcce79156b526c7a6b555cb3c414178c4de15d0894255f03ebe4dc25 +package state import ( ssz "github.com/ferranbt/fastssz" @@ -8,448 +8,6 @@ import ( v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ) -// MarshalSSZ ssz marshals the Status object -func (s *Status) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the Status object to a target array -func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'ForkDigest' - if len(s.ForkDigest) != 4 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, s.ForkDigest...) - - // Field (1) 'FinalizedRoot' - if len(s.FinalizedRoot) != 32 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, s.FinalizedRoot...) - - // Field (2) 'FinalizedEpoch' - dst = ssz.MarshalUint64(dst, uint64(s.FinalizedEpoch)) - - // Field (3) 'HeadRoot' - if len(s.HeadRoot) != 32 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, s.HeadRoot...) - - // Field (4) 'HeadSlot' - dst = ssz.MarshalUint64(dst, uint64(s.HeadSlot)) - - return -} - -// UnmarshalSSZ ssz unmarshals the Status object -func (s *Status) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 84 { - return ssz.ErrSize - } - - // Field (0) 'ForkDigest' - if cap(s.ForkDigest) == 0 { - s.ForkDigest = make([]byte, 0, len(buf[0:4])) - } - s.ForkDigest = append(s.ForkDigest, buf[0:4]...) - - // Field (1) 'FinalizedRoot' - if cap(s.FinalizedRoot) == 0 { - s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) - } - s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) - - // Field (2) 'FinalizedEpoch' - s.FinalizedEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[36:44])) - - // Field (3) 'HeadRoot' - if cap(s.HeadRoot) == 0 { - s.HeadRoot = make([]byte, 0, len(buf[44:76])) - } - s.HeadRoot = append(s.HeadRoot, buf[44:76]...) - - // Field (4) 'HeadSlot' - s.HeadSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[76:84])) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Status object -func (s *Status) SizeSSZ() (size int) { - size = 84 - return -} - -// HashTreeRoot ssz hashes the Status object -func (s *Status) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the Status object with a hasher -func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ForkDigest' - if len(s.ForkDigest) != 4 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(s.ForkDigest) - - // Field (1) 'FinalizedRoot' - if len(s.FinalizedRoot) != 32 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(s.FinalizedRoot) - - // Field (2) 'FinalizedEpoch' - hh.PutUint64(uint64(s.FinalizedEpoch)) - - // Field (3) 'HeadRoot' - if len(s.HeadRoot) != 32 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(s.HeadRoot) - - // Field (4) 'HeadSlot' - hh.PutUint64(uint64(s.HeadSlot)) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array -func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'StartSlot' - dst = ssz.MarshalUint64(dst, uint64(b.StartSlot)) - - // Field (1) 'Count' - dst = ssz.MarshalUint64(dst, b.Count) - - // Field (2) 'Step' - dst = ssz.MarshalUint64(dst, b.Step) - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 24 { - return ssz.ErrSize - } - - // Field (0) 'StartSlot' - b.StartSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) - - // Field (1) 'Count' - b.Count = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'Step' - b.Step = ssz.UnmarshallUint64(buf[16:24]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) { - size = 24 - return -} - -// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher -func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'StartSlot' - hh.PutUint64(uint64(b.StartSlot)) - - // Field (1) 'Count' - hh.PutUint64(b.Count) - - // Field (2) 'Step' - hh.PutUint64(b.Step) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ENRForkID object -func (e *ENRForkID) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ENRForkID object to a target array -func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'CurrentForkDigest' - if len(e.CurrentForkDigest) != 4 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, e.CurrentForkDigest...) - - // Field (1) 'NextForkVersion' - if len(e.NextForkVersion) != 4 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, e.NextForkVersion...) - - // Field (2) 'NextForkEpoch' - dst = ssz.MarshalUint64(dst, uint64(e.NextForkEpoch)) - - return -} - -// UnmarshalSSZ ssz unmarshals the ENRForkID object -func (e *ENRForkID) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 16 { - return ssz.ErrSize - } - - // Field (0) 'CurrentForkDigest' - if cap(e.CurrentForkDigest) == 0 { - e.CurrentForkDigest = make([]byte, 0, len(buf[0:4])) - } - e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...) - - // Field (1) 'NextForkVersion' - if cap(e.NextForkVersion) == 0 { - e.NextForkVersion = make([]byte, 0, len(buf[4:8])) - } - e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...) - - // Field (2) 'NextForkEpoch' - e.NextForkEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[8:16])) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object -func (e *ENRForkID) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the ENRForkID object -func (e *ENRForkID) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ENRForkID object with a hasher -func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'CurrentForkDigest' - if len(e.CurrentForkDigest) != 4 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(e.CurrentForkDigest) - - // Field (1) 'NextForkVersion' - if len(e.NextForkVersion) != 4 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(e.NextForkVersion) - - // Field (2) 'NextForkEpoch' - hh.PutUint64(uint64(e.NextForkEpoch)) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the MetaDataV0 object -func (m *MetaDataV0) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(m) -} - -// MarshalSSZTo ssz marshals the MetaDataV0 object to a target array -func (m *MetaDataV0) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SeqNumber' - dst = ssz.MarshalUint64(dst, m.SeqNumber) - - // Field (1) 'Attnets' - if len(m.Attnets) != 8 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, m.Attnets...) - - return -} - -// UnmarshalSSZ ssz unmarshals the MetaDataV0 object -func (m *MetaDataV0) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 16 { - return ssz.ErrSize - } - - // Field (0) 'SeqNumber' - m.SeqNumber = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'Attnets' - if cap(m.Attnets) == 0 { - m.Attnets = make([]byte, 0, len(buf[8:16])) - } - m.Attnets = append(m.Attnets, buf[8:16]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV0 object -func (m *MetaDataV0) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the MetaDataV0 object -func (m *MetaDataV0) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(m) -} - -// HashTreeRootWith ssz hashes the MetaDataV0 object with a hasher -func (m *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'SeqNumber' - hh.PutUint64(m.SeqNumber) - - // Field (1) 'Attnets' - if len(m.Attnets) != 8 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(m.Attnets) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the MetaDataV1 object -func (m *MetaDataV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(m) -} - -// MarshalSSZTo ssz marshals the MetaDataV1 object to a target array -func (m *MetaDataV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SeqNumber' - dst = ssz.MarshalUint64(dst, m.SeqNumber) - - // Field (1) 'Attnets' - if len(m.Attnets) != 8 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, m.Attnets...) - - // Field (2) 'Syncnets' - if len(m.Syncnets) != 64 { - err = ssz.ErrBytesLength - return - } - dst = append(dst, m.Syncnets...) - - return -} - -// UnmarshalSSZ ssz unmarshals the MetaDataV1 object -func (m *MetaDataV1) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 80 { - return ssz.ErrSize - } - - // Field (0) 'SeqNumber' - m.SeqNumber = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'Attnets' - if cap(m.Attnets) == 0 { - m.Attnets = make([]byte, 0, len(buf[8:16])) - } - m.Attnets = append(m.Attnets, buf[8:16]...) - - // Field (2) 'Syncnets' - if cap(m.Syncnets) == 0 { - m.Syncnets = make([]byte, 0, len(buf[16:80])) - } - m.Syncnets = append(m.Syncnets, buf[16:80]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV1 object -func (m *MetaDataV1) SizeSSZ() (size int) { - size = 80 - return -} - -// HashTreeRoot ssz hashes the MetaDataV1 object -func (m *MetaDataV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(m) -} - -// HashTreeRootWith ssz hashes the MetaDataV1 object with a hasher -func (m *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'SeqNumber' - hh.PutUint64(m.SeqNumber) - - // Field (1) 'Attnets' - if len(m.Attnets) != 8 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(m.Attnets) - - // Field (2) 'Syncnets' - if len(m.Syncnets) != 64 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(m.Syncnets) - - hh.Merkleize(indx) - return -} - // MarshalSSZ ssz marshals the BeaconState object func (b *BeaconState) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(b) diff --git a/proto/prysm/v2/wrapper/BUILD.bazel b/proto/prysm/v2/wrapper/BUILD.bazel index 67cc75c7be..a463e32498 100644 --- a/proto/prysm/v2/wrapper/BUILD.bazel +++ b/proto/prysm/v2/wrapper/BUILD.bazel @@ -2,7 +2,10 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["beacon_block.go"], + srcs = [ + "beacon_block.go", + "metadata.go", + ], importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper", visibility = ["//visibility:public"], deps = [ @@ -13,6 +16,7 @@ go_library( "//shared/version:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", + "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/proto/beacon/p2p/v1/wrapper/metadata.go b/proto/prysm/v2/wrapper/metadata.go similarity index 96% rename from proto/beacon/p2p/v1/wrapper/metadata.go rename to proto/prysm/v2/wrapper/metadata.go index 55480f0a89..9cda69b20f 100644 --- a/proto/beacon/p2p/v1/wrapper/metadata.go +++ b/proto/prysm/v2/wrapper/metadata.go @@ -2,8 +2,8 @@ package wrapper import ( "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/proto/beacon/p2p" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + p2p "github.com/prysmaticlabs/prysm/proto/interfaces" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "google.golang.org/protobuf/proto" ) diff --git a/proto/testing/BUILD.bazel b/proto/testing/BUILD.bazel index 57e54401af..68c8960296 100644 --- a/proto/testing/BUILD.bazel +++ b/proto/testing/BUILD.bazel @@ -10,8 +10,8 @@ proto_library( srcs = ["test.proto"], visibility = ["//visibility:public"], deps = [ - "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:descriptor_proto", + "@com_google_protobuf//:timestamp_proto", ], ) @@ -26,9 +26,9 @@ go_proto_library( "@io_bazel_rules_go//proto/wkt:timestamp_go_proto", "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", "@org_golang_google_protobuf//runtime/protoimpl:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", "@org_golang_google_protobuf//types/descriptorpb:go_default_library", - ] + "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", + ], ) go_library( @@ -52,18 +52,17 @@ go_test( embed = [":go_default_library"], tags = ["spectest"], deps = [ - "//beacon-chain/state/v1:go_default_library", "//beacon-chain/state/stateutil:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//beacon-chain/state/v1:go_default_library", + "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", "//shared/bytesutil:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", - "@com_github_golang_snappy//:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_ghodss_yaml//:go_default_library", - "//proto/prysm/v1alpha1:go_default_library", + "@com_github_golang_snappy//:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) diff --git a/shared/benchutil/BUILD.bazel b/shared/benchutil/BUILD.bazel index 44a7832cc7..a7486643fc 100644 --- a/shared/benchutil/BUILD.bazel +++ b/shared/benchutil/BUILD.bazel @@ -9,8 +9,8 @@ go_library( deps = [ "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], diff --git a/shared/benchutil/pregen.go b/shared/benchutil/pregen.go index 293e9705c5..66a74071ad 100644 --- a/shared/benchutil/pregen.go +++ b/shared/benchutil/pregen.go @@ -9,8 +9,8 @@ import ( "github.com/bazelbuild/rules_go/go/tools/bazel" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -50,7 +50,7 @@ func PreGenState1Epoch() (iface.BeaconState, error) { if err != nil { return nil, err } - beaconState := &pb.BeaconState{} + beaconState := &statepb.BeaconState{} if err := beaconState.UnmarshalSSZ(beaconBytes); err != nil { return nil, err } @@ -67,7 +67,7 @@ func PreGenState2FullEpochs() (iface.BeaconState, error) { if err != nil { return nil, err } - beaconState := &pb.BeaconState{} + beaconState := &statepb.BeaconState{} if err := beaconState.UnmarshalSSZ(beaconBytes); err != nil { return nil, err } diff --git a/shared/copyutil/BUILD.bazel b/shared/copyutil/BUILD.bazel index e9c13f5bc8..42d9a21606 100644 --- a/shared/copyutil/BUILD.bazel +++ b/shared/copyutil/BUILD.bazel @@ -6,9 +6,9 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/shared/copyutil", visibility = ["//visibility:public"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", ], ) @@ -18,9 +18,9 @@ go_test( srcs = ["cloners_test.go"], embed = [":go_default_library"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil/assert:go_default_library", ], ) diff --git a/shared/copyutil/cloners.go b/shared/copyutil/cloners.go index ed78f7dfb4..5accd67fc9 100644 --- a/shared/copyutil/cloners.go +++ b/shared/copyutil/cloners.go @@ -1,9 +1,9 @@ package copyutil import ( - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" ) @@ -20,12 +20,12 @@ func CopyETH1Data(data *ethpb.Eth1Data) *ethpb.Eth1Data { } // CopyPendingAttestation copies the provided pending attestation object. -func CopyPendingAttestation(att *pbp2p.PendingAttestation) *pbp2p.PendingAttestation { +func CopyPendingAttestation(att *state.PendingAttestation) *state.PendingAttestation { if att == nil { return nil } data := CopyAttestationData(att.Data) - return &pbp2p.PendingAttestation{ + return &state.PendingAttestation{ AggregationBits: bytesutil.SafeCopyBytes(att.AggregationBits), Data: data, InclusionDelay: att.InclusionDelay, diff --git a/shared/copyutil/cloners_test.go b/shared/copyutil/cloners_test.go index 438a90d963..9f223ba1cf 100644 --- a/shared/copyutil/cloners_test.go +++ b/shared/copyutil/cloners_test.go @@ -5,9 +5,9 @@ import ( "reflect" "testing" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) @@ -335,8 +335,8 @@ func genEth1Data() *ethpb.Eth1Data { } } -func genPendingAttestation() *pbp2p.PendingAttestation { - return &pbp2p.PendingAttestation{ +func genPendingAttestation() *state.PendingAttestation { + return &state.PendingAttestation{ AggregationBits: bytes(), Data: genAttData(), InclusionDelay: 3, diff --git a/shared/depositutil/BUILD.bazel b/shared/depositutil/BUILD.bazel index 889ecd3fe5..72f6890aa6 100644 --- a/shared/depositutil/BUILD.bazel +++ b/shared/depositutil/BUILD.bazel @@ -7,8 +7,8 @@ go_library( visibility = ["//visibility:public"], deps = [ "//beacon-chain/core/helpers:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/copyutil:go_default_library", "//shared/featureconfig:go_default_library", @@ -24,7 +24,7 @@ go_test( deps = [ ":go_default_library", "//beacon-chain/core/helpers:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/shared/depositutil/deposit.go b/shared/depositutil/deposit.go index 650d41295a..b0a0d4aea5 100644 --- a/shared/depositutil/deposit.go +++ b/shared/depositutil/deposit.go @@ -5,8 +5,8 @@ package depositutil import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -29,7 +29,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 := &p2ppb.DepositMessage{ + depositMessage := &statepb.DepositMessage{ PublicKey: depositKey.PublicKey().Marshal(), WithdrawalCredentials: WithdrawalCredentialsHash(withdrawalKey), Amount: amountInGwei, @@ -48,7 +48,7 @@ func DepositInput(depositKey, withdrawalKey bls.SecretKey, amountInGwei uint64) if err != nil { return nil, [32]byte{}, err } - root, err := (&p2ppb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, [32]byte{}, err } @@ -93,7 +93,7 @@ func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error { if err != nil { return errors.Wrap(err, "could not convert bytes to signature") } - di := &p2ppb.DepositMessage{ + di := &statepb.DepositMessage{ PublicKey: ddCopy.PublicKey, WithdrawalCredentials: ddCopy.WithdrawalCredentials, Amount: ddCopy.Amount, @@ -102,7 +102,7 @@ func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error { if err != nil { return errors.Wrap(err, "could not get signing root") } - signingData := &p2ppb.SigningData{ + signingData := &statepb.SigningData{ ObjectRoot: root[:], Domain: domain, } diff --git a/shared/depositutil/deposit_test.go b/shared/depositutil/deposit_test.go index 85e14ea4d6..39a6973561 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.DepositMessage{ + testData := &statepb.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 := (&pb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() require.NoError(t, err) assert.Equal(t, true, sig.Verify(k1.PublicKey(), root[:])) } diff --git a/shared/htrutils/BUILD.bazel b/shared/htrutils/BUILD.bazel index 42a25279be..a1916177d6 100644 --- a/shared/htrutils/BUILD.bazel +++ b/shared/htrutils/BUILD.bazel @@ -11,8 +11,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/shared/htrutils", visibility = ["//visibility:public"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", "//shared/params:go_default_library", @@ -34,8 +34,8 @@ go_test( ], deps = [ ":go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/hashutil:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/shared/htrutils/htrutils.go b/shared/htrutils/htrutils.go index dd272e8ebf..b390a259c1 100644 --- a/shared/htrutils/htrutils.go +++ b/shared/htrutils/htrutils.go @@ -6,8 +6,8 @@ import ( "encoding/binary" "github.com/pkg/errors" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -26,7 +26,7 @@ func Uint64Root(val uint64) [32]byte { // ForkRoot computes the HashTreeRoot Merkleization of // a Fork struct value according to the Ethereum // Simple Serialize specification. -func ForkRoot(fork *pb.Fork) ([32]byte, error) { +func ForkRoot(fork *statepb.Fork) ([32]byte, error) { fieldRoots := make([][]byte, 3) if fork != nil { prevRoot := bytesutil.ToBytes32(fork.PreviousVersion) diff --git a/shared/htrutils/htrutils_test.go b/shared/htrutils/htrutils_test.go index fc5f6fb480..bb44ee2aaf 100644 --- a/shared/htrutils/htrutils_test.go +++ b/shared/htrutils/htrutils_test.go @@ -3,8 +3,8 @@ package htrutils_test import ( "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/htrutils" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -20,7 +20,7 @@ func TestUint64Root(t *testing.T) { } func TestForkRoot(t *testing.T) { - testFork := pb.Fork{ + testFork := statepb.Fork{ PreviousVersion: []byte{123}, CurrentVersion: []byte{124}, Epoch: 1234567890, diff --git a/shared/interop/BUILD.bazel b/shared/interop/BUILD.bazel index c10b8f5e88..394b2d092c 100644 --- a/shared/interop/BUILD.bazel +++ b/shared/interop/BUILD.bazel @@ -12,8 +12,8 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/hashutil:go_default_library", "//shared/mputil:go_default_library", diff --git a/shared/interop/generate_genesis_state.go b/shared/interop/generate_genesis_state.go index 1e9f57a08b..85a9e4bda1 100644 --- a/shared/interop/generate_genesis_state.go +++ b/shared/interop/generate_genesis_state.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/mputil" @@ -28,7 +28,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) (*pb.BeaconState, []*ethpb.Deposit, error) { +func GenerateGenesisState(ctx context.Context, genesisTime, numValidators uint64) (*statepb.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 +44,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, -) (*pb.BeaconState, []*ethpb.Deposit, error) { +) (*statepb.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 +154,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 := &pb.DepositMessage{ + depositMessage := &statepb.DepositMessage{ PublicKey: pubKey.Marshal(), WithdrawalCredentials: withdrawalCredentialsHash(pubKey.Marshal()), Amount: params.BeaconConfig().MaxEffectiveBalance, @@ -167,7 +167,7 @@ func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Depo if err != nil { return nil, err } - root, err := (&pb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() + root, err := (&statepb.SigningData{ObjectRoot: sr[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, err } diff --git a/shared/p2putils/BUILD.bazel b/shared/p2putils/BUILD.bazel index d8ebe08366..87a9d5cfbc 100644 --- a/shared/p2putils/BUILD.bazel +++ b/shared/p2putils/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//beacon-chain/core/helpers:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/params:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/shared/p2putils/fork.go b/shared/p2putils/fork.go index bc66bfba5f..ede7dc16bb 100644 --- a/shared/p2putils/fork.go +++ b/shared/p2putils/fork.go @@ -7,7 +7,7 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -43,7 +43,7 @@ func CreateForkDigest( // returns the active fork version during this epoch. func Fork( targetEpoch types.Epoch, -) (*pb.Fork, error) { +) (*statepb.Fork, error) { // We retrieve a list of scheduled forks by epoch. // We loop through the keys in this map to determine the current // fork version based on the requested epoch. @@ -58,7 +58,7 @@ func Fork( forkEpoch = epoch } } - return &pb.Fork{ + return &statepb.Fork{ PreviousVersion: previousForkVersion, CurrentVersion: retrievedForkVersion, Epoch: forkEpoch, diff --git a/shared/sszutil/BUILD.bazel b/shared/sszutil/BUILD.bazel index ef5e5c71e6..f03f324589 100644 --- a/shared/sszutil/BUILD.bazel +++ b/shared/sszutil/BUILD.bazel @@ -17,8 +17,8 @@ go_test( srcs = ["deep_equal_test.go"], deps = [ ":go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil/assert:go_default_library", ], ) diff --git a/shared/sszutil/deep_equal_test.go b/shared/sszutil/deep_equal_test.go index 5f3cbdb4b9..a428bd260b 100644 --- a/shared/sszutil/deep_equal_test.go +++ b/shared/sszutil/deep_equal_test.go @@ -3,8 +3,8 @@ package sszutil_test import ( "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" ) @@ -60,15 +60,15 @@ func TestDeepEqualStructs_Unexported(t *testing.T) { } func TestDeepEqualProto(t *testing.T) { - var fork1, fork2 *pb.Fork + var fork1, fork2 *statepb.Fork assert.Equal(t, true, sszutil.DeepEqual(fork1, fork2)) - fork1 = &pb.Fork{ + fork1 = &statepb.Fork{ PreviousVersion: []byte{123}, CurrentVersion: []byte{124}, Epoch: 1234567890, } - fork2 = &pb.Fork{ + fork2 = &statepb.Fork{ PreviousVersion: []byte{123}, CurrentVersion: []byte{125}, Epoch: 1234567890, diff --git a/shared/testutil/BUILD.bazel b/shared/testutil/BUILD.bazel index 6d3b17d168..d8e729f497 100644 --- a/shared/testutil/BUILD.bazel +++ b/shared/testutil/BUILD.bazel @@ -19,11 +19,11 @@ go_library( "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", @@ -54,11 +54,11 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/state:go_default_library", "//beacon-chain/core/state/stateutils:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/shared/testutil/deposits.go b/shared/testutil/deposits.go index 1a4f351ece..00d8e12ee6 100644 --- a/shared/testutil/deposits.go +++ b/shared/testutil/deposits.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -165,7 +165,7 @@ func signedDeposit( ) (*ethpb.Deposit, error) { withdrawalCreds := hashutil.Hash(withdrawalKey) withdrawalCreds[0] = params.BeaconConfig().BLSWithdrawalPrefixByte - depositMessage := &pb.DepositMessage{ + depositMessage := &statepb.DepositMessage{ PublicKey: publicKey, Amount: balance, WithdrawalCredentials: withdrawalCreds[:], @@ -180,7 +180,7 @@ func signedDeposit( return nil, errors.Wrap(err, "could not get signing root of deposit data") } - sigRoot, err := (&pb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() + sigRoot, err := (&statepb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() if err != nil { return nil, err } @@ -329,7 +329,7 @@ func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Dep withdrawalCreds := hashutil.Hash(publicKeys[1].Marshal()) withdrawalCreds[0] = params.BeaconConfig().BLSWithdrawalPrefixByte - depositMessage := &pb.DepositMessage{ + depositMessage := &statepb.DepositMessage{ PublicKey: publicKeys[1].Marshal(), Amount: params.BeaconConfig().MaxEffectiveBalance, WithdrawalCredentials: withdrawalCreds[:], @@ -343,7 +343,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 := (&pb.SigningData{ObjectRoot: root[:], Domain: domain}).HashTreeRoot() + sigRoot, err := (&statepb.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 f1902cae80..2623a637f2 100644 --- a/shared/testutil/state.go +++ b/shared/testutil/state.go @@ -7,15 +7,15 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 *pb.BeaconState) error { +func FillRootsNaturalOpt(state *statepb.BeaconState) error { rootsLen := params.MainnetConfig().SlotsPerHistoricalRoot roots := make([][]byte, rootsLen) for i := types.Slot(0); i < rootsLen; i++ { @@ -36,8 +36,8 @@ func FillRootsNaturalOpt(state *pb.BeaconState) error { } // NewBeaconState creates a beacon state with minimum marshalable fields. -func NewBeaconState(options ...func(state *pb.BeaconState) error) (*v1.BeaconState, error) { - seed := &pb.BeaconState{ +func NewBeaconState(options ...func(state *statepb.BeaconState) error) (*v1.BeaconState, error) { + seed := &statepb.BeaconState{ BlockRoots: filledByteSlice2D(uint64(params.MainnetConfig().SlotsPerHistoricalRoot), 32), StateRoots: filledByteSlice2D(uint64(params.MainnetConfig().SlotsPerHistoricalRoot), 32), Slashings: make([]uint64, params.MainnetConfig().EpochsPerSlashingsVector), @@ -48,7 +48,7 @@ func NewBeaconState(options ...func(state *pb.BeaconState) error) (*v1.BeaconSta DepositRoot: make([]byte, 32), BlockHash: make([]byte, 32), }, - Fork: &pb.Fork{ + Fork: &statepb.Fork{ PreviousVersion: make([]byte, 4), CurrentVersion: make([]byte, 4), }, @@ -57,8 +57,8 @@ func NewBeaconState(options ...func(state *pb.BeaconState) error) (*v1.BeaconSta JustificationBits: bitfield.Bitvector4{0x0}, FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, LatestBlockHeader: HydrateBeaconHeader(ðpb.BeaconBlockHeader{}), - PreviousEpochAttestations: make([]*pb.PendingAttestation, 0), - CurrentEpochAttestations: make([]*pb.PendingAttestation, 0), + PreviousEpochAttestations: make([]*statepb.PendingAttestation, 0), + CurrentEpochAttestations: make([]*statepb.PendingAttestation, 0), PreviousJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, } diff --git a/shared/testutil/state_test.go b/shared/testutil/state_test.go index 892d82e798..54182d0013 100644 --- a/shared/testutil/state_test.go +++ b/shared/testutil/state_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{} + got := &statepb.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/spectest/shared/phase0/epoch_processing/BUILD.bazel b/spectest/shared/phase0/epoch_processing/BUILD.bazel index fc84d74fb9..676353c960 100644 --- a/spectest/shared/phase0/epoch_processing/BUILD.bazel +++ b/spectest/shared/phase0/epoch_processing/BUILD.bazel @@ -24,7 +24,7 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/epoch_processing/helpers.go b/spectest/shared/phase0/epoch_processing/helpers.go index 30eecb3596..4029811502 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" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{} + preBeaconStateBase := &statepb.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 := &pb.BeaconState{} + postBeaconState := &statepb.BeaconState{} if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } diff --git a/spectest/shared/phase0/finality/BUILD.bazel b/spectest/shared/phase0/finality/BUILD.bazel index 4463fe52ce..3c1d30b591 100644 --- a/spectest/shared/phase0/finality/BUILD.bazel +++ b/spectest/shared/phase0/finality/BUILD.bazel @@ -11,9 +11,9 @@ go_library( "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/finality/runner.go b/spectest/shared/phase0/finality/runner.go index 0464971438..9ba105eb1a 100644 --- a/spectest/shared/phase0/finality/runner.go +++ b/spectest/shared/phase0/finality/runner.go @@ -10,9 +10,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -40,7 +40,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 := &pb.BeaconState{} + beaconStateBase := &statepb.BeaconState{} require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") beaconState, err := v1.InitializeFromProto(beaconStateBase) require.NoError(t, err) @@ -71,7 +71,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 := &pb.BeaconState{} + postBeaconState := &statepb.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/BUILD.bazel b/spectest/shared/phase0/operations/BUILD.bazel index bbd6fe95d9..f7d2601d56 100644 --- a/spectest/shared/phase0/operations/BUILD.bazel +++ b/spectest/shared/phase0/operations/BUILD.bazel @@ -20,10 +20,10 @@ go_library( "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/operations/block_header.go b/spectest/shared/phase0/operations/block_header.go index c0512c38f0..81b99810ca 100644 --- a/spectest/shared/phase0/operations/block_header.go +++ b/spectest/shared/phase0/operations/block_header.go @@ -10,8 +10,8 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -36,7 +36,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 := &pb.BeaconState{} + preBeaconStateBase := &statepb.BeaconState{} require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") preBeaconState, err := v1.InitializeFromProto(preBeaconStateBase) require.NoError(t, err) @@ -62,7 +62,7 @@ func RunBlockHeaderTest(t *testing.T, config string) { postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &pb.BeaconState{} + postBeaconState := &statepb.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 8a1abeefa8..090dcc2634 100644 --- a/spectest/shared/phase0/operations/helpers.go +++ b/spectest/shared/phase0/operations/helpers.go @@ -12,10 +12,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -36,7 +36,7 @@ func RunBlockOperationTest( require.NoError(t, err) preBeaconStateSSZ, err := snappy.Decode(nil /* dst */, preBeaconStateFile) require.NoError(t, err, "Failed to decompress") - preStateBase := &pb.BeaconState{} + preStateBase := &statepb.BeaconState{} if err := preStateBase.UnmarshalSSZ(preBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } @@ -64,7 +64,7 @@ func RunBlockOperationTest( postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &pb.BeaconState{} + postBeaconState := &statepb.BeaconState{} if err := postBeaconState.UnmarshalSSZ(postBeaconStateSSZ); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } diff --git a/spectest/shared/phase0/rewards/BUILD.bazel b/spectest/shared/phase0/rewards/BUILD.bazel index f32c7221d3..ec631cd47b 100644 --- a/spectest/shared/phase0/rewards/BUILD.bazel +++ b/spectest/shared/phase0/rewards/BUILD.bazel @@ -10,7 +10,7 @@ go_library( "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/rewards/rewards_penalties.go b/spectest/shared/phase0/rewards/rewards_penalties.go index 41ca4776d4..2da7ae64ae 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{} + preBeaconStateBase := &statepb.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/BUILD.bazel b/spectest/shared/phase0/sanity/BUILD.bazel index 31576471e3..7e2d563e23 100644 --- a/spectest/shared/phase0/sanity/BUILD.bazel +++ b/spectest/shared/phase0/sanity/BUILD.bazel @@ -15,9 +15,9 @@ go_library( "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/sanity/block_processing.go b/spectest/shared/phase0/sanity/block_processing.go index d0b2743cd1..950746815f 100644 --- a/spectest/shared/phase0/sanity/block_processing.go +++ b/spectest/shared/phase0/sanity/block_processing.go @@ -14,9 +14,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -40,7 +40,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 := &pb.BeaconState{} + beaconStateBase := &statepb.BeaconState{} require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateSSZ), "Failed to unmarshal") beaconState, err := v1.InitializeFromProto(beaconStateBase) require.NoError(t, err) @@ -89,7 +89,7 @@ func RunBlockProcessingTest(t *testing.T, config string) { postBeaconStateSSZ, err := snappy.Decode(nil /* dst */, postBeaconStateFile) require.NoError(t, err, "Failed to decompress") - postBeaconState := &pb.BeaconState{} + postBeaconState := &statepb.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 9a82dc0e44..c5ca20bf7e 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" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "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 := &pb.BeaconState{} + base := &statepb.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 := &pb.BeaconState{} + postBeaconState := &statepb.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/BUILD.bazel b/spectest/shared/phase0/ssz_static/BUILD.bazel index 8d2daece21..3aaab206fc 100644 --- a/spectest/shared/phase0/ssz_static/BUILD.bazel +++ b/spectest/shared/phase0/ssz_static/BUILD.bazel @@ -8,8 +8,8 @@ go_library( visibility = ["//spectest:__subpackages__"], deps = [ "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", "//spectest/utils:go_default_library", diff --git a/spectest/shared/phase0/ssz_static/ssz_static.go b/spectest/shared/phase0/ssz_static/ssz_static.go index 298d841cf0..18d791fdd4 100644 --- a/spectest/shared/phase0/ssz_static/ssz_static.go +++ b/spectest/shared/phase0/ssz_static/ssz_static.go @@ -10,8 +10,8 @@ import ( fssz "github.com/ferranbt/fastssz" "github.com/golang/snappy" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -48,9 +48,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.(*pb.BeaconState); ok { + if _, ok := object.(*statepb.BeaconState); ok { htr = func(s interface{}) ([32]byte, error) { - beaconState, err := v1.InitializeFromProto(s.(*pb.BeaconState)) + beaconState, err := v1.InitializeFromProto(s.(*statepb.BeaconState)) require.NoError(t, err) return beaconState.HashTreeRoot(context.Background()) } @@ -109,13 +109,13 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i case "BeaconBlockHeader": obj = ðpb.BeaconBlockHeader{} case "BeaconState": - obj = &pb.BeaconState{} + obj = &statepb.BeaconState{} case "Checkpoint": obj = ðpb.Checkpoint{} case "Deposit": obj = ðpb.Deposit{} case "DepositMessage": - obj = &pb.DepositMessage{} + obj = &statepb.DepositMessage{} case "DepositData": obj = ðpb.Deposit_Data{} case "Eth1Data": @@ -124,15 +124,15 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i t.Skip("Unused type") return nil, nil case "Fork": - obj = &pb.Fork{} + obj = &statepb.Fork{} case "ForkData": - obj = &pb.ForkData{} + obj = &statepb.ForkData{} case "HistoricalBatch": - obj = &pb.HistoricalBatch{} + obj = &statepb.HistoricalBatch{} case "IndexedAttestation": obj = ðpb.IndexedAttestation{} case "PendingAttestation": - obj = &pb.PendingAttestation{} + obj = &statepb.PendingAttestation{} case "ProposerSlashing": obj = ðpb.ProposerSlashing{} case "SignedAggregateAndProof": @@ -144,7 +144,7 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i case "SignedVoluntaryExit": obj = ðpb.SignedVoluntaryExit{} case "SigningData": - obj = &pb.SigningData{} + obj = &statepb.SigningData{} case "Validator": obj = ðpb.Validator{} case "VoluntaryExit": diff --git a/tools/benchmark-files-gen/BUILD.bazel b/tools/benchmark-files-gen/BUILD.bazel index b92b8b6a90..117bcdd385 100644 --- a/tools/benchmark-files-gen/BUILD.bazel +++ b/tools/benchmark-files-gen/BUILD.bazel @@ -12,9 +12,9 @@ go_library( "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/interface:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/benchutil:go_default_library", "//shared/fileutil:go_default_library", "//shared/interop:go_default_library", diff --git a/tools/benchmark-files-gen/main.go b/tools/benchmark-files-gen/main.go index ea60fd8021..e6b5e5717b 100644 --- a/tools/benchmark-files-gen/main.go +++ b/tools/benchmark-files-gen/main.go @@ -14,9 +14,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/benchutil" "github.com/prysmaticlabs/prysm/shared/fileutil" "github.com/prysmaticlabs/prysm/shared/interop" @@ -211,7 +211,7 @@ func genesisBeaconState() (iface.BeaconState, error) { if err != nil { return nil, errors.Wrap(err, "cannot read genesis state file") } - genesisState := &pb.BeaconState{} + genesisState := &statepb.BeaconState{} if err := genesisState.UnmarshalSSZ(beaconBytes); err != nil { return nil, errors.Wrap(err, "cannot unmarshal genesis state file") } diff --git a/tools/bootnode/BUILD.bazel b/tools/bootnode/BUILD.bazel index 1e1b61b007..b8f452c541 100644 --- a/tools/bootnode/BUILD.bazel +++ b/tools/bootnode/BUILD.bazel @@ -11,7 +11,7 @@ go_library( visibility = ["//visibility:private"], deps = [ "//beacon-chain/core/helpers:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", + "//proto/prysm/v2:go_default_library", "//shared/bytesutil:go_default_library", "//shared/iputils:go_default_library", "//shared/logutil:go_default_library", diff --git a/tools/bootnode/bootnode.go b/tools/bootnode/bootnode.go index 66dfa0b78b..c2257868a8 100644 --- a/tools/bootnode/bootnode.go +++ b/tools/bootnode/bootnode.go @@ -33,7 +33,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/iputils" "github.com/prysmaticlabs/prysm/shared/logutil" diff --git a/tools/exploredb/BUILD.bazel b/tools/exploredb/BUILD.bazel index b226cf8b4b..e54437471e 100644 --- a/tools/exploredb/BUILD.bazel +++ b/tools/exploredb/BUILD.bazel @@ -9,8 +9,8 @@ go_library( deps = [ "//beacon-chain/db/kv:go_default_library", "//beacon-chain/state/interface:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "@com_github_dustin_go_humanize//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/tools/exploredb/main.go b/tools/exploredb/main.go index c450e12b23..dc6bc22ffe 100644 --- a/tools/exploredb/main.go +++ b/tools/exploredb/main.go @@ -20,8 +20,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/kv" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" - pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" log "github.com/sirupsen/logrus" "github.com/status-im/keycard-go/hexutils" @@ -421,7 +421,7 @@ func sizeAndCountGeneric(genericItems interface{}, err error) (uint64, uint64) { size += uint64(item.SizeSSZ()) } count = uint64(len(items)) - case []*pbp2p.PendingAttestation: + case []*statepb.PendingAttestation: for _, item := range items { size += uint64(item.SizeSSZ()) } diff --git a/tools/genesis-state-gen/BUILD.bazel b/tools/genesis-state-gen/BUILD.bazel index cd0e6d222f..205843c6e6 100644 --- a/tools/genesis-state-gen/BUILD.bazel +++ b/tools/genesis-state-gen/BUILD.bazel @@ -10,8 +10,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/tools/genesis-state-gen", visibility = ["//visibility:private"], deps = [ - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/fileutil:go_default_library", "//shared/interop:go_default_library", "//shared/params:go_default_library", diff --git a/tools/genesis-state-gen/main.go b/tools/genesis-state-gen/main.go index 4ea6c6d145..768b637f10 100644 --- a/tools/genesis-state-gen/main.go +++ b/tools/genesis-state-gen/main.go @@ -12,8 +12,8 @@ import ( "strings" "github.com/ghodss/yaml" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/fileutil" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" @@ -55,7 +55,7 @@ func main() { if !*useMainnetConfig { params.OverrideBeaconConfig(params.MinimalSpecConfig()) } - var genesisState *pb.BeaconState + var genesisState *statepb.BeaconState var err error if *depositJSONFile != "" { inputFile := *depositJSONFile @@ -131,7 +131,7 @@ func main() { } } -func genesisStateFromJSONValidators(r io.Reader, genesisTime uint64) (*pb.BeaconState, error) { +func genesisStateFromJSONValidators(r io.Reader, genesisTime uint64) (*statepb.BeaconState, error) { enc, err := ioutil.ReadAll(r) if err != nil { return nil, err diff --git a/tools/pcli/BUILD.bazel b/tools/pcli/BUILD.bazel index 96b05add4d..35a08a393c 100644 --- a/tools/pcli/BUILD.bazel +++ b/tools/pcli/BUILD.bazel @@ -12,9 +12,9 @@ go_library( deps = [ "//beacon-chain/core/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared/sszutil:go_default_library", "//shared/version:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", diff --git a/tools/pcli/main.go b/tools/pcli/main.go index b3ef233b4b..32bfc45be6 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -13,9 +13,9 @@ import ( "github.com/kr/pretty" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/version" log "github.com/sirupsen/logrus" @@ -82,7 +82,7 @@ func main() { case "deposit": data = ðpb.Deposit{} case "deposit_message": - data = &pb.DepositMessage{} + data = &statepb.DepositMessage{} case "proposer_slashing": data = ðpb.ProposerSlashing{} case "signed_block_header": @@ -92,7 +92,7 @@ func main() { case "voluntary_exit": data = ðpb.VoluntaryExit{} case "state": - data = &pb.BeaconState{} + data = &statepb.BeaconState{} default: log.Fatal("Invalid type") } @@ -156,7 +156,7 @@ func main() { } preStatePath = text } - preState := &pb.BeaconState{} + preState := &statepb.BeaconState{} if err := dataFetcher(preStatePath, preState); err != nil { log.Fatal(err) } @@ -188,7 +188,7 @@ func main() { // Diff the state if a post state is provided. if expectedPostStatePath != "" { - expectedState := &pb.BeaconState{} + expectedState := &statepb.BeaconState{} if err := dataFetcher(expectedPostStatePath, expectedState); err != nil { log.Fatal(err) } diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 61ead53f0a..94b91dd675 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -98,10 +98,10 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/core/helpers:go_default_library", - "//proto/beacon/p2p/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/state:go_default_library", "//shared:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/validator/client/attest_test.go b/validator/client/attest_test.go index 4b9a0a8ca2..380429cf8b 100644 --- a/validator/client/attest_test.go +++ b/validator/client/attest_test.go @@ -13,9 +13,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" @@ -448,7 +448,7 @@ func TestSignAttestation(t *testing.T) { secretKey, err := bls.SecretKeyFromBytes(bytesutil.PadTo([]byte{1}, 32)) require.NoError(t, err, "Failed to generate key from bytes") publicKey := secretKey.PublicKey() - wantedFork := &pb.Fork{ + wantedFork := &statepb.Fork{ PreviousVersion: []byte{'a', 'b', 'c', 'd'}, CurrentVersion: []byte{'d', 'e', 'f', 'f'}, Epoch: 0,