mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
cleaner logging (#7689)
This commit is contained in:
parent
f79b168ab2
commit
df762bbfee
@ -50,6 +50,7 @@ var (
|
||||
errFetcherCtxIsDone = errors.New("fetcher's context is done, reinitialize")
|
||||
errSlotIsTooHigh = errors.New("slot is higher than the finalized slot")
|
||||
errBlockAlreadyProcessed = errors.New("block is already processed")
|
||||
errParentDoesNotExist = errors.New("beacon node doesn't have a parent in db with root")
|
||||
errInvalidFetchedData = errors.New("invalid data returned from peer")
|
||||
)
|
||||
|
||||
|
@ -289,7 +289,7 @@ func TestBlocksQueue_Loop(t *testing.T) {
|
||||
assert.NoError(t, queue.start())
|
||||
processBlock := func(block *eth.SignedBeaconBlock) error {
|
||||
if !beaconDB.HasBlock(ctx, bytesutil.ToBytes32(block.Block.ParentRoot)) {
|
||||
return fmt.Errorf("beacon node doesn't have a block in db with root %#x", block.Block.ParentRoot)
|
||||
return fmt.Errorf("%w: %#x", errParentDoesNotExist, block.Block.ParentRoot)
|
||||
}
|
||||
root, err := block.Block.HashTreeRoot()
|
||||
if err != nil {
|
||||
|
@ -121,16 +121,26 @@ func (s *Service) processFetchedDataRegSync(
|
||||
defer s.updatePeerScorerStats(data.pid, startSlot)
|
||||
|
||||
blockReceiver := s.chain.ReceiveBlock
|
||||
invalidBlocks := 0
|
||||
for _, blk := range data.blocks {
|
||||
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
|
||||
if errors.Is(err, errBlockAlreadyProcessed) {
|
||||
switch {
|
||||
case errors.Is(err, errBlockAlreadyProcessed):
|
||||
log.WithField("err", err.Error()).Debug("Block is not processed")
|
||||
} else {
|
||||
invalidBlocks++
|
||||
case errors.Is(err, errParentDoesNotExist):
|
||||
log.WithField("err", err.Error()).Debug("Block is not processed")
|
||||
invalidBlocks++
|
||||
default:
|
||||
log.WithField("err", err.Error()).Warn("Block is not processed")
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
// Add more visible logging if all blocks cannot be processed.
|
||||
if len(data.blocks) == invalidBlocks {
|
||||
log.WithField("err", "Range had no valid blocks to process").Warn("Range is not processed")
|
||||
}
|
||||
}
|
||||
|
||||
// highestFinalizedEpoch returns the absolute highest finalized epoch of all connected peers.
|
||||
@ -204,7 +214,7 @@ func (s *Service) processBlock(
|
||||
s.logSyncStatus(genesis, blk.Block, blkRoot)
|
||||
parentRoot := bytesutil.ToBytes32(blk.Block.ParentRoot)
|
||||
if !s.db.HasBlock(ctx, parentRoot) && !s.chain.HasInitSyncBlock(parentRoot) {
|
||||
return fmt.Errorf("beacon node doesn't have a block in db with root %#x", blk.Block.ParentRoot)
|
||||
return fmt.Errorf("%w: %#x", errParentDoesNotExist, blk.Block.ParentRoot)
|
||||
}
|
||||
if err := blockReceiver(ctx, blk, blkRoot); err != nil {
|
||||
return err
|
||||
@ -237,7 +247,7 @@ func (s *Service) processBatchedBlocks(ctx context.Context, genesis time.Time,
|
||||
s.logBatchSyncStatus(genesis, blks, blkRoot)
|
||||
parentRoot := bytesutil.ToBytes32(firstBlock.Block.ParentRoot)
|
||||
if !s.db.HasBlock(ctx, parentRoot) && !s.chain.HasInitSyncBlock(parentRoot) {
|
||||
return fmt.Errorf("beacon node doesn't have a block in db with root %#x", firstBlock.Block.ParentRoot)
|
||||
return fmt.Errorf("%w: %#x", errParentDoesNotExist, firstBlock.Block.ParentRoot)
|
||||
}
|
||||
blockRoots := make([][32]byte, len(blks))
|
||||
blockRoots[0] = blkRoot
|
||||
|
Loading…
Reference in New Issue
Block a user