mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
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 <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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[:])
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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[:])
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
1
proto/prysm/BUILD.bazel
Normal file
1
proto/prysm/BUILD.bazel
Normal file
@@ -0,0 +1 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
@@ -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",
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
package interfaces
|
||||
package block
|
||||
|
||||
import (
|
||||
ssz "github.com/ferranbt/fastssz"
|
||||
12
proto/prysm/v2/metadata/BUILD.bazel
Normal file
12
proto/prysm/v2/metadata/BUILD.bazel
Normal file
@@ -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",
|
||||
],
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
package interfaces
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
@@ -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",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user