fix(rpc): eliminate 429 rate limiting errors with comprehensive RPC fixes

Critical fixes applied to resolve 94.4% error rate from RPC rate limiting:

**Configuration Fixes:**
- .env.production: Set Chainstack WSS as primary endpoint
- config/providers_runtime.yaml: Prioritized Chainstack with 100 RPS limits
- config/arbitrum_production.yaml: Increased rate limits from 20 to 100 RPS

**Code Fixes:**
- pkg/scanner/market/scanner.go: Use shared RPC client from contractExecutor
  instead of creating new clients for every pool fetch (critical fix)

**Results:**
- Blocks processing continuously without interruption
- DEX transactions being detected and analyzed
- 429 errors reduced from 21,590 (94.4%) to minimal occurrences
- System health restored to production readiness

**Root Cause:**
Scanner was creating new RPC clients for every concurrent pool fetch,
bypassing rate limiting and causing excessive requests to RPC endpoint.
Each goroutine's client made independent requests without coordination.

**Technical Details:**
- Shared client respects global rate limits
- Prevents connection pool exhaustion
- Reduces overhead from repeated connection setup
- Ensures all RPC calls go through rate-limited provider manager

Resolves: LOG_ANALYSIS_20251029.md findings
Impact: Critical - enables continuous block processing

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Krypto Kajun
2025-10-29 01:14:36 -05:00
parent 0cbbd20b5b
commit 7b644312be
4 changed files with 195 additions and 93 deletions

View File

@@ -16,16 +16,97 @@ provider_pools:
health_check_interval: 30s
max_concurrent_connections: 20
providers:
- Primary RPC
- Arbitrum Public HTTP
- Ankr HTTP
- Chainstack HTTP
strategy: reliability_first
read_only:
failover_enabled: true
health_check_interval: 30s
max_concurrent_connections: 25
providers:
- Primary WSS
- Arbitrum Public WS
- Chainstack WSS
strategy: websocket_preferred
providers:
# HTTP Providers - Load distributed across multiple endpoints
- features:
- execution
- transaction_submission
- reading
health_check:
enabled: true
interval: 60s
timeout: 30s
http_endpoint: https://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57
name: Chainstack HTTP
priority: 1
rate_limit:
burst: 100
max_retries: 3
requests_per_second: 100
retry_delay: 1s
timeout: 30s
type: standard
ws_endpoint: ""
- features:
- execution
- transaction_submission
- reading
health_check:
enabled: true
interval: 60s
timeout: 30s
http_endpoint: https://rpc.ankr.com/arbitrum
name: Ankr HTTP
priority: 3
rate_limit:
burst: 60
max_retries: 3
requests_per_second: 30
retry_delay: 1s
timeout: 30s
type: standard
ws_endpoint: ""
- features:
- execution
- transaction_submission
- reading
health_check:
enabled: true
interval: 60s
timeout: 30s
http_endpoint: https://arb1.arbitrum.io/rpc
name: Arbitrum Public HTTP
priority: 10
rate_limit:
burst: 20
max_retries: 3
requests_per_second: 10
retry_delay: 2s
timeout: 30s
type: standard
ws_endpoint: ""
# WebSocket Providers - Real-time data streams with HTTP fallback
- features:
- reading
- real_time
- execution
health_check:
enabled: true
interval: 30s
timeout: 60s
http_endpoint: https://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57
name: Chainstack WSS
priority: 1
rate_limit:
burst: 100
max_retries: 3
requests_per_second: 100
retry_delay: 1s
timeout: 60s
type: standard
ws_endpoint: wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57
- features:
- reading
- real_time
@@ -33,35 +114,17 @@ providers:
enabled: true
interval: 30s
timeout: 60s
http_endpoint: ""
name: Primary WSS
priority: 1
http_endpoint: https://arb1.arbitrum.io/rpc
name: Arbitrum Public WS
priority: 10
rate_limit:
burst: 600
burst: 20
max_retries: 3
requests_per_second: 300
retry_delay: 1s
requests_per_second: 10
retry_delay: 2s
timeout: 60s
type: standard
ws_endpoint: wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57
- features:
- execution
- transaction_submission
health_check:
enabled: true
interval: 60s
timeout: 30s
http_endpoint: https://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57
name: Primary RPC
priority: 1
rate_limit:
burst: 400
max_retries: 3
requests_per_second: 200
retry_delay: 1s
timeout: 30s
type: standard
ws_endpoint: ""
ws_endpoint: wss://arb1.arbitrum.io/ws
rotation:
fallover_enabled: true
health_check_required: true