version: "3.9"

# Define named volumes
volumes:
  linea-mainnet-geth:
    name: "linea-mainnet-geth"
  linea-mainnet-besu:
    name: "linea-mainnet-besu"
  linea-mainnet-erigon:
    name: "linea-mainnet-erigon"
  linea-mainnet-nethermind:
    name: "linea-mainnet-nethermind"

services:
  # Geth initialization
  geth-init:
    image: ethereum/client-go:v1.13.4
    command:
      - init
      - /genesis.json
    volumes:
      - ./genesis.json:/genesis.json:ro
      - linea-mainnet-geth:/root/.ethereum

  # Geth node
  geth-node:
    image: ethereum/client-go:v1.13.4
    pull_policy: always
    restart: unless-stopped
    stop_grace_period: 30s
    depends_on:
      geth-init:
        condition: service_completed_successfully
    command:
      - --networkid=59144
      - --syncmode=snap
      - --http
      - --http.addr=0.0.0.0
      - --http.port=8545
      - --http.corsdomain=*
      - --http.api=admin,web3,eth,txpool,net
      - --http.vhosts=*
      - --bootnodes=enode://ca2f06aa93728e2883ff02b0c2076329e475fe667a48035b4f77711ea41a73cf6cb2ff232804c49538ad77794185d83295b57ddd2be79eefc50a9dd5c48bbb2e@3.23.106.165:30303,enode://eef91d714494a1ceb6e06e5ce96fe5d7d25d3701b2d2e68c042b33d5fa0e4bf134116e06947b3f40b0f22db08f104504dd2e5c790d8bcbb6bfb1b7f4f85313ec@3.133.179.213:30303,enode://cfd472842582c422c7c98b0f2d04c6bf21d1afb2c767f72b032f7ea89c03a7abdaf4855b7cb2dc9ae7509836064ba8d817572cf7421ba106ac87857836fa1d1b@3.145.12.13:30303
      - --verbosity=3
    ports:
      - 30303:30303
      - 30303:30303/udp
      - 8545:8545
      - 8546:8546
    volumes:
      - ./genesis.json:/genesis.json:ro
      - linea-mainnet-geth:/root/.ethereum

  # Besu node currently not peering with bootnodes - need to verify whether this is because they're at max peers or
  # whether the docs have outdated enodes
  besu-node:
    hostname: besu-node
    container_name: besu-node
    image: consensys/linea-besu:${SEQUENCER_TAG:-linea-delivery-17}
    platform: linux/amd64
    healthcheck:
      test: [ "CMD-SHELL", "bash -c \"[ -f /tmp/pid ]\"" ]
      interval: 1s
      timeout: 1s
      retries: 120
    restart: "no"
    environment:
      LOG4J_CONFIGURATION_FILE: /var/lib/besu/log4j.xml
    command:
      - --config-file=/var/lib/besu/linea-besu.config.toml
      - --Xdns-enabled=true
      - --Xdns-update-enabled=true
      - --Xrpc-ipc-enabled=true
      - --static-nodes-file=/var/lib/besu/static-nodes.json
    volumes:
      - ./datadir:/data
      - ./linea-besu.config.toml:/var/lib/besu/linea-besu.config.toml:ro
      - ./besu-genesis.json:/var/lib/besu/genesis.json:ro
      - ../config/linea-besu-sequencer/log4j.xml:/var/lib/besu/log4j.xml
      - ./static-nodes.json:/var/lib/besu/static-nodes.json
      - linea-mainnet-besu:/data                                                                                       

  # Erigon initialization
  erigon-init:
    image: erigontech/erigon:2.61.0
    command:
      - init
      - /genesis.json
      - --datadir=/data
    volumes:
      - ./genesis.json:/genesis.json:ro
      - linea-mainnet-erigon:/home/erigon/.local/share/erigon/

  # Erigon node
  erigon-node:
    image: erigontech/erigon:2.61.0
    pull_policy: always
    restart: unless-stopped
    stop_grace_period: 30s
    depends_on:
      erigon-init:
        condition: service_completed_successfully
    command:
      - --networkid=59144
      - --prune=hrtc
      - --http
      - --http.addr=0.0.0.0
      - --http.port=8545
      - --http.corsdomain=*
      - --http.api=admin,web3,eth,txpool,net
      - --http.vhosts=*
      - --bootnodes=enode://069800db9e6e0ec9cadca670994ef1aea2cfd3d88133e63ecadbc1cdbd1a5847b09838ee08d8b5f02a9c32ee13abeb4d4104bb5514e5322c9d7ee19f41ff3e51@3.132.73.210:31002,enode://a8e03a71eab12ec4b47bb6e19169d8e4dc7a58373a2476969bbe463f2dded6003037fa4dd5f71e15027f7fc8d7340956fbbefed67ddd116ac19a7f74da034b61@3.132.73.210:31003,enode://97706526cf79df9d930003644f9156805f6c8bd964fc79e083444f7014ce10c9bdd2c5049e63b58040dca1d4c82ebef970822198cf0714de830cff4111534ff1@18.223.198.165:31004,enode://24e1c654a801975a96b7f54ebd7452ab15777fc635c1db25bdbd4425fdb04e7f4768e9e838a87ab724320a765e41631d5d37758c933ad0e8668693558125c8aa@18.223.198.165:31000
      - --verbosity=3
    ports:
      - 30303:30303
      - 30303:30303/udp
      - 8545:8545
    volumes:
      - ./genesis.json:/genesis.json:ro
      - linea-mainnet-erigon:/home/erigon/.local/share/erigon/
      
  # Nethermind node
  nethermind-node:
    hostname: nethermind-node
    container_name: nethermind-node
    image: nethermind/nethermind:1.30.0 
    restart: unless-stopped
    command:
      --datadir /nethermind/nethermind_db
      --config linea-mainnet
      --JsonRpc.Enabled=true
      --JsonRpc.Host=0.0.0.0
      --JsonRpc.Port=8545
      --Metrics.Enabled=true
      --Metrics.ExposePort=8008
    ports:
      - 8545:8545
      - 8008:8008
    volumes:
      - linea-mainnet-nethermind:/nethermind/nethermind_db
