From 1d3a9983cc04893c3abca54096d2d1ae61fd170a Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 6 Jul 2021 08:34:05 -0700 Subject: [PATCH] Move block interface next to generated pb (#9146) * Move block interface next to pb * Update fuzz build bazel * Move interface to /proto/interface and wrapper next to generated pb * Fix fuzz build bazel * Add //proto/eth/v1alpha1/wrapper Co-authored-by: Raul Jordan Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/blockchain/BUILD.bazel | 4 +- beacon-chain/blockchain/chain_info.go | 2 +- .../blockchain/chain_info_norace_test.go | 4 +- beacon-chain/blockchain/chain_info_test.go | 8 +- beacon-chain/blockchain/head.go | 2 +- beacon-chain/blockchain/head_test.go | 12 +-- beacon-chain/blockchain/info_test.go | 4 +- .../blockchain/init_sync_process_block.go | 2 +- beacon-chain/blockchain/log.go | 2 +- beacon-chain/blockchain/log_test.go | 17 ++-- beacon-chain/blockchain/metrics.go | 2 +- .../blockchain/process_attestation_test.go | 20 ++--- beacon-chain/blockchain/process_block.go | 2 +- .../blockchain/process_block_helpers.go | 2 +- beacon-chain/blockchain/process_block_test.go | 77 +++++++++--------- .../blockchain/receive_attestation_test.go | 10 +-- beacon-chain/blockchain/receive_block.go | 2 +- beacon-chain/blockchain/receive_block_test.go | 11 +-- beacon-chain/blockchain/service.go | 2 +- beacon-chain/blockchain/service_test.go | 35 ++++---- beacon-chain/blockchain/testing/BUILD.bazel | 2 +- beacon-chain/blockchain/testing/mock.go | 2 +- .../weak_subjectivity_checks_test.go | 4 +- beacon-chain/core/blocks/BUILD.bazel | 4 +- beacon-chain/core/blocks/attestation.go | 2 +- beacon-chain/core/blocks/attestation_test.go | 20 ++--- .../core/blocks/block_operations_fuzz_test.go | 10 +-- beacon-chain/core/blocks/header.go | 2 +- beacon-chain/core/blocks/header_test.go | 14 ++-- beacon-chain/core/blocks/randao.go | 2 +- beacon-chain/core/blocks/randao_test.go | 6 +- beacon-chain/core/feed/block/BUILD.bazel | 2 +- beacon-chain/core/feed/block/events.go | 4 +- beacon-chain/core/feed/state/BUILD.bazel | 2 +- beacon-chain/core/feed/state/events.go | 2 +- beacon-chain/core/helpers/BUILD.bazel | 2 +- beacon-chain/core/helpers/block.go | 2 +- beacon-chain/core/state/BUILD.bazel | 4 +- beacon-chain/core/state/benchmarks_test.go | 8 +- beacon-chain/core/state/interop/BUILD.bazel | 2 +- .../core/state/interop/write_block_to_disk.go | 2 +- .../core/state/skip_slot_cache_test.go | 12 +-- beacon-chain/core/state/transition.go | 2 +- .../core/state/transition_fuzz_test.go | 16 ++-- .../core/state/transition_no_verify_sig.go | 2 +- .../state/transition_no_verify_sig_test.go | 12 +-- beacon-chain/core/state/transition_test.go | 30 +++---- beacon-chain/db/BUILD.bazel | 2 +- beacon-chain/db/iface/BUILD.bazel | 2 +- beacon-chain/db/iface/interface.go | 2 +- beacon-chain/db/kafka/BUILD.bazel | 2 +- beacon-chain/db/kafka/export_wrapper.go | 2 +- beacon-chain/db/kafka/passthrough.go | 2 +- beacon-chain/db/kv/BUILD.bazel | 6 +- beacon-chain/db/kv/backup_test.go | 6 +- beacon-chain/db/kv/blocks.go | 17 ++-- beacon-chain/db/kv/blocks_test.go | 59 +++++++------- beacon-chain/db/kv/checkpoint_test.go | 4 +- beacon-chain/db/kv/finalized_block_roots.go | 5 +- .../db/kv/finalized_block_roots_test.go | 7 +- beacon-chain/db/kv/genesis.go | 4 +- beacon-chain/db/kv/state.go | 4 +- beacon-chain/db/kv/state_test.go | 23 +++--- beacon-chain/db/restore_test.go | 4 +- beacon-chain/rpc/eth/v1/beacon/BUILD.bazel | 6 +- beacon-chain/rpc/eth/v1/beacon/blocks.go | 5 +- beacon-chain/rpc/eth/v1/beacon/blocks_test.go | 45 ++++++----- beacon-chain/rpc/eth/v1/events/BUILD.bazel | 2 +- beacon-chain/rpc/eth/v1/events/events_test.go | 4 +- .../rpc/prysm/v1alpha1/beacon/BUILD.bazel | 5 +- .../prysm/v1alpha1/beacon/assignments_test.go | 4 +- .../rpc/prysm/v1alpha1/beacon/attestations.go | 2 +- .../v1alpha1/beacon/attestations_test.go | 25 +++--- .../rpc/prysm/v1alpha1/beacon/blocks_test.go | 45 ++++++----- .../prysm/v1alpha1/beacon/committees_test.go | 8 +- .../prysm/v1alpha1/beacon/validators_test.go | 30 +++---- .../rpc/prysm/v1alpha1/debug/BUILD.bazel | 2 +- .../rpc/prysm/v1alpha1/debug/block_test.go | 6 +- .../rpc/prysm/v1alpha1/debug/state_test.go | 4 +- .../rpc/prysm/v1alpha1/validator/BUILD.bazel | 5 +- .../prysm/v1alpha1/validator/attester_test.go | 14 ++-- .../rpc/prysm/v1alpha1/validator/exit_test.go | 6 +- .../rpc/prysm/v1alpha1/validator/proposer.go | 9 ++- .../prysm/v1alpha1/validator/proposer_test.go | 16 ++-- .../prysm/v1alpha1/validator/server_test.go | 4 +- .../prysm/v1alpha1/validator/status_test.go | 14 ++-- beacon-chain/rpc/statefetcher/BUILD.bazel | 2 +- beacon-chain/rpc/statefetcher/fetcher_test.go | 14 ++-- beacon-chain/state/stategen/BUILD.bazel | 5 +- beacon-chain/state/stategen/getter_test.go | 44 +++++----- beacon-chain/state/stategen/migrate_test.go | 15 ++-- beacon-chain/state/stategen/mock.go | 2 +- beacon-chain/state/stategen/replay.go | 2 +- beacon-chain/state/stategen/replay_test.go | 33 ++++---- beacon-chain/state/stategen/service.go | 2 +- beacon-chain/state/stategen/service_test.go | 4 +- beacon-chain/state/stategen/setter_test.go | 6 +- beacon-chain/sync/BUILD.bazel | 4 + beacon-chain/sync/initial-sync/BUILD.bazel | 6 +- .../sync/initial-sync/blocks_fetcher.go | 2 +- .../sync/initial-sync/blocks_fetcher_test.go | 5 +- .../sync/initial-sync/blocks_fetcher_utils.go | 2 +- .../initial-sync/blocks_fetcher_utils_test.go | 18 ++--- .../sync/initial-sync/blocks_queue.go | 2 +- .../sync/initial-sync/blocks_queue_test.go | 23 +++--- beacon-chain/sync/initial-sync/fsm.go | 2 +- .../sync/initial-sync/initial_sync_test.go | 4 +- beacon-chain/sync/initial-sync/round_robin.go | 2 +- .../sync/initial-sync/round_robin_test.go | 27 ++++--- .../sync/initial-sync/service_test.go | 4 +- .../sync/pending_attestations_queue_test.go | 13 ++- beacon-chain/sync/pending_blocks_queue.go | 2 +- .../sync/pending_blocks_queue_test.go | 80 +++++++++---------- .../sync/rpc_beacon_blocks_by_range.go | 3 +- .../sync/rpc_beacon_blocks_by_range_test.go | 22 ++--- .../sync/rpc_beacon_blocks_by_root.go | 3 +- .../sync/rpc_beacon_blocks_by_root_test.go | 4 +- beacon-chain/sync/rpc_chunked_response.go | 7 +- beacon-chain/sync/rpc_send_request.go | 2 +- beacon-chain/sync/rpc_send_request_test.go | 7 +- beacon-chain/sync/rpc_status_test.go | 16 ++-- beacon-chain/sync/subscriber_beacon_blocks.go | 4 +- beacon-chain/sync/utils.go | 2 +- beacon-chain/sync/utils_test.go | 7 +- .../sync/validate_aggregate_proof_test.go | 12 +-- .../sync/validate_beacon_attestation_test.go | 4 +- beacon-chain/sync/validate_beacon_blocks.go | 5 +- .../sync/validate_beacon_blocks_test.go | 26 +++--- fuzz/BUILD.bazel | 3 +- fuzz/block_fuzz.go | 6 +- proto/eth/v1alpha1/wrapper/BUILD.bazel | 15 ++++ .../eth/v1alpha1/wrapper/beacon_block.go | 37 ++++----- proto/interfaces/BUILD.bazel | 13 +++ .../interfaces/block_interface.go | 0 proto/migration/BUILD.bazel | 4 +- proto/migration/migration.go | 2 +- proto/migration/migration_test.go | 6 +- shared/interfaces/BUILD.bazel | 5 -- shared/testutil/BUILD.bazel | 4 +- shared/testutil/block_test.go | 18 ++--- shared/testutil/helpers.go | 4 +- spectest/shared/phase0/finality/BUILD.bazel | 2 +- spectest/shared/phase0/finality/runner.go | 4 +- spectest/shared/phase0/operations/BUILD.bazel | 3 +- .../phase0/operations/attester_slashing.go | 2 +- spectest/shared/phase0/operations/deposit.go | 2 +- spectest/shared/phase0/operations/helpers.go | 5 +- .../phase0/operations/proposer_slashing.go | 2 +- .../phase0/operations/voluntary_exit.go | 2 +- spectest/shared/phase0/sanity/BUILD.bazel | 2 +- .../shared/phase0/sanity/block_processing.go | 4 +- tools/benchmark-files-gen/BUILD.bazel | 2 +- tools/benchmark-files-gen/main.go | 10 +-- tools/pcli/BUILD.bazel | 2 +- tools/pcli/main.go | 4 +- 155 files changed, 740 insertions(+), 676 deletions(-) create mode 100644 proto/eth/v1alpha1/wrapper/BUILD.bazel rename shared/interfaces/phase0_block_wrapper.go => proto/eth/v1alpha1/wrapper/beacon_block.go (79%) create mode 100644 proto/interfaces/BUILD.bazel rename {shared => proto}/interfaces/block_interface.go (100%) diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 6dfcb367bd..61b31ed853 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -46,12 +46,12 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/copyutil:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mputil:go_default_library", "//shared/params:go_default_library", "//shared/slotutil:go_default_library", @@ -110,6 +110,7 @@ go_test( "//proto/beacon/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", "//shared/params:go_default_library", @@ -159,6 +160,7 @@ go_test( "//beacon-chain/powchain:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper: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 b93d57abb3..ac8ca94f64 100644 --- a/beacon-chain/blockchain/chain_info.go +++ b/beacon-chain/blockchain/chain_info.go @@ -10,9 +10,9 @@ import ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) diff --git a/beacon-chain/blockchain/chain_info_norace_test.go b/beacon-chain/blockchain/chain_info_norace_test.go index 76daeefb20..72b168331a 100644 --- a/beacon-chain/blockchain/chain_info_norace_test.go +++ b/beacon-chain/blockchain/chain_info_norace_test.go @@ -7,7 +7,7 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -39,7 +39,7 @@ func TestHeadBlock_DataRace(t *testing.T) { beaconDB := testDB.SetupDB(t) s := &Service{ cfg: &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB)}, - head: &head{block: interfaces.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{})}, + head: &head{block: wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{})}, } go func() { require.NoError(t, s.saveHead(context.Background(), [32]byte{})) diff --git a/beacon-chain/blockchain/chain_info_test.go b/beacon-chain/blockchain/chain_info_test.go index 84b58aef2f..06f069a6b0 100644 --- a/beacon-chain/blockchain/chain_info_test.go +++ b/beacon-chain/blockchain/chain_info_test.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -126,7 +126,7 @@ func TestHeadRoot_UseDB(t *testing.T) { b := testutil.NewBeaconBlock() br, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + 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.SaveHeadBlockRoot(context.Background(), br)) r, err := c.HeadRoot(context.Background()) @@ -140,7 +140,7 @@ func TestHeadBlock_CanRetrieve(t *testing.T) { s, err := v1.InitializeFromProto(&pb.BeaconState{}) require.NoError(t, err) c := &Service{} - c.head = &head{block: interfaces.WrappedPhase0SignedBeaconBlock(b), state: s} + c.head = &head{block: wrapper.WrappedPhase0SignedBeaconBlock(b), state: s} recevied, err := c.HeadBlock(context.Background()) require.NoError(t, err) @@ -222,7 +222,7 @@ func TestIsCanonical_Ok(t *testing.T) { blk.Block.Slot = 0 root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, root)) can, err := c.IsCanonical(ctx, root) require.NoError(t, err) diff --git a/beacon-chain/blockchain/head.go b/beacon-chain/blockchain/head.go index 3cd67231a8..c9d8180902 100644 --- a/beacon-chain/blockchain/head.go +++ b/beacon-chain/blockchain/head.go @@ -13,8 +13,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" "github.com/sirupsen/logrus" diff --git a/beacon-chain/blockchain/head_test.go b/beacon-chain/blockchain/head_test.go index 58a3f1de50..8d7d1f0149 100644 --- a/beacon-chain/blockchain/head_test.go +++ b/beacon-chain/blockchain/head_test.go @@ -12,7 +12,7 @@ import ( pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -40,7 +40,7 @@ func TestSaveHead_Different(t *testing.T) { service.head = &head{ slot: 0, root: oldRoot, - block: interfaces.WrappedPhase0SignedBeaconBlock( + block: wrapper.WrappedPhase0SignedBeaconBlock( ðpb.SignedBeaconBlock{ Block: ðpb.BeaconBlock{ Slot: 0, @@ -54,7 +54,7 @@ func TestSaveHead_Different(t *testing.T) { newHeadSignedBlock.Block.Slot = 1 newHeadBlock := newHeadSignedBlock.Block - require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(newHeadSignedBlock))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(newHeadSignedBlock))) newRoot, err := newHeadBlock.HashTreeRoot() require.NoError(t, err) headState, err := testutil.NewBeaconState() @@ -83,7 +83,7 @@ func TestSaveHead_Different_Reorg(t *testing.T) { service.head = &head{ slot: 0, root: oldRoot, - block: interfaces.WrappedPhase0SignedBeaconBlock( + block: wrapper.WrappedPhase0SignedBeaconBlock( ðpb.SignedBeaconBlock{ Block: ðpb.BeaconBlock{ Slot: 0, @@ -99,7 +99,7 @@ func TestSaveHead_Different_Reorg(t *testing.T) { newHeadSignedBlock.Block.ParentRoot = reorgChainParent[:] newHeadBlock := newHeadSignedBlock.Block - require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(newHeadSignedBlock))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(newHeadSignedBlock))) newRoot, err := newHeadBlock.HashTreeRoot() require.NoError(t, err) headState, err := testutil.NewBeaconState() @@ -138,7 +138,7 @@ func TestUpdateHead_MissingJustifiedRoot(t *testing.T) { service := setupBeaconChain(t, beaconDB) b := testutil.NewBeaconBlock() - require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) diff --git a/beacon-chain/blockchain/info_test.go b/beacon-chain/blockchain/info_test.go index d478118d99..b1899a4684 100644 --- a/beacon-chain/blockchain/info_test.go +++ b/beacon-chain/blockchain/info_test.go @@ -9,7 +9,7 @@ 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" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -38,7 +38,7 @@ func TestService_TreeHandler(t *testing.T) { require.NoError(t, err) require.NoError(t, s.cfg.ForkChoiceStore.ProcessBlock(ctx, 0, [32]byte{'a'}, [32]byte{'g'}, [32]byte{'c'}, 0, 0)) require.NoError(t, s.cfg.ForkChoiceStore.ProcessBlock(ctx, 1, [32]byte{'b'}, [32]byte{'a'}, [32]byte{'c'}, 0, 0)) - s.setHead([32]byte{'a'}, interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), headState) + s.setHead([32]byte{'a'}, wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), headState) rr := httptest.NewRecorder() handler := http.HandlerFunc(s.TreeHandler) diff --git a/beacon-chain/blockchain/init_sync_process_block.go b/beacon-chain/blockchain/init_sync_process_block.go index 7963a7a9bd..c4a3aaa152 100644 --- a/beacon-chain/blockchain/init_sync_process_block.go +++ b/beacon-chain/blockchain/init_sync_process_block.go @@ -1,7 +1,7 @@ package blockchain import ( - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // This saves a beacon block to the initial sync blocks cache. diff --git a/beacon-chain/blockchain/log.go b/beacon-chain/blockchain/log.go index 2edc1a6f7d..ac13689713 100644 --- a/beacon-chain/blockchain/log.go +++ b/beacon-chain/blockchain/log.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/sirupsen/logrus" diff --git a/beacon-chain/blockchain/log_test.go b/beacon-chain/blockchain/log_test.go index 9bf800349d..1bd630cee2 100644 --- a/beacon-chain/blockchain/log_test.go +++ b/beacon-chain/blockchain/log_test.go @@ -4,7 +4,8 @@ import ( "testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil/require" logTest "github.com/sirupsen/logrus/hooks/test" ) @@ -16,37 +17,37 @@ func Test_logStateTransitionData(t *testing.T) { want string }{ {name: "empty block body", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}), + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}), want: "\"Finished applying state transition\" prefix=blockchain slot=0", }, {name: "has attestation", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{Attestations: []*ethpb.Attestation{{}}}}), + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{Attestations: []*ethpb.Attestation{{}}}}), want: "\"Finished applying state transition\" attestations=1 prefix=blockchain slot=0", }, {name: "has deposit", - b: interfaces.WrappedPhase0BeaconBlock( + b: wrapper.WrappedPhase0BeaconBlock( ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ Attestations: []*ethpb.Attestation{{}}, Deposits: []*ethpb.Deposit{{}}}}), want: "\"Finished applying state transition\" attestations=1 deposits=1 prefix=blockchain slot=0", }, {name: "has attester slashing", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ AttesterSlashings: []*ethpb.AttesterSlashing{{}}}}), want: "\"Finished applying state transition\" attesterSlashings=1 prefix=blockchain slot=0", }, {name: "has proposer slashing", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ ProposerSlashings: []*ethpb.ProposerSlashing{{}}}}), want: "\"Finished applying state transition\" prefix=blockchain proposerSlashings=1 slot=0", }, {name: "has exit", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ VoluntaryExits: []*ethpb.SignedVoluntaryExit{{}}}}), want: "\"Finished applying state transition\" prefix=blockchain slot=0 voluntaryExits=1", }, {name: "has everything", - b: interfaces.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ + b: wrapper.WrappedPhase0BeaconBlock(ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{ Attestations: []*ethpb.Attestation{{}}, Deposits: []*ethpb.Deposit{{}}, AttesterSlashings: []*ethpb.AttesterSlashing{{}}, diff --git a/beacon-chain/blockchain/metrics.go b/beacon-chain/blockchain/metrics.go index daf719cff6..b660d34623 100644 --- a/beacon-chain/blockchain/metrics.go +++ b/beacon-chain/blockchain/metrics.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/blockchain/process_attestation_test.go b/beacon-chain/blockchain/process_attestation_test.go index 9b73eb1c83..ef956daa63 100644 --- a/beacon-chain/blockchain/process_attestation_test.go +++ b/beacon-chain/blockchain/process_attestation_test.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -38,13 +38,13 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) { BlkWithOutState := testutil.NewBeaconBlock() BlkWithOutState.Block.Slot = 0 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(BlkWithOutState))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(BlkWithOutState))) BlkWithOutStateRoot, err := BlkWithOutState.Block.HashTreeRoot() require.NoError(t, err) BlkWithStateBadAtt := testutil.NewBeaconBlock() BlkWithStateBadAtt.Block.Slot = 1 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(BlkWithStateBadAtt))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(BlkWithStateBadAtt))) BlkWithStateBadAttRoot, err := BlkWithStateBadAtt.Block.HashTreeRoot() require.NoError(t, err) @@ -55,7 +55,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) { BlkWithValidState := testutil.NewBeaconBlock() BlkWithValidState.Block.Slot = 2 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(BlkWithValidState))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(BlkWithValidState))) BlkWithValidStateRoot, err := BlkWithValidState.Block.HashTreeRoot() require.NoError(t, err) @@ -322,7 +322,7 @@ func TestVerifyBeaconBlock_futureBlock(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 2 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) d := ðpb.AttestationData{Slot: 1, BeaconBlockRoot: r[:]} @@ -340,7 +340,7 @@ func TestVerifyBeaconBlock_OK(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 2 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) d := ðpb.AttestationData{Slot: 2, BeaconBlockRoot: r[:]} @@ -358,7 +358,7 @@ func TestVerifyFinalizedConsistency_InconsistentRoot(t *testing.T) { b32 := testutil.NewBeaconBlock() b32.Block.Slot = 32 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b32))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b32))) r32, err := b32.Block.HashTreeRoot() require.NoError(t, err) @@ -367,7 +367,7 @@ func TestVerifyFinalizedConsistency_InconsistentRoot(t *testing.T) { b33 := testutil.NewBeaconBlock() b33.Block.Slot = 33 b33.Block.ParentRoot = r32[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b33))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b33))) r33, err := b33.Block.HashTreeRoot() require.NoError(t, err) @@ -385,7 +385,7 @@ func TestVerifyFinalizedConsistency_OK(t *testing.T) { b32 := testutil.NewBeaconBlock() b32.Block.Slot = 32 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b32))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b32))) r32, err := b32.Block.HashTreeRoot() require.NoError(t, err) @@ -394,7 +394,7 @@ func TestVerifyFinalizedConsistency_OK(t *testing.T) { b33 := testutil.NewBeaconBlock() b33.Block.Slot = 33 b33.Block.ParentRoot = r32[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b33))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b33))) r33, err := b33.Block.HashTreeRoot() require.NoError(t, err) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index d0a707449c..41bed94f1c 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -14,11 +14,11 @@ import ( pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index e8c2a6b907..259d12240a 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -10,10 +10,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index fb7f8af80b..095e8ccd3e 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -22,9 +22,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,7 +46,7 @@ func TestStore_OnBlock(t *testing.T) { require.NoError(t, err) genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) validGenesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -56,7 +57,7 @@ func TestStore_OnBlock(t *testing.T) { random := testutil.NewBeaconBlock() random.Block.Slot = 1 random.Block.ParentRoot = validGenesisRoot[:] - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(random))) + 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[:]})) @@ -122,7 +123,7 @@ func TestStore_OnBlock(t *testing.T) { root, err := tt.blk.Block.HashTreeRoot() assert.NoError(t, err) - err = service.onBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(tt.blk), root) + err = service.onBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(tt.blk), root) assert.ErrorContains(t, tt.wantErrString, err) }) } @@ -141,14 +142,14 @@ func TestStore_OnBlockBatch(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) service.finalizedCheckpt = ðpb.Checkpoint{ Root: gRoot[:], } service.cfg.ForkChoiceStore = protoarray.New(0, 0, [32]byte{}) - service.saveInitSyncBlock(gRoot, interfaces.WrappedPhase0SignedBeaconBlock(genesis)) + service.saveInitSyncBlock(gRoot, wrapper.WrappedPhase0SignedBeaconBlock(genesis)) st, keys := testutil.DeterministicGenesisState(t, 64) @@ -160,15 +161,15 @@ func TestStore_OnBlockBatch(t *testing.T) { for i := 1; i < 10; i++ { b, err := testutil.GenerateFullBlock(bState, keys, testutil.DefaultBlockGenConfig(), types.Slot(i)) require.NoError(t, err) - bState, err = state.ExecuteStateTransition(ctx, bState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + bState, err = state.ExecuteStateTransition(ctx, bState, wrapper.WrappedPhase0SignedBeaconBlock(b)) require.NoError(t, err) if i == 1 { firstState = bState.Copy() } root, err := b.Block.HashTreeRoot() require.NoError(t, err) - service.saveInitSyncBlock(root, interfaces.WrappedPhase0SignedBeaconBlock(b)) - blks = append(blks, interfaces.WrappedPhase0SignedBeaconBlock(b)) + service.saveInitSyncBlock(root, wrapper.WrappedPhase0SignedBeaconBlock(b)) + blks = append(blks, wrapper.WrappedPhase0SignedBeaconBlock(b)) blkRoots = append(blkRoots, root) } @@ -204,8 +205,8 @@ func TestRemoveStateSinceLastFinalized_EmptyStartSlot(t *testing.T) { newJustifiedBlk.Block.ParentRoot = bytesutil.PadTo(lastJustifiedRoot[:], 32) newJustifiedRoot, err := newJustifiedBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(newJustifiedBlk))) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(lastJustifiedBlk))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(newJustifiedBlk))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(lastJustifiedBlk))) diff := params.BeaconConfig().SlotsPerEpoch.Sub(1).Mul(params.BeaconConfig().SecondsPerSlot) service.genesisTime = time.Unix(time.Now().Unix()-int64(diff), 0) @@ -232,8 +233,8 @@ func TestShouldUpdateJustified_ReturnFalse(t *testing.T) { newJustifiedBlk.Block.ParentRoot = bytesutil.PadTo(lastJustifiedRoot[:], 32) newJustifiedRoot, err := newJustifiedBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(newJustifiedBlk))) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(lastJustifiedBlk))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(newJustifiedBlk))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(lastJustifiedBlk))) diff := params.BeaconConfig().SlotsPerEpoch.Sub(1).Mul(params.BeaconConfig().SecondsPerSlot) service.genesisTime = time.Unix(time.Now().Unix()-int64(diff), 0) @@ -260,21 +261,21 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) service.finalizedCheckpt = ðpb.Checkpoint{ Root: gRoot[:], } service.cfg.ForkChoiceStore = protoarray.New(0, 0, [32]byte{}) - service.saveInitSyncBlock(gRoot, interfaces.WrappedPhase0SignedBeaconBlock(genesis)) + service.saveInitSyncBlock(gRoot, wrapper.WrappedPhase0SignedBeaconBlock(genesis)) 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.StateGen.SaveState(ctx, gRoot, s)) - require.NoError(t, service.verifyBlkPreState(ctx, interfaces.WrappedPhase0BeaconBlock(b.Block))) + require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0BeaconBlock(b.Block))) } func TestCachedPreState_CanGetFromDB(t *testing.T) { @@ -290,19 +291,19 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) service.finalizedCheckpt = ðpb.Checkpoint{ Root: gRoot[:], } service.cfg.ForkChoiceStore = protoarray.New(0, 0, [32]byte{}) - service.saveInitSyncBlock(gRoot, interfaces.WrappedPhase0SignedBeaconBlock(genesis)) + service.saveInitSyncBlock(gRoot, wrapper.WrappedPhase0SignedBeaconBlock(genesis)) b := testutil.NewBeaconBlock() b.Block.Slot = 1 service.finalizedCheckpt = ðpb.Checkpoint{Root: gRoot[:]} - err = service.verifyBlkPreState(ctx, interfaces.WrappedPhase0BeaconBlock(b.Block)) + err = service.verifyBlkPreState(ctx, wrapper.WrappedPhase0BeaconBlock(b.Block)) wanted := "could not reconstruct parent state" assert.ErrorContains(t, wanted, err) @@ -311,7 +312,7 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) { require.NoError(t, err) require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 1, Root: gRoot[:]})) require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s)) - require.NoError(t, service.verifyBlkPreState(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b).Block())) + require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b).Block())) } func TestUpdateJustified_CouldUpdateBest(t *testing.T) { @@ -323,7 +324,7 @@ func TestUpdateJustified_CouldUpdateBest(t *testing.T) { require.NoError(t, err) signedBlock := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(signedBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(signedBlock))) r, err := signedBlock.Block.HashTreeRoot() require.NoError(t, err) service.justifiedCheckpt = ðpb.Checkpoint{Root: []byte{'A'}} @@ -359,7 +360,7 @@ func TestFillForkChoiceMissingBlocks_CanSave(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) validGenesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -375,7 +376,7 @@ func TestFillForkChoiceMissingBlocks_CanSave(t *testing.T) { block.Block.ParentRoot = roots[8] err = service.fillInForkChoiceMissingBlocks( - context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(block).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) + context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) require.NoError(t, err) // 5 nodes from the block tree 1. B0 - B3 - B4 - B6 - B8 @@ -397,7 +398,7 @@ func TestFillForkChoiceMissingBlocks_RootsMatch(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) validGenesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -413,7 +414,7 @@ func TestFillForkChoiceMissingBlocks_RootsMatch(t *testing.T) { block.Block.ParentRoot = roots[8] err = service.fillInForkChoiceMissingBlocks( - context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(block).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) + context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) require.NoError(t, err) // 5 nodes from the block tree 1. B0 - B3 - B4 - B6 - B8 @@ -439,7 +440,7 @@ func TestFillForkChoiceMissingBlocks_FilterFinalized(t *testing.T) { genesisStateRoot := [32]byte{} genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) validGenesisRoot, err := genesis.Block.HashTreeRoot() assert.NoError(t, err) st, err := testutil.NewBeaconState() @@ -450,23 +451,23 @@ func TestFillForkChoiceMissingBlocks_FilterFinalized(t *testing.T) { // Define a tree branch, slot 63 <- 64 <- 65 b63 := testutil.NewBeaconBlock() b63.Block.Slot = 63 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b63))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b63))) r63, err := b63.Block.HashTreeRoot() require.NoError(t, err) b64 := testutil.NewBeaconBlock() b64.Block.Slot = 64 b64.Block.ParentRoot = r63[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b64))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b64))) r64, err := b64.Block.HashTreeRoot() require.NoError(t, err) b65 := testutil.NewBeaconBlock() b65.Block.Slot = 65 b65.Block.ParentRoot = r64[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b65))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b65))) beaconState, _ := testutil.DeterministicGenesisState(t, 32) err = service.fillInForkChoiceMissingBlocks( - context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b65).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) + context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b65).Block(), beaconState.FinalizedCheckpoint(), beaconState.CurrentJustifiedCheckpoint()) require.NoError(t, err) // There should be 2 nodes, block 65 and block 64. @@ -546,7 +547,7 @@ func blockTree1(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][]byt beaconBlock := testutil.NewBeaconBlock() beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) - if err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { + if err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { return nil, err } if err := beaconDB.SaveState(context.Background(), st.Copy(), bytesutil.ToBytes32(beaconBlock.Block.ParentRoot)); err != nil { @@ -608,7 +609,7 @@ func TestAncestor_HandleSkipSlot(t *testing.T) { beaconBlock := testutil.NewBeaconBlock() beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock))) } // Slots 100 to 200 are skip slots. Requesting root at 150 will yield root at 100. The last physical block. @@ -690,7 +691,7 @@ func TestAncestor_CanUseDB(t *testing.T) { beaconBlock := testutil.NewBeaconBlock() beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock))) // Saves blocks to DB. + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock))) // Saves blocks to DB. } require.NoError(t, service.cfg.ForkChoiceStore.ProcessBlock(context.Background(), 200, r200, r200, [32]byte{}, 0, 0)) @@ -782,7 +783,7 @@ func TestFinalizedImpliesNewJustified(t *testing.T) { beaconBlock := testutil.NewBeaconBlock() beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock))) } service.finalizedCheckpt = ðpb.Checkpoint{Root: []byte{'c'}, Epoch: 1} service.justifiedCheckpt.Root = r100[:] @@ -801,14 +802,14 @@ func TestVerifyBlkDescendant(t *testing.T) { b.Block.Slot = 1 r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) b1 := testutil.NewBeaconBlock() b1.Block.Slot = 1 b1.Block.Body.Graffiti = bytesutil.PadTo([]byte{'a'}, 32) r1, err := b1.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) type args struct { parentRoot [32]byte @@ -875,7 +876,7 @@ func TestUpdateJustifiedInitSync(t *testing.T) { gBlk := testutil.NewBeaconBlock() gRoot, err := gBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(gBlk))) + 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[:]})) beaconState, _ := testutil.DeterministicGenesisState(t, 32) @@ -950,7 +951,7 @@ func TestOnBlock_CanFinalize(t *testing.T) { require.NoError(t, err) r, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.onBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk), r)) + require.NoError(t, service.onBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk), r)) testState, err = service.cfg.StateGen.StateByRoot(ctx, r) require.NoError(t, err) } diff --git a/beacon-chain/blockchain/receive_attestation_test.go b/beacon-chain/blockchain/receive_attestation_test.go index f6eee9efc1..eb20c7e40e 100644 --- a/beacon-chain/blockchain/receive_attestation_test.go +++ b/beacon-chain/blockchain/receive_attestation_test.go @@ -13,8 +13,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -44,13 +44,13 @@ func TestVerifyLMDFFGConsistent_NotOK(t *testing.T) { b32 := testutil.NewBeaconBlock() b32.Block.Slot = 32 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b32))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b32))) r32, err := b32.Block.HashTreeRoot() require.NoError(t, err) b33 := testutil.NewBeaconBlock() b33.Block.Slot = 33 b33.Block.ParentRoot = r32[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b33))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b33))) r33, err := b33.Block.HashTreeRoot() require.NoError(t, err) @@ -72,13 +72,13 @@ func TestVerifyLMDFFGConsistent_OK(t *testing.T) { b32 := testutil.NewBeaconBlock() b32.Block.Slot = 32 - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b32))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b32))) r32, err := b32.Block.HashTreeRoot() require.NoError(t, err) b33 := testutil.NewBeaconBlock() b33.Block.Slot = 33 b33.Block.ParentRoot = r32[:] - require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b33))) + require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b33))) r33, err := b33.Block.HashTreeRoot() require.NoError(t, err) diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 0702ec7d60..db15b9f759 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -8,8 +8,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" diff --git a/beacon-chain/blockchain/receive_block_test.go b/beacon-chain/blockchain/receive_block_test.go index ea9ad1d565..f0b8c9612f 100644 --- a/beacon-chain/blockchain/receive_block_test.go +++ b/beacon-chain/blockchain/receive_block_test.go @@ -14,8 +14,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -145,7 +146,7 @@ func TestService_ReceiveBlock(t *testing.T) { s.finalizedCheckpt = ðpb.Checkpoint{Root: gRoot[:]} root, err := tt.args.block.Block.HashTreeRoot() require.NoError(t, err) - err = s.ReceiveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(tt.args.block), root) + err = s.ReceiveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(tt.args.block), root) if tt.wantedErr != "" { assert.ErrorContains(t, tt.wantedErr, err) } else { @@ -189,7 +190,7 @@ func TestService_ReceiveBlockUpdateHead(t *testing.T) { wg := sync.WaitGroup{} wg.Add(1) go func() { - require.NoError(t, s.ReceiveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b), root)) + require.NoError(t, s.ReceiveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b), root)) wg.Done() }() wg.Wait() @@ -269,7 +270,7 @@ func TestService_ReceiveBlockBatch(t *testing.T) { s.finalizedCheckpt = ðpb.Checkpoint{Root: gRoot[:]} root, err := tt.args.block.Block.HashTreeRoot() require.NoError(t, err) - blks := []interfaces.SignedBeaconBlock{interfaces.WrappedPhase0SignedBeaconBlock(tt.args.block)} + blks := []interfaces.SignedBeaconBlock{wrapper.WrappedPhase0SignedBeaconBlock(tt.args.block)} roots := [][32]byte{root} err = s.ReceiveBlockBatch(ctx, blks, roots) if tt.wantedErr != "" { @@ -289,7 +290,7 @@ func TestService_HasInitSyncBlock(t *testing.T) { if s.HasInitSyncBlock(r) { t.Error("Should not have block") } - s.saveInitSyncBlock(r, interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + s.saveInitSyncBlock(r, wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) if !s.HasInitSyncBlock(r) { t.Error("Should have block") } diff --git a/beacon-chain/blockchain/service.go b/beacon-chain/blockchain/service.go index 15c872d915..fd8ab2bb36 100644 --- a/beacon-chain/blockchain/service.go +++ b/beacon-chain/blockchain/service.go @@ -29,9 +29,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" "github.com/sirupsen/logrus" diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index 231b287843..5624a1467a 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -26,9 +26,10 @@ import ( protodb "github.com/prysmaticlabs/prysm/proto/beacon/db" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -135,7 +136,7 @@ func TestChainStartStop_Initialized(t *testing.T) { genesisBlk := testutil.NewBeaconBlock() blkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk))) s, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, s.SetSlot(1)) @@ -165,7 +166,7 @@ func TestChainStartStop_GenesisZeroHashes(t *testing.T) { genesisBlk := testutil.NewBeaconBlock() blkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk))) s, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, s, blkRoot)) @@ -234,7 +235,7 @@ func TestChainService_CorrectGenesisRoots(t *testing.T) { genesisBlk := testutil.NewBeaconBlock() blkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk))) s, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, s.SetSlot(0)) @@ -261,7 +262,7 @@ func TestChainService_InitializeChainInfo(t *testing.T) { genesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, genesisRoot)) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) finalizedSlot := params.BeaconConfig().SlotsPerEpoch*2 + 1 headBlock := testutil.NewBeaconBlock() @@ -275,7 +276,7 @@ func TestChainService_InitializeChainInfo(t *testing.T) { require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, headState, headRoot)) require.NoError(t, beaconDB.SaveState(ctx, headState, genesisRoot)) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(headBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(headBlock))) require.NoError(t, beaconDB.SaveFinalizedCheckpoint(ctx, ðpb.Checkpoint{Epoch: helpers.SlotToEpoch(finalizedSlot), Root: headRoot[:]})) c := &Service{cfg: &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB)}} require.NoError(t, c.initializeChainInfo(ctx)) @@ -302,7 +303,7 @@ func TestChainService_InitializeChainInfo_SetHeadAtGenesis(t *testing.T) { genesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, genesisRoot)) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) finalizedSlot := params.BeaconConfig().SlotsPerEpoch*2 + 1 headBlock := testutil.NewBeaconBlock() @@ -316,7 +317,7 @@ func TestChainService_InitializeChainInfo_SetHeadAtGenesis(t *testing.T) { require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, headState, headRoot)) require.NoError(t, beaconDB.SaveState(ctx, headState, genesisRoot)) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(headBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(headBlock))) c := &Service{cfg: &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB)}} require.NoError(t, c.initializeChainInfo(ctx)) s, err := c.HeadState(ctx) @@ -344,14 +345,14 @@ func TestChainService_InitializeChainInfo_HeadSync(t *testing.T) { genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, genesisRoot)) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) finalizedBlock := testutil.NewBeaconBlock() finalizedBlock.Block.Slot = finalizedSlot finalizedBlock.Block.ParentRoot = genesisRoot[:] finalizedRoot, err := finalizedBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(finalizedBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(finalizedBlock))) // Set head slot close to the finalization point, no head sync is triggered. headBlock := testutil.NewBeaconBlock() @@ -359,7 +360,7 @@ func TestChainService_InitializeChainInfo_HeadSync(t *testing.T) { headBlock.Block.ParentRoot = finalizedRoot[:] headRoot, err := headBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(headBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(headBlock))) headState, err := testutil.NewBeaconState() require.NoError(t, err) @@ -392,7 +393,7 @@ func TestChainService_InitializeChainInfo_HeadSync(t *testing.T) { headBlock.Block.ParentRoot = finalizedRoot[:] headRoot, err = headBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(headBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(headBlock))) require.NoError(t, beaconDB.SaveState(ctx, headState, headRoot)) require.NoError(t, beaconDB.SaveHeadBlockRoot(ctx, headRoot)) @@ -421,7 +422,7 @@ func TestChainService_SaveHeadNoDB(t *testing.T) { newState, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, s.cfg.StateGen.SaveState(ctx, r, newState)) - require.NoError(t, s.saveHeadNoDB(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk), r, newState)) + require.NoError(t, s.saveHeadNoDB(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk), r, newState)) newB, err := s.cfg.BeaconDB.HeadBlock(ctx) require.NoError(t, err) @@ -442,7 +443,7 @@ func TestHasBlock_ForkChoiceAndDB(t *testing.T) { require.NoError(t, err) beaconState, err := testutil.NewBeaconState() require.NoError(t, err) - require.NoError(t, s.insertBlockAndAttestationsToForkChoiceStore(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState)) + require.NoError(t, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState)) assert.Equal(t, false, s.hasBlock(ctx, [32]byte{}), "Should not have block") assert.Equal(t, true, s.hasBlock(ctx, r), "Should have block") @@ -460,7 +461,7 @@ func TestServiceStop_SaveCachedBlocks(t *testing.T) { block := testutil.NewBeaconBlock() r, err := block.Block.HashTreeRoot() require.NoError(t, err) - s.saveInitSyncBlock(r, interfaces.WrappedPhase0SignedBeaconBlock(block)) + s.saveInitSyncBlock(r, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, s.Stop()) require.Equal(t, true, s.cfg.BeaconDB.HasBlock(ctx, r)) } @@ -486,7 +487,7 @@ func BenchmarkHasBlockDB(b *testing.B) { cfg: &Config{BeaconDB: beaconDB}, } block := testutil.NewBeaconBlock() - require.NoError(b, s.cfg.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(b, s.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) r, err := block.Block.HashTreeRoot() require.NoError(b, err) @@ -509,7 +510,7 @@ func BenchmarkHasBlockForkChoiceStore(b *testing.B) { bs := &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}} beaconState, err := v1.InitializeFromProto(bs) require.NoError(b, err) - require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState)) + require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState)) b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/beacon-chain/blockchain/testing/BUILD.bazel b/beacon-chain/blockchain/testing/BUILD.bazel index e8b2b0a681..7f526c48ea 100644 --- a/beacon-chain/blockchain/testing/BUILD.bazel +++ b/beacon-chain/blockchain/testing/BUILD.bazel @@ -22,9 +22,9 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", - "//shared/interfaces: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/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index 36e4d4c713..ecdfecf215 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -22,9 +22,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" ) diff --git a/beacon-chain/blockchain/weak_subjectivity_checks_test.go b/beacon-chain/blockchain/weak_subjectivity_checks_test.go index f235173839..81f8169091 100644 --- a/beacon-chain/blockchain/weak_subjectivity_checks_test.go +++ b/beacon-chain/blockchain/weak_subjectivity_checks_test.go @@ -7,8 +7,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -18,7 +18,7 @@ func TestService_VerifyWeakSubjectivityRoot(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 32 - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) tests := []struct { diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 35d6f216c0..cb022f7e02 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -29,13 +29,13 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/copyutil:go_default_library", "//shared/depositutil:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", "//shared/slashutil:go_default_library", @@ -78,13 +78,13 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/aggregation:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/copyutil:go_default_library", - "//shared/interfaces: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/blocks/attestation.go b/beacon-chain/core/blocks/attestation.go index 4a446b54cd..404c9ec090 100644 --- a/beacon-chain/core/blocks/attestation.go +++ b/beacon-chain/core/blocks/attestation.go @@ -10,9 +10,9 @@ import ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) diff --git a/beacon-chain/core/blocks/attestation_test.go b/beacon-chain/core/blocks/attestation_test.go index cd690b2a74..a97972d2b4 100644 --- a/beacon-chain/core/blocks/attestation_test.go +++ b/beacon-chain/core/blocks/attestation_test.go @@ -12,12 +12,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/aggregation" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -47,7 +47,7 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) { params.BeaconConfig().MinAttestationInclusionDelay, beaconState.Slot(), ) - _, err := blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -77,7 +77,7 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) { helpers.PrevEpoch(beaconState), helpers.CurrentEpoch(beaconState), ) - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -105,11 +105,11 @@ func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) { require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) want := "source check point not equal to current justified checkpoint" - _, err := blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) b.Block.Body.Attestations[0].Data.Source.Epoch = helpers.CurrentEpoch(beaconState) b.Block.Body.Attestations[0].Data.Source.Root = []byte{} - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -143,12 +143,12 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) { require.NoError(t, beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{})) want := "source check point not equal to previous justified checkpoint" - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) b.Block.Body.Attestations[0].Data.Source.Epoch = helpers.PrevEpoch(beaconState) b.Block.Body.Attestations[0].Data.Target.Epoch = helpers.PrevEpoch(beaconState) b.Block.Body.Attestations[0].Data.Source.Root = []byte{} - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -179,7 +179,7 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) { require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) expected := "failed to verify aggregation bitfield: wanted participants bitfield length 3, got: 4" - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, expected, err) } @@ -222,7 +222,7 @@ func TestProcessAttestations_OK(t *testing.T) { err = beaconState.SetSlot(beaconState.Slot() + params.BeaconConfig().MinAttestationInclusionDelay) require.NoError(t, err) - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.NoError(t, err) } @@ -353,7 +353,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) { err = beaconState.SetSlot(beaconState.Slot() + params.BeaconConfig().MinAttestationInclusionDelay) require.NoError(t, err) - _, err = blocks.ProcessAttestations(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.NoError(t, err) } diff --git a/beacon-chain/core/blocks/block_operations_fuzz_test.go b/beacon-chain/core/blocks/block_operations_fuzz_test.go index 8e9df8a246..cf41484669 100644 --- a/beacon-chain/core/blocks/block_operations_fuzz_test.go +++ b/beacon-chain/core/blocks/block_operations_fuzz_test.go @@ -10,7 +10,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -42,7 +42,7 @@ func TestFuzzProcessBlockHeader_10000(t *testing.T) { s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - _, err = ProcessBlockHeader(context.Background(), s, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = ProcessBlockHeader(context.Background(), s, wrapper.WrappedPhase0SignedBeaconBlock(block)) _ = err } } @@ -140,7 +140,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) { fuzzer.Fuzz(b) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessRandao(context.Background(), s, interfaces.WrappedPhase0SignedBeaconBlock(b)) + r, err := ProcessRandao(context.Background(), s, wrapper.WrappedPhase0SignedBeaconBlock(b)) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) } @@ -259,7 +259,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) { fuzzer.Fuzz(b) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessAttestations(ctx, s, interfaces.WrappedPhase0SignedBeaconBlock(b)) + r, err := ProcessAttestations(ctx, s, wrapper.WrappedPhase0SignedBeaconBlock(b)) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) } @@ -276,7 +276,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) { fuzzer.Fuzz(b) s, err := v1.InitializeFromProtoUnsafe(state) require.NoError(t, err) - r, err := ProcessAttestationsNoVerifySignature(ctx, s, interfaces.WrappedPhase0SignedBeaconBlock(b)) + r, err := ProcessAttestationsNoVerifySignature(ctx, s, wrapper.WrappedPhase0SignedBeaconBlock(b)) if err != nil && r != nil { t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) } diff --git a/beacon-chain/core/blocks/header.go b/beacon-chain/core/blocks/header.go index 7bcdf002f1..6ebb0b6fcf 100644 --- a/beacon-chain/core/blocks/header.go +++ b/beacon-chain/core/blocks/header.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/core/blocks/header_test.go b/beacon-chain/core/blocks/header_test.go index 065784abe8..2f0b06ca17 100644 --- a/beacon-chain/core/blocks/header_test.go +++ b/beacon-chain/core/blocks/header_test.go @@ -9,9 +9,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -66,7 +66,7 @@ func TestProcessBlockHeader_ImproperBlockSlot(t *testing.T) { err = state.UpdateValidatorAtIndex(proposerIdx, validators[proposerIdx]) require.NoError(t, err) - _, err = blocks.ProcessBlockHeader(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessBlockHeader(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.ErrorContains(t, "block.Slot 10 must be greater than state.LatestBlockHeader.Slot 10", err) } @@ -92,7 +92,7 @@ func TestProcessBlockHeader_WrongProposerSig(t *testing.T) { block.Signature, err = helpers.ComputeDomainAndSign(beaconState, 0, block.Block, params.BeaconConfig().DomainBeaconProposer, privKeys[proposerIdx+1]) require.NoError(t, err) - _, err = blocks.ProcessBlockHeader(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessBlockHeader(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) want := "signature did not verify" assert.ErrorContains(t, want, err) } @@ -134,7 +134,7 @@ func TestProcessBlockHeader_DifferentSlots(t *testing.T) { Signature: blockSig, }) - _, err = blocks.ProcessBlockHeader(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessBlockHeader(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(block)) want := "is different than block slot" assert.ErrorContains(t, want, err) } @@ -173,7 +173,7 @@ func TestProcessBlockHeader_PreviousBlockRootNotSignedRoot(t *testing.T) { block.Block.ParentRoot = bytesutil.PadTo([]byte{'A'}, 32) block.Signature = blockSig - _, err = blocks.ProcessBlockHeader(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessBlockHeader(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(block)) want := "does not match" assert.ErrorContains(t, want, err) } @@ -215,7 +215,7 @@ func TestProcessBlockHeader_SlashedProposer(t *testing.T) { block.Block.ParentRoot = parentRoot[:] block.Signature = blockSig - _, err = blocks.ProcessBlockHeader(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = blocks.ProcessBlockHeader(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(block)) want := "was previously slashed" assert.ErrorContains(t, want, err) } @@ -264,7 +264,7 @@ func TestProcessBlockHeader_OK(t *testing.T) { err = state.UpdateValidatorAtIndex(proposerIdx, validators[proposerIdx]) require.NoError(t, err) - newState, err := blocks.ProcessBlockHeader(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(block)) + newState, err := blocks.ProcessBlockHeader(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err, "Failed to process block header got") var zeroHash [32]byte nsh := newState.LatestBlockHeader() diff --git a/beacon-chain/core/blocks/randao.go b/beacon-chain/core/blocks/randao.go index c6f04cceea..253f9d0af4 100644 --- a/beacon-chain/core/blocks/randao.go +++ b/beacon-chain/core/blocks/randao.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/hashutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/core/blocks/randao_test.go b/beacon-chain/core/blocks/randao_test.go index 81cae940ad..384595d479 100644 --- a/beacon-chain/core/blocks/randao_test.go +++ b/beacon-chain/core/blocks/randao_test.go @@ -10,7 +10,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -39,7 +39,7 @@ func TestProcessRandao_IncorrectProposerFailsVerification(t *testing.T) { } want := "block randao: signature did not verify" - _, err = blocks.ProcessRandao(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = blocks.ProcessRandao(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -60,7 +60,7 @@ func TestProcessRandao_SignatureVerifiesAndUpdatesLatestStateMixes(t *testing.T) newState, err := blocks.ProcessRandao( context.Background(), beaconState, - interfaces.WrappedPhase0SignedBeaconBlock(b), + wrapper.WrappedPhase0SignedBeaconBlock(b), ) require.NoError(t, err, "Unexpected error processing block randao") currentEpoch := helpers.CurrentEpoch(beaconState) diff --git a/beacon-chain/core/feed/block/BUILD.bazel b/beacon-chain/core/feed/block/BUILD.bazel index a021e5f63f..18f9ec2a69 100644 --- a/beacon-chain/core/feed/block/BUILD.bazel +++ b/beacon-chain/core/feed/block/BUILD.bazel @@ -9,7 +9,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/block", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//proto/interfaces:go_default_library", "//shared/event:go_default_library", - "//shared/interfaces:go_default_library", ], ) diff --git a/beacon-chain/core/feed/block/events.go b/beacon-chain/core/feed/block/events.go index 7ff8e16e9e..834b808650 100644 --- a/beacon-chain/core/feed/block/events.go +++ b/beacon-chain/core/feed/block/events.go @@ -2,7 +2,9 @@ // during the runtime of a beacon node. package block -import "github.com/prysmaticlabs/prysm/shared/interfaces" +import ( + "github.com/prysmaticlabs/prysm/proto/interfaces" +) const ( // ReceivedBlock is sent after a block has been received by the beacon node via p2p or RPC. diff --git a/beacon-chain/core/feed/state/BUILD.bazel b/beacon-chain/core/feed/state/BUILD.bazel index 3eb15b66f6..0143374e12 100644 --- a/beacon-chain/core/feed/state/BUILD.bazel +++ b/beacon-chain/core/feed/state/BUILD.bazel @@ -9,8 +9,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//proto/interfaces:go_default_library", "//shared/event:go_default_library", - "//shared/interfaces:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", ], ) diff --git a/beacon-chain/core/feed/state/events.go b/beacon-chain/core/feed/state/events.go index 2903f2ca24..c31e477b31 100644 --- a/beacon-chain/core/feed/state/events.go +++ b/beacon-chain/core/feed/state/events.go @@ -7,7 +7,7 @@ import ( "time" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) const ( diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 206a6c3600..f2346af13e 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -38,10 +38,10 @@ go_library( "//beacon-chain/state/interface:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", diff --git a/beacon-chain/core/helpers/block.go b/beacon-chain/core/helpers/block.go index da4594f113..dbbdf2cc5c 100644 --- a/beacon-chain/core/helpers/block.go +++ b/beacon-chain/core/helpers/block.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" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index aa5b160585..0ab44dd007 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -36,11 +36,11 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", "//shared/traceutil:go_default_library", @@ -78,12 +78,12 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/attestationutil:go_default_library", "//shared/benchutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces: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/state/benchmarks_test.go b/beacon-chain/core/state/benchmarks_test.go index 5598095b99..fc470a8249 100644 --- a/beacon-chain/core/state/benchmarks_test.go +++ b/beacon-chain/core/state/benchmarks_test.go @@ -9,8 +9,8 @@ import ( 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" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/benchutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -28,7 +28,7 @@ func BenchmarkExecuteStateTransition_FullBlock(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - _, err := coreState.ExecuteStateTransition(context.Background(), cleanStates[i], interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err := coreState.ExecuteStateTransition(context.Background(), cleanStates[i], wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(b, err) } } @@ -49,12 +49,12 @@ func BenchmarkExecuteStateTransition_WithCache(b *testing.B) { require.NoError(b, helpers.UpdateCommitteeCache(beaconState, helpers.CurrentEpoch(beaconState))) require.NoError(b, beaconState.SetSlot(currentSlot)) // Run the state transition once to populate the cache. - _, err = coreState.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = coreState.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(b, err, "Failed to process block, benchmarks will fail") b.ResetTimer() for i := 0; i < b.N; i++ { - _, err := coreState.ExecuteStateTransition(context.Background(), cleanStates[i], interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err := coreState.ExecuteStateTransition(context.Background(), cleanStates[i], wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(b, err, "Failed to process block, benchmarks will fail") } } diff --git a/beacon-chain/core/state/interop/BUILD.bazel b/beacon-chain/core/state/interop/BUILD.bazel index 5ed7a481c3..b4c717d130 100644 --- a/beacon-chain/core/state/interop/BUILD.bazel +++ b/beacon-chain/core/state/interop/BUILD.bazel @@ -14,9 +14,9 @@ go_library( ], deps = [ "//beacon-chain/state/interface:go_default_library", + "//proto/interfaces:go_default_library", "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", - "//shared/interfaces:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], ) diff --git a/beacon-chain/core/state/interop/write_block_to_disk.go b/beacon-chain/core/state/interop/write_block_to_disk.go index 6af26de759..1d86e5688c 100644 --- a/beacon-chain/core/state/interop/write_block_to_disk.go +++ b/beacon-chain/core/state/interop/write_block_to_disk.go @@ -5,9 +5,9 @@ import ( "os" "path" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/fileutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" ) // WriteBlockToDisk as a block ssz. Writes to temp directory. Debug! diff --git a/beacon-chain/core/state/skip_slot_cache_test.go b/beacon-chain/core/state/skip_slot_cache_test.go index 6cc57d051b..d88ed86d96 100644 --- a/beacon-chain/core/state/skip_slot_cache_test.go +++ b/beacon-chain/core/state/skip_slot_cache_test.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -31,11 +31,11 @@ func TestSkipSlotCache_OK(t *testing.T) { // with the state blk, err := testutil.GenerateFullBlock(bState, privs, blkCfg, originalState.Slot()+10) require.NoError(t, err) - executedState, err := state.ExecuteStateTransition(context.Background(), originalState, interfaces.WrappedPhase0SignedBeaconBlock(blk)) + executedState, err := state.ExecuteStateTransition(context.Background(), originalState, wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err, "Could not run state transition") originalState, ok := executedState.(*v1.BeaconState) require.Equal(t, true, ok) - bState, err = state.ExecuteStateTransition(context.Background(), bState, interfaces.WrappedPhase0SignedBeaconBlock(blk)) + bState, err = state.ExecuteStateTransition(context.Background(), bState, wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err, "Could not process state transition") assert.DeepEqual(t, originalState.CloneInnerState(), bState.CloneInnerState(), "Skipped slots cache leads to different states") @@ -57,7 +57,7 @@ func TestSkipSlotCache_ConcurrentMixup(t *testing.T) { // with the state blk, err := testutil.GenerateFullBlock(bState, privs, blkCfg, originalState.Slot()+10) require.NoError(t, err) - executedState, err := state.ExecuteStateTransition(context.Background(), originalState, interfaces.WrappedPhase0SignedBeaconBlock(blk)) + executedState, err := state.ExecuteStateTransition(context.Background(), originalState, wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err, "Could not run state transition") originalState, ok := executedState.(*v1.BeaconState) require.Equal(t, true, ok) @@ -71,7 +71,7 @@ func TestSkipSlotCache_ConcurrentMixup(t *testing.T) { signature, err := testutil.BlockSignature(originalState, blk.Block, privs) require.NoError(t, err) blk.Signature = signature.Marshal() - state1, err = state.ExecuteStateTransition(context.Background(), originalState.Copy(), interfaces.WrappedPhase0SignedBeaconBlock(blk)) + state1, err = state.ExecuteStateTransition(context.Background(), originalState.Copy(), wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err, "Could not run state transition") } @@ -82,7 +82,7 @@ func TestSkipSlotCache_ConcurrentMixup(t *testing.T) { signature, err := testutil.BlockSignature(originalState, blk.Block, privs) require.NoError(t, err) blk.Signature = signature.Marshal() - state2, err = state.ExecuteStateTransition(context.Background(), originalState.Copy(), interfaces.WrappedPhase0SignedBeaconBlock(blk)) + state2, err = state.ExecuteStateTransition(context.Background(), originalState.Copy(), wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err, "Could not run state transition") } diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index 0caaf3a45e..71b0408a13 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -17,7 +17,7 @@ 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" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" diff --git a/beacon-chain/core/state/transition_fuzz_test.go b/beacon-chain/core/state/transition_fuzz_test.go index f79eee6deb..d10d772ef3 100644 --- a/beacon-chain/core/state/transition_fuzz_test.go +++ b/beacon-chain/core/state/transition_fuzz_test.go @@ -8,7 +8,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" ) func TestFuzzExecuteStateTransition_1000(t *testing.T) { @@ -22,7 +22,7 @@ func TestFuzzExecuteStateTransition_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(sb) - s, err := ExecuteStateTransition(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(sb)) + s, err := ExecuteStateTransition(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(sb)) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for state: %v and signed block: %v", s, err, state, sb) } @@ -40,7 +40,7 @@ func TestFuzzCalculateStateRoot_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(sb) - stateRoot, err := CalculateStateRoot(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(sb)) + stateRoot, err := CalculateStateRoot(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(sb)) if err != nil && stateRoot != [32]byte{} { t.Fatalf("state root should be empty on err. found: %v on error: %v for signed block: %v", stateRoot, err, sb) } @@ -92,7 +92,7 @@ func TestFuzzProcessBlock_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(sb) - s, err := ProcessBlock(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(sb)) + s, err := ProcessBlock(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(sb)) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for signed block: %v", s, err, sb) } @@ -110,7 +110,7 @@ func TestFuzzProcessOperations_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(bb) - s, err := ProcessBlock(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(bb)) + s, err := ProcessBlock(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(bb)) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for block body: %v", s, err, bb) } @@ -128,7 +128,7 @@ func TestFuzzprocessOperationsNoVerify_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(bb) - s, err := ProcessOperationsNoVerifyAttsSigs(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(bb)) + s, err := ProcessOperationsNoVerifyAttsSigs(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(bb)) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for block body: %v", s, err, bb) } @@ -145,7 +145,7 @@ func TestFuzzverifyOperationLengths_10000(t *testing.T) { for i := 0; i < 10000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(bb) - _, err := VerifyOperationLengths(context.Background(), state, interfaces.WrappedPhase0SignedBeaconBlock(bb)) + _, err := VerifyOperationLengths(context.Background(), state, wrapper.WrappedPhase0SignedBeaconBlock(bb)) _ = err } } @@ -189,7 +189,7 @@ func TestFuzzProcessBlockForStateRoot_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(sb) - s, err := ProcessBlockForStateRoot(ctx, state, interfaces.WrappedPhase0SignedBeaconBlock(sb)) + s, err := ProcessBlockForStateRoot(ctx, state, wrapper.WrappedPhase0SignedBeaconBlock(sb)) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for signed block: %v", s, err, sb) } diff --git a/beacon-chain/core/state/transition_no_verify_sig.go b/beacon-chain/core/state/transition_no_verify_sig.go index 08601ee9e8..6bc44cb3cc 100644 --- a/beacon-chain/core/state/transition_no_verify_sig.go +++ b/beacon-chain/core/state/transition_no_verify_sig.go @@ -11,9 +11,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) diff --git a/beacon-chain/core/state/transition_no_verify_sig_test.go b/beacon-chain/core/state/transition_no_verify_sig_test.go index 4b0338b051..3f1e30ed66 100644 --- a/beacon-chain/core/state/transition_no_verify_sig_test.go +++ b/beacon-chain/core/state/transition_no_verify_sig_test.go @@ -7,8 +7,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -51,7 +51,7 @@ func TestExecuteStateTransitionNoVerify_FullProcess(t *testing.T) { block.Block.Body.RandaoReveal = randaoReveal block.Block.Body.Eth1Data = eth1Data - stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) block.Block.StateRoot = stateRoot[:] @@ -60,7 +60,7 @@ func TestExecuteStateTransitionNoVerify_FullProcess(t *testing.T) { require.NoError(t, err) block.Signature = sig.Marshal() - set, _, err := state.ExecuteStateTransitionNoVerifyAnySig(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + set, _, err := state.ExecuteStateTransitionNoVerifyAnySig(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.NoError(t, err) verified, err := set.Verify() assert.NoError(t, err) @@ -103,7 +103,7 @@ func TestExecuteStateTransitionNoVerifySignature_CouldNotVerifyStateRoot(t *test block.Block.Body.RandaoReveal = randaoReveal block.Block.Body.Eth1Data = eth1Data - stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) block.Block.StateRoot = stateRoot[:] @@ -113,13 +113,13 @@ func TestExecuteStateTransitionNoVerifySignature_CouldNotVerifyStateRoot(t *test block.Signature = sig.Marshal() block.Block.StateRoot = bytesutil.PadTo([]byte{'a'}, 32) - _, _, err = state.ExecuteStateTransitionNoVerifyAnySig(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, _, err = state.ExecuteStateTransitionNoVerifyAnySig(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.ErrorContains(t, "could not validate state root", err) } func TestProcessBlockNoVerify_PassesProcessingConditions(t *testing.T) { beaconState, block, _, _, _ := createFullBlockWithOperations(t) - set, _, err := state.ProcessBlockNoVerifyAnySig(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + set, _, err := state.ProcessBlockNoVerifyAnySig(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) // Test Signature set verifies. verified, err := set.Verify() diff --git a/beacon-chain/core/state/transition_test.go b/beacon-chain/core/state/transition_test.go index 4574a33f4d..c4bbb5cb25 100644 --- a/beacon-chain/core/state/transition_test.go +++ b/beacon-chain/core/state/transition_test.go @@ -15,11 +15,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,7 +45,7 @@ func TestExecuteStateTransition_IncorrectSlot(t *testing.T) { }, } want := "expected state.slot" - _, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.ErrorContains(t, want, err) } @@ -88,7 +88,7 @@ func TestExecuteStateTransition_FullProcess(t *testing.T) { block.Block.Body.RandaoReveal = randaoReveal block.Block.Body.Eth1Data = eth1Data - stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + stateRoot, err := state.CalculateStateRoot(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) block.Block.StateRoot = stateRoot[:] @@ -97,7 +97,7 @@ func TestExecuteStateTransition_FullProcess(t *testing.T) { require.NoError(t, err) block.Signature = sig.Marshal() - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) assert.Equal(t, params.BeaconConfig().SlotsPerEpoch, beaconState.Slot(), "Unexpected Slot number") @@ -136,7 +136,7 @@ func TestProcessBlock_IncorrectProposerSlashing(t *testing.T) { beaconState, err = state.ProcessSlots(context.Background(), beaconState, 1) require.NoError(t, err) want := "could not verify proposer slashing" - _, err = state.ProcessBlock(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ProcessBlock(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.ErrorContains(t, want, err) } @@ -163,7 +163,7 @@ func TestProcessBlock_IncorrectProcessBlockAttestations(t *testing.T) { require.NoError(t, err) want := "could not verify attestation" - _, err = state.ProcessBlock(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ProcessBlock(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) assert.ErrorContains(t, want, err) } @@ -244,7 +244,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { cp.Root = []byte("hello-world") require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp)) require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{})) - _, err = state.VerifyOperationLengths(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, 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) } @@ -425,7 +425,7 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) { beaconState, block, _, proposerSlashings, exits := createFullBlockWithOperations(t) exit := exits[0] - beaconState, err := state.ProcessBlock(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err := state.ProcessBlock(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err, "Expected block to pass processing conditions") v, err := beaconState.ValidatorAtIndex(proposerSlashings[0].Header_1.Header.ProposerIndex) @@ -617,7 +617,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { - _, err := state.ProcessBlock(context.Background(), s, interfaces.WrappedPhase0SignedBeaconBlock(blk)) + _, err := state.ProcessBlock(context.Background(), s, wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(b, err) // Reset state fields to process block again v := s.Validators() @@ -701,7 +701,7 @@ func TestProcessBlk_AttsBasedOnValidatorCount(t *testing.T) { params.OverrideBeaconConfig(config) require.NoError(t, s.SetSlot(s.Slot()+1)) - _, err = state.ProcessBlock(context.Background(), s, interfaces.WrappedPhase0SignedBeaconBlock(blk)) + _, err = state.ProcessBlock(context.Background(), s, wrapper.WrappedPhase0SignedBeaconBlock(blk)) require.NoError(t, err) } @@ -748,7 +748,7 @@ func TestProcessBlock_OverMaxProposerSlashings(t *testing.T) { } want := fmt.Sprintf("number of proposer slashings (%d) in block body exceeds allowed threshold of %d", len(b.Block.Body.ProposerSlashings), params.BeaconConfig().MaxProposerSlashings) - _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -763,7 +763,7 @@ func TestProcessBlock_OverMaxAttesterSlashings(t *testing.T) { } want := fmt.Sprintf("number of attester slashings (%d) in block body exceeds allowed threshold of %d", len(b.Block.Body.AttesterSlashings), params.BeaconConfig().MaxAttesterSlashings) - _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -777,7 +777,7 @@ func TestProcessBlock_OverMaxAttestations(t *testing.T) { } want := fmt.Sprintf("number of attestations (%d) in block body exceeds allowed threshold of %d", len(b.Block.Body.Attestations), params.BeaconConfig().MaxAttestations) - _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -792,7 +792,7 @@ func TestProcessBlock_OverMaxVoluntaryExits(t *testing.T) { } want := fmt.Sprintf("number of voluntary exits (%d) in block body exceeds allowed threshold of %d", len(b.Block.Body.VoluntaryExits), maxExits) - _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err := state.VerifyOperationLengths(context.Background(), &v1.BeaconState{}, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } @@ -812,7 +812,7 @@ func TestProcessBlock_IncorrectDeposits(t *testing.T) { } want := fmt.Sprintf("incorrect outstanding deposits in block body, wanted: %d, got: %d", s.Eth1Data().DepositCount-s.Eth1DepositIndex(), len(b.Block.Body.Deposits)) - _, err = state.VerifyOperationLengths(context.Background(), s, interfaces.WrappedPhase0SignedBeaconBlock(b)) + _, err = state.VerifyOperationLengths(context.Background(), s, wrapper.WrappedPhase0SignedBeaconBlock(b)) assert.ErrorContains(t, want, err) } diff --git a/beacon-chain/db/BUILD.bazel b/beacon-chain/db/BUILD.bazel index 30ff0d9bbd..ff4c0292d0 100644 --- a/beacon-chain/db/BUILD.bazel +++ b/beacon-chain/db/BUILD.bazel @@ -58,8 +58,8 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/db/kv:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/cmd:go_default_library", - "//shared/interfaces:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/beacon-chain/db/iface/BUILD.bazel b/beacon-chain/db/iface/BUILD.bazel index 60aed122ea..e5cfa81494 100644 --- a/beacon-chain/db/iface/BUILD.bazel +++ b/beacon-chain/db/iface/BUILD.bazel @@ -16,8 +16,8 @@ go_library( "//proto/beacon/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/backuputil:go_default_library", - "//shared/interfaces: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 d79f060ad7..b1020167dc 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -15,8 +15,8 @@ import ( "github.com/prysmaticlabs/prysm/proto/beacon/db" ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/backuputil" - "github.com/prysmaticlabs/prysm/shared/interfaces" ) // ReadOnlyDatabase defines a struct which only has read access to database methods. diff --git a/beacon-chain/db/kafka/BUILD.bazel b/beacon-chain/db/kafka/BUILD.bazel index 829aaca073..7f4a373a79 100644 --- a/beacon-chain/db/kafka/BUILD.bazel +++ b/beacon-chain/db/kafka/BUILD.bazel @@ -17,8 +17,8 @@ go_library( "//proto/beacon/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/interfaces:go_default_library", "//shared/traceutil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", diff --git a/beacon-chain/db/kafka/export_wrapper.go b/beacon-chain/db/kafka/export_wrapper.go index d19cfd53bd..d8dd395fd8 100644 --- a/beacon-chain/db/kafka/export_wrapper.go +++ b/beacon-chain/db/kafka/export_wrapper.go @@ -7,8 +7,8 @@ import ( fssz "github.com/ferranbt/fastssz" "github.com/prysmaticlabs/prysm/beacon-chain/db/iface" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" jsonpb "google.golang.org/protobuf/encoding/protojson" diff --git a/beacon-chain/db/kafka/passthrough.go b/beacon-chain/db/kafka/passthrough.go index b4dbc16675..2054ea9753 100644 --- a/beacon-chain/db/kafka/passthrough.go +++ b/beacon-chain/db/kafka/passthrough.go @@ -11,7 +11,7 @@ import ( "github.com/prysmaticlabs/prysm/proto/beacon/db" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // DatabasePath -- passthrough. diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index 31af907733..7e22d3abf1 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -42,9 +42,10 @@ go_library( "//proto/beacon/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//shared/bytesutil:go_default_library", "//shared/fileutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", "//shared/traceutil:go_default_library", @@ -94,9 +95,10 @@ go_test( "//proto/beacon/db:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//proto/testing:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/db/kv/backup_test.go b/beacon-chain/db/kv/backup_test.go index 0d02218a15..3c602723fd 100644 --- a/beacon-chain/db/kv/backup_test.go +++ b/beacon-chain/db/kv/backup_test.go @@ -8,7 +8,7 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -21,7 +21,7 @@ func TestStore_Backup(t *testing.T) { head := testutil.NewBeaconBlock() head.Block.Slot = 5000 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(head))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(head))) root, err := head.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -61,7 +61,7 @@ func TestStore_BackupMultipleBuckets(t *testing.T) { for i := startSlot; i < 5200; i++ { head := testutil.NewBeaconBlock() head.Block.Slot = i - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(head))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(head))) root, err := head.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/db/kv/blocks.go b/beacon-chain/db/kv/blocks.go index f5b6dd5281..0b7332328a 100644 --- a/beacon-chain/db/kv/blocks.go +++ b/beacon-chain/db/kv/blocks.go @@ -10,8 +10,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" bolt "go.etcd.io/bbolt" @@ -39,7 +40,7 @@ func (s *Store) Block(ctx context.Context, blockRoot [32]byte) (interfaces.Signe block = ðpb.SignedBeaconBlock{} return decode(ctx, enc, block) }) - return interfaces.WrappedPhase0SignedBeaconBlock(block), err + return wrapper.WrappedPhase0SignedBeaconBlock(block), err } // HeadBlock returns the latest canonical block in the Ethereum Beacon Chain. @@ -60,7 +61,7 @@ func (s *Store) HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, er headBlock = ðpb.SignedBeaconBlock{} return decode(ctx, enc, headBlock) }) - return interfaces.WrappedPhase0SignedBeaconBlock(headBlock), err + return wrapper.WrappedPhase0SignedBeaconBlock(headBlock), err } // Blocks retrieves a list of beacon blocks and its respective roots by filter criteria. @@ -84,7 +85,7 @@ func (s *Store) Blocks(ctx context.Context, f *filters.QueryFilter) ([]interface if err := decode(ctx, encoded, block); err != nil { return err } - blocks = append(blocks, interfaces.WrappedPhase0SignedBeaconBlock(block)) + blocks = append(blocks, wrapper.WrappedPhase0SignedBeaconBlock(block)) blockRoots = append(blockRoots, bytesutil.ToBytes32(keys[i])) } return nil @@ -156,7 +157,7 @@ func (s *Store) BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []inte if err := decode(ctx, encoded, block); err != nil { return err } - blocks = append(blocks, interfaces.WrappedPhase0SignedBeaconBlock(block)) + blocks = append(blocks, wrapper.WrappedPhase0SignedBeaconBlock(block)) } return nil }) @@ -199,7 +200,7 @@ func (s *Store) deleteBlock(ctx context.Context, blockRoot [32]byte) error { if err := decode(ctx, enc, block); err != nil { return err } - indicesByBucket := createBlockIndicesFromBlock(ctx, interfaces.WrappedPhase0BeaconBlock(block.Block)) + indicesByBucket := createBlockIndicesFromBlock(ctx, wrapper.WrappedPhase0BeaconBlock(block.Block)) if err := deleteValueForIndices(ctx, indicesByBucket, blockRoot[:], tx); err != nil { return errors.Wrap(err, "could not delete root for DB indices") } @@ -224,7 +225,7 @@ func (s *Store) deleteBlocks(ctx context.Context, blockRoots [][32]byte) error { if err := decode(ctx, enc, block); err != nil { return err } - indicesByBucket := createBlockIndicesFromBlock(ctx, interfaces.WrappedPhase0BeaconBlock(block.Block)) + indicesByBucket := createBlockIndicesFromBlock(ctx, wrapper.WrappedPhase0BeaconBlock(block.Block)) if err := deleteValueForIndices(ctx, indicesByBucket, blockRoot[:], tx); err != nil { return errors.Wrap(err, "could not delete root for DB indices") } @@ -317,7 +318,7 @@ func (s *Store) GenesisBlock(ctx context.Context) (interfaces.SignedBeaconBlock, block = ðpb.SignedBeaconBlock{} return decode(ctx, enc, block) }) - return interfaces.WrappedPhase0SignedBeaconBlock(block), err + return wrapper.WrappedPhase0SignedBeaconBlock(block), err } // SaveGenesisBlockRoot to the db. diff --git a/beacon-chain/db/kv/blocks_test.go b/beacon-chain/db/kv/blocks_test.go index 5cdf8679d1..4e332e20e7 100644 --- a/beacon-chain/db/kv/blocks_test.go +++ b/beacon-chain/db/kv/blocks_test.go @@ -8,8 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -26,7 +27,7 @@ func TestStore_SaveBlock_NoDuplicates(t *testing.T) { prevBlock := testutil.NewBeaconBlock() prevBlock.Block.Slot = slot - 1 prevBlock.Block.ParentRoot = bytesutil.PadTo([]byte{1, 2, 3}, 32) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(prevBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(prevBlock))) block := testutil.NewBeaconBlock() block.Block.Slot = slot @@ -34,7 +35,7 @@ func TestStore_SaveBlock_NoDuplicates(t *testing.T) { // Even with a full cache, saving new blocks should not cause // duplicated blocks in the DB. for i := 0; i < 100; i++ { - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) } f := filters.NewFilter().SetStartSlot(slot).SetEndSlot(slot) retrieved, _, err := db.Blocks(ctx, f) @@ -57,7 +58,7 @@ func TestStore_BlocksCRUD(t *testing.T) { retrievedBlock, err := db.Block(ctx, blockRoot) require.NoError(t, err) assert.DeepEqual(t, (*ethpb.SignedBeaconBlock)(nil), retrievedBlock.Proto(), "Expected nil block") - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) assert.Equal(t, true, db.HasBlock(ctx, blockRoot), "Expected block to exist in the db") retrievedBlock, err = db.Block(ctx, blockRoot) require.NoError(t, err) @@ -77,7 +78,7 @@ func TestStore_BlocksBatchDelete(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) if i%2 == 0 { r, err := totalBlocks[i].Block().HashTreeRoot() require.NoError(t, err) @@ -112,7 +113,7 @@ func TestStore_BlocksHandleZeroCase(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) _, err := totalBlocks[i].Block().HashTreeRoot() require.NoError(t, err) } @@ -133,7 +134,7 @@ func TestStore_BlocksHandleInvalidEndSlot(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) + 1 b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) _, err := totalBlocks[i].Block().HashTreeRoot() require.NoError(t, err) } @@ -156,7 +157,7 @@ func TestStore_GenesisBlock(t *testing.T) { blockRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, blockRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) retrievedBlock, err := db.GenesisBlock(ctx) require.NoError(t, err) assert.Equal(t, true, proto.Equal(genesisBlock, retrievedBlock.Proto()), "Wanted: %v, received: %v", genesisBlock, retrievedBlock) @@ -173,7 +174,7 @@ func TestStore_BlocksCRUD_NoCache(t *testing.T) { retrievedBlock, err := db.Block(ctx, blockRoot) require.NoError(t, err) require.DeepEqual(t, (*ethpb.SignedBeaconBlock)(nil), retrievedBlock.Proto(), "Expected nil block") - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) db.blockCache.Del(string(blockRoot[:])) assert.Equal(t, true, db.HasBlock(ctx, blockRoot), "Expected block to exist in the db") retrievedBlock, err = db.Block(ctx, blockRoot) @@ -201,11 +202,11 @@ func TestStore_Blocks_FiltersCorrectly(t *testing.T) { b8.Block.Slot = 8 b8.Block.ParentRoot = bytesutil.PadTo([]byte("parent4"), 32) blocks := []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock(b4), - interfaces.WrappedPhase0SignedBeaconBlock(b5), - interfaces.WrappedPhase0SignedBeaconBlock(b6), - interfaces.WrappedPhase0SignedBeaconBlock(b7), - interfaces.WrappedPhase0SignedBeaconBlock(b8), + wrapper.WrappedPhase0SignedBeaconBlock(b4), + wrapper.WrappedPhase0SignedBeaconBlock(b5), + wrapper.WrappedPhase0SignedBeaconBlock(b6), + wrapper.WrappedPhase0SignedBeaconBlock(b7), + wrapper.WrappedPhase0SignedBeaconBlock(b8), } ctx := context.Background() require.NoError(t, db.SaveBlocks(ctx, blocks)) @@ -284,8 +285,8 @@ func TestStore_Blocks_VerifyBlockRoots(t *testing.T) { r2, err := b2.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) filter := filters.NewFilter().SetStartSlot(b1.Block.Slot).SetEndSlot(b2.Block.Slot) roots, err := db.BlockRoots(ctx, filter) @@ -301,7 +302,7 @@ func TestStore_Blocks_Retrieve_SlotRange(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) } ctx := context.Background() require.NoError(t, db.SaveBlocks(ctx, totalBlocks)) @@ -318,7 +319,7 @@ func TestStore_Blocks_Retrieve_Epoch(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = i b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) } ctx := context.Background() require.NoError(t, db.SaveBlocks(ctx, totalBlocks)) @@ -339,7 +340,7 @@ func TestStore_Blocks_Retrieve_SlotRangeWithStep(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) b.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) } const step = 2 ctx := context.Background() @@ -358,13 +359,13 @@ func TestStore_SaveBlock_CanGetHighestAt(t *testing.T) { block1 := testutil.NewBeaconBlock() block1.Block.Slot = 1 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block1))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block1))) block2 := testutil.NewBeaconBlock() block2.Block.Slot = 10 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block2))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block2))) block3 := testutil.NewBeaconBlock() block3.Block.Slot = 100 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block3))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block3))) highestAt, err := db.HighestSlotBlocksBelow(ctx, 2) require.NoError(t, err) @@ -396,10 +397,10 @@ func TestStore_GenesisBlock_CanGetHighestAt(t *testing.T) { genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, genesisRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) block1 := testutil.NewBeaconBlock() block1.Block.Slot = 1 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block1))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block1))) highestAt, err := db.HighestSlotBlocksBelow(ctx, 2) require.NoError(t, err) @@ -421,7 +422,7 @@ func TestStore_SaveBlocks_HasCachedBlocks(t *testing.T) { blk := testutil.NewBeaconBlock() blk.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) blk.Block.Slot = types.Slot(i) - b[i] = interfaces.WrappedPhase0SignedBeaconBlock(blk) + b[i] = wrapper.WrappedPhase0SignedBeaconBlock(blk) } require.NoError(t, db.SaveBlock(ctx, b[0])) @@ -442,7 +443,7 @@ func TestStore_SaveBlocks_HasRootsMatched(t *testing.T) { blk := testutil.NewBeaconBlock() blk.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) blk.Block.Slot = types.Slot(i) - b[i] = interfaces.WrappedPhase0SignedBeaconBlock(blk) + b[i] = wrapper.WrappedPhase0SignedBeaconBlock(blk) } require.NoError(t, db.SaveBlocks(ctx, b)) @@ -465,15 +466,15 @@ func TestStore_BlocksBySlot_BlockRootsBySlot(t *testing.T) { b1 := testutil.NewBeaconBlock() b1.Block.Slot = 20 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) b2 := testutil.NewBeaconBlock() b2.Block.Slot = 100 b2.Block.ParentRoot = bytesutil.PadTo([]byte("parent1"), 32) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 100 b3.Block.ParentRoot = bytesutil.PadTo([]byte("parent2"), 32) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) r1, err := b1.Block.HashTreeRoot() require.NoError(t, err) diff --git a/beacon-chain/db/kv/checkpoint_test.go b/beacon-chain/db/kv/checkpoint_test.go index 25b3060fa6..cd4a5efb89 100644 --- a/beacon-chain/db/kv/checkpoint_test.go +++ b/beacon-chain/db/kv/checkpoint_test.go @@ -5,8 +5,8 @@ import ( "testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -53,7 +53,7 @@ func TestStore_FinalizedCheckpoint_CanSaveRetrieve(t *testing.T) { } // a valid chain is required to save finalized checkpoint. - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) st, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1)) diff --git a/beacon-chain/db/kv/finalized_block_roots.go b/beacon-chain/db/kv/finalized_block_roots.go index 5e19a32d0b..9a488a8979 100644 --- a/beacon-chain/db/kv/finalized_block_roots.go +++ b/beacon-chain/db/kv/finalized_block_roots.go @@ -8,8 +8,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" dbpb "github.com/prysmaticlabs/prysm/proto/beacon/db" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" @@ -209,5 +210,5 @@ func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (in return decode(ctx, enc, blk) }) traceutil.AnnotateError(span, err) - return interfaces.WrappedPhase0SignedBeaconBlock(blk), err + return wrapper.WrappedPhase0SignedBeaconBlock(blk), err } diff --git a/beacon-chain/db/kv/finalized_block_roots_test.go b/beacon-chain/db/kv/finalized_block_roots_test.go index cf31e18fe4..10506c3c11 100644 --- a/beacon-chain/db/kv/finalized_block_roots_test.go +++ b/beacon-chain/db/kv/finalized_block_roots_test.go @@ -6,8 +6,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -61,7 +62,7 @@ func TestStore_IsFinalizedBlockGenesis(t *testing.T) { blk.Block.Slot = 0 root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, db.SaveGenesisBlockRoot(ctx, root)) assert.Equal(t, true, db.IsFinalizedBlock(ctx, root), "Finalized genesis block doesn't exist in db") } @@ -187,7 +188,7 @@ func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []interfaces.S var err error previousRoot, err = blocks[j-i].Block.HashTreeRoot() require.NoError(t, err) - ifaceBlocks[j-i] = interfaces.WrappedPhase0SignedBeaconBlock(blocks[j-i]) + ifaceBlocks[j-i] = wrapper.WrappedPhase0SignedBeaconBlock(blocks[j-i]) } return ifaceBlocks } diff --git a/beacon-chain/db/kv/genesis.go b/beacon-chain/db/kv/genesis.go index 835b058ed4..ae95e7b70d 100644 --- a/beacon-chain/db/kv/genesis.go +++ b/beacon-chain/db/kv/genesis.go @@ -13,7 +13,7 @@ import ( 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/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -28,7 +28,7 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState iface.BeaconSt if err != nil { return errors.Wrap(err, "could not get genesis block root") } - if err := s.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk)); err != nil { + if err := s.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk)); err != nil { return errors.Wrap(err, "could not save genesis block") } if err := s.SaveState(ctx, genesisState, genesisBlkRoot); err != nil { diff --git a/beacon-chain/db/kv/state.go b/beacon-chain/db/kv/state.go index abffaed44c..5f438f4d52 100644 --- a/beacon-chain/db/kv/state.go +++ b/beacon-chain/db/kv/state.go @@ -12,8 +12,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" @@ -262,7 +262,7 @@ func slotByBlockRoot(ctx context.Context, tx *bolt.Tx, blockRoot []byte) (types. if err != nil { return 0, err } - if err := helpers.VerifyNilBeaconBlock(interfaces.WrappedPhase0SignedBeaconBlock(b)); err != nil { + if err := helpers.VerifyNilBeaconBlock(wrapper.WrappedPhase0SignedBeaconBlock(b)); err != nil { return 0, err } return b.Block.Slot, nil diff --git a/beacon-chain/db/kv/state_test.go b/beacon-chain/db/kv/state_test.go index 5c8d91e6e4..e3d29e68d6 100644 --- a/beacon-chain/db/kv/state_test.go +++ b/beacon-chain/db/kv/state_test.go @@ -8,8 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -71,7 +72,7 @@ func TestStore_StatesBatchDelete(t *testing.T) { for i := 0; i < len(totalBlocks); i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) - totalBlocks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + totalBlocks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) r, err := totalBlocks[i].Block().HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -122,7 +123,7 @@ func TestStore_DeleteFinalizedState(t *testing.T) { blk.Block.ParentRoot = genesis[:] blk.Block.Slot = 100 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) finalizedBlockRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) @@ -147,7 +148,7 @@ func TestStore_DeleteHeadState(t *testing.T) { blk := testutil.NewBeaconBlock() blk.Block.ParentRoot = genesis[:] blk.Block.Slot = 100 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) headBlockRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) @@ -167,7 +168,7 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) { b.Block.Slot = 1 r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) st, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1)) @@ -177,7 +178,7 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) { b.Block.Slot = 100 r1, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) st, err = testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(100)) @@ -187,7 +188,7 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) { b.Block.Slot = 1000 r2, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) st, err = testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1000)) @@ -221,7 +222,7 @@ func TestStore_GenesisState_CanGetHighestBelow(t *testing.T) { b.Block.Slot = 1 r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) st, err := testutil.NewBeaconState() require.NoError(t, err) @@ -258,7 +259,7 @@ func TestStore_CleanUpDirtyStates_AboveThreshold(t *testing.T) { b.Block.ParentRoot = prevRoot[:] r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) bRoots = append(bRoots, r) prevRoot = r @@ -297,7 +298,7 @@ func TestStore_CleanUpDirtyStates_Finalized(t *testing.T) { b.Block.Slot = i r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) st, err := testutil.NewBeaconState() require.NoError(t, err) @@ -325,7 +326,7 @@ func TestStore_CleanUpDirtyStates_DontDeleteNonFinalized(t *testing.T) { b.Block.Slot = i r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) unfinalizedRoots = append(unfinalizedRoots, r) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/db/restore_test.go b/beacon-chain/db/restore_test.go index d76db9799c..1b6b37a277 100644 --- a/beacon-chain/db/restore_test.go +++ b/beacon-chain/db/restore_test.go @@ -10,8 +10,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/kv" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -27,7 +27,7 @@ func TestRestore(t *testing.T) { require.NoError(t, err) head := testutil.NewBeaconBlock() head.Block.Slot = 5000 - require.NoError(t, backupDb.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(head))) + require.NoError(t, backupDb.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(head))) root, err := head.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel index 0d840fea42..bdc5494f30 100644 --- a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel @@ -31,11 +31,12 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//proto/migration:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/grpcutils:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_pkg_errors//:go_default_library", @@ -76,11 +77,12 @@ go_test( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//proto/migration:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/grpcutils:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/beacon/blocks.go b/beacon-chain/rpc/eth/v1/beacon/blocks.go index 9d562a660b..7d1c806626 100644 --- a/beacon-chain/rpc/eth/v1/beacon/blocks.go +++ b/beacon-chain/rpc/eth/v1/beacon/blocks.go @@ -11,9 +11,10 @@ import ( blockfeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/block" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/proto/migration" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -163,7 +164,7 @@ func (bs *Server) SubmitBlock(ctx context.Context, req *ethpb.BeaconBlockContain if err != nil { return nil, status.Errorf(codes.InvalidArgument, "Could not convert block to v1 block") } - v1alpha1Block := interfaces.WrappedPhase0SignedBeaconBlock(rBlock) + v1alpha1Block := wrapper.WrappedPhase0SignedBeaconBlock(rBlock) root, err := blk.HashTreeRoot() if err != nil { diff --git a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go index e1c686467a..e1de40c0ab 100644 --- a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go +++ b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go @@ -13,9 +13,10 @@ import ( p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/proto/migration" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -28,7 +29,7 @@ func fillDBTestBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) ( genBlk.Block.ParentRoot = parentRoot[:] root, err := genBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genBlk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genBlk))) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, root)) count := types.Slot(100) @@ -47,7 +48,7 @@ func fillDBTestBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) ( b.Block.Body.Attestations = []*ethpb_alpha.Attestation{att1, att2} root, err := b.Block.HashTreeRoot() require.NoError(t, err) - blks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + blks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) blkContainers[i] = ðpb_alpha.BeaconBlockContainer{Block: b, BlockRoot: root[:]} } require.NoError(t, beaconDB.SaveBlocks(ctx, blks)) @@ -73,17 +74,17 @@ func TestServer_GetBlockHeader(t *testing.T) { b2 := testutil.NewBeaconBlock() b2.Block.Slot = 30 b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 30 b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) bs := &Server{ BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, @@ -168,7 +169,7 @@ func TestServer_ListBlockHeaders(t *testing.T) { BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, @@ -177,19 +178,19 @@ func TestServer_ListBlockHeaders(t *testing.T) { b2 := testutil.NewBeaconBlock() b2.Block.Slot = 30 b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 30 b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) b4 := testutil.NewBeaconBlock() b4.Block.Slot = 31 b4.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b4))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b4))) b5 := testutil.NewBeaconBlock() b5.Block.Slot = 28 b5.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b5))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b5))) tests := []struct { name string @@ -246,7 +247,7 @@ func TestServer_ProposeBlock_OK(t *testing.T) { params.OverrideBeaconConfig(params.MainnetConfig()) genesis := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") numDeposits := uint64(64) beaconState, _ := testutil.DeterministicGenesisState(t, numDeposits) @@ -269,7 +270,7 @@ func TestServer_ProposeBlock_OK(t *testing.T) { req.Block.ParentRoot = bsRoot[:] v1Block, err := migration.V1Alpha1ToV1Block(req) require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(req))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(req))) blockReq := ðpb.BeaconBlockContainer{ Message: v1Block.Block, Signature: v1Block.Signature, @@ -288,17 +289,17 @@ func TestServer_GetBlock(t *testing.T) { b2 := testutil.NewBeaconBlock() b2.Block.Slot = 30 b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 30 b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) bs := &Server{ BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, @@ -401,13 +402,13 @@ func TestServer_GetBlockSSZ(t *testing.T) { b2 := testutil.NewBeaconBlock() b2.Block.Slot = 30 b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) bs := &Server{ BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, @@ -434,17 +435,17 @@ func TestServer_GetBlockRoot(t *testing.T) { b2 := testutil.NewBeaconBlock() b2.Block.Slot = 30 b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 30 b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) bs := &Server{ BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, @@ -535,7 +536,7 @@ func TestServer_ListBlockAttestations(t *testing.T) { BeaconDB: beaconDB, ChainInfoFetcher: &mock.ChainService{ DB: beaconDB, - Block: interfaces.WrappedPhase0SignedBeaconBlock(headBlock.Block), + Block: wrapper.WrappedPhase0SignedBeaconBlock(headBlock.Block), Root: headBlock.BlockRoot, FinalizedCheckPoint: ðpb_alpha.Checkpoint{Root: blkContainers[64].BlockRoot}, }, diff --git a/beacon-chain/rpc/eth/v1/events/BUILD.bazel b/beacon-chain/rpc/eth/v1/events/BUILD.bazel index f2d71bc31e..2ba15f7fa4 100644 --- a/beacon-chain/rpc/eth/v1/events/BUILD.bazel +++ b/beacon-chain/rpc/eth/v1/events/BUILD.bazel @@ -36,9 +36,9 @@ go_test( "//beacon-chain/core/feed/state:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//proto/migration:go_default_library", "//shared/event:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mock:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/events/events_test.go b/beacon-chain/rpc/eth/v1/events/events_test.go index b3e22fe1fa..97d1040d41 100644 --- a/beacon-chain/rpc/eth/v1/events/events_test.go +++ b/beacon-chain/rpc/eth/v1/events/events_test.go @@ -13,9 +13,9 @@ import ( statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb_v1alpha1 "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/proto/migration" "github.com/prysmaticlabs/prysm/shared/event" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/mock" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -74,7 +74,7 @@ func TestStreamEvents_BlockEvents(t *testing.T) { itemToSend: &feed.Event{ Type: blockfeed.ReceivedBlock, Data: &blockfeed.ReceivedBlockData{ - SignedBlock: interfaces.WrappedPhase0SignedBeaconBlock(wantedBlock), + SignedBlock: wrapper.WrappedPhase0SignedBeaconBlock(wantedBlock), }, }, feed: srv.BlockNotifier.BlockFeed(), diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel index ac13dfff81..be4c46123a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel @@ -39,13 +39,13 @@ go_library( "//beacon-chain/sync:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/cmd:go_default_library", "//shared/event:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/interfaces:go_default_library", "//shared/pagination:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", @@ -97,12 +97,13 @@ go_test( "//cmd/beacon-chain/flags:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bytesutil:go_default_library", "//shared/cmd:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mock:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/assignments_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/assignments_test.go index f562816757..49a7c41056 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/assignments_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/assignments_test.go @@ -13,8 +13,8 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -51,7 +51,7 @@ func TestServer_ListAssignments_NoResults(t *testing.T) { require.NoError(t, err) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot)) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go index 065a0eaed9..02c9c9ef1d 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go @@ -11,11 +11,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/pagination" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index b82fa22174..ca352624a4 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -21,11 +21,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/mock" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -92,7 +93,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) { signedBlock.Block.Body.Attestations = []*ethpb.Attestation{att} root, err := signedBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(signedBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(signedBlock))) require.NoError(t, db.SaveGenesisBlockRoot(ctx, root)) wanted := ðpb.ListAttestationsResponse{ Attestations: []*ethpb.Attestation{att}, @@ -129,7 +130,7 @@ func TestServer_ListAttestations_NoPagination(t *testing.T) { AggregationBits: bitfield.Bitlist{0b11}, }, } - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) atts = append(atts, blockExample.Block.Body.Attestations...) } @@ -157,7 +158,7 @@ func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { targetEpoch := types.Epoch(7) blocks := []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock( + wrapper.WrappedPhase0SignedBeaconBlock( testutil.HydrateSignedBeaconBlock( ðpb.SignedBeaconBlock{ Block: ðpb.BeaconBlock{ @@ -184,7 +185,7 @@ func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { }, }, })), - interfaces.WrappedPhase0SignedBeaconBlock( + wrapper.WrappedPhase0SignedBeaconBlock( testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{ Block: ðpb.BeaconBlock{ Slot: 5 + params.BeaconConfig().SlotsPerEpoch, @@ -210,7 +211,7 @@ func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { }, }, })), - interfaces.WrappedPhase0SignedBeaconBlock( + wrapper.WrappedPhase0SignedBeaconBlock( testutil.HydrateSignedBeaconBlock( ðpb.SignedBeaconBlock{ Block: ðpb.BeaconBlock{ @@ -276,7 +277,7 @@ func TestServer_ListAttestations_Pagination_CustomPageParameters(t *testing.T) { AggregationBits: bitfield.Bitlist{0b11}, }), } - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) atts = append(atts, blockExample.Block.Body.Attestations...) } } @@ -385,7 +386,7 @@ func TestServer_ListAttestations_Pagination_OutOfRange(t *testing.T) { }, }, }) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) atts = append(atts, blockExample.Block.Body.Attestations...) } @@ -436,7 +437,7 @@ func TestServer_ListAttestations_Pagination_DefaultPageSize(t *testing.T) { AggregationBits: bitfield.Bitlist{0b11}, }, } - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) atts = append(atts, blockExample.Block.Body.Attestations...) } @@ -525,7 +526,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) { AggregationBits: bitfield.NewBitlist(128 / uint64(params.BeaconConfig().SlotsPerEpoch)), }, } - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) if i%2 == 0 { atts = append(atts, blockExample.Block.Body.Attestations...) } else { @@ -630,7 +631,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) { }, }, } - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blockExample))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blockExample))) atts = append(atts, blockExample.Block.Body.Attestations...) } @@ -854,7 +855,7 @@ func TestServer_StreamIndexedAttestations_OK(t *testing.T) { numValidators := 64 headState, privKeys := testutil.DeterministicGenesisState(t, uint64(numValidators)) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot)) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go index 26af46fc65..256054a86b 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go @@ -18,9 +18,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/mock" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -93,7 +94,7 @@ func TestServer_ListBlocks_Genesis(t *testing.T) { blk.Block.ParentRoot = parentRoot[:] root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, db.SaveGenesisBlockRoot(ctx, root)) wanted := ðpb.ListBlocksResponse{ BlockContainers: []*ethpb.BeaconBlockContainer{ @@ -130,7 +131,7 @@ func TestServer_ListBlocks_Genesis_MultiBlocks(t *testing.T) { blk.Block.ParentRoot = parentRoot[:] root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, db.SaveGenesisBlockRoot(ctx, root)) count := types.Slot(100) @@ -139,7 +140,7 @@ func TestServer_ListBlocks_Genesis_MultiBlocks(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = i require.NoError(t, err) - blks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + blks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) } require.NoError(t, db.SaveBlocks(ctx, blks)) @@ -171,7 +172,7 @@ func TestServer_ListBlocks_Pagination(t *testing.T) { root, err := b.Block.HashTreeRoot() require.NoError(t, err) chain.CanonicalRoots[root] = true - blks[i] = interfaces.WrappedPhase0SignedBeaconBlock(b) + blks[i] = wrapper.WrappedPhase0SignedBeaconBlock(b) blkContainers[i] = ðpb.BeaconBlockContainer{Block: b, BlockRoot: root[:], Canonical: true} } require.NoError(t, db.SaveBlocks(ctx, blks)) @@ -180,7 +181,7 @@ func TestServer_ListBlocks_Pagination(t *testing.T) { orphanedBlk.Block.Slot = 300 orphanedBlkRoot, err := orphanedBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(orphanedBlk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(orphanedBlk))) bs := &Server{ BeaconDB: db, @@ -334,14 +335,14 @@ func TestServer_GetChainHead_NoFinalizedBlock(t *testing.T) { genBlock := testutil.NewBeaconBlock() genBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'G'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genBlock))) gRoot, err := genBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), gRoot)) bs := &Server{ BeaconDB: db, - HeadFetcher: &chainMock.ChainService{Block: interfaces.WrappedPhase0SignedBeaconBlock(genBlock), State: s}, + HeadFetcher: &chainMock.ChainService{Block: wrapper.WrappedPhase0SignedBeaconBlock(genBlock), State: s}, FinalizationFetcher: &chainMock.ChainService{ FinalizedCheckPoint: s.FinalizedCheckpoint(), CurrentJustifiedCheckPoint: s.CurrentJustifiedCheckpoint(), @@ -367,7 +368,7 @@ func TestServer_GetChainHead(t *testing.T) { db := dbTest.SetupDB(t) genBlock := testutil.NewBeaconBlock() genBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'G'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genBlock))) gRoot, err := genBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), gRoot)) @@ -375,21 +376,21 @@ func TestServer_GetChainHead(t *testing.T) { finalizedBlock := testutil.NewBeaconBlock() finalizedBlock.Block.Slot = 1 finalizedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'A'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(finalizedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(finalizedBlock))) fRoot, err := finalizedBlock.Block.HashTreeRoot() require.NoError(t, err) justifiedBlock := testutil.NewBeaconBlock() justifiedBlock.Block.Slot = 2 justifiedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'B'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(justifiedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(justifiedBlock))) jRoot, err := justifiedBlock.Block.HashTreeRoot() require.NoError(t, err) prevJustifiedBlock := testutil.NewBeaconBlock() prevJustifiedBlock.Block.Slot = 3 prevJustifiedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'C'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(prevJustifiedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(prevJustifiedBlock))) pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -407,7 +408,7 @@ func TestServer_GetChainHead(t *testing.T) { b.Block.Slot++ bs := &Server{ BeaconDB: db, - HeadFetcher: &chainMock.ChainService{Block: interfaces.WrappedPhase0SignedBeaconBlock(b), State: s}, + HeadFetcher: &chainMock.ChainService{Block: wrapper.WrappedPhase0SignedBeaconBlock(b), State: s}, FinalizationFetcher: &chainMock.ChainService{ FinalizedCheckPoint: s.FinalizedCheckpoint(), CurrentJustifiedCheckPoint: s.CurrentJustifiedCheckpoint(), @@ -457,7 +458,7 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) { params.UseMainnetConfig() genBlock := testutil.NewBeaconBlock() genBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'G'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genBlock))) gRoot, err := genBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), gRoot)) @@ -465,21 +466,21 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) { finalizedBlock := testutil.NewBeaconBlock() finalizedBlock.Block.Slot = 32 finalizedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'A'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(finalizedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(finalizedBlock))) fRoot, err := finalizedBlock.Block.HashTreeRoot() require.NoError(t, err) justifiedBlock := testutil.NewBeaconBlock() justifiedBlock.Block.Slot = 64 justifiedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'B'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(justifiedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(justifiedBlock))) jRoot, err := justifiedBlock.Block.HashTreeRoot() require.NoError(t, err) prevJustifiedBlock := testutil.NewBeaconBlock() prevJustifiedBlock.Block.Slot = 96 prevJustifiedBlock.Block.ParentRoot = bytesutil.PadTo([]byte{'C'}, 32) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(prevJustifiedBlock))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(prevJustifiedBlock))) pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -502,7 +503,7 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) { ctx := context.Background() server := &Server{ Ctx: ctx, - HeadFetcher: &chainMock.ChainService{Block: interfaces.WrappedPhase0SignedBeaconBlock(b), State: s}, + HeadFetcher: &chainMock.ChainService{Block: wrapper.WrappedPhase0SignedBeaconBlock(b), State: s}, BeaconDB: db, StateNotifier: chainService.StateNotifier(), FinalizationFetcher: &chainMock.ChainService{ @@ -630,7 +631,7 @@ func TestServer_StreamBlocks_OnHeadUpdated(t *testing.T) { for sent := 0; sent == 0; { sent = server.BlockNotifier.BlockFeed().Send(&feed.Event{ Type: blockfeed.ReceivedBlock, - Data: &blockfeed.ReceivedBlockData{SignedBlock: interfaces.WrappedPhase0SignedBeaconBlock(b)}, + Data: &blockfeed.ReceivedBlockData{SignedBlock: wrapper.WrappedPhase0SignedBeaconBlock(b)}, }) } <-exitRoutine @@ -644,7 +645,7 @@ func TestServer_StreamBlocksVerified_OnHeadUpdated(t *testing.T) { require.NoError(t, err) r, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) chainService := &chainMock.ChainService{State: beaconState} server := &Server{ Ctx: ctx, @@ -671,7 +672,7 @@ func TestServer_StreamBlocksVerified_OnHeadUpdated(t *testing.T) { for sent := 0; sent == 0; { sent = server.StateNotifier.StateFeed().Send(&feed.Event{ Type: statefeed.BlockProcessed, - Data: &statefeed.BlockProcessedData{Slot: b.Block.Slot, BlockRoot: r, SignedBlock: interfaces.WrappedPhase0SignedBeaconBlock(b)}, + Data: &statefeed.BlockProcessedData{Slot: b.Block.Slot, BlockRoot: r, SignedBlock: wrapper.WrappedPhase0SignedBeaconBlock(b)}, }) } <-exitRoutine @@ -708,7 +709,7 @@ func TestServer_GetWeakSubjectivityCheckpoint(t *testing.T) { genesisBlock := testutil.NewBeaconBlock() genesisBlockRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) require.NoError(t, db.SaveState(ctx, beaconState, genesisBlockRoot)) require.NoError(t, db.SaveGenesisBlockRoot(ctx, genesisBlockRoot)) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go index 98c30b9283..e9f6854850 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go @@ -13,7 +13,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -41,7 +41,7 @@ func TestServer_ListBeaconCommittees_CurrentEpoch(t *testing.T) { StateGen: stategen.New(db), } b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot)) @@ -86,7 +86,7 @@ func TestServer_ListBeaconCommittees_PreviousEpoch(t *testing.T) { require.NoError(t, headState.SetSlot(params.BeaconConfig().SlotsPerEpoch)) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, headState, gRoot)) @@ -157,7 +157,7 @@ func TestRetrieveCommitteesForRoot(t *testing.T) { StateGen: stategen.New(db), } b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot)) diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go index 401e13e94b..85366db231 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators_test.go @@ -22,9 +22,9 @@ import ( 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/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -106,7 +106,7 @@ func TestServer_ListValidatorBalances_NoResults(t *testing.T) { headState, err := testutil.NewBeaconState() require.NoError(t, err) b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -158,7 +158,7 @@ func TestServer_ListValidatorBalances_DefaultResponse_NoArchive(t *testing.T) { require.NoError(t, st.SetValidators(validators)) require.NoError(t, st.SetBalances(balances)) b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -523,7 +523,7 @@ func TestServer_ListValidators_OnlyActiveValidators(t *testing.T) { } b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -591,7 +591,7 @@ func TestServer_ListValidators_InactiveInTheMiddle(t *testing.T) { } b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -997,7 +997,7 @@ func TestServer_ListValidators_FromOldEpoch(t *testing.T) { require.NoError(t, st.SetSlot(20*params.BeaconConfig().SlotsPerEpoch)) require.NoError(t, st.SetValidators(validators)) b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, st, gRoot)) @@ -1066,7 +1066,7 @@ func TestServer_ListValidators_ProcessHeadStateSlots(t *testing.T) { require.NoError(t, st.SetValidators(validators)) require.NoError(t, st.SetBalances(balances)) b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, st, gRoot)) @@ -1220,7 +1220,7 @@ func TestServer_GetValidatorActiveSetChanges(t *testing.T) { require.NoError(t, err) } b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) @@ -1522,7 +1522,7 @@ func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 16 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + 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[:]})) @@ -1600,7 +1600,7 @@ func TestServer_GetValidatorParticipation_OrphanedUntilGenesis(t *testing.T) { require.NoError(t, headState.AppendPreviousEpochAttestations(atts[0])) b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + 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[:]})) @@ -1948,7 +1948,7 @@ func TestServer_GetIndividualVotes_ValidatorsDontExist(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = params.BeaconConfig().SlotsPerEpoch - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) gen := stategen.New(beaconDB) @@ -2044,7 +2044,7 @@ func TestServer_GetIndividualVotes_Working(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = params.BeaconConfig().SlotsPerEpoch - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) gen := stategen.New(beaconDB) @@ -2177,7 +2177,7 @@ func TestServer_isSlotCanonical(t *testing.T) { for i := 1; i < 100; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) br, err := b.Block.HashTreeRoot() require.NoError(t, err) if i%2 == 0 { @@ -2213,7 +2213,7 @@ func TestServer_isSlotCanonical_MultipleBlocks(t *testing.T) { for i := 1; i < 100; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) br, err := b.Block.HashTreeRoot() require.NoError(t, err) if i%2 == 0 { @@ -2222,7 +2222,7 @@ func TestServer_isSlotCanonical_MultipleBlocks(t *testing.T) { b = testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) b.Block.ProposerIndex = 100 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) } roots = append(roots, br) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel index 73553eb2e2..c853b84ccb 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/BUILD.bazel @@ -54,7 +54,7 @@ go_test( "//beacon-chain/state/stategen:go_default_library", "//proto/beacon/rpc/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go b/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go index 02c2c346a4..531be0ad59 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/block_test.go @@ -12,7 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pbrpc "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -25,7 +25,7 @@ func TestServer_GetBlock(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 100 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) blockRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) bs := &Server{ @@ -77,7 +77,7 @@ func TestServer_GetAttestationInclusionSlot(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 2 b.Block.Body.Attestations = []*ethpb.Attestation{a} - require.NoError(t, bs.BeaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, bs.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) res, err := bs.GetInclusionSlot(ctx, &pbrpc.InclusionSlotRequest{Slot: 1, Id: uint64(c[0])}) require.NoError(t, err) require.Equal(t, b.Block.Slot, res.Slot) diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/state_test.go b/beacon-chain/rpc/prysm/v1alpha1/debug/state_test.go index 738ad5299d..8fd80e80e8 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/state_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/state_test.go @@ -9,7 +9,7 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pbrpc "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -24,7 +24,7 @@ func TestServer_GetBeaconState(t *testing.T) { require.NoError(t, st.SetSlot(slot)) b := testutil.NewBeaconBlock() b.Block.Slot = slot - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) gen := stategen.New(db) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index abf007b79d..a4dee143a6 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -41,6 +41,8 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//proto/prysm/v2:go_default_library", "//shared/aggregation:go_default_library", "//shared/aggregation/attestations:go_default_library", @@ -50,7 +52,6 @@ go_library( "//shared/depositutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/rand:go_default_library", "//shared/slotutil:go_default_library", @@ -110,6 +111,7 @@ go_test( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", @@ -117,7 +119,6 @@ go_test( "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mock:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go index 996e631ad6..a3920e447a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go @@ -19,9 +19,9 @@ import ( 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/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,7 +45,7 @@ func TestProposeAttestation_OK(t *testing.T) { head := testutil.NewBeaconBlock() head.Block.Slot = 999 head.Block.ParentRoot = bytesutil.PadTo([]byte{'a'}, 32) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(head))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(head))) root, err := head.Block.HashTreeRoot() require.NoError(t, err) @@ -151,7 +151,7 @@ func TestGetAttestationData_OK(t *testing.T) { StateNotifier: chainService.StateNotifier(), } require.NoError(t, db.SaveState(ctx, beaconState, blockRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) require.NoError(t, db.SaveHeadBlockRoot(ctx, blockRoot)) req := ðpb.AttestationDataRequest{ @@ -252,7 +252,7 @@ func TestAttestationDataAtSlot_HandlesFarAwayJustifiedEpoch(t *testing.T) { StateNotifier: chainService.StateNotifier(), } require.NoError(t, db.SaveState(ctx, beaconState, blockRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) require.NoError(t, db.SaveHeadBlockRoot(ctx, blockRoot)) req := ðpb.AttestationDataRequest{ @@ -371,7 +371,7 @@ func TestServer_GetAttestationData_HeadStateSlotGreaterThanRequestSlot(t *testin require.NoError(t, err, "Could not hash beacon block") blockRoot2, err := block2.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block2))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block2))) justifiedRoot, err := justifiedBlock.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root for justified block") targetRoot, err := targetBlock.Block.HashTreeRoot() @@ -417,7 +417,7 @@ func TestServer_GetAttestationData_HeadStateSlotGreaterThanRequestSlot(t *testin StateGen: stategen.New(db), } require.NoError(t, db.SaveState(ctx, beaconState, blockRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) require.NoError(t, db.SaveHeadBlockRoot(ctx, blockRoot)) req := ðpb.AttestationDataRequest{ @@ -495,7 +495,7 @@ func TestGetAttestationData_SucceedsInFirstEpoch(t *testing.T) { StateNotifier: chainService.StateNotifier(), } require.NoError(t, db.SaveState(ctx, beaconState, blockRoot)) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block))) require.NoError(t, db.SaveHeadBlockRoot(ctx, blockRoot)) req := ðpb.AttestationDataRequest{ diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/exit_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/exit_test.go index 18d525a445..6481a21500 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/exit_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/exit_test.go @@ -16,8 +16,8 @@ import ( mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -35,7 +35,7 @@ func TestProposeExit_Notification(t *testing.T) { epoch := types.Epoch(2048) require.NoError(t, beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)))) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -106,7 +106,7 @@ func TestProposeExit_NoPanic(t *testing.T) { epoch := types.Epoch(2048) require.NoError(t, beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)))) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index 7e2150ed16..159b655717 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -21,11 +21,12 @@ import ( iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" dbpb "github.com/prysmaticlabs/prysm/proto/beacon/db" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/trieutil" @@ -130,9 +131,9 @@ func (vs *Server) GetBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb } // Compute state root with the newly constructed block. - stateRoot, err = vs.computeStateRoot(ctx, interfaces.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: blk, Signature: make([]byte, 96)})) + stateRoot, err = vs.computeStateRoot(ctx, wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: blk, Signature: make([]byte, 96)})) if err != nil { - interop.WriteBlockToDisk(interfaces.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: blk}), true /*failed*/) + interop.WriteBlockToDisk(wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: blk}), true /*failed*/) return nil, status.Errorf(codes.Internal, "Could not compute state root: %v", err) } blk.StateRoot = stateRoot @@ -143,7 +144,7 @@ func (vs *Server) GetBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb // ProposeBlock is called by a proposer during its assigned slot to create a block in an attempt // to get it processed by the beacon node as the canonical head. func (vs *Server) ProposeBlock(ctx context.Context, rBlk *ethpb.SignedBeaconBlock) (*ethpb.ProposeResponse, error) { - blk := interfaces.WrappedPhase0SignedBeaconBlock(rBlk) + blk := wrapper.WrappedPhase0SignedBeaconBlock(rBlk) root, err := blk.Block().HashTreeRoot() if err != nil { return nil, status.Errorf(codes.Internal, "Could not tree hash block: %v", err) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index 9b197f1c14..0d4022f0d3 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -23,11 +23,11 @@ import ( dbpb "github.com/prysmaticlabs/prysm/proto/beacon/db" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -48,7 +48,7 @@ func TestProposer_GetBlock_OK(t *testing.T) { require.NoError(t, err, "Could not hash genesis state") genesis := b.NewGenesisBlock(stateRoot[:]) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") parentRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -130,7 +130,7 @@ func TestProposer_GetBlock_AddsUnaggregatedAtts(t *testing.T) { require.NoError(t, err, "Could not hash genesis state") genesis := b.NewGenesisBlock(stateRoot[:]) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") parentRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -212,7 +212,7 @@ func TestProposer_ProposeBlock_OK(t *testing.T) { params.OverrideBeaconConfig(params.MainnetConfig()) genesis := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") numDeposits := uint64(64) beaconState, _ := testutil.DeterministicGenesisState(t, numDeposits) @@ -236,7 +236,7 @@ func TestProposer_ProposeBlock_OK(t *testing.T) { req := testutil.NewBeaconBlock() req.Block.Slot = 5 req.Block.ParentRoot = bsRoot[:] - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(req))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(req))) _, err = proposerServer.ProposeBlock(context.Background(), req) assert.NoError(t, err, "Could not propose block correctly") } @@ -253,7 +253,7 @@ func TestProposer_ComputeStateRoot_OK(t *testing.T) { require.NoError(t, err, "Could not hash genesis state") genesis := b.NewGenesisBlock(stateRoot[:]) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") parentRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -282,7 +282,7 @@ func TestProposer_ComputeStateRoot_OK(t *testing.T) { req.Signature, err = helpers.ComputeDomainAndSign(beaconState, currentEpoch, req.Block, params.BeaconConfig().DomainBeaconProposer, privKeys[proposerIdx]) require.NoError(t, err) - _, err = proposerServer.computeStateRoot(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(req)) + _, err = proposerServer.computeStateRoot(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(req)) require.NoError(t, err) } @@ -1819,7 +1819,7 @@ func TestProposer_FilterAttestation(t *testing.T) { params.SetupTestConfigCleanup(t) params.OverrideBeaconConfig(params.MainnetConfig()) genesis := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesis)), "Could not save genesis block") numValidators := uint64(64) state, privKeys := testutil.DeterministicGenesisState(t, numValidators) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index 42405e1489..f0dfe5b97d 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -17,10 +17,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/mock" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -65,7 +65,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) { }) require.NoError(t, err) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go index 6972726987..88318ac97a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status_test.go @@ -18,9 +18,9 @@ import ( 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/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -177,7 +177,7 @@ func TestValidatorStatus_Pending(t *testing.T) { pubKey := pubKey(1) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") // Pending active because activation epoch is still defaulted at far future slot. @@ -264,7 +264,7 @@ func TestValidatorStatus_Active(t *testing.T) { activeEpoch := helpers.ActivationExitEpoch(0) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -321,7 +321,7 @@ func TestValidatorStatus_Exiting(t *testing.T) { exitEpoch := helpers.ActivationExitEpoch(epoch) withdrawableEpoch := exitEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -382,7 +382,7 @@ func TestValidatorStatus_Slashing(t *testing.T) { slot := types.Slot(10000) epoch := helpers.SlotToEpoch(slot) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") @@ -442,7 +442,7 @@ func TestValidatorStatus_Exited(t *testing.T) { slot := types.Slot(10000) epoch := helpers.SlotToEpoch(slot) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") params.SetupTestConfigCleanup(t) @@ -619,7 +619,7 @@ func TestValidatorStatus_CorrectActivationQueue(t *testing.T) { pbKey := pubKey(5) block := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block)), "Could not save genesis block") genesisRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") currentSlot := types.Slot(5000) diff --git a/beacon-chain/rpc/statefetcher/BUILD.bazel b/beacon-chain/rpc/statefetcher/BUILD.bazel index c3c76a2605..b10a056b37 100644 --- a/beacon-chain/rpc/statefetcher/BUILD.bazel +++ b/beacon-chain/rpc/statefetcher/BUILD.bazel @@ -27,8 +27,8 @@ go_test( "//beacon-chain/state/stategen:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", diff --git a/beacon-chain/rpc/statefetcher/fetcher_test.go b/beacon-chain/rpc/statefetcher/fetcher_test.go index 22bd08863f..46037cb4ec 100644 --- a/beacon-chain/rpc/statefetcher/fetcher_test.go +++ b/beacon-chain/rpc/statefetcher/fetcher_test.go @@ -14,8 +14,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -56,7 +56,7 @@ func TestGetState(t *testing.T) { db := testDB.SetupDB(t) b := testutil.NewBeaconBlock() b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) @@ -203,7 +203,7 @@ func TestGetStateRoot(t *testing.T) { p := StateProvider{ ChainInfoFetcher: &chainMock.ChainService{ State: state, - Block: interfaces.WrappedPhase0SignedBeaconBlock(b), + Block: wrapper.WrappedPhase0SignedBeaconBlock(b), }, } @@ -215,7 +215,7 @@ func TestGetStateRoot(t *testing.T) { t.Run("genesis", func(t *testing.T) { db := testDB.SetupDB(t) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) @@ -254,7 +254,7 @@ func TestGetStateRoot(t *testing.T) { Root: root[:], } // a valid chain is required to save finalized checkpoint. - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) st, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1)) @@ -285,7 +285,7 @@ func TestGetStateRoot(t *testing.T) { Root: root[:], } // a valid chain is required to save finalized checkpoint. - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) st, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1)) @@ -334,7 +334,7 @@ func TestGetStateRoot(t *testing.T) { blk.Block.Slot = 40 root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) st, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, st.SetSlot(1)) diff --git a/beacon-chain/state/stategen/BUILD.bazel b/beacon-chain/state/stategen/BUILD.bazel index 1e4421327b..e1eb517bdd 100644 --- a/beacon-chain/state/stategen/BUILD.bazel +++ b/beacon-chain/state/stategen/BUILD.bazel @@ -27,8 +27,8 @@ go_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", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "@com_github_hashicorp_golang_lru//:go_default_library", "@com_github_pkg_errors//:go_default_library", @@ -62,8 +62,9 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces: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/stategen/getter_test.go b/beacon-chain/state/stategen/getter_test.go index 43336d8231..f664cf5ccb 100644 --- a/beacon-chain/state/stategen/getter_test.go +++ b/beacon-chain/state/stategen/getter_test.go @@ -8,8 +8,8 @@ import ( "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/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -26,13 +26,13 @@ func TestStateByRoot_ColdState(t *testing.T) { b := testutil.NewBeaconBlock() b.Block.Slot = 1 - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) bRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) beaconState, _ := testutil.DeterministicGenesisState(t, 32) require.NoError(t, beaconState.SetSlot(1)) require.NoError(t, service.beaconDB.SaveState(ctx, beaconState, bRoot)) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, bRoot)) loadedState, err := service.StateByRoot(ctx, bRoot) require.NoError(t, err) @@ -73,7 +73,7 @@ func TestStateByRoot_HotStateUsingEpochBoundaryCacheWithReplay(t *testing.T) { targetBlock.Block.Slot = 11 targetBlock.Block.ParentRoot = blkRoot[:] targetBlock.Block.ProposerIndex = 8 - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(targetBlock))) + 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[:]})) @@ -151,7 +151,7 @@ func TestStateByRootInitialSync_CanProcessUpTo(t *testing.T) { targetBlk.Block.ParentRoot = blkRoot[:] targetRoot, err := targetBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(targetBlk))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(targetBlk))) require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: targetSlot, Root: targetRoot[:]})) loadedState, err := service.StateByRootInitialSync(ctx, targetRoot) @@ -171,7 +171,7 @@ func TestStateBySlot_ColdState(t *testing.T) { genesisStateRoot, err := beaconState.HashTreeRoot(ctx) require.NoError(t, err) genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) assert.NoError(t, beaconDB.SaveState(ctx, beaconState, gRoot)) @@ -179,7 +179,7 @@ func TestStateBySlot_ColdState(t *testing.T) { b, err := testutil.GenerateFullBlock(beaconState, pks, testutil.DefaultBlockGenConfig(), 1) require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) bRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveState(ctx, beaconState, bRoot)) @@ -204,7 +204,7 @@ func TestStateBySlot_HotStateDB(t *testing.T) { genesisStateRoot, err := beaconState.HashTreeRoot(ctx) require.NoError(t, err) genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) assert.NoError(t, beaconDB.SaveState(ctx, beaconState, gRoot)) @@ -240,7 +240,7 @@ func TestLoadeStateByRoot_FinalizedState(t *testing.T) { genesisStateRoot, err := beaconState.HashTreeRoot(ctx) require.NoError(t, err) genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + 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[:]})) @@ -270,7 +270,7 @@ func TestLoadeStateByRoot_EpochBoundaryStateCanProcess(t *testing.T) { blk.Block.Slot = 11 blk.Block.ProposerIndex = 8 blk.Block.ParentRoot = gBlkRoot[:] - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + 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[:]})) @@ -296,7 +296,7 @@ func TestLoadeStateByRoot_FromDBBoundaryCase(t *testing.T) { blk.Block.Slot = 11 blk.Block.ProposerIndex = 8 blk.Block.ParentRoot = gBlkRoot[:] - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + 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[:]})) @@ -313,7 +313,7 @@ func TestLoadeStateBySlot_CanAdvanceSlotUsingDB(t *testing.T) { service := New(beaconDB) beaconState, _ := testutil.DeterministicGenesisState(t, 32) b := testutil.NewBeaconBlock() - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -335,14 +335,14 @@ func TestLoadeStateBySlot_CanReplayBlock(t *testing.T) { stateRoot, err := genesis.HashTreeRoot(ctx) require.NoError(t, err) genesisBlk := blocks.NewGenesisBlock(stateRoot[:]) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk))) genesisBlkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, genesisBlkRoot)) b1, err := testutil.GenerateFullBlock(genesis, keys, testutil.DefaultBlockGenConfig(), 1) assert.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + 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[:]})) @@ -382,10 +382,10 @@ func TestLastAncestorState_CanGetUsingDB(t *testing.T) { require.NoError(t, err) require.NoError(t, b1State.SetSlot(1)) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b0))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) require.NoError(t, service.beaconDB.SaveState(ctx, b1State, r1)) lastState, err := service.lastAncestorState(ctx, r3) @@ -422,10 +422,10 @@ func TestLastAncestorState_CanGetUsingCache(t *testing.T) { require.NoError(t, err) require.NoError(t, b1State.SetSlot(1)) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b0))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) service.hotStateCache.put(r1, b1State) lastState, err := service.lastAncestorState(ctx, r3) diff --git a/beacon-chain/state/stategen/migrate_test.go b/beacon-chain/state/stategen/migrate_test.go index 2d79bdeb2c..7281eca88f 100644 --- a/beacon-chain/state/stategen/migrate_test.go +++ b/beacon-chain/state/stategen/migrate_test.go @@ -4,12 +4,11 @@ import ( "context" "testing" - "github.com/prysmaticlabs/prysm/shared/interfaces" - 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/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -25,7 +24,7 @@ func TestMigrateToCold_CanSaveFinalizedInfo(t *testing.T) { b.Block.Slot = 1 br, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) require.NoError(t, service.epochBoundaryStateCache.put(br, beaconState)) require.NoError(t, service.MigrateToCold(ctx, br)) @@ -47,7 +46,7 @@ func TestMigrateToCold_HappyPath(t *testing.T) { b.Block.Slot = 2 fRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) require.NoError(t, service.epochBoundaryStateCache.put(fRoot, beaconState)) require.NoError(t, service.MigrateToCold(ctx, fRoot)) @@ -74,7 +73,7 @@ func TestMigrateToCold_RegeneratePath(t *testing.T) { genesisStateRoot, err := beaconState.HashTreeRoot(ctx) require.NoError(t, err) genesis := blocks.NewGenesisBlock(genesisStateRoot[:]) - assert.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(genesis))) + assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis))) gRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err) assert.NoError(t, beaconDB.SaveState(ctx, beaconState, gRoot)) @@ -84,14 +83,14 @@ func TestMigrateToCold_RegeneratePath(t *testing.T) { require.NoError(t, err) r1, err := b1.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 1, Root: r1[:]})) b4, err := testutil.GenerateFullBlock(beaconState, pks, testutil.DefaultBlockGenConfig(), 4) require.NoError(t, err) r4, err := b4.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b4))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b4))) require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 4, Root: r4[:]})) service.finalizedInfo = &finalizedInfo{ slot: 0, @@ -127,7 +126,7 @@ func TestMigrateToCold_StateExistsInDB(t *testing.T) { b.Block.Slot = 2 fRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) require.NoError(t, service.epochBoundaryStateCache.put(fRoot, beaconState)) require.NoError(t, service.beaconDB.SaveState(ctx, beaconState, fRoot)) diff --git a/beacon-chain/state/stategen/mock.go b/beacon-chain/state/stategen/mock.go index 134b5c8ada..12d39b9def 100644 --- a/beacon-chain/state/stategen/mock.go +++ b/beacon-chain/state/stategen/mock.go @@ -6,7 +6,7 @@ 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/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // MockStateManager is a fake implementation of StateManager. diff --git a/beacon-chain/state/stategen/replay.go b/beacon-chain/state/stategen/replay.go index a163634166..0ef2ebea5a 100644 --- a/beacon-chain/state/stategen/replay.go +++ b/beacon-chain/state/stategen/replay.go @@ -9,8 +9,8 @@ import ( transition "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "go.opencensus.io/trace" ) diff --git a/beacon-chain/state/stategen/replay_test.go b/beacon-chain/state/stategen/replay_test.go index 27a6a5b208..c79d66e744 100644 --- a/beacon-chain/state/stategen/replay_test.go +++ b/beacon-chain/state/stategen/replay_test.go @@ -10,8 +10,9 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -104,7 +105,7 @@ func TestReplayBlocks_LowerSlotBlock(t *testing.T) { targetSlot := beaconState.Slot() b := testutil.NewBeaconBlock() b.Block.Slot = beaconState.Slot() - 1 - newState, err := service.ReplayBlocks(context.Background(), beaconState, []interfaces.SignedBeaconBlock{interfaces.WrappedPhase0SignedBeaconBlock(b)}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []interfaces.SignedBeaconBlock{wrapper.WrappedPhase0SignedBeaconBlock(b)}, targetSlot) require.NoError(t, err) assert.Equal(t, targetSlot, newState.Slot(), "Did not advance slots") } @@ -296,7 +297,7 @@ func TestLastSavedBlock_Genesis(t *testing.T) { gBlk := testutil.NewBeaconBlock() gRoot, err := gBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(gBlk))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(gBlk))) require.NoError(t, s.beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) savedRoot, savedSlot, err := s.lastSavedBlock(ctx, 0) @@ -315,13 +316,13 @@ func TestLastSavedBlock_CanGet(t *testing.T) { b1 := testutil.NewBeaconBlock() b1.Block.Slot = s.finalizedInfo.slot + 5 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) b2 := testutil.NewBeaconBlock() b2.Block.Slot = s.finalizedInfo.slot + 10 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b3 := testutil.NewBeaconBlock() b3.Block.Slot = s.finalizedInfo.slot + 20 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) savedRoot, savedSlot, err := s.lastSavedBlock(ctx, s.finalizedInfo.slot+100) require.NoError(t, err) @@ -359,7 +360,7 @@ func TestLastSavedState_Genesis(t *testing.T) { require.NoError(t, err) gRoot, err := gBlk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(gBlk))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(gBlk))) require.NoError(t, s.beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) require.NoError(t, s.beaconDB.SaveState(ctx, gState, gRoot)) @@ -378,10 +379,10 @@ func TestLastSavedState_CanGet(t *testing.T) { b1 := testutil.NewBeaconBlock() b1.Block.Slot = s.finalizedInfo.slot + 5 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) b2 := testutil.NewBeaconBlock() b2.Block.Slot = s.finalizedInfo.slot + 10 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b2))) b2Root, err := b2.Block.HashTreeRoot() require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -391,7 +392,7 @@ func TestLastSavedState_CanGet(t *testing.T) { require.NoError(t, s.beaconDB.SaveState(ctx, st, b2Root)) b3 := testutil.NewBeaconBlock() b3.Block.Slot = s.finalizedInfo.slot + 20 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b3))) savedState, err := s.lastSavedState(ctx, s.finalizedInfo.slot+100) require.NoError(t, err) @@ -408,7 +409,7 @@ func TestLastSavedState_NoSavedBlockState(t *testing.T) { b1 := testutil.NewBeaconBlock() b1.Block.Slot = 127 - require.NoError(t, s.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, s.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1))) _, err := s.lastSavedState(ctx, s.finalizedInfo.slot+1) assert.ErrorContains(t, errUnknownState.Error(), err) @@ -490,7 +491,7 @@ func tree1(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte, beaconBlock := testutil.NewBeaconBlock() beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) - if err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { + if err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { return nil, nil, err } if err := beaconDB.SaveState(context.Background(), st.Copy(), bytesutil.ToBytes32(beaconBlock.Block.ParentRoot)); err != nil { @@ -570,7 +571,7 @@ func tree2(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte, beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) beaconBlock.Block.StateRoot = bytesutil.PadTo(b.Block.StateRoot, 32) - if err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { + if err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { return nil, nil, err } if err := beaconDB.SaveState(context.Background(), st.Copy(), bytesutil.ToBytes32(beaconBlock.Block.ParentRoot)); err != nil { @@ -643,7 +644,7 @@ func tree3(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte, beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) beaconBlock.Block.StateRoot = bytesutil.PadTo(b.Block.StateRoot, 32) - if err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { + if err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { return nil, nil, err } if err := beaconDB.SaveState(context.Background(), st.Copy(), bytesutil.ToBytes32(beaconBlock.Block.ParentRoot)); err != nil { @@ -710,7 +711,7 @@ func tree4(t *testing.T, beaconDB db.Database, genesisRoot []byte) ([][32]byte, beaconBlock.Block.Slot = b.Block.Slot beaconBlock.Block.ParentRoot = bytesutil.PadTo(b.Block.ParentRoot, 32) beaconBlock.Block.StateRoot = bytesutil.PadTo(b.Block.StateRoot, 32) - if err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { + if err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(beaconBlock)); err != nil { return nil, nil, err } if err := beaconDB.SaveState(context.Background(), st.Copy(), bytesutil.ToBytes32(beaconBlock.Block.ParentRoot)); err != nil { @@ -731,7 +732,7 @@ func TestLoadFinalizedBlocks(t *testing.T) { gBlock := testutil.NewBeaconBlock() gRoot, err := gBlock.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(gBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(gBlock))) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, [32]byte{})) roots, _, err := tree1(t, beaconDB, gRoot[:]) require.NoError(t, err) diff --git a/beacon-chain/state/stategen/service.go b/beacon-chain/state/stategen/service.go index 3dec30200b..1e64b59c17 100644 --- a/beacon-chain/state/stategen/service.go +++ b/beacon-chain/state/stategen/service.go @@ -12,8 +12,8 @@ import ( "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" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" ) diff --git a/beacon-chain/state/stategen/service_test.go b/beacon-chain/state/stategen/service_test.go index 2d12119881..c3ef2085d0 100644 --- a/beacon-chain/state/stategen/service_test.go +++ b/beacon-chain/state/stategen/service_test.go @@ -6,7 +6,7 @@ import ( testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -19,7 +19,7 @@ func TestResume(t *testing.T) { service := New(beaconDB) b := testutil.NewBeaconBlock() - require.NoError(t, service.beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) beaconState, _ := testutil.DeterministicGenesisState(t, 32) diff --git a/beacon-chain/state/stategen/setter_test.go b/beacon-chain/state/stategen/setter_test.go index 06bc55029d..9738907829 100644 --- a/beacon-chain/state/stategen/setter_test.go +++ b/beacon-chain/state/stategen/setter_test.go @@ -5,7 +5,7 @@ import ( "testing" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -123,7 +123,7 @@ func TestSaveState_NoSaveNotEpochBoundary(t *testing.T) { require.NoError(t, beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch-1)) r := [32]byte{'A'} b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) gRoot, err := b.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, gRoot)) @@ -183,7 +183,7 @@ func TestEnableSaveHotStateToDB_Disabled(t *testing.T) { service := New(beaconDB) service.saveHotStateDB.enabled = true b := testutil.NewBeaconBlock() - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b))) r, err := b.Block.HashTreeRoot() require.NoError(t, err) service.saveHotStateDB.savedStateRoots = [][32]byte{r} diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 869f6e81fd..534773ccd3 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -67,6 +67,8 @@ go_library( "//cmd/beacon-chain/flags:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//shared:go_default_library", "//shared/abool:go_default_library", "//shared/bls:go_default_library", @@ -160,6 +162,8 @@ go_test( "//cmd/beacon-chain/flags:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces: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 38d8f3397f..f2f560c628 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -29,10 +29,10 @@ go_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", "//shared:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", "//shared/rand:go_default_library", @@ -74,6 +74,7 @@ go_test( "//cmd/beacon-chain/flags:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", @@ -122,12 +123,13 @@ go_test( "//cmd/beacon-chain/flags:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/sliceutil:go_default_library", "//shared/testutil:go_default_library", diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 939d66b4eb..03ea679a17 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -16,7 +16,7 @@ import ( 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/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "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 30a440aa6f..f5836983c3 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -21,7 +21,8 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -267,7 +268,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) { genesisRoot := cache.rootCache[0] cache.RUnlock() - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go index eb81d64f44..0d4287dd19 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go @@ -12,8 +12,8 @@ import ( 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" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" "go.opencensus.io/trace" 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 76f30129a5..6061b1dd47 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils_test.go @@ -19,8 +19,8 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -164,7 +164,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { finalizedEpoch := helpers.SlotToEpoch(finalizedSlot) genesisBlock := chain1[0] - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -258,7 +258,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { require.Equal(t, curForkMoreBlocksPeer, fork.peer) // Save all chain1b blocks (so that they do not interfere with alternative fork) for _, blk := range chain1b { - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, st.SetSlot(blk.Block.Slot)) } forkSlot := types.Slot(129) @@ -295,7 +295,7 @@ func TestBlocksFetcher_findFork(t *testing.T) { // Only save is parent block exists. parentRoot := bytesutil.ToBytes32(blk.Block.ParentRoot) if beaconDB.HasBlock(ctx, parentRoot) || mc.HasInitSyncBlock(parentRoot) { - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, st.SetSlot(blk.Block.Slot)) } } @@ -314,7 +314,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) { knownBlocks := extendBlockSequence(t, []*eth.SignedBeaconBlock{}, 128) genesisBlock := knownBlocks[0] - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -339,7 +339,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) { fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false) for _, blk := range knownBlocks { - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, st.SetSlot(blk.Block.Slot)) } @@ -424,7 +424,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) { finalizedEpoch := helpers.SlotToEpoch(finalizedSlot) genesisBlock := knownBlocks[0] - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -457,7 +457,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) { p2 := p2pt.NewTestP2P(t) p2p.Connect(p2) - _, err := fetcher.findAncestor(ctx, p2.PeerID(), interfaces.WrappedPhase0SignedBeaconBlock(knownBlocks[4])) + _, err := fetcher.findAncestor(ctx, p2.PeerID(), wrapper.WrappedPhase0SignedBeaconBlock(knownBlocks[4])) assert.ErrorContains(t, "protocol not supported", err) }) @@ -469,7 +469,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) { assert.NoError(t, stream.Close()) }) - fork, err := fetcher.findAncestor(ctx, p2.PeerID(), interfaces.WrappedPhase0SignedBeaconBlock(knownBlocks[4])) + fork, err := fetcher.findAncestor(ctx, p2.PeerID(), wrapper.WrappedPhase0SignedBeaconBlock(knownBlocks[4])) assert.ErrorContains(t, "no common ancestor found", err) assert.Equal(t, (*forkData)(nil), fork) }) diff --git a/beacon-chain/sync/initial-sync/blocks_queue.go b/beacon-chain/sync/initial-sync/blocks_queue.go index 757565f317..9506a7fa03 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue.go +++ b/beacon-chain/sync/initial-sync/blocks_queue.go @@ -11,7 +11,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/sirupsen/logrus" ) diff --git a/beacon-chain/sync/initial-sync/blocks_queue_test.go b/beacon-chain/sync/initial-sync/blocks_queue_test.go index 8cfd0582e6..d27c3984a3 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue_test.go +++ b/beacon-chain/sync/initial-sync/blocks_queue_test.go @@ -17,8 +17,9 @@ import ( beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -525,8 +526,8 @@ func TestBlocksQueue_onDataReceivedEvent(t *testing.T) { response := &fetchRequestResponse{ pid: "abc", blocks: []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), - interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), + wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), + wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), }, } fsm := &stateMachine{ @@ -621,7 +622,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.machines[256].state = stateDataParsed queue.smm.machines[256].pid = pidDataParsed queue.smm.machines[256].blocks = []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), + wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } handlerFn := queue.onReadyToSendEvent(ctx) @@ -651,7 +652,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.machines[320].state = stateDataParsed queue.smm.machines[320].pid = pidDataParsed queue.smm.machines[320].blocks = []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), + wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } handlerFn := queue.onReadyToSendEvent(ctx) @@ -678,7 +679,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.machines[320].state = stateDataParsed queue.smm.machines[320].pid = pidDataParsed queue.smm.machines[320].blocks = []interfaces.SignedBeaconBlock{ - interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), + wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } handlerFn := queue.onReadyToSendEvent(ctx) @@ -1037,7 +1038,7 @@ func TestBlocksQueue_stuckInUnfavourableFork(t *testing.T) { finalizedEpoch := helpers.SlotToEpoch(finalizedSlot) genesisBlock := chain1[0] - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -1077,7 +1078,7 @@ func TestBlocksQueue_stuckInUnfavourableFork(t *testing.T) { parentRoot := bytesutil.ToBytes32(blk.Block.ParentRoot) // Save block only if parent root is already in database or cache. if beaconDB.HasBlock(ctx, parentRoot) || mc.HasInitSyncBlock(parentRoot) { - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, st.SetSlot(blk.Block.Slot)) } } @@ -1236,7 +1237,7 @@ func TestBlocksQueue_stuckWhenHeadIsSetToOrphanedBlock(t *testing.T) { finalizedEpoch := helpers.SlotToEpoch(finalizedSlot) genesisBlock := chain[0] - require.NoError(t, beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlock))) + require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlock))) genesisRoot, err := genesisBlock.Block.HashTreeRoot() require.NoError(t, err) @@ -1257,7 +1258,7 @@ func TestBlocksQueue_stuckWhenHeadIsSetToOrphanedBlock(t *testing.T) { parentRoot := bytesutil.ToBytes32(blk.Block.ParentRoot) // Save block only if parent root is already in database or cache. if beaconDB.HasBlock(ctx, parentRoot) || mc.HasInitSyncBlock(parentRoot) { - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, st.SetSlot(blk.Block.Slot)) } } @@ -1269,7 +1270,7 @@ func TestBlocksQueue_stuckWhenHeadIsSetToOrphanedBlock(t *testing.T) { orphanedBlock := testutil.NewBeaconBlock() orphanedBlock.Block.Slot = 85 orphanedBlock.Block.StateRoot = testutil.Random32Bytes(t) - require.NoError(t, beaconDB.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(orphanedBlock))) + require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(orphanedBlock))) require.NoError(t, st.SetSlot(orphanedBlock.Block.Slot)) require.Equal(t, types.Slot(85), mc.HeadSlot()) diff --git a/beacon-chain/sync/initial-sync/fsm.go b/beacon-chain/sync/initial-sync/fsm.go index 691e4b8b15..9279e2a9fa 100644 --- a/beacon-chain/sync/initial-sync/fsm.go +++ b/beacon-chain/sync/initial-sync/fsm.go @@ -9,7 +9,7 @@ import ( "github.com/libp2p/go-libp2p-core/peer" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/timeutils" ) diff --git a/beacon-chain/sync/initial-sync/initial_sync_test.go b/beacon-chain/sync/initial-sync/initial_sync_test.go index fb0bdaab0b..a49f8ffaa8 100644 --- a/beacon-chain/sync/initial-sync/initial_sync_test.go +++ b/beacon-chain/sync/initial-sync/initial_sync_test.go @@ -23,10 +23,10 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/hashutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -83,7 +83,7 @@ func initializeTestServices(t *testing.T, slots []types.Slot, peers []*peerData) genesisRoot := cache.rootCache[0] cache.RUnlock() - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index 59391a99b2..1f761e7572 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -13,8 +13,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/sirupsen/logrus" ) diff --git a/beacon-chain/sync/initial-sync/round_robin_test.go b/beacon-chain/sync/initial-sync/round_robin_test.go index ba55349d03..f9ffa7adfe 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -11,8 +11,9 @@ import ( dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/abool" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -282,7 +283,7 @@ func TestService_roundRobinSync(t *testing.T) { genesisRoot := cache.rootCache[0] cache.RUnlock() - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -323,7 +324,7 @@ func TestService_processBlock(t *testing.T) { genesisBlk := testutil.NewBeaconBlock() genesisBlkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) - err = beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk)) + err = beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk)) require.NoError(t, err) st, err := testutil.NewBeaconState() require.NoError(t, err) @@ -354,7 +355,7 @@ func TestService_processBlock(t *testing.T) { blk2.Block.ParentRoot = blk1Root[:] // Process block normally. - err = s.processBlock(ctx, genesis, interfaces.WrappedPhase0SignedBeaconBlock(blk1), func( + err = s.processBlock(ctx, genesis, wrapper.WrappedPhase0SignedBeaconBlock(blk1), func( ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlock(ctx, block, blockRoot)) return nil @@ -362,14 +363,14 @@ func TestService_processBlock(t *testing.T) { assert.NoError(t, err) // Duplicate processing should trigger error. - err = s.processBlock(ctx, genesis, interfaces.WrappedPhase0SignedBeaconBlock(blk1), func( + err = s.processBlock(ctx, genesis, wrapper.WrappedPhase0SignedBeaconBlock(blk1), func( ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { return nil }) assert.ErrorContains(t, errBlockAlreadyProcessed.Error(), err) // Continue normal processing, should proceed w/o errors. - err = s.processBlock(ctx, genesis, interfaces.WrappedPhase0SignedBeaconBlock(blk2), func( + err = s.processBlock(ctx, genesis, wrapper.WrappedPhase0SignedBeaconBlock(blk2), func( ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlock(ctx, block, blockRoot)) return nil @@ -384,7 +385,7 @@ func TestService_processBlockBatch(t *testing.T) { genesisBlk := testutil.NewBeaconBlock() genesisBlkRoot, err := genesisBlk.Block.HashTreeRoot() require.NoError(t, err) - err = beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(genesisBlk)) + err = beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(genesisBlk)) require.NoError(t, err) st, err := testutil.NewBeaconState() require.NoError(t, err) @@ -414,9 +415,9 @@ func TestService_processBlockBatch(t *testing.T) { blk1.Block.ParentRoot = parentRoot[:] blk1Root, err := blk1.Block.HashTreeRoot() require.NoError(t, err) - err = beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk1)) + err = beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk1)) require.NoError(t, err) - batch = append(batch, interfaces.WrappedPhase0SignedBeaconBlock(blk1)) + batch = append(batch, wrapper.WrappedPhase0SignedBeaconBlock(blk1)) currBlockRoot = blk1Root } @@ -428,9 +429,9 @@ func TestService_processBlockBatch(t *testing.T) { blk1.Block.ParentRoot = parentRoot[:] blk1Root, err := blk1.Block.HashTreeRoot() require.NoError(t, err) - err = beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk1)) + err = beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk1)) require.NoError(t, err) - batch2 = append(batch2, interfaces.WrappedPhase0SignedBeaconBlock(blk1)) + batch2 = append(batch2, wrapper.WrappedPhase0SignedBeaconBlock(blk1)) currBlockRoot = blk1Root } @@ -512,7 +513,7 @@ func TestService_blockProviderScoring(t *testing.T) { genesisRoot := cache.rootCache[0] cache.RUnlock() - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) st, err := testutil.NewBeaconState() @@ -576,7 +577,7 @@ func TestService_syncToFinalizedEpoch(t *testing.T) { genesisRoot := cache.rootCache[0] cache.RUnlock() - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) st, err := testutil.NewBeaconState() diff --git a/beacon-chain/sync/initial-sync/service_test.go b/beacon-chain/sync/initial-sync/service_test.go index f356abee97..42bec2fc6c 100644 --- a/beacon-chain/sync/initial-sync/service_test.go +++ b/beacon-chain/sync/initial-sync/service_test.go @@ -16,9 +16,9 @@ import ( p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/event" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -372,7 +372,7 @@ func TestService_Resync(t *testing.T) { }, p.Peers()) cache.initializeRootCache(makeSequence(1, 160), t) beaconDB := dbtest.SetupDB(t) - err := beaconDB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) + err := beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock())) require.NoError(t, err) cache.RLock() genesisRoot := cache.rootCache[0] diff --git a/beacon-chain/sync/pending_attestations_queue_test.go b/beacon-chain/sync/pending_attestations_queue_test.go index 03a9d03397..e62b01e3e9 100644 --- a/beacon-chain/sync/pending_attestations_queue_test.go +++ b/beacon-chain/sync/pending_attestations_queue_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/prysmaticlabs/prysm/shared/interfaces" - "github.com/ethereum/go-ethereum/p2p/enr" lru "github.com/hashicorp/golang-lru" "github.com/libp2p/go-libp2p-core/network" @@ -20,6 +18,7 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -64,7 +63,7 @@ func TestProcessPendingAtts_HasBlockSaveUnAggregatedAtt(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, validators) sb := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(sb))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(sb))) root, err := sb.Block.HashTreeRoot() require.NoError(t, err) @@ -128,7 +127,7 @@ func TestProcessPendingAtts_HasBlockSaveUnAggregatedAtt(t *testing.T) { sb = testutil.NewBeaconBlock() r32, err := sb.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(sb))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(sb))) s, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, r.cfg.DB.SaveState(context.Background(), s, r32)) @@ -173,7 +172,7 @@ func TestProcessPendingAtts_NoBroadcastWithBadSignature(t *testing.T) { b := testutil.NewBeaconBlock() r32, err := b.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) require.NoError(t, r.cfg.DB.SaveState(context.Background(), s, r32)) r.blkRootToPendingAtts[r32] = []*ethpb.SignedAggregateAttestationAndProof{{Message: a, Signature: make([]byte, 96)}} @@ -257,7 +256,7 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, validators) sb := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(sb))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(sb))) root, err := sb.Block.HashTreeRoot() require.NoError(t, err) @@ -325,7 +324,7 @@ func TestProcessPendingAtts_HasBlockSaveAggregatedAtt(t *testing.T) { sb = testutil.NewBeaconBlock() r32, err := sb.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(sb))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(sb))) s, err := testutil.NewBeaconState() require.NoError(t, err) require.NoError(t, r.cfg.DB.SaveState(context.Background(), s, r32)) diff --git a/beacon-chain/sync/pending_blocks_queue.go b/beacon-chain/sync/pending_blocks_queue.go index 908771612f..0e0503dacc 100644 --- a/beacon-chain/sync/pending_blocks_queue.go +++ b/beacon-chain/sync/pending_blocks_queue.go @@ -11,8 +11,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/runutil" diff --git a/beacon-chain/sync/pending_blocks_queue_test.go b/beacon-chain/sync/pending_blocks_queue_test.go index d25cdb9ef5..08faa9d7aa 100644 --- a/beacon-chain/sync/pending_blocks_queue_test.go +++ b/beacon-chain/sync/pending_blocks_queue_test.go @@ -21,8 +21,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/copyutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -56,13 +56,13 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks1(t *testing.T) { require.NoError(t, err) b0 := testutil.NewBeaconBlock() - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b0))) b0Root, err := b0.Block.HashTreeRoot() require.NoError(t, err) b3 := testutil.NewBeaconBlock() b3.Block.Slot = 3 b3.Block.ParentRoot = b0Root[:] - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b3))) // Incomplete block link b1 := testutil.NewBeaconBlock() b1.Block.Slot = 1 @@ -76,18 +76,18 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks1(t *testing.T) { require.NoError(t, err) // Add b2 to the cache - require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b2), b2Root)) + require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b2), b2Root)) require.NoError(t, r.processPendingBlocks(context.Background())) assert.Equal(t, 1, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache") assert.Equal(t, 1, len(r.seenPendingBlocks), "Incorrect size for seen pending block") // Add b1 to the cache - require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b1), b1Root)) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b1), b1Root)) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b1))) // Insert bad b1 in the cache to verify the good one doesn't get replaced. - require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), [32]byte{})) + require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), [32]byte{})) require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run @@ -119,7 +119,7 @@ func TestRegularSync_InsertDuplicateBlocks(t *testing.T) { b0 := testutil.NewBeaconBlock() b0r := [32]byte{'a'} - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b0))) b0Root, err := b0.Block.HashTreeRoot() require.NoError(t, err) b1 := testutil.NewBeaconBlock() @@ -127,18 +127,18 @@ func TestRegularSync_InsertDuplicateBlocks(t *testing.T) { b1.Block.ParentRoot = b0Root[:] b1r := [32]byte{'b'} - require.NoError(t, r.insertBlockToPendingQueue(b0.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b0), b0r)) + require.NoError(t, r.insertBlockToPendingQueue(b0.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b0), b0r)) require.Equal(t, 1, len(r.pendingBlocksInCache(b0.Block.Slot)), "Block was not added to map") - require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b1), b1r)) + require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b1), b1r)) require.Equal(t, 1, len(r.pendingBlocksInCache(b1.Block.Slot)), "Block was not added to map") // Add duplicate block which should not be saved. - require.NoError(t, r.insertBlockToPendingQueue(b0.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b0), b0r)) + require.NoError(t, r.insertBlockToPendingQueue(b0.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b0), b0r)) require.Equal(t, 1, len(r.pendingBlocksInCache(b0.Block.Slot)), "Block was added to map") // Add duplicate block which should not be saved. - require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b1), b1r)) + require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b1), b1r)) require.Equal(t, 1, len(r.pendingBlocksInCache(b1.Block.Slot)), "Block was added to map") } @@ -191,13 +191,13 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin p1.Peers().SetChainState(p2.PeerID(), &pb.Status{}) b0 := testutil.NewBeaconBlock() - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b0))) b0Root, err := b0.Block.HashTreeRoot() require.NoError(t, err) b1 := testutil.NewBeaconBlock() b1.Block.Slot = 1 b1.Block.ParentRoot = b0Root[:] - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b1))) b1Root, err := b1.Block.HashTreeRoot() require.NoError(t, err) @@ -223,8 +223,8 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin b4Root, err := b4.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, r.insertBlockToPendingQueue(b4.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b4), b4Root)) - require.NoError(t, r.insertBlockToPendingQueue(b5.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b5), b5Root)) + require.NoError(t, r.insertBlockToPendingQueue(b4.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b4), b4Root)) + require.NoError(t, r.insertBlockToPendingQueue(b5.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b5), b5Root)) require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run @@ -233,8 +233,8 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin assert.Equal(t, 2, len(r.seenPendingBlocks), "Incorrect size for seen pending block") // Add b3 to the cache - require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b3), b3Root)) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b3))) + require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b3), b3Root)) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b3))) require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run @@ -243,9 +243,9 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks_2Chains(t *testin assert.Equal(t, 3, len(r.seenPendingBlocks), "Incorrect size for seen pending block") // Add b2 to the cache - require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b2), b2Root)) + require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b2), b2Root)) - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b2))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b2))) require.NoError(t, r.processPendingBlocks(context.Background())) // Marks a block as bad require.NoError(t, r.processPendingBlocks(context.Background())) // Bad block removed on second run @@ -282,13 +282,13 @@ func TestRegularSyncBeaconBlockSubscriber_PruneOldPendingBlocks(t *testing.T) { p1.Peers().SetChainState(p1.PeerID(), &pb.Status{}) b0 := testutil.NewBeaconBlock() - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b0))) b0Root, err := b0.Block.HashTreeRoot() require.NoError(t, err) b1 := testutil.NewBeaconBlock() b1.Block.Slot = 1 b1.Block.ParentRoot = b0Root[:] - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b1))) b1Root, err := b1.Block.HashTreeRoot() require.NoError(t, err) @@ -314,10 +314,10 @@ func TestRegularSyncBeaconBlockSubscriber_PruneOldPendingBlocks(t *testing.T) { b4Root, err := b4.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b2), b2Root)) - require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b3), b3Root)) - require.NoError(t, r.insertBlockToPendingQueue(b4.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b4), b4Root)) - require.NoError(t, r.insertBlockToPendingQueue(b5.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b5), b5Root)) + require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b2), b2Root)) + require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b3), b3Root)) + require.NoError(t, r.insertBlockToPendingQueue(b4.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b4), b4Root)) + require.NoError(t, r.insertBlockToPendingQueue(b5.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b5), b5Root)) require.NoError(t, r.processPendingBlocks(context.Background())) assert.Equal(t, 0, len(r.slotToPendingBlocks.Items()), "Incorrect size for slot to pending blocks cache") @@ -331,10 +331,10 @@ func TestService_sortedPendingSlots(t *testing.T) { } var lastSlot types.Slot = math.MaxUint64 - require.NoError(t, r.insertBlockToPendingQueue(lastSlot, interfaces.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot}})), [32]byte{1})) - require.NoError(t, r.insertBlockToPendingQueue(lastSlot-3, interfaces.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 3}})), [32]byte{2})) - require.NoError(t, r.insertBlockToPendingQueue(lastSlot-5, interfaces.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 5}})), [32]byte{3})) - require.NoError(t, r.insertBlockToPendingQueue(lastSlot-2, interfaces.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 2}})), [32]byte{4})) + require.NoError(t, r.insertBlockToPendingQueue(lastSlot, wrapper.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot}})), [32]byte{1})) + require.NoError(t, r.insertBlockToPendingQueue(lastSlot-3, wrapper.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 3}})), [32]byte{2})) + require.NoError(t, r.insertBlockToPendingQueue(lastSlot-5, wrapper.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 5}})), [32]byte{3})) + require.NoError(t, r.insertBlockToPendingQueue(lastSlot-2, wrapper.WrappedPhase0SignedBeaconBlock(testutil.HydrateSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: lastSlot - 2}})), [32]byte{4})) want := []types.Slot{lastSlot - 5, lastSlot - 3, lastSlot - 2, lastSlot} assert.DeepEqual(t, want, r.sortedPendingSlots(), "Unexpected pending slots list") @@ -369,13 +369,13 @@ func TestService_BatchRootRequest(t *testing.T) { p1.Peers().SetChainState(p2.PeerID(), &pb.Status{FinalizedEpoch: 2}) b0 := testutil.NewBeaconBlock() - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b0))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b0))) b0Root, err := b0.Block.HashTreeRoot() require.NoError(t, err) b1 := testutil.NewBeaconBlock() b1.Block.Slot = 1 b1.Block.ParentRoot = b0Root[:] - require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b1))) + require.NoError(t, r.cfg.DB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b1))) b1Root, err := b1.Block.HashTreeRoot() require.NoError(t, err) @@ -442,13 +442,13 @@ func TestService_AddPeningBlockToQueueOverMax(t *testing.T) { b1.Block.StateRoot = []byte{'a'} b2 := copyutil.CopySignedBeaconBlock(b) b2.Block.StateRoot = []byte{'b'} - require.NoError(t, r.insertBlockToPendingQueue(0, interfaces.WrappedPhase0SignedBeaconBlock(b), [32]byte{})) - require.NoError(t, r.insertBlockToPendingQueue(0, interfaces.WrappedPhase0SignedBeaconBlock(b1), [32]byte{1})) - require.NoError(t, r.insertBlockToPendingQueue(0, interfaces.WrappedPhase0SignedBeaconBlock(b2), [32]byte{2})) + require.NoError(t, r.insertBlockToPendingQueue(0, wrapper.WrappedPhase0SignedBeaconBlock(b), [32]byte{})) + require.NoError(t, r.insertBlockToPendingQueue(0, wrapper.WrappedPhase0SignedBeaconBlock(b1), [32]byte{1})) + require.NoError(t, r.insertBlockToPendingQueue(0, wrapper.WrappedPhase0SignedBeaconBlock(b2), [32]byte{2})) b3 := copyutil.CopySignedBeaconBlock(b) b3.Block.StateRoot = []byte{'c'} - require.NoError(t, r.insertBlockToPendingQueue(0, interfaces.WrappedPhase0SignedBeaconBlock(b2), [32]byte{3})) + require.NoError(t, r.insertBlockToPendingQueue(0, wrapper.WrappedPhase0SignedBeaconBlock(b2), [32]byte{3})) require.Equal(t, maxBlocksPerSlot, len(r.pendingBlocksInCache(0))) } @@ -476,7 +476,7 @@ func TestService_ProcessPendingBlockOnCorrectSlot(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -513,11 +513,11 @@ func TestService_ProcessPendingBlockOnCorrectSlot(t *testing.T) { require.NoError(t, err) // Add block1 for slot1 - require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b1), b1Root)) + require.NoError(t, r.insertBlockToPendingQueue(b1.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b1), b1Root)) // Add block2 for slot2 - require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b2), b2Root)) + require.NoError(t, r.insertBlockToPendingQueue(b2.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b2), b2Root)) // Add block3 for slot3 - require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, interfaces.WrappedPhase0SignedBeaconBlock(b3), b3Root)) + require.NoError(t, r.insertBlockToPendingQueue(b3.Block.Slot, wrapper.WrappedPhase0SignedBeaconBlock(b3), b3Root)) // processPendingBlocks should process only blocks of the current slot. i.e. slot 1. // Then check if the other two blocks are still in the pendingQueue. diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range.go b/beacon-chain/sync/rpc_beacon_blocks_by_range.go index 791939d184..59f8123195 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range.go @@ -4,8 +4,6 @@ import ( "context" "time" - "github.com/prysmaticlabs/prysm/shared/interfaces" - libp2pcore "github.com/libp2p/go-libp2p-core" "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" @@ -13,6 +11,7 @@ import ( 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" "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 e1753e66e9..428061d6d6 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go @@ -22,8 +22,8 @@ import ( "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -48,7 +48,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsBlocks(t *testing.T) { for i := req.StartSlot; i < req.StartSlot.Add(req.Step*req.Count); i += types.Slot(req.Step) { blk := testutil.NewBeaconBlock() blk.Block.Slot = i - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } // Start service with 160 as allowed blocks capacity (and almost zero capacity recovery). @@ -109,7 +109,7 @@ func TestRPCBeaconBlocksByRange_ReturnCorrectNumberBack(t *testing.T) { require.NoError(t, err) genRoot = rt } - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } require.NoError(t, d.SaveGenesisBlockRoot(context.Background(), genRoot)) @@ -173,7 +173,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsSortedBlocks(t *testing.T) { rt, err := blk.Block.HashTreeRoot() require.NoError(t, err) expectedRoots[j] = rt - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) j-- } @@ -239,7 +239,7 @@ func TestRPCBeaconBlocksByRange_ReturnsGenesisBlock(t *testing.T) { if i == 0 { require.NoError(t, d.SaveGenesisBlockRoot(context.Background(), rt)) } - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) prevRoot = rt } @@ -284,7 +284,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) { if req.Step == 1 { block.Block.ParentRoot = parentRoot[:] } - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(block))) rt, err := block.Block.HashTreeRoot() require.NoError(t, err) parentRoot = rt @@ -543,7 +543,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) { block := testutil.NewBeaconBlock() block.Block.Slot = i block.Block.ParentRoot = parentRoot[:] - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(block))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(block))) rt, err := block.Block.HashTreeRoot() require.NoError(t, err) parentRoot = rt @@ -618,7 +618,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { previousRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, d.SaveGenesisBlockRoot(context.Background(), previousRoot)) blocks := make([]*ethpb.SignedBeaconBlock, req.Count) // Populate the database with blocks that would match the request. @@ -631,7 +631,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { var err error previousRoot, err = blocks[j].Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blocks[j]))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blocks[j]))) j++ } stateSummaries := make([]*pb.StateSummary, len(blocks)) @@ -664,7 +664,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { require.NoError(t, err) genRoot := previousRoot - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, d.SaveGenesisBlockRoot(context.Background(), previousRoot)) blocks := make([]*ethpb.SignedBeaconBlock, req.Count) // Populate the database with blocks with non linear roots. @@ -681,7 +681,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { var err error previousRoot, err = blocks[j].Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blocks[j]))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blocks[j]))) j++ } stateSummaries := make([]*pb.StateSummary, len(blocks)) diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_root.go b/beacon-chain/sync/rpc_beacon_blocks_by_root.go index f71bed12f4..c4c091ee08 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_root.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_root.go @@ -3,12 +3,11 @@ package sync import ( "context" - "github.com/prysmaticlabs/prysm/shared/interfaces" - libp2pcore "github.com/libp2p/go-libp2p-core" "github.com/libp2p/go-libp2p-core/peer" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" ) diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_root_test.go b/beacon-chain/sync/rpc_beacon_blocks_by_root_test.go index 36b1fdf82b..493dc018de 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_root_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_root_test.go @@ -18,7 +18,7 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -39,7 +39,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks(t *testing.T) { blk.Block.Slot = i root, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, d.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, d.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) blkRoots = append(blkRoots, root) } diff --git a/beacon-chain/sync/rpc_chunked_response.go b/beacon-chain/sync/rpc_chunked_response.go index 87e9ca9b09..282b54f1e9 100644 --- a/beacon-chain/sync/rpc_chunked_response.go +++ b/beacon-chain/sync/rpc_chunked_response.go @@ -8,7 +8,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // chunkWriter writes the given message as a chunked response to the given network @@ -43,7 +44,7 @@ func ReadChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetche if err := readResponseChunk(stream, chain, p2p, blk); err != nil { return nil, err } - return interfaces.WrappedPhase0SignedBeaconBlock(blk), nil + return wrapper.WrappedPhase0SignedBeaconBlock(blk), nil } // readFirstChunkedBlock reads the first chunked block and applies the appropriate deadlines to @@ -63,7 +64,7 @@ func readFirstChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoF return nil, err } err = p2p.Encoding().DecodeWithMaxLength(stream, blk) - return interfaces.WrappedPhase0SignedBeaconBlock(blk), err + return wrapper.WrappedPhase0SignedBeaconBlock(blk), err } // readResponseChunk reads the response from the stream and decodes it into the diff --git a/beacon-chain/sync/rpc_send_request.go b/beacon-chain/sync/rpc_send_request.go index b1286ec777..07607dc8e1 100644 --- a/beacon-chain/sync/rpc_send_request.go +++ b/beacon-chain/sync/rpc_send_request.go @@ -11,7 +11,7 @@ import ( "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/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "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 87662462bd..f58ee7422a 100644 --- a/beacon-chain/sync/rpc_send_request_test.go +++ b/beacon-chain/sync/rpc_send_request_test.go @@ -15,7 +15,8 @@ import ( p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -63,7 +64,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { for i := req.StartSlot; i < req.StartSlot.Add(req.Count*req.Step); i += types.Slot(req.Step) { if processor != nil { - if processorErr := processor(interfaces.WrappedPhase0SignedBeaconBlock(knownBlocks[i])); processorErr != nil { + if processorErr := processor(wrapper.WrappedPhase0SignedBeaconBlock(knownBlocks[i])); processorErr != nil { if errors.Is(processorErr, io.EOF) { // Close stream, w/o any errors written. return @@ -326,7 +327,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { for _, root := range *req { if blk, ok := knownBlocks[root]; ok { if processor != nil { - if processorErr := processor(interfaces.WrappedPhase0SignedBeaconBlock(blk)); processorErr != nil { + if processorErr := processor(wrapper.WrappedPhase0SignedBeaconBlock(blk)); processorErr != nil { if errors.Is(processorErr, io.EOF) { // Close stream, w/o any errors written. return diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index 8f0b5dc65d..fc8d7218f6 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -22,6 +22,8 @@ import ( 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/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + interfaces2 "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" @@ -176,7 +178,7 @@ func TestStatusRPCHandler_ReturnsHelloMessage(t *testing.T) { require.NoError(t, err) require.NoError(t, genesisState.SetSlot(111)) require.NoError(t, genesisState.UpdateBlockRootAtIndex(111%uint64(params.BeaconConfig().SlotsPerHistoricalRoot), headRoot)) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(finalized))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(finalized))) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), finalizedRoot)) finalizedCheckpt := ðpb.Checkpoint{ Epoch: 3, @@ -266,7 +268,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) { require.NoError(t, err) blk := testutil.NewBeaconBlock() blk.Block.Slot = 0 - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) finalizedRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), finalizedRoot)) @@ -478,7 +480,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) { require.NoError(t, genesisState.UpdateBlockRootAtIndex(111%uint64(params.BeaconConfig().SlotsPerHistoricalRoot), headRoot)) blk := testutil.NewBeaconBlock() blk.Block.Slot = blkSlot - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), finalizedRoot)) finalizedCheckpt := ðpb.Checkpoint{ Epoch: 3, @@ -559,7 +561,7 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) { genRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), genRoot)) blocksTillHead := makeBlocks(t, 1, 1000, genRoot) require.NoError(t, db.SaveBlocks(context.Background(), blocksTillHead)) @@ -926,9 +928,9 @@ func TestShouldResync(t *testing.T) { } } -func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []interfaces.SignedBeaconBlock { +func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []interfaces2.SignedBeaconBlock { blocks := make([]*ethpb.SignedBeaconBlock, n) - ifaceBlocks := make([]interfaces.SignedBeaconBlock, n) + ifaceBlocks := make([]interfaces2.SignedBeaconBlock, n) for j := i; j < n+i; j++ { parentRoot := make([]byte, 32) copy(parentRoot, previousRoot[:]) @@ -938,7 +940,7 @@ func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []interfaces.S var err error previousRoot, err = blocks[j-i].Block.HashTreeRoot() require.NoError(t, err) - ifaceBlocks[j-i] = interfaces.WrappedPhase0SignedBeaconBlock(blocks[j-i]) + ifaceBlocks[j-i] = wrapper.WrappedPhase0SignedBeaconBlock(blocks[j-i]) } return ifaceBlocks } diff --git a/beacon-chain/sync/subscriber_beacon_blocks.go b/beacon-chain/sync/subscriber_beacon_blocks.go index 024e8c6edc..ff30ca7c57 100644 --- a/beacon-chain/sync/subscriber_beacon_blocks.go +++ b/beacon-chain/sync/subscriber_beacon_blocks.go @@ -7,7 +7,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "google.golang.org/protobuf/proto" ) @@ -16,7 +16,7 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message) if !ok { return errors.New("message is not type *ethpb.SignedBeaconBlock") } - signed := interfaces.WrappedPhase0SignedBeaconBlock(rBlock) + signed := wrapper.WrappedPhase0SignedBeaconBlock(rBlock) if signed.IsNil() || signed.Block().IsNil() { return errors.New("nil block") diff --git a/beacon-chain/sync/utils.go b/beacon-chain/sync/utils.go index 3d9a96ac7d..e48ebc35d7 100644 --- a/beacon-chain/sync/utils.go +++ b/beacon-chain/sync/utils.go @@ -4,7 +4,7 @@ import ( "errors" "sort" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" ) // A type to represent beacon blocks and roots which have methods diff --git a/beacon-chain/sync/utils_test.go b/beacon-chain/sync/utils_test.go index 6641c83775..4ae1ffa686 100644 --- a/beacon-chain/sync/utils_test.go +++ b/beacon-chain/sync/utils_test.go @@ -6,8 +6,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -22,7 +23,7 @@ func TestSortedObj_SortBlocksRoots(t *testing.T) { for i := 0; i < 10; i++ { slot := types.Slot(randFunc()) - newBlk := interfaces.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: slot}}) + newBlk := wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: slot}}) blks = append(blks, newBlk) root := bytesutil.ToBytes32(bytesutil.Bytes32(uint64(slot))) roots = append(roots, root) @@ -57,7 +58,7 @@ func TestSortedObj_NoDuplicates(t *testing.T) { slot := types.Slot(randFunc()) newBlk := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: slot}} // append twice - blks = append(blks, interfaces.WrappedPhase0SignedBeaconBlock(newBlk), interfaces.WrappedPhase0SignedBeaconBlock(newBlk)) + blks = append(blks, wrapper.WrappedPhase0SignedBeaconBlock(newBlk), wrapper.WrappedPhase0SignedBeaconBlock(newBlk)) // append twice root := bytesutil.ToBytes32(bytesutil.Bytes32(uint64(slot))) diff --git a/beacon-chain/sync/validate_aggregate_proof_test.go b/beacon-chain/sync/validate_aggregate_proof_test.go index 647bef9299..2f8dca331d 100644 --- a/beacon-chain/sync/validate_aggregate_proof_test.go +++ b/beacon-chain/sync/validate_aggregate_proof_test.go @@ -20,10 +20,10 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -152,7 +152,7 @@ func TestValidateAggregateAndProof_NotWithinSlotRange(t *testing.T) { beaconState, _ := testutil.DeterministicGenesisState(t, validators) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) s, err := testutil.NewBeaconState() @@ -240,7 +240,7 @@ func TestValidateAggregateAndProof_ExistedInPool(t *testing.T) { beaconState, _ := testutil.DeterministicGenesisState(t, validators) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) @@ -308,7 +308,7 @@ func TestValidateAggregateAndProof_CanValidate(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, validators) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) s, err := testutil.NewBeaconState() @@ -401,7 +401,7 @@ func TestVerifyIndexInCommittee_SeenAggregatorEpoch(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, validators) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) s, err := testutil.NewBeaconState() @@ -604,7 +604,7 @@ func TestValidateAggregateAndProof_RejectWhenAttEpochDoesntEqualTargetEpoch(t *t beaconState, privKeys := testutil.DeterministicGenesisState(t, validators) b := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(b))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b))) root, err := b.Block.HashTreeRoot() require.NoError(t, err) s, err := testutil.NewBeaconState() diff --git a/beacon-chain/sync/validate_beacon_attestation_test.go b/beacon-chain/sync/validate_beacon_attestation_test.go index 8a9bcbc3d7..0d6e112018 100644 --- a/beacon-chain/sync/validate_beacon_attestation_test.go +++ b/beacon-chain/sync/validate_beacon_attestation_test.go @@ -17,8 +17,8 @@ import ( p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -59,7 +59,7 @@ func TestService_validateCommitteeIndexBeaconAttestation(t *testing.T) { blk := testutil.NewBeaconBlock() blk.Block.Slot = 1 - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(blk))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk))) validBlockRoot, err := blk.Block.HashTreeRoot() require.NoError(t, err) diff --git a/beacon-chain/sync/validate_beacon_blocks.go b/beacon-chain/sync/validate_beacon_blocks.go index 833ff68a61..fb836a7323 100644 --- a/beacon-chain/sync/validate_beacon_blocks.go +++ b/beacon-chain/sync/validate_beacon_blocks.go @@ -15,8 +15,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -58,7 +59,7 @@ func (s *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms log.WithError(errors.New("msg is not ethpb.SignedBeaconBlock")).Debug("Rejected block") return pubsub.ValidationReject } - blk := interfaces.WrappedPhase0SignedBeaconBlock(rblk) + blk := wrapper.WrappedPhase0SignedBeaconBlock(rblk) if blk.IsNil() || blk.Block().IsNil() { log.WithError(errors.New("block.Block is nil")).Debug("Rejected block") diff --git a/beacon-chain/sync/validate_beacon_blocks_test.go b/beacon-chain/sync/validate_beacon_blocks_test.go index 6e2c9bb0a1..861d2172e2 100644 --- a/beacon-chain/sync/validate_beacon_blocks_test.go +++ b/beacon-chain/sync/validate_beacon_blocks_test.go @@ -24,10 +24,10 @@ import ( 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/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -45,7 +45,7 @@ func TestValidateBeaconBlockPubSub_InvalidSignature(t *testing.T) { ctx := context.Background() beaconState, _ := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -105,7 +105,7 @@ func TestValidateBeaconBlockPubSub_BlockAlreadyPresentInDB(t *testing.T) { msg := testutil.NewBeaconBlock() msg.Block.Slot = 100 msg.Block.ParentRoot = testutil.Random32Bytes(t) - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(msg))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(msg))) c, err := lru.New(10) require.NoError(t, err) @@ -145,7 +145,7 @@ func TestValidateBeaconBlockPubSub_CanRecoverStateSummary(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -207,7 +207,7 @@ func TestValidateBeaconBlockPubSub_ValidProposerSignature(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -270,7 +270,7 @@ func TestValidateBeaconBlockPubSub_WithLookahead(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -335,7 +335,7 @@ func TestValidateBeaconBlockPubSub_AdvanceEpochsForState(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -441,7 +441,7 @@ func TestValidateBeaconBlockPubSub_AcceptBlocksFromNearFuture(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -604,7 +604,7 @@ func TestValidateBeaconBlockPubSub_SeenProposerSlot(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -665,7 +665,7 @@ func TestValidateBeaconBlockPubSub_FilterByFinalizedEpoch(t *testing.T) { p := p2ptest.NewTestP2P(t) parent := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(context.Background(), interfaces.WrappedPhase0SignedBeaconBlock(parent))) + require.NoError(t, db.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(parent))) parentRoot, err := parent.Block.HashTreeRoot() require.NoError(t, err) chain := &mock.ChainService{Genesis: time.Unix(time.Now().Unix()-int64(params.BeaconConfig().SecondsPerSlot), 0), @@ -727,7 +727,7 @@ func TestValidateBeaconBlockPubSub_ParentNotFinalizedDescendant(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -790,7 +790,7 @@ func TestValidateBeaconBlockPubSub_InvalidParentBlock(t *testing.T) { ctx := context.Background() beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) @@ -879,7 +879,7 @@ func TestValidateBeaconBlockPubSub_RejectEvilBlocksFromFuture(t *testing.T) { beaconState, privKeys := testutil.DeterministicGenesisState(t, 100) parentBlock := testutil.NewBeaconBlock() - require.NoError(t, db.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(parentBlock))) + require.NoError(t, db.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(parentBlock))) bRoot, err := parentBlock.Block.HashTreeRoot() require.NoError(t, err) require.NoError(t, db.SaveState(ctx, beaconState, bRoot)) diff --git a/fuzz/BUILD.bazel b/fuzz/BUILD.bazel index fe9ed2a3fa..85319d41be 100644 --- a/fuzz/BUILD.bazel +++ b/fuzz/BUILD.bazel @@ -66,6 +66,8 @@ go_fuzz_test( "//fuzz/testing:go_default_library", "//shared/params:go_default_library", "//proto/beacon/p2p/v1:go_default_library", + "//proto/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//beacon-chain/operations/attestations:go_default_library", "//beacon-chain/p2p/testing:go_default_library", "//beacon-chain/sync:go_default_library", @@ -86,7 +88,6 @@ go_fuzz_test( "//beacon-chain/cache:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//shared/rand:go_default_library", - "//shared/interfaces:go_default_library", ] + COMMON_DEPS, ) diff --git a/fuzz/block_fuzz.go b/fuzz/block_fuzz.go index 26a4076e7e..707e838de1 100644 --- a/fuzz/block_fuzz.go +++ b/fuzz/block_fuzz.go @@ -28,7 +28,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/beacon-chain/sync" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -71,7 +71,7 @@ func setupDB() { panic(err) } b := testutil.NewBeaconBlock() - if err := db1.SaveBlock(ctx, interfaces.WrappedPhase0SignedBeaconBlock(b)); err != nil { + if err := db1.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b)); err != nil { panic(err) } br, err := b.HashTreeRoot() @@ -199,7 +199,7 @@ func BeaconFuzzBlock(b []byte) { _ = err } - if _, err := state.ProcessBlock(ctx, st, interfaces.WrappedPhase0SignedBeaconBlock(input.Block)); err != nil { + if _, err := state.ProcessBlock(ctx, st, wrapper.WrappedPhase0SignedBeaconBlock(input.Block)); err != nil { _ = err } } diff --git a/proto/eth/v1alpha1/wrapper/BUILD.bazel b/proto/eth/v1alpha1/wrapper/BUILD.bazel new file mode 100644 index 0000000000..948411f092 --- /dev/null +++ b/proto/eth/v1alpha1/wrapper/BUILD.bazel @@ -0,0 +1,15 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["beacon_block.go"], + importpath = "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper", + visibility = ["//visibility:public"], + deps = [ + "//proto/eth/v1alpha1:go_default_library", + "//proto/interfaces:go_default_library", + "//shared/copyutil:go_default_library", + "@com_github_prysmaticlabs_eth2_types//:go_default_library", + "@org_golang_google_protobuf//proto:go_default_library", + ], +) diff --git a/shared/interfaces/phase0_block_wrapper.go b/proto/eth/v1alpha1/wrapper/beacon_block.go similarity index 79% rename from shared/interfaces/phase0_block_wrapper.go rename to proto/eth/v1alpha1/wrapper/beacon_block.go index 47aa24e7cc..10aa7c9719 100644 --- a/shared/interfaces/phase0_block_wrapper.go +++ b/proto/eth/v1alpha1/wrapper/beacon_block.go @@ -1,8 +1,9 @@ -package interfaces +package wrapper import ( types "github.com/prysmaticlabs/eth2-types" - ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/copyutil" "google.golang.org/protobuf/proto" ) @@ -11,12 +12,12 @@ import ( // object. This wrapper allows us to conform to a common interface so that beacon // blocks for future forks can also be applied across prysm without issues. type Phase0SignedBeaconBlock struct { - b *ethpb.SignedBeaconBlock + b *eth.SignedBeaconBlock } // WrappedPhase0SignedBeaconBlock is constructor which wraps a protobuf phase 0 block // with the block wrapper. -func WrappedPhase0SignedBeaconBlock(b *ethpb.SignedBeaconBlock) Phase0SignedBeaconBlock { +func WrappedPhase0SignedBeaconBlock(b *eth.SignedBeaconBlock) Phase0SignedBeaconBlock { return Phase0SignedBeaconBlock{b: b} } @@ -26,7 +27,7 @@ func (w Phase0SignedBeaconBlock) Signature() []byte { } // Block returns the underlying beacon block object. -func (w Phase0SignedBeaconBlock) Block() BeaconBlock { +func (w Phase0SignedBeaconBlock) Block() interfaces.BeaconBlock { return WrappedPhase0BeaconBlock(w.b.Block) } @@ -38,7 +39,7 @@ func (w Phase0SignedBeaconBlock) IsNil() bool { // Copy performs a deep copy of the signed beacon block // object. -func (w Phase0SignedBeaconBlock) Copy() SignedBeaconBlock { +func (w Phase0SignedBeaconBlock) Copy() interfaces.SignedBeaconBlock { return WrappedPhase0SignedBeaconBlock(copyutil.CopySignedBeaconBlock(w.b)) } @@ -55,18 +56,18 @@ func (w Phase0SignedBeaconBlock) Proto() proto.Message { } // PbPhase0Block returns the underlying protobuf object. -func (w Phase0SignedBeaconBlock) PbPhase0Block() (*ethpb.SignedBeaconBlock, error) { +func (w Phase0SignedBeaconBlock) PbPhase0Block() (*eth.SignedBeaconBlock, error) { return w.b, nil } // Phase0BeaconBlock is the wrapper for the actual block. type Phase0BeaconBlock struct { - b *ethpb.BeaconBlock + b *eth.BeaconBlock } // WrappedPhase0BeaconBlock is constructor which wraps a protobuf phase 0 object // with the block wrapper. -func WrappedPhase0BeaconBlock(b *ethpb.BeaconBlock) Phase0BeaconBlock { +func WrappedPhase0BeaconBlock(b *eth.BeaconBlock) Phase0BeaconBlock { return Phase0BeaconBlock{b: b} } @@ -91,7 +92,7 @@ func (w Phase0BeaconBlock) StateRoot() []byte { } // Body returns the underlying block body. -func (w Phase0BeaconBlock) Body() BeaconBlockBody { +func (w Phase0BeaconBlock) Body() interfaces.BeaconBlockBody { return WrappedPhase0BeaconBlockBody(w.b.Body) } @@ -119,12 +120,12 @@ func (w Phase0BeaconBlock) Proto() proto.Message { // Phase0BeaconBlockBody is a wrapper of a beacon block body. type Phase0BeaconBlockBody struct { - b *ethpb.BeaconBlockBody + b *eth.BeaconBlockBody } // WrappedPhase0BeaconBlockBody is constructor which wraps a protobuf phase 0 object // with the block wrapper. -func WrappedPhase0BeaconBlockBody(b *ethpb.BeaconBlockBody) Phase0BeaconBlockBody { +func WrappedPhase0BeaconBlockBody(b *eth.BeaconBlockBody) Phase0BeaconBlockBody { return Phase0BeaconBlockBody{b: b} } @@ -134,7 +135,7 @@ func (w Phase0BeaconBlockBody) RandaoReveal() []byte { } // Eth1Data returns the eth1 data in the block. -func (w Phase0BeaconBlockBody) Eth1Data() *ethpb.Eth1Data { +func (w Phase0BeaconBlockBody) Eth1Data() *eth.Eth1Data { return w.b.Eth1Data } @@ -144,27 +145,27 @@ func (w Phase0BeaconBlockBody) Graffiti() []byte { } // ProposerSlashings returns the proposer slashings in the block. -func (w Phase0BeaconBlockBody) ProposerSlashings() []*ethpb.ProposerSlashing { +func (w Phase0BeaconBlockBody) ProposerSlashings() []*eth.ProposerSlashing { return w.b.ProposerSlashings } // AttesterSlashings returns the attester slashings in the block. -func (w Phase0BeaconBlockBody) AttesterSlashings() []*ethpb.AttesterSlashing { +func (w Phase0BeaconBlockBody) AttesterSlashings() []*eth.AttesterSlashing { return w.b.AttesterSlashings } // Attestations returns the stored attestations in the block. -func (w Phase0BeaconBlockBody) Attestations() []*ethpb.Attestation { +func (w Phase0BeaconBlockBody) Attestations() []*eth.Attestation { return w.b.Attestations } // Deposits returns the stored deposits in the block. -func (w Phase0BeaconBlockBody) Deposits() []*ethpb.Deposit { +func (w Phase0BeaconBlockBody) Deposits() []*eth.Deposit { return w.b.Deposits } // VoluntaryExits returns the voluntary exits in the block. -func (w Phase0BeaconBlockBody) VoluntaryExits() []*ethpb.SignedVoluntaryExit { +func (w Phase0BeaconBlockBody) VoluntaryExits() []*eth.SignedVoluntaryExit { return w.b.VoluntaryExits } diff --git a/proto/interfaces/BUILD.bazel b/proto/interfaces/BUILD.bazel new file mode 100644 index 0000000000..8ac74ab399 --- /dev/null +++ b/proto/interfaces/BUILD.bazel @@ -0,0 +1,13 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["block_interface.go"], + importpath = "github.com/prysmaticlabs/prysm/proto/interfaces", + visibility = ["//visibility:public"], + deps = [ + "//proto/eth/v1alpha1:go_default_library", + "@com_github_prysmaticlabs_eth2_types//:go_default_library", + "@org_golang_google_protobuf//proto:go_default_library", + ], +) diff --git a/shared/interfaces/block_interface.go b/proto/interfaces/block_interface.go similarity index 100% rename from shared/interfaces/block_interface.go rename to proto/interfaces/block_interface.go diff --git a/proto/migration/BUILD.bazel b/proto/migration/BUILD.bazel index fc25d088d7..c6837bed8b 100644 --- a/proto/migration/BUILD.bazel +++ b/proto/migration/BUILD.bazel @@ -11,7 +11,7 @@ go_library( deps = [ "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/interfaces:go_default_library", "@com_github_pkg_errors//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], @@ -27,8 +27,8 @@ go_test( deps = [ "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/proto/migration/migration.go b/proto/migration/migration.go index 27e862c984..a86e4faf25 100644 --- a/proto/migration/migration.go +++ b/proto/migration/migration.go @@ -4,7 +4,7 @@ import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "google.golang.org/protobuf/proto" ) diff --git a/proto/migration/migration_test.go b/proto/migration/migration_test.go index d6e4b14550..12dbb63535 100644 --- a/proto/migration/migration_test.go +++ b/proto/migration/migration_test.go @@ -7,8 +7,8 @@ import ( "github.com/prysmaticlabs/go-bitfield" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -42,7 +42,7 @@ func Test_BlockIfaceToV1BlockHeader(t *testing.T) { alphaBlock.Block.StateRoot = stateRoot alphaBlock.Signature = signature - v1Header, err := BlockIfaceToV1BlockHeader(interfaces.WrappedPhase0SignedBeaconBlock(alphaBlock)) + v1Header, err := BlockIfaceToV1BlockHeader(wrapper.WrappedPhase0SignedBeaconBlock(alphaBlock)) require.NoError(t, err) bodyRoot, err := alphaBlock.Block.Body.HashTreeRoot() require.NoError(t, err) @@ -347,7 +347,7 @@ func Test_BlockInterfaceToV1Block(t *testing.T) { } v1Alpha1Block.Signature = signature - v1Block, err := SignedBeaconBlock(interfaces.WrappedPhase0SignedBeaconBlock(v1Alpha1Block)) + v1Block, err := SignedBeaconBlock(wrapper.WrappedPhase0SignedBeaconBlock(v1Alpha1Block)) require.NoError(t, err) v1Root, err := v1Block.HashTreeRoot() require.NoError(t, err) diff --git a/shared/interfaces/BUILD.bazel b/shared/interfaces/BUILD.bazel index 1086193590..c0d571c336 100644 --- a/shared/interfaces/BUILD.bazel +++ b/shared/interfaces/BUILD.bazel @@ -3,18 +3,13 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = [ - "block_interface.go", "metadata_interface.go", "metadata_wrapper.go", - "phase0_block_wrapper.go", ], importpath = "github.com/prysmaticlabs/prysm/shared/interfaces", visibility = ["//visibility:public"], deps = [ "//proto/beacon/p2p/v1:go_default_library", - "//proto/eth/v1alpha1:go_default_library", - "//shared/copyutil: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/shared/testutil/BUILD.bazel b/shared/testutil/BUILD.bazel index f314efc350..9243216a3d 100644 --- a/shared/testutil/BUILD.bazel +++ b/shared/testutil/BUILD.bazel @@ -22,10 +22,10 @@ go_library( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", "//shared/hashutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/interop:go_default_library", "//shared/params:go_default_library", "//shared/rand:go_default_library", @@ -56,8 +56,8 @@ go_test( "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/params:go_default_library", "//shared/testutil/assert:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/shared/testutil/block_test.go b/shared/testutil/block_test.go index fb2abf0937..aa93ac6167 100644 --- a/shared/testutil/block_test.go +++ b/shared/testutil/block_test.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils" v1 "github.com/prysmaticlabs/prysm/proto/eth/v1" eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -23,7 +23,7 @@ func TestGenerateFullBlock_PassesStateTransition(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - _, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) } @@ -36,7 +36,7 @@ func TestGenerateFullBlock_ThousandValidators(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - _, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) } @@ -54,7 +54,7 @@ func TestGenerateFullBlock_Passes4Epochs(t *testing.T) { helpers.ClearCache() block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) } @@ -79,7 +79,7 @@ func TestGenerateFullBlock_ValidProposerSlashings(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()+1) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) slashableIndice := block.Block.Body.ProposerSlashings[0].Header_1.Header.ProposerIndex @@ -98,7 +98,7 @@ func TestGenerateFullBlock_ValidAttesterSlashings(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) slashableIndices := block.Block.Body.AttesterSlashings[0].Attestation_1.AttestingIndices @@ -118,7 +118,7 @@ func TestGenerateFullBlock_ValidAttestations(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) atts, err := beaconState.CurrentEpochAttestations() require.NoError(t, err) @@ -139,7 +139,7 @@ func TestGenerateFullBlock_ValidDeposits(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) depositedPubkey := block.Block.Body.Deposits[0].Data.PublicKey @@ -165,7 +165,7 @@ func TestGenerateFullBlock_ValidVoluntaryExits(t *testing.T) { } block, err := GenerateFullBlock(beaconState, privs, conf, beaconState.Slot()) require.NoError(t, err) - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) exitedIndex := block.Block.Body.VoluntaryExits[0].Exit.ValidatorIndex diff --git a/shared/testutil/helpers.go b/shared/testutil/helpers.go index ad620cd8bc..1f205797c9 100644 --- a/shared/testutil/helpers.go +++ b/shared/testutil/helpers.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bls" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" ) @@ -39,7 +39,7 @@ func BlockSignature( privKeys []bls.SecretKey, ) (bls.Signature, error) { var err error - s, err := state.CalculateStateRoot(context.Background(), bState, interfaces.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: block})) + s, err := state.CalculateStateRoot(context.Background(), bState, wrapper.WrappedPhase0SignedBeaconBlock(ðpb.SignedBeaconBlock{Block: block})) if err != nil { return nil, err } diff --git a/spectest/shared/phase0/finality/BUILD.bazel b/spectest/shared/phase0/finality/BUILD.bazel index 86db4fc99d..d6008395ae 100644 --- a/spectest/shared/phase0/finality/BUILD.bazel +++ b/spectest/shared/phase0/finality/BUILD.bazel @@ -13,7 +13,7 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper: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 6093c60a57..864a28fcb4 100644 --- a/spectest/shared/phase0/finality/runner.go +++ b/spectest/shared/phase0/finality/runner.go @@ -12,7 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -61,7 +61,7 @@ func RunFinalityTest(t *testing.T, config string) { require.NoError(t, err, "Failed to decompress") block := ðpb.SignedBeaconBlock{} require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal") - processedState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + processedState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) require.NoError(t, err) beaconState, ok = processedState.(*v1.BeaconState) require.Equal(t, true, ok) diff --git a/spectest/shared/phase0/operations/BUILD.bazel b/spectest/shared/phase0/operations/BUILD.bazel index fedfaeac4b..d1e820dc03 100644 --- a/spectest/shared/phase0/operations/BUILD.bazel +++ b/spectest/shared/phase0/operations/BUILD.bazel @@ -22,7 +22,8 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", + "//proto/interfaces: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/attester_slashing.go b/spectest/shared/phase0/operations/attester_slashing.go index d87a1035db..6f2af106be 100644 --- a/spectest/shared/phase0/operations/attester_slashing.go +++ b/spectest/shared/phase0/operations/attester_slashing.go @@ -10,7 +10,7 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" diff --git a/spectest/shared/phase0/operations/deposit.go b/spectest/shared/phase0/operations/deposit.go index 4b8ff44e46..9641178e0f 100644 --- a/spectest/shared/phase0/operations/deposit.go +++ b/spectest/shared/phase0/operations/deposit.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" diff --git a/spectest/shared/phase0/operations/helpers.go b/spectest/shared/phase0/operations/helpers.go index cb5d53fcfe..81a6c3d496 100644 --- a/spectest/shared/phase0/operations/helpers.go +++ b/spectest/shared/phase0/operations/helpers.go @@ -14,7 +14,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "google.golang.org/protobuf/proto" @@ -54,7 +55,7 @@ func RunBlockOperationTest( helpers.ClearCache() b := testutil.NewBeaconBlock() b.Block.Body = body - beaconState, err := operationFn(context.Background(), preState, interfaces.WrappedPhase0SignedBeaconBlock(b)) + beaconState, err := operationFn(context.Background(), preState, wrapper.WrappedPhase0SignedBeaconBlock(b)) if postSSZExists { require.NoError(t, err) diff --git a/spectest/shared/phase0/operations/proposer_slashing.go b/spectest/shared/phase0/operations/proposer_slashing.go index aa0b4def27..f1071246ae 100644 --- a/spectest/shared/phase0/operations/proposer_slashing.go +++ b/spectest/shared/phase0/operations/proposer_slashing.go @@ -10,7 +10,7 @@ import ( v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" diff --git a/spectest/shared/phase0/operations/voluntary_exit.go b/spectest/shared/phase0/operations/voluntary_exit.go index 7aadc68c14..9aac759fb4 100644 --- a/spectest/shared/phase0/operations/voluntary_exit.go +++ b/spectest/shared/phase0/operations/voluntary_exit.go @@ -9,7 +9,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" diff --git a/spectest/shared/phase0/sanity/BUILD.bazel b/spectest/shared/phase0/sanity/BUILD.bazel index 164c25edd5..6c9fac3dab 100644 --- a/spectest/shared/phase0/sanity/BUILD.bazel +++ b/spectest/shared/phase0/sanity/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper: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 3196a25dc5..072a6559cb 100644 --- a/spectest/shared/phase0/sanity/block_processing.go +++ b/spectest/shared/phase0/sanity/block_processing.go @@ -16,7 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -62,7 +62,7 @@ func RunBlockProcessingTest(t *testing.T, config string) { require.NoError(t, err, "Failed to decompress") block := ðpb.SignedBeaconBlock{} require.NoError(t, block.UnmarshalSSZ(blockSSZ), "Failed to unmarshal") - processedState, transitionError = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + processedState, transitionError = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) if transitionError != nil { break } diff --git a/tools/benchmark-files-gen/BUILD.bazel b/tools/benchmark-files-gen/BUILD.bazel index 17403e369e..941f1f0914 100644 --- a/tools/benchmark-files-gen/BUILD.bazel +++ b/tools/benchmark-files-gen/BUILD.bazel @@ -14,9 +14,9 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", + "//proto/eth/v1alpha1/wrapper:go_default_library", "//shared/benchutil:go_default_library", "//shared/fileutil:go_default_library", - "//shared/interfaces:go_default_library", "//shared/interop:go_default_library", "//shared/params:go_default_library", "//shared/testutil:go_default_library", diff --git a/tools/benchmark-files-gen/main.go b/tools/benchmark-files-gen/main.go index 9e2ddfb564..011b2cf424 100644 --- a/tools/benchmark-files-gen/main.go +++ b/tools/benchmark-files-gen/main.go @@ -16,9 +16,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/benchutil" "github.com/prysmaticlabs/prysm/shared/fileutil" - "github.com/prysmaticlabs/prysm/shared/interfaces" "github.com/prysmaticlabs/prysm/shared/interop" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -103,7 +103,7 @@ func generateMarshalledFullStateAndBlock() error { if err != nil { return err } - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) if err != nil { return err } @@ -127,7 +127,7 @@ func generateMarshalledFullStateAndBlock() error { } block.Block.Body.Attestations = append(atts, block.Block.Body.Attestations...) - s, err := state.CalculateStateRoot(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + s, err := state.CalculateStateRoot(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) if err != nil { return errors.Wrap(err, "could not calculate state root") } @@ -158,7 +158,7 @@ func generateMarshalledFullStateAndBlock() error { } // Running a single state transition to make sure the generated files aren't broken. - _, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + _, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) if err != nil { return err } @@ -192,7 +192,7 @@ func generate2FullEpochState() error { if err != nil { return err } - beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, interfaces.WrappedPhase0SignedBeaconBlock(block)) + beaconState, err = state.ExecuteStateTransition(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block)) if err != nil { return err } diff --git a/tools/pcli/BUILD.bazel b/tools/pcli/BUILD.bazel index a8da0be834..ea23ae928f 100644 --- a/tools/pcli/BUILD.bazel +++ b/tools/pcli/BUILD.bazel @@ -14,7 +14,7 @@ go_library( "//beacon-chain/state/v1:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//proto/eth/v1alpha1:go_default_library", - "//shared/interfaces:go_default_library", + "//proto/eth/v1alpha1/wrapper: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 a7e6da02e0..c5f183401e 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -15,7 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/interfaces" + "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/sszutil" "github.com/prysmaticlabs/prysm/shared/version" log "github.com/sirupsen/logrus" @@ -176,7 +176,7 @@ func main() { blkRoot, preStateRoot, ) - postState, err := state.ExecuteStateTransition(context.Background(), stateObj, interfaces.WrappedPhase0SignedBeaconBlock(block)) + postState, err := state.ExecuteStateTransition(context.Background(), stateObj, wrapper.WrappedPhase0SignedBeaconBlock(block)) if err != nil { log.Fatal(err) }