proxyd is an important RPC request router and proxy used within the OP Stack infrastructure. It enables operators to efficiently route and manage RPC requests across multiple backend services, ensuring performance, fault tolerance, and security.
Key features
- RPC method whitelisting
- Backend request routing
- Automatic retries for failed backend requests
- Consensus tracking (latest, safe, and finalized blocks)
- Request/response rewriting to enforce consensus
- Load balancing across backend services
- Caching of immutable responses
- Metrics for request latency, error rates, and backend health
How it works
To start usingproxyd, follow these steps:
1
Build the binary:
- Run the following command to build the
proxydbinary: - This will build the
proxydbinary. No additional dependencies are required.
2
Configure proxyd:
- Create a configuration file to define your proxy backends and routing rules.
- Refer to example.config.toml for a full list of options with commentary.
3
Start the service:
Once the configuration file is ready, start the
proxyd service using the following command:Consensus awareness
Version 4.0.0 and later include consensus awareness to minimize chain reorganizations. Enable it per backend group withrouting_strategy = "consensus_aware" (the older consensus_aware = true setting is deprecated, and the two cannot be set together). Consensus awareness enables:
- Polling backends for consensus data (latest block, safe block, peer count, etc.).
- Resolving consensus groups based on healthiest backends
- Enforcing consensus state across client requests
consensus_aware is for execution-client backends.
For consensus-layer backends, such as the follow source of a Light CL fleet, use consensus_aware_consensus_layer, described next.
Consensus-layer routing for follow sources
routing_strategy = "consensus_aware_consensus_layer" (proxyd v4.27.5 and later; use the latest release) puts a pool of op-node or op-supernode instances behind one highly available endpoint.
Point the --l2.follow.source flag of your Light CLs at it instead of at a single source.
In this mode, proxyd:
- Polls each backend’s
optimism_syncStatusand excludes a backend whose derivation lags L1 by more thanconsensus_cl_sync_thresholdL1 blocks (default10) or whose L1 head is older thanconsensus_cl_head_l1_max_age(default5m). - Compares
optimism_outputAtBlockat the consensus safe block across backends on each poll. A backend that disagrees with a strict majority is banned. If there is no majority (for example, a 1–1 split), proxyd freezes the served state at the last agreed value and rejects other requests until a majority returns, so run at least three backends. - Answers
optimism_syncStatusfrom the in-consensus backend that is furthest behind on L1, so it serves the most conservative view in the pool. - Checks each backend’s P2P peer count through
opp2p_peerStats, unless the backend setsconsensus_skip_peer_count = true. Set it on backends that run with P2P disabled, such as supernodes behind a Light CL fleet that handles gossip itself; otherwise proxyd never admits them to the consensus group.
/<chainID>) of your op-supernodes.
This example serves OP Mainnet (chain ID 10) from three supernodes that run with --disable-p2p=true:
--l2.follow.source=http://<this-proxyd>:8545, with no /<chainID> suffix.
Repeat with the Unichain path (/130) for a second instance that serves the Unichain fleet.
A Light CL only calls optimism_syncStatus on its follow source, so that is the only method the instance needs to map.
Caching and metrics
Cacheable methods
Certain immutable methods, such aseth_chainId and eth_getBlockByHash, can be cached using Redis to optimize performance.
Metrics
Extensive metrics are available to monitor request latency, error rates, backend health, and more. These can be configured viametrics.port and metrics.host in the configuration file.
Next steps
- Read about the OP Stack chain architecture.
- Find out how you can support snap sync. on your chain.
- Find out how you can utilize blob space to reduce the transaction fee cost on your chain.