Skip to content

Per-network deploy step data: make deployStepData and deployedAddress virtual - #415

Merged
thedavidmeister merged 18 commits into
mainfrom
2026-11-30-per-network-deploy-step-data
Nov 30, 2026
Merged

thedavidmeister merged 18 commits into
mainfrom
2026-11-30-per-network-deploy-step-data

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What

  • RainDeploySuitesBase.deployStepData(d, suite, chainId) and deployedAddress(d, suite, chainId) are now virtual.
  • DeployMechanismHandler gains deployStepLocally, the non-broadcasting local twin of deployStep (Zoltu: etchAndDeployZoltu). RainDeploySuitesBase.deployStepDataLocally(d, index, vm, suite, chainId, deployer) etches the dependency closure and deploys deployStepData(d, suite, chainId) through it, refusing DeployStepAddressMismatch unless it lands at deployedAddress(d, suite, chainId). checkSeatsNoDeployKey deploys through it per chain id, so it reads owner() on exactly what the broadcast deploys on that network.
  • RainDeployBroadcast.checkSeatsNoDeployKey also fails closed: it refuses SuiteOwnerUnreadable(suite, deployed, chainId) when deployedAddress(d, suite, chainId) holds no code after the local deploy, or when owner() there succeeds with less than a word. Previously a no-code address answered owner() with empty data and the check passed.
  • RainDeployVerifyBase.deriveDeployment derives per chain id: for each of the suite's networks with a nonzero deployedAddress, it deploys deployStepData(d, suite, chainId) under vm.chainId(chainId) through deployStepDataLocally and records that chain's code hash. derivedBytecodeHash(derived, chainId) returns it, refusing NotDerivedOnChain(suite, chainId) for a chain with no derivation. checkSuiteOnNetwork checks each network's deployed code against that network's derived hash, and checkInternallyConsistent checks the stored code hash against every derived chain's hash. A per-chain beacon proxy (rain.factory Per-network beacon for registry beacon proxy suites rain.factory#309, beacon stored as an immutable) therefore has its own code hash on each chain.

Why

Ruling: multi-network deploys use per-network deploy data. The hooks already take the chain id and RainDeployBroadcast.networkDeploys already calls them once per network, filling NetworkDeploys.deployStepData[i] / derivedAddresses[i], which checkNetworkDeploys length-checks and deployToConfigs broadcasts per network. They were not overridable, so a consumer could not supply per-chain data (st0x.deploy S01-Issuer/st0x.deploy#656 needs each chain's live beacon in its token suites' deploy data). Overriding deployStepData gives each network its own data in one run; overriding deployedAddress keeps the derived address consistent with that data in networkDeploys and the chain matrix.

Making them virtual opened a hole: the seat check deploys the mechanism's own creation code at the mechanism's address (deployLocallyOnChain), then reads owner() at the overridden deployedAddress, which holds no code, so a deploy-key-owned per-network deploy was never refused. The seat check now deploys each network's deployStepData at its deployedAddress through deployStepLocally, and the read fails closed.

Breaking

  • DeployMechanismHandler has a new required field, deployStepLocally: a consumer that builds its own mechanism handler must add it.
  • DerivedDeploy.bytecodeHash (one hash) is replaced by chainIds and bytecodeHashes (one per network, in the suite's network order); read a chain's hash with derivedBytecodeHash(derived, chainId).
  • RainDeployVerifyChain.checkSuiteOnNetwork takes a SupportedNetwork instead of the network name.
  • Stored-code comparisons (checkInternallyConsistent, deployToConfigs, sibling dependency code checks) use expectedBytecodeHash(d, suite, chainId), a virtual hook defaulting to storedBytecodeHash; a suite whose code differs per chain overrides it. A chain whose expected hash is zero refuses NoExpectedBytecodeHash(suite, chainId).

Consumers that only use the shipped Zoltu mechanism, or only override deployStepData/deployedAddress, are not broken by the handler field; those hook signatures are unchanged.

Behaviour for consumers that do not override

Unchanged except: a Zoltu address mismatch in the seat check or in deriveDeployment now refuses DeployStepAddressMismatch instead of ZoltuDerivationMismatch, and an owner() that succeeds with less than a word is now refused rather than passed. A suite with no owner() (the call reverts) still passes, as before.

QA

  • Discriminating tests: RainDeployBroadcast.perNetworkDeployKeySeat.t.sol (the seat probe: a per-network suite owned by the deploy key refuses SuiteSeatsDeployKey from checkSeatsNoDeployKey and broadcastSuite, and passed before the fail-closed read); per-chain code across RainDeployVerifySnapshotBase.perChainCode.t.sol, RainDeployVerifyChain.perChainCode.t.sol, RainDeployDeclarationChecks.perChainCode.t.sol and RainDeployBroadcast.perChainCode.t.sol (each chain against its own hash, another chain's refused, NoExpectedBytecodeHash, NotDerivedOnChain, NoDerivedDeployment, DeployStepAddressMismatch).
  • Mutations applied: n/a - mutation runs last, on the frozen head after review.
  • Oracle: the ruling (per-network data) and st0x.deploy#656's per-chain beacon addresses, independent of this code.
  • Category check: every stored-code comparison (internal consistency, chain check, broadcast, sibling dependencies) and the seat check are covered per chain.

🤖 Generated with Claude Code

…y data

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Nov 30, 2026
thedavidmeister and others added 16 commits November 30, 2026 07:27
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e or owner() is unreadable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in of the deploy step

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompile)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… networks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the per-network deploy key seat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er read

A short owner() answer is refused SuiteOwnerUnreadable; a Zoltu formula/factory
disagreement is refused DeployStepAddressMismatch on the first derived chain; the
fork-through-vm case keeps the suite on catalogue networks so derivation resolves
them before the bad name is forked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister
thedavidmeister merged commit f8bd275 into main Nov 30, 2026
8 of 9 checks passed
@linear

linear Bot commented Nov 30, 2026

Copy link
Copy Markdown

RAI-4999

@thedavidmeister thedavidmeister mentioned this pull request Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant