mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Update comments describing init-sync process (#7521)
* updates comments * fetcher mode from config Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
5cd6f65a2c
commit
b9844024b4
@ -133,6 +133,7 @@ func newBlocksFetcher(ctx context.Context, cfg *blocksFetcherConfig) *blocksFetc
|
|||||||
fetchRequests: make(chan *fetchRequestParams, maxPendingRequests),
|
fetchRequests: make(chan *fetchRequestParams, maxPendingRequests),
|
||||||
fetchResponses: make(chan *fetchRequestResponse, maxPendingRequests),
|
fetchResponses: make(chan *fetchRequestResponse, maxPendingRequests),
|
||||||
capacityWeight: capacityWeight,
|
capacityWeight: capacityWeight,
|
||||||
|
mode: cfg.mode,
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,17 @@ const (
|
|||||||
// blockReceiverFn defines block receiving function.
|
// blockReceiverFn defines block receiving function.
|
||||||
type blockReceiverFn func(ctx context.Context, block *eth.SignedBeaconBlock, blockRoot [32]byte) error
|
type blockReceiverFn func(ctx context.Context, block *eth.SignedBeaconBlock, blockRoot [32]byte) error
|
||||||
|
|
||||||
|
// batchBlockReceiverFn defines batch receiving function.
|
||||||
type batchBlockReceiverFn func(ctx context.Context, blks []*eth.SignedBeaconBlock, roots [][32]byte) error
|
type batchBlockReceiverFn func(ctx context.Context, blks []*eth.SignedBeaconBlock, roots [][32]byte) error
|
||||||
|
|
||||||
// Round Robin sync looks at the latest peer statuses and syncs with the highest
|
// Round Robin sync looks at the latest peer statuses and syncs up to the highest known epoch.
|
||||||
// finalized peer.
|
|
||||||
//
|
//
|
||||||
// Step 1 - Sync to finalized epoch.
|
// Step 1 - Sync to finalized epoch.
|
||||||
// Sync with peers of lowest finalized root with epoch greater than head state.
|
// Sync with peers having the majority on best finalized epoch greater than node's head state.
|
||||||
//
|
//
|
||||||
// Step 2 - Sync to head from finalized epoch.
|
// Step 2 - Sync to head from finalized epoch.
|
||||||
// Using the finalized root as the head_block_root and the epoch start slot
|
// Using enough peers (at least, MinimumSyncPeers*2, for example) obtain best non-finalized epoch,
|
||||||
// after the finalized epoch, request blocks to head from some subset of peers
|
// known to majority of the peers, and keep fetching blocks, up until that epoch is reached.
|
||||||
// where step = 1.
|
|
||||||
func (s *Service) roundRobinSync(genesis time.Time) error {
|
func (s *Service) roundRobinSync(genesis time.Time) error {
|
||||||
ctx, cancel := context.WithCancel(s.ctx)
|
ctx, cancel := context.WithCancel(s.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -75,16 +74,13 @@ func (s *Service) roundRobinSync(genesis time.Time) error {
|
|||||||
log.WithError(err).Debug("Error stopping queue")
|
log.WithError(err).Debug("Error stopping queue")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Already at head, no need for 2nd phase.
|
||||||
if s.chain.HeadSlot() == helpers.SlotsSince(genesis) {
|
if s.chain.HeadSlot() == helpers.SlotsSince(genesis) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2 - sync to head from any single peer.
|
// Step 2 - sync to head from majority of peers (from no less than MinimumSyncPeers*2 peers) having the same
|
||||||
// This step might need to be improved for cases where there has been a long period since
|
// world view on non-finalized epoch.
|
||||||
// finality. This step is less important than syncing to finality in terms of threat
|
|
||||||
// mitigation. We are already convinced that we are on the correct finalized chain. Any blocks
|
|
||||||
// we receive there after must build on the finalized chain or be considered invalid during
|
|
||||||
// fork choice resolution / block processing.
|
|
||||||
queue = newBlocksQueue(ctx, &blocksQueueConfig{
|
queue = newBlocksQueue(ctx, &blocksQueueConfig{
|
||||||
p2p: s.p2p,
|
p2p: s.p2p,
|
||||||
headFetcher: s.chain,
|
headFetcher: s.chain,
|
||||||
@ -114,16 +110,16 @@ func (s *Service) processFetchedData(
|
|||||||
ctx context.Context, genesis time.Time, startSlot uint64, data *blocksQueueFetchedData) {
|
ctx context.Context, genesis time.Time, startSlot uint64, data *blocksQueueFetchedData) {
|
||||||
defer s.updatePeerScorerStats(data.pid, startSlot)
|
defer s.updatePeerScorerStats(data.pid, startSlot)
|
||||||
|
|
||||||
blockReceiver := s.chain.ReceiveBlockInitialSync
|
|
||||||
batchReceiver := s.chain.ReceiveBlockBatch
|
|
||||||
|
|
||||||
// Use Batch Block Verify to process and verify batches directly.
|
// Use Batch Block Verify to process and verify batches directly.
|
||||||
if featureconfig.Get().BatchBlockVerify {
|
if featureconfig.Get().BatchBlockVerify {
|
||||||
|
batchReceiver := s.chain.ReceiveBlockBatch
|
||||||
if err := s.processBatchedBlocks(ctx, genesis, data.blocks, batchReceiver); err != nil {
|
if err := s.processBatchedBlocks(ctx, genesis, data.blocks, batchReceiver); err != nil {
|
||||||
log.WithError(err).Debug("Batch is not processed")
|
log.WithError(err).Debug("Batch is not processed")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockReceiver := s.chain.ReceiveBlockInitialSync
|
||||||
for _, blk := range data.blocks {
|
for _, blk := range data.blocks {
|
||||||
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
|
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
|
||||||
log.WithError(err).Debug("Block is not processed")
|
log.WithError(err).Debug("Block is not processed")
|
||||||
@ -138,7 +134,6 @@ func (s *Service) processFetchedDataRegSync(
|
|||||||
defer s.updatePeerScorerStats(data.pid, startSlot)
|
defer s.updatePeerScorerStats(data.pid, startSlot)
|
||||||
|
|
||||||
blockReceiver := s.chain.ReceiveBlock
|
blockReceiver := s.chain.ReceiveBlock
|
||||||
|
|
||||||
for _, blk := range data.blocks {
|
for _, blk := range data.blocks {
|
||||||
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
|
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
|
||||||
log.WithError(err).Debug("Block is not processed")
|
log.WithError(err).Debug("Block is not processed")
|
||||||
|
Loading…
Reference in New Issue
Block a user