# 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_data:
  safedb_data:
  challenger_data:
  da_data:
  op_log:


services:

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

  l1-bn:
    depends_on:
      - l1
    build:
        context: .
        dockerfile: l1-lighthouse.Dockerfile
    ports:
      - "9000:9000"
      - "5052:5052"
    volumes:
      - "l1_bn_data:/db"
      - "${PWD}/test-jwt-secret.txt:/config/jwt-secret.txt"
      - "${PWD}/beacon-data/config.yaml:/genesis/config.yaml"
      - "${PWD}/beacon-data/deposit_contract_block.txt:/genesis/deposit_contract_block.txt"
      - "${PWD}/../.devnet/genesis-l1.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: .
        dockerfile: l1-lighthouse.Dockerfile
    volumes:
      - "l1_vc_data:/db"
      - "${PWD}/beacon-data/data/keys:/validator_setup/validators"
      - "${PWD}/beacon-data/data/secrets:/validator_setup/secrets"
      - "${PWD}/beacon-data/config.yaml:/genesis/config.yaml"
      - "${PWD}/beacon-data/deposit_contract_block.txt:/genesis/deposit_contract_block.txt"
      - "${PWD}/../.devnet/genesis-l1.ssz:/genesis/genesis.ssz"
    environment:
      LH_BEACON_NODES: "http://l1-bn:5052/"
    entrypoint:
      - "/bin/sh"
      - "/entrypoint-vc.sh"

  l2:
    build:
      context: .
      dockerfile: l2-op-geth.Dockerfile
    ports:
      - "9545:8545"
      - "8060:6060"
    volumes:
      - "l2_data:/db"
      - "${PWD}/../.devnet/genesis-l2.json:/genesis.json"
      - "${PWD}/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

  op-node:
    depends_on:
      - l1
      - l1-bn
      - l1-vc
      - l2
    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:8551
      --l2.jwt-secret=/config/jwt-secret.txt
      --sequencer.enabled
      --sequencer.l1-confs=0
      --verifier.l1-confs=0
      --p2p.sequencer.key=8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
      --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
      --p2p.priv.path=/config/p2p-node-key.txt
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300
      --pprof.enabled
      --rpc.enable-admin
      --safedb.path=/db
      --altda.enabled=${ALTDA_ENABLED}
      --altda.da-service=${ALTDA_SERVICE}
      --altda.da-server=http://da-server:3100
    ports:
      - "7545:8545"
      - "9003:9003"
      - "7300:7300"
      - "6060:6060"
    volumes:
      - "safedb_data:/db"
      - "${PWD}/p2p-sequencer-key.txt:/config/p2p-sequencer-key.txt"
      - "${PWD}/p2p-node-key.txt:/config/p2p-node-key.txt"
      - "${PWD}/test-jwt-secret.txt:/config/jwt-secret.txt"
      - "${PWD}/../.devnet/rollup.json:/rollup.json"
      - op_log:/op_log

  op-proposer:
    depends_on:
      - l1
      - l2
      - op-node
    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:
      - "6062:6060"
      - "7302:7300"
      - "6546:8545"
    environment:
      OP_PROPOSER_L1_ETH_RPC: http://l1:8545
      OP_PROPOSER_ROLLUP_RPC: http://op-node:8545
      OP_PROPOSER_POLL_INTERVAL: 1s
      OP_PROPOSER_NUM_CONFIRMATIONS: 1
      OP_PROPOSER_MNEMONIC: test test test test test test test test test test test junk
      OP_PROPOSER_L2_OUTPUT_HD_PATH: "m/44'/60'/0'/0/1"
      OP_PROPOSER_L2OO_ADDRESS: "${L2OO_ADDRESS}"
      OP_PROPOSER_GAME_FACTORY_ADDRESS: "${DGF_ADDRESS}"
      OP_PROPOSER_GAME_TYPE: "${DG_TYPE}"
      OP_PROPOSER_PROPOSAL_INTERVAL: "${PROPOSAL_INTERVAL}"
      OP_PROPOSER_PPROF_ENABLED: "true"
      OP_PROPOSER_METRICS_ENABLED: "true"
      OP_PROPOSER_ALLOW_NON_FINALIZED: "true"
      OP_PROPOSER_RPC_ENABLE_ADMIN: "true"

  op-batcher:
    depends_on:
      - l1
      - l2
      - op-node
    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:
      - "6061:6060"
      - "7301:7300"
      - "6545:8545"
    environment:
      OP_BATCHER_L1_ETH_RPC: http://l1:8545
      OP_BATCHER_L2_ETH_RPC: http://l2:8545
      OP_BATCHER_ROLLUP_RPC: http://op-node: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_MNEMONIC: test test test test test test test test test test test junk
      OP_BATCHER_SEQUENCER_HD_PATH: "m/44'/60'/0'/0/2"
      OP_BATCHER_PPROF_ENABLED: "true"
      OP_BATCHER_METRICS_ENABLED: "true"
      OP_BATCHER_RPC_ENABLE_ADMIN: "true"
      OP_BATCHER_BATCH_TYPE: 1
      OP_BATCHER_ALTDA_ENABLED: "${ALTDA_ENABLED}"
      OP_BATCHER_ALTDA_DA_SERVICE: "${ALTDA_SERVICE}"
      OP_BATCHER_ALTDA_DA_SERVER: "http://da-server:3100"
      OP_BATCHER_DATA_AVAILABILITY_TYPE: "${DA_TYPE}"

  op-challenger:
    depends_on:
      - l1
      - l1-bn
      - l2
      - op-node
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: op-challenger-target
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-challenger:devnet
    volumes:
      - "challenger_data:/db"
      - "../op-program/bin:/op-program"
    environment:
      OP_CHALLENGER_L1_ETH_RPC: http://l1:8545
      OP_CHALLENGER_L1_BEACON: http://l1-bn:5052
      OP_CHALLENGER_ROLLUP_RPC: http://op-node:8545
      OP_CHALLENGER_TRACE_TYPE: cannon,fast
      OP_CHALLENGER_GAME_FACTORY_ADDRESS: ${DGF_ADDRESS}
      # The devnet can't set the absolute prestate output root because the contracts are deployed in L1 genesis
      # before the L2 genesis is known.
      OP_CHALLENGER_UNSAFE_ALLOW_INVALID_PRESTATE: "true"
      OP_CHALLENGER_DATADIR: /db
      OP_CHALLENGER_CANNON_ROLLUP_CONFIG: ./.devnet/rollup.json
      OP_CHALLENGER_CANNON_L2_GENESIS: ./.devnet/genesis-l2.json
      OP_CHALLENGER_CANNON_BIN: ./cannon/bin/cannon
      OP_CHALLENGER_CANNON_SERVER: /op-program/op-program
      OP_CHALLENGER_CANNON_PRESTATE: /op-program/prestate.bin.gz
      OP_CHALLENGER_L2_ETH_RPC: http://l2:8545
      OP_CHALLENGER_MNEMONIC: test test test test test test test test test test test junk
      OP_CHALLENGER_HD_PATH: "m/44'/60'/0'/0/4"
      OP_CHALLENGER_NUM_CONFIRMATIONS: 1

  da-server:
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:devnet
    build:
      context: ../
      dockerfile: ops/docker/op-stack-go/Dockerfile
      target: da-server-target
    command: >
      da-server
      --file.path=/data
      --addr=0.0.0.0
      --port=3100
      --log.level=debug
      --generic-commitment="${ALTDA_GENERIC_DA}"
    ports:
      - "3100:3100"
    volumes:
      - "da_data:/data"

  sentinel:
    image: quarry/sentinel # TODO(10141): We need a public image for this (sentinel is out of repo)
    volumes:
      - "${PWD}/../.devnet/rollup.json:/rollup.json"
    # private-key is mnemonic index 5 of the test mnemonic.
    command: >
      sentinel
      --datadir=data
      --l1-rpc-http=http://l1:8545
      --l1-rpc-ws=ws://l1:8546
      --da-storage-uri=http://da-server:3100
      --private-key=0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
      --config=/rollup.json

  artifact-server:
    depends_on:
      - l1
    image: nginx:1.25-alpine
    ports:
      - "8080:80"
    volumes:
      - "${PWD}/../.devnet/:/usr/share/nginx/html/:ro"
    security_opt:
      - "no-new-privileges:true"
