Optimism 백서

Optimism

원문

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

tputOracleChallenger": "0xcA4571b1ecBeC86Ea2E660d242c1c29FcB55Dc72", - add the below default values, if you expect different values for your chain reach out to OP Labs support for clarification before proceeding "useFaultProofs": true, "faultGameMaxDepth": 73, "faultGameSplitDepth": 30, "faultGameWithdrawalDelay": 604800, "faultGameMaxClockDuration": 302400, "faultGameClockExtension": 10800, - You can update this to the latest absolute prestate hash in the superchain-registry; however, the permissioned Fault Proof System doesn't use this. This comes into play when you upgrade your chain to the permissionless Fault Proof System. "faultGameAbsolutePrestate": "0x03925193e3e89f87835bbdf3a813f60b2aa818a36bbe71cd5d8fd7e79f52bafe", - add the below default values, if you expect different values for your chain, reach out to OP Labs support for clarification before proceeding "faultGameGenesisBlock": 0, "faultGameGenesisOutputRoot": "0xdead000000000000000000000000000000000000000000000000000000000000", "respectedGameType": 1, "preimageOracleMinProposalSize": 126000, "preimageOracleChallengePeriod": 86400, "proofMaturityDelaySeconds": 604800, "disputeGameFinalityDelaySeconds": 302400, "enableGovernance": false, "systemConfigStartBlock": 0, "requiredProtocolVersion": "0x0000000000000000000000000000000000000003000000010000000000000000", "recommendedProtocolVersion": "0x0000000000000000000000000000000000000003000000010000000000000000", - make sure to add the below if not present already, these values won't matter but the script needs them to be present in the config "sequencerFeeVaultWithdrawalNetwork": 0, "baseFeeVaultWithdrawalNetwork": 0, "l1FeeVaultWithdrawalNetwork": 0, "baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000", "l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000", "sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000" } ``` Make sure that important addresses (like the `ProxyAdmin`, `ProxyAdminOwner`, all L1 addresses, `L2OO`) are actually up to date by cross checking the superchain-registry and on-chain (you can do this easily with [`op-fetcher`](https://github.com/ethereum-optimism/optimism/tree/develop/op-fetcher), especially for the `deployments.json`. ## Step-by-step upgrade process ### 1. Create your working directory Create a working directory: ```shell theme={null} mkdir upgrade-dir cd upgrade-dir ``` And then create an outputs directory: ```shell theme={null} mkdir outputs ``` ### 2. Copy config files Copy your `deployments.json` and `deploy-config.json` into the working directory ### 3. Configure and deploy environment Create and update an `.env` file with the required information: ```json theme={null} ############################################## # ↓ Required ↓ # ############################################## # Can be "mainnet" or "sepolia" NETWORK= # Etherscan API key used to verify contract bytecode ETHERSCAN_API_KEY= # RPC URL for the L1 network that matches $NETWORK ETH_RPC_URL= # Private key used to deploy the new contracts for this upgrade PRIVATE_KEY= # Base fee scalar for the SystemConfig BASE_FEE_SCALAR= # Blob base fee scalar for the SystemConfig BLOB_BASE_FEE_SCALAR= # Check if required files and folders exist if [ ! -f "./deploy_config.json" ]; then echo "Error: deploy_config.json not found" fi if [ ! -f "./deployments.json" ]; then echo "Error: deployments.json not found" fi if [ ! -d "./outputs" ]; then echo "Error: outputs folder not found" fi ``` ### 4. Run the deployment process Run the deployment process with the following command: ```docker theme={null} docker run -t --env-file .env -v ./deploy_config.json:/deploy_config.json -v ./deployments.json:/deployments.json -v ./outputs:/outputs kfoplabs/upgrade-v1.3.0-v1.8.0-permissioned /deploy_config.json /deployments.json ``` The source code for the `kfoplabs/upgrade-v1.3.0-v1.8.0-permissioned` image is available in the [`perm/op-contracts/v1.8.0` branch of the Optimism monorepo](https://github.com/ethereum-optimism/optimism/tree/perm/op-contracts/v1.8.0). If you need to fork or customize the upgrade script (e.g. to support L3s), start from that branch. ### 5. Verify outputs The deployment should output four files: * `deploy.log` is a log of the deployment process * `deployments.json` includes the newly deployed contract addresses * `bundle.json` is the safe transaction bundle * `transactions.json` is the summary of the executed deployment transactions * `standard-addresses.json` is the addresses of `SystemConfigImpl`, `OptimismPortal2Impl`, `L1CrossDomainMessengerImpl`, `L1StandardBridgeImpl`, `L1ERC721BridgeImpl`, and `OptimismMintableERC20FactoryImpl` * `validation.txt` is used for Tenderly state diff validation. Some info needed for the superchain-ops task might be missing from this file, and will instead be generated during the Tenderly simulation. ### 6. Verify outputs Now you have the calldata that can be executed onchain to perform the L1 contract upgrade. You should simulate this upgrade and make sure the changes are expected. You can reference the validation files of previously executed upgrade tasks in the [superchain-ops repo](https://github.com/ethereum-optimism/superchain-ops/blob/main/tasks/eth/022-holocene-fp-upgrade/NestedSignFromJson.s.sol) to see what the expected changes are. Once you're confident the state changes are expected, you can sign and execute the upgrade. ## Additional Resources * [superchain-ops Repository](https://github.com/ethereum-optimism/superchain-ops) * [Optimism Monorepo](https://github.com/ethereum-optimism/optimism) * [Upgrade script source code (`perm/op-contracts/v1.8.0` branch)](https://github.com/ethereum-optimism/optimism/tree/perm/op-contracts/v1.8.0) # Merging Two Chains Into a Shared Dispute Game Source: https://docs.optimism.io/chain-operators/tutorials/merge-shared-dispute-game Merge two pre-interop OP Stack chains into a shared DisputeGameFactory and AnchorStateRegistry with opcm.migrate, then cut over op-proposer, op-challenger, and op-dispute-mon to the shared factory. # Merging Two Chains Into a Shared Dispute Game <Warning>This guide depends on the interop feature, which is still in development. Do not follow it on production chains.</Warning> This runbook walks you through merging two existing OP Stack chains into a shared dispute game by calling `OPContractsManagerMigrator.migrate` (`opcm.migrate`). After migration, both chains share a newly deployed `DisputeGameFactory`, `AnchorStateRegistry`, and `ETHLockbox`. New proposals are super-root claims defended on the shared factory; the per-chain dispute game factories are emptied of implementations and exist only to let still-in-flight games resolve so their bonds can be reclaimed. By the end you will have one `op-proposer` proposing super-root claims to the shared factory against an `op-supernode` that derives both chains, one `op-challenger` defending super-root games on the shared factory, one `op-dispute-mon` watching it, and per-chain `op-challenger` and `op-dispute-mon` "drain" instances — each using that shared op-supernode's `/<chainID>/` endpoint — winding down the retired games on the old per-chain factories. <Warning>`opcm.migrate` is a one-way operation that invalidates every withdrawal proof submitted but not finalized on either chain. Affected users must re-prove against a new super-root game after migration. Announce the migration window to users at least seven days in advance—long enough for a withdrawal proven just before the announcement to mature past `PROOF_MATURITY_DELAY_SECONDS` and finalize.</Warning> If you instead want to swap a single chain's proof method from output roots to super roots without merging chains, follow [Upgrading a Chain From Output Roots to Super Roots](/chain-operators/tutorials/upgrade-chain-to-super-roots). This runbook is for two chains that are merging into a shared interop set. ## Before You Begin <SuperchainOpsPrereqs /> This runbook assumes: * Exactly two chains, referred to below as `chainA` and `chainB`, are being merged. * Neither chain has activated interop yet. * Both chains run permissionless fault proofs with `SUPER_CANNON_KONA` (game type `9`) as the respected game type today. * The per-chain `op-proposer`, `op-challenger`, and `op-dispute-mon` instances stood up by the [single-chain super-roots upgrade](/chain-operators/tutorials/upgrade-chain-to-super-roots) are running for both chains. The per-chain challengers and monitors keep running through migration cutover and the subsequent drain window. * A separate `op-supernode` instance is in sync and derives **exactly `chainA` and `chainB`** (and no other chains) in the same process. This is the supernode the new shared `op-proposer`, `op-challenger`, and `op-dispute-mon` point at after migration; it must not double as a multi-chain supernode for any other chain or interop cluster. * Both chains have already been upgraded to a release that exposes `OPContractsManagerMigrator.migrate` and have `Features.ETH_LOCKBOX` enabled on their `SystemConfig`. `ETH_LOCKBOX` is turned on automatically by `OPContractsManagerV2.upgrade()`; that pre-upgrade is a prerequisite for this runbook. `Features.INTEROP` must still be **disabled** going in, `migrate()` enables it. ### Install Required Tooling The versions below are the ones the optimism repo's `mise.toml` pins; older versions of `cast` in particular may not parse the function-selector syntax used in this runbook. | Tool | Minimum version | | - | - | | `foundry` (`cast`, `forge`) | `1.8.3` | | `just` | `1.46.0` | | `jq` | `1.7.1` | | `go` | `1.26.5` | | `curl` | any | ### Gather the Required Inputs Collect everything below before you start. Replace `<chainA>` and `<chainB>` placeholders with the actual values for each chain. Anywhere this runbook says `<X>` it means a value you must capture. **Per-chain identity, addresses, and roles.** For each chain, open the entry under `superchain/configs/<network>/<chain-name>.toml` in `superchain-registry` and read `chain_id`, `addresses.SystemConfigProxy`, and `addresses.L1StandardBridgeProxy`. Pass those two proxies to [`op-fetcher`](https://github.com/ethereum-optimism/optimism/tree/develop/op-fetcher) to resolve the rest in a single L1 call, writing the JSON to a file you can reference later: ```bash theme={null} op-fetcher fetch \ --l1-rpc-url $L1_RPC \ --system-config <SystemConfigProxy> \ --l1-standard-bridge <L1StandardBridgeProxy> \ --output-file <chainX>.json ``` The portal-derived lookups return the chain's current `DisputeGameFactory`, `AnchorStateRegistry`, and `ETHLockbox` while migration has not yet run; after migration, the same selectors return the new shared addresses, so capture both chains' values now. Capture the following fields from each chain's JSON output: | Item | Source | | - | - | | L2 chain ID | `chain_id` in the chain's registry TOML | | `SystemConfig` proxy | `addresses.SystemConfigProxy` in the chain's registry TOML | | `L1StandardBridge` proxy | `addresses.L1StandardBridgeProxy` in the chain's registry TOML | | `OptimismPortal2` proxy | `addresses.OptimismPortalProxy` in `<chainX>.json` | | Existing `AnchorStateRegistry` proxy (`<oldASR_chainX>`) | `addresses.AnchorStateRegistryProxy` in `<chainX>.json` | | Existing `DisputeGameFactory` proxy (`<oldDGF_chainX>`) | `addresses.DisputeGameFactoryProxy` in `<chainX>.json` | | Existing `ETHLockbox` proxy | `addresses.EthLockboxProxy` in `<chainX>.json` | | `SuperchainConfig` proxy | `addresses.SuperchainConfigProxy` in `<chainX>.json` | | `ProxyAdmin` owner Safe | `roles.OpChainProxyAdminOwner` in `<chainX>.json` | `migrate` reads each chain's `DelayedWETH` directly from `SystemConfig.delayedWETH()` at execution time, so there is nothing to capture for it here. **Init bonds.** The migration registers two super game types on the new shared factory. `SUPER_PERMISSIONED` (game type `5`) is bondless and must use an `initBond` of `0`. `SUPER_CANNON_KONA` (game type `9`) uses `0.08 ether` (`80000000000000000` wei). **Release artifacts and infrastructure.** | Item | Source | | - | - | | `OPCM` address for the migrate-feature container | The same OPCM the chains ran for the prerequisite `OPCMv2.upgrade()`. This run is what enables `Features.ETH_LOCKBOX` on each `SystemConfig`. `Features.INTEROP` is not set by the upgrade; `migrate()` sets it. The container must have `OPTIMISM_PORTAL_INTEROP` set in `devFeatureBitmap`, which gates `migrate()` itself; without it `migrate()` reverts with `OPContractsManagerMigrator_InteropNotEnabled`. | | `SUPER_CANNON_KONA` absolute prestate hash | `validation/standard/standard-prestates.toml` in `superchain-registry`. Use the entry with `type="cannon64-kona-interop"` for the OPCM release version. | | Prestate artifact URL | The `cannon-kona-prestates-url` server, with the kona-interop prestate uploaded ahead of the migration. | | Shared `op-supernode` RPC URL | Your infrastructure team. The instance must derive **exactly `chainA` and `chainB`** (and no other chains). The shared `op-proposer`, `op-challenger`, and `op-dispute-mon` for the merged factory all point at this same instance. The per-chain services will be pointed to chain-specific endpoints under this URL. | | Privileged `proposer` for `SUPER_PERMISSIONED` | The address authorized to post proposals to the permissioned super game. `op-proposer` is configured to sign with this key. | ### Verify the Preconditions Run every check below. Each one corresponds to an invariant the migrator enforces; resolve any failure before proceeding. * **Confirm the same `ProxyAdmin` owner across both chains.** `migrate` reverts with `OPContractsManagerMigrator_ProxyAdminOwnerMismatch` otherwise. Each chain's `ProxyAdmin` proxy may differ as long as the owner Safe is identical on both. ```bash theme={null} diff <(jq -r '.roles.OpChainProxyAdminOwner' <chainA>.json) <(jq -r '.roles.OpChainProxyAdminOwner' <chainB>.json) # Expect: no output (identical). ``` * **Confirm the same `SuperchainConfig` across both chains.** `migrate` reverts with `OPContractsManagerMigrator_SuperchainConfigMismatch` otherwise. ```bash theme={null} diff <(jq -r '.addresses.SuperchainConfigProxy' <chainA>.json) <(jq -r '.addresses.SuperchainConfigProxy' <chainB>.json) # Expect: no output (identical). ``` * **Confirm `Features.INTEROP` is disabled and `Features.ETH_LOCKBOX` is enabled on both chains.** `migrate()` is the only thing that sets `INTEROP` on L1, so a chain that already has it on is already in an interop set; `_validateChainSystemConfigs` reverts with `OPContractsManagerMigrator_ChainAlreadyMigrated` when INTEROP is already on, so **do not** enable `INTEROP` yourself via `SystemConfig.setFeature`, doing so permanently blocks the migration. `ETH_LOCKBOX` flips on automatically during the prerequisite `OPCMv2.upgrade()`; if either `ETH_LOCKBOX` check below returns `false`, run that prerequisite upgrade first. `Features` constants are short-string `bytes32` values, so feed them through `cast format-bytes32-string`. ```bash theme={null} for SC in <SystemConfig_chainA> <SystemConfig_chainB>; do for F in INTEROP ETH_LOCKBOX; do echo "$SC $F = $(cast call $SC 'isFeatureEnabled(bytes32)(bool)' "$(cast format-bytes32-string $F)" --rpc-url $L1_RPC)" done done # Expect: both INTEROP lines end in false, both ETH_LOCKBOX lines end in true. ``` * **Clear any scoped pause before the prerequisite upgrade.** `OPCMv2.upgrade()` turns on `ETH_LOCKBOX`, and `SystemConfig.setFeature` refuses to do that while the portal is under a scoped pause. Enabling the lockbox moves the pause check from the portal's address to the lockbox's address, so without that guard the chain would come out of the upgrade unpaused. If either portal is paused, the Guardian has to unpause it first. * **Confirm neither chain runs in Custom Gas Token mode.** `_migratePortal` reverts with `OPContractsManagerMigrator_CustomGasTokenNotSupported` for any CGT chain. ```bash theme={null} cast call <SystemConfig_chainA> 'isCustomGasToken()(bool)' --rpc-url $L1_RPC cast call <SystemConfig_chainB> 'isCustomGasToken()(bool)' --rpc-url $L1_RPC # Expect: both false. ``` * **Confirm the current respected game type on both chains is `SUPER_CANNON_KONA` (`9`).** ```bash theme={null} cast call <oldASR_chainA> 'respectedGameType()(uint32)' --rpc-url $L1_RPC cast call <oldASR_chainB> 'respectedGameType()(uint32)' --rpc-url $L1_RPC # Expect: 9 for both. ``` * **Confirm the shared supernode derives exactly the two merging chains.** Verify with your infrastructure team that the instance behind `$SUPERNODE_RPC` has `chainA` and `chainB` in its dependency set and **no** other chains. A supernode that also tracks an unrelated chain (or an interop cluster that includes one) computes super roots over that broader set, and those roots will not match what the shared `SUPER_CANNON_KONA` and `SUPER_PERMISSIONED` games verify. * **Confirm the shared supernode is in sync.** It must report a finalized L2 head within both chains' expected finality windows: ```bash theme={null} cast rpc supernode_syncStatus --rpc-url $SUPERNODE_RPC | jq -r '.finalized_timestamp' ``` If the supernode is materially behind either chain, postpone the migration. * **Confirm the prestate server serves the `SUPER_CANNON_KONA` prestate.** ```bash theme={null} curl -fI "$PRESTATE_URL/$SUPER_CANNON_KONA_PRESTATE.bin.gz" ``` * **Note the chain B `DelayedWETH` divergence.** `migrate` reuses chain A's `DelayedWETH` for the new shared super games and does not touch chain B's. After migration, chain B's `SystemConfig.delayedWETH()` still references chain B's old `DelayedWETH`, which is no longer attached to any super game. Future `OPCMv2.upgrade()` calls against chain B that read `SystemConfig.delayedWETH()` will therefore reference a different contract than the shared games use. Track this in your operational runbook so future upgrades do not surprise you. The bonds posted by chain B's still-in-flight pre-migration games continue to claim out of chain B's old `DelayedWETH`, so the divergence does not block the drain described in [Drain Pre-Migration Games and Reclaim Bonds](#drain-pre-migration-games-and-reclaim-bonds). ## Stage the Off-Chain Configuration Apply these changes before you submit the on-chain migration. The pre-migration `op-challenger` and `op-dispute-mon` instances per chain must keep running to defend and watch in-flight games on the per-chain factories until those games resolve. Add a third instance of each component for the shared factory. Stop both per-chain `op-proposer` instances at cutover time, in [Execute the Migration](#execute-the-migration). ### Point Per-Chain Services at the Shared op-supernode Before migration, point every existing per-chain service at its chain's RPC namespace on the shared op-supernode: | Service flag | chainA value | chainB value | | - | - | - | | `op-proposer --superroot-rpcs` | `$SUPERNODE_RPC/$CHAIN_A_CHAINID` | `$SUPERNODE_RPC/$CHAIN_B_CHAINID` | | `op-challenger --supernode-rpc` | `$SUPERNODE_RPC/$CHAIN_A_CHAINID` | `$SUPERNODE_RPC/$CHAIN_B_CHAINID` | | `op-dispute-mon --supernode-rpc` | `$SUPERNODE_RPC/$CHAIN_A_CHAINID` | `$SUPERNODE_RPC/$CHAIN_B_CHAINID` | Do not point these per-chain instances at `$SUPERNODE_RPC` without the chain ID suffix; the root endpoint returns a two-chain super root. Restart each service and confirm it connects successfully before continuing. This removes the operational dependency on separate single-chain op-node or op-supernode processes before interop activation. ### Stand Up a Shared op-challenger A single `op-challenger` process can only watch one `DisputeGameFactory`, so the existing per-chain instances cannot also cover the new shared factory. Run a third `op-challenger` instance dedicated to the shared factory in addition to the existing per-chain instances. Configur
프로젝트로 돌아가기