debug: add debug_getBlockReceipts with EIP-8037 dimensional gas fields#800
Closed
qu0b wants to merge 1 commit into
Closed
debug: add debug_getBlockReceipts with EIP-8037 dimensional gas fields#800qu0b wants to merge 1 commit into
qu0b wants to merge 1 commit into
Conversation
Mirrors eth_getBlockReceipts. When EIP-8037 is active, each receipt also carries stateGasCharged (pre-refund state-dimension gas) and stateGasRefunded (state-dimension refunds applied). Pre-activation blocks omit both fields. Header reconstruction: header.stateGasUsed = Σ stateGasCharged − Σ stateGasRefunded header.regularGasUsed = Σ gasUsed − header.stateGasUsed Motivation: bal-devnet-6 clients diverged on regular-vs-state gas attribution by exactly AccountCreationCost (131488) because the missing tx-level CREATE-halt refund (now fixed in EIPs#11611) was invisible at the receipt level. The split charged/refunded counters make the failure mode directly observable. Why split and not a single net stateGasUsed: per EIPs#11611, execution_state_gas_used may go below zero under EIP-7702 unset. JSON-RPC convention is unsigned hex; the split keeps every wire value uint64 without signed encoding or data loss. Per-tx stateGasRefunded MAY exceed stateGasCharged; block-boundary Σ charged ≥ Σ refunded. Conformance fixtures: not-found, pre-Amsterdam (fields omitted), top-level CREATE halt (the bal-devnet-6 case), and a two-tx block where the second tx is an EIP-7702 unset whose refund exceeds its charge.
c1ffcb1 to
c4185eb
Compare
4 tasks
4 tasks
Author
|
Closed for now, clients are not in favor of this new endpoint, but would rather implement a Tracer that displays the state gas. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirrors
eth_getBlockReceipts. When EIP-8037 is active, each receipt also carriesstateGasCharged(pre-refund state-dimension gas) andstateGasRefunded(state-dimension refunds applied). Pre-activation blocks omit both fields.Header reconstruction (MUST):
Motivation
bal-devnet-6 clients diverged on regular-vs-state gas attribution by exactly
AccountCreationCost = 131,488because the missing tx-level CREATE-halt refund (now fixed in ethereum/EIPs#11611) was invisible at the receipt level. The currentReceiptexposes only the unifiedgasUsed— a missed refund and "no state operations" produce the same number.The split
stateGasCharged/stateGasRefundedmakes the failure mode directly observable at receipt scope. A consumer can verifyheader.stateGasUsedreconstructs from the receipts and localise any divergence to a specific tx without running a tracer.Tracking issue: ethereum/execution-specs#2804.
Design choices
regularGasUsedis derivable asgasUsed − (stateGasCharged − stateGasRefunded);cumulative*fields are derivable by summing per-tx values in order. Only the two non-derivable, state-dimension counters are spec'd.stateGasCharged+stateGasRefunded, not a signed net. Per EIPs#11611,execution_state_gas_usedmay go negative under EIP-7702 unset. JSON-RPC convention is unsigned hex. A single netstateGasUsedwould have to be either signed (parser-hostile) or clamped (data loss — "no state ops" indistinguishable from "charge + larger refund"). The split is the only encoding that's both parseable and lossless.gasUsed.debugnamespace, additive. No receipts-root change, no consensus impact. Once cross-client implementations are stable, the same two fields can land oneth_getBlockReceipts/eth_getTransactionReceiptwithout rename.Implementation cost
Both clients already compute the dimensional values during execution:
core/vm/gascosts.gohasGasBudget{RegularGas, StateGas, StateGasRefund}and threads it throughstate_transition.go. TheStateGasRefundaccumulator already exists per-frame. Receipt struct (core/types/receipt.go) is single-dim today; the wiring is the new work.crates/ethereum/payload/src/lib.rstracksblock_state_gas_used(net) at payload-build time. Persisted receipt isalloy_consensus::EthereumReceipt, single-dim. Splittingstate_gas_used()into charged + refunded requires a revm change.Per-client wiring is small. No new tracing infrastructure required (geth's
core/tracing/hooks.go:171has an unlandedGasChangeV2HookTODO — this PR doesn't depend on it).