feat: Implement dynamic weighted RPC load balancing for enhanced resilience
Summary
This PR introduces dynamic weight adjustment for RPC providers, improving failover and resilience by adapting to real-time provider health. The system now dynamically adjusts provider selection weights based on health metrics including latency, error rates, and consecutive failures.
This enhancement builds upon the static weighted RPC steering implemented in #6126, making the RPC management more adaptive and robust.
Changes
Core Implementation
-
Health Monitoring Module (
chain/ethereum/src/health.rs): New module to track RPC provider health metrics- Monitors provider latency with exponential moving average
- Tracks error rates and consecutive failures
- Calculates health scores for weight adjustment
Integration Points
-
Dynamic Weight Adjustment (
chain/ethereum/src/network.rs): Integrated health metrics into provider selection logic- Provider weights are now dynamically adjusted based on health scores
- Traffic is automatically steered away from underperforming endpoints
- Maintains compatibility with existing weighted selection algorithm
-
Health Checker Initialization (
node/src/network_setup.rs): Setup and management of health checkers for Ethereum RPC adapters- Initializes health monitoring for each RPC provider
- Manages lifecycle of health check processes
Dependencies
- Added
tokiodependency tochain/ethereumandnodecrates for asynchronous health checks
Testing
- Updated test cases in
chain/ethereum/src/network.rsto accommodate dynamic weighting behavior
Related Issues
Builds on #6126 - Weighted RPC load balancing
Test Plan
- [ ] Unit tests pass with dynamic weight adjustments
- [ ] Integration tests verify failover behavior
- [ ] Manual testing with multiple RPC providers shows proper weight adjustment
- [ ] Verify health metrics correctly influence provider selection
- [ ] Confirm graceful degradation when providers become unhealthy
🤖 Generated with Claude Code