OP Stack L2 Chain

Sunrise's Data Availability Layer supports Layer 2 blockchains created using OP Stack This is a guide to connecting an L2 chain created using OP Stack to Sunrise chain with Sunrise Data. 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
  • pnpm

      curl -fsSL https://get.pnpm.io/install.sh | sh -
  • foundry

      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

  2. Check out the correct branch

γ€€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

  2. Build all packages associated with Optimism

    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

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

  1. Fill out environment variables

    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:

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

  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

    Ref: Sepolia PoW Faucet

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

    If you do not see any output, try

    nano ~/.zshrc

    nano ~/.bashrc

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

    Save the changes with

    source ~/.zshrc

    source ~/.bashrc

  4. Configure the network

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

  5. Deploy the L1 contracts

    L2 Allocs

    Use your L2 chain id in --chain.

    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 CREATE2(opens in a new tab). 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.

  6. Generate the L2 config files

    Check the end of the generated rollup.json

  7. Create an authentication key

  8. Copy genesis files into op-geth directory

  9. Initialize op-geth

Start L2

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

Sunrise Data

  1. Start op-geth

  2. Start op-node

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

  3. Start op-batcher

  4. Start op-proposer

  5. Work

Last updated