Repository navigation
test: pin that a clone can clone through the same factory during initialize - #263
Open
thedavidmeister wants to merge 2 commits into
Open
thedavidmeister wants to merge 2 commits into
thedavidmeister wants to merge 2 commits into
Conversation
…ialize `cloneAndInitialize` calls the clone after the clone exists and after `NewClone` is emitted, and the library holds no state, so that call may re-enter the factory. No fixture called out during `initialize`, so nothing reached the re-entrant path at all: every existing fixture stores, emits, returns or reverts. `TestCloneableNestedClone` clones a second implementation through the factory that is initializing it. One test pins that both clones land at their own derivation's address with their own bytes and that the two `NewClone` logs interleave as an indexer would see them, the outer first and the nested one sent by the outer clone. The other pins that a nested revert takes the whole outer deploy with it and leaves its `(deployer, salt)` free, by deploying there again rather than by reading a code length a revert has already rolled back. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…nested-clone-reentrancy
|
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 #121
cloneAndInitializemakes one external call,child.call(initialize), afterthe clone exists and after
NewCloneis emitted. That call can re-enter thefactory, and an orchestrator clone deploying its own parts during initialization
is the ordinary Rain shape. No fixture could reach the path: every one of them
only stores, emits, returns or reverts, so nothing exercised a nested
CREATE2,a nested occupancy check running while the outer clone already has code, or the
interleaved
NewClonelogs an indexer would see. No mutation operator canauthor a fixture that calls back, so the gap was invisible to the campaign.
test/concrete/TestCloneableNestedClone.sol— new: clones a secondimplementation through the factory that is initializing it.
testNestedCloneDuringInitialize— pins both addresses against their ownpredictions, both initializations, and the two
NewClonelogs in order, thenested one sent by the outer clone.
testNestedCloneAtOccupiedAddressUnwindsOuterDeploy— a nested revert takesthe whole outer deploy with it, and the outer
(deployer, salt)is still freeafterwards: a retry at a free inner salt lands at the address the outer always
predicted. The outer runs through the NAMESPACED entry point, whose derivation
excludes
data, which is what lets the retry change the inner salt and keepthe outer address.
QA
testNestedCloneDuringInitializeandtestNestedCloneAtOccupiedAddressUnwindsOuterDeploy(
test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol).tail (
tload/revert/tstore(0,1)beforecheckImplementationCode,tstore(0,0)beforereturn child), the defensive edit this PR exists tomake fail. On main it SURVIVES: all 8 suites green, 78 passed / 0 failed. On
this branch the
cloneAndInitializefile goes 9 passed / 2 failed, and thetwo failures are exactly these two tests. Unmutated, the whole suite is 80
passed / 0 failed.
ICloneableFactoryV4's clauses oncloneDeterministic/cloneDeterministicOpenSalt, which say nothing that forbids re-entry, againsta library that holds no storage of its own — so the second deploy is governed
by the same occupancy check as the first, evaluated fresh. The open-salt
derivation is caller-independent, which is what lets the test predict the
nested address from outside.
inside
initialize". Its members are a nested clone that succeeds (firsttest), a nested clone that reverts (second test), and a nested call to a
predictfunction — which reads no state the tail mutates and returns thesame value inside the call as outside, so there is nothing there to break.
Touches
test/src/lib/LibICloneableFactoryV4.cloneAndInitialize.t.sol, as doesthe PR for #120 — both branch off
mainand append to the same file.🤖 Generated with Claude Code