feat(op-reth): support multiple sequencer HTTP endpoints with automatic failover#214
Draft
brendontan03 wants to merge 4 commits intodevfrom
Draft
feat(op-reth): support multiple sequencer HTTP endpoints with automatic failover#214brendontan03 wants to merge 4 commits intodevfrom
brendontan03 wants to merge 4 commits intodevfrom
Conversation
This reverts commit 4c6a5e1.
Add tests for transport error failover, local usage error handling, mixed HTTP/WS endpoint rejection, trailing comma parsing, config with timeouts, and constructor delegation. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--rollup.sequencer-httpfor automatic failover--rollup.sequencer-dial-timeoutand--rollup.sequencer-request-timeoutCLI flags for configurable timeoutsAtomicUsizepreferred index and pre-built alloy clients sharing a single reqwest connection poolMirrors the equivalent feature in op-geth (op-geth PR #764).
Changes
op-reth/crates/rpc/src/sequencer.rsSequencerClientConfig, failover-awarerequest(),should_failover()classificationop-reth/crates/rpc/src/metrics.rsop-reth/crates/rpc/src/error.rsAllEndpointsFailedvariant toSequencerClientErrorop-reth/crates/node/src/args.rs--rollup.sequencer-dial-timeout(default 5s) and--rollup.sequencer-request-timeout(default 10s) CLI flagsop-reth/crates/node/src/node.rsOpAddOnsBuilder, update bothSequencerClientconstruction sites to usenew_with_configop-reth/crates/rpc/src/eth/mod.rsOpEthApiBuilder, useSequencerClientConfiginbuild_eth_api()op-reth/crates/rpc/src/lib.rsSequencerClientConfigDesign
Failover logic: On each RPC call, try the preferred endpoint first, then cycle through remaining endpoints. Transport errors (network failures, null responses, deserialization errors) trigger failover. Application errors (
ErrorRespfrom sequencer) return immediately.Concurrency: Lock-free by design. All alloy
Clientinstances are pre-built at startup and share a singlereqwest::Client(connection pool). Onlypreferred_index: AtomicUsizeis mutated — no mutex needed, unlike the Go implementation which requiressync.Mutexdue to statefulrpc.Clientconnections.Backward compatible: Single URL still works exactly as before. WebSocket is supported for single endpoints only.
Usage
Test plan
should_failover()across allRpcErrorvariantsSequencerClientConfigwith timeoutscargo check -p reth-optimism-rpc -p reth-optimism-nodepassescargo test -p reth-optimism-rpc -p reth-optimism-nodepasses (19 sequencer tests, 9 args tests)🤖 Generated with Claude Code