Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions beacon_chain/consensus_object_pools/blockchain_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,20 @@ proc loadExecutionAndParentBlockHash*(dag: ChainDAGRef, bid: BlockId):
else:
(Opt.some ZERO_HASH, Opt.some ZERO_HASH)

proc loadExecutionGasLimit*(dag: ChainDAGRef, bid: BlockId): Opt[uint64] =
## The `gas_limit` of the execution payload committed to by the block, i.e.
## the bid's `gas_limit` post-Gloas (the envelope must match the bid).
let blockData = dag.getForkedBlock(bid).valueOr:
return Opt.none(uint64)

withBlck(blockData):
when consensusFork >= ConsensusFork.Gloas:
Opt.some forkyBlck.message.body.signed_execution_payload_bid.message.gas_limit
elif consensusFork in ConsensusFork.Bellatrix .. ConsensusFork.Fulu:
Opt.some forkyBlck.message.body.execution_payload.gas_limit
else:
Opt.none(uint64)

proc loadExecutionAndParentBlockHash*(dag: ChainDAGRef, blck: BlockRef):
tuple[blockHash: Opt[Eth2Digest], parentHash: Opt[Eth2Digest]] =
if blck.executionBlockHash.isNone() or blck.executionParentHash.isNone():
Expand Down
15 changes: 13 additions & 2 deletions beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2028,9 +2028,20 @@ proc validateExecutionPayloadBid*(
# ... `is_gas_limit_target_compatible(parent_gas_limit, bid.gas_limit,
# proposer_preferences.target_gas_limit)` is True, where
# `parent_gas_limit` is the `gas_limit` of that execution payload.
#
# The execution payload identified by `bid.parent_block_hash` is either
# the parent block's own payload or one the parent block builds on
# (withheld), whose `gas_limit` can differ from the parent block's bid.
let parentPayloadBlck =
dag.executionParent(parentBlck, bid.parent_block_hash).valueOr:
return errIgnore(
"ExecutionPayloadBid: parent execution payload block unknown")
let parentGasLimit =
dag.loadExecutionGasLimit(parentPayloadBlck.bid).valueOr:
return errIgnore(
"ExecutionPayloadBid: parent execution payload gas limit unknown")
if not is_gas_limit_target_compatible(
forkyState.data.latest_execution_payload_bid.gas_limit,
bid.gas_limit, seenPref.target_gas_limit):
parentGasLimit, bid.gas_limit, seenPref.target_gas_limit):
return errIgnore("ExecutionPayloadBid: gas limit not target-compatible")

# [IGNORE] bid.slot is the current slot or the next slot
Expand Down
Loading