Skip to content

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

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.8" (foundry.toml:73).

1. src/abstract/MetaBoardDeploySuites.sol

One candidate, metaboard:

  • Line 55 — delete sourceCreationCode: type(MetaBoard).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 {MetaBoard} from "../concrete/MetaBoard.sol";. It
    becomes unused: line 55 is its only use in this file. The remaining MetaBoard
    spellings are the aliased import from ../generated/candidate/MetaBoard.sol
    (line 10) and doc prose, neither of which needs the type.

artifactPath at line 52 is "src/concrete/MetaBoard.sol:MetaBoard". Checked
against the tree: that file exists and declares contract MetaBoard, so it
resolves and needs no correction. Note that after #242 this string stops being a
forge verify-contract convenience and becomes the load-bearing source operand —
the anchor fails, inside RainDeployBroadcast.run() and before the broadcast, if
it ever goes stale.

2. script/Build.sol

  • Line 88 — 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.

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

Nine files spell the versioned remapping prefix rain-deploy-0.1.8/ 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/MetaBoardDeployChain.t.sol,
    test/src/abstract/MetaBoardDeploySnapshot.t.sol,
    test/src/lib/LibMetaBoardDeployCandidate.t.sol,
    test/src/lib/LibMetaBoardDeploy.t.sol,
    test/src/subgraph/SubgraphDeployRecord.t.sol,
    test/src/subgraph/SubgraphRecordReader.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