Optimism 백서

Optimism

원문

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

sh theme={null} curl ifconfig.me curl ipinfo.io/ip ``` </Step> <Step title="Choose your ports"> * `8545`: op-reth HTTP RPC * `8546`: op-reth WebSocket RPC * `8551`: op-reth Auth RPC (Engine API) * `8547`: op-node RPC * `9222`: P2P networking </Step> </Steps> <Accordion title=".env template"> ```bash theme={null} L1_RPC_URL=https://sepolia.infura.io/v3/YOUR_ACTUAL_INFURA_KEY L1_BEACON_URL=https://ethereum-sepolia-beacon-api.publicnode.com SEQUENCER_ENABLED=true SEQUENCER_STOPPED=false PRIVATE_KEY=YOUR_ACTUAL_PRIVATE_KEY P2P_LISTEN_PORT=9222 P2P_ADVERTISE_IP=YOUR_ACTUAL_PUBLIC_IP OP_NODE_RPC_PORT=8547 OP_RETH_HTTP_PORT=8545 OP_RETH_WS_PORT=8546 OP_RETH_AUTH_PORT=8551 JWT_SECRET=./jwt.txt ``` </Accordion> ## Sequencer specific configuration ### op-reth configuration for sequencer Create `scripts/start-op-reth.sh`: ```bash theme={null} #!/bin/bash source .env ../optimism/rust/target/release/op-reth node \ --chain=./genesis.json \ --datadir=./op-reth-data \ --http \ --http.addr=0.0.0.0 \ --http.port=$OP_RETH_HTTP_PORT \ --http.corsdomain="*" \ --http.api=admin,debug,eth,net,txpool,web3 \ --ws \ --ws.addr=0.0.0.0 \ --ws.port=$OP_RETH_WS_PORT \ --ws.origins="*" \ --ws.api=admin,debug,eth,net,txpool,web3 \ --authrpc.addr=0.0.0.0 \ --authrpc.port=$OP_RETH_AUTH_PORT \ --authrpc.jwtsecret=$JWT_SECRET \ --rollup.disable-tx-pool-gossip \ --builder.deadline=2 \ --builder.interval=100ms ``` <Info> op-reth initializes its database from the genesis file on first startup — there is no separate `geth init`-style step. It also runs as an archive node by default. </Info> ### op-node configuration for sequencer Create `scripts/start-op-node.sh`: ```bash theme={null} #!/bin/bash source .env ../optimism/op-node/bin/op-node \ --l1=$L1_RPC_URL \ --l1.beacon=$L1_BEACON_URL \ --l2=http://localhost:$OP_RETH_AUTH_PORT \ --l2.jwt-secret=$JWT_SECRET \ --l2.enginekind=reth \ --rollup.config=./rollup.json \ --sequencer.enabled=$SEQUENCER_ENABLED \ --sequencer.stopped=$SEQUENCER_STOPPED \ --sequencer.max-safe-lag=3600 \ --verifier.l1-confs=4 \ --p2p.listen.ip=0.0.0.0 \ --p2p.listen.tcp=$P2P_LISTEN_PORT \ --p2p.listen.udp=$P2P_LISTEN_PORT \ --p2p.advertise.ip=$P2P_ADVERTISE_IP \ --p2p.advertise.tcp=$P2P_LISTEN_PORT \ --p2p.advertise.udp=$P2P_LISTEN_PORT \ --p2p.sequencer.key=$PRIVATE_KEY \ --rpc.addr=0.0.0.0 \ --rpc.port=$OP_NODE_RPC_PORT \ --rpc.enable-admin \ --log.level=info \ --log.format=json ``` <Warning> This tutorial enables op-node's admin API (`--rpc.enable-admin`) on `0.0.0.0:8547`. The op-node RPC is unauthenticated (the JWT secret protects only the Engine API), so anyone who can reach that port can call admin methods such as `admin_stopSequencer`. Take care not to expose the admin API to the public internet: publish the port on localhost only (`"127.0.0.1:8547:8547"`) instead of `"8547:8547"`. Docker-published ports bypass host firewalls such as `ufw` by default. </Warning> ## Starting the sequencer <Steps> <Step title="Start op-reth"> ```bash theme={null} cd rollup/sequencer chmod +x scripts/start-op-reth.sh chmod +x scripts/start-op-node.sh ./scripts/start-op-reth.sh ``` </Step> <Step title="Start op-node"> In a second terminal: ```bash theme={null} ./scripts/start-op-node.sh ``` </Step> <Step title="Verify sequencer is running"> ```bash theme={null} curl -X POST -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ http://localhost:8545 curl -X POST -H "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"admin_sequencerActive","params":[],"id":1}' \ http://localhost:8547 ``` </Step> </Steps> Your sequencer node is now operational and ready to process transactions. </Tab> </Tabs> ## What's Next? Great! Your sequencer is running and processing transactions. The next step is to set up the batcher to publish transaction data to L1. <Card title="Spin up batcher →" href="./op-batcher-setup"> **Next**: Configure and start op-batcher to publish L2 transaction data to L1 for data availability. </Card> *** ## Need Help? * **Running op-reth**: [Execution client configuration](/node-operators/guides/configuration/execution-clients) * **op-reth CLI reference**: [op-reth node command](/node-operators/op-reth/cli/op-reth/node) * **Best Practices**: [Chain Operator Best Practices](/chain-operators/guides/management/best-practices) * **Support**: [Report an issue or ask a question](https://github.com/ethereum-optimism/optimism/issues) in the Optimism monorepo # Deploying new dispute games with OPCM Source: https://docs.optimism.io/chain-operators/tutorials/dispute-games Learn how to deploy new dispute games to an OP Stack chain using OPCM This guide provides instructions on how to deploy new dispute games to an OP Stack chain using the [OPCM (OP Contracts Manager)](/chain-operators/reference/opcm). This process is particularly relevant for teams looking to upgrade their chains to support permissionless dispute games. ## Prerequisites Before you begin, ensure that: * Run op-contracts/v2.0.0 or higher on your chain * Own the chain's L1 `ProxyAdmin` contract * Install the Forge toolkit (see [Foundry docs](https://getfoundry.sh/)) ## Understanding dispute games The OP Stack uses two types of dispute games: * **Permissioned dispute game**: Limited to specific proposer and challenger addresses * **Permissionless dispute game**: Open to anyone to propose or challenge <Info> In the Permissioned dispute game (PDG), the [challenger role](/op-stack/protocol/privileged-roles) is a protocol-level permission assigned to specific addresses, allowing them to initiate or respond to disputes. This role is distinct from the op-challenger service, which is an off-chain monitoring service responsible for automatically detecting discrepancies and submitting challenges. While the op-challenger service typically operates using an address that has been assigned the challenger role, the protocol-level role itself can be independently assigned, regardless of whether the op-challenger service is in use. Refer to the [OP Stack configurability spec](https://specs.optimism.io/protocol/configurability.html) for more details. </Info> All chains deployed with `op-deployer` only initially include the permissioned dispute game. This guide explains how to add the permissionless game. ## The `addGameType` function The OPCM contract contains an `addGameType` function that handles the deployment of new dispute games. This function: 1. Deploys a new dispute game implementation 2. Optionally deploys a new [`DelayedWETH`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/dispute/DelayedWETH.sol) contract 3. Registers the game with the `DisputeGameFactory` 4. Sets the initial bond amount ### 1. Finding the correct OPCM instance Each OP Contracts release has its own OPCM instance. You must use the OPCM corresponding exactly to your chain's contract version. For example, if your system uses contracts version **v3.0.0**, you must use the OPCM for **v3.0.0**. To find the correct OPCM address: * For **Mainnet**, refer to the [standard-versions-mainnet.toml](https://github.com/ethereum-optimism/superchain-registry/blob/main/validation/standard/standard-versions-mainnet.toml) file in the superchain-registry. * For **Sepolia**, refer to the [standard-versions-sepolia.toml](https://github.com/ethereum-optimism/superchain-registry/blob/main/validation/standard/standard-versions-sepolia.toml) file in the superchain-registry. These registry files contain mappings between OP contract versions and their corresponding OPCM addresses. ### 2. Preparing the `addGameType` Call The `addGameType` function expects an array of `AddGameInput` structs. Here is the structure: ```solidity theme={null} struct AddGameInput { string saltMixer; ISystemConfig systemConfig; IProxyAdmin proxyAdmin; IDelayedWETH delayedWETH; GameType disputeGameType; Claim disputeAbsolutePrestate; uint256 disputeMaxGameDepth; uint256 disputeSplitDepth; Duration disputeClockExtension; Duration disputeMaxClockDuration; uint256 initialBond; IBigStepper vm; bool permissioned; } ``` **Key parameters explained:** * **saltMixer:** A string used to create unique contract addresses * **systemConfig:** The address of your chain's `SystemConfig` contract * **proxyAdmin:** The Address of your chain's `ProxyAdmin` contract * **delayedWETH:** The Address of the `DelayedWETH` contract (use zero address to deploy a new one) * **disputeGameType:** For permissionless games, use `GameTypes.CANNON` * **disputeAbsolutePrestate:** The absolute prestate hash for the game * **permissioned:** Set to `false` for a permissionless game For a permissionless game, you'll generally want to mirror most parameters from your existing permissioned game, but set permissioned to `false` and use the GameType `CANNON`. 3. Execute the addGameType function The following is a template for calling the addGameType function using Forge's cast: <Info> The most recommended way is to use a script to execute this call, rather than manual execution. </Info> ```bash theme={null} # Retrieve existing values from chain for reference # Get permissioned game implementation PERMISSIONED_GAME=$(cast call --rpc-url $RPC_URL $DISPUTE_GAME_FACTORY "gameImpls(uint32)" $PERMISSIONED_GAME_TYPE) # Retrieve parameters from existing permissioned game ABSOLUTE_PRESTATE=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "absolutePrestate()") MAX_GAME_DEPTH=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "maxGameDepth()") SPLIT_DEPTH=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "splitDepth()") CLOCK_EXTENSION=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "clockExtension()") MAX_CLOCK_DURATION=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "maxClockDuration()") VM=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "vm()") ANCHOR_STATE_REGISTRY=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "anchorStateRegistry()") L2_CHAIN_ID=$(cast call --rpc-url $RPC_URL $PERMISSIONED_GAME "l2ChainId()") # Create call data for addGameType function # Note: Set delayedWETH to 0x0 to deploy a new one CALLDATA=$(cast calldata "addGameType((string,address,address,address,uint32,bytes32,uint256,uint256,uint64,uint64,uint256,address,bool)[])" \ "[(\ \"unique_salt_mixer\",\ $SYSTEM_CONFIG,\ $PROXY_ADMIN,\ 0x0000000000000000000000000000000000000000,\ $CANNON_GAME_TYPE,\ $ABSOLUTE_PRESTATE,\ $MAX_GAME_DEPTH,\ $SPLIT_DEPTH,\ $CLOCK_EXTENSION,\ $MAX_CLOCK_DURATION,\ $INITIAL_BOND,\ $VM,\ false\ )]") # Execute the transaction cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $OPCM_ADDRESS $CALLDATA ``` 4. Setting the respected game type After deploying the permissionless dispute game, you'll need to update the respectedGameType in the OptimismPortal to start using it. For detailed instructions on setting the respected game type and migrating your chain from permissioned to permissionless fault proofs, refer to the [migrating to permissionless fault proofs guide](/chain-operators/tutorials/migrating-permissionless). ## Next Steps * For more detail on deploying new dispute games with OPCM, [see the docs](/chain-operators/tutorials/dispute-games). * Learn about [absolute prestate](/chain-operators/tutorials/absolute-prestate) * checkout the [migrating to permissionless fault proofs](/chain-operators/tutorials/migrating-permissionless) guide * [Fault proofs explainer](/op-stack/fault-proofs/explainer) # Integrating a new DA layer with Alt-DA Source: https://docs.optimism.io/chain-operators/tutorials/integrating-da-layer Learn how to add support for a new DA Layer within the OP Stack. <Info> The Alt-DA Mode feature is currently in <strong>Beta</strong> within the MIT-licensed OP Stack. Beta features are built and reviewed by Optimism Collective core contributors, and provide developers with early access to highly requested configurations. These features may experience stability issues, and we encourage feedback from our early users. </Info> [Alt-DA Mode](/op-stack/features/experimental/alt-da-mode) enables seamless integration of any DA Layer, regardless of their commitment type, into the OP Stack. After a DA Server is built for a DA Layer, any chain operator can launch an OP Stack chain using that DA Layer for sustainably low costs. ## Build your DA server Our suggestion is for every DA Layer to build and maintain their own DA Server, with support from the OP Labs team along the way. The DA Server will need to be run by every node operator, so we highly recommend making your DA Server open source and MIT licensed. <Steps> <Step title="Design your commitment binary encoding"> * It must point to the data on your layer (like block height / hash). * It must be able to validate the data returned from the data (i.e., include a cryptographic commitment to the data like a hash, merkle proof, or polynomial commitment, this could be done against the block hash with a complex proof). <Info> See the [specs](https://specs.optimism.io/experimental/alt-da.html?highlight=input-commitment-submission?utm_source=op-docs\&utm_medium=docs#input-commitment-submission) for more info on commitment submission. </Info> </Step> <Step title="Claim your da\_layer byte"> * Claim your [byte](https://github.com/ethereum-optimism/specs/discussions/135) </Step> <Step title="Implement the DA server"> * Write a simple HTTP server which supports `get` and `put` * `put` is used by the batcher and can return the commitment to the batcher in the body. It should not return until the data is known to be submitted to your DA layer. * `get` should fetch the data. If the data is not available, it should return a `404` not found. If there are other errors, a different error should be returned. </Step> </Steps> ## Run Alt-DA Follow our guide on [how to operate an Alt-DA Mode chain](/chain-operators/guides/features/alt-da-mode-guide), except instead of using the S3 DA server, use the DA server that you built. ## Next steps * For more detail on implementing the DA Server, [see the specification](https://specs.optimism.io/experimental/alt-da.html?utm_source=op-docs\&utm_medium=docs#da-server). # Generating a custom kona-client absolute prestate Source: https://docs.optimism.io/chain-operators/tutorials/kona-custom-prestate How to build a kona-client absolute prestate that embeds a chain configuration not yet in the public Superchain Registry. # Overview For chains that are part of the public [`superchain-registry`](https://github.com/ethereum-optimism/superchain-registry), the standard `kona-client` absolute prestate published in [`standard-prestates.toml`](https://github.com/ethereum-optimism/superchain-registry/blob/main/validation/standard/standard-prestates.toml) already embeds your chain configuration. No custom build is needed. This tutorial is for the rarer case: a partner chain whose `RollupConfig` is not yet in the public registry but which still needs to run permissionless fault proofs (`cannon-kona` game type). In that case you must build a custom `kona-client` that embeds your chain's configuration, generate the absolute prestate hash from that build, and host the resulting binary at a URL `op-challenger` can fetch. <Info> Most chains are in the Superchain Registry and should use the standard prestate; follow [Generating absolute prestate and preimage files](/chain-operators/tutorials/absolute-prestate) instead. Only follow this tutorial if your chain is **not yet** in the registry. Once the chain is added to the public registry, future releases will cover it via the standard prestate and you can stop maintaining a custom build. </Info> ## Prerequisites Before starting, ensure you have: * [Docker](https://docs.docker.com/engine/install/) running * [`just`](https://github.com/casey/just) installed * Your chain's `rollup.json`, L2 genesis, and deployment artifacts (typically produced by `op-deployer`) ## How kona-client picks up custom chain configurations `kona-client` reads its embedded chain registry from the [`kona-registry` crate](https://github.com/ethereum-optimism/optimism/tree/develop/rust/kona/crates/protocol/registry). At build time, the crate's `build.rs` can merge additional chains on top of the canonical Superchain Registry snapshot. The merge is gated by two environment variables: ```bash theme={null} KONA_CUSTOM_CONFIGS=true KONA_CUSTOM_CONFIGS_DIR=/absolute/path/to/your/configs ``` When set, the build script reads two files from `KONA_CUSTOM_CONFIGS_DIR`: * `chainList.json` — light-weight `Chain` entries for your custom chains * `configs.json` — full `ChainConfig` + `RollupConfig` entries grouped under a `Superchain` bucket The full schema and an end-to-end example are documented in the [`kona-registry` README](https://github.com/ethereum-optimism/optimism/tree/develop/rust/kona/crates/protocol/registry#custom-chain-configurations). The compiled `kona-client` binary embeds the merged registry via `include_str!()`, so the resulting absolute prestate hash differs from the standard one. Any honest challenger participating in your chain's dispute games will need to run this same binary. ## Generating the custom prestate <Steps> <Step title="Check out a kona-node release tag"> Use the same `kona-node/v<VERSION>` tag that your chain's nodes are running. The native `KONA_CUSTOM_CONFIGS_DIR` support documented below requires **`kona-node/v1.5.2` or later**; on older tags, additional justfile patches are needed. ```bash theme={null} git clone https://github.com/ethereum-optimism/optimism.git cd optimism git checkout kona-node/v<VERSION> ``` </Step> <Step title="Stage your chain configuration"> Create a directory for your custom configs: ```bash theme={null} mkdir -p rust/kona/crates/protocol/registry/etc/custom-configs/<chain-name> ``` Add two files inside it — `chainList.json` (lightweight chain entry) and `configs.json` (full rollup config). Replace every `<PLACEHOLDER>` with your chain's value. Notes: * **`<CHAIN_GROUP>`**: `mainnet` if your L1 is Ethereum mainnet, `sepolia` if your L1 is Sepolia. The bucket groups chains by L1 network, not by governance — your custom-chain status is expressed via `governedByOptimism: false` and `superchainLevel: 0`. * **`faultProofs.status`**: `permissionless` for chains running the `cannon-kona` game type publicly, `permissioned` for chains that only allow whitelisted challengers. <Tabs> <Tab title="chainList.json"> ```json theme={null} [ { "name": "<YOUR_CHAIN_NAME>", "identifier": "<CHAIN_GROUP>/<YOUR_CHAIN_NAME>", "chainId": <YOUR_L2_CHAIN_ID>, "rpc": [], "explorers": [], "superchainLevel": 0, "governedByOptimism": false, "dataAvailabilityType": "eth-da", "parent": { "type": "L2", "chain": "<CHAIN_GROUP>" }, "faultProofs": { "status": "<permissionless | permissioned>" } } ] ``` </Tab> <Tab title="configs.json"> ```json theme={null} { "superchains": [ { "name": "<CHAIN_GROUP>", "config": { "name": "<CHAIN_GROUP_DISPLAY_NAME>", "l1": { "chain_id": <L1_CHAIN_ID>, "public_rpc": "<L1_PUBLIC_RPC>", "explorer": "<L1_EXPLORER>" }, "hardforks": { "canyon_time": 0, "delta_time": 0, "ecotone_time": 0, "fjord_time": 0, "granite_time": 0, "holocene_time": 0, "isthmus_time": 0, "jovian_time": 0 }, "superchain_config_addr": null, "op_contracts_manager_proxy_addr": null }, "chains": [ { "Name": "<YOUR_CHAIN_NAME>", "PublicRPC": "", "SequencerRPC": "", "Explorer": "", "SuperchainLevel": 0, "GovernedByOptimism": false, "SuperchainTime": 0, "DataAvailabilityType": "eth-da", "l2_chain_id": <YOUR_L2_CHAIN_ID>, "batch_inbox_address": "<BATCH_INBOX_ADDRESS>", "block_time": 2, "seq_window_size": 3600, "max_sequencer_drift": 600, "GasPayingToken": null, "hardfork_configuration": { "canyon_time":
프로젝트로 돌아가기