Optimism 백서

Optimism

원문

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

hosted on a web server, you can simply provide the URL to the directory containing those files: ```bash theme={null} docker run -d --name op-challenger \ -e OP_CHALLENGER_TRACE_TYPE=permissioned,cannon \ -e OP_CHALLENGER_PRESTATES_URL=<HTTP_URL_PATH_TO_PRESTATE> \ -e OP_CHALLENGER_L1_ETH_RPC=<YOUR_L1_RPC_URL> \ -e OP_CHALLENGER_GAME_FACTORY_ADDRESS=<YOUR_DISPUTE_GAME_FACTORY> \ -e OP_CHALLENGER_PRIVATE_KEY=<YOUR_PRIVATE_KEY_OR_USE_WALLET_SIGNER> \ -e OP_CHALLENGER_NETWORK=<YOUR_NETWORK> \ -e OP_CHALLENGER_CANNON_ROLLUP_CONFIG=<PATH_TO_ROLLUP_CONFIG> \ -e OP_CHALLENGER_CANNON_L2_GENESIS=<PATH_TO_GENESIS_CONFIG> \ us-docker.pkg.dev/oplabs-tools-artifacts/images/op-challenger:latest ``` <Info> When using an HTTP URL, no volume mount is required. The challenger will download the prestate files as needed. </Info> </Step> <Step title="Option 2: Using local files"> If you have prestate files stored locally, you'll need to mount them as a volume and use the `file://` protocol: ```bash theme={null} docker run -d --name op-challenger \ -e OP_CHALLENGER_TRACE_TYPE=permissioned,cannon \ -e OP_CHALLENGER_PRESTATES_URL=file:///prestates \ -e OP_CHALLENGER_L1_ETH_RPC=<YOUR_L1_RPC_URL> \ -e OP_CHALLENGER_GAME_FACTORY_ADDRESS=<YOUR_DISPUTE_GAME_FACTORY> \ -e OP_CHALLENGER_PRIVATE_KEY=<YOUR_PRIVATE_KEY_OR_USE_WALLET_SIGNER> \ -e OP_CHALLENGER_NETWORK=<YOUR_NETWORK> \ -e OP_CHALLENGER_CANNON_ROLLUP_CONFIG=<PATH_TO_ROLLUP_CONFIG> \ -e OP_CHALLENGER_CANNON_L2_GENESIS=<PATH_TO_GENESIS_CONFIG> \ -v /path/to/local/prestates:/prestates \ us-docker.pkg.dev/oplabs-tools-artifacts/images/op-challenger:latest ``` <Info> When using local files, ensure your prestate files are in the mounted directory and properly named with their hash (e.g., `0x03eb07101fbdeaf3f04d9fb76526362c1eea2824e4c6e970bdb19675b72e4fc8.bin.gz`). </Info> </Step> </Steps> <Info> * Ensure you're using the latest op-challenger version, see the [release page](https://github.com/ethereum-optimism/optimism/releases). * If your chain uses interoperability features, you'll need to add a `depsets.json` file to the `op-program/chainconfig/configs` directory. * This file contains dependency set configurations. Use the same dependency set definition your interop-enabled chain is already configured with. </Info> ## Next steps * Check out the [migrating to permissionless fault proofs guide](/chain-operators/tutorials/migrating-permissionless). * Read the [Fault proofs explainer](/op-stack/fault-proofs/explainer). # L2 Rollup Code Examples Source: https://docs.optimism.io/chain-operators/tutorials/create-l2-rollup/code-setup Complete working code examples for the Create L2 Rollup tutorial This page contains complete working code examples for the Create L2 Rollup tutorial. You can find all the code and configuration files in the [create-l2-rollup-example directory](https://github.com/ethereum-optimism/optimism/tree/develop/docs/public-docs/create-l2-rollup-example/). <Info> For the complete working implementation, visit the [Create L2 Rollup code on GitHub](https://github.com/ethereum-optimism/optimism/tree/develop/docs/public-docs/create-l2-rollup-example/). </Info> ## Quick Start ```bash theme={null} # Copy and configure environment cp .example.env .env # Edit .env with your values # Run the automated setup make init # Download tools make setup # Deploy and configure make up # Start services ``` ## Files * `.example.env` - Environment configuration template * `docker-compose.yml` - Service orchestration * `Makefile` - Automation commands * `scripts/` - Setup and utility scripts * `README.md` - Detailed documentation ## About This Code This implementation provides: * Automated deployment of OP Stack L2 contracts * Complete Docker-based service orchestration * Working examples of all OP Stack components * Production-ready configuration patterns For detailed setup instructions, see the [Create L2 Rollup tutorial](/chain-operators/tutorials/create-l2-rollup). # Creating your own L2 rollup testnet Source: https://docs.optimism.io/chain-operators/tutorials/create-l2-rollup/index Learn how to deploy and orchestrate all OP Stack components for a complete testnet deployment. <Info> **Learn the OP Stack — stop 6 of 14.** You've covered the foundations: what the stack is, how it differs from Ethereum, and which components make it up. In this first project you deploy a rollup testnet with op-deployer and start each component yourself. Work through every part of the series, then continue to [Transaction flow](/op-stack/transactions/transaction-flow). </Info> Welcome to the complete guide for deploying your own OP Stack L2 rollup testnet. This multi-part tutorial will walk you through each component step-by-step, from initial setup to a fully functioning rollup. <Info> This tutorial requires **intermediate-level experience working with EVM chains**. You should be comfortable with concepts like smart contracts, private keys, RPC endpoints, gas fees, and command-line operations. Basic familiarity with Docker is also recommended. </Info> ## What you'll build By the end of this tutorial, you'll have a complete OP Stack testnet with: * **L1 Smart Contracts** deployed on Sepolia testnet * **Execution Client** (op-reth) processing transactions * **Consensus Client** (op-node) managing rollup consensus * **Batcher** (op-batcher) publishing transaction data to L1 * **Proposer** (op-proposer) submitting state root proposals * **Challenger** (op-challenger) monitoring for disputes ## Before you start Set up the following before you pick a setup path below. Both the automated and manual paths need these dependencies and resources. ### Software dependencies | Dependency | Version | Version check command | | - | - | - | | [git](https://git-scm.com/) | `^2` | `git --version` | | [go](https://go.dev/) | `^1.26` | `go version` | | [rust](https://rustup.rs/) (source builds only) | pinned by `rust/rust-toolchain.toml` | `rustc --version` | | [just](https://github.com/casey/just) (source builds only) | `^1` | `just --version` | | [zip](https://infozip.sourceforge.net/) (source builds only) | `^3` | `zip --version` | | [node](https://nodejs.org/en/) | `^20` | `node --version` | | [pnpm](https://pnpm.io/installation) | `^8` | `pnpm --version` | | [foundry](https://github.com/foundry-rs/foundry#installation) | `^0.2.0` | `forge --version` | | [make](https://linux.die.net/man/1/make) | `^3` | `make --version` | | [jq](https://github.com/jqlang/jq) | `^1.6` | `jq --version` | | [direnv](https://direnv.net) | `^2` | `direnv --version` | | [Docker](https://docs.docker.com/get-docker/) | `^24` | `docker --version` | ### Notes on specific dependencies <Info> Expand each dependency below for details </Info> <Accordion title="node"> We recommend using the latest LTS version of Node.js (currently v20).\ [`nvm`](https://github.com/nvm-sh/nvm) is a useful tool that can help you manage multiple versions of Node.js on your machine.\ You may experience unexpected errors on older versions of Node.js. </Accordion> <Accordion title="foundry"> We will use cast to generate wallet addresses in this guide. </Accordion> <Accordion title="direnv"> Parts of this tutorial use [`direnv`](https://direnv.net) as a way of loading environment variables from `.envrc` files into your shell.\ This means you won't have to manually export environment variables every time you want to use them.\ `direnv` only ever has access to files that you explicitly allow it to see. After [installing `direnv`](https://direnv.net/docs/installation.html), you will need to **make sure that [`direnv` is hooked into your shell](https://direnv.net/docs/hook.html)**.\ Make sure you've followed [the guide on the `direnv` website](https://direnv.net/docs/hook.html), then **close your terminal and reopen it** so that the changes take effect (or `source` your config file if you know how to do that). <Info> Make sure that you have correctly hooked `direnv` into your shell by modifying your shell configuration file (like `~/.bashrc` or `~/.zshrc`).\ If you haven't edited a config file then you probably haven't configured `direnv` properly (and things might not work later). </Info> </Accordion> <Accordion title="Docker"> Docker is used extensively in this tutorial for running various OP Stack components.\ Make sure you have both Docker and Docker Compose installed and running on your system.\ On Linux, you may need to [configure Docker to run without sudo](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user). <Info> If you're using Docker Desktop, ensure it's running before starting the tutorial.\ You can verify your installation with: ```bash theme={null} docker run hello-world ``` </Info> </Accordion> ### Get access to a sepolia node Since you're deploying your OP Stack chain to Sepolia, you'll need to have access to a Sepolia node. You can either use a node provider like [Alchemy](https://www.alchemy.com/) (easier) or run your own Sepolia node (harder). ### Required resources * **Sepolia ETH** - You'll need about 2-3 ETH: * Start with [Superchain Faucet](https://console.optimism.io/faucet) (gives 0.05 ETH) * Get more from: * [Alchemy Faucet](https://sepoliafaucet.com/) * [Infura Faucet](https://www.infura.io/faucet/sepolia) * [Paradigm Faucet](https://faucet.paradigm.xyz/) * **L1 RPC URL** - An RPC endpoint to connect to the Sepolia network. You can get this from node providers like [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/). This is required so `op-deployer` and other services can read from and send transactions to L1. <Info> **Testnet Only**: This guide is for **testnet deployment only**. </Info> ## Choose your path With your dependencies and resources in place, pick the path that fits how you want to work: * **[Automated setup](#automated-setup)** — the fastest way to a running rollup. Uses the complete working implementation in this repository and handles all configuration and deployment for you. * **[Manual setup](#manual-setup)** — walks through each component step-by-step. Choose this if you want to understand each component in detail or need custom configurations. ## Automated setup If you want to get started quickly, you can use the complete working implementation provided in this repository. This automated setup handles all the configuration and deployment steps for you. <Info> **Complete working example** A complete, working implementation is available in the [`create-l2-rollup-example/`](https://github.com/ethereum-optimism/optimism/tree/develop/docs/public-docs/create-l2-rollup-example/) directory. This includes all necessary scripts, Docker Compose configuration, and example environment files. </Info> ### Automated setup steps 1. **Clone and navigate to the code directory:** ```bash theme={null} git clone https://github.com/ethereum-optimism/optimism.git cd optimism/docs/public-docs/create-l2-rollup-example ``` 2. **Configure your environment:** ```bash theme={null} cp .example.env .env # Edit .env with your L1_RPC_URL, PRIVATE_KEY, and other settings ``` 3. **Run the automated setup:** ```bash theme={null} make init # Download op-deployer make setup # Deploy contracts and generate configs make up # Start all services make test-l1 # Verify L1 connectivity make test-l2 # Verify L2 functionality ``` 4. **Monitor your rollup:** ```bash theme={null} make logs # View all service logs make status # Check service health ``` The automated setup uses the standard OP Stack environment variable conventions (prefixed with `OP_*`) and handles all the complex configuration automatically. ## Manual setup If you prefer to understand each component in detail or need custom configurations, follow the step-by-step guide below. Each step builds on the previous one, so complete them in order for the best experience. ### Directory structure To keep your rollup deployment organized, we'll create a dedicated directory structure. All components will be set up within this structure: ```bash theme={null} rollup/ ├── deployer/ # op-deployer files and contracts ├── sequencer/ # op-reth and op-node ├── batcher/ # op-batcher configuration ├── proposer/ # op-proposer setup └── challenger/ # op-challenger files ``` Each component's documentation will show you how the directory structure evolves as you add files and configurations. <Info> Throughout this tutorial, all file paths will be relative to this `rollup` directory structure. Make sure to adjust any commands if you use different directory names. </Info> ### Manual setup steps The manual path is organized into sequential steps that build upon each other: <Steps> <Step title="Spin up op-deployer"> Install op-deployer, deploy L1 contracts, and prepare your environment [Go to op-deployer setup →](/chain-operators/tutorials/create-l2-rollup/op-deployer-setup) </Step> <Step title="Spin up sequencer"> Set up and run op-reth and op-node (the execution and consensus layers) [Go to sequencer setup →](/chain-operators/tutorials/create-l2-rollup/op-reth-setup) </Step> <Step title="Spin up batcher"> Configure and start op-batcher for L1 data publishing [Go to batcher setup →](/chain-operators/tutorials/create-l2-rollup/op-batcher-setup) </Step> <Step title="Spin up proposer"> Set up op-proposer for state root submissions [Go to proposer setup →](/chain-operators/tutorials/create-l2-rollup/op-proposer-setup) </Step> <Step title="Spin up challenger"> Configure op-challenger for dispute resolution monitoring [Go to challenger setup →](/chain-operators/tutorials/create-l2-rollup/op-challenger-setup) </Step> </Steps> <Card title="Spin up op-deployer" href="/chain-operators/tutorials/create-l2-rollup/op-deployer-setup"> Already have your dependencies? Get started and spin up op-deployer </Card> *** ## Need help? * **Questions or issues**: Ask questions or report bugs and docs problems on the [Optimism monorepo issue tracker](https://github.com/ethereum-optimism/optimism/issues) * **Code examples**: Browse the [complete working example](/chain-operators/tutorials/create-l2-rollup/code-setup) that accompanies this tutorial # Spin up batcher Source: https://docs.optimism.io/chain-operators/tutorials/create-l2-rollup/op-batcher-setup Learn how to set up and configure an OP Stack batcher to submit L2 transaction batches to L1. After you have spun up your sequencer, you need to configure a batcher to submit L2 transaction batches to L1. <Info> **Step 3 of 5**: This tutorial is designed to be followed step-by-step. Each step builds on the [previous one](/chain-operators/tutorials/create-l2-rollup/op-reth-setup). </Info> <Info> **Automated Setup Available** For a complete working setup with all components, check out the [automated approach](https://github.com/ethereum-optimism/optimism/tree/develop/docs/public-docs/create-l2-rollup-example/) in the code directory. </Info> ## Understanding the batcher's role The batcher (`op-batcher`) serves as a crucial component that bridges your L2 chain data to L1. Its primary responsibilities include: * **Batch submission**: Collecting L2 transactions and submitting them as batches to L1 * **Data availability**: Ensuring L2 transaction data is available on L1 for verification * **Cost optimization**: Compressing and efficiently packing transaction data to minimize L1 costs * **Channel management**: Managing data channels for optimal batch submission timing The batcher reads transaction data from your sequencer and submits compressed batches to the `BatchInbox` contract on L1. ## Prerequisites Before setting up your batcher, ensure you have: **Running infrastructure:** * An operational sequencer node * Access to a L1 RPC endpoint **Network information:** * Your L2 chain ID and network configuration * L1 network details (chain ID, RPC endpoints) * `BatchInbox` contract address from your deployment For setting up the batcher, we recommend using Docker as it provides a consistent and isolated environment. Building from source is also available for more advanced users. <Tabs> <Tab title="Use docker"> If you prefer containerized deployment, you can use the official Docker images and do the following: <Steps> <Step title="Set up directory structure and copy configuration files"> ```bash theme={null} # Create your batcher directory inside rollup cd ../ # Go back to rollup directory if you're in sequencer mkdir batcher cd batcher # Copy configuration files from deployer cp ../deployer/.deployer/state.json . # Extract the BatchInbox address BATCH_INBOX_ADDRESS=$(cat state.json | jq -r '.opChainDeployments[0].systemConfigProxyAddress') echo "BatchInbox Address: $BATCH_INBOX_ADDRESS" ``` </Step> <Step title="Create environment variables file"> <Info> **OP Stack Standard Variables** The batcher uses OP Stack standard environment variables following the OP Stack conventions. These are prefixed with `OP_BATCHER_` for batcher-specific settings. </Info> ```bash theme={null} # Create .env file with your actual values cat > .env << 'EOF' # L1 Configuration - Replace with your actual RPC URLs OP_BATCHER_L1_RPC_URL=https://sepolia.infura.io/v3/YOUR_ACTUAL_INFURA_KEY # Private key - Replace with your actual private key OP_BATCHER_PRIVATE_KEY=YOUR_ACTUAL_PRIVATE_KEY # L2 Configuration - Should match your sequencer setup OP_BATCHER_L2_ETH_RPC=http://op-reth:8545 OP_BATCHER_ROLLUP_RPC=http://op-node:8547 # Contract addresses - Extract from your op-deployer output OP_BATCHER_BATCH_INBOX_ADDR=YOUR_ACTUAL_BATCH_INBOX_ADDRESS # Batcher configuration OP_BATCHER_POLL_INTERVAL=1s OP_BATCHER_SUB_SAFETY_MARGIN=6 OP_BATCHER_NUM_CONFIRMATIONS=1 OP_BATCHER_SAFE_ABORT_NONCE_TOO_LOW_COUNT=3 OP_BATCHER_MAX_CHANNEL_DURATION=1 OP_BATCHER_DATA_AVAILABILITY_TYPE=calldata # RPC configuration OP_BATCHER_RPC_PORT=8548 EOF ``` **Important**: Replace ALL placeholder values (`YOUR_ACTUAL_*`) with your real configuration values. </Step> <Step title="Create a docker-compose.yml file"> <Info> This configuration assumes your sequencer is running in a Docker container named `sequencer-node` on the same `op-stack` network. Make sure your sequencer is running before starting the batcher. </Info> ```yaml theme={null} services: op-batcher: image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:v1.16.11 volumes: - .:/workspace working_dir: /workspace ports: - "8548:8548" env_file: - .env networks: - sequencer-node_default command: > op-batcher --rpc.addr=0.0.0.0 --rpc.enable-admin --resubmission-timeout=30s --log.level=info --log.format=json restart: unless-stopped networks: sequencer-node_default: external: false ``` </Step> <Step title="Start the batcher service"> ```bash theme={null} # Make sure your sequencer network exists # Start the batcher docker-compose up -d # View logs docker-compose logs -f op-batcher ``` </Step> <Step title="Verify batcher is running"> ```bash theme={null} # Check container status docker-compose ps ``` </Step> <Step title="Final directory structure"> ```bash theme={null} rollup/ ├── deployer/ # From previous step │ └── .deployer/ # Contains genesis.json and rollup.json ├── sequencer/ # From previous step └── batcher/ # You are here ├── state.json # Copied from deployer ├── .env # Environment variables └── docker-compose.yml # Docker configuration ``` </Step> </Steps> Your batcher is now operational and will continuously submit L2 transaction batches to L1! </Tab> <Tab title="Build from source"> 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-batcher/v*` release that's compatible with
프로젝트로 돌아가기