Don't write headBlockHash & co when FCU points to an old canonical block (#4650)

This commit is contained in:
Andrew Ashikhmin 2022-07-06 13:14:13 +02:00 committed by GitHub
parent d9cb87a149
commit f05401b78e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -332,22 +332,15 @@ func startHandlingForkChoice(
if headerHash == canonicalHash { if headerHash == canonicalHash {
log.Info(fmt.Sprintf("[%s] Fork choice on previously known block", s.LogPrefix())) log.Info(fmt.Sprintf("[%s] Fork choice on previously known block", s.LogPrefix()))
cfg.hd.BeaconRequestList.Remove(requestId) cfg.hd.BeaconRequestList.Remove(requestId)
rawdb.WriteForkchoiceHead(tx, forkChoice.HeadBlockHash) // Per the Engine API spec:
canonical, err := safeAndFinalizedBlocksAreCanonical(forkChoice, s, tx, cfg) // Client software MAY skip an update of the forkchoice state and MUST NOT begin a payload build process
if err != nil { // if forkchoiceState.headBlockHash references an ancestor of the head of canonical chain.
log.Warn(fmt.Sprintf("[%s] Fork choice err", s.LogPrefix()), "err", err) // In the case of such an event, client software MUST return
return nil, err // {payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}.
}
if canonical {
return &privateapi.PayloadStatus{ return &privateapi.PayloadStatus{
Status: remote.EngineStatus_VALID, Status: remote.EngineStatus_VALID,
LatestValidHash: headerHash, LatestValidHash: headerHash,
}, nil }, nil
} else {
return &privateapi.PayloadStatus{
CriticalError: &privateapi.InvalidForkchoiceStateErr,
}, nil
}
} }
if cfg.memoryOverlay && headerHash == cfg.hd.GetNextForkHash() { if cfg.memoryOverlay && headerHash == cfg.hd.GetNextForkHash() {