Optimism 백서

Optimism

원문

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

Ensure the proposal is from a block at or before the `safe` head: ```bash theme={null} cast block --rpc-url <OP_GETH_ENDPOINT> safe ``` 2. Get a valid output root (from op-node): ```bash theme={null} cast rpc --rpc-url <OP_NODE_ENDPOINT> optimism_outputAtBlock \ $(cast 2h <BLOCK_NUMBER>) | jq -r .outputRoot ``` 3. Create a test game: ```bash theme={null} ./op-challenger/bin/op-challenger create-game \ --l1-eth-rpc=<L1_RPC_ENDPOINT> \ --game-factory-address <DISPUTE_GAME_FACTORY_ADDR> \ --l2-block-num <BLOCK_NUMBER> \ --output-root <OUTPUT_ROOT> \ <SIGNER_OPTIONS> ``` 4. Verify: * `op-challenger` logs a message showing the game is in progress * `op-challenger` doesn't post a counter claim (as this is a valid proposal) * `dispute-mon` includes the new game with `status="agree_defender_ahead"` ### Test countering invalid claims Post an invalid counter claim to the valid proposal created above: ```bash theme={null} ./op-challenger/bin/op-challenger move \ --l1-eth-rpc <L1_RPC_ENDPOINT> \ --game-address <GAME_ADDR> \ --attack \ --parent-index 0 \ --claim 0x0000000000000000000000000000000000000000000000000000000000000000 \ <SIGNER_OPTIONS> ``` Verify that `op-challenger` posts a counter-claim to the invalid claim. You can view claims using: ```bash theme={null} ./op-challenger/bin/op-challenger list-claims \ --l1-eth-rpc <L1_RPC_ENDPOINT> \ --game-address <GAME_ADDR> ``` There should be 3 claims in the game after this test. ## Switch to permissionless proofs After completing all previous steps and verifying their successful operation, you need to update the `respectedGameType` in the `AnchorStateRegistry`. This requires execution through the appropriate privileged role (typically the Guardian). You have two main options for executing this step: ### Option 1: Execute using a multisig If your privileged role (such as the Guardian) is controlled by a multisig or DAO governance system, use the provided JSON payload (`input.json`): <Accordion title="Create an `input.json` file with the transaction to update the `respectedGameType`: "> ```json theme={null} { "chainId": "<YOUR_L1_CHAIN_ID>", "metadata": { "name": "Deputy Guardian - Enable Permissionless Dispute Game", "description": "This task updates the `respectedGameType` in the `AnchorStateRegistry` to `CANNON` (game type 0), enabling users to permissionlessly propose outputs as well as for anyone to participate in the dispute of these proposals. This action requires all in-progress withdrawals to be re-proven against a new `FaultDisputeGame` that was created after this update occurs." }, "transactions": [ { "metadata": { "name": "Update `respectedGameType` in the `AnchorStateRegistry`", "description": "Updates the `respectedGameType` to `CANNON` in the `AnchorStateRegistry`, enabling permissionless proposals and challenging." }, "to": "<ASR_ADDRESS>", "value": "0x0", "data": "0x7fc485040000000000000000000000000000000000000000000000000000000000000000", "contractMethod": { "type": "function", "name": "setRespectedGameType", "inputs": [ { "name": "_gameType", "type": "uint32" } ], "outputs": [], "stateMutability": "nonpayable" }, "contractInputsValues": { "_gameType": "0" } } ] } ``` </Accordion> * **Submit this JSON payload** through your interface (e.g., Safe transaction builder). * **Simulate** this transaction using Tenderly before execution to ensure the expected state changes: * The `respectedGameType` in the `AnchorStateRegistry` should change from `1` (PERMISSIONED) to `0` (CANNON). *** ### Option 2: Direct execution via `cast` (Forge CLI) Alternatively, if you're executing directly from a single-privileged wallet or want quicker execution, use the following `cast` commands: 1. First, encode the transaction calldata using `cast calldata`: ```bash theme={null} CALLDATA=$(cast calldata "setRespectedGameType(uint32)" 0) ``` 2. Send the transaction: ```bash theme={null} # Execute the transaction cast send --rpc-url <YOUR_RPC_URL> --private-key <YOUR_PRIVATE_KEY> <ASR_ADDRESS> "$CALLDATA" ``` 3. After execution, verify the respected game type: ```bash theme={null} cast call --rpc-url <YOUR_RPC_URL> <ASR_ADDRESS> "respectedGameType()(uint32)" # The value should now be 0 (CANNON) ``` ### Post-execution configuration: After updating, configure `op-proposer` to create proposals using the permissionless `CANNON` game type: Via command-line argument: ```bash theme={null} --game-type 0 ``` Or via environment variable: ```bash theme={null} OP_PROPOSER_GAME_TYPE=0 ``` <Info> This action requires all in-progress withdrawals to be re-proven against a new `FaultDisputeGame` created after this update occurs. </Info> ## Next steps * For more detail on deploying new dispute games with OPCM, [see the docs](/chain-operators/tutorials/dispute-games). * Deploy new dispute games with OPCM via [this tutorial](/chain-operators/tutorials/dispute-games). * Generate an absolute prestate using the [absolute prestate guide](/chain-operators/tutorials/absolute-prestate). * Understand fault proofs in the [Fault proofs explainer](/op-stack/fault-proofs/explainer). # Modifying predeployed contracts Source: https://docs.optimism.io/chain-operators/tutorials/modifying-predeploys Learn how to modify predeployed contracts for an OP Stack chain by upgrading the proxy. <Info> OP Stack Hacks are explicitly things that you can do with the OP Stack that are *not* currently intended for production use. OP Stack Hacks are not for the faint of heart. You will not be able to receive significant developer support for OP Stack Hacks. Be prepared to get your hands dirty and to work without support. </Info> OP Stack blockchains have a number of [predeployed contracts](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/libraries/Predeploys.sol) that provide important functionality. Most of those contracts are proxies that can be upgraded using the `proxyAdminOwner` which was configured when the network was initially deployed. ## Before you begin In this tutorial, you learn how to modify predeployed contracts for an OP Stack chain by upgrading the proxy. The predeploys are controlled from a predeploy called [`ProxyAdmin`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/universal/ProxyAdmin.sol), whose address is `0x4200000000000000000000000000000000000018`. The function to call is [`upgrade(address,address)`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/universal/ProxyAdmin.sol#L152-L168). The first parameter is the proxy to upgrade, and the second is the address of a new implementation. ## Modify the legacy `L1BlockNumber` contract For example, the legacy `L1BlockNumber` contract is at `0x420...013`. To disable this function, we'll set the implementation to `0x00...00`. We do this using the [Foundry](https://book.getfoundry.sh/) command `cast`. <Steps> <Step title="We'll need several constants."> * Set these addresses as variables in your terminal. ```sh theme={null} L1BLOCKNUM=0x4200000000000000000000000000000000000013 PROXY_ADMIN=0x4200000000000000000000000000000000000018 ZERO_ADDR=0x0000000000000000000000000000000000000000 ``` * Set `PRIVKEY` to the private key of your ADMIN address. * Set `ETH_RPC_URL`. If you're on the computer that runs the blockchain, use this command. ```sh theme={null} export ETH_RPC_URL=http://localhost:8545 ``` </Step> <Step title="Verify `L1BlockNumber` works correctly."> See that when you call the contract you get a block number, and twelve seconds later you get the next one (block time on L1 is twelve seconds). ```sh theme={null} cast call $L1BLOCKNUM 'number()' | cast --to-dec sleep 12 && cast call $L1BLOCKNUM 'number()' | cast --to-dec ``` </Step> <Step title="Get the current implementation for the contract."> ```sh theme={null} L1BLOCKNUM_IMPLEMENTATION=`cast call $L1BLOCKNUM "implementation()" | sed 's/000000000000000000000000//'` echo $L1BLOCKNUM_IMPLEMENTATION ``` </Step> <Step title="Change the implementation to the zero address"> ```sh theme={null} cast send --private-key $PRIVKEY $PROXY_ADMIN "upgrade(address,address)" $L1BLOCKNUM $ZERO_ADDR ``` </Step> <Step title="See that the implementation is address zero, and that calling it fails."> ```sh theme={null} cast call $L1BLOCKNUM 'implementation()' cast call $L1BLOCKNUM 'number()' ``` </Step> <Step title="Fix the predeploy by returning it to the previous implementation, and verify it works."> ```sh theme={null} cast send --private-key $PRIVKEY $PROXY_ADMIN "upgrade(address,address)" $L1BLOCKNUM $L1BLOCKNUM_IMPLEMENTATION cast call $L1BLOCKNUM 'number()' | cast --to-dec ``` </Step> </Steps> # How to rewind op-geth Source: https://docs.optimism.io/chain-operators/tutorials/rewind-op-geth Learn how to rewind an op-geth node to a previous chain head. ## Overview This tutorial teaches you how to rewind a single op-geth instance to a previous chain head. This can be helpful to fix a divergent node, recreate archival state, or the safedb from an earlier chain state. ## Rewind op-geth Follow these steps to rewind your op-geth node. <Steps> <Step title="Shut down the CL"> Whatever CL clients are driving the op-geth instance need to be stopped to prevent them from interfering with the rewind later. This would typically be a locally running `op-node` or `kona-node` application, a Docker container or a pod in a Kubernetes cluster. <Note> Make sure you don't have something like ArgoCD syncing the app in question which would just scale the pod back up again. </Note> </Step> <Step title="Determine rewind target"> If you already know the block number/hash you want to rewind to, you can proceed to the next step. If you only know the *timestamp* you want to rewind to, you can find the corresponding block with ```bash theme={null} cast find-block 1741890000 -r <ETH_RPC_URL> ``` Where `<ETH_RPC_URL>` points to your op-geth node’s RPC endpoint, e.g. `http://localhost:8545` if it was a local instance with the default port and `1741890000` is an example unix timestamp. You can use e.g. [https://www.epochconverter.com/](https://www.epochconverter.com/) to convert from human times to unix timestamps. </Step> <Step title="Rewind op-geth"> You need the JWT secret and *open* & *admin* port (default `8545` & `8551`). Then you can use the `op-wheel` command from the [monorepo](https://github.com/ethereum-optimism/optimism/tree/develop/op-wheel) to issue the rewind. ```bash theme={null} # save JWT secret to env var export JWT="YourJWTSecret123" # assuming default ports 8545 and 8551 and local endpoint go run ./op-wheel/cmd engine rewind \ --engine.open http://localhost:8545 \ --engine http://localhost:8551 \ --engine.jwt-secret $JWT \ --log.level DEBUG \ --set-head --to 8460000 ``` This would rewind the op-geth node to the block with number `8460000`. You should have determined the right block number in step 2. </Step> <Step title="Start the CL"> You can now start your CL client again. It will sync from the rewound block head. </Step> </Steps> # Upgrading a Chain From Output Roots to Super Roots Source: https://docs.optimism.io/chain-operators/tutorials/upgrade-chain-to-super-roots Upgrade an OP Stack chain from output-root dispute games to super-root dispute games with a single opcm.upgrade call, then cut op-proposer, op-challenger, and op-dispute-mon over to super roots. # Upgrading a Chain From Output Roots to Super Roots <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 upgrading a single OP Stack chain from output-root dispute games (`PERMISSIONED_CANNON`, `CANNON` or `CANNON_KONA`) to super-root dispute games (`SUPER_PERMISSIONED` or `SUPER_CANNON_KONA`). It runs as a single `opcm.upgrade` call against the chain's existing per-chain `AnchorStateRegistry` and `DisputeGameFactory`. The chain's permission model is preserved: a permissioned chain stays permissioned with `SUPER_PERMISSIONED` only; a permissionless chain runs both super game types with `SUPER_CANNON_KONA` as the respected one. Differences between the two are called out inline. By the end you will have a chain proposing super-root claims via `op-proposer` using a single-chain super-root RPC endpoint and monitoring them with `op-dispute-mon`. On permissionless chains, `op-challenger` defends `SUPER_CANNON_KONA` claims. On permissioned chains, `op-dispute-mon` detects invalid `SUPER_PERMISSIONED` claims, `op-challenger` updates the `AnchorStateRegistry` as games finalize. Every pre-migration dispute game already in flight continues to resolve, and proven withdrawals are not invalidated. <Note>This is `opcm.upgrade`, not `opcm.migrate` — the chain keeps its own per-chain `AnchorStateRegistry` and `DisputeGameFactory`.</Note> Looking to switch from permissioned to permissionless fault proofs? See [Migrating to permissionless fault proofs](/chain-operators/tutorials/migrating-permissionless). This runbook is for chains already running fault proofs that need to move from output-root games to super-root games. ## Before You Begin <SuperchainOpsPrereqs /> ### 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 | You also need a checkout of the [optimism monorepo](https://github.com/ethereum-optimism/optimism) to run [`op-fetcher`](https://github.com/ethereum-optimism/optimism/tree/develop/op-fetcher) (used in the next step). ### Gather the Required Inputs Collect everything below before you start. **Chain identity.** The chain's per-chain addresses live in the `superchain-registry` repository under `superchain/configs/<network>/<chain-name>.toml`. Open that file and read `chain_id`, `addresses.SystemConfigProxy`, and `addresses.L1StandardBridgeProxy`. **Chain addresses and roles.** Use `op-fetcher` to derive the rest of the on-chain configuration in a single call. It runs an embedded forge script against `$L1_RPC` and resolves every per-chain proxy, role, and the current fault-proof status from `SystemConfig` and `L1StandardBridge`: ```bash theme={null} cd <optimism-monorepo>/op-fetcher just build-all go run ./cmd fetch \ --l1-rpc-url "$L1_RPC" \ --system-config "<SystemConfigProxy>" \ --l1-standard-bridge "<L1StandardBridgeProxy>" \ --output-file chain.json ``` Read the values you need from `chain.json`: | Item | Source | | - | - | | L2 chain ID | `chain_id` in the chain's registry TOML | | `SystemConfig` proxy | `addresses.SystemConfigProxy` in the chain's registry TOML | | `OptimismPortal2` proxy | `.addresses.OptimismPortalProxy` | | `AnchorStateRegistry` proxy (referred to below as `<ASR>`) | `.addresses.AnchorStateRegistryProxy` | | `DisputeGameFactory` proxy (referred to below as `<DGF>`) | `.addresses.DisputeGameFactoryProxy` | | `SuperchainConfig` proxy | `.addresses.SuperchainConfigProxy` | **Chain type.** The upgrade preserves the chain's existing permission model. `chain.json` reports the current respected game type at `.faultProofs.respectedGameType`: * `1` (`PERMISSIONED_CANNON`) — chain is **permissioned**. The new respected game type is `5` (`SUPER_PERMISSIONED`). * `0` (`CANNON`) or `8` (`CANNON_KONA`) — chain is **permissionless**. The new respected game type is `9` (`SUPER_CANNON_KONA`). **Init bonds.** `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), the standard value used on existing chains. **Release artifacts and infrastructure.** | Item | Source | | - | - | | `OPCM` address for the target network | `validation/standard/standard-versions-<network>.toml` in the [superchain-registry](https://github.com/ethereum-optimism/superchain-registry). Look up the `op-contracts/v8.x.y` release pinned by the `OPCMUpgradeV800` template and read `op_contracts_manager.address`. | | Kona-interop prestate hash | OPCM release manifest. Use the `-interop` kona variant, even if interop is not scheduled for the chain. | | Prestate artifact URL | The chain's existing `cannon-kona-prestates-url` server, with the kona-interop prestate uploaded ahead of the upgrade | | Single-chain super-root RPC endpoint (`$SUPER_ROOT_RPC`) | Your infrastructure team. Use the chain's op-node RPC endpoint or an op-supernode `/<chainID>/` endpoint. An op-node must run with `--safedb.path` enabled and populated. The namespaced endpoint returns a super root containing only this chain, even if the op-supernode tracks other chains. | ### Verify the Preconditions Before you change any configuration: * **Confirm the template's extra instructions.** Open `superchain-ops/src/template/OPCMUpgradeV800.sol` and check `_buildExtraInstructions`. As of writing it injects `overrides.cfg.startingRespectedGameType` and `PermittedProxyDeployment`. Both need attention before continuing. `PermittedProxyDeployment` must be dropped: OPCM `8.0.0` permits no proxy deployments during an upgrade, because the unified `DelayedWETH` shipped with the 7.x OPCM, so the instruction now reverts with `OPContractsManagerV2_InvalidUpgradeInstruction`. An `overrides.cfg.startingAnchorRoot` override must be added: without it, OPCM falls back to the existing on-chain `startingAnchorRoot`, which on a pre-upgrade chain is an output-root-shaped value with a block-number `l2SequenceNumber` — not a valid super-root anchor. The template must be extended to read a starting super-root anchor from TOML and add it as an extra instruction. Fix the template before continuing. * **Confirm the RPC endpoint returns a single-chain super root.** Either the chain's op-node RPC endpoint or an op-supernode `/<chainID>/` endpoint can be used. Do not use a multi-chain op-supernode root endpoint; it computes roots across its full dependency set. * **Verify the single-chain RPC endpoint is healthy.** For an op-node or namespaced op-supernode endpoint, confirm it reports a recent finalized L2 head and can produce the corresponding super root: ```bash theme={null} TS=$(cast rpc optimism_syncStatus --rpc-url $SUPER_ROOT_RPC | jq -r '.finalized_l2.timestamp') cast rpc superroot_atTimestamp "$(cast 2h $TS)" \ --rpc-url $SUPER_ROOT_RPC | jq -r '.data.super_root' ``` If an op-node returns a SafeDB error, configure `--safedb.path`, let the node populate records through derivation, and retry. `optimism_syncStatus` can succeed while SafeDB is disabled, but `superroot_atTimestamp` cannot serve a non-genesis timestamp without SafeDB. * **Verify the prestate server serves the new hash.** ```bash theme={null} curl -fI "$PRESTATE_URL/$SUPER_PRESTATE_HASH.bin.gz" ``` ## Stage the Off-Chain Configuration Apply these changes before you submit the on-chain upgrade. After the changes ship, the components keep operating against existing pre-migration games and pick up super-root games automatically once the upgrade lands. ### Update op-challenger Update the running `op-challenger` for the chain. Keep `--rollup-rpc` and the existing `--game-types` so existing games continue to be defended. Add the super-root trace type only on permissionless chains, where `SUPER_CANNON_KONA` is enabled. | Action | Flag (env var) | Value | | - | - | - | | Add | `--superroot-rpc` (`OP_CHALLENGER_SUPERROOT_RPC`) | `$SUPER_ROOT_RPC` | | Append to | `--game-types` (`OP_CHALLENGER_GAME_TYPES`) | `super-cannon-kona`. Do not add `super-permissioned`; the simplified `SUPER_PERMISSIONED` game does not require claims to be posted.
프로젝트로 돌아가기