Small readjustment of FCU logs (#4473)

This commit is contained in:
Andrew Ashikhmin 2022-06-17 13:47:17 +02:00 committed by GitHub
parent 45b374a6d8
commit 70b41f5dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -254,11 +254,11 @@ func startHandlingForkChoice(
headerReader services.HeaderReader,
) error {
headerHash := forkChoice.HeadBlockHash
log.Info(fmt.Sprintf("[%s] Handling fork choice", s.LogPrefix()), "headerHash", headerHash)
log.Debug(fmt.Sprintf("[%s] Handling fork choice", s.LogPrefix()), "headerHash", headerHash)
currentHeadHash := rawdb.ReadHeadHeaderHash(tx)
if currentHeadHash == headerHash { // no-op
log.Info(fmt.Sprintf("[%s] Fork choice no-op", s.LogPrefix()))
log.Debug(fmt.Sprintf("[%s] Fork choice no-op", s.LogPrefix()))
cfg.hd.BeaconRequestList.Remove(requestId)
rawdb.WriteForkchoiceHead(tx, forkChoice.HeadBlockHash)
canonical, err := safeAndFinalizedBlocksAreCanonical(forkChoice, s, tx, cfg, requestStatus == engineapi.New)
@ -280,7 +280,7 @@ func startHandlingForkChoice(
bad, lastValidHash := cfg.hd.IsBadHeaderPoS(headerHash)
if bad {
log.Info(fmt.Sprintf("[%s] Fork choice bad head block", s.LogPrefix()), "headerHash", headerHash)
log.Warn(fmt.Sprintf("[%s] Fork choice bad head block", s.LogPrefix()), "headerHash", headerHash)
cfg.hd.BeaconRequestList.Remove(requestId)
if requestStatus == engineapi.New {
cfg.hd.PayloadStatusCh <- privateapi.PayloadStatus{
@ -293,7 +293,7 @@ func startHandlingForkChoice(
return nil
}
// Header itself may already be in the snapshots, if CL starts off at much ealier state than Erigon
// Header itself may already be in the snapshots, if CL starts off at much earlier state than Erigon
header, err := headerReader.HeaderByHash(ctx, tx, headerHash)
if err != nil {
return err
@ -318,7 +318,7 @@ func startHandlingForkChoice(
cfg.hd.BeaconRequestList.Remove(requestId)
headerNumber := header.Number.Uint64()
// If header is canononical, then no reorgs are required
// If header is canonical, then no reorgs are required
canonicalHash, err := rawdb.ReadCanonicalHash(tx, headerNumber)
if err != nil {
log.Warn(fmt.Sprintf("[%s] Fork choice err (reading canonical hash of %d)", s.LogPrefix(), headerNumber), "err", err)
@ -348,6 +348,7 @@ func startHandlingForkChoice(
}
return nil
}
cfg.hd.UpdateTopSeenHeightPoS(headerNumber)
forkingPoint := uint64(0)
@ -365,20 +366,18 @@ func startHandlingForkChoice(
}
}
log.Info(fmt.Sprintf("[%s] Fork choice re-org", s.LogPrefix()), "headerNumber", headerNumber, "forkingPoint", forkingPoint)
if requestStatus == engineapi.New {
if headerNumber-forkingPoint <= ShortPoSReorgThresholdBlocks {
log.Info(fmt.Sprintf("[%s] Short range re-org", s.LogPrefix()), "headerNumber", headerNumber, "forkingPoint", forkingPoint)
// TODO(yperbasis): what if some bodies are missing and we have to download them?
cfg.hd.SetPendingPayloadStatus(headerHash)
} else {
log.Info(fmt.Sprintf("[%s] Long range re-org", s.LogPrefix()), "headerNumber", headerNumber, "forkingPoint", forkingPoint)
cfg.hd.PayloadStatusCh <- privateapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}
}
}
log.Trace(fmt.Sprintf("[%s] Fork choice beginning unwind", s.LogPrefix()))
u.UnwindTo(forkingPoint, common.Hash{})
log.Trace(fmt.Sprintf("[%s] Fork choice unwind finished", s.LogPrefix()))
cfg.hd.SetUnsettledForkChoice(forkChoice, headerNumber)