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