From 8db0c9a0e6dd50870807efd2c22b19b5c7dcc6aa Mon Sep 17 00:00:00 2001 From: terence tsao Date: Fri, 23 Jul 2021 13:10:15 -0700 Subject: [PATCH] Move proto/interfaces -> proto/prysm/v2 (#9270) * Move proto/interfaces -> proto/prysm * Update paths * Fix block2 * Update blocks_fetcher_utils.go * Update BUILD.bazel Co-authored-by: Raul Jordan Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/blockchain/BUILD.bazel | 2 +- beacon-chain/blockchain/chain_info.go | 6 ++-- beacon-chain/blockchain/head.go | 18 +++++------ .../blockchain/init_sync_process_block.go | 12 +++---- beacon-chain/blockchain/log.go | 6 ++-- beacon-chain/blockchain/log_test.go | 4 +-- beacon-chain/blockchain/metrics.go | 4 +-- beacon-chain/blockchain/process_block.go | 14 ++++---- .../blockchain/process_block_helpers.go | 16 +++++----- beacon-chain/blockchain/process_block_test.go | 4 +-- beacon-chain/blockchain/receive_block.go | 12 +++---- beacon-chain/blockchain/receive_block_test.go | 6 ++-- beacon-chain/blockchain/service.go | 6 ++-- beacon-chain/blockchain/service_test.go | 4 +-- beacon-chain/blockchain/testing/BUILD.bazel | 2 +- beacon-chain/blockchain/testing/mock.go | 14 ++++---- beacon-chain/core/blocks/BUILD.bazel | 2 +- beacon-chain/core/blocks/attestation.go | 6 ++-- beacon-chain/core/blocks/header.go | 4 +-- beacon-chain/core/blocks/randao.go | 4 +-- 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 | 4 +-- beacon-chain/core/helpers/BUILD.bazel | 2 +- beacon-chain/core/helpers/block.go | 4 +-- beacon-chain/core/state/BUILD.bazel | 2 +- beacon-chain/core/state/interop/BUILD.bazel | 2 +- .../core/state/interop/write_block_to_disk.go | 4 +-- beacon-chain/core/state/transition.go | 20 ++++++------ .../core/state/transition_no_verify_sig.go | 12 +++---- beacon-chain/db/iface/BUILD.bazel | 2 +- beacon-chain/db/iface/interface.go | 20 ++++++------ beacon-chain/db/kafka/BUILD.bazel | 2 +- beacon-chain/db/kafka/export_wrapper.go | 8 ++--- beacon-chain/db/kafka/passthrough.go | 16 +++++----- beacon-chain/db/kv/BUILD.bazel | 4 +-- beacon-chain/db/kv/blocks.go | 32 +++++++++---------- beacon-chain/db/kv/blocks_test.go | 22 ++++++------- beacon-chain/db/kv/finalized_block_roots.go | 4 +-- .../db/kv/finalized_block_roots_test.go | 8 ++--- beacon-chain/db/kv/state_test.go | 4 +-- beacon-chain/p2p/BUILD.bazel | 2 +- beacon-chain/p2p/interfaces.go | 4 +-- beacon-chain/p2p/peers/BUILD.bazel | 2 +- beacon-chain/p2p/peers/peerdata/BUILD.bazel | 2 +- beacon-chain/p2p/peers/peerdata/store.go | 4 +-- beacon-chain/p2p/peers/status.go | 6 ++-- beacon-chain/p2p/service.go | 6 ++-- beacon-chain/p2p/testing/BUILD.bazel | 2 +- beacon-chain/p2p/testing/fuzz_p2p.go | 4 +-- .../p2p/testing/mock_metadataprovider.go | 6 ++-- beacon-chain/p2p/testing/p2p.go | 6 ++-- beacon-chain/p2p/utils.go | 4 +-- beacon-chain/rpc/eth/v1/beacon/BUILD.bazel | 4 +-- beacon-chain/rpc/eth/v1/beacon/blocks.go | 8 ++--- beacon-chain/rpc/eth/v1/beacon/blocks_test.go | 4 +-- .../rpc/prysm/v1alpha1/beacon/BUILD.bazel | 4 +-- .../rpc/prysm/v1alpha1/beacon/attestations.go | 6 ++-- .../v1alpha1/beacon/attestations_test.go | 4 +-- .../rpc/prysm/v1alpha1/beacon/blocks_test.go | 6 ++-- .../rpc/prysm/v1alpha1/validator/BUILD.bazel | 2 +- .../rpc/prysm/v1alpha1/validator/proposer.go | 4 +-- beacon-chain/state/stategen/BUILD.bazel | 4 +-- beacon-chain/state/stategen/mock.go | 6 ++-- beacon-chain/state/stategen/replay.go | 14 ++++---- beacon-chain/state/stategen/replay_test.go | 8 ++--- beacon-chain/state/stategen/service.go | 6 ++-- beacon-chain/sync/BUILD.bazel | 5 +-- beacon-chain/sync/initial-sync/BUILD.bazel | 4 +-- .../sync/initial-sync/blocks_fetcher.go | 12 +++---- .../sync/initial-sync/blocks_fetcher_test.go | 26 +++++++-------- .../sync/initial-sync/blocks_fetcher_utils.go | 8 ++--- .../sync/initial-sync/blocks_queue.go | 4 +-- .../sync/initial-sync/blocks_queue_test.go | 18 +++++------ beacon-chain/sync/initial-sync/fsm.go | 6 ++-- beacon-chain/sync/initial-sync/round_robin.go | 16 +++++----- .../sync/initial-sync/round_robin_test.go | 22 ++++++------- beacon-chain/sync/pending_blocks_queue.go | 18 +++++------ .../sync/rpc_beacon_blocks_by_range.go | 12 +++---- .../sync/rpc_beacon_blocks_by_root.go | 4 +-- beacon-chain/sync/rpc_chunked_response.go | 6 ++-- beacon-chain/sync/rpc_metadata.go | 4 +-- beacon-chain/sync/rpc_send_request.go | 16 +++++----- beacon-chain/sync/rpc_send_request_test.go | 24 +++++++------- beacon-chain/sync/rpc_status_test.go | 6 ++-- beacon-chain/sync/utils.go | 10 +++--- beacon-chain/sync/utils_test.go | 6 ++-- beacon-chain/sync/validate_beacon_blocks.go | 4 +-- fuzz/BUILD.bazel | 2 +- proto/migration/BUILD.bazel | 2 +- proto/migration/migration.go | 6 ++-- proto/prysm/BUILD.bazel | 1 + proto/prysm/v1alpha1/wrapper/BUILD.bazel | 2 +- proto/prysm/v1alpha1/wrapper/beacon_block.go | 14 ++++---- .../v2/block}/BUILD.bazel | 8 ++--- .../v2/block/block_interfaces.go} | 2 +- proto/prysm/v2/metadata/BUILD.bazel | 12 +++++++ .../v2/metadata/metadata_interfaces.go} | 2 +- proto/prysm/v2/wrapper/BUILD.bazel | 3 +- proto/prysm/v2/wrapper/beacon_block.go | 20 ++++++------ proto/prysm/v2/wrapper/metadata.go | 6 ++-- shared/blockutil/BUILD.bazel | 2 +- shared/blockutil/block_utils.go | 6 ++-- spectest/shared/phase0/operations/BUILD.bazel | 2 +- .../phase0/operations/attester_slashing.go | 4 +-- spectest/shared/phase0/operations/deposit.go | 4 +-- spectest/shared/phase0/operations/helpers.go | 4 +-- .../phase0/operations/proposer_slashing.go | 4 +-- .../phase0/operations/voluntary_exit.go | 4 +-- validator/client/BUILD.bazel | 2 +- validator/client/propose_protect.go | 8 ++--- 112 files changed, 408 insertions(+), 397 deletions(-) create mode 100644 proto/prysm/BUILD.bazel rename proto/{interfaces => prysm/v2/block}/BUILD.bazel (69%) rename proto/{interfaces/block.go => prysm/v2/block/block_interfaces.go} (98%) create mode 100644 proto/prysm/v2/metadata/BUILD.bazel rename proto/{interfaces/metadata.go => prysm/v2/metadata/metadata_interfaces.go} (95%) diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 19f7364e80..18ccc5bad5 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -44,8 +44,8 @@ go_library( "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", "//proto/eth/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", diff --git a/beacon-chain/blockchain/chain_info.go b/beacon-chain/blockchain/chain_info.go index 2c6613f739..dd613b90aa 100644 --- a/beacon-chain/blockchain/chain_info.go +++ b/beacon-chain/blockchain/chain_info.go @@ -8,8 +8,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" @@ -43,7 +43,7 @@ type GenesisFetcher interface { type HeadFetcher interface { HeadSlot() types.Slot HeadRoot(ctx context.Context) ([]byte, error) - HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) + HeadBlock(ctx context.Context) (block.SignedBeaconBlock, error) HeadState(ctx context.Context) (state.BeaconState, error) HeadValidatorsIndices(ctx context.Context, epoch types.Epoch) ([]types.ValidatorIndex, error) HeadSeed(ctx context.Context, epoch types.Epoch) ([32]byte, error) @@ -140,7 +140,7 @@ func (s *Service) HeadRoot(ctx context.Context) ([]byte, error) { // HeadBlock returns the head block of the chain. // If the head is nil from service struct, // it will attempt to get the head block from DB. -func (s *Service) HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) { +func (s *Service) HeadBlock(ctx context.Context) (block.SignedBeaconBlock, error) { s.headLock.RLock() defer s.headLock.RUnlock() diff --git a/beacon-chain/blockchain/head.go b/beacon-chain/blockchain/head.go index 2b8a8a8a5f..e8d0eeaec3 100644 --- a/beacon-chain/blockchain/head.go +++ b/beacon-chain/blockchain/head.go @@ -13,7 +13,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" @@ -23,10 +23,10 @@ import ( // This defines the current chain service's view of head. type head struct { - slot types.Slot // current head slot. - root [32]byte // current head root. - block interfaces.SignedBeaconBlock // current head block. - state state.BeaconState // current head state. + slot types.Slot // current head slot. + root [32]byte // current head root. + block block.SignedBeaconBlock // current head block. + state state.BeaconState // current head state. } // Determined the head from the fork choice service and saves its new data @@ -168,7 +168,7 @@ func (s *Service) saveHead(ctx context.Context, headRoot [32]byte) error { // This gets called to update canonical root mapping. It does not save head block // root in DB. With the inception of initial-sync-cache-state flag, it uses finalized // check point as anchors to resume sync therefore head is no longer needed to be saved on per slot basis. -func (s *Service) saveHeadNoDB(ctx context.Context, b interfaces.SignedBeaconBlock, r [32]byte, hs state.BeaconState) error { +func (s *Service) saveHeadNoDB(ctx context.Context, b block.SignedBeaconBlock, r [32]byte, hs state.BeaconState) error { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return err } @@ -185,7 +185,7 @@ func (s *Service) saveHeadNoDB(ctx context.Context, b interfaces.SignedBeaconBlo } // This sets head view object which is used to track the head slot, root, block and state. -func (s *Service) setHead(root [32]byte, block interfaces.SignedBeaconBlock, state state.BeaconState) { +func (s *Service) setHead(root [32]byte, block block.SignedBeaconBlock, state state.BeaconState) { s.headLock.Lock() defer s.headLock.Unlock() @@ -201,7 +201,7 @@ func (s *Service) setHead(root [32]byte, block interfaces.SignedBeaconBlock, sta // This sets head view object which is used to track the head slot, root, block and state. The method // assumes that state being passed into the method will not be modified by any other alternate // caller which holds the state's reference. -func (s *Service) setHeadInitialSync(root [32]byte, block interfaces.SignedBeaconBlock, state state.BeaconState) { +func (s *Service) setHeadInitialSync(root [32]byte, block block.SignedBeaconBlock, state state.BeaconState) { s.headLock.Lock() defer s.headLock.Unlock() @@ -234,7 +234,7 @@ func (s *Service) headRoot() [32]byte { // This returns the head block. // It does a full copy on head block for immutability. // This is a lock free version. -func (s *Service) headBlock() interfaces.SignedBeaconBlock { +func (s *Service) headBlock() block.SignedBeaconBlock { return s.head.block.Copy() } diff --git a/beacon-chain/blockchain/init_sync_process_block.go b/beacon-chain/blockchain/init_sync_process_block.go index c4a3aaa152..87bff0f72e 100644 --- a/beacon-chain/blockchain/init_sync_process_block.go +++ b/beacon-chain/blockchain/init_sync_process_block.go @@ -1,11 +1,11 @@ package blockchain import ( - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) // This saves a beacon block to the initial sync blocks cache. -func (s *Service) saveInitSyncBlock(r [32]byte, b interfaces.SignedBeaconBlock) { +func (s *Service) saveInitSyncBlock(r [32]byte, b block.SignedBeaconBlock) { s.initSyncBlocksLock.Lock() defer s.initSyncBlocksLock.Unlock() s.initSyncBlocks[r] = b @@ -22,7 +22,7 @@ func (s *Service) hasInitSyncBlock(r [32]byte) bool { // This retrieves a beacon block from the initial sync blocks cache using the root of // the block. -func (s *Service) getInitSyncBlock(r [32]byte) interfaces.SignedBeaconBlock { +func (s *Service) getInitSyncBlock(r [32]byte) block.SignedBeaconBlock { s.initSyncBlocksLock.RLock() defer s.initSyncBlocksLock.RUnlock() b := s.initSyncBlocks[r] @@ -31,11 +31,11 @@ func (s *Service) getInitSyncBlock(r [32]byte) interfaces.SignedBeaconBlock { // This retrieves all the beacon blocks from the initial sync blocks cache, the returned // blocks are unordered. -func (s *Service) getInitSyncBlocks() []interfaces.SignedBeaconBlock { +func (s *Service) getInitSyncBlocks() []block.SignedBeaconBlock { s.initSyncBlocksLock.RLock() defer s.initSyncBlocksLock.RUnlock() - blks := make([]interfaces.SignedBeaconBlock, 0, len(s.initSyncBlocks)) + blks := make([]block.SignedBeaconBlock, 0, len(s.initSyncBlocks)) for _, b := range s.initSyncBlocks { blks = append(blks, b) } @@ -46,5 +46,5 @@ func (s *Service) getInitSyncBlocks() []interfaces.SignedBeaconBlock { func (s *Service) clearInitSyncBlocks() { s.initSyncBlocksLock.Lock() defer s.initSyncBlocksLock.Unlock() - s.initSyncBlocks = make(map[[32]byte]interfaces.SignedBeaconBlock) + s.initSyncBlocks = make(map[[32]byte]block.SignedBeaconBlock) } diff --git a/beacon-chain/blockchain/log.go b/beacon-chain/blockchain/log.go index e14de004b4..912a5d2d48 100644 --- a/beacon-chain/blockchain/log.go +++ b/beacon-chain/blockchain/log.go @@ -6,8 +6,8 @@ import ( "time" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/sirupsen/logrus" @@ -16,7 +16,7 @@ import ( var log = logrus.WithField("prefix", "blockchain") // logs state transition related data every slot. -func logStateTransitionData(b interfaces.BeaconBlock) { +func logStateTransitionData(b block.BeaconBlock) { log := log.WithField("slot", b.Slot) if len(b.Body().Attestations()) > 0 { log = log.WithField("attestations", len(b.Body().Attestations())) @@ -36,7 +36,7 @@ func logStateTransitionData(b interfaces.BeaconBlock) { log.Info("Finished applying state transition") } -func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error { +func logBlockSyncStatus(block block.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error { startTime, err := helpers.SlotToTime(genesisTime, block.Slot()) if err != nil { return err diff --git a/beacon-chain/blockchain/log_test.go b/beacon-chain/blockchain/log_test.go index 2389869b98..b2284d4c5b 100644 --- a/beacon-chain/blockchain/log_test.go +++ b/beacon-chain/blockchain/log_test.go @@ -3,9 +3,9 @@ package blockchain import ( "testing" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/testutil/require" logTest "github.com/sirupsen/logrus/hooks/test" ) @@ -13,7 +13,7 @@ import ( func Test_logStateTransitionData(t *testing.T) { tests := []struct { name string - b interfaces.BeaconBlock + b block.BeaconBlock want string }{ {name: "empty block body", diff --git a/beacon-chain/blockchain/metrics.go b/beacon-chain/blockchain/metrics.go index b43d4d24a7..0806e1217a 100644 --- a/beacon-chain/blockchain/metrics.go +++ b/beacon-chain/blockchain/metrics.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -228,7 +228,7 @@ func reportEpochMetrics(ctx context.Context, postState, headState state.BeaconSt return nil } -func reportAttestationInclusion(blk interfaces.BeaconBlock) { +func reportAttestationInclusion(blk block.BeaconBlock) { for _, att := range blk.Body().Attestations() { attestationInclusionDelay.Observe(float64(blk.Slot() - att.Data.Slot)) } diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 8432c044a2..4e9d5e6ad9 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -12,8 +12,8 @@ import ( core "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/state" ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -83,7 +83,7 @@ var initialSyncBlockCacheSize = uint64(2 * params.BeaconConfig().SlotsPerEpoch) // ancestor_at_finalized_slot = get_ancestor(store, store.justified_checkpoint.root, finalized_slot) // if ancestor_at_finalized_slot != store.finalized_checkpoint.root: // store.justified_checkpoint = state.current_justified_checkpoint -func (s *Service) onBlock(ctx context.Context, signed interfaces.SignedBeaconBlock, blockRoot [32]byte) error { +func (s *Service) onBlock(ctx context.Context, signed block.SignedBeaconBlock, blockRoot [32]byte) error { ctx, span := trace.StartSpan(ctx, "blockChain.onBlock") defer span.End() @@ -195,7 +195,7 @@ func (s *Service) onBlock(ctx context.Context, signed interfaces.SignedBeaconBlo return s.handleEpochBoundary(ctx, postState) } -func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.SignedBeaconBlock, +func (s *Service) onBlockBatch(ctx context.Context, blks []block.SignedBeaconBlock, blockRoots [][32]byte) ([]*ethpb.Checkpoint, []*ethpb.Checkpoint, error) { ctx, span := trace.StartSpan(ctx, "blockChain.onBlockBatch") defer span.End() @@ -271,7 +271,7 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.SignedBeac // handles a block after the block's batch has been verified, where we can save blocks // their state summaries and split them off to relative hot/cold storage. -func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed interfaces.SignedBeaconBlock, +func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed block.SignedBeaconBlock, blockRoot [32]byte, fCheckpoint, jCheckpoint *ethpb.Checkpoint) error { b := signed.Block() @@ -353,7 +353,7 @@ func (s *Service) handleEpochBoundary(ctx context.Context, postState state.Beaco // This feeds in the block and block's attestations to fork choice store. It's allows fork choice store // to gain information on the most current chain. -func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Context, blk interfaces.BeaconBlock, root [32]byte, +func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Context, blk block.BeaconBlock, root [32]byte, st state.BeaconState) error { fCheckpoint := st.FinalizedCheckpoint() jCheckpoint := st.CurrentJustifiedCheckpoint() @@ -375,7 +375,7 @@ func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Contex return nil } -func (s *Service) insertBlockToForkChoiceStore(ctx context.Context, blk interfaces.BeaconBlock, +func (s *Service) insertBlockToForkChoiceStore(ctx context.Context, blk block.BeaconBlock, root [32]byte, fCheckpoint, jCheckpoint *ethpb.Checkpoint) error { if err := s.fillInForkChoiceMissingBlocks(ctx, blk, fCheckpoint, jCheckpoint); err != nil { return err @@ -392,7 +392,7 @@ func (s *Service) insertBlockToForkChoiceStore(ctx context.Context, blk interfac // This saves post state info to DB or cache. This also saves post state info to fork choice store. // Post state info consists of processed block and state. Do not call this method unless the block and state are verified. -func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b interfaces.SignedBeaconBlock, st state.BeaconState, initSync bool) error { +func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b block.SignedBeaconBlock, st state.BeaconState, initSync bool) error { ctx, span := trace.StartSpan(ctx, "blockChain.savePostStateInfo") defer span.End() if initSync { diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index 7e73348889..757deed3c8 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -9,8 +9,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -27,7 +27,7 @@ func (s *Service) CurrentSlot() types.Slot { // getBlockPreState returns the pre state of an incoming block. It uses the parent root of the block // to retrieve the state in DB. It verifies the pre state's validity and the incoming block // is in the correct time window. -func (s *Service) getBlockPreState(ctx context.Context, b interfaces.BeaconBlock) (state.BeaconState, error) { +func (s *Service) getBlockPreState(ctx context.Context, b block.BeaconBlock) (state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "blockChain.getBlockPreState") defer span.End() @@ -58,7 +58,7 @@ func (s *Service) getBlockPreState(ctx context.Context, b interfaces.BeaconBlock } // verifyBlkPreState validates input block has a valid pre-state. -func (s *Service) verifyBlkPreState(ctx context.Context, b interfaces.BeaconBlock) error { +func (s *Service) verifyBlkPreState(ctx context.Context, b block.BeaconBlock) error { ctx, span := trace.StartSpan(ctx, "blockChain.verifyBlkPreState") defer span.End() @@ -121,7 +121,7 @@ func (s *Service) VerifyBlkDescendant(ctx context.Context, root [32]byte) error // verifyBlkFinalizedSlot validates input block is not less than or equal // to current finalized slot. -func (s *Service) verifyBlkFinalizedSlot(b interfaces.BeaconBlock) error { +func (s *Service) verifyBlkFinalizedSlot(b block.BeaconBlock) error { finalizedSlot, err := helpers.StartSlot(s.finalizedCheckpt.Epoch) if err != nil { return err @@ -140,7 +140,7 @@ func (s *Service) shouldUpdateCurrentJustified(ctx context.Context, newJustified if helpers.SlotsSinceEpochStarts(s.CurrentSlot()) < params.BeaconConfig().SafeSlotsToUpdateJustified { return true, nil } - var newJustifiedBlockSigned interfaces.SignedBeaconBlock + var newJustifiedBlockSigned block.SignedBeaconBlock justifiedRoot := s.ensureRootNotZeros(bytesutil.ToBytes32(newJustifiedCheckpt.Root)) var err error if s.hasInitSyncBlock(justifiedRoot) { @@ -163,7 +163,7 @@ func (s *Service) shouldUpdateCurrentJustified(ctx context.Context, newJustified if newJustifiedBlock.Slot() <= jSlot { return false, nil } - var justifiedBlockSigned interfaces.SignedBeaconBlock + var justifiedBlockSigned block.SignedBeaconBlock cachedJustifiedRoot := s.ensureRootNotZeros(bytesutil.ToBytes32(s.justifiedCheckpt.Root)) if s.hasInitSyncBlock(cachedJustifiedRoot) { justifiedBlockSigned = s.getInitSyncBlock(cachedJustifiedRoot) @@ -364,9 +364,9 @@ func (s *Service) finalizedImpliesNewJustified(ctx context.Context, state state. // This retrieves missing blocks from DB (ie. the blocks that couldn't be received over sync) and inserts them to fork choice store. // This is useful for block tree visualizer and additional vote accounting. -func (s *Service) fillInForkChoiceMissingBlocks(ctx context.Context, blk interfaces.BeaconBlock, +func (s *Service) fillInForkChoiceMissingBlocks(ctx context.Context, blk block.BeaconBlock, fCheckpoint, jCheckpoint *ethpb.Checkpoint) error { - pendingNodes := make([]interfaces.BeaconBlock, 0) + pendingNodes := make([]block.BeaconBlock, 0) pendingRoots := make([][32]byte, 0) parentRoot := bytesutil.ToBytes32(blk.ParentRoot()) diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index ffb922ab96..3b406d1daf 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -20,9 +20,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -155,7 +155,7 @@ func TestStore_OnBlockBatch(t *testing.T) { bState := st.Copy() - var blks []interfaces.SignedBeaconBlock + var blks []block.SignedBeaconBlock var blkRoots [][32]byte var firstState state.BeaconState for i := 1; i < 10; i++ { diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index db15b9f759..c1576f4d45 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -8,7 +8,7 @@ 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/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -20,8 +20,8 @@ var epochsSinceFinalitySaveHotStateDB = types.Epoch(100) // BlockReceiver interface defines the methods of chain service receive and processing new blocks. type BlockReceiver interface { - ReceiveBlock(ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error - ReceiveBlockBatch(ctx context.Context, blocks []interfaces.SignedBeaconBlock, blkRoots [][32]byte) error + ReceiveBlock(ctx context.Context, block block.SignedBeaconBlock, blockRoot [32]byte) error + ReceiveBlockBatch(ctx context.Context, blocks []block.SignedBeaconBlock, blkRoots [][32]byte) error HasInitSyncBlock(root [32]byte) bool } @@ -30,7 +30,7 @@ type BlockReceiver interface { // 1. Validate block, apply state transition and update check points // 2. Apply fork choice to the processed block // 3. Save latest head info -func (s *Service) ReceiveBlock(ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { +func (s *Service) ReceiveBlock(ctx context.Context, block block.SignedBeaconBlock, blockRoot [32]byte) error { ctx, span := trace.StartSpan(ctx, "blockChain.ReceiveBlock") defer span.End() receivedTime := timeutils.Now() @@ -86,7 +86,7 @@ func (s *Service) ReceiveBlock(ctx context.Context, block interfaces.SignedBeaco // ReceiveBlockBatch processes the whole block batch at once, assuming the block batch is linear ,transitioning // the state, performing batch verification of all collected signatures and then performing the appropriate // actions for a block post-transition. -func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []interfaces.SignedBeaconBlock, blkRoots [][32]byte) error { +func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []block.SignedBeaconBlock, blkRoots [][32]byte) error { ctx, span := trace.StartSpan(ctx, "blockChain.ReceiveBlockBatch") defer span.End() @@ -134,7 +134,7 @@ func (s *Service) HasInitSyncBlock(root [32]byte) bool { return s.hasInitSyncBlock(root) } -func (s *Service) handlePostBlockOperations(b interfaces.BeaconBlock) error { +func (s *Service) handlePostBlockOperations(b block.BeaconBlock) error { // Delete the processed block attestations from attestation pool. if err := s.deletePoolAtts(b.Body().Attestations()); err != nil { return err diff --git a/beacon-chain/blockchain/receive_block_test.go b/beacon-chain/blockchain/receive_block_test.go index cbf23071ba..78cecb1097 100644 --- a/beacon-chain/blockchain/receive_block_test.go +++ b/beacon-chain/blockchain/receive_block_test.go @@ -14,9 +14,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" @@ -272,7 +272,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{wrapper.WrappedPhase0SignedBeaconBlock(tt.args.block)} + blks := []block.SignedBeaconBlock{wrapper.WrappedPhase0SignedBeaconBlock(tt.args.block)} roots := [][32]byte{root} err = s.ReceiveBlockBatch(ctx, blks, roots) if tt.wantedErr != "" { @@ -296,7 +296,7 @@ func TestService_ReceiveBlockBatch_UpdateFinalizedCheckpoint(t *testing.T) { genesis, keys := testutil.DeterministicGenesisState(t, 64) // Generate 5 epochs worth of blocks. - var blks []interfaces.SignedBeaconBlock + var blks []block.SignedBeaconBlock var roots [][32]byte copied := genesis.Copy() for i := types.Slot(1); i < params.BeaconConfig().SlotsPerEpoch*5; i++ { diff --git a/beacon-chain/blockchain/service.go b/beacon-chain/blockchain/service.go index d832669efb..81d03e68a2 100644 --- a/beacon-chain/blockchain/service.go +++ b/beacon-chain/blockchain/service.go @@ -28,8 +28,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -60,7 +60,7 @@ type Service struct { nextEpochBoundarySlot types.Slot boundaryRoots [][32]byte checkpointStateCache *cache.CheckpointStateCache - initSyncBlocks map[[32]byte]interfaces.SignedBeaconBlock + initSyncBlocks map[[32]byte]block.SignedBeaconBlock initSyncBlocksLock sync.RWMutex justifiedBalances []uint64 justifiedBalancesLock sync.RWMutex @@ -95,7 +95,7 @@ func NewService(ctx context.Context, cfg *Config) (*Service, error) { cancel: cancel, boundaryRoots: [][32]byte{}, checkpointStateCache: cache.NewCheckpointStateCache(), - initSyncBlocks: make(map[[32]byte]interfaces.SignedBeaconBlock), + initSyncBlocks: make(map[[32]byte]block.SignedBeaconBlock), justifiedBalances: make([]uint64, 0), }, nil } diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index 7a7a1ed830..57f54ab3d1 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -23,10 +23,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" protodb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" @@ -456,7 +456,7 @@ func TestServiceStop_SaveCachedBlocks(t *testing.T) { cfg: &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB)}, ctx: ctx, cancel: cancel, - initSyncBlocks: make(map[[32]byte]interfaces.SignedBeaconBlock), + initSyncBlocks: make(map[[32]byte]block.SignedBeaconBlock), } block := testutil.NewBeaconBlock() r, err := block.Block.HashTreeRoot() diff --git a/beacon-chain/blockchain/testing/BUILD.bazel b/beacon-chain/blockchain/testing/BUILD.bazel index 021f1aafcf..309f590941 100644 --- a/beacon-chain/blockchain/testing/BUILD.bazel +++ b/beacon-chain/blockchain/testing/BUILD.bazel @@ -20,8 +20,8 @@ go_library( "//beacon-chain/forkchoice/protoarray:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", diff --git a/beacon-chain/blockchain/testing/mock.go b/beacon-chain/blockchain/testing/mock.go index 11fc17f5a5..4b4a1fa279 100644 --- a/beacon-chain/blockchain/testing/mock.go +++ b/beacon-chain/blockchain/testing/mock.go @@ -20,8 +20,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/event" @@ -33,11 +33,11 @@ import ( type ChainService struct { State state.BeaconState Root []byte - Block interfaces.SignedBeaconBlock + Block block.SignedBeaconBlock FinalizedCheckPoint *ethpb.Checkpoint CurrentJustifiedCheckPoint *ethpb.Checkpoint PreviousJustifiedCheckPoint *ethpb.Checkpoint - BlocksReceived []interfaces.SignedBeaconBlock + BlocksReceived []block.SignedBeaconBlock Balance *precompute.Balance Genesis time.Time ValidatorsRoot [32]byte @@ -150,7 +150,7 @@ func (mon *MockOperationNotifier) OperationFeed() *event.Feed { } // ReceiveBlockInitialSync mocks ReceiveBlockInitialSync method in chain service. -func (s *ChainService) ReceiveBlockInitialSync(ctx context.Context, block interfaces.SignedBeaconBlock, _ [32]byte) error { +func (s *ChainService) ReceiveBlockInitialSync(ctx context.Context, block block.SignedBeaconBlock, _ [32]byte) error { if s.State == nil { s.State = &v1.BeaconState{} } @@ -177,7 +177,7 @@ func (s *ChainService) ReceiveBlockInitialSync(ctx context.Context, block interf } // ReceiveBlockBatch processes blocks in batches from initial-sync. -func (s *ChainService) ReceiveBlockBatch(ctx context.Context, blks []interfaces.SignedBeaconBlock, _ [][32]byte) error { +func (s *ChainService) ReceiveBlockBatch(ctx context.Context, blks []block.SignedBeaconBlock, _ [][32]byte) error { if s.State == nil { s.State = &v1.BeaconState{} } @@ -206,7 +206,7 @@ func (s *ChainService) ReceiveBlockBatch(ctx context.Context, blks []interfaces. } // ReceiveBlock mocks ReceiveBlock method in chain service. -func (s *ChainService) ReceiveBlock(ctx context.Context, block interfaces.SignedBeaconBlock, _ [32]byte) error { +func (s *ChainService) ReceiveBlock(ctx context.Context, block block.SignedBeaconBlock, _ [32]byte) error { if s.State == nil { s.State = &v1.BeaconState{} } @@ -249,7 +249,7 @@ func (s *ChainService) HeadRoot(_ context.Context) ([]byte, error) { } // HeadBlock mocks HeadBlock method in chain service. -func (s *ChainService) HeadBlock(context.Context) (interfaces.SignedBeaconBlock, error) { +func (s *ChainService) HeadBlock(context.Context) (block.SignedBeaconBlock, error) { return s.Block, nil } diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 5121c1f01a..94a06536d7 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -27,8 +27,8 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", diff --git a/beacon-chain/core/blocks/attestation.go b/beacon-chain/core/blocks/attestation.go index d7b2a2b658..a3c2e86c81 100644 --- a/beacon-chain/core/blocks/attestation.go +++ b/beacon-chain/core/blocks/attestation.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bls" @@ -22,7 +22,7 @@ import ( func ProcessAttestations( ctx context.Context, beaconState state.BeaconState, - b interfaces.SignedBeaconBlock, + b block.SignedBeaconBlock, ) (state.BeaconState, error) { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return nil, err @@ -84,7 +84,7 @@ func ProcessAttestation( func ProcessAttestationsNoVerifySignature( ctx context.Context, beaconState state.BeaconState, - b interfaces.SignedBeaconBlock, + b block.SignedBeaconBlock, ) (state.BeaconState, error) { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return nil, err diff --git a/beacon-chain/core/blocks/header.go b/beacon-chain/core/blocks/header.go index ebe319a56c..08cd48ef3a 100644 --- a/beacon-chain/core/blocks/header.go +++ b/beacon-chain/core/blocks/header.go @@ -8,8 +8,8 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -41,7 +41,7 @@ import ( func ProcessBlockHeader( _ context.Context, beaconState state.BeaconState, - block interfaces.SignedBeaconBlock, + block block.SignedBeaconBlock, ) (state.BeaconState, error) { if err := helpers.VerifyNilBeaconBlock(block); err != nil { return nil, err diff --git a/beacon-chain/core/blocks/randao.go b/beacon-chain/core/blocks/randao.go index 3208d14bcd..86ffa52c16 100644 --- a/beacon-chain/core/blocks/randao.go +++ b/beacon-chain/core/blocks/randao.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -28,7 +28,7 @@ import ( func ProcessRandao( _ context.Context, beaconState state.BeaconState, - b interfaces.SignedBeaconBlock, + b block.SignedBeaconBlock, ) (state.BeaconState, error) { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return nil, err diff --git a/beacon-chain/core/feed/block/BUILD.bazel b/beacon-chain/core/feed/block/BUILD.bazel index 18f9ec2a69..2579d6bdbf 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", + "//proto/prysm/v2/block:go_default_library", "//shared/event:go_default_library", ], ) diff --git a/beacon-chain/core/feed/block/events.go b/beacon-chain/core/feed/block/events.go index 834b808650..75e364db81 100644 --- a/beacon-chain/core/feed/block/events.go +++ b/beacon-chain/core/feed/block/events.go @@ -3,7 +3,7 @@ package block import ( - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) const ( @@ -13,5 +13,5 @@ const ( // ReceivedBlockData is the data sent with ReceivedBlock events. type ReceivedBlockData struct { - SignedBlock interfaces.SignedBeaconBlock + SignedBlock block.SignedBeaconBlock } diff --git a/beacon-chain/core/feed/state/BUILD.bazel b/beacon-chain/core/feed/state/BUILD.bazel index 0143374e12..0ffe9f6401 100644 --- a/beacon-chain/core/feed/state/BUILD.bazel +++ b/beacon-chain/core/feed/state/BUILD.bazel @@ -9,7 +9,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state", visibility = ["//beacon-chain:__subpackages__"], deps = [ - "//proto/interfaces:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/event: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 c31e477b31..d29fc77c71 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/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) const ( @@ -35,7 +35,7 @@ type BlockProcessedData struct { // BlockRoot of the processed block. BlockRoot [32]byte // SignedBlock is the physical processed block. - SignedBlock interfaces.SignedBeaconBlock + SignedBlock block.SignedBeaconBlock // Verified is true if the block's BLS contents have been verified. Verified bool } diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 7749498094..ce96eeddfa 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -36,8 +36,8 @@ go_library( deps = [ "//beacon-chain/cache:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/beacon-chain/core/helpers/block.go b/beacon-chain/core/helpers/block.go index 378fba26a6..a07e40061f 100644 --- a/beacon-chain/core/helpers/block.go +++ b/beacon-chain/core/helpers/block.go @@ -6,14 +6,14 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" ) // VerifyNilBeaconBlock checks if any composite field of input signed beacon block is nil. // Access to these nil fields will result in run time panic, // it is recommended to run these checks as first line of defense. -func VerifyNilBeaconBlock(b interfaces.SignedBeaconBlock) error { +func VerifyNilBeaconBlock(b block.SignedBeaconBlock) error { if b == nil || b.IsNil() { return errors.New("signed beacon block can't be nil") } diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index fecab1d727..8b874c2ef3 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -34,8 +34,8 @@ go_library( "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/beacon-chain/core/state/interop/BUILD.bazel b/beacon-chain/core/state/interop/BUILD.bazel index c291915654..cf103eb3cf 100644 --- a/beacon-chain/core/state/interop/BUILD.bazel +++ b/beacon-chain/core/state/interop/BUILD.bazel @@ -14,7 +14,7 @@ go_library( ], deps = [ "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/featureconfig:go_default_library", "//shared/fileutil: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 1d86e5688c..830556f728 100644 --- a/beacon-chain/core/state/interop/write_block_to_disk.go +++ b/beacon-chain/core/state/interop/write_block_to_disk.go @@ -5,13 +5,13 @@ import ( "os" "path" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/fileutil" ) // WriteBlockToDisk as a block ssz. Writes to temp directory. Debug! -func WriteBlockToDisk(block interfaces.SignedBeaconBlock, failed bool) { +func WriteBlockToDisk(block block.SignedBeaconBlock, failed bool) { if !featureconfig.Get().WriteSSZStateTransitions { return } diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index f310cdda30..b75f993fd2 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" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -25,24 +25,24 @@ import ( ) // processFunc is a function that processes a block with a given state. State is mutated. -type processFunc func(context.Context, state.BeaconState, interfaces.SignedBeaconBlock) (state.BeaconState, error) +type processFunc func(context.Context, state.BeaconState, block.SignedBeaconBlock) (state.BeaconState, error) -var processDepositsFunc = func(ctx context.Context, s state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) { +var processDepositsFunc = func(ctx context.Context, s state.BeaconState, blk block.SignedBeaconBlock) (state.BeaconState, error) { return b.ProcessDeposits(ctx, s, blk.Block().Body().Deposits()) } -var processProposerSlashingFunc = func(ctx context.Context, s state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) { +var processProposerSlashingFunc = func(ctx context.Context, s state.BeaconState, blk block.SignedBeaconBlock) (state.BeaconState, error) { return b.ProcessProposerSlashings(ctx, s, blk.Block().Body().ProposerSlashings(), v.SlashValidator) } -var processAttesterSlashingFunc = func(ctx context.Context, s state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) { +var processAttesterSlashingFunc = func(ctx context.Context, s state.BeaconState, blk block.SignedBeaconBlock) (state.BeaconState, error) { return b.ProcessAttesterSlashings(ctx, s, blk.Block().Body().AttesterSlashings(), v.SlashValidator) } -var processEth1DataFunc = func(ctx context.Context, s state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) { +var processEth1DataFunc = func(ctx context.Context, s state.BeaconState, blk block.SignedBeaconBlock) (state.BeaconState, error) { return b.ProcessEth1DataInBlock(ctx, s, blk.Block().Body().Eth1Data()) } -var processExitFunc = func(ctx context.Context, s state.BeaconState, blk interfaces.SignedBeaconBlock) (state.BeaconState, error) { +var processExitFunc = func(ctx context.Context, s state.BeaconState, blk block.SignedBeaconBlock) (state.BeaconState, error) { return b.ProcessVoluntaryExits(ctx, s, blk.Block().Body().VoluntaryExits()) } @@ -81,7 +81,7 @@ var processingPipeline = []processFunc{ func ExecuteStateTransition( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (state.BeaconState, error) { if ctx.Err() != nil { return nil, ctx.Err() @@ -308,7 +308,7 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) func ProcessBlock( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "core.state.ProcessBlock") defer span.End() @@ -329,7 +329,7 @@ func ProcessBlock( } // VerifyOperationLengths verifies that block operation lengths are valid. -func VerifyOperationLengths(_ context.Context, state state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { +func VerifyOperationLengths(_ context.Context, state state.BeaconState, b block.SignedBeaconBlock) (state.BeaconState, error) { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return nil, err } diff --git a/beacon-chain/core/state/transition_no_verify_sig.go b/beacon-chain/core/state/transition_no_verify_sig.go index 61ce25ab9c..4fa9b9800f 100644 --- a/beacon-chain/core/state/transition_no_verify_sig.go +++ b/beacon-chain/core/state/transition_no_verify_sig.go @@ -11,7 +11,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -42,7 +42,7 @@ import ( func ExecuteStateTransitionNoVerifyAnySig( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (*bls.SignatureSet, state.BeaconState, error) { if ctx.Err() != nil { return nil, nil, ctx.Err() @@ -113,7 +113,7 @@ func ExecuteStateTransitionNoVerifyAnySig( func CalculateStateRoot( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) ([32]byte, error) { ctx, span := trace.StartSpan(ctx, "core.state.CalculateStateRoot") defer span.End() @@ -169,7 +169,7 @@ func CalculateStateRoot( func ProcessBlockNoVerifyAnySig( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (*bls.SignatureSet, state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "core.state.ProcessBlockNoVerifyAnySig") defer span.End() @@ -229,7 +229,7 @@ func ProcessBlockNoVerifyAnySig( func ProcessOperationsNoVerifyAttsSigs( ctx context.Context, state state.BeaconState, - signedBeaconBlock interfaces.SignedBeaconBlock) (state.BeaconState, error) { + signedBeaconBlock block.SignedBeaconBlock) (state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "core.state.ProcessOperationsNoVerifyAttsSigs") defer span.End() if err := helpers.VerifyNilBeaconBlock(signedBeaconBlock); err != nil { @@ -269,7 +269,7 @@ func ProcessOperationsNoVerifyAttsSigs( func ProcessBlockForStateRoot( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "core.state.ProcessBlockForStateRoot") defer span.End() diff --git a/beacon-chain/db/iface/BUILD.bazel b/beacon-chain/db/iface/BUILD.bazel index 9f2f0b50a8..e5ede984a3 100644 --- a/beacon-chain/db/iface/BUILD.bazel +++ b/beacon-chain/db/iface/BUILD.bazel @@ -13,9 +13,9 @@ go_library( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/slasher/types:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/backuputil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", diff --git a/beacon-chain/db/iface/interface.go b/beacon-chain/db/iface/interface.go index af16821f24..b0476af040 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -12,9 +12,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/backuputil" ) @@ -22,16 +22,16 @@ import ( // ReadOnlyDatabase defines a struct which only has read access to database methods. type ReadOnlyDatabase interface { // Block related methods. - Block(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) - Blocks(ctx context.Context, f *filters.QueryFilter) ([]interfaces.SignedBeaconBlock, [][32]byte, error) + Block(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) + Blocks(ctx context.Context, f *filters.QueryFilter) ([]block.SignedBeaconBlock, [][32]byte, error) BlockRoots(ctx context.Context, f *filters.QueryFilter) ([][32]byte, error) - BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []interfaces.SignedBeaconBlock, error) + BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []block.SignedBeaconBlock, error) BlockRootsBySlot(ctx context.Context, slot types.Slot) (bool, [][32]byte, error) HasBlock(ctx context.Context, blockRoot [32]byte) bool - GenesisBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) + GenesisBlock(ctx context.Context) (block.SignedBeaconBlock, error) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool - FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) - HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]interfaces.SignedBeaconBlock, error) + FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) + HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]block.SignedBeaconBlock, error) // State related methods. State(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error) GenesisState(ctx context.Context) (state.BeaconState, error) @@ -65,8 +65,8 @@ type NoHeadAccessDatabase interface { ReadOnlyDatabase // Block related methods. - SaveBlock(ctx context.Context, block interfaces.SignedBeaconBlock) error - SaveBlocks(ctx context.Context, blocks []interfaces.SignedBeaconBlock) error + SaveBlock(ctx context.Context, block block.SignedBeaconBlock) error + SaveBlocks(ctx context.Context, blocks []block.SignedBeaconBlock) error SaveGenesisBlockRoot(ctx context.Context, blockRoot [32]byte) error // State related methods. SaveState(ctx context.Context, state state.ReadOnlyBeaconState, blockRoot [32]byte) error @@ -98,7 +98,7 @@ type HeadAccessDatabase interface { NoHeadAccessDatabase // Block related methods. - HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) + HeadBlock(ctx context.Context) (block.SignedBeaconBlock, error) SaveHeadBlockRoot(ctx context.Context, blockRoot [32]byte) error // Genesis operations. diff --git a/beacon-chain/db/kafka/BUILD.bazel b/beacon-chain/db/kafka/BUILD.bazel index 5021a4f231..c2b3a8b058 100644 --- a/beacon-chain/db/kafka/BUILD.bazel +++ b/beacon-chain/db/kafka/BUILD.bazel @@ -14,9 +14,9 @@ go_library( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/db/iface:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/featureconfig:go_default_library", "//shared/traceutil:go_default_library", diff --git a/beacon-chain/db/kafka/export_wrapper.go b/beacon-chain/db/kafka/export_wrapper.go index d8dd395fd8..6df9274ad7 100644 --- a/beacon-chain/db/kafka/export_wrapper.go +++ b/beacon-chain/db/kafka/export_wrapper.go @@ -7,7 +7,7 @@ import ( fssz "github.com/ferranbt/fastssz" "github.com/prysmaticlabs/prysm/beacon-chain/db/iface" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" @@ -41,7 +41,7 @@ func Wrap(db iface.Database) (iface.Database, error) { return &Exporter{db: db, p: p}, nil } -func (e Exporter) publish(ctx context.Context, topic string, msg interfaces.SignedBeaconBlock) error { +func (e Exporter) publish(ctx context.Context, topic string, msg block.SignedBeaconBlock) error { ctx, span := trace.StartSpan(ctx, "kafka.publish") defer span.End() @@ -83,7 +83,7 @@ func (e Exporter) Close() error { } // SaveBlock publishes to the kafka topic for beacon blocks. -func (e Exporter) SaveBlock(ctx context.Context, block interfaces.SignedBeaconBlock) error { +func (e Exporter) SaveBlock(ctx context.Context, block block.SignedBeaconBlock) error { go func() { if err := e.publish(ctx, "beacon_block", block); err != nil { log.WithError(err).Error("Failed to publish block") @@ -94,7 +94,7 @@ func (e Exporter) SaveBlock(ctx context.Context, block interfaces.SignedBeaconBl } // SaveBlocks publishes to the kafka topic for beacon blocks. -func (e Exporter) SaveBlocks(ctx context.Context, blocks []interfaces.SignedBeaconBlock) error { +func (e Exporter) SaveBlocks(ctx context.Context, blocks []block.SignedBeaconBlock) error { go func() { for _, block := range blocks { if err := e.publish(ctx, "beacon_block", block); err != nil { diff --git a/beacon-chain/db/kafka/passthrough.go b/beacon-chain/db/kafka/passthrough.go index 60c1f114b7..ed7cf4a9cc 100644 --- a/beacon-chain/db/kafka/passthrough.go +++ b/beacon-chain/db/kafka/passthrough.go @@ -8,9 +8,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) @@ -30,17 +30,17 @@ func (e Exporter) Backup(ctx context.Context, outputDir string, overridePermissi } // Block -- passthrough. -func (e Exporter) Block(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) { +func (e Exporter) Block(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) { return e.db.Block(ctx, blockRoot) } // HeadBlock -- passthrough. -func (e Exporter) HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) { +func (e Exporter) HeadBlock(ctx context.Context) (block.SignedBeaconBlock, error) { return e.db.HeadBlock(ctx) } // Blocks -- passthrough. -func (e Exporter) Blocks(ctx context.Context, f *filters.QueryFilter) ([]interfaces.SignedBeaconBlock, [][32]byte, error) { +func (e Exporter) Blocks(ctx context.Context, f *filters.QueryFilter) ([]block.SignedBeaconBlock, [][32]byte, error) { return e.db.Blocks(ctx, f) } @@ -50,7 +50,7 @@ func (e Exporter) BlockRoots(ctx context.Context, f *filters.QueryFilter) ([][32 } // BlocksBySlot -- passthrough. -func (e Exporter) BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []interfaces.SignedBeaconBlock, error) { +func (e Exporter) BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []block.SignedBeaconBlock, error) { return e.db.BlocksBySlot(ctx, slot) } @@ -130,7 +130,7 @@ func (e Exporter) SaveHeadBlockRoot(ctx context.Context, blockRoot [32]byte) err } // GenesisBlock -- passthrough. -func (e Exporter) GenesisBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) { +func (e Exporter) GenesisBlock(ctx context.Context) (block.SignedBeaconBlock, error) { return e.db.GenesisBlock(ctx) } @@ -215,7 +215,7 @@ func (e Exporter) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool } // FinalizedChildBlock -- passthrough. -func (e Exporter) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) { +func (e Exporter) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) { return e.db.FinalizedChildBlock(ctx, blockRoot) } @@ -245,7 +245,7 @@ func (e Exporter) LastArchivedRoot(ctx context.Context) [32]byte { } // HighestSlotBlocksBelow -- passthrough -func (e Exporter) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]interfaces.SignedBeaconBlock, error) { +func (e Exporter) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]block.SignedBeaconBlock, error) { return e.db.HighestSlotBlocksBelow(ctx, slot) } diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index befbf203dc..f35d8fe730 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -39,10 +39,10 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/genesis:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/fileutil:go_default_library", @@ -92,10 +92,10 @@ go_test( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/db/iface:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//proto/testing:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/beacon-chain/db/kv/blocks.go b/beacon-chain/db/kv/blocks.go index 586abc7393..7f5f01e8b5 100644 --- a/beacon-chain/db/kv/blocks.go +++ b/beacon-chain/db/kv/blocks.go @@ -9,9 +9,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" @@ -23,12 +23,12 @@ import ( var errInvalidSlotRange = errors.New("invalid end slot and start slot provided") // Block retrieval by root. -func (s *Store) Block(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) { +func (s *Store) Block(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.Block") defer span.End() // Return block from cache if it exists. if v, ok := s.blockCache.Get(string(blockRoot[:])); v != nil && ok { - return v.(interfaces.SignedBeaconBlock), nil + return v.(block.SignedBeaconBlock), nil } var block *ethpb.SignedBeaconBlock err := s.db.View(func(tx *bolt.Tx) error { @@ -44,7 +44,7 @@ func (s *Store) Block(ctx context.Context, blockRoot [32]byte) (interfaces.Signe } // HeadBlock returns the latest canonical block in the Ethereum Beacon Chain. -func (s *Store) HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) { +func (s *Store) HeadBlock(ctx context.Context) (block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.HeadBlock") defer span.End() var headBlock *ethpb.SignedBeaconBlock @@ -65,10 +65,10 @@ func (s *Store) HeadBlock(ctx context.Context) (interfaces.SignedBeaconBlock, er } // Blocks retrieves a list of beacon blocks and its respective roots by filter criteria. -func (s *Store) Blocks(ctx context.Context, f *filters.QueryFilter) ([]interfaces.SignedBeaconBlock, [][32]byte, error) { +func (s *Store) Blocks(ctx context.Context, f *filters.QueryFilter) ([]block.SignedBeaconBlock, [][32]byte, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.Blocks") defer span.End() - blocks := make([]interfaces.SignedBeaconBlock, 0) + blocks := make([]block.SignedBeaconBlock, 0) blockRoots := make([][32]byte, 0) err := s.db.View(func(tx *bolt.Tx) error { @@ -138,10 +138,10 @@ func (s *Store) HasBlock(ctx context.Context, blockRoot [32]byte) bool { } // BlocksBySlot retrieves a list of beacon blocks and its respective roots by slot. -func (s *Store) BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []interfaces.SignedBeaconBlock, error) { +func (s *Store) BlocksBySlot(ctx context.Context, slot types.Slot) (bool, []block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.BlocksBySlot") defer span.End() - blocks := make([]interfaces.SignedBeaconBlock, 0) + blocks := make([]block.SignedBeaconBlock, 0) err := s.db.View(func(tx *bolt.Tx) error { bkt := tx.Bucket(blocksBucket) @@ -239,7 +239,7 @@ func (s *Store) deleteBlocks(ctx context.Context, blockRoots [][32]byte) error { } // SaveBlock to the db. -func (s *Store) SaveBlock(ctx context.Context, signed interfaces.SignedBeaconBlock) error { +func (s *Store) SaveBlock(ctx context.Context, signed block.SignedBeaconBlock) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveBlock") defer span.End() blockRoot, err := signed.Block().HashTreeRoot() @@ -250,11 +250,11 @@ func (s *Store) SaveBlock(ctx context.Context, signed interfaces.SignedBeaconBlo return nil } - return s.SaveBlocks(ctx, []interfaces.SignedBeaconBlock{signed}) + return s.SaveBlocks(ctx, []block.SignedBeaconBlock{signed}) } // SaveBlocks via bulk updates to the db. -func (s *Store) SaveBlocks(ctx context.Context, blocks []interfaces.SignedBeaconBlock) error { +func (s *Store) SaveBlocks(ctx context.Context, blocks []block.SignedBeaconBlock) error { ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveBlocks") defer span.End() @@ -304,7 +304,7 @@ func (s *Store) SaveHeadBlockRoot(ctx context.Context, blockRoot [32]byte) error } // GenesisBlock retrieves the genesis block of the beacon chain. -func (s *Store) GenesisBlock(ctx context.Context) (interfaces.SignedBeaconBlock, error) { +func (s *Store) GenesisBlock(ctx context.Context) (block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.GenesisBlock") defer span.End() var block *ethpb.SignedBeaconBlock @@ -332,7 +332,7 @@ func (s *Store) SaveGenesisBlockRoot(ctx context.Context, blockRoot [32]byte) er } // HighestSlotBlocksBelow returns the block with the highest slot below the input slot from the db. -func (s *Store) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]interfaces.SignedBeaconBlock, error) { +func (s *Store) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([]block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.HighestSlotBlocksBelow") defer span.End() @@ -359,7 +359,7 @@ func (s *Store) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([] return nil, err } - var blk interfaces.SignedBeaconBlock + var blk block.SignedBeaconBlock var err error if best != nil { blk, err = s.Block(ctx, bytesutil.ToBytes32(best)) @@ -374,7 +374,7 @@ func (s *Store) HighestSlotBlocksBelow(ctx context.Context, slot types.Slot) ([] } } - return []interfaces.SignedBeaconBlock{blk}, nil + return []block.SignedBeaconBlock{blk}, nil } // blockRootsByFilter retrieves the block roots given the filter criteria. @@ -526,7 +526,7 @@ func blockRootsBySlot(ctx context.Context, tx *bolt.Tx, slot types.Slot) ([][]by // createBlockIndicesFromBlock takes in a beacon block and returns // a map of bolt DB index buckets corresponding to each particular key for indices for // data, such as (shard indices bucket -> shard 5). -func createBlockIndicesFromBlock(ctx context.Context, block interfaces.BeaconBlock) map[string][]byte { +func createBlockIndicesFromBlock(ctx context.Context, block block.BeaconBlock) map[string][]byte { ctx, span := trace.StartSpan(ctx, "BeaconDB.createBlockIndicesFromBlock") defer span.End() indicesByBucket := make(map[string][]byte) diff --git a/beacon-chain/db/kv/blocks_test.go b/beacon-chain/db/kv/blocks_test.go index 213d0bb834..d3c2e8aef5 100644 --- a/beacon-chain/db/kv/blocks_test.go +++ b/beacon-chain/db/kv/blocks_test.go @@ -7,9 +7,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -71,9 +71,9 @@ func TestStore_BlocksBatchDelete(t *testing.T) { db := setupDB(t) ctx := context.Background() numBlocks := 10 - totalBlocks := make([]interfaces.SignedBeaconBlock, numBlocks) + totalBlocks := make([]block.SignedBeaconBlock, numBlocks) blockRoots := make([][32]byte, 0) - oddBlocks := make([]interfaces.SignedBeaconBlock, 0) + oddBlocks := make([]block.SignedBeaconBlock, 0) for i := 0; i < len(totalBlocks); i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) @@ -108,7 +108,7 @@ func TestStore_BlocksHandleZeroCase(t *testing.T) { db := setupDB(t) ctx := context.Background() numBlocks := 10 - totalBlocks := make([]interfaces.SignedBeaconBlock, numBlocks) + totalBlocks := make([]block.SignedBeaconBlock, numBlocks) for i := 0; i < len(totalBlocks); i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) @@ -128,7 +128,7 @@ func TestStore_BlocksHandleInvalidEndSlot(t *testing.T) { db := setupDB(t) ctx := context.Background() numBlocks := 10 - totalBlocks := make([]interfaces.SignedBeaconBlock, numBlocks) + totalBlocks := make([]block.SignedBeaconBlock, numBlocks) // Save blocks from slot 1 onwards. for i := 0; i < len(totalBlocks); i++ { b := testutil.NewBeaconBlock() @@ -201,7 +201,7 @@ func TestStore_Blocks_FiltersCorrectly(t *testing.T) { b8 := testutil.NewBeaconBlock() b8.Block.Slot = 8 b8.Block.ParentRoot = bytesutil.PadTo([]byte("parent4"), 32) - blocks := []interfaces.SignedBeaconBlock{ + blocks := []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock(b4), wrapper.WrappedPhase0SignedBeaconBlock(b5), wrapper.WrappedPhase0SignedBeaconBlock(b6), @@ -297,7 +297,7 @@ func TestStore_Blocks_VerifyBlockRoots(t *testing.T) { func TestStore_Blocks_Retrieve_SlotRange(t *testing.T) { db := setupDB(t) - totalBlocks := make([]interfaces.SignedBeaconBlock, 500) + totalBlocks := make([]block.SignedBeaconBlock, 500) for i := 0; i < 500; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) @@ -314,7 +314,7 @@ func TestStore_Blocks_Retrieve_SlotRange(t *testing.T) { func TestStore_Blocks_Retrieve_Epoch(t *testing.T) { db := setupDB(t) slots := params.BeaconConfig().SlotsPerEpoch.Mul(7) - totalBlocks := make([]interfaces.SignedBeaconBlock, slots) + totalBlocks := make([]block.SignedBeaconBlock, slots) for i := types.Slot(0); i < slots; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = i @@ -335,7 +335,7 @@ func TestStore_Blocks_Retrieve_Epoch(t *testing.T) { func TestStore_Blocks_Retrieve_SlotRangeWithStep(t *testing.T) { db := setupDB(t) - totalBlocks := make([]interfaces.SignedBeaconBlock, 500) + totalBlocks := make([]block.SignedBeaconBlock, 500) for i := 0; i < 500; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = types.Slot(i) @@ -417,7 +417,7 @@ func TestStore_SaveBlocks_HasCachedBlocks(t *testing.T) { db := setupDB(t) ctx := context.Background() - b := make([]interfaces.SignedBeaconBlock, 500) + b := make([]block.SignedBeaconBlock, 500) for i := 0; i < 500; i++ { blk := testutil.NewBeaconBlock() blk.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) @@ -438,7 +438,7 @@ func TestStore_SaveBlocks_HasRootsMatched(t *testing.T) { db := setupDB(t) ctx := context.Background() - b := make([]interfaces.SignedBeaconBlock, 500) + b := make([]block.SignedBeaconBlock, 500) for i := 0; i < 500; i++ { blk := testutil.NewBeaconBlock() blk.Block.ParentRoot = bytesutil.PadTo([]byte("parent"), 32) diff --git a/beacon-chain/db/kv/finalized_block_roots.go b/beacon-chain/db/kv/finalized_block_roots.go index 788967b89f..d288e40390 100644 --- a/beacon-chain/db/kv/finalized_block_roots.go +++ b/beacon-chain/db/kv/finalized_block_roots.go @@ -6,10 +6,10 @@ import ( "fmt" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" @@ -184,7 +184,7 @@ func (s *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool { // FinalizedChildBlock returns the child block of a provided finalized block. If // no finalized block or its respective child block exists we return with a nil // block. -func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (interfaces.SignedBeaconBlock, error) { +func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (block.SignedBeaconBlock, error) { ctx, span := trace.StartSpan(ctx, "BeaconDB.FinalizedChildBlock") defer span.End() diff --git a/beacon-chain/db/kv/finalized_block_roots_test.go b/beacon-chain/db/kv/finalized_block_roots_test.go index e2d50c3cbb..bee227bc2b 100644 --- a/beacon-chain/db/kv/finalized_block_roots_test.go +++ b/beacon-chain/db/kv/finalized_block_roots_test.go @@ -5,9 +5,9 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -170,15 +170,15 @@ func TestStore_IsFinalizedChildBlock(t *testing.T) { } } -func sszRootOrDie(t *testing.T, block interfaces.SignedBeaconBlock) []byte { +func sszRootOrDie(t *testing.T, block block.SignedBeaconBlock) []byte { root, err := block.Block().HashTreeRoot() require.NoError(t, err) return root[:] } -func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []interfaces.SignedBeaconBlock { +func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []block.SignedBeaconBlock { blocks := make([]*ethpb.SignedBeaconBlock, n) - ifaceBlocks := make([]interfaces.SignedBeaconBlock, n) + ifaceBlocks := make([]block.SignedBeaconBlock, n) for j := i; j < n+i; j++ { parentRoot := make([]byte, 32) copy(parentRoot, previousRoot[:]) diff --git a/beacon-chain/db/kv/state_test.go b/beacon-chain/db/kv/state_test.go index 1445018dbd..4350f4149c 100644 --- a/beacon-chain/db/kv/state_test.go +++ b/beacon-chain/db/kv/state_test.go @@ -7,9 +7,9 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -66,7 +66,7 @@ func TestStore_StatesBatchDelete(t *testing.T) { db := setupDB(t) ctx := context.Background() numBlocks := 100 - totalBlocks := make([]interfaces.SignedBeaconBlock, numBlocks) + totalBlocks := make([]block.SignedBeaconBlock, numBlocks) blockRoots := make([][32]byte, 0) evenBlockRoots := make([][32]byte, 0) for i := 0; i < len(totalBlocks); i++ { diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 6ac5d76d29..8019402d99 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -49,9 +49,9 @@ go_library( "//beacon-chain/p2p/peers/scorers:go_default_library", "//beacon-chain/p2p/types:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "//proto/prysm/v2/wrapper:go_default_library", "//shared:go_default_library", "//shared/featureconfig:go_default_library", diff --git a/beacon-chain/p2p/interfaces.go b/beacon-chain/p2p/interfaces.go index e9edff6a43..1ce595f920 100644 --- a/beacon-chain/p2p/interfaces.go +++ b/beacon-chain/p2p/interfaces.go @@ -12,8 +12,8 @@ import ( "github.com/multiformats/go-multiaddr" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "google.golang.org/protobuf/proto" ) @@ -92,6 +92,6 @@ type PeersProvider interface { // MetadataProvider returns the metadata related information for the local peer. type MetadataProvider interface { - Metadata() interfaces.Metadata + Metadata() metadata.Metadata MetadataSeq() uint64 } diff --git a/beacon-chain/p2p/peers/BUILD.bazel b/beacon-chain/p2p/peers/BUILD.bazel index c453dbe011..b9abc2285f 100644 --- a/beacon-chain/p2p/peers/BUILD.bazel +++ b/beacon-chain/p2p/peers/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/p2p/peers/peerdata:go_default_library", "//beacon-chain/p2p/peers/scorers:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "//shared/params:go_default_library", "//shared/rand:go_default_library", "//shared/timeutils:go_default_library", diff --git a/beacon-chain/p2p/peers/peerdata/BUILD.bazel b/beacon-chain/p2p/peers/peerdata/BUILD.bazel index ec654f1878..dd86a7ff3c 100644 --- a/beacon-chain/p2p/peers/peerdata/BUILD.bazel +++ b/beacon-chain/p2p/peers/peerdata/BUILD.bazel @@ -6,9 +6,9 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata", visibility = ["//beacon-chain:__subpackages__"], deps = [ - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enr:go_default_library", "@com_github_libp2p_go_libp2p_core//network:go_default_library", "@com_github_libp2p_go_libp2p_core//peer:go_default_library", diff --git a/beacon-chain/p2p/peers/peerdata/store.go b/beacon-chain/p2p/peers/peerdata/store.go index 03e20c58ca..d769ff07ee 100644 --- a/beacon-chain/p2p/peers/peerdata/store.go +++ b/beacon-chain/p2p/peers/peerdata/store.go @@ -10,9 +10,9 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" ) var ( @@ -49,7 +49,7 @@ type PeerData struct { Enr *enr.Record NextValidTime time.Time // Chain related data. - MetaData interfaces.Metadata + MetaData metadata.Metadata ChainState *pb.Status ChainStateLastUpdated time.Time ChainStateValidationError error diff --git a/beacon-chain/p2p/peers/status.go b/beacon-chain/p2p/peers/status.go index be19b459cf..1ce533db3c 100644 --- a/beacon-chain/p2p/peers/status.go +++ b/beacon-chain/p2p/peers/status.go @@ -38,8 +38,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/prysmaticlabs/prysm/shared/timeutils" @@ -230,7 +230,7 @@ func (p *Status) InboundLimit() int { } // SetMetadata sets the metadata of the given remote peer. -func (p *Status) SetMetadata(pid peer.ID, metaData interfaces.Metadata) { +func (p *Status) SetMetadata(pid peer.ID, metaData metadata.Metadata) { p.store.Lock() defer p.store.Unlock() @@ -240,7 +240,7 @@ func (p *Status) SetMetadata(pid peer.ID, metaData interfaces.Metadata) { // Metadata returns a copy of the metadata corresponding to the provided // peer id. -func (p *Status) Metadata(pid peer.ID) (interfaces.Metadata, error) { +func (p *Status) Metadata(pid peer.ID) (metadata.Metadata, error) { p.store.RLock() defer p.store.RUnlock() diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index 01dc51de72..a3c563daca 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -26,7 +26,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "github.com/prysmaticlabs/prysm/shared" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/runutil" @@ -64,7 +64,7 @@ type Service struct { addrFilter *multiaddr.Filters ipLimiter *leakybucket.Collector privKey *ecdsa.PrivateKey - metaData interfaces.Metadata + metaData metadata.Metadata pubsub *pubsub.PubSub joinedTopics map[string]*pubsub.Topic joinedTopicsLock sync.Mutex @@ -342,7 +342,7 @@ func (s *Service) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) { } // Metadata returns a copy of the peer's metadata. -func (s *Service) Metadata() interfaces.Metadata { +func (s *Service) Metadata() metadata.Metadata { return s.metaData.Copy() } diff --git a/beacon-chain/p2p/testing/BUILD.bazel b/beacon-chain/p2p/testing/BUILD.bazel index d3aa5cd881..ca6124631f 100644 --- a/beacon-chain/p2p/testing/BUILD.bazel +++ b/beacon-chain/p2p/testing/BUILD.bazel @@ -21,9 +21,9 @@ go_library( "//beacon-chain/p2p/encoder:go_default_library", "//beacon-chain/p2p/peers:go_default_library", "//beacon-chain/p2p/peers/scorers:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enode:go_default_library", "@com_github_ethereum_go_ethereum//p2p/enr:go_default_library", diff --git a/beacon-chain/p2p/testing/fuzz_p2p.go b/beacon-chain/p2p/testing/fuzz_p2p.go index 4fc89e278d..07526c7bfe 100644 --- a/beacon-chain/p2p/testing/fuzz_p2p.go +++ b/beacon-chain/p2p/testing/fuzz_p2p.go @@ -12,8 +12,8 @@ import ( "github.com/multiformats/go-multiaddr" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "google.golang.org/protobuf/proto" ) @@ -74,7 +74,7 @@ func (p *FakeP2P) LeaveTopic(_ string) error { } // Metadata -- fake. -func (p *FakeP2P) Metadata() interfaces.Metadata { +func (p *FakeP2P) Metadata() metadata.Metadata { return nil } diff --git a/beacon-chain/p2p/testing/mock_metadataprovider.go b/beacon-chain/p2p/testing/mock_metadataprovider.go index ae7b9485b2..07de59eaa7 100644 --- a/beacon-chain/p2p/testing/mock_metadataprovider.go +++ b/beacon-chain/p2p/testing/mock_metadataprovider.go @@ -1,16 +1,16 @@ package testing import ( - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" ) // MockMetadataProvider is a fake implementation of the MetadataProvider interface. type MockMetadataProvider struct { - Data interfaces.Metadata + Data metadata.Metadata } // Metadata -- -func (m *MockMetadataProvider) Metadata() interfaces.Metadata { +func (m *MockMetadataProvider) Metadata() metadata.Metadata { return m.Data } diff --git a/beacon-chain/p2p/testing/p2p.go b/beacon-chain/p2p/testing/p2p.go index 3fe0d71c55..50a63538d8 100644 --- a/beacon-chain/p2p/testing/p2p.go +++ b/beacon-chain/p2p/testing/p2p.go @@ -23,8 +23,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" ) @@ -39,7 +39,7 @@ type TestP2P struct { DelaySend bool Digest [4]byte peers *peers.Status - LocalMetadata interfaces.Metadata + LocalMetadata metadata.Metadata } // NewTestP2P initializes a new p2p test service. @@ -338,7 +338,7 @@ func (p *TestP2P) ForkDigest() ([4]byte, error) { } // Metadata mocks the peer's metadata. -func (p *TestP2P) Metadata() interfaces.Metadata { +func (p *TestP2P) Metadata() metadata.Metadata { return p.LocalMetadata.Copy() } diff --git a/beacon-chain/p2p/utils.go b/beacon-chain/p2p/utils.go index 654b934e48..5cea6ab890 100644 --- a/beacon-chain/p2p/utils.go +++ b/beacon-chain/p2p/utils.go @@ -18,8 +18,8 @@ import ( "github.com/libp2p/go-libp2p-core/crypto" "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/fileutil" "github.com/prysmaticlabs/prysm/shared/iputils" @@ -109,7 +109,7 @@ func privKeyFromFile(path string) (*ecdsa.PrivateKey, error) { // Retrieves node p2p metadata from a set of configuration values // from the p2p service. // TODO: Figure out how to do a v1/v2 check. -func metaDataFromConfig(cfg *Config) (interfaces.Metadata, error) { +func metaDataFromConfig(cfg *Config) (metadata.Metadata, error) { defaultKeyPath := path.Join(cfg.DataDir, metaDataPath) metaDataPath := cfg.MetaDataDir diff --git a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel index 550fb197b2..c25c2f3492 100644 --- a/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/v1/beacon/BUILD.bazel @@ -30,10 +30,10 @@ go_library( "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/state/v1:go_default_library", "//proto/eth/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/migration:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/bytesutil:go_default_library", "//shared/featureconfig:go_default_library", "//shared/grpcutils:go_default_library", @@ -75,10 +75,10 @@ go_test( "//beacon-chain/rpc/testutil:go_default_library", "//beacon-chain/state:go_default_library", "//proto/eth/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/migration:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/beacon-chain/rpc/eth/v1/beacon/blocks.go b/beacon-chain/rpc/eth/v1/beacon/blocks.go index b03309a889..7eb75354ab 100644 --- a/beacon-chain/rpc/eth/v1/beacon/blocks.go +++ b/beacon-chain/rpc/eth/v1/beacon/blocks.go @@ -11,9 +11,9 @@ 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/interfaces" "github.com/prysmaticlabs/prysm/proto/migration" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "go.opencensus.io/trace" "google.golang.org/grpc/codes" @@ -94,7 +94,7 @@ func (bs *Server) ListBlockHeaders(ctx context.Context, req *ethpb.BlockHeadersR defer span.End() var err error - var blks []interfaces.SignedBeaconBlock + var blks []block.SignedBeaconBlock var blkRoots [][32]byte if len(req.ParentRoot) == 32 { blks, blkRoots, err = bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetParentRoot(req.ParentRoot)) @@ -352,9 +352,9 @@ func (bs *Server) ListBlockAttestations(ctx context.Context, req *ethpb.BlockReq }, nil } -func (bs *Server) blockFromBlockID(ctx context.Context, blockId []byte) (interfaces.SignedBeaconBlock, error) { +func (bs *Server) blockFromBlockID(ctx context.Context, blockId []byte) (block.SignedBeaconBlock, error) { var err error - var blk interfaces.SignedBeaconBlock + var blk block.SignedBeaconBlock switch string(blockId) { case "head": blk, err = bs.ChainInfoFetcher.HeadBlock(ctx) diff --git a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go index e8f2f34b9e..7b4a8efe09 100644 --- a/beacon-chain/rpc/eth/v1/beacon/blocks_test.go +++ b/beacon-chain/rpc/eth/v1/beacon/blocks_test.go @@ -11,10 +11,10 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" "github.com/prysmaticlabs/prysm/proto/migration" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -33,7 +33,7 @@ func fillDBTestBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) ( require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, root)) count := types.Slot(100) - blks := make([]interfaces.SignedBeaconBlock, count) + blks := make([]block.SignedBeaconBlock, count) blkContainers := make([]*ethpb_alpha.BeaconBlockContainer, count) for i := types.Slot(0); i < count; i++ { b := testutil.NewBeaconBlock() diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel index bb14338b0e..e2589dbfd0 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel @@ -37,8 +37,8 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", @@ -95,9 +95,9 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/aggregation/attestations:go_default_library", "//shared/attestationutil:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go index b8f25dc320..d13e38888a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/operation" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -63,7 +63,7 @@ func (bs *Server) ListAttestations( return nil, status.Errorf(codes.InvalidArgument, "Requested page size %d can not be greater than max size %d", req.PageSize, cmd.Get().MaxRPCPageSize) } - var blocks []interfaces.SignedBeaconBlock + var blocks []block.SignedBeaconBlock var err error switch q := req.QueryFilter.(type) { case *ethpb.ListAttestationsRequest_GenesisEpoch: @@ -117,7 +117,7 @@ func (bs *Server) ListAttestations( func (bs *Server) ListIndexedAttestations( ctx context.Context, req *ethpb.ListIndexedAttestationsRequest, ) (*ethpb.ListIndexedAttestationsResponse, error) { - var blocks []interfaces.SignedBeaconBlock + var blocks []block.SignedBeaconBlock var err error switch q := req.QueryFilter.(type) { case *ethpb.ListIndexedAttestationsRequest_GenesisEpoch: diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go index 193ab1e5c2..49847ca44f 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go @@ -19,9 +19,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/attestationutil" @@ -157,7 +157,7 @@ func TestServer_ListAttestations_FiltersCorrectly(t *testing.T) { targetRoot := [32]byte{7, 8, 9} targetEpoch := types.Epoch(7) - blocks := []interfaces.SignedBeaconBlock{ + blocks := []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock( testutil.HydrateSignedBeaconBlock( ðpb.SignedBeaconBlock{ diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go index 31dbd6100a..b27a1ac58f 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go @@ -16,9 +16,9 @@ import ( dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/cmd" @@ -135,7 +135,7 @@ func TestServer_ListBlocks_Genesis_MultiBlocks(t *testing.T) { require.NoError(t, db.SaveGenesisBlockRoot(ctx, root)) count := types.Slot(100) - blks := make([]interfaces.SignedBeaconBlock, count) + blks := make([]block.SignedBeaconBlock, count) for i := types.Slot(0); i < count; i++ { b := testutil.NewBeaconBlock() b.Block.Slot = i @@ -164,7 +164,7 @@ func TestServer_ListBlocks_Pagination(t *testing.T) { ctx := context.Background() count := types.Slot(100) - blks := make([]interfaces.SignedBeaconBlock, count) + blks := make([]block.SignedBeaconBlock, count) blkContainers := make([]*ethpb.BeaconBlockContainer, count) for i := types.Slot(0); i < count; i++ { b := testutil.NewBeaconBlock() diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index d4e9524901..eb94446c04 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -36,10 +36,10 @@ go_library( "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", "//proto/eth/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/aggregation:go_default_library", "//shared/aggregation/attestations:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index 725f01e986..25d9e19adb 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -19,10 +19,10 @@ import ( core "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" @@ -367,7 +367,7 @@ func (vs *Server) randomETH1DataVote(ctx context.Context) (*ethpb.Eth1Data, erro // computeStateRoot computes the state root after a block has been processed through a state transition and // returns it to the validator client. -func (vs *Server) computeStateRoot(ctx context.Context, block interfaces.SignedBeaconBlock) ([]byte, error) { +func (vs *Server) computeStateRoot(ctx context.Context, block block.SignedBeaconBlock) ([]byte, error) { beaconState, err := vs.StateGen.StateByRoot(ctx, bytesutil.ToBytes32(block.Block().ParentRoot())) if err != nil { return nil, errors.Wrap(err, "could not retrieve beacon state") diff --git a/beacon-chain/state/stategen/BUILD.bazel b/beacon-chain/state/stategen/BUILD.bazel index d9baaf04bb..3a298b6334 100644 --- a/beacon-chain/state/stategen/BUILD.bazel +++ b/beacon-chain/state/stategen/BUILD.bazel @@ -26,7 +26,7 @@ go_library( "//beacon-chain/db:go_default_library", "//beacon-chain/db/filters:go_default_library", "//beacon-chain/state:go_default_library", - "//proto/interfaces:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", @@ -60,9 +60,9 @@ go_test( "//beacon-chain/db/testing:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", diff --git a/beacon-chain/state/stategen/mock.go b/beacon-chain/state/stategen/mock.go index 11d38fa8fa..4c47d2e369 100644 --- a/beacon-chain/state/stategen/mock.go +++ b/beacon-chain/state/stategen/mock.go @@ -5,7 +5,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" ) @@ -42,7 +42,7 @@ func (m *MockStateManager) MigrateToCold(ctx context.Context, fRoot [32]byte) er func (m *MockStateManager) ReplayBlocks( ctx context.Context, state state.BeaconState, - signed []interfaces.SignedBeaconBlock, + signed []block.SignedBeaconBlock, targetSlot types.Slot, ) (state.BeaconState, error) { panic("implement me") @@ -53,7 +53,7 @@ func (m *MockStateManager) LoadBlocks( ctx context.Context, startSlot, endSlot types.Slot, endBlockRoot [32]byte, -) ([]interfaces.SignedBeaconBlock, error) { +) ([]block.SignedBeaconBlock, error) { panic("implement me") } diff --git a/beacon-chain/state/stategen/replay.go b/beacon-chain/state/stategen/replay.go index 03bdd45a1b..e8179df91d 100644 --- a/beacon-chain/state/stategen/replay.go +++ b/beacon-chain/state/stategen/replay.go @@ -9,7 +9,7 @@ import ( transition "github.com/prysmaticlabs/prysm/beacon-chain/core/state" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "go.opencensus.io/trace" ) @@ -18,7 +18,7 @@ import ( func (s *State) ReplayBlocks( ctx context.Context, state state.BeaconState, - signed []interfaces.SignedBeaconBlock, + signed []block.SignedBeaconBlock, targetSlot types.Slot, ) (state.BeaconState, error) { ctx, span := trace.StartSpan(ctx, "stateGen.ReplayBlocks") @@ -58,7 +58,7 @@ func (s *State) ReplayBlocks( // LoadBlocks loads the blocks between start slot and end slot by recursively fetching from end block root. // The Blocks are returned in slot-descending order. -func (s *State) LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, endBlockRoot [32]byte) ([]interfaces.SignedBeaconBlock, error) { +func (s *State) LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, endBlockRoot [32]byte) ([]block.SignedBeaconBlock, error) { // Nothing to load for invalid range. if endSlot < startSlot { return nil, fmt.Errorf("start slot %d >= end slot %d", startSlot, endSlot) @@ -96,7 +96,7 @@ func (s *State) LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, e return nil, errors.New("end block roots don't match") } - filteredBlocks := []interfaces.SignedBeaconBlock{blocks[length-1]} + filteredBlocks := []block.SignedBeaconBlock{blocks[length-1]} // Starting from second to last index because the last block is already in the filtered block list. for i := length - 2; i >= 0; i-- { if ctx.Err() != nil { @@ -119,7 +119,7 @@ func (s *State) LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, e func executeStateTransitionStateGen( ctx context.Context, state state.BeaconState, - signed interfaces.SignedBeaconBlock, + signed block.SignedBeaconBlock, ) (state.BeaconState, error) { if ctx.Err() != nil { return nil, ctx.Err() @@ -264,7 +264,7 @@ func (s *State) genesisRoot(ctx context.Context) ([32]byte, error) { // Given the start slot and the end slot, this returns the finalized beacon blocks in between. // Since hot states don't have finalized blocks, this should ONLY be used for replaying cold state. -func (s *State) loadFinalizedBlocks(ctx context.Context, startSlot, endSlot types.Slot) ([]interfaces.SignedBeaconBlock, error) { +func (s *State) loadFinalizedBlocks(ctx context.Context, startSlot, endSlot types.Slot) ([]block.SignedBeaconBlock, error) { f := filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot) bs, bRoots, err := s.beaconDB.Blocks(ctx, f) if err != nil { @@ -273,7 +273,7 @@ func (s *State) loadFinalizedBlocks(ctx context.Context, startSlot, endSlot type if len(bs) != len(bRoots) { return nil, errors.New("length of blocks and roots don't match") } - fbs := make([]interfaces.SignedBeaconBlock, 0, len(bs)) + fbs := make([]block.SignedBeaconBlock, 0, len(bs)) for i := len(bs) - 1; i >= 0; i-- { if s.beaconDB.IsFinalizedBlock(ctx, bRoots[i]) { fbs = append(fbs, bs[i]) diff --git a/beacon-chain/state/stategen/replay_test.go b/beacon-chain/state/stategen/replay_test.go index 80ba0d4c24..81c8e2dd73 100644 --- a/beacon-chain/state/stategen/replay_test.go +++ b/beacon-chain/state/stategen/replay_test.go @@ -8,9 +8,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/db" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -44,7 +44,7 @@ func TestReplayBlocks_AllSkipSlots(t *testing.T) { service := New(beaconDB) targetSlot := params.BeaconConfig().SlotsPerEpoch - 1 - newState, err := service.ReplayBlocks(context.Background(), beaconState, []interfaces.SignedBeaconBlock{}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []block.SignedBeaconBlock{}, targetSlot) require.NoError(t, err) assert.Equal(t, targetSlot, newState.Slot(), "Did not advance slots") } @@ -73,7 +73,7 @@ func TestReplayBlocks_SameSlot(t *testing.T) { service := New(beaconDB) targetSlot := beaconState.Slot() - newState, err := service.ReplayBlocks(context.Background(), beaconState, []interfaces.SignedBeaconBlock{}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []block.SignedBeaconBlock{}, targetSlot) require.NoError(t, err) assert.Equal(t, targetSlot, newState.Slot(), "Did not advance slots") } @@ -105,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{wrapper.WrappedPhase0SignedBeaconBlock(b)}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []block.SignedBeaconBlock{wrapper.WrappedPhase0SignedBeaconBlock(b)}, targetSlot) require.NoError(t, err) assert.Equal(t, targetSlot, newState.Slot(), "Did not advance slots") } diff --git a/beacon-chain/state/stategen/service.go b/beacon-chain/state/stategen/service.go index 857782e2b8..4ec6d96bb6 100644 --- a/beacon-chain/state/stategen/service.go +++ b/beacon-chain/state/stategen/service.go @@ -11,7 +11,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/db" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -26,8 +26,8 @@ type StateManager interface { Resume(ctx context.Context) (state.BeaconState, error) SaveFinalizedState(fSlot types.Slot, fRoot [32]byte, fState state.BeaconState) MigrateToCold(ctx context.Context, fRoot [32]byte) error - ReplayBlocks(ctx context.Context, state state.BeaconState, signed []interfaces.SignedBeaconBlock, targetSlot types.Slot) (state.BeaconState, error) - LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, endBlockRoot [32]byte) ([]interfaces.SignedBeaconBlock, error) + ReplayBlocks(ctx context.Context, state state.BeaconState, signed []block.SignedBeaconBlock, targetSlot types.Slot) (state.BeaconState, error) + LoadBlocks(ctx context.Context, startSlot, endSlot types.Slot, endBlockRoot [32]byte) ([]block.SignedBeaconBlock, error) HasState(ctx context.Context, blockRoot [32]byte) (bool, error) HasStateInCache(ctx context.Context, blockRoot [32]byte) (bool, error) StateByRoot(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error) diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 1a8ce8ea57..fdcafc4491 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -65,10 +65,11 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "//proto/prysm/v2/wrapper:go_default_library", "//shared:go_default_library", "//shared/abool:go_default_library", @@ -160,10 +161,10 @@ go_test( "//beacon-chain/state/v1:go_default_library", "//beacon-chain/sync/initial-sync/testing:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//proto/prysm/v2/wrapper:go_default_library", "//shared/abool:go_default_library", diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index c8022566bd..f5aa8bc99d 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -28,8 +28,8 @@ go_library( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", @@ -121,10 +121,10 @@ go_test( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", "//shared/event:go_default_library", diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index b20d457ad8..b73d92231a 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -15,8 +15,8 @@ import ( p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" prysmsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" "github.com/sirupsen/logrus" @@ -103,7 +103,7 @@ type fetchRequestResponse struct { pid peer.ID start types.Slot count uint64 - blocks []interfaces.SignedBeaconBlock + blocks []block.SignedBeaconBlock err error } @@ -244,7 +244,7 @@ func (f *blocksFetcher) handleRequest(ctx context.Context, start types.Slot, cou response := &fetchRequestResponse{ start: start, count: count, - blocks: []interfaces.SignedBeaconBlock{}, + blocks: []block.SignedBeaconBlock{}, err: nil, } @@ -278,7 +278,7 @@ func (f *blocksFetcher) fetchBlocksFromPeer( ctx context.Context, start types.Slot, count uint64, peers []peer.ID, -) ([]interfaces.SignedBeaconBlock, peer.ID, error) { +) ([]block.SignedBeaconBlock, peer.ID, error) { ctx, span := trace.StartSpan(ctx, "initialsync.fetchBlocksFromPeer") defer span.End() @@ -302,7 +302,7 @@ func (f *blocksFetcher) requestBlocks( ctx context.Context, req *p2ppb.BeaconBlocksByRangeRequest, pid peer.ID, -) ([]interfaces.SignedBeaconBlock, error) { +) ([]block.SignedBeaconBlock, error) { if ctx.Err() != nil { return nil, ctx.Err() } @@ -331,7 +331,7 @@ func (f *blocksFetcher) requestBlocksByRoot( ctx context.Context, req *p2pTypes.BeaconBlockByRootsReq, pid peer.ID, -) ([]interfaces.SignedBeaconBlock, error) { +) ([]block.SignedBeaconBlock, error) { if ctx.Err() != nil { return nil, ctx.Err() } diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go index 34acc87b6a..2fa54c4d7d 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -19,10 +19,10 @@ import ( p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -298,9 +298,9 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) { fetcher.stop() }() - processFetchedBlocks := func() ([]interfaces.SignedBeaconBlock, error) { + processFetchedBlocks := func() ([]block.SignedBeaconBlock, error) { defer cancel() - var unionRespBlocks []interfaces.SignedBeaconBlock + var unionRespBlocks []block.SignedBeaconBlock for { select { @@ -445,7 +445,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) { } }() - var blocks []interfaces.SignedBeaconBlock + var blocks []block.SignedBeaconBlock select { case <-ctx.Done(): t.Error(ctx.Err()) @@ -596,7 +596,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) req *p2ppb.BeaconBlocksByRangeRequest handlerGenFn func(req *p2ppb.BeaconBlocksByRangeRequest) func(stream network.Stream) wantedErr string - validate func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) + validate func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) }{ { name: "no error", @@ -615,7 +615,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, req.Count, uint64(len(blocks))) }, }, @@ -636,7 +636,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), @@ -660,7 +660,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), @@ -684,7 +684,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), @@ -716,7 +716,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) } }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, }, @@ -747,7 +747,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) } }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, }, @@ -770,7 +770,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 2, len(blocks)) }, }, @@ -793,7 +793,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) assert.NoError(t, stream.Close()) } }, - validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []interfaces.SignedBeaconBlock) { + validate: func(req *p2ppb.BeaconBlocksByRangeRequest, blocks []block.SignedBeaconBlock) { assert.Equal(t, 0, len(blocks)) }, wantedErr: beaconsync.ErrInvalidFetchedData.Error(), diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go index d4628bc5d9..b20c27f71c 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" p2ppb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/sirupsen/logrus" @@ -24,7 +24,7 @@ import ( // either in DB or initial sync cache. type forkData struct { peer peer.ID - blocks []interfaces.SignedBeaconBlock + blocks []block.SignedBeaconBlock } // nonSkippedSlotAfter checks slots after the given one in an attempt to find a non-empty future slot. @@ -257,8 +257,8 @@ func (f *blocksFetcher) findForkWithPeer(ctx context.Context, pid peer.ID, slot } // findAncestor tries to figure out common ancestor slot that connects a given root to known block. -func (f *blocksFetcher) findAncestor(ctx context.Context, pid peer.ID, block interfaces.SignedBeaconBlock) (*forkData, error) { - outBlocks := []interfaces.SignedBeaconBlock{block} +func (f *blocksFetcher) findAncestor(ctx context.Context, pid peer.ID, b block.SignedBeaconBlock) (*forkData, error) { + outBlocks := []block.SignedBeaconBlock{b} for i := uint64(0); i < backtrackingMaxHops; i++ { parentRoot := bytesutil.ToBytes32(outBlocks[len(outBlocks)-1].Block().ParentRoot()) if f.db.HasBlock(ctx, parentRoot) || f.chain.HasInitSyncBlock(parentRoot) { diff --git a/beacon-chain/sync/initial-sync/blocks_queue.go b/beacon-chain/sync/initial-sync/blocks_queue.go index 9506a7fa03..7ea8f94133 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/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/sirupsen/logrus" ) @@ -89,7 +89,7 @@ type blocksQueue struct { // blocksQueueFetchedData is a data container that is returned from a queue on each step. type blocksQueueFetchedData struct { pid peer.ID - blocks []interfaces.SignedBeaconBlock + blocks []block.SignedBeaconBlock } // newBlocksQueue creates initialized priority queue. diff --git a/beacon-chain/sync/initial-sync/blocks_queue_test.go b/beacon-chain/sync/initial-sync/blocks_queue_test.go index d24195ede0..fe84a9a210 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue_test.go +++ b/beacon-chain/sync/initial-sync/blocks_queue_test.go @@ -16,9 +16,9 @@ import ( p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -254,7 +254,7 @@ func TestBlocksQueue_Loop(t *testing.T) { highestExpectedSlot: tt.highestExpectedSlot, }) assert.NoError(t, queue.start()) - processBlock := func(block interfaces.SignedBeaconBlock) error { + processBlock := func(block block.SignedBeaconBlock) error { if !beaconDB.HasBlock(ctx, bytesutil.ToBytes32(block.Block().ParentRoot())) { return fmt.Errorf("%w: %#x", errParentDoesNotExist, block.Block().ParentRoot()) } @@ -265,7 +265,7 @@ func TestBlocksQueue_Loop(t *testing.T) { return mc.ReceiveBlock(ctx, block, root) } - var blocks []interfaces.SignedBeaconBlock + var blocks []block.SignedBeaconBlock for data := range queue.fetchedData { for _, block := range data.blocks { if err := processBlock(block); err != nil { @@ -525,7 +525,7 @@ func TestBlocksQueue_onDataReceivedEvent(t *testing.T) { handlerFn := queue.onDataReceivedEvent(ctx) response := &fetchRequestResponse{ pid: "abc", - blocks: []interfaces.SignedBeaconBlock{ + blocks: []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), }, @@ -534,7 +534,7 @@ func TestBlocksQueue_onDataReceivedEvent(t *testing.T) { state: stateScheduled, } assert.Equal(t, peer.ID(""), fsm.pid) - assert.DeepSSZEqual(t, []interfaces.SignedBeaconBlock(nil), fsm.blocks) + assert.DeepSSZEqual(t, []block.SignedBeaconBlock(nil), fsm.blocks) updatedState, err := handlerFn(fsm, response) assert.NoError(t, err) assert.Equal(t, stateDataParsed, updatedState) @@ -621,7 +621,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.addStateMachine(320) queue.smm.machines[256].state = stateDataParsed queue.smm.machines[256].pid = pidDataParsed - queue.smm.machines[256].blocks = []interfaces.SignedBeaconBlock{ + queue.smm.machines[256].blocks = []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } @@ -651,7 +651,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.addStateMachine(320) queue.smm.machines[320].state = stateDataParsed queue.smm.machines[320].pid = pidDataParsed - queue.smm.machines[320].blocks = []interfaces.SignedBeaconBlock{ + queue.smm.machines[320].blocks = []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } @@ -678,7 +678,7 @@ func TestBlocksQueue_onReadyToSendEvent(t *testing.T) { queue.smm.addStateMachine(320) queue.smm.machines[320].state = stateDataParsed queue.smm.machines[320].pid = pidDataParsed - queue.smm.machines[320].blocks = []interfaces.SignedBeaconBlock{ + queue.smm.machines[320].blocks = []block.SignedBeaconBlock{ wrapper.WrappedPhase0SignedBeaconBlock(testutil.NewBeaconBlock()), } @@ -1299,7 +1299,7 @@ func TestBlocksQueue_stuckWhenHeadIsSetToOrphanedBlock(t *testing.T) { }) require.NoError(t, queue.start()) - isProcessedBlock := func(ctx context.Context, blk interfaces.SignedBeaconBlock, blkRoot [32]byte) bool { + isProcessedBlock := func(ctx context.Context, blk block.SignedBeaconBlock, blkRoot [32]byte) bool { finalizedSlot, err := helpers.StartSlot(mc.FinalizedCheckpt().Epoch) if err != nil { return false diff --git a/beacon-chain/sync/initial-sync/fsm.go b/beacon-chain/sync/initial-sync/fsm.go index 9279e2a9fa..4ada9f6749 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/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/timeutils" ) @@ -46,7 +46,7 @@ type stateMachine struct { start types.Slot state stateID pid peer.ID - blocks []interfaces.SignedBeaconBlock + blocks []block.SignedBeaconBlock updated time.Time } @@ -78,7 +78,7 @@ func (smm *stateMachineManager) addStateMachine(startSlot types.Slot) *stateMach smm: smm, start: startSlot, state: stateNew, - blocks: []interfaces.SignedBeaconBlock{}, + blocks: []block.SignedBeaconBlock{}, updated: timeutils.Now(), } smm.recalculateMachineAttribs() diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index 1f761e7572..c1d870b129 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -13,7 +13,7 @@ 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/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/sirupsen/logrus" ) @@ -24,10 +24,10 @@ const ( ) // blockReceiverFn defines block receiving function. -type blockReceiverFn func(ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error +type blockReceiverFn func(ctx context.Context, block block.SignedBeaconBlock, blockRoot [32]byte) error // batchBlockReceiverFn defines batch receiving function. -type batchBlockReceiverFn func(ctx context.Context, blks []interfaces.SignedBeaconBlock, roots [][32]byte) error +type batchBlockReceiverFn func(ctx context.Context, blks []block.SignedBeaconBlock, roots [][32]byte) error // Round Robin sync looks at the latest peer statuses and syncs up to the highest known epoch. // @@ -178,7 +178,7 @@ func (s *Service) highestFinalizedEpoch() types.Epoch { } // logSyncStatus and increment block processing counter. -func (s *Service) logSyncStatus(genesis time.Time, blk interfaces.BeaconBlock, blkRoot [32]byte) { +func (s *Service) logSyncStatus(genesis time.Time, blk block.BeaconBlock, blkRoot [32]byte) { s.counter.Incr(1) rate := float64(s.counter.Rate()) / counterSeconds if rate == 0 { @@ -198,7 +198,7 @@ func (s *Service) logSyncStatus(genesis time.Time, blk interfaces.BeaconBlock, b } // logBatchSyncStatus and increments the block processing counter. -func (s *Service) logBatchSyncStatus(genesis time.Time, blks []interfaces.SignedBeaconBlock, blkRoot [32]byte) { +func (s *Service) logBatchSyncStatus(genesis time.Time, blks []block.SignedBeaconBlock, blkRoot [32]byte) { s.counter.Incr(int64(len(blks))) rate := float64(s.counter.Rate()) / counterSeconds if rate == 0 { @@ -220,7 +220,7 @@ func (s *Service) logBatchSyncStatus(genesis time.Time, blks []interfaces.Signed func (s *Service) processBlock( ctx context.Context, genesis time.Time, - blk interfaces.SignedBeaconBlock, + blk block.SignedBeaconBlock, blockReceiver blockReceiverFn, ) error { blkRoot, err := blk.Block().HashTreeRoot() @@ -240,7 +240,7 @@ func (s *Service) processBlock( } func (s *Service) processBatchedBlocks(ctx context.Context, genesis time.Time, - blks []interfaces.SignedBeaconBlock, bFunc batchBlockReceiverFn) error { + blks []block.SignedBeaconBlock, bFunc batchBlockReceiverFn) error { if len(blks) == 0 { return errors.New("0 blocks provided into method") } @@ -299,7 +299,7 @@ func (s *Service) updatePeerScorerStats(pid peer.ID, startSlot types.Slot) { } // isProcessedBlock checks DB and local cache for presence of a given block, to avoid duplicates. -func (s *Service) isProcessedBlock(ctx context.Context, blk interfaces.SignedBeaconBlock, blkRoot [32]byte) bool { +func (s *Service) isProcessedBlock(ctx context.Context, blk block.SignedBeaconBlock, blkRoot [32]byte) bool { finalizedSlot, err := helpers.StartSlot(s.cfg.Chain.FinalizedCheckpt().Epoch) if err != nil { return false diff --git a/beacon-chain/sync/initial-sync/round_robin_test.go b/beacon-chain/sync/initial-sync/round_robin_test.go index 64fc72752f..958c70048e 100644 --- a/beacon-chain/sync/initial-sync/round_robin_test.go +++ b/beacon-chain/sync/initial-sync/round_robin_test.go @@ -10,9 +10,9 @@ import ( mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/abool" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -356,7 +356,7 @@ func TestService_processBlock(t *testing.T) { // Process block normally. err = s.processBlock(ctx, genesis, wrapper.WrappedPhase0SignedBeaconBlock(blk1), func( - ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { + ctx context.Context, block block.SignedBeaconBlock, blockRoot [32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlock(ctx, block, blockRoot)) return nil }) @@ -364,14 +364,14 @@ func TestService_processBlock(t *testing.T) { // Duplicate processing should trigger error. err = s.processBlock(ctx, genesis, wrapper.WrappedPhase0SignedBeaconBlock(blk1), func( - ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { + ctx context.Context, block block.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, wrapper.WrappedPhase0SignedBeaconBlock(blk2), func( - ctx context.Context, block interfaces.SignedBeaconBlock, blockRoot [32]byte) error { + ctx context.Context, block block.SignedBeaconBlock, blockRoot [32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlock(ctx, block, blockRoot)) return nil }) @@ -406,7 +406,7 @@ func TestService_processBlockBatch(t *testing.T) { genesis := makeGenesisTime(32) t.Run("process non-linear batch", func(t *testing.T) { - var batch []interfaces.SignedBeaconBlock + var batch []block.SignedBeaconBlock currBlockRoot := genesisBlkRoot for i := types.Slot(1); i < 10; i++ { parentRoot := currBlockRoot @@ -421,7 +421,7 @@ func TestService_processBlockBatch(t *testing.T) { currBlockRoot = blk1Root } - var batch2 []interfaces.SignedBeaconBlock + var batch2 []block.SignedBeaconBlock for i := types.Slot(10); i < 20; i++ { parentRoot := currBlockRoot blk1 := testutil.NewBeaconBlock() @@ -437,7 +437,7 @@ func TestService_processBlockBatch(t *testing.T) { // Process block normally. err = s.processBatchedBlocks(ctx, genesis, batch, func( - ctx context.Context, blks []interfaces.SignedBeaconBlock, blockRoots [][32]byte) error { + ctx context.Context, blks []block.SignedBeaconBlock, blockRoots [][32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlockBatch(ctx, blks, blockRoots)) return nil }) @@ -445,12 +445,12 @@ func TestService_processBlockBatch(t *testing.T) { // Duplicate processing should trigger error. err = s.processBatchedBlocks(ctx, genesis, batch, func( - ctx context.Context, blocks []interfaces.SignedBeaconBlock, blockRoots [][32]byte) error { + ctx context.Context, blocks []block.SignedBeaconBlock, blockRoots [][32]byte) error { return nil }) assert.ErrorContains(t, "no good blocks in batch", err) - var badBatch2 []interfaces.SignedBeaconBlock + var badBatch2 []block.SignedBeaconBlock for i, b := range batch2 { // create a non-linear batch if i%3 == 0 && i != 0 { @@ -461,7 +461,7 @@ func TestService_processBlockBatch(t *testing.T) { // Bad batch should fail because it is non linear err = s.processBatchedBlocks(ctx, genesis, badBatch2, func( - ctx context.Context, blks []interfaces.SignedBeaconBlock, blockRoots [][32]byte) error { + ctx context.Context, blks []block.SignedBeaconBlock, blockRoots [][32]byte) error { return nil }) expectedSubErr := "expected linear block list" @@ -469,7 +469,7 @@ func TestService_processBlockBatch(t *testing.T) { // Continue normal processing, should proceed w/o errors. err = s.processBatchedBlocks(ctx, genesis, batch2, func( - ctx context.Context, blks []interfaces.SignedBeaconBlock, blockRoots [][32]byte) error { + ctx context.Context, blks []block.SignedBeaconBlock, blockRoots [][32]byte) error { assert.NoError(t, s.cfg.Chain.ReceiveBlockBatch(ctx, blks, blockRoots)) return nil }) diff --git a/beacon-chain/sync/pending_blocks_queue.go b/beacon-chain/sync/pending_blocks_queue.go index 0e0503dacc..daf66d37b1 100644 --- a/beacon-chain/sync/pending_blocks_queue.go +++ b/beacon-chain/sync/pending_blocks_queue.go @@ -11,7 +11,7 @@ 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/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/rand" @@ -299,7 +299,7 @@ func (s *Service) clearPendingSlots() { // Delete block from the list from the pending queue using the slot as key. // Note: this helper is not thread safe. -func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error { +func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b block.SignedBeaconBlock, r [32]byte) error { mutexasserts.AssertRWMutexLocked(&s.pendingQueueLock) blks := s.pendingBlocksInCache(slot) @@ -307,7 +307,7 @@ func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b interfaces.Sign return nil } - newBlks := make([]interfaces.SignedBeaconBlock, 0, len(blks)) + newBlks := make([]block.SignedBeaconBlock, 0, len(blks)) for _, blk := range blks { if sszutil.DeepEqual(blk, b) { continue @@ -330,7 +330,7 @@ func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b interfaces.Sign // Insert block to the list in the pending queue using the slot as key. // Note: this helper is not thread safe. -func (s *Service) insertBlockToPendingQueue(slot types.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error { +func (s *Service) insertBlockToPendingQueue(slot types.Slot, b block.SignedBeaconBlock, r [32]byte) error { mutexasserts.AssertRWMutexLocked(&s.pendingQueueLock) if s.seenPendingBlocks[r] { @@ -346,21 +346,21 @@ func (s *Service) insertBlockToPendingQueue(slot types.Slot, b interfaces.Signed } // This returns signed beacon blocks given input key from slotToPendingBlocks. -func (s *Service) pendingBlocksInCache(slot types.Slot) []interfaces.SignedBeaconBlock { +func (s *Service) pendingBlocksInCache(slot types.Slot) []block.SignedBeaconBlock { k := slotToCacheKey(slot) value, ok := s.slotToPendingBlocks.Get(k) if !ok { - return []interfaces.SignedBeaconBlock{} + return []block.SignedBeaconBlock{} } - blks, ok := value.([]interfaces.SignedBeaconBlock) + blks, ok := value.([]block.SignedBeaconBlock) if !ok { - return []interfaces.SignedBeaconBlock{} + return []block.SignedBeaconBlock{} } return blks } // This adds input signed beacon block to slotToPendingBlocks cache. -func (s *Service) addPendingBlockToCache(b interfaces.SignedBeaconBlock) error { +func (s *Service) addPendingBlockToCache(b block.SignedBeaconBlock) error { if err := helpers.VerifyNilBeaconBlock(b); err != nil { return err } diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range.go b/beacon-chain/sync/rpc_beacon_blocks_by_range.go index 1f3a13a8a6..7b87e60d3f 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/traceutil" @@ -139,7 +139,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo traceutil.AnnotateError(span, err) return err } - blks = append([]interfaces.SignedBeaconBlock{genBlock}, blks...) + blks = append([]block.SignedBeaconBlock{genBlock}, blks...) roots = append([][32]byte{genRoot}, roots...) } // Filter and sort our retrieved blocks, so that @@ -207,13 +207,13 @@ func (s *Service) validateRangeRequest(r *pb.BeaconBlocksByRangeRequest) error { // filters all the provided blocks to ensure they are canonical // and are strictly linear. -func (s *Service) filterBlocks(ctx context.Context, blks []interfaces.SignedBeaconBlock, roots [][32]byte, prevRoot *[32]byte, - step uint64, startSlot types.Slot) ([]interfaces.SignedBeaconBlock, error) { +func (s *Service) filterBlocks(ctx context.Context, blks []block.SignedBeaconBlock, roots [][32]byte, prevRoot *[32]byte, + step uint64, startSlot types.Slot) ([]block.SignedBeaconBlock, error) { if len(blks) != len(roots) { return nil, errors.New("input blks and roots are diff lengths") } - newBlks := make([]interfaces.SignedBeaconBlock, 0, len(blks)) + newBlks := make([]block.SignedBeaconBlock, 0, len(blks)) for i, b := range blks { isCanonical, err := s.cfg.Chain.IsCanonical(ctx, roots[i]) if err != nil { @@ -250,7 +250,7 @@ func (s *Service) writeErrorResponseToStream(responseCode byte, reason string, s writeErrorResponseToStream(responseCode, reason, stream, s.cfg.P2P) } -func (s *Service) retrieveGenesisBlock(ctx context.Context) (interfaces.SignedBeaconBlock, [32]byte, error) { +func (s *Service) retrieveGenesisBlock(ctx context.Context) (block.SignedBeaconBlock, [32]byte, error) { genBlock, err := s.cfg.DB.GenesisBlock(ctx) if err != nil { return nil, [32]byte{}, err diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_root.go b/beacon-chain/sync/rpc_beacon_blocks_by_root.go index c4c091ee08..4bb9c4bbcc 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_root.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_root.go @@ -7,7 +7,7 @@ import ( "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/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -17,7 +17,7 @@ func (s *Service) sendRecentBeaconBlocksRequest(ctx context.Context, blockRoots ctx, cancel := context.WithTimeout(ctx, respTimeout) defer cancel() - _, err := SendBeaconBlocksByRootRequest(ctx, s.cfg.Chain, s.cfg.P2P, id, blockRoots, func(blk interfaces.SignedBeaconBlock) error { + _, err := SendBeaconBlocksByRootRequest(ctx, s.cfg.Chain, s.cfg.P2P, id, blockRoots, func(blk block.SignedBeaconBlock) error { blkRoot, err := blk.Block().HashTreeRoot() if err != nil { return err diff --git a/beacon-chain/sync/rpc_chunked_response.go b/beacon-chain/sync/rpc_chunked_response.go index e0b9255f1f..70337fcd34 100644 --- a/beacon-chain/sync/rpc_chunked_response.go +++ b/beacon-chain/sync/rpc_chunked_response.go @@ -7,9 +7,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) // chunkWriter writes the given message as a chunked response to the given network @@ -35,7 +35,7 @@ func WriteChunk(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, enc // ReadChunkedBlock handles each response chunk that is sent by the // peer and converts it into a beacon block. -func ReadChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P, isFirstChunk bool) (interfaces.SignedBeaconBlock, error) { +func ReadChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P, isFirstChunk bool) (block.SignedBeaconBlock, error) { // Handle deadlines differently for first chunk if isFirstChunk { return readFirstChunkedBlock(stream, chain, p2p) @@ -49,7 +49,7 @@ func ReadChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetche // readFirstChunkedBlock reads the first chunked block and applies the appropriate deadlines to // it. -func readFirstChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P) (interfaces.SignedBeaconBlock, error) { +func readFirstChunkedBlock(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P) (block.SignedBeaconBlock, error) { blk := ð.SignedBeaconBlock{} code, errMsg, err := ReadStatusCode(stream, p2p.Encoding()) if err != nil { diff --git a/beacon-chain/sync/rpc_metadata.go b/beacon-chain/sync/rpc_metadata.go index 33186831ec..512a51a968 100644 --- a/beacon-chain/sync/rpc_metadata.go +++ b/beacon-chain/sync/rpc_metadata.go @@ -7,8 +7,8 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" - "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" ) @@ -35,7 +35,7 @@ func (s *Service) metaDataHandler(_ context.Context, _ interface{}, stream libp2 return nil } -func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (interfaces.Metadata, error) { +func (s *Service) sendMetaDataRequest(ctx context.Context, id peer.ID) (metadata.Metadata, error) { ctx, cancel := context.WithTimeout(ctx, respTimeout) defer cancel() diff --git a/beacon-chain/sync/rpc_send_request.go b/beacon-chain/sync/rpc_send_request.go index 5fc8a93054..056670d1bf 100644 --- a/beacon-chain/sync/rpc_send_request.go +++ b/beacon-chain/sync/rpc_send_request.go @@ -10,8 +10,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -20,13 +20,13 @@ var ErrInvalidFetchedData = errors.New("invalid data returned from peer") // BeaconBlockProcessor defines a block processing function, which allows to start utilizing // blocks even before all blocks are ready. -type BeaconBlockProcessor func(block interfaces.SignedBeaconBlock) error +type BeaconBlockProcessor func(block block.SignedBeaconBlock) error // SendBeaconBlocksByRangeRequest sends BeaconBlocksByRange and returns fetched blocks, if any. func SendBeaconBlocksByRangeRequest( ctx context.Context, chain blockchain.ChainInfoFetcher, p2pProvider p2p.P2P, pid peer.ID, req *pb.BeaconBlocksByRangeRequest, blockProcessor BeaconBlockProcessor, -) ([]interfaces.SignedBeaconBlock, error) { +) ([]block.SignedBeaconBlock, error) { stream, err := p2pProvider.Send(ctx, req, p2p.RPCBlocksByRangeTopicV1, pid) if err != nil { return nil, err @@ -34,8 +34,8 @@ func SendBeaconBlocksByRangeRequest( defer closeStream(stream, log) // Augment block processing function, if non-nil block processor is provided. - blocks := make([]interfaces.SignedBeaconBlock, 0, req.Count) - process := func(blk interfaces.SignedBeaconBlock) error { + blocks := make([]block.SignedBeaconBlock, 0, req.Count) + process := func(blk block.SignedBeaconBlock) error { blocks = append(blocks, blk) if blockProcessor != nil { return blockProcessor(blk) @@ -84,7 +84,7 @@ func SendBeaconBlocksByRangeRequest( func SendBeaconBlocksByRootRequest( ctx context.Context, chain blockchain.ChainInfoFetcher, p2pProvider p2p.P2P, pid peer.ID, req *p2ptypes.BeaconBlockByRootsReq, blockProcessor BeaconBlockProcessor, -) ([]interfaces.SignedBeaconBlock, error) { +) ([]block.SignedBeaconBlock, error) { stream, err := p2pProvider.Send(ctx, req, p2p.RPCBlocksByRootTopicV1, pid) if err != nil { return nil, err @@ -92,8 +92,8 @@ func SendBeaconBlocksByRootRequest( defer closeStream(stream, log) // Augment block processing function, if non-nil block processor is provided. - blocks := make([]interfaces.SignedBeaconBlock, 0, len(*req)) - process := func(block interfaces.SignedBeaconBlock) error { + blocks := make([]block.SignedBeaconBlock, 0, len(*req)) + process := func(block block.SignedBeaconBlock) error { blocks = append(blocks, block) if blockProcessor != nil { return blockProcessor(block) diff --git a/beacon-chain/sync/rpc_send_request_test.go b/beacon-chain/sync/rpc_send_request_test.go index d7aa4cee05..617ab23d8b 100644 --- a/beacon-chain/sync/rpc_send_request_test.go +++ b/beacon-chain/sync/rpc_send_request_test.go @@ -13,10 +13,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/assert" @@ -116,8 +116,8 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { Count: 128, Step: 1, } - blocksFromProcessor := make([]interfaces.SignedBeaconBlock, 0) - blocks, err := SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + blocksFromProcessor := make([]block.SignedBeaconBlock, 0) + blocks, err := SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { blocksFromProcessor = append(blocksFromProcessor, block) return nil }) @@ -139,7 +139,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { Step: 1, } errFromProcessor := errors.New("processor error") - _, err := SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + _, err := SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { return errFromProcessor }) assert.ErrorContains(t, errFromProcessor.Error(), err) @@ -168,7 +168,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { cfg.MaxRequestBlocks = maxRequestBlocks params.OverrideBeaconNetworkConfig(cfg) }() - blocks, err = SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + blocks, err = SendBeaconBlocksByRangeRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { // Since ssz checks the boundaries, and doesn't normally allow to send requests bigger than // the max request size, we are updating max request size dynamically. Even when updated dynamically, // no more than max request size of blocks is expected on return. @@ -186,7 +186,7 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { p1.Connect(p2) blocksProcessed := 0 expectedErr := errors.New("some error") - p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block interfaces.SignedBeaconBlock) error { + p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block block.SignedBeaconBlock) error { if blocksProcessed > 2 { return expectedErr } @@ -369,8 +369,8 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { // No error from block processor. req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]} - blocksFromProcessor := make([]interfaces.SignedBeaconBlock, 0) - blocks, err := SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + blocksFromProcessor := make([]block.SignedBeaconBlock, 0) + blocks, err := SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { blocksFromProcessor = append(blocksFromProcessor, block) return nil }) @@ -388,7 +388,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { // Send error from block processor. req := &p2pTypes.BeaconBlockByRootsReq{knownRoots[0], knownRoots[1]} errFromProcessor := errors.New("processor error") - _, err := SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + _, err := SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { return errFromProcessor }) assert.ErrorContains(t, errFromProcessor.Error(), err) @@ -413,7 +413,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { cfg.MaxRequestBlocks = maxRequestBlocks params.OverrideBeaconNetworkConfig(cfg) }() - blocks, err = SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block interfaces.SignedBeaconBlock) error { + blocks, err = SendBeaconBlocksByRootRequest(ctx, nil, p1, p2.PeerID(), req, func(block block.SignedBeaconBlock) error { // Since ssz checks the boundaries, and doesn't normally allow to send requests bigger than // the max request size, we are updating max request size dynamically. Even when updated dynamically, // no more than max request size of blocks is expected on return. @@ -431,7 +431,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { p1.Connect(p2) blocksProcessed := 0 expectedErr := errors.New("some error") - p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block interfaces.SignedBeaconBlock) error { + p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block block.SignedBeaconBlock) error { if blocksProcessed > 2 { return expectedErr } @@ -451,7 +451,7 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { p1.Connect(p2) blocksProcessed := 0 expectedErr := io.EOF - p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block interfaces.SignedBeaconBlock) error { + p2.SetStreamHandler(pcl, knownBlocksProvider(p2, func(block block.SignedBeaconBlock) error { if blocksProcessed > 2 { return expectedErr } diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index 20a6f45697..5a53c791f6 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -20,10 +20,10 @@ import ( p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" - p2pInterfaces "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" p2pWrapper "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" @@ -929,9 +929,9 @@ func TestShouldResync(t *testing.T) { } } -func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []p2pInterfaces.SignedBeaconBlock { +func makeBlocks(t *testing.T, i, n uint64, previousRoot [32]byte) []block.SignedBeaconBlock { blocks := make([]*ethpb.SignedBeaconBlock, n) - ifaceBlocks := make([]p2pInterfaces.SignedBeaconBlock, n) + ifaceBlocks := make([]block.SignedBeaconBlock, n) for j := i; j < n+i; j++ { parentRoot := make([]byte, 32) copy(parentRoot, previousRoot[:]) diff --git a/beacon-chain/sync/utils.go b/beacon-chain/sync/utils.go index e48ebc35d7..24a74a84d0 100644 --- a/beacon-chain/sync/utils.go +++ b/beacon-chain/sync/utils.go @@ -4,14 +4,14 @@ import ( "errors" "sort" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) // A type to represent beacon blocks and roots which have methods // which satisfy the Interface in `Sort` so that this type can // be sorted in ascending order. type sortedObj struct { - blks []interfaces.SignedBeaconBlock + blks []block.SignedBeaconBlock roots [][32]byte } @@ -32,14 +32,14 @@ func (s sortedObj) Len() int { } // removes duplicates from provided blocks and roots. -func (s *Service) dedupBlocksAndRoots(blks []interfaces.SignedBeaconBlock, roots [][32]byte) ([]interfaces.SignedBeaconBlock, [][32]byte, error) { +func (s *Service) dedupBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte, error) { if len(blks) != len(roots) { return nil, nil, errors.New("input blks and roots are diff lengths") } // Remove duplicate blocks received rootMap := make(map[[32]byte]bool, len(blks)) - newBlks := make([]interfaces.SignedBeaconBlock, 0, len(blks)) + newBlks := make([]block.SignedBeaconBlock, 0, len(blks)) newRoots := make([][32]byte, 0, len(roots)) for i, r := range roots { if rootMap[r] { @@ -67,7 +67,7 @@ func (s *Service) dedupRoots(roots [][32]byte) [][32]byte { // sort the provided blocks and roots in ascending order. This method assumes that the size of // block slice and root slice is equal. -func (s *Service) sortBlocksAndRoots(blks []interfaces.SignedBeaconBlock, roots [][32]byte) ([]interfaces.SignedBeaconBlock, [][32]byte) { +func (s *Service) sortBlocksAndRoots(blks []block.SignedBeaconBlock, roots [][32]byte) ([]block.SignedBeaconBlock, [][32]byte) { obj := sortedObj{ blks: blks, roots: roots, diff --git a/beacon-chain/sync/utils_test.go b/beacon-chain/sync/utils_test.go index 827872a767..78d6da68f5 100644 --- a/beacon-chain/sync/utils_test.go +++ b/beacon-chain/sync/utils_test.go @@ -5,9 +5,9 @@ import ( "testing" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) @@ -15,7 +15,7 @@ import ( func TestSortedObj_SortBlocksRoots(t *testing.T) { source := rand.NewSource(33) randGen := rand.New(source) - var blks []interfaces.SignedBeaconBlock + var blks []block.SignedBeaconBlock var roots [][32]byte randFunc := func() int64 { return randGen.Int63n(50) @@ -48,7 +48,7 @@ func TestSortedObj_SortBlocksRoots(t *testing.T) { func TestSortedObj_NoDuplicates(t *testing.T) { source := rand.NewSource(33) randGen := rand.New(source) - var blks []interfaces.SignedBeaconBlock + var blks []block.SignedBeaconBlock var roots [][32]byte randFunc := func() int64 { return randGen.Int63n(50) diff --git a/beacon-chain/sync/validate_beacon_blocks.go b/beacon-chain/sync/validate_beacon_blocks.go index 66e6067167..e3297e6cbe 100644 --- a/beacon-chain/sync/validate_beacon_blocks.go +++ b/beacon-chain/sync/validate_beacon_blocks.go @@ -14,9 +14,9 @@ import ( blockfeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/block" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" @@ -177,7 +177,7 @@ func (s *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms return pubsub.ValidationAccept } -func (s *Service) validateBeaconBlock(ctx context.Context, blk interfaces.SignedBeaconBlock, blockRoot [32]byte) error { +func (s *Service) validateBeaconBlock(ctx context.Context, blk block.SignedBeaconBlock, blockRoot [32]byte) error { ctx, span := trace.StartSpan(ctx, "sync.validateBeaconBlock") defer span.End() diff --git a/fuzz/BUILD.bazel b/fuzz/BUILD.bazel index 70fa15ad15..b0b8dff3e5 100644 --- a/fuzz/BUILD.bazel +++ b/fuzz/BUILD.bazel @@ -68,7 +68,7 @@ go_fuzz_test( "//shared/params:go_default_library", "//proto/prysm/v2:go_default_library", "//proto/prysm/v2/state:go_default_library", - "//proto/interfaces:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//beacon-chain/operations/attestations:go_default_library", "//beacon-chain/p2p/testing:go_default_library", diff --git a/proto/migration/BUILD.bazel b/proto/migration/BUILD.bazel index afad460ad4..210422f83e 100644 --- a/proto/migration/BUILD.bazel +++ b/proto/migration/BUILD.bazel @@ -10,8 +10,8 @@ go_library( visibility = ["//visibility:public"], deps = [ "//proto/eth/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "@com_github_pkg_errors//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], diff --git a/proto/migration/migration.go b/proto/migration/migration.go index d8d03b3483..ed280ef874 100644 --- a/proto/migration/migration.go +++ b/proto/migration/migration.go @@ -3,13 +3,13 @@ package migration import ( "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb_alpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "google.golang.org/protobuf/proto" ) // BlockIfaceToV1BlockHeader converts a signed beacon block interface into a signed beacon block header. -func BlockIfaceToV1BlockHeader(block interfaces.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { +func BlockIfaceToV1BlockHeader(block block.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { bodyRoot, err := block.Block().Body().HashTreeRoot() if err != nil { return nil, errors.Wrap(err, "failed to get body root of block") @@ -307,7 +307,7 @@ func V1Alpha1ValidatorToV1(v1Validator *ethpb_alpha.Validator) *ethpb.Validator } // SignedBeaconBlock converts a signed beacon block interface to a v1alpha1 block. -func SignedBeaconBlock(block interfaces.SignedBeaconBlock) (*ethpb.SignedBeaconBlock, error) { +func SignedBeaconBlock(block block.SignedBeaconBlock) (*ethpb.SignedBeaconBlock, error) { if block == nil || block.IsNil() { return nil, errors.New("could not find requested block") } diff --git a/proto/prysm/BUILD.bazel b/proto/prysm/BUILD.bazel new file mode 100644 index 0000000000..15fb9adff4 --- /dev/null +++ b/proto/prysm/BUILD.bazel @@ -0,0 +1 @@ +load("@prysm//tools/go:def.bzl", "go_library") diff --git a/proto/prysm/v1alpha1/wrapper/BUILD.bazel b/proto/prysm/v1alpha1/wrapper/BUILD.bazel index dfca854158..b1d4ffab9a 100644 --- a/proto/prysm/v1alpha1/wrapper/BUILD.bazel +++ b/proto/prysm/v1alpha1/wrapper/BUILD.bazel @@ -6,9 +6,9 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper", visibility = ["//visibility:public"], deps = [ - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/copyutil:go_default_library", "//shared/version:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/proto/prysm/v1alpha1/wrapper/beacon_block.go b/proto/prysm/v1alpha1/wrapper/beacon_block.go index 07598ba4be..2bd07a42b3 100644 --- a/proto/prysm/v1alpha1/wrapper/beacon_block.go +++ b/proto/prysm/v1alpha1/wrapper/beacon_block.go @@ -3,9 +3,9 @@ package wrapper import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/proto/interfaces" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/version" "google.golang.org/protobuf/proto" @@ -20,7 +20,7 @@ type Phase0SignedBeaconBlock struct { // WrappedPhase0SignedBeaconBlock is constructor which wraps a protobuf phase 0 block // with the block wrapper. -func WrappedPhase0SignedBeaconBlock(b *eth.SignedBeaconBlock) interfaces.SignedBeaconBlock { +func WrappedPhase0SignedBeaconBlock(b *eth.SignedBeaconBlock) block.SignedBeaconBlock { return Phase0SignedBeaconBlock{b: b} } @@ -30,7 +30,7 @@ func (w Phase0SignedBeaconBlock) Signature() []byte { } // Block returns the underlying beacon block object. -func (w Phase0SignedBeaconBlock) Block() interfaces.BeaconBlock { +func (w Phase0SignedBeaconBlock) Block() block.BeaconBlock { return WrappedPhase0BeaconBlock(w.b.Block) } @@ -42,7 +42,7 @@ func (w Phase0SignedBeaconBlock) IsNil() bool { // Copy performs a deep copy of the signed beacon block // object. -func (w Phase0SignedBeaconBlock) Copy() interfaces.SignedBeaconBlock { +func (w Phase0SignedBeaconBlock) Copy() block.SignedBeaconBlock { return WrappedPhase0SignedBeaconBlock(copyutil.CopySignedBeaconBlock(w.b)) } @@ -97,7 +97,7 @@ type Phase0BeaconBlock struct { // WrappedPhase0BeaconBlock is constructor which wraps a protobuf phase 0 object // with the block wrapper. -func WrappedPhase0BeaconBlock(b *eth.BeaconBlock) interfaces.BeaconBlock { +func WrappedPhase0BeaconBlock(b *eth.BeaconBlock) block.BeaconBlock { return Phase0BeaconBlock{b: b} } @@ -122,7 +122,7 @@ func (w Phase0BeaconBlock) StateRoot() []byte { } // Body returns the underlying block body. -func (w Phase0BeaconBlock) Body() interfaces.BeaconBlockBody { +func (w Phase0BeaconBlock) Body() block.BeaconBlockBody { return WrappedPhase0BeaconBlockBody(w.b.Body) } @@ -177,7 +177,7 @@ type Phase0BeaconBlockBody struct { // WrappedPhase0BeaconBlockBody is constructor which wraps a protobuf phase 0 object // with the block wrapper. -func WrappedPhase0BeaconBlockBody(b *eth.BeaconBlockBody) interfaces.BeaconBlockBody { +func WrappedPhase0BeaconBlockBody(b *eth.BeaconBlockBody) block.BeaconBlockBody { return Phase0BeaconBlockBody{b: b} } diff --git a/proto/interfaces/BUILD.bazel b/proto/prysm/v2/block/BUILD.bazel similarity index 69% rename from proto/interfaces/BUILD.bazel rename to proto/prysm/v2/block/BUILD.bazel index d84f956be2..81504812a7 100644 --- a/proto/interfaces/BUILD.bazel +++ b/proto/prysm/v2/block/BUILD.bazel @@ -2,18 +2,14 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", - srcs = [ - "block.go", - "metadata.go", - ], - importpath = "github.com/prysmaticlabs/prysm/proto/interfaces", + srcs = ["block_interfaces.go"], + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v2/block", visibility = ["//visibility:public"], deps = [ "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", - "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/proto/interfaces/block.go b/proto/prysm/v2/block/block_interfaces.go similarity index 98% rename from proto/interfaces/block.go rename to proto/prysm/v2/block/block_interfaces.go index 55d48ef25d..c8e2571975 100644 --- a/proto/interfaces/block.go +++ b/proto/prysm/v2/block/block_interfaces.go @@ -1,4 +1,4 @@ -package interfaces +package block import ( ssz "github.com/ferranbt/fastssz" diff --git a/proto/prysm/v2/metadata/BUILD.bazel b/proto/prysm/v2/metadata/BUILD.bazel new file mode 100644 index 0000000000..d3f79e0e00 --- /dev/null +++ b/proto/prysm/v2/metadata/BUILD.bazel @@ -0,0 +1,12 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["metadata_interfaces.go"], + importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata", + visibility = ["//visibility:public"], + deps = [ + "//proto/prysm/v2:go_default_library", + "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + ], +) diff --git a/proto/interfaces/metadata.go b/proto/prysm/v2/metadata/metadata_interfaces.go similarity index 95% rename from proto/interfaces/metadata.go rename to proto/prysm/v2/metadata/metadata_interfaces.go index 0b482cd839..80b89ba33c 100644 --- a/proto/interfaces/metadata.go +++ b/proto/prysm/v2/metadata/metadata_interfaces.go @@ -1,4 +1,4 @@ -package interfaces +package metadata import ( "github.com/prysmaticlabs/go-bitfield" diff --git a/proto/prysm/v2/wrapper/BUILD.bazel b/proto/prysm/v2/wrapper/BUILD.bazel index a463e32498..6baf2c3bb5 100644 --- a/proto/prysm/v2/wrapper/BUILD.bazel +++ b/proto/prysm/v2/wrapper/BUILD.bazel @@ -9,9 +9,10 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper", visibility = ["//visibility:public"], deps = [ - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", + "//proto/prysm/v2/metadata:go_default_library", "//shared/copyutil:go_default_library", "//shared/version:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/proto/prysm/v2/wrapper/beacon_block.go b/proto/prysm/v2/wrapper/beacon_block.go index 778ba49e00..ca1720d570 100644 --- a/proto/prysm/v2/wrapper/beacon_block.go +++ b/proto/prysm/v2/wrapper/beacon_block.go @@ -3,9 +3,9 @@ package wrapper import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" prysmv2 "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/copyutil" "github.com/prysmaticlabs/prysm/shared/version" "google.golang.org/protobuf/proto" @@ -13,9 +13,9 @@ import ( // Interface conformance checks. var ( - _ = interfaces.SignedBeaconBlock(&altairSignedBeaconBlock{}) - _ = interfaces.BeaconBlock(&altairBeaconBlock{}) - _ = interfaces.BeaconBlockBody(&altairBeaconBlockBody{}) + _ = block.SignedBeaconBlock(&altairSignedBeaconBlock{}) + _ = block.BeaconBlock(&altairBeaconBlock{}) + _ = block.BeaconBlockBody(&altairBeaconBlockBody{}) ) var ( @@ -35,7 +35,7 @@ type altairSignedBeaconBlock struct { // WrappedAltairSignedBeaconBlock is constructor which wraps a protobuf altair block // with the block wrapper. -func WrappedAltairSignedBeaconBlock(b *prysmv2.SignedBeaconBlock) (interfaces.SignedBeaconBlock, error) { +func WrappedAltairSignedBeaconBlock(b *prysmv2.SignedBeaconBlock) (block.SignedBeaconBlock, error) { w := altairSignedBeaconBlock{b: b} if w.IsNil() { return nil, ErrNilObjectWrapped @@ -49,7 +49,7 @@ func (w altairSignedBeaconBlock) Signature() []byte { } // Block returns the underlying beacon block object. -func (w altairSignedBeaconBlock) Block() interfaces.BeaconBlock { +func (w altairSignedBeaconBlock) Block() block.BeaconBlock { return altairBeaconBlock{b: w.b.Block} } @@ -61,7 +61,7 @@ func (w altairSignedBeaconBlock) IsNil() bool { // Copy performs a deep copy of the signed beacon block // object. -func (w altairSignedBeaconBlock) Copy() interfaces.SignedBeaconBlock { +func (w altairSignedBeaconBlock) Copy() block.SignedBeaconBlock { return altairSignedBeaconBlock{b: copyutil.CopySignedBeaconBlockAltair(w.b)} } @@ -116,7 +116,7 @@ type altairBeaconBlock struct { // WrappedAltairBeaconBlock is constructor which wraps a protobuf altair object // with the block wrapper. -func WrappedAltairBeaconBlock(b *prysmv2.BeaconBlock) (interfaces.BeaconBlock, error) { +func WrappedAltairBeaconBlock(b *prysmv2.BeaconBlock) (block.BeaconBlock, error) { w := altairBeaconBlock{b: b} if w.IsNil() { return nil, ErrNilObjectWrapped @@ -145,7 +145,7 @@ func (w altairBeaconBlock) StateRoot() []byte { } // Body returns the underlying block body. -func (w altairBeaconBlock) Body() interfaces.BeaconBlockBody { +func (w altairBeaconBlock) Body() block.BeaconBlockBody { return altairBeaconBlockBody{b: w.b.Body} } @@ -200,7 +200,7 @@ type altairBeaconBlockBody struct { // WrappedAltairBeaconBlockBody is constructor which wraps a protobuf altair object // with the block wrapper. -func WrappedAltairBeaconBlockBody(b *prysmv2.BeaconBlockBody) (interfaces.BeaconBlockBody, error) { +func WrappedAltairBeaconBlockBody(b *prysmv2.BeaconBlockBody) (block.BeaconBlockBody, error) { w := altairBeaconBlockBody{b: b} if w.IsNil() { return nil, ErrNilObjectWrapped diff --git a/proto/prysm/v2/wrapper/metadata.go b/proto/prysm/v2/wrapper/metadata.go index 9cda69b20f..571516af2c 100644 --- a/proto/prysm/v2/wrapper/metadata.go +++ b/proto/prysm/v2/wrapper/metadata.go @@ -2,8 +2,8 @@ package wrapper import ( "github.com/prysmaticlabs/go-bitfield" - p2p "github.com/prysmaticlabs/prysm/proto/interfaces" pb "github.com/prysmaticlabs/prysm/proto/prysm/v2" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/metadata" "google.golang.org/protobuf/proto" ) @@ -38,7 +38,7 @@ func (m MetadataV0) IsNil() bool { } // Copy performs a full copy of the underlying metadata object. -func (m MetadataV0) Copy() p2p.Metadata { +func (m MetadataV0) Copy() metadata.Metadata { return WrappedMetadataV0(proto.Clone(m.md).(*pb.MetaDataV0)) } @@ -85,7 +85,7 @@ func (m MetadataV1) IsNil() bool { } // Copy performs a full copy of the underlying metadata object. -func (m MetadataV1) Copy() p2p.Metadata { +func (m MetadataV1) Copy() metadata.Metadata { return WrappedMetadataV1(proto.Clone(m.md).(*pb.MetaDataV1)) } diff --git a/shared/blockutil/BUILD.bazel b/shared/blockutil/BUILD.bazel index 19d1f754bf..c35448674a 100644 --- a/shared/blockutil/BUILD.bazel +++ b/shared/blockutil/BUILD.bazel @@ -6,8 +6,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/shared/blockutil", visibility = ["//visibility:public"], deps = [ - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "//proto/prysm/v2/block:go_default_library", "@com_github_pkg_errors//:go_default_library", ], ) diff --git a/shared/blockutil/block_utils.go b/shared/blockutil/block_utils.go index bceff3001d..b87dec4fb2 100644 --- a/shared/blockutil/block_utils.go +++ b/shared/blockutil/block_utils.go @@ -2,8 +2,8 @@ package blockutil import ( "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" ) // SignedBeaconBlockHeaderFromBlock function to retrieve signed block header from block. @@ -29,7 +29,7 @@ func SignedBeaconBlockHeaderFromBlock(block *ethpb.SignedBeaconBlock) (*ethpb.Si } // SignedBeaconBlockHeaderFromBlockInterface function to retrieve signed block header from block. -func SignedBeaconBlockHeaderFromBlockInterface(sb interfaces.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { +func SignedBeaconBlockHeaderFromBlockInterface(sb block.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) { b := sb.Block() if b.IsNil() || b.Body().IsNil() { return nil, errors.New("nil block") @@ -65,7 +65,7 @@ func BeaconBlockHeaderFromBlock(block *ethpb.BeaconBlock) (*ethpb.BeaconBlockHea } // BeaconBlockHeaderFromBlockInterface function to retrieve block header from block. -func BeaconBlockHeaderFromBlockInterface(block interfaces.BeaconBlock) (*ethpb.BeaconBlockHeader, error) { +func BeaconBlockHeaderFromBlockInterface(block block.BeaconBlock) (*ethpb.BeaconBlockHeader, error) { if block.Body().IsNil() { return nil, errors.New("nil block body") } diff --git a/spectest/shared/phase0/operations/BUILD.bazel b/spectest/shared/phase0/operations/BUILD.bazel index 638a01aeb3..b20c92cac2 100644 --- a/spectest/shared/phase0/operations/BUILD.bazel +++ b/spectest/shared/phase0/operations/BUILD.bazel @@ -20,9 +20,9 @@ go_library( "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//proto/prysm/v2/state:go_default_library", "//shared/testutil:go_default_library", "//shared/testutil/require:go_default_library", diff --git a/spectest/shared/phase0/operations/attester_slashing.go b/spectest/shared/phase0/operations/attester_slashing.go index 97ed7f57da..97af174050 100644 --- a/spectest/shared/phase0/operations/attester_slashing.go +++ b/spectest/shared/phase0/operations/attester_slashing.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -31,7 +31,7 @@ func RunAttesterSlashingTest(t *testing.T, config string) { require.NoError(t, attSlashing.UnmarshalSSZ(attSlashingSSZ), "Failed to unmarshal") body := ðpb.BeaconBlockBody{AttesterSlashings: []*ethpb.AttesterSlashing{attSlashing}} - RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { + RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b block.SignedBeaconBlock) (state.BeaconState, error) { return blocks.ProcessAttesterSlashings(ctx, s, b.Block().Body().AttesterSlashings(), v.SlashValidator) }) }) diff --git a/spectest/shared/phase0/operations/deposit.go b/spectest/shared/phase0/operations/deposit.go index 04a9ca52d1..6d3ffb8920 100644 --- a/spectest/shared/phase0/operations/deposit.go +++ b/spectest/shared/phase0/operations/deposit.go @@ -8,8 +8,8 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -30,7 +30,7 @@ func RunDepositTest(t *testing.T, config string) { require.NoError(t, deposit.UnmarshalSSZ(depositSSZ), "Failed to unmarshal") body := ðpb.BeaconBlockBody{Deposits: []*ethpb.Deposit{deposit}} - processDepositsFunc := func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { + processDepositsFunc := func(ctx context.Context, s state.BeaconState, b block.SignedBeaconBlock) (state.BeaconState, error) { return blocks.ProcessDeposits(ctx, s, b.Block().Body().Deposits()) } RunBlockOperationTest(t, folderPath, body, processDepositsFunc) diff --git a/spectest/shared/phase0/operations/helpers.go b/spectest/shared/phase0/operations/helpers.go index 2333a3bca5..a6ec6b590d 100644 --- a/spectest/shared/phase0/operations/helpers.go +++ b/spectest/shared/phase0/operations/helpers.go @@ -12,9 +12,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" @@ -22,7 +22,7 @@ import ( "gopkg.in/d4l3k/messagediff.v1" ) -type blockOperation func(context.Context, state.BeaconState, interfaces.SignedBeaconBlock) (state.BeaconState, error) +type blockOperation func(context.Context, state.BeaconState, block.SignedBeaconBlock) (state.BeaconState, error) // RunBlockOperationTest takes in the prestate and the beacon block body, processes it through the // passed in block operation function and checks the post state with the expected post state. diff --git a/spectest/shared/phase0/operations/proposer_slashing.go b/spectest/shared/phase0/operations/proposer_slashing.go index 9b91c5d12c..c3cc0d3557 100644 --- a/spectest/shared/phase0/operations/proposer_slashing.go +++ b/spectest/shared/phase0/operations/proposer_slashing.go @@ -9,8 +9,8 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -31,7 +31,7 @@ func RunProposerSlashingTest(t *testing.T, config string) { require.NoError(t, proposerSlashing.UnmarshalSSZ(proposerSlashingSSZ), "Failed to unmarshal") body := ðpb.BeaconBlockBody{ProposerSlashings: []*ethpb.ProposerSlashing{proposerSlashing}} - RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { + RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b block.SignedBeaconBlock) (state.BeaconState, error) { return blocks.ProcessProposerSlashings(ctx, s, b.Block().Body().ProposerSlashings(), v.SlashValidator) }) }) diff --git a/spectest/shared/phase0/operations/voluntary_exit.go b/spectest/shared/phase0/operations/voluntary_exit.go index a8028688ff..af91c2cf33 100644 --- a/spectest/shared/phase0/operations/voluntary_exit.go +++ b/spectest/shared/phase0/operations/voluntary_exit.go @@ -8,8 +8,8 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/proto/interfaces" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/testutil" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/spectest/utils" @@ -30,7 +30,7 @@ func RunVoluntaryExitTest(t *testing.T, config string) { require.NoError(t, voluntaryExit.UnmarshalSSZ(exitSSZ), "Failed to unmarshal") body := ðpb.BeaconBlockBody{VoluntaryExits: []*ethpb.SignedVoluntaryExit{voluntaryExit}} - RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b interfaces.SignedBeaconBlock) (state.BeaconState, error) { + RunBlockOperationTest(t, folderPath, body, func(ctx context.Context, s state.BeaconState, b block.SignedBeaconBlock) (state.BeaconState, error) { return blocks.ProcessVoluntaryExits(ctx, s, b.Block().Body().VoluntaryExits()) }) }) diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 94b91dd675..88d400f88b 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -21,10 +21,10 @@ go_library( visibility = ["//validator:__subpackages__"], deps = [ "//beacon-chain/core/helpers:go_default_library", - "//proto/interfaces:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", "//proto/prysm/v2:go_default_library", + "//proto/prysm/v2/block:go_default_library", "//shared/blockutil:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/validator/client/propose_protect.go b/validator/client/propose_protect.go index bb5dfd19bf..b4c2ab3560 100644 --- a/validator/client/propose_protect.go +++ b/validator/client/propose_protect.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/proto/interfaces" + "github.com/prysmaticlabs/prysm/proto/prysm/v2/block" "github.com/prysmaticlabs/prysm/shared/blockutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" @@ -17,7 +17,7 @@ var failedPreBlockSignExternalErr = "attempted a double proposal, block rejected var failedPostBlockSignErr = "made a double proposal, considered slashable by remote slashing protection" func (v *validator) preBlockSignValidations( - ctx context.Context, pubKey [48]byte, block interfaces.BeaconBlock, signingRoot [32]byte, + ctx context.Context, pubKey [48]byte, block block.BeaconBlock, signingRoot [32]byte, ) error { fmtKey := fmt.Sprintf("%#x", pubKey[:]) @@ -77,7 +77,7 @@ func (v *validator) preBlockSignValidations( func (v *validator) postBlockSignUpdate( ctx context.Context, pubKey [48]byte, - block interfaces.SignedBeaconBlock, + block block.SignedBeaconBlock, signingRoot [32]byte, ) error { fmtKey := fmt.Sprintf("%#x", pubKey[:]) @@ -106,7 +106,7 @@ func (v *validator) postBlockSignUpdate( return nil } -func blockLogFields(pubKey [48]byte, blk interfaces.BeaconBlock, sig []byte) logrus.Fields { +func blockLogFields(pubKey [48]byte, blk block.BeaconBlock, sig []byte) logrus.Fields { fields := logrus.Fields{ "proposerPublicKey": fmt.Sprintf("%#x", pubKey), "proposerIndex": blk.ProposerIndex(),