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.8.38(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

    for zktrie nodes;

    SNAPSHOT_URL = https://scroll-geth-snapshot.s3.us-west-2.amazonaws.com/zktrie/latest.tar

    mkdir l2geth-zktrie && pushd l2geth-zktrie
    wget $SNAPSHOT_URL 
    # unarchive the tar file
    tar -xf latest.tar
    

    for mpt nodes;

    SNAPSHOT_URL = https://scroll-geth-snapshot.s3.us-west-2.amazonaws.com/mpt/latest.tar

    mkdir l2geth-mpt && pushd l2geth-mpt
    wget $SNAPSHOT_URL 
    # unarchive the tar file
    tar -xf latest.tar
    
  2. Run the l2geth container by docker-compose, following is the compose file, you can run docker compose up -d to start the node.

    Note: for MPT nodes simply add --scroll-mpt flag to the command field in your docker-compose.yaml

    $ cat docker-compose.yaml
    ---
    version: '3'
    services:
      l2geth:
        image: scrolltech/l2geth:scroll-v5.8.38
        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
        # default zktrie type
        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>"
        # mpt type
        # command: --scroll --scroll-mpt --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