Blockchain Infrastructure Production Status
Last Updated: 2025-12-04 Status: 🟢 Core Infrastructure Operational | 🟡 Bitcoin UTXO Flow In Progress
✅ COMPLETED - Production Ready
1. All Watchers Operational (5⁄5)
| Chain | Status | Block Height | Last Update | Deposit Detection | Sweep Integration |
|---|---|---|---|---|---|
| ETH | 🟢 Running | 23,939,375 | 1s ago | ✅ Native + ERC20 | ✅ Yes |
| BSC | 🟢 Running | 70,461,189 | 2s ago | ✅ Native + BEP20 | ✅ Yes |
| TON | 🟢 Running | 54,657,006 | 1s ago | ✅ Native TON | ✅ Yes |
| TRON | 🟢 Running | 78,061,847 | 4s ago | ✅ Native + TRC20 | ✅ Yes |
| BTC | 🟢 Running | 926,394 | Polling (10min) | ✅ UTXO-based | ✅ Yes |
All watchers: - ✅ Using enhanced RPC provider management (health-weighted selection) - ✅ Circuit breaker protection (optimized for fast recovery) - ✅ Cursor-based block tracking with atomic updates - ✅ Deposit detection with database wallet lookup - ✅ RabbitMQ event publishing for bot notifications - ✅ Prometheus metrics instrumentation - ✅ Graceful shutdown with context cancellation
2. getLatestBlock() Functions - All Chains
✅ Production-Ready Implementation: - Caching Strategy: 30s TTL to reduce RPC calls - Thread-Safe: RWMutex locks for concurrent access - Error Handling: Returns errors for graceful degradation - Consistent Pattern: All chains use same approach
Per-Chain Implementation:
- ETH/BSC: eth_blockNumber via JSON-RPC
- TON: getMasterchainInfo REST API
- TRON: getNowBlock HTTP API
- BTC: getblockcount Bitcoin RPC
3. Deposit Detection System
✅ All Chains Implemented:
EVM Chains (ETH, BSC)
- ✅ Native transfers via block scanning
- ✅ ERC20/BEP20
Transferevent parsing - ✅ Database-first lookup (scalable for 10k+ users)
- ✅ Confirmation threshold before credit
- ✅ Hot wallet detection (skip internal transfers)
- ✅ Sweep item auto-creation
TON
- ✅ Transaction scanning via TON RPC
- ✅ In-message parsing for deposits
- ✅ Success-only transaction filtering
- ✅ Jetton transfer detection (future)
TRON
- ✅ Native TRX transfers
- ✅ TRC20 token transfer detection
- ✅ Energy/bandwidth awareness
- ✅ Confirmation threshold
BTC (NEW)
- ✅ UTXO Model Implementation:
- Block scanning with
getblockcount - Transaction fetching via
getrawtransaction - Output (vout) parsing for recipient addresses
- Multi-output support (multiple deposits per tx)
- Satoshi → BTC conversion
- Monitored address matching
- Block scanning with
- ✅ Deposit record creation
- ✅ Sweep item upsert
- ✅ RabbitMQ notification
- ✅ Hot wallet filtering
Bitcoin Deposit Flow:
Block N received
→ For each transaction in block
→ Fetch full transaction details (getrawtransaction)
→ For each output (vout)
→ Check if output address is monitored
→ If yes: Create deposit record (satoshis)
→ Update sweep_items table
→ Publish to RabbitMQ
4. Sweep System - Fee Optimized
✅ Lazy Sweep Strategy (Cost Optimization):
| Chain | Min Idle Time | Strategy | Notes |
|---|---|---|---|
| ETH | 15 minutes | Wait for accumulation | High gas, be patient |
| BSC | 5 minutes | Fast & cheap | Low gas fees |
| TRON | 10 minutes | Balanced | Energy-based fees |
| TON | 5 minutes | Fast & cheap | Low fees |
| BTC | 30 minutes | Conservative | High fees, longer confirmations |
Sweep Triggers: 1. Immediate: Balance >= big_threshold (large deposits) 2. Idle-Based: Balance >= min_sweep_amount + idle_duration met 3. Liquidity: Hot wallet needs funds (future enhancement)
Fee Optimization: - ✅ EVM chains: Low priority gas (20 gwei default, EIP-1559 planned) - ✅ TRON: Pure-Go builder (bypasses TWC’s broken BlockHeader) - ✅ TON: TWC signing for native + Jetton transfers - ✅ BTC: Added to coordinator (sweep executor needs UTXO builder)
Current Sweep Integration: - ✅ Coordinator: All 5 chains (ETH, BSC, TRON, TON, BTC) - ✅ Planner: Fee-aware, idle-based scheduling - ✅ Executor: Chain-specific tx builders - ⚠️ BTC: Needs UTXO transaction builder for execution
5. RPC Provider Management
✅ Multi-Provider Failover: - ETH: QuickNode (priority 1) → Infura → NOWNodes → Public - BSC: QuickNode → NOWNodes → Public (binance.org) - TON: QuickNode REST API → GetBlock → Public - TRON: QuickNode → GetBlock → TronGrid → Public - BTC: QuickNode → Public (bitcoin.publicnode.com)
✅ Health & Circuit Breaker (Optimized):
Circuit Breaker:
- Threshold: 50% error rate
- Min Requests: 5 (fast trigger)
- Open Timeout: 30s (fast recovery)
- Half-Open Max: 3 attempts
Health Checks:
- Interval: 15s (frequent monitoring)
- Timeout: 10s
- Success Window: 20 requests
- Latency Window: 20 requests
✅ Selection Strategy: - Health-weighted: Prioritizes providers with best success rate & latency - Automatic fallback on provider failure - Real-time health tracking with sliding windows - Fixed: recordedCount for accurate success rate on startup
🟡 IN PROGRESS - Remaining Work
6. Bitcoin UTXO Transaction Builder
Status: Deposit detection ✅ | Sweep/Withdrawal ⚠️
What’s Needed:
1. UTXO Selection Algorithm:
- Fetch UTXOs for address via listunspent or scantxoutset
- Select optimal UTXOs (largest-first or coin selection algorithm)
- Calculate total input value
- Determine change output (if input > amount + fee)
Transaction Building:
- Create inputs (prevTxHash + vout index)
- Create outputs (recipient + change address)
- Calculate fee (size-based: ~1-10 sat/vB depending on priority)
- Build unsigned transaction (P2PKH, P2WPKH, or P2SH)
Signing:
- TWC or pure-Go Bitcoin signing
- SIGHASH_ALL for standard transactions
- Support SegWit (Bech32) addresses
Broadcasting:
sendrawtransactionvia Bitcoin RPC- Handle fee estimation errors
- Retry logic for broadcast failures
📊 System Metrics & Monitoring
Prometheus Metrics Instrumented:
watcher_blocks_scanned_total{chain, status}- Block scan success/error countwatcher_blocks_behind{chain}- How many blocks behind latestwatcher_deposits_detected{chain, status}- Deposit detection countwatcher_block_scan_duration_seconds{chain}- Block processing timerpc_calls_total{chain, provider, method, status}- RPC call countrpc_call_duration_seconds{chain, provider, method}- RPC latencyrpc_circuit_breaker_state{chain, provider}- Circuit breaker state (closed/open/half-open)
Health Check Endpoints:
- Watcher services:
:9091/healthz(per-chain) - Wallet service:
:8081/healthz - Withdrawal service:
:8082/healthz
🎯 Production Readiness Score
| Component | Status | Score |
|---|---|---|
| Watchers (All Chains) | ✅ Operational | 5⁄5 |
| Deposit Detection | ✅ Complete | 5⁄5 |
| Sweep System | ✅ Optimized (BTC executor pending) | 4.5⁄5 |
| Withdrawal System | ⚠️ BTC UTXO builder needed | 4⁄5 |
| RPC Resilience | ✅ Multi-provider + circuit breaker | 5⁄5 |
| Monitoring | ✅ Prometheus + health checks | 5⁄5 |
| Testing | ⚠️ Needs real deposit/withdrawal tests | 2⁄5 |
Overall: 85% Production Ready
This document is a copy of the root BLOCKCHAIN_PRODUCTION_STATUS.md for docs-site linking. For the full version including troubleshooting and architecture decisions, see the repo root file.