status-im / nimbus-eth1

Nimbus: an Ethereum Execution Client for Resource-Restricted Devices

Home Page:https://status-im.github.io/nimbus-eth1/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`engine_forkchoiceUpdatedV1`/`V2`/`V3` allow beginning payload build process if `forkchoiceState.headBlockHash` references a `VALID` ancestor of the head of canonical chain

tersec opened this issue · comments

https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/engine/paris.md#specification-1 notes:

  1. Client software MAY skip an update of the forkchoice state and MUST NOT begin a payload build process if forkchoiceState.headBlockHash references a VALID ancestor of the head of canonical chain, i.e. the ancestor passed payload validation process and deemed VALID. In the case of such an event, client software MUST return {payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}.

But

# If the head block is already in our canonical chain, the beacon client is
# probably resyncing. Ignore the update.
var canonHash: common.Hash256
if db.getBlockHash(header.blockNumber, canonHash) and canonHash == blockHash:
# TODO should this be possible?
# If we allow these types of reorgs, we will do lots and lots of reorgs during sync
notice "Reorg to previous block", blockHash

combined with
# If payload generation was requested, create a new block to be potentially
# sealed by the beacon client. The payload will be requested later, and we
# might replace it arbitrarilly many times in between.
if attrsOpt.isSome:
let attrs = attrsOpt.get()
validateVersion(attrs, com, apiVersion)
let bundle = ben.generatePayload(attrs).valueOr:
error "Failed to create sealing payload", err = error
raise invalidAttr(error)
let id = computePayloadId(blockHash, attrs)
ben.put(id, ben.blockValue, bundle.executionPayload, bundle.blobsBundle)
info "Created payload for sealing",
id = id.toHex,
hash = bundle.executionPayload.blockHash.short,
number = bundle.executionPayload.blockNumber
return validFCU(some(id), blockHash)

allow exactly this.