From 21c01e8de8b25ce5e93b92845b2fd6744cf29b17 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Thu, 2 Jul 2026 13:35:16 +0000 Subject: [PATCH] bitcoin: production-ready mainnet bitcoind for DRPC serving Switch to bitcoin/bitcoin:31.0 with txindex and tuned RPC flags, drop the esplora indexer sidecar, and add bitcoin-protocol health probes so fleet status and wait-for-online work for bitcoin-family nodes. Co-authored-by: Cursor --- .../bitcoin-mainnet-bitcoind-full.yml | 40 ++++--------------- .../bitcoin-testnet-bitcoind-full.yml | 40 ++++--------------- check-health.sh | 34 +++++++++++++++- compose_registry.json | 10 ++--- sync-status.sh | 12 +++++- 5 files changed, 62 insertions(+), 74 deletions(-) diff --git a/bitcoin/bitcoind/bitcoin-mainnet-bitcoind-full.yml b/bitcoin/bitcoind/bitcoin-mainnet-bitcoind-full.yml index 269a3802..ac00998f 100644 --- a/bitcoin/bitcoind/bitcoin-mainnet-bitcoind-full.yml +++ b/bitcoin/bitcoind/bitcoin-mainnet-bitcoind-full.yml @@ -30,7 +30,7 @@ x-logging-defaults: &logging-defaults services: bitcoin-mainnet: - image: ${BITCOIN_BITCOIND_IMAGE:-lncm/bitcoind}:${BITCOIN_MAINNET_BITCOIND_VERSION:-v28.0} + image: ${BITCOIN_BITCOIND_IMAGE:-bitcoin/bitcoin}:${BITCOIN_MAINNET_BITCOIND_VERSION:-31.0} sysctls: # TCP Performance net.ipv4.tcp_slow_start_after_idle: 0 # Disable slow start after idle @@ -57,14 +57,20 @@ services: entrypoint: [bitcoind] command: - -datadir=/data + - -dbcache=4096 + - -disablewallet=1 - -externalip=${IP} + - -maxconnections=64 - -port=12518 - -printtoconsole - -rpcallowip=::/0 - -rpcauth=username:0b6623bdebb516ced10631668833e42a$$c478b38890678c51b9f013174a20addb317c2046b68c05e0250ff86e31a505f7 - -rpcbind=0.0.0.0 - -rpcport=8545 + - -rpcthreads=16 + - -rpcworkqueue=512 - -server + - -txindex=1 - -zmqpubhashblock=tcp://0.0.0.0:28332 - -zmqpubhashtx=tcp://0.0.0.0:28333 - -zmqpubrawblock=tcp://0.0.0.0:28334 @@ -117,40 +123,8 @@ services: - ${NO_SSL:+traefik.http.routers.bitcoin-mainnet-bitcoind-full-rawtx.rule=PathPrefix(`/bitcoin-mainnet/rawtx`)} - traefik.http.routers.bitcoin-mainnet-bitcoind-full-rawtx.middlewares=bitcoin-mainnet-bitcoind-full-stripprefix, ipallowlist - bitcoin-mainnet-indexer: - image: blockstream/esplora - expose: - - 3000 # HTTP - - 50001 # RPC (electrum) - environment: - - ELECTRS_DAEMON_P2P_ADDR=bitcoin-mainnet:12518 - - ELECTRS_DAEMON_RPC_ADDR=bitcoin-mainnet:8545 - - ELECTRS_DB_DIR=/data/electrs - - ELECTRS_ELECTRUM_RPC_ADDR=0.0.0.0:50001 - - ELECTRS_HTTP_ADDR=0.0.0.0:3000 - - ELECTRS_JSONRPC_IMPORT=true - - ELECTRS_NETWORK=bitcoin - - ELECTRS_RPC_PASS=password - - ELECTRS_RPC_USER=username - networks: - - chains - volumes: - - ${BITCOIN_MAINNET_BITCOIND_FULL__ESPLORA_DATA:-bitcoin-mainnet-bitcoind-full_esplora}:/data - logging: *logging-defaults - labels: - - traefik.enable=true - - traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.service=bitcoin-mainnet-bitcoind-full-esplora - - traefik.http.middlewares.bitcoin-mainnet-bitcoind-full-esplora-stripprefix.stripprefix.prefixes=/bitcoin-mainnet - - traefik.http.services.bitcoin-mainnet-bitcoind-full-esplora.loadbalancer.server.port=3000 - - ${NO_SSL:-traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.entrypoints=websecure} - - ${NO_SSL:-traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.tls.certresolver=myresolver} - - ${NO_SSL:-traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.rule=Host(`$DOMAIN`) && (PathPrefix(`bitcoin-mainnet/address`) || PathPrefix(`bitcoin-mainnet/tx`) || PathPrefix(`bitcoin-mainnet/block`) || PathPrefix(`bitcoin-mainnet/blocks`) || PathPrefix(`bitcoin-mainnet/mempool`) || PathPrefix(`bitcoin-mainnet/fee-estimates`) || PathPrefix(`bitcoin-mainnet/scripthash`) || PathPrefix(`bitcoin-mainnet/asset`))} - - ${NO_SSL:+traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.rule=PathPrefix(`bitcoin-mainnet/address`) || PathPrefix(`bitcoin-mainnet/tx`) || PathPrefix(`bitcoin-mainnet/block`) || PathPrefix(`bitcoin-mainnet/blocks`) || PathPrefix(`bitcoin-mainnet/mempool`) || PathPrefix(`bitcoin-mainnet/fee-estimates`) || PathPrefix(`bitcoin-mainnet/scripthash`) || PathPrefix(`bitcoin-mainnet/asset`))} - - traefik.http.routers.bitcoin-mainnet-bitcoind-full-esplora.middlewares=bitcoin-mainnet-bitcoind-full-esplora-stripprefix, ipallowlist - volumes: bitcoin-mainnet-bitcoind-full: - bitcoin-mainnet-bitcoind-full_esplora: x-upstreams: - id: $${ID} diff --git a/bitcoin/bitcoind/bitcoin-testnet-bitcoind-full.yml b/bitcoin/bitcoind/bitcoin-testnet-bitcoind-full.yml index aa3557a2..fce31f43 100644 --- a/bitcoin/bitcoind/bitcoin-testnet-bitcoind-full.yml +++ b/bitcoin/bitcoind/bitcoin-testnet-bitcoind-full.yml @@ -30,7 +30,7 @@ x-logging-defaults: &logging-defaults services: bitcoin-testnet: - image: ${BITCOIN_BITCOIND_IMAGE:-lncm/bitcoind}:${BITCOIN_TESTNET_BITCOIND_VERSION:-v28.0} + image: ${BITCOIN_BITCOIND_IMAGE:-bitcoin/bitcoin}:${BITCOIN_TESTNET_BITCOIND_VERSION:-31.0} sysctls: # TCP Performance net.ipv4.tcp_slow_start_after_idle: 0 # Disable slow start after idle @@ -57,15 +57,21 @@ services: entrypoint: [bitcoind] command: - -datadir=/data + - -dbcache=4096 + - -disablewallet=1 - -externalip=${IP} + - -maxconnections=64 - -port=13668 - -printtoconsole - -rpcallowip=::/0 - -rpcauth=username:0b6623bdebb516ced10631668833e42a$$c478b38890678c51b9f013174a20addb317c2046b68c05e0250ff86e31a505f7 - -rpcbind=0.0.0.0 - -rpcport=8545 + - -rpcthreads=16 + - -rpcworkqueue=512 - -server - -testnet + - -txindex=1 - -zmqpubhashblock=tcp://0.0.0.0:28332 - -zmqpubhashtx=tcp://0.0.0.0:28333 - -zmqpubrawblock=tcp://0.0.0.0:28334 @@ -118,40 +124,8 @@ services: - ${NO_SSL:+traefik.http.routers.bitcoin-testnet-bitcoind-full-rawtx.rule=PathPrefix(`/bitcoin-testnet/rawtx`)} - traefik.http.routers.bitcoin-testnet-bitcoind-full-rawtx.middlewares=bitcoin-testnet-bitcoind-full-stripprefix, ipallowlist - bitcoin-testnet-indexer: - image: blockstream/esplora - expose: - - 3000 # HTTP - - 50001 # RPC (electrum) - environment: - - ELECTRS_DAEMON_P2P_ADDR=bitcoin-testnet:13668 - - ELECTRS_DAEMON_RPC_ADDR=bitcoin-testnet:8545 - - ELECTRS_DB_DIR=/data/electrs - - ELECTRS_ELECTRUM_RPC_ADDR=0.0.0.0:50001 - - ELECTRS_HTTP_ADDR=0.0.0.0:3000 - - ELECTRS_JSONRPC_IMPORT=true - - ELECTRS_NETWORK=bitcoin-testnet - - ELECTRS_RPC_PASS=password - - ELECTRS_RPC_USER=username - networks: - - chains - volumes: - - ${BITCOIN_TESTNET_BITCOIND_FULL__ESPLORA_DATA:-bitcoin-testnet-bitcoind-full_esplora}:/data - logging: *logging-defaults - labels: - - traefik.enable=true - - traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.service=bitcoin-testnet-bitcoind-full-esplora - - traefik.http.middlewares.bitcoin-testnet-bitcoind-full-esplora-stripprefix.stripprefix.prefixes=/bitcoin-testnet - - traefik.http.services.bitcoin-testnet-bitcoind-full-esplora.loadbalancer.server.port=3000 - - ${NO_SSL:-traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.entrypoints=websecure} - - ${NO_SSL:-traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.tls.certresolver=myresolver} - - ${NO_SSL:-traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.rule=Host(`$DOMAIN`) && (PathPrefix(`bitcoin-testnet/address`) || PathPrefix(`bitcoin-testnet/tx`) || PathPrefix(`bitcoin-testnet/block`) || PathPrefix(`bitcoin-testnet/blocks`) || PathPrefix(`bitcoin-testnet/mempool`) || PathPrefix(`bitcoin-testnet/fee-estimates`) || PathPrefix(`bitcoin-testnet/scripthash`) || PathPrefix(`bitcoin-testnet/asset`))} - - ${NO_SSL:+traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.rule=PathPrefix(`bitcoin-testnet/address`) || PathPrefix(`bitcoin-testnet/tx`) || PathPrefix(`bitcoin-testnet/block`) || PathPrefix(`bitcoin-testnet/blocks`) || PathPrefix(`bitcoin-testnet/mempool`) || PathPrefix(`bitcoin-testnet/fee-estimates`) || PathPrefix(`bitcoin-testnet/scripthash`) || PathPrefix(`bitcoin-testnet/asset`))} - - traefik.http.routers.bitcoin-testnet-bitcoind-full-esplora.middlewares=bitcoin-testnet-bitcoind-full-esplora-stripprefix, ipallowlist - volumes: bitcoin-testnet-bitcoind-full: - bitcoin-testnet-bitcoind-full_esplora: x-upstreams: - id: $${ID} diff --git a/check-health.sh b/check-health.sh index cb639851..002220b7 100755 --- a/check-health.sh +++ b/check-health.sh @@ -10,11 +10,12 @@ fi RPC_URL=$1 shift -# Check for --starknet / --aztec / --cosmos / --ripple flag +# Check for --starknet / --aztec / --cosmos / --ripple / --bitcoin flag is_starknet=false is_aztec=false is_cosmos=false is_ripple=false +is_bitcoin=false if [ "$1" == "--starknet" ]; then is_starknet=true shift @@ -27,6 +28,9 @@ elif [ "$1" == "--cosmos" ]; then elif [ "$1" == "--ripple" ]; then is_ripple=true shift +elif [ "$1" == "--bitcoin" ]; then + is_bitcoin=true + shift fi REF="" @@ -102,6 +106,34 @@ if $is_ripple; then echo "online"; exit 0 fi +# Bitcoin-family (bitcoind/dogecoind): getblockchaininfo — initialblockdownload=true means syncing. +# Short-circuits here; the EVM/starknet/aztec block-comparison path below is not used. +if $is_bitcoin; then + status=$(curl -L --ipv4 -m $timeout -s -u username:password -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"1.0","id":1,"method":"getblockchaininfo","params":[]}' "$RPC_URL") + if [ $? -ne 0 ] || [ -z "$status" ]; then echo "error"; exit 1; fi + ibd=$(echo "$status" | jq -r '.result.initialblockdownload' 2>/dev/null) + node_height=$(echo "$status" | jq -r '.result.blocks' 2>/dev/null) + if [ -z "$node_height" ] || [ "$node_height" = "null" ]; then echo "error"; exit 1; fi + if [ "$ibd" = "true" ]; then echo "syncing"; exit 1; fi + if [ -n "$ref" ]; then + ref_status=$($BASEPATH/multicurl.sh -L --ipv4 -m $timeout -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"1.0","id":1,"method":"getblockcount","params":[]}' $ref) + ref_height=$(echo "$ref_status" | jq -r '.result' 2>/dev/null) + if [ -n "$ref_height" ] && [ "$ref_height" != "null" ] && [ "$ref_height" -gt 0 ] 2>/dev/null; then + lag=$(( ref_height - node_height )) + lo=${LAGGING_LAG:-2}; hi=${SYNCING_LAG:-6} + if [ "$lo" -gt "$hi" ]; then tmp=$lo; lo=$hi; hi=$tmp; fi + if [ "$lag" -le "$lo" ]; then + echo "online"; exit 0 + elif [ "$lag" -le "$hi" ]; then + echo "lagging"; exit 0 + else + echo "syncing"; exit 1 + fi + fi + fi + echo "online"; exit 0 +fi + response_file=$(mktemp) # Use appropriate RPC method based on chain type diff --git a/compose_registry.json b/compose_registry.json index 1df46b38..6429fbb6 100644 --- a/compose_registry.json +++ b/compose_registry.json @@ -1258,13 +1258,12 @@ "compose_file": "bitcoin/bitcoind/bitcoin-mainnet-bitcoind-full", "features": [], "network": "bitcoin", - "node": "esplora", + "node": null, "relay": null, "stack": null, "type": "full", "volumes": [ - "bitcoin-mainnet-bitcoind-full", - "bitcoin-mainnet-bitcoind-full_esplora" + "bitcoin-mainnet-bitcoind-full" ] }, { @@ -1273,13 +1272,12 @@ "compose_file": "bitcoin/bitcoind/bitcoin-testnet-bitcoind-full", "features": [], "network": "bitcoin", - "node": "esplora", + "node": null, "relay": null, "stack": null, "type": "full", "volumes": [ - "bitcoin-testnet-bitcoind-full", - "bitcoin-testnet-bitcoind-full_esplora" + "bitcoin-testnet-bitcoind-full" ] }, { diff --git a/sync-status.sh b/sync-status.sh index 70bf8b0d..ecad1fde 100755 --- a/sync-status.sh +++ b/sync-status.sh @@ -54,7 +54,7 @@ for path in $pathlist; do fi case "$protocol" in - eth|starknet|aztec|cosmos|ripple) + eth|starknet|aztec|cosmos|ripple|bitcoin) ;; *) # Protocol family known from the registry but no probe support @@ -69,10 +69,12 @@ for path in $pathlist; do is_aztec=false is_cosmos=false is_ripple=false + is_bitcoin=false [ "$protocol" = "starknet" ] && is_starknet=true [ "$protocol" = "aztec" ] && is_aztec=true [ "$protocol" = "cosmos" ] && is_cosmos=true [ "$protocol" = "ripple" ] && is_ripple=true + [ "$protocol" = "bitcoin" ] && is_bitcoin=true ref='' if [ -n "$2" ]; then @@ -143,6 +145,12 @@ for path in $pathlist; do if [ -n "$chain_slug" ]; then ref=$($BASEPATH/reference-rpc-endpoint.sh --chain "$chain_slug" 2>/dev/null) || ref="" fi + elif $is_bitcoin; then + # Bitcoin-family (bitcoind/dogecoind): no chainid. Reference by drpc slug + # (optional — initialblockdownload is authoritative; ref only adds a head-gap check). + if [ -n "$chain_slug" ]; then + ref=$($BASEPATH/reference-rpc-endpoint.sh --chain "$chain_slug" 2>/dev/null) || ref="" + fi else # Ethereum chain ID detection chain_id_response=$(curl -L --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $RPC_URL) @@ -196,6 +204,8 @@ for path in $pathlist; do timeout "$HC_TIMEOUT" $BASEPATH/check-health.sh "$RPC_URL" --cosmos $ref elif $is_ripple; then timeout "$HC_TIMEOUT" $BASEPATH/check-health.sh "$RPC_URL" --ripple $ref + elif $is_bitcoin; then + timeout "$HC_TIMEOUT" $BASEPATH/check-health.sh "$RPC_URL" --bitcoin $ref else timeout "$HC_TIMEOUT" $BASEPATH/check-health.sh "$RPC_URL" $ref fi