Enforce that [package].version, its snapshot and the deploy lib agree - #4
Enforce that [package].version, its snapshot and the deploy lib agree#4thedavidmeister wants to merge 1 commit into
Conversation
A release moves three things together: `[package].version`, the frozen `src/generated/<tag>/` snapshot it names, and the `LibCloneFactoryDeploy` pins aliased out of that snapshot. Nothing asserted they still name the same tag, so a hand-edited version silently publishes a release whose pins belong to another one. `BuildPointers` now emits the tag it generated for as `LibCloneFactoryDeploy. DEPLOY_TAG` (the name `rainix-tag-release` already documents for a deploy-pin snapshot), and `LibCloneFactoryDeployTagTest` asserts: - `DEPLOY_TAG` equals `[package].version` with dots as underscores, read from `foundry.toml` rather than hardcoded so it survives a release untouched; - a `src/generated/<DEPLOY_TAG>/` snapshot exists; - that snapshot records exactly the address and codehash the lib exposes. The frozen snapshots are untouched: regenerating writes only the lib. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughThe generated deployment library now exposes its release snapshot tag. A new test contract verifies that the tag matches the package version, the corresponding snapshot exists, and its pinned address and bytecode hash match the library aliases. ChangesDeployment tag pinning
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Superseded by #5, which migrates this repo to the rolling-candidate model (mirroring S01-Issuer/st0x.deploy#283). That migration removes the premise this PR enforces: The other two assertions are carried forward, not lost:
The Recommend closing this in favour of #5. Not closing it here — that is yours to call. |
|
🤖 ai:vetter |
|
🤖 ai:producer |
What
A release in this repo moves three things at once:
[package].versioninfoundry.toml,src/generated/<tag>/CloneFactory.pointers.solsnapshot it names,LibCloneFactoryDeploypins aliased out of that snapshot.Nothing asserted they still name the same tag.
LibCloneFactoryDeployTestcatches drift in one direction only — current source vs the aliased pins — so a
hand-edited
[package].versionthat outruns the snapshot passed CI green, andrainix-tag-releasewould then publish a version whose pins belong to adifferent release.
This adds the
testDeployTaganalogue thatst0x.deploycarries, closing thathole.
script/BuildPointers.solemits the tag it generated for asLibCloneFactoryDeploy.DEPLOY_TAG. That is the name the shared reusablealready documents for a deploy-pin snapshot (
rainix-tag-release'ssnapshot-generate-cmd: "regenerates the deploy-pin snapshot ... intosrc/generated/<tag>/, DEPLOY_TAG and any pointer libs"), and the analogueof
st0x.deploy'sLibProdDeployCurrent.DEPLOY_TAG.test/src/lib/LibCloneFactoryDeployTag.t.solasserts all three agree:testDeployTag—DEPLOY_TAGequals[package].versionwith dots asunderscores. The version is read from
foundry.toml, not hardcoded, soa release moves it without hand-editing the test (same approach as
st0x.deploy).testDeployTagSnapshotExists— asrc/generated/<DEPLOY_TAG>/snapshotactually exists, so the version can only name a release that was really
snapshotted.
testDeployTagSnapshotHoldsTheAliasedPins— that snapshot records exactlythe address and codehash the library exposes, so the alias cannot silently
point at a different tag's snapshot.
Frozen snapshots are untouched: regenerating writes only
src/lib/LibCloneFactoryDeploy.sol. Thefrozen-snapshots-append-onlygate hasnothing to complain about.
Proof the test actually bites
Baseline (committed state) is green:
Mutant 1 — hand-edited version outruns the snapshot.
[package].version0.1.5->0.1.6, snapshot still0_1_5. Exactly the hole this closes:Mutant 2 — library left aliasing a superseded snapshot.
[package].versionand
DEPLOY_TAGboth say0_1_3, while the generated import still resolves0_1_5.testDeployTagis happy (version and tag agree) and the0_1_3snapshot exists, so only the third assertion can catch it — and does:
Mutant 3 — version names a tag that was never snapshotted.
0.9.9/0_9_9:Restored with
git checkout HEAD -- foundry.toml src/lib/LibCloneFactoryDeploy.sol;clean tree, suite green again.
Verification
nix develop github:rainlanguage/rainix/53e96a7d0a97d7c7c75c3b2412521324776fdac6#sol-shell:forge soldeer install && forge build— clean.forge test— 18 passed. The 5LibCloneFactoryDeployProdTestfork testsfail locally only because no
*_RPC_URLis set in this shell; they areuntouched by this PR.
forge fmt --check— clean.reuse lint— clean.forge script ./script/BuildPointers.sol && forge fmtfrom the committedstate leaves an empty
git status: the generator reproduces the committedLibCloneFactoryDeploy.solbyte-for-byte and rewrites no frozen snapshot.Known CI red — do not chase
rainix-sol / testis expected to fail ontestProdDeployArbitrum:That is an exhausted drpc quota on the
RPC_URL_ARBITRUM_FORKsecret, not acode failure — it needs a human RPC swap. 19/20 pass on
maintoday for thesame reason. This PR adds 3 passing tests and changes nothing that a fork test
reads.
Summary by CodeRabbit
New Features
Documentation
Tests