Crates.io | edb-rpc-proxy |
lib.rs | edb-rpc-proxy |
version | 0.0.1 |
created_at | 2025-09-19 14:24:57.713554+00 |
updated_at | 2025-09-19 14:24:57.713554+00 |
description | Caching RPC proxy server for EDB |
homepage | https://medga.org/ |
repository | https://github.com/edb-rs/EDB |
max_upload_size | |
id | 1846552 |
size | 549,258 |
A high-performance, intelligent caching RPC proxy for Ethereum that can reduce RPC requests by 70-90% and dramatically accelerate blockchain debugging and development workflows.
This document is created by Claude with β€οΈ.
Install and run in 30 seconds:
# Clone and build
git clone https://github.com/MedGa-eth/EDB
cd EDB
cargo build --release -p edb-rpc-proxy
# Start proxy server with sensible defaults
./target/release/edb-rpc-proxy server
# Or monitor a running proxy with TUI
./target/release/edb-rpc-proxy monitor http://localhost:8546
Use immediately:
# Point your RPC client to the proxy
curl -X POST http://localhost:8546 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Common Issues
If you are using Foundry (e.g., cast
) and ebd-rpc-proxy
together, where ebd-rpc-proxy
is running on a loopback address (e.g., 127.0.0.1
), you may encounter connection issues. This is because Foundry's HTTP client (reqwest/hyper) honors *_PROXY
environment variables and may route http://127.0.0.1:...
through your local proxy, which often drops loopback-to-loopback forwarding. On macOS, localhost
may resolve to ::1
(IPv6) first; if your RPC server isn't bound to IPv6, localhost
wonβt work even though 127.0.0.1
does.
To bypass these issues, run the CLI with proxy bypasses for both IPv4 and IPv6 loopback, and use an explicit loopback that your server actually binds to:
# Ensure loopback addresses bypass any proxy and clear proxy vars
NO_PROXY=localhost,127.0.0.1,::1 \
no_proxy=localhost,127.0.0.1,::1 \
HTTP_PROXY= HTTPS_PROXY= ALL_PROXY= \
http_proxy= https_proxy= all_proxy= \
cast tx 0xda0df2b215534a6cea2304f55ffa307bcb0f4e4b55e3a1158fc9bcde1fd76ae0 \
--rpc-url http://127.0.0.1:54321
If you've ever faced these problems:
Then EDB RPC Proxy is your solution!
EDB RPC Proxy was originally developed as part of the EDB (Ethereum Debugger) project but provides universal benefits for any Ethereum development workflow. While it includes EDB-specific features like instance registration and lifecycle management, the core caching and multi-provider functionality benefits any RPC client.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EDB RPC PROXY β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β EDB Client β β Any RPC β β Hardhat/ β β
β β Instance β β Client β β Foundry β β
β βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ β
β β β β β
β ββββββββββββββββββββββββΌβββββββββββββββββββββββ β
β β β
β ββββββββΌβββββββ β
β β HTTP API β β
β β (Port 8546) β β
β ββββββββ¬βββββββ β
β β β
β ββββββββββββββββββββββββΌβββββββββββββββββββββββ β
β β βΌ β β
β β βββββββββββββββββββββββ β β
β β β RPC HANDLER β β β
β β β β β β
β β β βββββββββββββββββββ β β β
β β β β Smart Cache β β β β
β β β β β’ 55+ Methods β β β β
β β β β β’ Deterministic β β β β
β β β β β’ Block Params β β β β
β β β βββββββββββββββββββ β β β
β β ββββββββββββ¬βββββββββββ β β
β β β β β
β βββββββββΌβββββββββ β βββββββββββββββΌβββββ β
β β CACHE MANAGER β β β PROVIDER MANAGER β β
β β β β β β β
β β ββββββββββββββ β β β ββββββββββββββββ β β
β β β In-Memory β β β β β Weighted β β β
β β β LRU Cache β β β β β Selection β β β
β β ββββββββββββββ β β β ββββββββββββββββ β β
β β ββββββββββββββ β β β ββββββββββββββββ β β
β β β Disk Cache β β β β βHealth Monitorβ β β
β β β Atomic I/O β β β β β& Error Track β β β
β β ββββββββββββββ β β β ββββββββββββββββ β β
β ββββββββββββββββββ β βββββββββββ¬βββββββββ β
β β β β
β ββββββββΌβββββββ β β
β β CACHE β β β
β β HIT β β β
β ββββββββ¬βββββββ β β
β β β β
β ββββββββΌβββββββ ββββββββββΌββββββββ β
β β Return β β Forward to β β
β β Cached β β Best β β
β β Response β β Provider β β
β βββββββββββββββ ββββββββββ¬ββββββββ β
β β β
βββββββββββββββββββββββββββββββββββββββββββββ-ββββββββββΌββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ
β WEIGHTED PROVIDER SELECTION (13 Endpoints) β
βββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ
β
ββββββββββββββββ¬βββββββββββββββ¬βββββββββββΌβββββββββββ¬βββββββββββββββ
β β β β β
ββββββΌββββ βββββββΌβββββ βββββββΌβββββ βββββ-ββΌββββ βββ-ββββΌββββ
βGateway β βPublicNodeβ βTenderly β ... β Ankr β β LlamaRPC β
β Tier 1 β β Tier 2 β β Tier 1 β β Tier 3 β β Tier 2 β
ββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
# Clone the EDB repository
git clone https://github.com/MedGa-eth/EDB
cd EDB
# Build the RPC proxy
cargo build --release -p edb-rpc-proxy
# The binary will be at: ./target/release/edb-rpc-proxy
./target/release/edb-rpc-proxy --help
The proxy has two main operation modes:
# Start proxy server with defaults
edb-rpc-proxy server
# Start with custom configuration
edb-rpc-proxy server --port 8547 --max-cache-items 500000
# Monitor a local proxy
edb-rpc-proxy monitor http://localhost:8546
# Monitor a remote proxy
edb-rpc-proxy monitor https://your-proxy.example.com:8546
Option | Default | Description |
---|---|---|
--help |
- | Show help information |
--version |
- | Show version information |
Argument | Default | Description |
---|---|---|
--port |
8546 |
HTTP server listening port |
--rpc-urls |
13 public RPCs | Comma-separated upstream RPC endpoints |
Argument | Default | Description |
---|---|---|
--max-cache-items |
1024000 |
Maximum cached responses (~1GB for 1M items) |
--cache-dir |
~/.edb/cache/rpc/<chain_id>/ |
Cache storage directory |
--cache-save-interval |
5 |
Minutes between disk saves (0 = shutdown only) |
Argument | Default | Description |
---|---|---|
--max-failures |
3 |
Failures before marking provider unhealthy |
--health-check-interval |
60 |
Seconds between provider health checks |
Argument | Default | Description |
---|---|---|
--grace-period |
0 |
Seconds before auto-shutdown when no EDB instances (0 = never) |
--heartbeat-interval |
10 |
Seconds between EDB instance health checks |
Development Mode (auto-shutdown when idle):
edb-rpc-proxy server --grace-period 300 --cache-save-interval 1
# Saves cache every minute, shuts down after 5 minutes of no activity
Production Mode (long-running service):
edb-rpc-proxy server --port 8546 --max-cache-items 500000 --grace-period 0
# Large cache, never auto-shutdown, standard port
High-Performance Setup:
edb-rpc-proxy server \
--max-cache-items 1000000 \
--cache-save-interval 10 \
--health-check-interval 30 \
--max-failures 2
# 1M item cache, frequent health checks, fast failover
50MB + (max_cache_items Γ 1KB)
The TUI provides real-time monitoring of a running proxy instance:
edb-rpc-proxy monitor http://localhost:8546
Key | Action |
---|---|
Tab |
Navigate between tabs |
β β |
Switch tabs |
r |
Refresh data |
c |
Clear cache (with confirmation) |
q / Ctrl+C |
Quit |
While the proxy works with any RPC client, it includes special features for EDB instances:
EDB instances can register themselves for lifecycle management:
# EDB instances automatically call:
curl -X POST http://localhost:8546 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"edb_register","params":[12345, 1703123456],"id":1}'
Registered instances send periodic heartbeats:
curl -X POST http://localhost:8546 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"edb_heartbeat","params":[12345],"id":1}'
When --grace-period > 0
, the proxy automatically shuts down when no EDB instances are active, preventing resource waste.
This functionality can be adopted by any project - simply implement the registration and heartbeat calls in your application.
All standard Ethereum RPC methods are supported and automatically cached when appropriate:
curl -X POST http://localhost:8546 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1000000",false],"id":1}'
Method | Description | Example Response |
---|---|---|
edb_ping |
Service health check | {"status": "healthy", "timestamp": 1703123456} |
edb_info |
Detailed service info | Version, uptime, PID, cache info |
edb_cache_stats |
Cache utilization | Hit rate, size, utilization |
edb_cache_metrics |
Method-level cache stats | Per-method hit rates and performance |
edb_active_instances |
List registered EDB instances | PIDs and last heartbeat times |
edb_providers |
Provider health status | Health, response times, failure counts |
edb_shutdown |
Graceful shutdown | Saves cache and stops service |
# Check service health
curl -X POST http://localhost:8546 \
-d '{"jsonrpc":"2.0","method":"edb_ping","id":1}'
# Get detailed cache statistics
curl -X POST http://localhost:8546 \
-d '{"jsonrpc":"2.0","method":"edb_cache_metrics","id":1}'
# Check provider health and performance
curl -X POST http://localhost:8546 \
-d '{"jsonrpc":"2.0","method":"edb_providers","id":1}'
Problem: You're hitting rate limits on free public RPC providers and constantly switching between them manually.
Solution: The proxy automatically rotates through 13+ providers with intelligent failover.
# Start proxy with default free providers
edb-rpc-proxy server
# The proxy handles:
# - Automatic rotation when rate limited
# - Weighted selection based on performance
# - Seamless failover without manual intervention
# - Each provider tried only once per request
# Your app just uses one endpoint:
curl http://localhost:8546 # Never worry about rate limits again!
Real Example: A developer scanning NFT metadata hits Ankr's rate limit. The proxy automatically switches to LlamaRPC, then Tenderly, keeping the scan running without any code changes.
Problem: You have Infura/Alchemy but want to reduce costs by using free RPCs when possible and caching repeated requests.
Solution: Mix paid and free providers with intelligent caching.
# Combine paid and free RPCs (paid as fallback)
edb-rpc-proxy server --rpc-urls \
"https://eth.llamarpc.com,\
https://rpc.ankr.com/eth,\
https://mainnet.infura.io/v3/YOUR_KEY"
# Benefits:
# - Free RPCs used first (weighted by performance)
# - Paid RPC as reliable fallback
# - 70-90% reduction through caching
# - One request cached = savings for entire team
Real Example: A DeFi protocol saves $3,000/month by caching eth_getLogs
queries that their 50-person team repeatedly makes while debugging the same smart contract events.
Problem: Your MEV bot or critical service uses a local node that might silently fail, causing missed opportunities.
Solution: Use proxy as an automatic failover layer with health monitoring.
# Local node as primary, public RPCs as emergency backup
edb-rpc-proxy server --rpc-urls \
"http://localhost:8545,\
https://rpc.flashbots.net/fast,\
https://eth.llamarpc.com" \
--health-check-interval 10 \
--max-failures 1
# Your MEV bot configuration:
const provider = new ethers.JsonRpcProvider('http://localhost:8546');
// If local node fails, proxy instantly switches to Flashbots RPC
// Your bot never misses a block!
Real Example: An MEV searcher's local node crashed at 3 AM. The proxy automatically failed over to Flashbots RPC, allowing the bot to continue operating and capture a $50K arbitrage opportunity.
Problem: Debug traces cost 10-100x more compute than regular calls. Teams repeatedly debug the same transactions.
Solution: Cache expensive debug calls for instant team-wide access.
# First developer triggers expensive computation
cast run 0xabc... --rpc-url http://localhost:8546 # Takes 3 seconds
# Rest of the team gets instant access
cast run 0xabc... --rpc-url http://localhost:8546 # Takes 5ms (cached!)
# Massive time savings:
# - 10 developers debugging same tx = 30 seconds β 3 seconds total
# - Complex traces cached permanently
# - Share cache across team via network mount
Real Example: Uniswap team debugging a complex MEV sandwich attack. First developer waits 5 seconds for trace computation. Next 20 team members analyzing the same attack get instant responses.
Problem: Hardhat/Foundry fork tests make thousands of identical RPC calls, slowing down test suites.
Solution: Cache fork state queries across test runs.
# First test run populates cache
npx hardhat test --network mainnet # 2 minutes
# Subsequent runs use cache
npx hardhat test --network mainnet # 30 seconds
# CI/CD benefits:
# - Faster test execution
# - Reduced RPC costs
# - Deterministic test data
Real Example: Compound's test suite reduced from 5 minutes to 45 seconds by caching eth_getStorageAt
calls used in fork tests.
Problem: Your global dApp needs reliable RPC access across different regions with automatic geo-failover.
Solution: Deploy proxy instances in multiple regions with shared cache.
# US Instance
edb-rpc-proxy server --cache-dir /shared/cache --port 8546
# EU Instance
edb-rpc-proxy server --cache-dir /shared/cache --port 8547
# Asia Instance
edb-rpc-proxy server --cache-dir /shared/cache --port 8548
# Benefits:
# - Shared cache across regions
# - Automatic regional failover
# - Reduced latency for global users
Real Example: A DEX aggregator runs proxy instances in 3 AWS regions, reducing average RPC latency from 200ms to 50ms for global users.
Problem: Tools like Etherscan verification or Slither analysis repeatedly fetch the same bytecode and state.
Solution: Cache contract data for faster repeated analysis.
# Run Slither analysis with proxy
export WEB3_PROVIDER_URI=http://localhost:8546
slither MyContract.sol
# Benefits:
# - Contract bytecode cached
# - State queries cached
# - 10x faster repeated analysis
Real Example: Security firm reduces contract audit time by 40% by caching all contract interactions during initial analysis phase.
# For high-volume usage, increase cache size
edb-rpc-proxy server --max-cache-items 1000000
# For memory-constrained environments
edb-rpc-proxy server --max-cache-items 50000
# Faster failover for critical applications
edb-rpc-proxy server --max-failures 1 --health-check-interval 15
# More tolerance for unstable providers
edb-rpc-proxy server --max-failures 5 --health-check-interval 120
# Frequent saves for critical data
edb-rpc-proxy server --cache-save-interval 1
# Reduce I/O for high-performance setups
edb-rpc-proxy server --cache-save-interval 30
The proxy intelligently caches 55+ RPC methods when they use deterministic parameters:
eth_chainId
, net_version
eth_getTransactionByHash
, eth_getTransactionReceipt
eth_getBlockByHash
, eth_getBlockByNumber
(with specific block numbers)eth_call
, eth_getBalance
, eth_getCode
(only with specific block numbers, not "latest")debug_traceTransaction
, trace_transaction
(immutable once computed)eth_getLogs
(only with specific block ranges)eth_blockNumber
, eth_gasPrice
, eth_estimateGas
net_peerCount
, eth_syncing
The proxy uses a sophisticated weighted selection system:
# Development mode with debug logging
RUST_LOG=debug cargo run --bin edb-rpc-proxy -- server --grace-period 300
# Run with TUI monitoring
cargo run --bin edb-rpc-proxy -- monitor http://localhost:8546
# Run tests
cargo test -p edb-rpc-proxy
# Run with custom configuration
cargo run --bin edb-rpc-proxy -- server \
--port 8547 \
--max-cache-items 10000 \
--cache-save-interval 1
# Run all tests
cargo test -p edb-rpc-proxy
# Run specific test
cargo test -p edb-rpc-proxy test_provider_tried_once_per_request
# Run with output
cargo test -p edb-rpc-proxy -- --nocapture
# Run integration tests
cargo test -p edb-rpc-proxy --test integration_tests
git checkout -b feature/amazing-feature
cargo test -p edb-rpc-proxy
This project is licensed under the MIT OR Apache-2.0 license.
Get started in 30 seconds β Just run edb-rpc-proxy server
and point your RPC client to http://localhost:8546
!