Migration und Ausstieg
Ein Smart Contract lässt sich nach dem Deploy nicht ändern, deshalb ist eine Korrektur immer eine neue Version an einer neuen Adresse. Diese Seite zeigt, wie die Owner einen Safe auf eine neue Version umstellen: Chain für Chain, mit je einer eigenen Safe-Transaktion. Außerdem beschreibt sie, wie die Owner den Auto-Umtausch (im Leitfaden „sweep") auf einer Chain anhalten oder ganz aussteigen; der Safe bleibt dabei an derselben Adresse.
Der Leitfaden unten steht auf Englisch, weil wir ihn unverändert aus dem Repository der SDKs übernehmen.
Migration and exit
How a Safe moves to a new version of the contracts, and how its owners stop the sweep or leave. Index:
README.md. Related: running.md,
status.md, docs/advisories.md, SECURITY.md.
Why a fix is a new version
A deployed contract has no admin, pause or upgrade key. Its code cannot be changed or stopped, and it gives no one, the company included, a way to reach into a Safe that uses it. A configuration or order already signed under a version stays valid on chain whatever later versions do. So a fix to a contract is a new version at a new address, and an advisory says what the owners of an affected Safe do (docs/advisories.md). An SDK is not changed after it is published either: a flaw in it is fixed by a new release.
The status of a contract version is a field of its release record: current, superseded,
retired or vulnerable (docs/release-record.md, "The statuses"). The advisory, the release record of the affected version, the release record of the replacement and the release notes of the SDKs name the replacement. The SDK does not tell an integrator's users that a version is
vulnerable; the integrator follows the advisories and the statuses, re-pins its SDK, and tells its users (docs/cra/risk-assessment.md, "What an integrator's own file takes over"). A replacement is checked against a tag and a release record in this repository before it is used (SECURITY.md, "Verify a replacement version").
A later version gives new Safes a new address
A later version with another setup helper gives new Safes a new address, because the address of a Safe follows from the helper, the router and the factory of the version (SETUP-REQ-015).
computeSafeAddress computes it under the version of the chain's record. Existing Safes do not change address: they migrate per chain and keep theirs. The fork test is
test_ASafeBornFromVersionTwosHelperIsAnotherAddressWithVersionTwosModules.
Move a Safe to the new version
Versions never read each other, and a Safe has the modules of one version enabled at a time. A move is the owners' own transaction on each chain. There is no one-signature migration, because one signature must not install a module on all of a Safe's chains at once.
buildMigration reads, on each chain where the Safe is deployed, which version's modules are enabled, and returns one atomic Safe transaction for that chain. It removes the old version's conditional orders from ComposableCoW, disables the old version's modules, enables the new version's and, where the router changes, makes the new router the fallback handler. If one call fails the whole transaction fails, so no chain is left with two versions or none. The destination is the release the SDK serves, or the one named by
toVersion. A request for two versions at once is refused (two-versions), a Safe that already has the modules of two versions is refused (two-versions-modules), and a
retired or vulnerable release cannot be moved to (version-unavailable).
const migration = await sdk.buildMigration({ safe, toVersion, chains, validUntil });for (const step of migration.steps) { // the owners of step.chainId sign step.walletTypedData; each chain is its own transaction const exec = await sdk.buildSafeTransactionExecution({ step, signatures: signaturesOf(step) });}
final migration = await sdk.buildMigration( MigrationInput(safe: safe, toVersion: [toVersion], chains: chainIds),);for (final step in migration.steps) { final exec = await sdk.buildSafeTransactionExecution( SafeExecutionInput(step: step, signatures: signaturesOf(step)), );}
The build also returns:
-
skipped: a chain that gets no transaction, with the reason:undeployed,already-on-versionorno-record-of-version. -
warnings:versions-differwhen the chains end on different versions (a chain left out, or without a record of the release). -
a note on each step,
allowances-not-revoked: the swap leaves the allowances that the old version's sweeps gave to CoW's vault relayer. The owners may revoke them in a transaction of their own; the advisory says whether that matters for the flaw at hand. -
configuration: the fresh message of the new release, withseqone above the highest the store holds across the chains the migration reads, carrying what the Safe has stored (the target, the integrator's entry and each chain's row), except that a row that is on names the new release's reviewed oracle in place of the stored one, with a notice (oracle-replaced, the linewarn.oracle-replaced) that the price source changes with the version and the sweep keeps running; a row that is off is carried untouched, and a row whose oracle is the reviewed one already has no notice, in the domain of the release's own record. The refusal list gates it as it gates a messagebuildConfigurationbuilds: a stored target, or a token of a stored oracle, that the list names gives no message:configurationis notavailableand itsreasonis the code of the refusal (annex-asset-refusedand the other two), while the swap steps are built all the same, so the owners can still move off the old version. What it carries over that is not the reviewed one, or not the SDK's default, is named inbuild.warnings:oracle-not-reviewed,token-not-reviewedandintegrator-entry(an integrator's fee that is not the one the SDK is configured with). It isavailableunless the list refuses what is stored (above), nothing is stored (nothing-stored: build the first configuration withbuildConfiguration) or no chain gets a transaction (no-migration).
The end of the window and the bridge choice in the fresh message. The fresh message needs a
validUntil (the input is required: what the Safe has stored is the end of an earlier window, and the owners renew it with this message; later than now and within the store's longest window ahead, which the store checks). The bridge choice,
sendStablecoinToTargetChain, is carried over from what the Safe has stored, as the target and the rows are: it is a choice the owners already signed. This is sound while only one store ABI exists. Condition: when a second store ABI exists, an older store may have no such field, and the bridge choice becomes a required input of
buildMigration, as it is of buildConfiguration, so that no choice is ever assumed for the owners. (This is the reading adopted in the review of the pull request that added the field; it can be overturned.)
After the swap, the owners read the fresh message with describeConfiguration, sign it, and
combineConfigurationSignatures and buildApply turn it into the apply
that follows, on each chain whose seq lags (configuration.md,
running.md). A chain left out stays on the old version. The same shape moves a Safe back to an earlier release, and a swap whose last call fails reverts with that call's own error and changes nothing (test_ASwapWhoseLastCallFailsRevertsWithThatCallsOwnErrorAndChangesNothing).
Re-enable the modules
When the owners disabled the release's modules, buildMigration builds a re-enable
step instead: it enables the modules again, and the fresh message lets the owners see what resumes. Where nothing was ever stored (status
says bare), the step is the same and the fresh message is not available (nothing-stored): after the step is sent, build the first configuration with
buildConfiguration and carry on as in setup.md. The configuration stored while the modules were off applies again when they are enabled (test_DisablingTheModulesStopsEveryOrderAndTheStoredConfigurationResumesOnReEnable).
Stopping on a chain, and leaving
The owners can stop the sweep on a chain, alone and at any time:
-
A newer message with the chain off. Build a message with the chain's row off, or with no row for it (a chain a message does not list is off), sign it, and apply it. A message with every row off stops the sweep everywhere:
buildConfigurationwithrows: []builds it. Nothing is sold or sent until a newer message turns a chain on (test_AMessageWithEveryRowOffAndAMessageWithNoRowTurnTheChainOff). - A Safe transaction that disables the modules on that chain, from the owners' own wallet. The SDK builds no such transaction outside a migration.
The second way is also the way out on a chain a phished message left behind: the store refuses a seq
more than 1,000 above the one it holds (DEC-030 point 2; the disclosure line scope.seq-lock; the cap is
MAX_SEQ_JUMP in packages/sdk-ts/src/configuration.ts), so there a message within 1,000 of its number goes first and the owners' newer one after it.
What stopping does not do: a transfer that has already started depends on Circle to complete it, and the USDC is not refunded (recovery.md); tokens and USDC stay in the Safe, which stays the owners' Safe at the same address, with the router as its fallback handler. The sweep stops, the Safe does not close. An owner who does not move to a new version keeps the old version as it was released, flaw included; the company does not act on an owner's Safe and cannot.