Skip to content

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

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. This repo has five candidates and four tests
that read the removed field, so it carries more of the migration than any other
consumer except raindex.

What this repo has to change

Current pin: rain-deploy = "0.1.10" (foundry.toml:60).

1. src/abstract/RainlangDeploySuites.sol — five candidates

Delete the sourceCreationCode: line from each DeployCandidate({...}) literal,
and the trailing comma on the snapshot: DeploySuite({...}) entry above it:

Suite sourceCreationCode line artifactPath line Path
parser 114 — type(RainlangParser).creationCode 111 src/concrete/RainlangParser.sol:RainlangParser
store 134 — type(RainlangStore).creationCode 131 src/concrete/RainlangStore.sol:RainlangStore
interpreter 161 — type(RainlangInterpreter).creationCode 158 src/concrete/RainlangInterpreter.sol:RainlangInterpreter
expression-deployer 191 — type(RainlangExpressionDeployer).creationCode 188 src/concrete/RainlangExpressionDeployer.sol:RainlangExpressionDeployer
rainlang 224 — type(Rainlang).creationCode 221 src/concrete/Rainlang.sol:Rainlang

All five artifact paths were checked against the tree: each file exists and
declares the named contract, so all five resolve and none needs correction.

The five concrete imports on lines 6-10 — RainlangParser, RainlangStore,
RainlangInterpreter, RainlangExpressionDeployer, Rainlang — exist only to
spell those type(X).creationCode expressions and all become unused.

2. test/src/abstract/RainlangDeploySuites.t.sol — four tests read the removed field

This is the substantial part of the migration here.

testArtifactPathsResolveToTheCandidateSource (line 92, external view)
asserts keccak256(vm.getCode(artifactPath)) == keccak256(sourceCreationCode) —
exactly the property #242 moves into the package. Its right-hand operand
disappears, and restating it against the same vm.getCode call would compare a
value with itself, which is the shape #242 exists to eliminate. Delete it, and
note in its place that checkCandidatesAnchoredToSource now enforces it. Its doc
comment at lines 86-91 ("nothing in rain-deploy dereferences it") also stops
being true and goes with it.

Three external pure tests scan the removed field's bytes for addresses and
need a new source of those bytes:

  • testCandidatesDependOnTheSiblingsTheyReach — line 142,
    containsAddress(candidates[i].sourceCreationCode, candidates[j].snapshot.storedDeployedAddress)
  • testCandidatesReachEveryDependencyTheyDeclare — line 181,
    containsAddress(candidates[i].sourceCreationCode, deps[j])
  • testCandidatesDependOnTheExternalsTheyReach — line 224,
    containsAddress(candidates[i].sourceCreationCode, externals[j])

There are two spellings and this issue does not pick one:

  • candidates[i].snapshot.creationCode — the recorded constant. Keeps all three
    tests pure, no other edit. Sound only because the anchor now guarantees the
    record equals the compiled artifact; these tests would be asserting about the
    snapshot rather than about source.
  • vm.getCode(candidates[i].snapshot.artifactPath) — the compiled artifact.
    Preserves the "what the source actually embeds" meaning the tests were written
    for, but each of the three must change from external pure to external view.

3. script/Build.sol

  • Line 99 — contracts[i].candidate.sourceCreationCode, becomes
    vm.getCode(contracts[i].candidate.snapshot.artifactPath),, so
    regenerateSnapshots writes from the same origin the anchor reads back.
  • Line 26 — the GeneratedContract doc comment names sourceCreationCode.

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

Five files spell the versioned remapping prefix rain-deploy-0.1.10/ 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/src/abstract/RainlangDeployChain.t.sol,
    test/src/abstract/RainlangDeploySnapshot.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