Repository navigation
fix(cheatcodes): charge deployCode creation gas to caller - #17732
Merged
Merged
Conversation
With dynamic test linking, `new` expressions in tests are rewritten to `vm.deployCode`, which returned all of its gas to the caller. The creation was left out of test gas, gas snapshots, and the gas report. Charge the caller as a native CREATE or CREATE2 would, apply isolated snapshot refund corrections at the caller's depth, and report a creation under `deployCode` as a top-level deployment in the gas report. Fixes #17727.
stevencartavia
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr and
mattsse
as code owners
October 22, 2026 03:17
Enforce the EIP-3860 initcode size limit before charging the synthetic create, as the CREATE opcode does. On Amsterdam, charge the EIP-8037 account creation state gas when the destination is empty, forward the reservoir, and refund the charge when the create does not deploy. Previously deployCode under-reported a non-isolated deployment by the creation state gas (407,475 vs 590,422 for native CREATE; now 591,075).
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.
With dynamic test linking, which is on by default,
newexpressions in tests are rewritten tovm.deployCode. Like every cheatcode,deployCodereturned all of its gas to the caller, so the creation was left out of test gas,forge snapshot, gas snapshot cheatcodes, and the gas report's deployment cost. The same test reported 4,057 gas with linking on and 147,889 with it off. Fixes #17727.deployCodenow charges its caller as a native CREATE or CREATE2 would. It charges the opcode and initcode costs, forwards all but one 64th of the remaining gas to the creation, and settles the result with revm's frame accounting. Isolated gas snapshot sections apply their refund correction at the depth where the caller resumes, and the gas report counts a creation directly underdeployCodeas a top-level deployment. Explicitvm.deployCodecalls are charged too, so existing gas snapshots that use them will increase.