Skip to content

docs: clarify EIP-8037 gas accounting - #910

Open
mattsse wants to merge 3 commits into
masterfrom
mattsse/docs-eip8037-gas
Open

docs: clarify EIP-8037 gas accounting#910
mattsse wants to merge 3 commits into
masterfrom
mattsse/docs-eip8037-gas

Conversation

@mattsse

@mattsse mattsse commented Sep 9, 2026

Copy link
Copy Markdown
Member

Clarify every Vm.Gas field and the last-frame and snapshot cheatcode docs, including which values exclude EIP-8037 state gas, how state refills differ from ordinary refunds, and what isolation changes. Explain signed state deltas and why measured consumption is not a sufficient transaction gas limit, with references to the EIP and the book. Import the documentation from Foundry's canonical cheatcode metadata while preserving the existing interface surface.

The canonical documentation comes from foundry-rs/foundry#16772; merge that before the next full interface regeneration. The expanded guide is in foundry-rs/book#2076, with matching Rust API documentation in alloy-rs/alloy#4195.

AI assistance: Codex authored the documentation and PR description.

@mattsse mattsse left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vm.sol is generated from cheatcodes.json, so the substantive review is on foundry#16772 and regenerating with scripts/vm.py after that lands will pick everything up. Leaving the same suggestions inline here so they can be applied directly if this PR goes first; the text is identical to the foundry ones apart from the // field-comment style this file uses.

Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment on lines +2632 to +2635
/// This scalar snapshot is not the EIP-8037 sum of regular and state gas.
/// It can include state gas drawn from regular gas, but excludes state gas paid from the reservoir.
/// Isolated frames with zero net state gas use receipt gas instead.
/// Use `lastFrameGas` for separate components. See <https://eips.ethereum.org/EIPS/eip-8037>.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as on foundry#16772: one pointer sentence per overload instead of the four-line block, and the "isolated frames with zero net state gas" clause goes away once the stack.rs behaviour is settled (details in the foundry review).

Suggested change
/// This scalar snapshot is not the EIP-8037 sum of regular and state gas.
/// It can include state gas drawn from regular gas, but excludes state gas paid from the reservoir.
/// Isolated frames with zero net state gas use receipt gas instead.
/// Use `lastFrameGas` for separate components. See <https://eips.ethereum.org/EIPS/eip-8037>.
/// Records regular gas only; EIP-8037 state gas paid from the reservoir is excluded. See <https://getfoundry.sh/reference/cheatcodes/gas-snapshots>.

Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
Comment thread src/Vm.sol Outdated
@mattsse

mattsse commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Regenerated Vm.sol from the updated Foundry metadata, including the shorter field definitions and call-versus-create distinction. Snapshot docs retain the spillover and isolated zero-state qualifications to match the current implementation. No interface signatures changed.

AI assistance: Codex authored this update and reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant