Skip to content

Migrate to the compiler-derived candidate source anchor: rain-deploy removes DeployCandidate.sourceCreationCode #10

Description

@thedavidmeister

Upstream change

rainlanguage/rain.deploy#242 removes DeployCandidate.sourceCreationCode and
makes checkCandidatesAnchoredToSource resolve the candidate's own
snapshot.artifactPath through vm.getCode instead. The source operand now
comes from the compiler rather than from the declaration.

The removed field was one a consumer filled in. Pointing it at the same
generated constant as the record made the one check that catches a snapshot of
the wrong contract compare a value with itself — green for any candidate at all,
in CI and on the irreversible RainDeployBroadcast.run() path alike. That is
rainlanguage/rain.factory.deploy#34, which #242 closes.

This is a BREAKING change and this repo's declaration must be edited before the
pin can move.

What this repo has to change

Current pin: "rain-deploy" = "0.1.7" (foundry.toml:66) — the oldest pin of
any consumer, so this repo has the largest jump.

1. src/abstract/ExtrospectDeploySuites.sol

One candidate, extrospect:

  • Line 56 — delete sourceCreationCode: type(Extrospect).creationCode, and
    the trailing comma on the snapshot: DeploySuite({...}) entry above it. The
    DeployCandidate({...}) literal is left with its single snapshot field.
  • Line 6 — delete import {Extrospect} from "../concrete/Extrospect.sol";.
    It becomes unused: line 56 is its only use in this file. The remaining
    Extrospect spellings are the aliased import from
    ../generated/candidate/Extrospect.sol (line 10) and doc prose, neither of
    which needs the type.

artifactPath at line 53 is "src/concrete/Extrospect.sol:Extrospect". Checked
against the tree: that file exists and declares contract Extrospect, so it
resolves and needs no correction.

2. test/src/abstract/ExtrospectDeploySuites.t.sol — one test becomes unspellable

testExtrospectArtifactPathIsTheCandidateContract (lines 30-36) currently
asserts exactly the property #242 moves into the package:

assertEq(
    keccak256(vm.getCode(candidate.snapshot.artifactPath)),
    keccak256(candidate.sourceCreationCode),
    "artifact path does not compile to the candidate's source creation code"
);

Its right-hand operand is the field being removed, so the test cannot compile
after the bump. It is not merely redundant — once the anchor itself reads
vm.getCode(artifactPath), restating it here against the same call would compare
a value with itself, which is the exact shape #242 exists to eliminate. Delete it
rather than rewrite it, and note in its place that the package now enforces it.
The two sibling tests in the same file,
testExtrospectSuiteKeyIsTheDispatchedSuite and
testExtrospectCandidateHasNoDependencies, are untouched and still cover the
other two unconstrained fields.

The doc comment at lines 25-29 names sourceCreationCode and goes with it.

3. script/Build.sol

  • Line 82 — contracts[i].candidate.sourceCreationCode, becomes
    vm.getCode(contracts[i].candidate.snapshot.artifactPath),, so
    regenerateSnapshots writes from the same origin the anchor reads back.
  • Line 18 — the GeneratedContract doc comment says "Snapshots are written
    from its sourceCreationCode and snapshot.dependencies"; that field will no
    longer exist.

test/script/Build.t.sol:116 splits artifactPath on ":" to check the
generated contract name. That keeps working — src/concrete/Extrospect.sol:Extrospect
splits to two components — but it is worth re-reading alongside the change, since
the path it reads is now load-bearing rather than cosmetic.

4. Version pin, when there is one to move to

Seven files spell the versioned remapping prefix rain-deploy-0.1.7/ and each has
to be rewritten together with foundry.toml and soldeer.lock:

  • src/abstract/RainDeploySuitesBase.sol (the re-export shim holding the one
    local spelling of the package path, which the generated libs reach through a
    relative import and so cannot be skipped)
  • script/Build.sol, script/Deploy.sol
  • test/script/Build.t.sol, test/src/abstract/ExtrospectDeployChain.t.sol,
    test/src/abstract/ExtrospectDeploySnapshot.t.sol,
    test/src/concrete/Extrospect.constants.t.sol

The version to bump to does not exist yet

rainlanguage/rain.deploy#242 is open, unmerged and unreleased. There is no
published rain-deploy version carrying this change, so this issue deliberately
names none. The bump target has to be filled in once #242 merges and a Soldeer
release is cut; until then this issue is the record of what the edit will be,
not a request to make it.

Not affected in this repo

Migration item 3 of #242 — "any consumer wrapper marked pure must become
view" — needs no edit here. This repo inherits RainDeployVerifySnapshot
without redeclaring testSnapshotMatchesSource or wrapping
checkCandidatesAnchoredToSource, so the mutability change lands entirely
inside the package.

Migration item 4 — no foundry.toml change is required, because vm.getCode
does not go through fs_permissions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions