version: '3.4'

# 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:
  l2_data:
  op_log:


services:
  l1:
    build:
      context: .
      dockerfile: Dockerfile.l1
    ports:
      - "8545:8545"
    volumes:
      - "l1_data:/db"
      - ${PWD}/../.devnet/genesis-l1.json:/genesis.json

  l2:
    build:
      context: .
      dockerfile: Dockerfile.l2
    ports:
      - "9545:8545"
    volumes:
      - "l2_data:/db"
      - ${PWD}/../.devnet/genesis-l2.json:/genesis.json
      - ${PWD}/test-jwt-secret.txt:/config/test-jwt-secret.txt
    entrypoint:  # pass the L2 specific flags by overriding the entry-point and adding extra arguments
      - "/bin/sh"
      - "/entrypoint.sh"
      - "--authrpc.jwtsecret=/config/test-jwt-secret.txt"

  op-node:
    depends_on:
      - l1
      - l2
    build:
      context: ../
      dockerfile: ./ops-bedrock/Dockerfile.node
    command: >
      op-node
      --l1=ws://l1:8546
      --l2=ws://l2:8546
      --l2.jwt-secret=/config/test-jwt-secret.txt
      --sequencer.enabled
      --sequencer.l1-confs=0
      --verifier.l1-confs=0
      --p2p.sequencer.key=/config/p2p-sequencer-key.txt
      --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
      --snapshotlog.file=/op_log/snapshot.log
      --p2p.priv.path=/config/p2p-node-key.txt
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300
    ports:
      - "7545:8545"
      - "9003:9003"
      - "7300:7300"
    volumes:
      - ${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/test-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-bedrock/Dockerfile.proposer
    environment:
      L1_ETH_RPC: http://l1:8545
      L2_ETH_RPC: http://l2:8545
      ROLLUP_RPC: http://op-node:8545
      OUTPUT_SUBMITTER_POLL_INTERVAL: 10s
      OUTPUT_SUBMITTER_NUM_CONFIRMATIONS: 1
      OUTPUT_SUBMITTER_SAFE_ABORT_NONCE_TOO_LOW_COUNT: 3
      OUTPUT_SUBMITTER_RESUBMISSION_TIMEOUT: 30s
      OUTPUT_SUBMITTER_MNEMONIC: test test test test test test test test test test test junk
      OUTPUT_SUBMITTER_L2_OUTPUT_HD_PATH: "m/44'/60'/0'/0/1"
      OUTPUT_SUBMITTER_LOG_TERMINAL: "true"
      L2OO_ADDRESS: "${L2OO_ADDRESS}"

  op-batcher:
    depends_on:
      - l1
      - l2
      - op-node
    build:
      context: ../
      dockerfile: ./ops-bedrock/Dockerfile.batcher
    environment:
      L1_ETH_RPC: http://l1:8545
      L2_ETH_RPC: http://l2:8545
      ROLLUP_RPC: http://op-node:8545
      BATCH_SUBMITTER_MIN_L1_TX_SIZE_BYTES: 1
      BATCH_SUBMITTER_MAX_L1_TX_SIZE_BYTES: 120000
      BATCH_SUBMITTER_CHANNEL_TIMEOUT: 40
      BATCH_SUBMITTER_POLL_INTERVAL: 1s
      BATCH_SUBMITTER_NUM_CONFIRMATIONS: 1
      BATCH_SUBMITTER_SAFE_ABORT_NONCE_TOO_LOW_COUNT: 3
      BATCH_SUBMITTER_RESUBMISSION_TIMEOUT: 30s
      BATCH_SUBMITTER_MNEMONIC: test test test test test test test test test test test junk
      BATCH_SUBMITTER_SEQUENCER_HD_PATH: "m/44'/60'/0'/0/2"
      BATCH_SUBMITTER_SEQUENCER_HISTORY_DB_FILENAME: "history_db.json"
      BATCH_SUBMITTER_SEQUENCER_GENESIS_HASH: "${SEQUENCER_GENESIS_HASH}"
      BATCH_SUBMITTER_SEQUENCER_BATCH_INBOX_ADDRESS: "${SEQUENCER_BATCH_INBOX_ADDRESS}"
      BATCH_SUBMITTER_LOG_TERMINAL: "true"

  stateviz:
    build:
      context: ../
      dockerfile: ./ops-bedrock/Dockerfile.stateviz
    command:
      - stateviz
      - -addr=0.0.0.0:8080
      - -snapshot=/op_log/snapshot.log
      - -refresh=10s
    ports:
      - "9090:8080"
    volumes:
      - op_log:/op_log:ro
