`...ExecutionPayloadHash` --> `...ExecutionBlockHash` (#5864)

Finish the rename started in #4809 to have a consistent naming.
`ExecutionPayloadHash` suggests hash over payload instead of block.
`BlockHash` is also the canonical name in engine API.
This commit is contained in:
Etan Kissling 2024-02-08 01:24:55 +01:00 committed by GitHub
parent 464ff68658
commit e398078abc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 48 additions and 48 deletions

View File

@ -71,8 +71,8 @@ proc initLightClient*(
template callForkchoiceUpdated(attributes: untyped) =
discard await node.elManager.forkchoiceUpdated(
headBlockHash = blckPayload.block_hash,
safeBlockHash = beaconHead.safeExecutionPayloadHash,
finalizedBlockHash = beaconHead.finalizedExecutionPayloadHash,
safeBlockHash = beaconHead.safeExecutionBlockHash,
finalizedBlockHash = beaconHead.finalizedExecutionBlockHash,
payloadAttributes = none attributes)
case node.dag.cfg.consensusForkAtEpoch(

View File

@ -761,18 +761,18 @@ func getAggregatedAttestation*(pool: var AttestationPool,
type BeaconHead* = object
blck*: BlockRef
safeExecutionPayloadHash*, finalizedExecutionPayloadHash*: Eth2Digest
safeExecutionBlockHash*, finalizedExecutionBlockHash*: Eth2Digest
proc getBeaconHead*(
pool: AttestationPool, headBlock: BlockRef): BeaconHead =
let
finalizedExecutionPayloadHash =
finalizedExecutionBlockHash =
pool.dag.loadExecutionBlockHash(pool.dag.finalizedHead.blck)
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/fork_choice/safe-block.md#get_safe_execution_payload_hash
safeBlockRoot = pool.forkChoice.get_safe_beacon_block_root()
safeBlock = pool.dag.getBlockRef(safeBlockRoot)
safeExecutionPayloadHash =
safeExecutionBlockHash =
if safeBlock.isErr:
# Safe block is currently the justified block determined by fork choice.
# If finality already advanced beyond the current justified checkpoint,
@ -780,14 +780,14 @@ proc getBeaconHead*(
# the justified block may end up not having a `BlockRef` anymore.
# Because we know that a different fork already finalized a later point,
# let's just report the finalized execution payload hash instead.
finalizedExecutionPayloadHash
finalizedExecutionBlockHash
else:
pool.dag.loadExecutionBlockHash(safeBlock.get)
BeaconHead(
blck: headBlock,
safeExecutionPayloadHash: safeExecutionPayloadHash,
finalizedExecutionPayloadHash: finalizedExecutionPayloadHash)
safeExecutionBlockHash: safeExecutionBlockHash,
finalizedExecutionBlockHash: finalizedExecutionBlockHash)
proc selectOptimisticHead*(
pool: var AttestationPool, wallTime: BeaconTime): Opt[BeaconHead] =

View File

@ -145,7 +145,7 @@ func shouldSyncOptimistically*(self: ConsensusManager, wallSlot: Slot): bool =
func optimisticHead*(self: ConsensusManager): BlockId =
self.optimisticHead.bid
func optimisticExecutionPayloadHash*(self: ConsensusManager): Eth2Digest =
func optimisticExecutionBlockHash*(self: ConsensusManager): Eth2Digest =
self.optimisticHead.execution_block_hash
func setOptimisticHead*(
@ -155,18 +155,18 @@ func setOptimisticHead*(
proc updateExecutionClientHead(self: ref ConsensusManager,
newHead: BeaconHead): Future[Opt[void]] {.async: (raises: [CancelledError]).} =
let headExecutionPayloadHash = self.dag.loadExecutionBlockHash(newHead.blck)
let headExecutionBlockHash = self.dag.loadExecutionBlockHash(newHead.blck)
if headExecutionPayloadHash.isZero:
if headExecutionBlockHash.isZero:
# Blocks without execution payloads can't be optimistic.
self.dag.markBlockVerified(newHead.blck)
return Opt[void].ok()
template callForkchoiceUpdated(attributes: untyped): auto =
await self.elManager.forkchoiceUpdated(
headBlockHash = headExecutionPayloadHash,
safeBlockHash = newHead.safeExecutionPayloadHash,
finalizedBlockHash = newHead.finalizedExecutionPayloadHash,
headBlockHash = headExecutionBlockHash,
safeBlockHash = newHead.safeExecutionBlockHash,
finalizedBlockHash = newHead.finalizedExecutionBlockHash,
payloadAttributes = none attributes)
# Can't use dag.head here because it hasn't been updated yet
@ -352,13 +352,13 @@ proc runProposalForkchoiceUpdated*(
if headBlockHash.isZero:
return err()
let safeBlockHash = beaconHead.safeExecutionPayloadHash
let safeBlockHash = beaconHead.safeExecutionBlockHash
withState(self.dag.headState):
template callForkchoiceUpdated(fcPayloadAttributes: auto) =
let (status, _) = await self.elManager.forkchoiceUpdated(
headBlockHash, safeBlockHash,
beaconHead.finalizedExecutionPayloadHash,
beaconHead.finalizedExecutionBlockHash,
payloadAttributes = some fcPayloadAttributes)
debug "Fork-choice updated for proposal", status

View File

@ -16,7 +16,7 @@ import
from std/deques import Deque, addLast, contains, initDeque, items, len, shrink
from std/sequtils import mapIt
from ../consensus_object_pools/consensus_manager import
ConsensusManager, checkNextProposer, optimisticExecutionPayloadHash,
ConsensusManager, checkNextProposer, optimisticExecutionBlockHash,
runProposalForkchoiceUpdated, shouldSyncOptimistically, updateHead,
updateHeadWithExecution
from ../consensus_object_pools/blockchain_dag import
@ -636,12 +636,12 @@ proc storeBlock(
template callForkchoiceUpdated(attributes: untyped) =
if NewPayloadStatus.noResponse != payloadStatus and
not self.consensusManager[].optimisticExecutionPayloadHash.isZero:
not self.consensusManager[].optimisticExecutionBlockHash.isZero:
discard await elManager.forkchoiceUpdated(
headBlockHash =
self.consensusManager[].optimisticExecutionPayloadHash,
safeBlockHash = newHead.get.safeExecutionPayloadHash,
finalizedBlockHash = newHead.get.finalizedExecutionPayloadHash,
self.consensusManager[].optimisticExecutionBlockHash,
safeBlockHash = newHead.get.safeExecutionBlockHash,
finalizedBlockHash = newHead.get.finalizedExecutionBlockHash,
payloadAttributes = none attributes)
let consensusFork = self.consensusManager.dag.cfg.consensusForkAtEpoch(
@ -651,10 +651,10 @@ proc storeBlock(
callForkchoiceUpdated(consensusFork.PayloadAttributes)
else:
let
headExecutionPayloadHash =
headExecutionBlockHash =
dag.loadExecutionBlockHash(newHead.get.blck)
wallSlot = self.getBeaconTime().slotOrZero
if headExecutionPayloadHash.isZero or
if headExecutionBlockHash.isZero or
NewPayloadStatus.noResponse == payloadStatus:
# Blocks without execution payloads can't be optimistic, and don't try
# to fcU to a block the EL hasn't seen
@ -666,9 +666,9 @@ proc storeBlock(
template callExpectValidFCU(payloadAttributeType: untyped): auto =
await elManager.expectValidForkchoiceUpdated(
headBlockPayloadAttributesType = payloadAttributeType,
headBlockHash = headExecutionPayloadHash,
safeBlockHash = newHead.get.safeExecutionPayloadHash,
finalizedBlockHash = newHead.get.finalizedExecutionPayloadHash,
headBlockHash = headExecutionBlockHash,
safeBlockHash = newHead.get.safeExecutionBlockHash,
finalizedBlockHash = newHead.get.finalizedExecutionBlockHash,
receivedBlock = signedBlock)
template callForkChoiceUpdated: auto =

View File

@ -389,8 +389,8 @@ proc getExecutionPayload(
forkyState.data.latest_execution_payload_header.block_hash
else:
(static(default(Eth2Digest)))
latestSafe = beaconHead.safeExecutionPayloadHash
latestFinalized = beaconHead.finalizedExecutionPayloadHash
latestSafe = beaconHead.safeExecutionBlockHash
latestFinalized = beaconHead.finalizedExecutionBlockHash
timestamp = withState(proposalState[]):
compute_timestamp_at_slot(forkyState.data, forkyState.data.slot)
random = withState(proposalState[]):
@ -553,7 +553,7 @@ proc getBlindedExecutionPayload[
EPH: capella.ExecutionPayloadHeader |
deneb_mev.BlindedExecutionPayloadAndBlobsBundle](
node: BeaconNode, payloadBuilderClient: RestClientRef, slot: Slot,
executionBlockRoot: Eth2Digest, pubkey: ValidatorPubKey):
executionBlockHash: Eth2Digest, pubkey: ValidatorPubKey):
Future[BlindedBlockResult[EPH]] {.async: (raises: [CancelledError, RestError]).} =
# Not ideal to use `when` where instead of splitting into separate functions,
# but Nim doesn't overload on generic EPH type parameter.
@ -561,7 +561,7 @@ proc getBlindedExecutionPayload[
let
response = awaitWithTimeout(
payloadBuilderClient.getHeaderCapella(
slot, executionBlockRoot, pubkey),
slot, executionBlockHash, pubkey),
BUILDER_PROPOSAL_DELAY_TOLERANCE):
return err "Timeout obtaining Capella blinded header from builder"
@ -577,7 +577,7 @@ proc getBlindedExecutionPayload[
let
response = awaitWithTimeout(
payloadBuilderClient.getHeaderDeneb(
slot, executionBlockRoot, pubkey),
slot, executionBlockHash, pubkey),
BUILDER_PROPOSAL_DELAY_TOLERANCE):
return err "Timeout obtaining Deneb blinded header from builder"
@ -767,12 +767,12 @@ proc getBlindedBlockParts[
Future[Result[(EPH, UInt256, ForkedBeaconBlock), string]]
{.async: (raises: [CancelledError]).} =
let
executionBlockRoot = node.dag.loadExecutionBlockHash(head)
executionBlockHash = node.dag.loadExecutionBlockHash(head)
executionPayloadHeader =
try:
awaitWithTimeout(
getBlindedExecutionPayload[EPH](
node, payloadBuilderClient, slot, executionBlockRoot, pubkey),
node, payloadBuilderClient, slot, executionBlockHash, pubkey),
BUILDER_PROPOSAL_DELAY_TOLERANCE):
BlindedBlockResult[EPH].err("getBlindedExecutionPayload timed out")
except RestDecodingError as exc:

View File

@ -39,7 +39,7 @@ type
opOnBlock
opOnMergeBlock
opOnAttesterSlashing
opInvalidateRoot
opInvalidateHash
opChecks
BlobData = object
@ -61,8 +61,8 @@ type
powBlock: PowBlock
of opOnAttesterSlashing:
attesterSlashing: AttesterSlashing
of opInvalidateRoot:
invalidatedRoot: Eth2Digest
of opInvalidateHash:
invalidatedHash: Eth2Digest
latestValidHash: Eth2Digest
of opChecks:
checks: JsonNode
@ -153,9 +153,9 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] =
attesterSlashing: attesterSlashing)
elif step.hasKey"payload_status":
if step["payload_status"]["status"].getStr() == "INVALID":
result.add Operation(kind: opInvalidateRoot,
result.add Operation(kind: opInvalidateHash,
valid: true,
invalidatedRoot: Eth2Digest.fromHex(step["block_hash"].getStr()),
invalidatedHash: Eth2Digest.fromHex(step["block_hash"].getStr()),
latestValidHash: Eth2Digest.fromHex(
step["payload_status"]["latest_valid_hash"].getStr()))
elif step.hasKey"checks":
@ -180,7 +180,7 @@ proc stepOnBlock(
signedBlock: ForkySignedBeaconBlock,
blobData: Opt[BlobData],
time: BeaconTime,
invalidatedRoots: Table[Eth2Digest, Eth2Digest]):
invalidatedHashes: Table[Eth2Digest, Eth2Digest]):
Result[BlockRef, VerifierError] =
# 1. Validate blobs
when typeof(signedBlock).kind >= ConsensusFork.Deneb:
@ -210,18 +210,18 @@ proc stepOnBlock(
# would also have `true` validity because it'd not be known they weren't, so
# adding this mock of the block processor is realistic and sufficient.
when consensusFork >= ConsensusFork.Bellatrix:
let executionPayloadHash =
let executionBlockHash =
signedBlock.message.body.execution_payload.block_hash
if executionPayloadHash in invalidatedRoots:
if executionBlockHash in invalidatedHashes:
# Mocks fork choice INVALID list application. These tests sequence this
# in a way the block processor does not, specifying each payload_status
# before the block itself, while Nimbus fork choice treats invalidating
# a non-existent block root as a no-op and does not remember it for the
# future.
let lvh = invalidatedRoots.getOrDefault(
executionPayloadHash, static(default(Eth2Digest)))
let lvh = invalidatedHashes.getOrDefault(
executionBlockHash, static(default(Eth2Digest)))
fkChoice[].mark_root_invalid(dag.getEarliestInvalidBlockRoot(
signedBlock.message.parent_root, lvh, executionPayloadHash))
signedBlock.message.parent_root, lvh, executionBlockHash))
return err VerifierError.Invalid
@ -304,7 +304,7 @@ proc doRunTest(path: string, fork: ConsensusFork) =
let steps = loadOps(path, fork)
var time = stores.fkChoice.checkpoints.time
var invalidatedRoots: Table[Eth2Digest, Eth2Digest]
var invalidatedHashes: Table[Eth2Digest, Eth2Digest]
let state = newClone(stores.dag.headState)
var stateCache = StateCache()
@ -325,7 +325,7 @@ proc doRunTest(path: string, fork: ConsensusFork) =
let status = stepOnBlock(
stores.dag, stores.fkChoice,
verifier, state[], stateCache,
forkyBlck, step.blobData, time, invalidatedRoots)
forkyBlck, step.blobData, time, invalidatedHashes)
doAssert status.isOk == step.valid
of opOnAttesterSlashing:
let indices =
@ -334,8 +334,8 @@ proc doRunTest(path: string, fork: ConsensusFork) =
for idx in indices.get:
stores.fkChoice[].process_equivocation(idx)
doAssert indices.isOk == step.valid
of opInvalidateRoot:
invalidatedRoots[step.invalidatedRoot] = step.latestValidHash
of opInvalidateHash:
invalidatedHashes[step.invalidatedHash] = step.latestValidHash
of opChecks:
stepChecks(step.checks, stores.dag, stores.fkChoice, time)
else: