πŸŒ…
Sunrise / Gluon Docs
  • Home
    • πŸ‘‹Sunrise
  • πŸ“œLearn
    • πŸŒ†Sunrise
      • Proof of Liquidity
      • Fee Abstraction
      • Data Availability
      • Gauges Voting
      • Liquidity Pool
      • Liquidity Incentive
      • Swap
      • TokenConverter
      • Fee
      • Lockup Account
      • Bribes
    • πŸ’΄$RISE
      • Allocations
    • 🏦Gluon
    • πŸ’΄$GLU
    • πŸŽ“Thesis
      • App chain thesis
      • Interoperability
  • πŸ› οΈBuild
    • πŸš€Quick Start
    • Client
    • L2 Blockchains
      • Rollkit
        • Sunrise Data
        • Rollkit L2 Chain
      • OP Stack
        • Sunrise Data
        • OP Stack L2 Chain
    • Validators
      • Proof of Data Availability
      • Self Delegation
  • πŸ—οΈRun a Sunrise Node
    • Networks
    • Types of Nodes
      • Consensus
        • Full Consensus Node
        • Validator Node (Genesis)
        • Validator Node
        • Setup Cosmovisor
      • IBC Relayers
    • Resources
      • Upgrade
      • Environment
  • πŸ—οΈRun a Gluon Node
    • Networks
    • Node
      • Validator Node
  • πŸ”—Links
    • GitHub
    • Discord
    • X (Twitter)
    • Medium
    • dev.to
  • πŸ““Deprecated (UnUniFi)
    • IBC Channels
    • Security
    • CosmWasm
      • Tutorial
      • Create Project
    • IYA Strategy
      • Interface
      • External CosmWasm chain with IBCHooks
      • External EVM chain with Axelar
    • Frontend
      • Cosmos Client TS
    • Resources
    • Setup ununifid
    • ununifid
      • Basic Commands
      • Module Commands
        • wasm
    • Build a Node
    • Build a Validator Node
    • Setup Cosmovisor
    • Mainnet Upgrades
    • IBC Relayer
Powered by GitBook
On this page
  • How to set up OP Stack
  • Dependencies
  • Set up Optimism Rollup Testnet
  • Optimism
  • Start L2
  1. Build
  2. L2 Blockchains
  3. OP Stack

OP Stack L2 Chain

PreviousSunrise DataNextValidators

Last updated 1 month ago

Sunrise's Data Availability Layer supports Layer 2 blockchains created using This is a guide to connecting an L2 chain created using OP Stack to Sunrise chain with . Data Availability layer is supported in Sunrise v0.3.0 and later.

This version of the OP Stack requires the L1 EVM chain for operation. Use some kind of testnet or local chain.

How to set up OP Stack

As an example, here is how to use OP Stack to create an L2 chain and run it on the Sunrise's Data Availability Layer.

This guide uses the Ethereum Sepolia testnet to meet the OP Stack requirements, but a local EVM chain will also work.

Dependencies

Dependencies and general installation instructions for Ubuntu 22.04.

  • node

      curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt-get install -y nodejs
  •   curl -fsSL https://get.pnpm.io/install.sh | sh -
  •   curl -L https://foundry.paradigm.xyz | bash
  • just

      wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
      echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
      sudo apt update
      sudo apt install just

Set up Optimism Rollup Testnet

Optimism

  1. Clone the optimism repo

    git clone https://github.com/ethereum-optimism/optimism.git
  2. Check out the correct branch

    cd optimism
    git checkout v1.9.1

γ€€We have confirmed the operation with the latest version at the time of document update. If you use other versions, please check the differences.

  1. Run the following to check you have all dependencies

    ./packages/contracts-bedrock/scripts/getting-started/versions.sh
  2. Build all packages associated with Optimism

    make op-node op-batcher op-proposer

    If you are having issues with this step, make sure your versions match those in the optimism docs. Specifically, you may have to downgrade your go version.

  3. Clone and build op-geth

    cd ~
    git clone https://github.com/ethereum-optimism/op-geth.git
    cd op-geth
    make geth
  1. Fill out environment variables

    cd ~/optimism
    cp .envrc.example .envrc

    Run the script to generate addresses with the following command in the optimism repo: ./packages/contracts-bedrock/scripts/getting-started/wallets.sh

    The output will look like the following which will you need to paste into the environment file as well:

    ##################################################
    #                 Getting Started                #
    ##################################################
    
    # Admin account
    export GS_ADMIN_ADDRESS=0x82eeB61600f290ce3F9400d345aAEcBe5faF7AEB
    export GS_ADMIN_PRIVATE_KEY=0x7c726817d047ee62cbb060312fe2620ba5462495e34f7e8279ba22faa96bca20
    
    # Batcher account
    export GS_BATCHER_ADDRESS=0x7BECbC4C747922d92e4F917951D9D8c3Ada7eb60
    export GS_BATCHER_PRIVATE_KEY=0xc7dfaa7b8449f00480196377da50d29318b2397fd0296d0ab4f11d48ee3cf723
    
    # Proposer account
    export GS_PROPOSER_ADDRESS=0x773F4527fECc889d6DD3Cd7d044F4AC1Ad765a31
    export GS_PROPOSER_PRIVATE_KEY=0xed6029a5928e83c5d2a28d9574304bae9a825e19f7f18a50d34edc13b505afed
    
    # Sequencer account
    export GS_SEQUENCER_ADDRESS=0x2B43c41FCbabc5437A6E1B97F47cA085a4B16f61
    export GS_SEQUENCER_PRIVATE_KEY=0x0a7d4ce467fe4d00b8930215c98335e06c16db34cd501c8c3f3173015487662e
    
    ##################################################
    #                Chain Information               #
    ##################################################
    
    # L1 chain information
    export L1_CHAIN_ID=11155111
    export L1_BLOCK_TIME=12
    
    # L2 chain information
    export L2_CHAIN_ID=42069
    export L2_BLOCK_TIME=2
    
    ##################################################
    #              op-node Configuration             #
    ##################################################
    
    # The kind of RPC provider, used to inform optimal transactions receipts
    # fetching. Valid options: alchemy, quicknode, infura, parity, nethermind,
    # debug_geth, erigon, basic, any.
    export L1_RPC_KIND=infura
    
    ##################################################
    #               Contract Deployment              #
    ##################################################
    
    # RPC URL for the L1 network to interact with
    export L1_RPC_URL=https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  2. Fund the addresses with enough Sepolia ETH, the optimism docs recommend the following:

    • Admin β€” 0.5 Sepolia ETH

    • Proposer β€” 0.2 Sepolia ETH

    • Batcher β€” 0.1 Sepolia ETH

  3. Load environment variables with direnv direnv allow You should see something similar to this after:

        direnv: loading ~/optimism/.envrc                                                            direnv: export +DEPLOYMENT_CONTEXT +ETHERSCAN_API_KEY +GS_ADMIN_ADDRESS +GS_ADMIN_PRIVATE_KEY +GS_BATCHER_ADDRESS +GS_BATCHER_PRIVATE_KEY +GS_PROPOSER_ADDRESS +GS_PROPOSER_PRIVATE_KEY +GS_SEQUENCER_ADDRESS +GS_SEQUENCER_PRIVATE_KEY +IMPL_SALT +L1_RPC_KIND +L1_RPC_URL +PRIVATE_KEY +TENDERLY_PROJECT +TENDERLY_USERNAME

    If you do not see any output, try

    nano ~/.zshrc

    nano ~/.bashrc

    Add the following line depending on whether you use bash or zsh

    eval "$(direnv hook zsh)"
    eval "$(direnv hook bash)"

    Save the changes with

    source ~/.zshrc

    source ~/.bashrc

  4. Configure the network

    
    cd ~/optimism/packages/contracts-bedrock
    ./scripts/getting-started/config.sh

    You can view the config in the deploy-config/getting-started.json file Add the following at the bottom of the config generated

    nano deploy-config/getting-started.json
    ...
      "preimageOracleMinProposalSize": 1800000,
      "preimageOracleChallengePeriod": 300,
    
      "useAltDA": true,
      "daCommitmentType": "GenericCommitment",
      "daChallengeWindow": 160,
      "daResolveWindow": 160,
      "daBondSize": 1000000,
      "daResolverRefundPercentage": 0
    }
  5. Deploy the L1 contracts

    just install
    DEPLOYMENT_OUTFILE=deployments/artifact.json \
    DEPLOY_CONFIG_PATH=deploy-config/getting-started.json \
    forge script scripts/deploy/Deploy.s.sol:Deploy \
    --broadcast --private-key $GS_ADMIN_PRIVATE_KEY \
    --rpc-url $L1_RPC_URL --slow

    L2 Allocs

    CONTRACT_ADDRESSES_PATH=deployments/artifact.json \
    DEPLOY_CONFIG_PATH=deploy-config/getting-started.json \
    STATE_DUMP_PATH=deploy-config/statedump.json \
    forge script scripts/L2Genesis.s.sol:L2Genesis \
    --sig 'runWithStateDump()' \
    --chain 42069

    Use your L2 chain id in --chain.

  6. Generate the L2 config files

    cd ~/optimism/op-node
    ./bin/op-node genesis l2 \
      --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json \
      --l1-deployments ../packages/contracts-bedrock/deployments/artifact.json \
      --outfile.l2 genesis.json \
      --outfile.rollup rollup.json \
      --l1-rpc $L1_RPC_URL \
      --l2-allocs ../packages/contracts-bedrock/deploy-config/statedump.json

    Check the end of the generated rollup.json

     "alt_da": {
        "da_challenge_contract_address": "0x0000000000000000000000000000000000000000",
        "da_commitment_type": "GenericCommitment",
        "da_challenge_window": 160,
        "da_resolve_window": 160
      }
  7. Create an authentication key

    openssl rand -hex 32 > jwt.txt
  8. Copy genesis files into op-geth directory

    cp genesis.json ~/op-geth
    cp jwt.txt ~/op-geth
  9. Initialize op-geth

    cd ~/op-geth
    mkdir datadir
    make geth
    build/bin/geth init --datadir=datadir genesis.json

Start L2

Before optimism start, set up sunrised & sunrise-data, etc.

  1. Start op-geth

    ./build/bin/geth \
      --datadir ./datadir \
      --http \
      --http.corsdomain="*" \
      --http.vhosts="*" \
      --http.addr=0.0.0.0 \
      --http.port=9545 \
      --http.api=web3,debug,eth,txpool,net,engine \
      --ws \
      --ws.addr=0.0.0.0 \
      --ws.port=9546 \
      --ws.origins="*" \
      --ws.api=debug,eth,txpool,net,engine \
      --syncmode=full \
      --nodiscover \
      --maxpeers=0 \
      --networkid=42069 \
      --authrpc.vhosts="*" \
      --authrpc.addr=0.0.0.0 \
      --authrpc.port=9551 \
      --authrpc.jwtsecret=./jwt.txt \
      --rollup.disabletxpoolgossip=true
  2. Start op-node

    cd ~/optimism/op-node
    ./bin/op-node \
      --l2=http://localhost:9551 \
      --l2.jwt-secret=./jwt.txt \
      --sequencer.enabled \
      --sequencer.l1-confs=5 \
      --verifier.l1-confs=4 \
      --rollup.config=./rollup.json \
      --rpc.addr=0.0.0.0 \
      --rpc.port=8547 \
      --p2p.disable \
      --rpc.enable-admin \
      --p2p.sequencer.key=$GS_SEQUENCER_PRIVATE_KEY \
      --l1=$L1_RPC_URL \
      --l1.rpckind=$L1_RPC_KIND \
      --altda.enabled=true \
      --altda.da-server=http://localhost:3100 \
      --altda.da-service=true \
      --l1.beacon.ignore=true

    --altda.da-server is your da-serer’s http URL

  3. Start op-batcher

    cd ~/optimism/op-batcher
    ./bin/op-batcher \
      --l2-eth-rpc=http://localhost:9545 \
      --rollup-rpc=http://localhost:8547 \
      --poll-interval=1s \
      --sub-safety-margin=6 \
      --num-confirmations=1 \
      --safe-abort-nonce-too-low-count=3 \
      --resubmission-timeout=30s \
      --rpc.addr=0.0.0.0 \
      --rpc.port=8548 \
      --rpc.enable-admin \
      --max-channel-duration=1 \
      --l1-eth-rpc=$L1_RPC_URL \
      --private-key=$GS_BATCHER_PRIVATE_KEY \
      --altda.enabled=true \
      --altda.da-service=true \
      --altda.da-server=http://localhost:3100
  4. Start op-proposer

    cd ~/optimism/op-proposer
    ./bin/op-proposer \
      --poll-interval=12s \
      --rpc.port=9560 \
      --rollup-rpc=http://localhost:8547 \
      --l2oo-address=$(cat ../packages/contracts-bedrock/deployments/42069-deploy.json | jq -r .L2OutputOracleProxy) \
      --private-key=$GS_PROPOSER_PRIVATE_KEY \
      --l1-eth-rpc=$L1_RPC_URL
  5. Work

γ€€ For more information on supported `op-geth, please check the in the optimism repository.

API key for RPC URL can be found in or other providers.

Ref:

If you see a nondescript error that includes EvmError: Revert and Script failed then you likely need to change the IMPL_SALT environment variable. This variable determines the addresses of various smart contracts that are deployed via . If the same IMPL_SALT is used to deploy the same contracts twice, the second deployment will fail. You can generate a new IMPL_SALT by running direnv allow anywhere in the Optimism Monorepo.

πŸ› οΈ
Production Releases
Infura
Sepolia PoW Faucet
CREATE2(opens in a new tab)
Sunrise Data
OP Stack
Sunrise Data
pnpm
foundry