test: pin that the factory forwards uncapped gas to initialize - #262
Open
thedavidmeister wants to merge 2 commits into
Open
thedavidmeister wants to merge 2 commits into
thedavidmeister wants to merge 2 commits into
Conversation
`cloneAndInitialize` calls the clone with no gas option, so the callee's
budget tracks the caller's. Nothing read gas anywhere in the suite, so a
`{gas: K}` cap would have left it green while making every gas-heavy
implementation undeployable.
`TestCloneableGasRecorder` records `gasleft()` on entry to `initialize`,
which is the only way the budget the call carried is observable. The test
deploys through both entry points at an eighth and at a half of what it
itself has left and asserts the observed gas rises, so no figure is pinned
and a cap anywhere below a chain's own gas limit is caught.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…initialize-gas-uncapped
|
Warning Review limit reachedNext included review available in 29 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
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.
Closes #120
ICloneableFactoryV4states normatively that "the factory forwards whatever gasthe caller left it, and the deployer chooses that". The code that makes it true
is an absence:
src/lib/LibICloneableFactoryV4.sol:184calls the clone with no{gas: …}option, so EIP-150's 63/64 rule governs and the callee's budgettracks the caller's. Nothing in the suite read gas at all —
grep -rn "gasleft\|gas:" test/returned nothing — and mutation cannot reach an absent operand, so a
"defensive" cap would have left all 78 tests green while making every gas-heavy
implementation undeployable.
test/concrete/TestCloneableGasRecorder.sol— new: recordsgasleft()onentry to
initialize. No existing fixture exposes anything about the budgetthe call carried.
testInitializeGasRisesWithCallerBudget— deploys through BOTH entry pointsat
gasleft()/8and thengasleft()/2and asserts the observed figure rises.The budgets are fractions of what the test itself has left, so they are
derived inside the same run rather than pinned, and both sit far above any cap
a chain's own block gas limit would let a caller supply.
QA
testInitializeGasRisesWithCallerBudget(
test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol).child.call{gas: 30000000}(abi.encodeCall(...))atsrc/lib/LibICloneableFactoryV4.sol:184, a plausible defensive cap. On mainit SURVIVES: all 8 suites green, 78 passed / 0 failed. On this branch the
cloneAndInitializefile goes 9 passed / 1 failed, and the one failure istestInitializeGasRisesWithCallerBudgeton the open-salt leg. Unmutated, thewhole suite is 79 passed / 0 failed.
src/interface/ICloneableFactoryV4.sol's own sentence aboutforwarding the caller's gas, and EIP-150 — 63/64 of a larger budget is larger,
which is the only reason the strict inequality can hold without a pinned
figure.
the factory uses, invisible to mutation because the source carries no
operand". The other options on that same call are value and callee/calldata.
Value is pinned on both paths by
…NoEthForwarded(namespaced today,open-salt in [F19] [LOW] Four shared-tail clauses are pinned only through
cloneDeterministic; nothing assertscloneDeterministicOpenSaltreaches them #123); callee and calldata are pinned by the recorder's selectorand
sDataassertions. Gas was the only one with nothing behind it.Touches
test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol, as doesthe PR for #121 — both branch off
mainand append to the same file.🤖 Generated with Claude Code