Build and Run Using Docker

Download L2geth

  1. Build the container using make mockccc_docker. This will produce the image scrolltech/l2geth:latest.

    Alternatively, you can download the l2geth Docker image using docker pull scrolltech/l2geth:scroll-v5.3.0(currently not supported arm64 architecture, if you runs on arm64 server, you can build it from source). In this case, substitute this image name in the commands below.

Run L2geth

  1. prepare the snapshot first

    mkdir l2geth && pushd l2geth
    wget <https://scroll-geth-snapshot.s3.us-west-2.amazonaws.com/mainnet/latest/rpc_data.tar>
    # unarchive the tar file
    tar -xf rpc_data.tar
    # remove the legacy keystore files, pls remember to do this step otherwise the node may not start
    sudo rm -rf docker-data/l2geth/data/geth/nodekey docker-data/l2geth/data/keystore
    
  2. Run the l2geth container by docker-compose, following is the compose file, you can run docker compose up -d to start the node.

    $ cat docker-compose.yaml
    ---
    version: '3'
    services:
      l2geth:
        image: scrolltech/l2geth:scroll-v5.5.0
        container_name: l2geth-docker
        stop_signal: SIGINT
        stop_grace_period: 60s
        restart: "unless-stopped"
        environment:
          - CHAIN_ID=534352
          - RUST_LOG="info"
        volumes:
          - './docker-data/l2geth/data:/volume/l2geth/data'
        ports:
          - 8545:8545
          - 8546:8546
          - 30303:30303
          - 30303:30303/udp
        command: --scroll --datadir "/volume/l2geth/data" --gcmode archive --http --http.addr "0.0.0.0" --http.port 8545 --http.api "eth,net,web3,debug,scroll" --cache.noprefetch --l1.endpoint  "<https://rpc.ankr.com/eth>"
        logging:
          driver: "json-file"
          options:
            max-size: "100m"
            max-file: "1"
    
  3. In a separate shell, you can now attach to l2geth.

    $ docker exec -it l2geth-docker geth attach "/volume/l2geth-datadir/geth.ipc"
    
    > admin.peers.length
    5
    
    > eth.blockNumber
    10000
    

Interacting with the L2geth Container