Optimism 백서

Optimism

원문

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

previous step └── proposer/ # You are here ├── state.json # Copied from deployer ├── .env # Environment variables └── docker-compose.yml # Docker configuration ``` </Step> </Steps> <Accordion title="Understanding proposer startup logs"> When you first start your proposer, you'll see several types of log messages: 1. **Initialization messages** (normal): ``` lvl=info msg="Initializing L2Output Submitter" lvl=info msg="Connected to DisputeGameFactory" lvl=info msg="Starting JSON-RPC server" ``` 2. **Sync status messages** (expected during startup): ``` msg="rollup current L1 block still behind target, retrying" current_l1=...:9094035 target_l1=9132815 ``` This is normal! It means: * Your rollup is still syncing with L1 (e.g., Sepolia) * The proposer is waiting until sync is closer to L1 tip * You'll see the `current_l1` number increasing as it catches up * Once caught up, the proposer will start submitting proposals Don't worry about the "retrying" messages - they show healthy progress as your rollup catches up to the latest L1 blocks. **Common log patterns:** * Startup: You'll see initialization messages as services start * Sync: "block still behind target" messages while catching up * Normal operation: Regular proposal submissions once synced * Network: Connection messages to L1/L2 endpoints If you see errors about "failed to dial" or connection issues: * For source build: Verify your localhost ports and services </Accordion> Your proposer is now operational and will continuously submit state roots to L1! </Tab> <Tab title="Build from source"> ### Finding the current stable releases To ensure you're using the latest compatible versions of OP Stack components, always check the official [releases page](https://github.com/ethereum-optimism/optimism/releases). Look for the latest `op-proposer/v*` release that's compatible with your sequencer setup. <Info> This guide uses `op-proposer/v1.16.3`, the latest release at the time of writing, alongside op-node/v1.19.3 and op-reth/v2.4.0 from the sequencer setup. Always check the [release notes](https://github.com/ethereum-optimism/optimism/releases) for compatibility information. </Info> Building from source gives you full control over the binaries. <Steps> <Step title="Clone and build op-proposer"> ```bash theme={null} # If you don't already have the optimism repository from the sequencer setup git clone https://github.com/ethereum-optimism/optimism.git cd optimism # Checkout the latest release tag git checkout op-proposer/v1.16.3 # Build op-proposer cd op-proposer just # Binary will be available at ./bin/op-proposer ``` </Step> <Step title="Verify installation"> Run this command to verify the installation: ```bash theme={null} ./bin/op-proposer --version ``` </Step> </Steps> ## Configuration setup <Info> The rest of this guide assumes you're using the **build-from-source** approach. If you chose Docker, all the necessary configuration was covered in the Docker tab above. </Info> <Steps> <Step title="Organize your workspace"> Create your proposer working directory at the same level as your sequencer: ```bash theme={null} # Create proposer directory inside rollup cd ../ # Go back to rollup directory mkdir proposer cd proposer # Create scripts directory mkdir scripts ``` </Step> <Step title="Extract DisputeGameFactory address"> Extract the `DisputeGameFactory` contract address from your op-deployer output: ```bash theme={null} # Make sure you're in the rollup/proposer directory cd rollup/proposer # Copy the state.json from deployer cp ../deployer/.deployer/state.json . # Extract the DisputeGameFactory address GAME_FACTORY_ADDRESS=$(cat state.json | jq -r '.opChainDeployments[0].disputeGameFactoryProxyAddress') echo "DisputeGameFactory Address: $GAME_FACTORY_ADDRESS" ``` <Info> The proposer only needs the `DisputeGameFactory` address to submit proposals. The `GAME_TYPE=0` represents the standard fault proof game type. </Info> </Step> <Step title="Set up environment variables"> Create your `.env` file with the actual values: ```bash theme={null} # Create .env file with your actual values # L1 Configuration - Replace with your actual RPC URL L1_RPC_URL=https://sepolia.infura.io/v3/YOUR_ACTUAL_INFURA_KEY # L2 Configuration - Should match your sequencer setup L2_RPC_URL=http://localhost:8545 ROLLUP_RPC_URL=http://localhost:8547 # Contract addresses - Extract from your op-deployer output GAME_FACTORY_ADDRESS=YOUR_ACTUAL_GAME_FACTORY_ADDRESS # Private key - Replace with your actual private key PRIVATE_KEY=YOUR_ACTUAL_PRIVATE_KEY # Proposer configuration PROPOSAL_INTERVAL=3600s GAME_TYPE=0 POLL_INTERVAL=20s # RPC configuration PROPOSER_RPC_PORT=8560 ``` **Important**: Replace ALL placeholder values (`YOUR_ACTUAL_*`) with your real configuration values! </Step> <Step title="Get your private key"> Get a private key from your wallet that will be used for submitting proposals to L1. This account needs sufficient ETH to pay for L1 gas costs. <Info> The proposer account needs to be funded with ETH on L1 to pay for proposal submission transactions. Monitor this account's balance regularly as it will consume ETH for each proposal submission. </Info> </Step> </Steps> ## Proposer configuration Create `scripts/start-proposer.sh`: ```bash theme={null} #!/bin/bash source .env # Path to the op-proposer binary we built ../../optimism/op-proposer/bin/op-proposer \ --poll-interval=$POLL_INTERVAL \ --rpc.port=$PROPOSER_RPC_PORT \ --rpc.enable-admin \ --rollup-rpc=$ROLLUP_RPC_URL \ --l1-eth-rpc=$L1_RPC_URL \ --private-key=$PRIVATE_KEY \ --game-factory-address=$GAME_FACTORY_ADDRESS \ --game-type=$GAME_TYPE \ --proposal-interval=$PROPOSAL_INTERVAL \ --num-confirmations=1 \ --resubmission-timeout=30s \ --wait-node-sync=true \ --log.level=info ``` Your final directory structure should look like: ```bash theme={null} rollup/ ├── deployer/ # From previous step │ └── .deployer/ # Contains state.json ├── optimism/ # Contains op-proposer binary ├── sequencer/ # From previous step ├── batcher/ # From previous step └── proposer/ # You are here ├── state.json # Copied from deployer ├── .env # Environment variables └── scripts/ # Startup scripts └── start-proposer.sh ``` ## Starting the proposer <Steps> <Step title="Start the proposer"> ```bash theme={null} # Make the script executable chmod +x scripts/start-proposer.sh # Start the proposer ./scripts/start-proposer.sh ``` </Step> </Steps> <Accordion title="Understanding proposer startup logs"> When you first start your proposer, you'll see several types of log messages: 1. **Initialization messages** (normal): ``` lvl=info msg="Initializing L2Output Submitter" lvl=info msg="Connected to DisputeGameFactory" lvl=info msg="Starting JSON-RPC server" ``` 2. **Sync status messages** (expected during startup): ``` msg="rollup current L1 block still behind target, retrying" current_l1=...:9094035 target_l1=9132815 ``` This is normal! It means: * Your rollup is still syncing with L1 (e.g., Sepolia) * The proposer is waiting until sync is closer to L1 tip * You'll see the `current_l1` number increasing as it catches up * Once caught up, the proposer will start submitting proposals Don't worry about the "retrying" messages - they show healthy progress as your rollup catches up to the latest L1 blocks. **Common log patterns:** * Startup: You'll see initialization messages as services start * Sync: "block still behind target" messages while catching up * Normal operation: Regular proposal submissions once synced * Network: Connection messages to L1/L2 endpoints If you see errors about "failed to dial" or connection issues: * For Docker: Check your network configuration and service names </Accordion> Your proposer is now operational! </Tab> </Tabs> ## What's Next? Perfect! Your proposer is submitting state roots to L1. The final step is to set up the challenger to monitor and respond to disputes. <Card title="Spin up challenger →" href="./op-challenger-setup"> **Next**: Configure and start op-challenger to monitor disputes and maintain your rollup's security. </Card> *** ## Need Help? * **Proposer Configuration**: [op-proposer Configuration Reference](/chain-operators/guides/configuration/proposer) * **Dispute Games**: [Deploying Dispute Games with OPCM](/chain-operators/tutorials/dispute-games) # Spin up sequencer Source: https://docs.optimism.io/chain-operators/tutorials/create-l2-rollup/op-reth-setup Set up and run op-reth and op-node, the execution and consensus layers for your rollup. Now that you have op-deployer configured, it's time to spin up the sequencer for your rollup. This involves running both `op-reth` and `op-node` to create a functioning sequencer. <Info> **Step 2 of 5**: This tutorial builds on [Spin up op-deployer](./op-deployer-setup). Make sure you've completed that first. </Info> <Warning> **op-geth has reached end-of-support (2026-05-31) and does not support the now-active Karst hardfork, so op-geth nodes can no longer follow the canonical chain.** Migrate to op-reth, the primary supported execution client. See the [op-geth deprecation notice](/notices/archive/op-geth-deprecation) for the full migration plan. </Warning> This tutorial previously taught `op-geth` as the execution client; this page now uses `op-reth` throughout. ## What you'll set up The sequencer node consists of two core components: * `op-reth`: Execution layer that processes transactions and maintains state * `op-node`: Consensus layer that orders transactions and creates L2 blocks The sequencer is responsible for: * Ordering transactions from users * Building L2 blocks * Signing blocks on the P2P network ## Software installation For spinning up a sequencer, we recommend using Docker, as it provides a simpler setup and consistent environment. In this guide, building from source is also provided as an alternative for those who need more control and easier debugging. <Info> The versions used in this guide (**op-node/v1.19.3** and **op-reth/v2.4.0**) were the latest releases at the time of writing. Check the [op-node releases](https://github.com/ethereum-optimism/optimism/releases?q=op-node) and [op-reth releases](https://github.com/ethereum-optimism/optimism/releases?q=op-reth) for the current versions, and always read the release notes for compatibility information. </Info> <Tabs> <Tab title="Use docker"> <Steps> <Step title="Set up directory structure and copy configuration files"> If you prefer containerized deployment, you can use the official Docker images, and do the following: ```bash theme={null} # Create your sequencer directory inside rollup cd ../ # Go back to rollup directory if you're in deployer mkdir sequencer cd sequencer # Copy configuration files from deployer cp ../deployer/.deployer/genesis.json . cp ../deployer/.deployer/rollup.json . # Generate JWT secret openssl rand -hex 32 > jwt.txt chmod 600 jwt.txt ``` </Step> <Step title="Create environment variables file"> ```bash theme={null} # Create .env file with your actual values cat > .env << 'EOF' # L1 Configuration - Replace with your actual RPC URLs L1_RPC_URL=https://sepolia.infura.io/v3/YOUR_ACTUAL_INFURA_KEY L1_BEACON_URL=https://ethereum-sepolia-beacon-api.publicnode.com # Private keys - Replace with your actual private key PRIVATE_KEY=YOUR_ACTUAL_PRIVATE_KEY # P2P configuration - Replace with your actual public IP # Run `curl ifconfig.me` in a separate shell to obtain the value, then paste it below P2P_ADVERTISE_IP=YOUR_ACTUAL_PUBLIC_IP EOF ``` **Important**: Replace ALL placeholder values (`YOUR_ACTUAL_*`) with your real configuration values. </Step> <Step title="Make sure your docker application is running"> Create a `docker-compose.yml` file in the same directory: ```yaml theme={null} services: op-reth: image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-reth:v2.4.0 volumes: # Mount entire directory to avoid file mounting issues - .:/workspace working_dir: /workspace ports: - "8545:8545" - "8546:8546" - "8551:8551" command: - "node" - "--chain=/workspace/genesis.json" - "--datadir=/workspace/op-reth-data" - "--http" - "--http.addr=0.0.0.0" - "--http.port=8545" - "--http.corsdomain=*" - "--http.api=admin,debug,eth,net,txpool,web3" - "--ws" - "--ws.addr=0.0.0.0" - "--ws.port=8546" - "--ws.origins=*" - "--ws.api=admin,debug,eth,net,txpool,web3" - "--authrpc.addr=0.0.0.0" - "--authrpc.port=8551" - "--authrpc.jwtsecret=/workspace/jwt.txt" - "--rollup.disable-tx-pool-gossip" - "--builder.deadline=2" - "--builder.interval=100ms" op-node: image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.19.3 depends_on: - op-reth volumes: - .:/workspace working_dir: /workspace ports: - "8547:8547" - "9222:9222" environment: - L1_RPC_URL=${L1_RPC_URL} - L1_BEACON_URL=${L1_BEACON_URL} - PRIVATE_KEY=${PRIVATE_KEY} - P2P_ADVERTISE_IP=${P2P_ADVERTISE_IP} command: - "op-node" - "--l1=${L1_RPC_URL}" - "--l1.beacon=${L1_BEACON_URL}" - "--l2=http://op-reth:8551" - "--l2.jwt-secret=/workspace/jwt.txt" - "--l2.enginekind=reth" - "--rollup.config=/workspace/rollup.json" - "--sequencer.enabled=true" - "--sequencer.stopped=false" - "--sequencer.max-safe-lag=3600" - "--verifier.l1-confs=4" - "--p2p.listen.ip=0.0.0.0" - "--p2p.listen.tcp=9222" - "--p2p.listen.udp=9222" - "--p2p.advertise.ip=${P2P_ADVERTISE_IP}" - "--p2p.advertise.tcp=9222" - "--p2p.advertise.udp=9222" - "--p2p.sequencer.key=${PRIVATE_KEY}" - "--rpc.addr=0.0.0.0" - "--rpc.port=8547" - "--rpc.enable-admin" - "--log.level=info" - "--log.format=json" ``` <Info> A few flags worth understanding: * `--chain=/workspace/genesis.json` points op-reth at the genesis file generated by op-deployer. Unlike op-geth, op-reth needs no separate `init` step — it initializes its database from the chain spec on first startup. * `--l2.enginekind=reth` tells op-node it is driving a reth-based execution client. * `--rollup.disable-tx-pool-gossip` is the op-reth equivalent of op-geth's `--rollup.disabletxpoolgossip=true`. * `--builder.deadline=2` and `--builder.interval=100ms` tune op-reth's block builder for the 2-second L2 block time (the defaults target Ethereum's 12-second slots). * op-reth runs as an archive node by default, so there is no `--gcmode=archive` equivalent to set. </Info> <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> </Step> <Step title="Start the services"> ```bash theme={null} # Start both services docker-compose up -d # View logs docker-compose logs -f ``` </Step> <Step title="Final directory structure"> ```bash theme={null} rollup/ ├── deployer/ # From previous step │ └── .deployer/ # Contains genesis.json and rollup.json └── sequencer/ # You are here ├── jwt.txt # Generated JWT secret ├── genesis.json # Copied from deployer ├── rollup.json # Copied from deployer ├── .env # Environment variables ├── docker-compose.yml # Docker configuration ├── opnode_discovery_db/ # Created by Docker ├── opnode_peerstore_db/ # Created by Docker └── op-reth-data/ # Created by Docker (op-reth database) ``` Your sequencer node is now operational and ready to process transactions. </Step> </Steps> </Tab> <Tab title="Build from source"> To ensure you're using the latest compatible versions of OP Stack components, always check the official [release page](https://github.com/ethereum-optimism/optimism/releases). The main components you'll need for sequencer deployment are: * `op-node`: Look for the latest `op-node/v*` [release](https://github.com/ethereum-optimism/optimism/releases?q=op-node) * `op-reth`: Look for the latest `op-reth/v*` [release](https://github.com/ethereum-optimism/optimism/releases?q=op-reth) Both components live in the [optimism monorepo](https://github.com/ethereum-optimism/optimism). Building op-node requires [Go](https://go.dev/dl/) and [just](https://github.com/casey/just); building op-reth requires a [Rust toolchain](https://rustup.rs/) (the build picks up the version pinned in `rust/rust-toolchain.toml` automatically). Building from source gives you full control over the binaries. <Steps> <Step title="Clone and build op-node"> ```bash theme={null} # Clone the optimism monorepo git clone https://github.com/ethereum-optimism/optimism.git cd optimism # Checkout the latest op-node release tag git checkout op-node/v1.19.3 # Generate the embedded superchain config bundle (initializes the # superchain-registry submodule; op-node embeds this file at compile time) just build-superchain-go # Build op-node cd op-node just # Binary will be available at ./bin/op-node cd .. ``` </Step> <Step title="Build op-reth"> ```bash theme={null} # Still inside the optimism monorepo: # checkout the latest op-reth release tag git checkout op-reth/v2.4.0 # Sync the superchain-registry submodule to this tag # (the op-reth build generates its chain configs from it) just update-superchain-registry-submodule # Build op-reth (release build; this can take a while) cd rust cargo build --release --bin op-reth # Binary will be available at ./target/release/op-reth cd .. ``` <Info> op-node and op-reth release from the same repository on different tags, so the two builds check out different tags in sequence. The `--version` checks below confirm what you actually built. If you prefer, use two separate clones of the monorepo instead. </Info> </Step> <Step title="Verify installation"> Check that you have properly installed the needed components. ```bash theme={null} # From the optimism monorepo root ./op-node/bin/op-node --version ./rust/target/release/op-reth --version ``` </Step> </Steps> ## Configuration setup <Steps> <Step title="Organize your workspace"> After building the binaries, you should have the following directory structure: ```bash theme={null} rollup/ ├── deployer/ # From previous step │ └── .deployer/ # Contains genesis.json and rollup.json └── optimism/ # Optimism monorepo ├── op-node/ │ └── bin/ │ └── op-node └── rust/ └── target/ └── release/ └── op-reth ``` Now create your sequencer working directory: ```bash theme={null} cd ../ mkdir sequencer cd sequencer ``` </Step> <Step title="Generate JWT secret"> ```bash theme={null} openssl rand -hex 32 > jwt.txt chmod 600 jwt.txt ``` </Step> <Step title="Set up directory structure and copy files"> ```bash theme={null} mkdir scripts cp ../deployer/.deployer/genesis.json . cp ../deployer/.deployer/rollup.json . ``` </Step> <Step title="Environment variables"> You'll need to gather several pieces of information before creating your configuration. </Step> <Step title="Get L1 network access"> You need access to the L1 network (Ethereum mainnet or Sepolia testnet) and its beacon node. **L1 RPC URL options:** * **Infura**: [infura.io](https://infura.io) * **Alchemy**: [alchemy.com](https://alchemy.com) **L1 Beacon URL options:** * `https://ethereum-sepolia-beacon-api.publicnode.com` * `https://ethereum-beacon-api.publicnode.com` </Step> <Step title="Get private key from your wallet"> For this basic sequencer setup, you only need a private key during op-node initialization. </Step> <Step title="Get your public IP address"> ```ba
프로젝트로 돌아가기