Repository navigation
feat: check gas limit consistency with the target #9391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6151936
3b60b56
34ec0f9
873a4b6
eeb75ed
3b997a1
b3e038d
fbd98c9
852b4cf
bcb484f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { | |||||
| createSingleSignatureSetFromComponents, | ||||||
| getExecutionPayloadBidSigningRoot, | ||||||
| isActiveBuilder, | ||||||
| isGasLimitTargetCompatible, | ||||||
| isStatePostGloas, | ||||||
| } from "@lodestar/state-transition"; | ||||||
| import {gloas} from "@lodestar/types"; | ||||||
|
|
@@ -128,14 +129,32 @@ async function validateExecutionPayloadBid( | |||||
| }); | ||||||
| } | ||||||
|
|
||||||
| // [REJECT] `bid.gas_limit == proposer_preferences.target_gas_limit`. | ||||||
| // [IGNORE] `bid.parent_block_hash` is the block hash of a known execution payload in fork | ||||||
| // choice. Partial implementation: we can only resolve the head's last committed bid because | ||||||
| // fork choice doesn't yet index per-payload metadata by EL block hash. Bids whose parent | ||||||
| // payload sits behind that (EMPTY-parent chains, sibling forks) get IGNORED and will | ||||||
| // re-enter the validator as the head catches up. | ||||||
| // TODO GLOAS: drop this guard once fork choice tracks executed-payload gas_limit by hash. | ||||||
| if (!byteArrayEquals(bid.parentBlockHash, state.latestExecutionPayloadBid.blockHash)) { | ||||||
| throw new ExecutionPayloadBidError(GossipAction.IGNORE, { | ||||||
| code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH, | ||||||
| parentBlockHash: parentBlockHashHex, | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| // [REJECT] `is_gas_limit_target_compatible(parent_gas_limit, bid.gas_limit, target_gas_limit)`, | ||||||
| // where `parent_gas_limit` is the `gas_limit` of the parent execution payload and | ||||||
| // `target_gas_limit` is `proposer_preferences.target_gas_limit`. | ||||||
| const bidGasLimit = Number(bid.gasLimit); | ||||||
| if (bidGasLimit !== proposerPreferences.message.targetGasLimit) { | ||||||
| const parentGasLimit = Number(state.latestExecutionPayloadBid.gasLimit); | ||||||
| const targetGasLimit = proposerPreferences.message.targetGasLimit; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| if (!isGasLimitTargetCompatible(parentGasLimit, bidGasLimit, targetGasLimit)) { | ||||||
| throw new ExecutionPayloadBidError(GossipAction.REJECT, { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH, | ||||||
| builderIndex: bid.builderIndex, | ||||||
| bidGasLimit, | ||||||
| expectedGasLimit: proposerPreferences.message.targetGasLimit, | ||||||
| parentGasLimit, | ||||||
| targetGasLimit, | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -183,10 +202,6 @@ async function validateExecutionPayloadBid( | |||||
| }); | ||||||
| } | ||||||
|
|
||||||
| // [IGNORE] `bid.parent_block_hash` is the block hash of a known execution | ||||||
| // payload in fork choice. | ||||||
| // TODO GLOAS: implement this | ||||||
|
|
||||||
| // [REJECT] `signed_execution_payload_bid.signature` is valid with respect to the `bid.builder_index`. | ||||||
| const signatureSet = createSingleSignatureSetFromComponents( | ||||||
| PublicKey.fromBytes(builder.pubkey), | ||||||
|
|
||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guard uses
state.latestExecutionPayloadBid.blockHash, but in Gloas that field can diverge from the latest executed EL payload hash after EMPTY-parent transitions (processParentExecutionPayloadleavesstate.latestBlockHashunchanged whileprocessExecutionPayloadBidstill updateslatestExecutionPayloadBid). In that state, spec-valid bids withparent_block_hash == state.latestBlockHashare incorrectly IGNORED, and bids pointing to a non-executed bid hash can pass this check. This can cause the node to drop valid gossip bids and accept invalid parent references until head/state alignment changes.Useful? React with 👍 / 👎.