Optimism 백서

Optimism

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 50쪽

e the new shared instance with the flags below. | Flag (env var) | Value | | - | - | | `--game-factory-address` (`OP_CHALLENGER_GAME_FACTORY_ADDRESS`) | The new shared `<DGF>` (capture from chain A's portal after [Execute the Migration](#execute-the-migration)) | | `--superroot-rpc` (`OP_CHALLENGER_SUPERNODE_RPC`) | `$SUPERNODE_RPC` | | `--l2-eth-rpc` (`OP_CHALLENGER_L2_ETH_RPC`) | `<chainA-EL>,<chainB-EL>` (comma-separated) | | `--game-types` (`OP_CHALLENGER_GAME_TYPES`) | `super-cannon-kona`. Do not add `super-permissioned`; the simplified `SUPER_PERMISSIONED` game does not require `op-challenger` to post claims. `op-challenger` is still required by permissioned only networks and will automatically update the `AnchorStateRegistry` as games are finalized. | | `--network` (`OP_CHALLENGER_NETWORK`) | `<chainA-network>,<chainB-network>` (the registry chain names; the challenger loads the depset from `superchain-registry` the same way `op-supernode` does) | | `--cannon-kona-prestates-url` (`OP_CHALLENGER_CANNON_KONA_PRESTATES_URL`) | The prestate server URL validated in the preconditions | If either chain is not in `superchain-registry`, omit `--network` and instead pass each chain's rollup config and L2 genesis as comma-separated paths via `--rollup-config` (`OP_CHALLENGER_ROLLUP_CONFIG`) and `--l2-genesis` (`OP_CHALLENGER_L2_GENESIS`), plus the shared depset via `--depset-config` (`OP_CHALLENGER_DEPSET_CONFIG`). The shared instance's `--game-factory-address` is the new shared factory, which only exists once `migrate` has been broadcast. Stage the deployment now with every other flag set; the address is filled in and the process is started in [Start the Shared op-challenger and op-dispute-mon](#start-the-shared-op-challenger-and-op-dispute-mon) after the migration is verified on-chain. Keep the per-chain `op-challenger` instances running with the namespaced RPC configuration for the duration of the drain window. ### Stand Up a Shared op-dispute-mon `op-dispute-mon` is also single-factory per process. Run a third instance pointed at the new shared factory in addition to the two per-chain instances. | Flag (env var) | Value | | - | - | | `--game-factory-address` (`OP_DISPUTE_MON_GAME_FACTORY_ADDRESS`) | The new shared `<DGF>` | | `--superroot-rpc` (`OP_DISPUTE_MON_SUPERNODE_RPC`) | `$SUPERNODE_RPC` or a comma-separated list of high-availability root endpoints for the same dependency set | | `--l1-eth-rpc` (`OP_DISPUTE_MON_L1_ETH_RPC`) | unchanged | As with the shared `op-challenger`, stage the deployment now with every flag except `--game-factory-address`; the address is filled in and the process is started in [Start the Shared op-challenger and op-dispute-mon](#start-the-shared-op-challenger-and-op-dispute-mon) after the migration is verified on-chain. Keep both per-chain `op-dispute-mon` instances running with the namespaced RPC configuration so they continue to track in-flight pre-migration games to resolution. ### Leave Other op-proposer Settings Unchanged for Now After switching the per-chain `op-proposer` RPC endpoints above, leave their other settings unchanged until [Execute the Migration](#execute-the-migration). Stop both per-chain proposers at cutover and replace them with a single shared one; see [Cut Over to a Single Shared op-proposer](#cut-over-to-a-single-shared-op-proposer). ## Generate the Starting Anchor Super Root The new shared `AnchorStateRegistry` is initialized with a starting anchor super root. Compute the value from the supernode using `superroot_atTimestamp`. Pick the supernode's current finalized timestamp (or any recent finalized timestamp), then ask the supernode for the super root at that timestamp: ```bash theme={null} # .finalized_timestamp is a JSON number (decimal unix seconds). TS=$(cast rpc supernode_syncStatus --rpc-url $SUPERNODE_RPC | jq -r '.finalized_timestamp') # superroot_atTimestamp expects a hex-encoded JSON string (hexutil.Uint64); cast 2h handles the conversion. cast rpc superroot_atTimestamp "$(cast 2h $TS)" --rpc-url $SUPERNODE_RPC | jq -r '.data.super_root' echo "timestamp=$TS" ``` Capture two values: * `super_root` (a `bytes32` hash from `.data.super_root`)—passed as `Proposal.root` in `startingAnchorRoot`. * `timestamp` (the uint64 you passed in)—passed as `Proposal.l2SequenceNumber`. For super games this field is the timestamp itself, not a block number. **Get a second person to recompute these values before anyone signs.** Nothing on-chain can tell a correct anchor from a wrong one. `migrate` only rejects a zero `startingAnchorRoot` or a zero `absolutePrestate`. A super root taken at the wrong timestamp passes both checks and becomes the starting point for every super-root game on both chains. Someone other than the task author should: * Ask a separately run `op-supernode` for the super root at the same `timestamp`. It must derive the same two chains. * Look up the `SUPER_CANNON_KONA` prestate in `standard-prestates.toml` for this OPCM release. * Compare both results with the values in the task's `config.toml`. ## Build the superchain-ops Task Author a new task directory under `superchain-ops/src/tasks/<network>/<NNN-name>/` using the `OPCMMigrateInterop` template, which wraps `OPContractsManagerMigrator.migrate(MigrateInput)` and runs `OPContractsManagerMigrationValidator` over the resulting state. ### Configure config.toml ```toml theme={null} l2chains = [ {name = "<chainA name>", chainId = <chainA id>}, {name = "<chainB name>", chainId = <chainB id>}, ] templateName = "OPCMMigrateInterop" [addresses] OPCM = "0x<OPCM address with OPTIMISM_PORTAL_INTEROP enabled>" # One stanza per chain, both required. [[migrateChains]] chainId = <chainA id> systemConfigProxy = "0x<SystemConfig_chainA>" [[migrateChains]] chainId = <chainB id> systemConfigProxy = "0x<SystemConfig_chainB>" # Starting anchor for the new shared AnchorStateRegistry, computed in the previous step. [startingAnchorRoot] root = "0x<super root hash>" l2SequenceNumber = <timestamp> # 9 = SUPER_CANNON_KONA. Required because both chains run permissionless fault proofs today. startingRespectedGameType = 9 # Both super game types must be registered. The migration validator requires it. # The template assembles the on-chain DisputeGameConfig.gameArgs bytes from these # fields: abi.encode(absolutePrestate) for game type 9, and # abi.encode(proposer) for game type 5. [[disputeGameConfigs]] gameType = 9 # SUPER_CANNON_KONA enabled = true initBond = 80000000000000000 # match the value gathered in the inputs absolutePrestate = "0x<super-cannon-kona prestate>" [[disputeGameConfigs]] gameType = 5 # SUPER_PERMISSIONED enabled = true initBond = 0 # SUPER_PERMISSIONED does not charge init bonds proposer = "0x<privileged proposer>" expectedValidationErrors = "" # fill in after the dry run if any structurally expected codes appear ``` ### Capture expectedValidationErrors Run the task in simulation mode against an L1 fork from inside the task directory: ```bash theme={null} cd superchain-ops/src/tasks/<network>/<NNN-name> just simulate ``` The validator only proves that the result matches the expectations. Take each chain's legacy addresses from the pre-migration `op-fetcher` files you saved in [Gather the Required Inputs](#gather-the-required-inputs). Take the expected shared `DelayedWETH` from chain A's `SystemConfig.delayedWETH()` before migrating. The shared lockbox, factory, and `AnchorStateRegistry` are deployed with CREATE2 using a salt that includes the execution block's timestamp, so compute their addresses from those inputs rather than reading them from the portals after the simulated migration. If you read them back instead, the validator compares the result with itself and always passes. The validator behind `OPContractsManagerMigrationValidator` returns a comma-separated string of error codes when something is structurally wrong. The default expectation is no errors—`expectedValidationErrors = ""` and a clean simulation. The codes you may see fall into the families below. Resolve every code rather than copy-pasting it into `expectedValidationErrors`; a code added to that field must have an inline TOML comment explaining why it is structurally expected for this migration. | Code | Meaning | | - | - | | `MIG-DGF-10` | `SUPER_PERMISSIONED` is not registered on the shared factory. | | `MIG-DGF-20` | `SUPER_CANNON_KONA` is not registered on the shared factory. | | `MIG-DGF-30` | `CANNON` is still registered on the shared factory. | | `MIG-DGF-40` | `PERMISSIONED_CANNON` is still registered on the shared factory. | | `MIG-DGF-50` | `CANNON_KONA` is still registered on the shared factory. | | `MIG-SDGF-10` to `-40` | Shared factory version, proxy implementation pointer, owner, or `ProxyAdmin` does not match the expected configuration. | | `MIG-SASR-RGT` | Shared `AnchorStateRegistry.respectedGameType()` is not a super game type. | | `MIG-SLOCKBOX-10` to `-30` | Shared lockbox version, proxy implementation pointer, or `ProxyAdmin` mismatch. | | `MIG-CHAIN-EMPTY` | The validator received an empty chain list. | | `MIG-LOCKBOX-MISSING` | Chain A's portal does not point at the shared lockbox. | | `MIG-CHAIN-{i}-10` | Chain `i`'s portal does not reference the shared `AnchorStateRegistry`. | | `MIG-CHAIN-{i}-20` | Chain `i`'s per-chain factory still has `CANNON` registered. | | `MIG-CHAIN-{i}-30` | Chain `i`'s per-chain factory still has `PERMISSIONED_CANNON` registered. | | `MIG-CHAIN-{i}-40` | Chain `i`'s per-chain factory still has `CANNON_KONA` registered. | | `MIG-CHAIN-{i}-60` | Chain `i`'s per-chain factory still has `SUPER_PERMISSIONED` registered. | | `MIG-CHAIN-{i}-70` | Chain `i`'s per-chain factory still has `SUPER_CANNON_KONA` registered. | | `MIG-CHAIN-{i}-80` | Shared lockbox does not list chain `i`'s portal as authorized. | | `MIG-CHAIN-{i}-90` | Chain `i`'s portal `ethLockbox` does not equal the shared lockbox. | | `MIG-CHAIN-{i}-100` | Chain `i`'s `SystemConfig` does not have `Features.INTEROP` enabled. | | `MIG-CHAIN-{i}-110` | Chain `i`'s `SystemConfig` does not have `Features.ETH_LOCKBOX` enabled. | | `MIG-SPDG-*` or `MIG-SCKDG-*` | Super game drill-down. The first prefix covers `SUPER_PERMISSIONED` and the second covers `SUPER_CANNON_KONA`. `MIG-SPDG-*` subcodes cover the simplified permissioned game's args, proposer, and `AnchorStateRegistry`; `MIG-SCKDG-*` covers the fault-proof game checks. | ## Execute the Migration <Warning>Verify that the user announcement has gone out and at least seven days have elapsed since the announcement before broadcasting. Withdrawals proven against either chain's old games will not finalize against the new shared registry; users must re-prove or finalize ahead of cutover.</Warning> 1. Stop both per-chain `op-proposer` processes. Once the migration broadcasts, the per-chain factories no longer have `SUPER_CANNON_KONA` registered, so `DisputeGameFactory.create` reverts. Stopping the proposers first prevents wasted gas. 2. Leave both per-chain `op-challenger` and `op-dispute-mon` instances running. They continue to defend and observe in-flight pre-migration games on the per-chain factories. 3. Sign and broadcast the task using your team's standard `superchain-ops` signing workflow. 4. Wait for the L1 transaction to confirm. The on-chain effect: * `OPCM` deploys and initializes new `ETHLockbox`, `DisputeGameFactory`, and `AnchorStateRegistry` proxies. The new `AnchorStateRegistry` binds to the new factory and sets `retirementTimestamp` to `block.timestamp` at initialization. * `OPCM` calls `OptimismPortal2.migrateToSharedDisputeGame` on each chain to repoint the portal at the new lockbox and the new `AnchorStateRegistry`. It also authorizes each chain's existing portal on the shared lockbox, authorizes each chain's existing lockbox to forward liquidity, and migrates that liquidity into the shared lockbox. * `OPCM` zeroes every implementation pointer on each chain's existing per-chain `DisputeGameFactory`. Already-deployed game proxies on those factories are unaffected and continue to resolve. Capture the new shared addresses by re-running op-fetcher against each chain. After migration, `optimismPortal().anchorStateRegistry()`, `disputeGameFactory()`, and `ethLockbox()` all return the new shared proxies, so the same op-fetcher inputs you used in [Gather the Required Inputs](#gather-the-required-inputs) now resolve the post-migration addresses. Write the post-migration output to new files (do not overwrite the pre-migration ones — you still need them to reference the per-chain `<oldASR>` and `<oldDGF>` during the drain). ```bash theme={null} op-fetcher fetch \ --l1-rpc-url $L1_RPC \ --system-config <SystemConfig_chainA> \ --l1-standard-bridge <L1StandardBridge_chainA> \ --output-file <chainA>-postmigrate.json op-fetcher fetch \ --l1-rpc-url $L1_RPC \ --system-config <SystemConfig_chainB> \ --l1-standard-bridge <L1StandardBridge_chainB> \ --output-file <chainB>-postmigrate.json ``` Capture the shared addresses from chain A's post-migration output: ```bash theme={null} SHARED_ASR=$(jq -r '.addresses.AnchorStateRegistryProxy' <chainA>-postmigrate.json) SHARED_DGF=$(jq -r '.addresses.DisputeGameFactoryProxy' <chainA>-postmigrate.json) SHARED_LOCKBOX=$(jq -r '.addresses.EthLockboxProxy' <chainA>-postmigrate.json) ``` Confirm chain B's portal resolves to the same shared proxies: ```bash theme={null} diff <(jq -r '.addresses.AnchorStateRegistryProxy, .addresses.DisputeGameFactoryProxy, .addresses.EthLockboxProxy' <chainA>-postmigrate.json) \ <(jq -r '.addresses.AnchorStateRegistryProxy, .addresses.DisputeGameFactoryProxy, .addresses.EthLockboxProxy' <chainB>-postmigrate.json) # Expect: no output (identical). ``` ## Verify the Migration On-Chain Run every check below before you start the new `op-proposer`. If any check fails, stop and escalate via your standard incident-response channel; recovery from a half-cut state with a misbehaving proposer is materially harder than recovery from one that is paused. ### Verify the Shared Registry and Factory ```bash theme={null} # Respected game type on the new ASR cast call $SHARED_ASR 'respectedGameType()(uint32)' --rpc-url $L1_RPC # Expect: 9 (SUPER_CANNON_KONA) # Anchor root and timestamp on the new ASR cast call $SHARED_ASR 'getAnchorRoot()(bytes32,uint256)' --rpc-url $L1_RPC # Expect: (<super root hash>, <timestamp>) from "Generate the Starting Anchor Super Root" # Retirement timestamp on the new ASR cast call $SHARED_ASR 'retirementTimestamp()(uint64)' --rpc-url $L1_RPC # Expect: equal to the migration block's timestamp # Game implementations registered on the shared factory cast call $SHARED_DGF 'gameImpls(uint32)(address)' 5 --rpc-url $L1_RPC # SUPER_PERMISSIONED cast call $SHARED_DGF 'gameImpls(uint32)(address)' 9 --rpc-url $L1_RPC # SUPER_CANNON_KONA # Expect both: non-zero # Init bonds match each game type's configuration cast call $SHARED_DGF 'initBonds(uint32)(uint256)' 5 --rpc-url $L1_RPC # Expect: 0 cast call $SHARED_DGF 'initBonds(uint32)(uint256)' 9 --rpc-url $L1_RPC # Expect: 80000000000000000 # No legacy implementations registered on the shared factory cast call $SHARED_DGF 'gameImpls(uint32)(address)' 0 --rpc-url $L1_RPC # CANNON cast call $SHARED_DGF 'gameImpls(uint32)(address)' 1 --rpc-url $L1_RPC # PERMISSIONED_CANNON cast call $SHARED_DGF 'gameImpls(uint32)(address)' 8 --rpc-url $L1_RPC # CANNON_KONA # Expect each: 0x0000000000000000000000000000000000000000 ``` ### Confirm Per-Chain Factories Are Cleared ```bash theme={null} for OLD_DGF in <oldDGF_chainA> <oldDGF_chainB>; do for GT in 0 1 5 8 9; do echo "$OLD_DGF gameImpls($GT)= $(cast call $OLD_DGF 'gameImpls(uint32)(address)' $GT --rpc-url $L1_RPC)" done done # Expect every entry: 0x0000000000000000000000000000000000000000 ``` ### Confirm the Shared Lockbox Is Authorized ```bash theme={null} cast call $SHARED_LOCKBOX 'authorizedPortals(address)(bool)' <OptimismPortal2_chainA> --rpc-url $L1_RPC cast call $SHARED_LOCKBOX 'authorizedPortals(address)(bool)' <OptimismPortal2_chainB> --rpc-url $L1_RPC # Expect both: true ``` ## Start the Shared op-challenger and op-dispute-mon Both shared instances were staged in [Stage the Off-Chain Configuration](#stage-the-off-chain-configuration) with every flag except `--game-factory-address` set. Now that `$SHARED_DGF` is known and the migration is verified on-chain, fill in the address on both and start the processes as soon as practical. `SUPER_CANNON_KONA` is a permissionless game type, so the moment the shared factory is live anyone can create a game against it — not just `op-proposer`. Once a game is created, its clock runs and it resolves whether or not anyone challenges. `op-challenger` must be running to defend invalid claims before their game clocks expire, and `op-dispute-mon` must be running to observe and alert. This is independent of [Cut Over to a Single Shared op-proposer](#cut-over-to-a-single-shared-op-proposer) below — complete it first regardless of when the proposer cutover happens. 1. **Set the shared `op-challenger`'s `--game-factory-address` (`OP_CHALLENGER_GAME_FACTORY_ADDRESS`) to `$SHARED_DGF` and start the process.** Confirm the startup log lists `super-cannon-kona` as a registered trace type and shows no errors connecting to the shared supernode root RPC endpoint. 2. **Set the shared `op-dispute-mon`'s `--game-factory-address` (`OP_DISPUTE_MON_GAME_FACTORY_ADDRESS`) to `$SHARED_DGF` and start the process.** Confirm the supernode root connection is healthy and the metrics endpoint is serving. Healthy startup logs and a quiet error stream are the bar for proceeding. Both instances discover existing games on startup, so it does not matter whether a super-root game already exists in the shared factory by the time they come up. ## Cut Over to a Single Shared op-proposer Start one new `op-proposer` process for the shared factory. A single proposer replaces both per-chain ones because the supernode produces one super root per timestamp covering both chains. Configure the new instance with the flags below. | Flag (env var) | Value | | - | - | | `--game-factory-address` (`OP_PROPOSER_GAME_FACTORY_ADDRESS`) | the new shared `<DGF>` | | `--superroot-rpcs` (`OP_PROPOSER_SUPERROOT_RPCS`) | `$SUPERNODE_RPC` or high-availability root endpoints for the same dependency set | | `--game-type` (`OP_PROPOSER_GAME_TYPE`) | `9` (SUPER\_CANNON\_KONA) | | `--l1-eth-rpc` (`OP_PROPOSER_L1_ETH_RPC`) | as for the existing proposers | | `--proposal-interval`, `--poll-interval`, `--mnemonic` or `--private-key` | as for the existing proposers | After start-up, verify: * The logs show the proposer polling the supernode and writing to the shared factory. * Within one `--proposal-interval`, the proposer submits a new game on the shared factory. Inspect it: ```bash theme={null} COUNT=$(cast call $SHARED_DGF 'gameCount()(uint256)' --rpc-url $L1_RPC) echo "gameCount=$COUNT" read -r GAME_TYPE CREATED_AT GAME_PROXY < <(cast call $SHARED_DGF 'gameAtIndex(uint256)(uint32,uint64,address)' $((COUNT-1)) --rpc-url $L1_RPC) # Expect: GAME_TYPE=9 and GAME_PROXY non-zero. echo "gameType=$GAME_TYPE createdAt=$CREATED_AT gameProxy=$GAME_PROXY" cast call $GAME_PROXY 'rootClaim()(bytes32)' --rpc-url $L1_RPC cast call $GAME_PROXY 'l2SequenceNumber()(uint256)' --rpc-url $L1_RPC ``` * Recompute the super root for the proposed timestamp and confirm it matches the proposal: ```bash theme={null} cast rpc superroot_atTimestamp "$(cast 2h <l2SequenceNumber from above>)" \ --rpc-url $SUPERNODE_RPC | jq -r '.data.super_root' # Expect: equals rootClaim from above. ``` Once the proposer is stable, do not stop the per-chain `op-challenger` or `op-dispute-mon` instances—they are still needed for the drain window described next. ## Drain Pre-Migration Games and Reclaim Bonds The migration cleared the per-chain factories' implementation pointers so no new pre-migrati
프로젝트로 돌아가기