services:
  celo-mainnet-archive:
    image: us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${CELO_L2_VERSION:-celo-v2.0.0}
    volumes:
      - "${CELO_MAINNET_OP_GETH_ARCHIVE_LEVELDB_HASH_DATA:-celo-mainnet-op-geth-archive-leveldb-hash}:/datadir"
      - ".jwtsecret:/shared/jwt.txt"
      - "./celo/mainnet/:/chainconfig"
      - "./celo/scripts/:/scripts"
    ports:
      - "10111:10111"
      - "10111:10111/udp"
    expose:
      - 8545
      - 8551
    networks:
      - chains
    restart: always
    stop_grace_period: 5m
    entrypoint: /scripts/start-op-geth.sh
    environment:
      - NETWORK_NAME=mainnet
      - GETH_BOOTNODES=enode://28f4fcb7f38c1b012087f7aef25dcb0a1257ccf1cdc4caa88584dc25416129069b514908c8cead5d0105cb0041dd65cd4ee185ae0d379a586fb07b1447e9de38@34.169.39.223:30303,enode://a9077c3e030206954c5c7f22cc16a32cb5013112aa8985e3575fadda7884a508384e1e63c077b7d9fcb4a15c716465d8585567f047c564ada2e823145591e444@34.169.212.31:30303,enode://029b007a7a56acbaa8ea50ec62cda279484bf3843fae1646f690566f784aca50e7d732a9a0530f0541e5ed82ba9bf2a4e21b9021559c5b8b527b91c9c7a38579@34.82.139.199:30303,enode://f3c96b73a5772c5efb48d5a33bf193e58080d826ba7f03e9d5bdef20c0634a4f83475add92ab6313b7a24aa4f729689efb36f5093e5d527bb25e823f8a377224@34.82.84.247:30303,enode://daa5ad65d16bcb0967cf478d9f20544bf1b6de617634e452dff7b947279f41f408b548261d62483f2034d237f61cbcf92a83fc992dbae884156f28ce68533205@34.168.45.168:30303,enode://c79d596d77268387e599695d23e941c14c220745052ea6642a71ef7df31a13874cb7f2ce2ecf5a8a458cfc9b5d9219ce3e8bc6e5c279656177579605a5533c4f@35.247.32.229:30303,enode://4151336075dd08eb6c75bfd63855e8a4bd6fd0f91ae4a81b14930f2671e16aee55495c139380c16e1094a49691875e69e40a3a5e2b4960c7859e7eb5745f9387@35.205.149.224:30303,enode://ab999db751265c714b171344de1972ed74348162de465a0444f56e50b8cfd048725b213ba1fe48c15e3dfb0638e685ea9a21b8447a54eb2962c6768f43018e5c@34.79.3.199:30303,enode://9d86d92fb38a429330546fe1aefce264e1f55c5d40249b63153e7df744005fa3c1e2da295e307041fd30ab1c618715f362c932c28715bc20bed7ae4fc76dea81@34.77.144.164:30303,enode://c82c31f21dd5bbb8dc35686ff67a4353382b4017c9ec7660a383ccb5b8e3b04c6d7aefe71203e550382f6f892795728570f8190afd885efcb7b78fa398608699@34.76.202.74:30303,enode://3bad5f57ad8de6541f02e36d806b87e7e9ca6d533c956e89a56b3054ae85d608784f2cd948dc685f7d6bbd5a2f6dd1a23cc03e529ea370dd72d880864a2af6a3@104.199.93.87:30303,enode://1decf3b8b9a0d0b8332d15218f3bf0ceb9606b0efe18f352c51effc14bbf1f4f3f46711e1d460230cb361302ceaad2be48b5b187ad946e50d729b34e463268d2@35.240.26.148:30303
      - BEDROCK_DATADIR=/datadir
      - OP_GETH__SYNCMODE=full
      - GETH_STATE_SCHEME=hash
      - GETH_DB_ENGINE=leveldb
      - GETH_NAT=extip:${IP}
      - NODE_TYPE=archive
      - BEDROCK_SEQUENCER_HTTP=https://cel2-sequencer.celo.org
      - PORT__OP_GETH_P2P=10111
      - IS_CUSTOM_CHAIN=true
      - OP_GETH__HISTORICAL_RPC=${CELO_MAINNET_ARCHIVE_GETH:-http://celo-mainnet-geth-archive:8545}

    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.celo-mainnet-op-geth-archive-leveldb-hash-stripprefix.stripprefix.prefixes=/celo-mainnet-archive"
      - "traefik.http.services.celo-mainnet-op-geth-archive-leveldb-hash-op-geth-pruned-pebble-path.loadbalancer.server.port=8545"
      - "${NO_SSL:-traefik.http.routers.celo-mainnet-op-geth-archive-leveldb-hash.entrypoints=websecure}"
      - "${NO_SSL:-traefik.http.routers.celo-mainnet-op-geth-archive-leveldb-hash.tls.certresolver=myresolver}"
      - "${NO_SSL:-traefik.http.routers.celo-mainnet-op-geth-archive-leveldb-hash.rule=Host(`$DOMAIN`) && PathPrefix(`/celo-mainnet-archive`)}"
      - "${NO_SSL:+traefik.http.routers.celo-mainnet-op-geth-archive-leveldb-hash.rule=PathPrefix(`/celo-mainnet-archive`)}"
      - "traefik.http.routers.celo-mainnet-op-geth-archive-leveldb-hash.middlewares=celo-mainnet-op-geth-archive-leveldb-hash-stripprefix, ipwhitelist"


  celo-mainnet-archive-node:
    image: us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-node:${CELO_L2_VERSION:-celo-v2.0.0}
    depends_on:
      - celo-mainnet-archive
    expose:
      - 9545     # RPC
      - 7300     # metrics
      - 6060     # pprof
    networks:
      - chains
    ports:
      - "15111:15111"
      - "15111:15111/udp"
    environment:
      - HEALTHCHECK__REFERENCE_RPC_PROVIDER=https://forno.celo.org
      - OP_NODE_ALTDA_DA_SERVER="http://celo-mainnet-archive-eigenda-proxy:4242"
      - OP_NODE_P2P_LISTEN_TCP_PORT=15111
      - OP_NODE_P2P_LISTEN_UDP_PORT=15111
      - OP_NODE_P2P_STATIC=/ip4/34.83.180.111/tcp/9222/p2p/16Uiu2HAkxBYxPd4eDFJzwm84XPzymkXud847vu65eju4UCDRpDSM,/ip4/34.169.135.64/tcp/9222/p2p/16Uiu2HAm6oVW1YeKheAuhnJSySnVvbXZ5gXL4g36XrWb1imF9K3m,/ip4/34.169.201.36/tcp/9222/p2p/16Uiu2HAmCqAFUoq72tjGJfCkkzHoNbjTjshjEED4kWtRKMSxcMgb,/ip4/34.83.127.51/tcp/9222/p2p/16Uiu2HAmBqKBoxkk95CsZiXQmQHv9WMiHXU4Di6wzFuYEKo1i7dg,/ip4/35.227.175.30/tcp/9222/p2p/16Uiu2HAmTNVkin4vogHsqwJwShUkHtx48aDoxygGwgp9Tv5zQWTM,/ip4/34.82.198.98/tcp/9222/p2p/16Uiu2HAmS6CeFPUXMztLf4VDh9NLbauuXLSYx9YkXfyiscqoxsKt,/ip4/34.38.181.223/tcp/9222/p2p/16Uiu2HAmH3xfYGjaJDw6sxa8ds3bVwMYLZRpPzpTtTrYq7G4nZs3,/ip4/34.76.38.6/tcp/9222/p2p/16Uiu2HAm6yXZ9oRTSJfZzXe8wXJ165X3pfzAKdLB9sa27eRZgTwD,/ip4/35.187.106.54/tcp/9222/p2p/16Uiu2HAmPFucuARxzAqtXcD3evFoutKh7tSmfQCxwPKUXfkoyaqY,/ip4/34.76.16.183/tcp/9222/p2p/16Uiu2HAmS8NybNYedzHf4nuFfqyCDH9xiMpgMWxctMtau8dTUxeP,/ip4/104.199.39.59/tcp/9222/p2p/16Uiu2HAmGfwjf1XPikWYDN4NFpTBuuvs6C7eF2iyyKvvjK2MGrVM,/ip4/34.140.117.79/tcp/9222/p2p/16Uiu2HAkwSVN7WHohhoE1sh932y2q3Pv7AFiSugM8K6iFZLALq66
      - OP_NODE_ALTDA_ENABLED=true
      - OP_NODE_ALTDA_DA_SERVICE=true
      - OP_NODE_ALTDA_VERIFY_ON_READ=false
      - OP_NODE_ALTDA_DA_SERVER=http://celo-mainnet-archive-eigenda-proxy:4242
      - OP_NODE_L2_ENGINE_AUTH=/jwtsecret
    command: >
      op-node
      --l1="${ETHEREUM_MAINNET_EXECUTION_RPC}"
      --l2=http://celo-mainnet-archive:8551
      --rpc.addr=0.0.0.0
      --rpc.port=9545
      --l1.trustrpc
      --l1.rpckind=basic
      --l1.beacon="${ETHEREUM_MAINNET_BEACON_REST}"
      --syncmode=execution-layer
      --p2p.priv.path=/chainconfigs/p2p_node_key_txt
      --rollup.config=/chainconfigs/rollup.json
      --rollup.load-protocol-versions=true
      --rollup.halt=major
    restart: always
    volumes:
      - .jwtsecret:/jwtsecret
      - ./celo/mainnet/:/chainconfigs/
    stop_grace_period: 30s

  celo-mainnet-archive-eigenda-proxy:
    platform: linux/amd64
    image: ghcr.io/layr-labs/eigenda-proxy:v1.6.4
    restart: unless-stopped
    stop_grace_period: 5m
    entrypoint: /scripts/start-eigenda-proxy.sh
    environment:
      - EIGENDA_LOCAL_DISPERSER_RPC=disperser.eigenda.xyz:443
      - EIGENDA_LOCAL_SVC_MANAGER_ADDR=0x870679e138bcdf293b7ff14dd44b70fc97e12fc0
      - OP_NODE__RPC_ENDPOINT=${ETHEREUM_MAINNET_EXECUTION_RPC}
    volumes:
      - ${CELO_MAINNET_OP_GETH_ARCHIVE_LEVELDB_HASH__EIGENDA_DATA:-celo-mainnet-op-geth-archive-leveldb-hash_eigenda}:/data
      - ./celo/scripts:/scripts
    
  celo-mainnet-archive-key-generator:
    image: ghcr.io/foundry-rs/foundry
    volumes:
      - "./celo/mainnet:/config"
    entrypoint: sh
    command: "[ -f /config/p2p_node_key_txt ] && exit 0 || cast w n | grep -i 'Private Key' | awk -F ': ' '{print $2}' | sed 's/0x//' > /config/p2p_node_key_txt"
    
volumes:
  celo-mainnet-op-geth-archive-leveldb-hash:
  celo-mainnet-op-geth-archive-leveldb-hash_eigenda:

    
