Skip to content

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

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, so a consumer names
the contract and has no say in what that contract compiles to.

This repo is the one that found the bug: #34, whose mutant M27 flipped
sourceCreationCode from type(CloneFactory).creationCode to the recorded
constant and survived this repo's whole 28-test suite. #242 closes it.

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

What this repo has to change

Current pin: "rain-deploy" = "0.1.8" (foundry.toml:45).

1. src/abstract/CloneFactoryDeploySuites.sol

One candidate, clone-factory:

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

artifactPath at line 53 is "src/concrete/CloneFactory.sol:CloneFactory".
Checked against the tree: src/concrete/CloneFactory.sol exists and declares
contract CloneFactory, 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 88contracts[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

Seven 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 that holds the one
    local spelling of the package path — but which the generated libs reach
    through a relative import, so it cannot be skipped)
  • script/Build.sol, script/Deploy.sol
  • test/src/abstract/CloneFactoryDeployChain.t.sol,
    test/src/abstract/CloneFactoryDeploySnapshot.t.sol,
    test/src/lib/LibCloneFactoryDeployCandidate.t.sol,
    test/src/lib/LibCloneFactoryDeploy.t.sol

Related but separate

#41 — the RECORD half of the anchor can still be spelled
type(X).creationCode. #242 explicitly does not close that, and this issue does
not either.

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