Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active February 28, 2023 02:10
Show Gist options
  • Save miguelmota/973e62c8f3da0571fc2c469b65c54d71 to your computer and use it in GitHub Desktop.
Save miguelmota/973e62c8f3da0571fc2c469b65c54d71 to your computer and use it in GitHub Desktop.
Deploy custom Optimism rollup instructions

Instructions

Unofficial guide on deploying a custom Optimism rollup on Kovan

⚠️ Notice: Guide updated April 2021. Check out the Optimism discord for additional help and support.

Clone optimism contracts:

git clone git@github.com:ethereum-optimism/optimism.git
cd optimism/packages/contracts/

Build optimism contracts:

yarn
yarn build:kovan

Deploy optimism contracts to kovan (replace YOUR_PRIVATE_KEY and L1_NODE_WEB3_URL to your own):

DEPLOYER_PRIVATE_KEY=YOUR_PRIVATE_KEY \
SEQUENCER_PRIVATE_KEY=YOUR_PRIVATE_KEY \
L1_NODE_WEB3_URL=https://kovan.infura.io/v3/PROJECT_ID \
WAIT_FOR_RECEIPTS=true \
WHITELIST_ALLOW_ARBITRARY_CONTRACT_DEPLOYMENT=true \
CHAIN_ID=420 \
RELAYER_PRIVATE_KEY=YOUR_PRIVATE_KEY \
MAX_TRANSACTION_GAS_LIMIT=9000000 \
MIN_TRANSACTION_GAS_LIMIT=0 \
FRAUD_PROOF_WINDOW_SECONDS=604800 \
yarn deploy

The deployment script will write a JSON file to dist/dumps/addresses.json with the contract addresses (your addresses will be different):

{
  "AddressManager": "0xf920d5576C96e9b89f329146b6Cc3E6c6Bb9d614",
  "OVM_CanonicalTransactionChain": "0x6Da275Dcaa1e90B07f0BFff245067d706E16c2F5",
  "OVM_ChainStorageContainer:CTC:batches": "0x885DfCeF2fDb61e05531d8898FE26aC75c64aD86",
  "OVM_ChainStorageContainer:CTC:queue": "0x32692c512D98780545b619b837ae254c7cde4D31",
  "OVM_ChainStorageContainer:SCC:batches": "0x0577A1dC50e93e14c94B11816e152F10C54388Ab",
  "OVM_ExecutionManager": "0x2A01739daDE5450283b605c9aea91a1CF9303972",
  "OVM_FraudVerifier": "0x448E3876e06e58283094090D1752feeA52E05021",
  "OVM_L1CrossDomainMessenger": "0xE5a1BD7476Ea1E9105A7e1e82226207853b52fDB",
  "OVM_L1ETHGateway": "0x64974Ae6b99B0803C1d8e0528E49BeF0F2344f6D",
  "OVM_L1MultiMessageRelayer": "0xCdD55f0e27478eBf4297684d0f262D5b367A1043",
  "OVM_SafetyChecker": "0x215FaA481B191Fe714a7DBaaf968F25871298BC1",
  "OVM_StateCommitmentChain": "0xEA5405f789b3A98BFDeae8E7aBeeA2C066006dE7",
  "OVM_StateManagerFactory": "0x29f1D16Ecc7Fc0e791c1525D7e3385016B9FA671",
  "OVM_StateTransitionerFactory": "0x47994998cAf4383fe9b145AbBf2bbF17BCe0Ebe9",
  "Proxy__OVM_L1CrossDomainMessenger": "0x206DdaDE27215137ebC67f66948cD5384a0ff8Fe",
  "Proxy__OVM_L1ETHGateway": "0xc17b9807De38004cf4EFd4AA69A31aA74a3c74D4",
  "OVM_BondManager": "0x0db9aDf5fB972503076c2A12F751a54D0EcE4352"
}

Create docker-compose.yml:

version: '3'

services:
  geth_l2:
    image: ethereumoptimism/go-ethereum:latest
    restart: unless-stopped
    volumes:
      - geth:/root/.ethereum:rw
    env_file:
      - docker-compose.env
    ports:
      - 8545:8545
      - 8546:8546

  batch_submitter:
    image: ethereumoptimism/batch-submitter:latest
    restart: unless-stopped
    env_file:
      - docker-compose.env

  data_transport_layer:
    image: ethereumoptimism/data-transport-layer:latest
    restart: unless-stopped
    env_file:
      - docker-compose.env
    ports:
      - 7878:7878

volumes:
  geth:

Create docker-compose.env (replace YOUR_PRIVATE_KEY, YOUR_PRIVATE_KEY_ADDRESS, YOUR_ADDRESS_MANAGER_ADDRESS, _YOUR_PROXY_OVM_L1_CROSS_DOMAIN_MESSENGER_ADDRESS to your own)

######### L2 GETH VARS #########
CHAIN_ID=420
NETWORK_ID=420
DEV=true
DATADIR=/root/.ethereum
RPC_ENABLE=true
RPC_ADDR=geth_l2
RPC_CORS_DOMAIN='*'
RPC_VHOSTS='*'
RPC_PORT=8545
WS=true
WS_ADDR=0.0.0.0
WS_PORT=8546
IPC_DISABLE=true
TARGET_GAS_LIMIT=9000000
RPC_API='eth,net,rollup,web3'
WS_API='eth,net,rollup,web3'
WS_ORIGINS='*'
GASPRICE=0
NO_USB=true
GCMODE=archive
NO_DISCOVER=true
USING_OVM=true

ETH1_SYNC_SERVICE_ENABLE=true
ETH1_CTC_DEPLOYMENT_HEIGHT=24400000
ETH1_HTTP=https://kovan.infura.io/v3/PROJECT_ID
ETH1_CONFIRMATION_DEPTH=1
ETH1_CHAINID=42
ETH1_NETWORKID=42

# This is "AddressManager" address from deployed contracts
ETH1_ADDRESS_RESOLVER_ADDRESS=YOUR_ADDRESS_MANAGER_ADDRESS

# This is "Proxy__OVM_L1CrossDomainMessenger" address from deployed contracts
ETH1_L1_CROSS_DOMAIN_MESSENGER_ADDRESS=YOUR_PROXY_OVM_L1_CROSS_DOMAIN_MESSENGER_ADDRESS

# This should be public address of private key that deployed contracts
ROLLUP_ADDRESS_MANAGER_OWNER_ADDRESS=YOUR_PRIVATE_KEY_ADDRESS

ROLLUP_STATE_DUMP_PATH=https://raw.githubusercontent.com/ethereum-optimism/regenesis/master/kovan/2.json
ROLLUP_DIFFDB_CACHE=1
ROLLUP_CLIENT_HTTP=http://data_transport_layer:7878

######### Batch Submitter #########
# Logging
DEBUG=info*,error*,warn*,debug*
DEPLOYER_PRIVATE_KEY=YOUR_PRIVATE_KEY
SEQUENCER_PRIVATE_KEY=YOUR_PRIVATE_KEY
TX_INGESTION_SIGNER_KEY=YOUR_PRIVATE_KEY
TX_INGESTION_SIGNER_ADDRESS=YOUR_PRIVATE_KEY_ADDRESS
MAX_TX_SIZE=90000
MIN_TX_SIZE=0
MAX_BATCH_SIZE=50
POLL_INTERVAL=15000
NUM_CONFIRMATIONS=1
RESUBMISSION_TIMEOUT=1000000
FINALITY_CONFIRMATIONS=1
RUN_TX_BATCH_SUBMITTER=true
RUN_STATE_BATCH_SUBMITTER=true
MAX_BATCH_SUBMISSION_TIME=1000000
SAFE_MINIMUM_ETHER_BALANCE=0
MAX_L1_TX_SIZE=90000
MIN_L1_TX_SIZE=0
MAX_TX_BATCH_COUNT=50
MAX_STATE_BATCH_COUNT=50

L1_NODE_WEB3_URL=https://kovan.infura.io/v3/PROJECT_ID
L2_NODE_WEB3_URL=http://geth_l2:8545
CLEAR_PENDING_TXS=false

ADDRESS_MANAGER_ADDRESS=YOUR_ADDRESS_MANAGER_ADDRESS

# Data transport layer
DATA_TRANSPORT_LAYER__SYNC_FROM_L1=true
DATA_TRANSPORT_LAYER__SYNC_FROM_L2=false
DATA_TRANSPORT_LAYER__L2_RPC_ENDPOINT=http://geth_l2:8545
DATA_TRANSPORT_LAYER__L2_CHAIN_ID=420
DATA_TRANSPORT_LAYER__DB_PATH=/db
DATA_TRANSPORT_LAYER__SERVER_PORT=7878
DATA_TRANSPORT_LAYER__TRANSACTIONS_PER_POLLING_INTERVAL=1000
DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT=https://kovan.infura.io/v3/PROJECT_ID
DATA_TRANSPORT_LAYER__CONFIRMATIONS=1
DATA_TRANSPORT_LAYER__POLLING_INTERVAL=500
DATA_TRANSPORT_LAYER__LOGS_PER_POLLING_INTERVAL=2000
DATA_TRANSPORT_LAYER__DANGEROUSLY_CATCH_ALL_ERRORS=true
DATA_TRANSPORT_LAYER__SERVER_HOSTNAME=0.0.0.0
DATA_TRANSPORT_LAYER__ADDRESS_MANAGER=YOUR_ADDRESS_MANAGER_ADDRESS
RETRIES=50

Run docker compose services:

docker-compose up

L2 node will be accessible on http://localhost:8545

L2 messenger will be 0x4200000000000000000000000000000000000007 (see this readme)

@miguelmota
Copy link
Author

Guide has been updated based on latest changes. Thanks @rphansen91 @taijusanagi

@ducnh1022
Copy link

is there any update.
I got error when run "yarn build:kovan"

error Command "build:copy" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment