# This Compose file is expected to be used with the devnet-up.sh script.
# The volumes below mount the configs generated by the script into each
# service.

volumes:
  l1_data:
  l1_bn_data:
  l1_vc_data:
  l2_a_data:
  safedb_a_data:
  l2_b_data:
  safedb_b_data:
  supervisor_data:
  op_log_a:
  op_log_b:

services:

  l1:
    build:
      context: ../ops-bedrock
      dockerfile: l1-geth.Dockerfile
    ports:
      - "8545:8545"
      - "8546:8546"
      - "7060:6060"
    volumes:
      - "l1_data:/db"
      - "${PWD}/../.devnet-interop/genesis/l1/genesis.json:/genesis.json"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
    environment:
      GETH_MINER_RECOMMIT: 100ms

  l1-bn:
    depends_on:
      - l1
    build:
        context: ../ops-bedrock
        dockerfile: l1-lighthouse.Dockerfile
    ports:
      - "9000:9000"
      - "5052:5052"
    volumes:
      - "l1_bn_data:/db"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
      - "${PWD}/../ops-bedrock/beacon-data/config.yaml:/genesis/config.yaml"
      - "${PWD}/../ops-bedrock/beacon-data/deposit_contract_block.txt:/genesis/deposit_contract_block.txt"
      - "${PWD}/../.devnet-interop/genesis/l1/beaconstate.ssz:/genesis/genesis.ssz"
    environment:
      LH_EXECUTION_ENDPOINT: "http://l1:8551"
    entrypoint:
      - "/bin/sh"
      - "/entrypoint-bn.sh"

  l1-vc:
    depends_on:
      - l1
      - l1-bn
    build:
        context: ../ops-bedrock
        dockerfile: l1-lighthouse.Dockerfile
    volumes:
      - "l1_vc_data:/db"
      - "${PWD}/../ops-bedrock/beacon-data/data/keys:/validator_setup/validators"
      - "${PWD}/../ops-bedrock/beacon-data/data/secrets:/validator_setup/secrets"
      - "${PWD}/../ops-bedrock/beacon-data/config.yaml:/genesis/config.yaml"
      - "${PWD}/../ops-bedrock/beacon-data/deposit_contract_block.txt:/genesis/deposit_contract_block.txt"
      - "${PWD}/../.devnet-interop/genesis/l1/beaconstate.ssz:/genesis/genesis.ssz"
    environment:
      LH_BEACON_NODES: "http://l1-bn:5052/"
    entrypoint:
      - "/bin/sh"
      - "/entrypoint-vc.sh"

  op-supervisor:
    depends_on:
      - l1
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-supervisor-target
    ports:
      - "9045:8545"
    volumes:
      - "supervisor_data:/db"
      - "./depset.json:/depset.json"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-supervisor:devnet
    command: >
      op-supervisor
      --datadir="/db"
      --dependency-set="/depset.json"
      --rpc.addr="0.0.0.0"
      --rpc.port=8545
      --rpc.enable-admin
      --l1-rpc="http://l1:8545"
      --l2-consensus.nodes="http://op-node-a:9645,http://op-node-b:9645"
      --l2-consensus.jwt-secret=/config/jwt-secret.txt
    environment:
      OP_SUPERVISOR_METRICS_ENABLED: "true"

  l2-a:
    depends_on:
      - op-supervisor
    build:
      context: ../ops-bedrock/
      dockerfile: l2-op-geth-interop.Dockerfile
    ports:
      - "9145:8545"
      - "8160:6060"
    volumes:
      - "l2_a_data:/db"
      - "${PWD}/../.devnet-interop/genesis/l2/900200/genesis.json:/genesis.json"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
    entrypoint:  # pass the L2 specific flags by overriding the entry-point and adding extra arguments
      - "/bin/sh"
      - "/entrypoint.sh"
    environment:
      GETH_MINER_RECOMMIT: 100ms
      GETH_ROLLUP_INTEROPRPC: "ws://op-supervisor:8545"

  l2-b:
    depends_on:
      - op-supervisor
    build:
      context: ../ops-bedrock/
      dockerfile: l2-op-geth-interop.Dockerfile
    ports:
      - "9245:8545"
      - "8260:6060"
    volumes:
      - "l2_b_data:/db"
      - "${PWD}/../.devnet-interop/genesis/l2/900201/genesis.json:/genesis.json"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
    entrypoint:  # pass the L2 specific flags by overriding the entry-point and adding extra arguments
      - "/bin/sh"
      - "/entrypoint.sh"
    environment:
      GETH_MINER_RECOMMIT: 100ms
      GETH_ROLLUP_INTEROPRPC: "ws://op-supervisor:8545"

  op-node-a:
    depends_on:
      - l1
      - l1-bn
      - l1-vc
      - l2-a
      - op-supervisor
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-node-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:devnet
    command: >
      op-node
      --l1=ws://l1:8546
      --l1.beacon=http://l1-bn:5052
      --l1.epoch-poll-interval=12s
      --l1.http-poll-interval=6s
      --l2=http://l2-a:8551
      --l2.jwt-secret=/config/jwt-secret.txt
      --interop.supervisor=http://op-supervisor:8545
      --interop.rpc.addr=0.0.0.0
      --interop.rpc.port=9645
      --interop.jwt-secret=/config/jwt-secret.txt
      --sequencer.enabled
      --sequencer.l1-confs=0
      --verifier.l1-confs=0
      --rollup.config=/rollup.json
      --rpc.addr=0.0.0.0
      --rpc.port=8545
      --p2p.listen.ip=0.0.0.0
      --p2p.listen.tcp=9003
      --p2p.listen.udp=9003
      --p2p.scoring.peers=light
      --p2p.ban.peers=true
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300
      --pprof.enabled
      --rpc.enable-admin
      --safedb.path=/db
    ports:
      - "7145:8545"
      - "9103:9003"
      - "7100:7300"
      - "6160:6060"
      - "9645:9645"
    volumes:
      - "safedb_a_data:/db"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
      - "${PWD}/../.devnet-interop/genesis/l2/900200/rollup.json:/rollup.json"
      - op_log_a:/op_log
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900200/op-node.env"

  op-node-b:
    depends_on:
      - l1
      - l1-bn
      - l1-vc
      - l2-b
      - op-supervisor
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-node-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:devnet
    command: >
      op-node
      --l1=ws://l1:8546
      --l1.beacon=http://l1-bn:5052
      --l1.epoch-poll-interval=12s
      --l1.http-poll-interval=6s
      --l2=http://l2-b:8551
      --l2.jwt-secret=/config/jwt-secret.txt
      --interop.supervisor=http://op-supervisor:8545
      --interop.rpc.addr=0.0.0.0
      --interop.rpc.port=9645
      --interop.jwt-secret=/config/jwt-secret.txt
      --sequencer.enabled
      --sequencer.l1-confs=0
      --verifier.l1-confs=0
      --rollup.config=/rollup.json
      --rpc.addr=0.0.0.0
      --rpc.port=8545
      --p2p.listen.ip=0.0.0.0
      --p2p.listen.tcp=9003
      --p2p.listen.udp=9003
      --p2p.scoring.peers=light
      --p2p.ban.peers=true
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300
      --pprof.enabled
      --rpc.enable-admin
      --safedb.path=/db
    ports:
      - "7245:8545"
      - "9203:9003"
      - "7200:7300"
      - "6260:6060"
      - "9645:9645"
    volumes:
      - "safedb_b_data:/db"
      - "${PWD}/../ops-bedrock/test-jwt-secret.txt:/config/jwt-secret.txt"
      - "${PWD}/../.devnet-interop/genesis/l2/900201/rollup.json:/rollup.json"
      - op_log_b:/op_log
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900201/op-node.env"

  op-proposer-a:
    depends_on:
      - l1
      - op-node-a
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-proposer-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:devnet
    ports:
      - "6162:6060"
      - "7102:7300"
      - "6146:8545"
    environment:
      OP_PROPOSER_L1_ETH_RPC: http://l1:8545
      OP_PROPOSER_ROLLUP_RPC: http://op-node-a:8545
      OP_PROPOSER_POLL_INTERVAL: 1s
      OP_PROPOSER_NUM_CONFIRMATIONS: 1
      OP_PROPOSER_GAME_TYPE: "254"
      OP_PROPOSER_PROPOSAL_INTERVAL: "12s"
      OP_PROPOSER_PPROF_ENABLED: "true"
      OP_PROPOSER_METRICS_ENABLED: "true"
      OP_PROPOSER_ALLOW_NON_FINALIZED: "true"
      OP_PROPOSER_RPC_ENABLE_ADMIN: "true"
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900200/op-proposer.env"

  op-proposer-b:
    depends_on:
      - l1
      - op-node-b
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-proposer-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:devnet
    ports:
      - "6262:6060"
      - "7202:7300"
      - "6246:8545"
    environment:
      OP_PROPOSER_L1_ETH_RPC: http://l1:8545
      OP_PROPOSER_ROLLUP_RPC: http://op-node-b:8545
      OP_PROPOSER_POLL_INTERVAL: 1s
      OP_PROPOSER_NUM_CONFIRMATIONS: 1
      OP_PROPOSER_GAME_TYPE: "254"
      OP_PROPOSER_PROPOSAL_INTERVAL: "12s"
      OP_PROPOSER_PPROF_ENABLED: "true"
      OP_PROPOSER_METRICS_ENABLED: "true"
      OP_PROPOSER_ALLOW_NON_FINALIZED: "true"
      OP_PROPOSER_RPC_ENABLE_ADMIN: "true"
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900201/op-proposer.env"

  op-batcher-a:
    depends_on:
      - l1
      - l2-a
      - op-node-a
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-batcher-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:devnet
    ports:
      - "6161:6060"
      - "7101:7300"
      - "6145:8545"
    environment:
      OP_BATCHER_L1_ETH_RPC: http://l1:8545
      OP_BATCHER_L2_ETH_RPC: http://l2-a:8545
      OP_BATCHER_ROLLUP_RPC: http://op-node-a:8545
      OP_BATCHER_MAX_CHANNEL_DURATION: 2
      OP_BATCHER_SUB_SAFETY_MARGIN: 4 # SWS is 15, ChannelTimeout is 40
      OP_BATCHER_POLL_INTERVAL: 1s
      OP_BATCHER_NUM_CONFIRMATIONS: 1
      OP_BATCHER_PPROF_ENABLED: "true"
      OP_BATCHER_METRICS_ENABLED: "true"
      OP_BATCHER_RPC_ENABLE_ADMIN: "true"
      OP_BATCHER_BATCH_TYPE:
      OP_BATCHER_THROTTLE_INTERVAL: 0
      # uncomment to use blobs
      # OP_BATCHER_DATA_AVAILABILITY_TYPE: blobs
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900200/op-batcher.env"

  op-batcher-b:
    depends_on:
      - l1
      - l2-b
      - op-node-b
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-batcher-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:devnet
    ports:
      - "6261:6060"
      - "7201:7300"
      - "6245:8545"
    environment:
      OP_BATCHER_L1_ETH_RPC: http://l1:8545
      OP_BATCHER_L2_ETH_RPC: http://l2-b:8545
      OP_BATCHER_ROLLUP_RPC: http://op-node-b:8545
      OP_BATCHER_MAX_CHANNEL_DURATION: 2
      OP_BATCHER_SUB_SAFETY_MARGIN: 4 # SWS is 15, ChannelTimeout is 40
      OP_BATCHER_POLL_INTERVAL: 1s
      OP_BATCHER_NUM_CONFIRMATIONS: 1
      OP_BATCHER_PPROF_ENABLED: "true"
      OP_BATCHER_METRICS_ENABLED: "true"
      OP_BATCHER_RPC_ENABLE_ADMIN: "true"
      OP_BATCHER_BATCH_TYPE:
      OP_BATCHER_THROTTLE_INTERVAL: 0
      # uncomment to use blobs
      # OP_BATCHER_DATA_AVAILABILITY_TYPE: blobs
    env_file:
      - "${PWD}/../.devnet-interop/env/l2/900201/op-batcher.env"

  grafana:
    image: grafana/grafana:11.1.0
    restart: unless-stopped
    env_file:
      - monitoring/grafana.env
    volumes:
      - ./monitoring/grafana/provisioning/:/etc/grafana/provisioning/:ro
      - ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards
      # - grafana_data:/var/lib/grafana
    ports:
      - 3300:3000

  prometheus:
    image: prom/prometheus:latest
    restart: unless-stopped
    volumes:
      - ./monitoring/prometheus:/etc/prometheus
      # - prometheus_data:/prometheus
    ports:
      - 3090:9090
    command: --config.file=/etc/prometheus/prometheus.yml --log.level=debug

  loki:
    image: grafana/loki:3.1.1
    restart: unless-stopped
    volumes:
      - ./monitoring/loki:/etc/loki
    ports:
      - 3200:3200
    command: -config.file=/etc/loki/config.yaml

  promtail:
    image: grafana/promtail:3.1.1
    restart: unless-stopped
    volumes:
      # uncomment to scrape system logs
      # - /var/log:/var/log
      - ./monitoring/promtail:/etc/promtail
      - /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket to read container logs
    command: -config.file=/etc/promtail/config.yaml
