mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
This reverts commit 9a4bf6c1a2.
This commit is contained in:
@@ -85,19 +85,16 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedB
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get head from fork choice service")
|
||||
}
|
||||
signedHeadBlock, err := s.beaconDB.Block(ctx, bytesutil.ToBytes32(headRoot))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not compute state from block head")
|
||||
}
|
||||
if signedHeadBlock == nil || signedHeadBlock.Block == nil {
|
||||
return errors.New("nil head block")
|
||||
}
|
||||
|
||||
// Only save head if it's different than the current head.
|
||||
if !bytes.Equal(headRoot, s.HeadRoot()) {
|
||||
signedHeadBlock, err := s.beaconDB.Block(ctx, bytesutil.ToBytes32(headRoot))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not compute state from block head")
|
||||
}
|
||||
if signedHeadBlock == nil || signedHeadBlock.Block == nil {
|
||||
return errors.New("nil head block")
|
||||
}
|
||||
|
||||
logCompetingBlock(root[:], blockCopy.Block.Slot, headRoot, signedHeadBlock.Block.Slot)
|
||||
|
||||
if err := s.saveHead(ctx, signedHeadBlock, bytesutil.ToBytes32(headRoot)); err != nil {
|
||||
return errors.Wrap(err, "could not save head")
|
||||
}
|
||||
@@ -121,6 +118,9 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedB
|
||||
// Reports on block and fork choice metrics.
|
||||
s.reportSlotMetrics(blockCopy.Block.Slot)
|
||||
|
||||
// Log if block is a competing block.
|
||||
isCompetingBlock(root[:], blockCopy.Block.Slot, headRoot, signedHeadBlock.Block.Slot)
|
||||
|
||||
// Log state transition data.
|
||||
logStateTransitionData(blockCopy.Block)
|
||||
|
||||
@@ -244,12 +244,14 @@ func (s *Service) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.SignedB
|
||||
}
|
||||
|
||||
// This checks if the block is from a competing chain, emits warning and updates metrics.
|
||||
func logCompetingBlock(root []byte, slot uint64, headRoot []byte, headSlot uint64) {
|
||||
log.WithFields(logrus.Fields{
|
||||
"blkSlot": slot,
|
||||
"blkRoot": hex.EncodeToString(root[:]),
|
||||
"headSlot": headSlot,
|
||||
"headRoot": hex.EncodeToString(headRoot),
|
||||
}).Warn("Calculated head diffs from new block")
|
||||
competingBlks.Inc()
|
||||
func isCompetingBlock(root []byte, slot uint64, headRoot []byte, headSlot uint64) {
|
||||
if !bytes.Equal(root[:], headRoot) {
|
||||
log.WithFields(logrus.Fields{
|
||||
"blkSlot": slot,
|
||||
"blkRoot": hex.EncodeToString(root[:]),
|
||||
"headSlot": headSlot,
|
||||
"headRoot": hex.EncodeToString(headRoot),
|
||||
}).Warn("Calculated head diffs from new block")
|
||||
competingBlks.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user