Skip to content

test: pin that the factory forwards uncapped gas to initialize - #262

Open
thedavidmeister wants to merge 2 commits into
mainfrom
2026-09-21-issue-120-initialize-gas-uncapped
Open

thedavidmeister wants to merge 2 commits into
mainfrom
2026-09-21-issue-120-initialize-gas-uncapped

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #120

ICloneableFactoryV4 states normatively that "the factory forwards whatever gas
the caller left it, and the deployer chooses that". The code that makes it true
is an absence: src/lib/LibICloneableFactoryV4.sol:184 calls the clone with no
{gas: …} option, so EIP-150's 63/64 rule governs and the callee's budget
tracks 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: records gasleft() on
    entry to initialize. No existing fixture exposes anything about the budget
    the call carried.
  • testInitializeGasRisesWithCallerBudget — deploys through BOTH entry points
    at gasleft()/8 and then gasleft()/2 and 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

  • Discriminating tests: testInitializeGasRisesWithCallerBudget
    (test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol).
  • Mutations applied: 1 — child.call{gas: 30000000}(abi.encodeCall(...)) at
    src/lib/LibICloneableFactoryV4.sol:184, a plausible defensive cap. On main
    it SURVIVES: all 8 suites green, 78 passed / 0 failed. On this branch the
    cloneAndInitialize file goes 9 passed / 1 failed, and the one failure is
    testInitializeGasRisesWithCallerBudget on the open-salt leg. Unmutated, the
    whole suite is 79 passed / 0 failed.
  • Oracle: src/interface/ICloneableFactoryV4.sol's own sentence about
    forwarding 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.
  • Category check: the category is "a normative claim about the CALL OPTIONS
    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 asserts cloneDeterministicOpenSalt reaches them #123); callee and calldata are pinned by the recorder's selector
    and sData assertions. Gas was the only one with nothing behind it.

Touches test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol, as does
the PR for #121 — both branch off main and append to the same file.

🤖 Generated with Claude Code

thedavidmeister and others added 2 commits September 21, 2026 11:24
`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>
@thedavidmeister thedavidmeister self-assigned this Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: b3065e78-0031-4cea-9faa-47856375d04d

📥 Commits

Reviewing files that changed from the base of the PR and between f2d9e5a and 4114a87.

📒 Files selected for processing (2)
  • test/concrete/TestCloneableGasRecorder.sol
  • test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

[F16] [LOW] Nothing pins that the factory forwards uncapped gas to initialize — the behaviour #100 added to the NatSpec after the ledgered commit

1 participant