Skip to content

proxyd: skip consensus polling for forced candidate backends - #608

Open
jcortejoso wants to merge 155 commits into
ethereum-optimism:mainfrom
celo-org:jcortejoso/skip-polling-forced-candidates
Open

jcortejoso wants to merge 155 commits into
ethereum-optimism:mainfrom
celo-org:jcortejoso/skip-polling-forced-candidates

Conversation

@jcortejoso

Copy link
Copy Markdown

Summary

  • Backends with consensus_forced_candidate = true are now excluded from the consensus polling loop entirely — zero health check requests (eth_syncing, net_peerCount, eth_getBlockByNumber)
  • Forced candidates remain in the consensus group for request routing, so they still serve archive requests when restrict_archive_node_traffic = true
  • Forced candidates no longer affect consensus block number calculations or block hash verification

Motivation

When paid backends like Alchemy are in a consensus-aware group, the consensus poller sends ~5 RPC requests/second/backend for health checks — even when the proxyd instance receives zero frontend traffic. This generates unnecessary costs.

With this change, configuring a backend with consensus_forced_candidate = true means it participates in routing (especially archive request routing) without any polling overhead.

Example config

[backends.alchemy]
rpc_url = "$ALCHEMY_URL"
archive = true
consensus_forced_candidate = true

[backend_groups.all]
backends = ["nethermind", "reth", "alchemy"]
consensus_aware = true
restrict_archive_node_traffic = true

Test plan

  • New TestConsensusForcedCandidate integration tests verify:
    • Forced candidate is included in consensus group without being polled
    • Forced candidate receives zero polling requests
    • Forced candidate's zero block state doesn't drag consensus to 0x0
  • All existing TestConsensus tests pass (38/38)

jcortejoso and others added 27 commits September 8, 2025 09:29
- Introduced a new TOML configuration file for sequencer and network settings.
- Added support for multiple sequencer configurations with specific URLs and voting options.
- Updated the Python version to 3.12.7 in the project.
Add configuration for sequencers and networks
…ling

- Introduced a new test function `TestContainsArchiveRequiredError` to validate various scenarios for detecting archive required errors in RPC responses.
- Enhanced the `containsArchiveRequiredError` function to check for additional error messages related to state availability for blocks.
- Added checks for new error messages related to the maximum proof window and distance to target block in the `containsArchiveRequiredError` function to improve error handling for RPC responses.
- Updated the `rewriteParam` function to improve error handling for out-of-range block requests.
- Introduced `handleRewriteTagResult` to manage responses based on error conditions.
- Modified tests to validate that out-of-range block requests return null instead of an error.
- Enhanced the `TestRewriteRequest` and `TestConsensus` tests to reflect the new behavior for `eth_getBlockByNumber` requests.
- Added checks for new error messages related to data availability in the `containsArchiveRequiredError` function to improve error handling for RPC responses.
- Added .gocache and .gomodcache to the .gitignore file to prevent caching files from being tracked in the repository.
- Added additional checks for error messages related to pruned state blocks in the `containsArchiveRequiredError` function to further improve error handling for RPC responses.
Proxyd: return `null` for out-of-range block requests
- Added logic to set `archiveRequired` to true for any RPC requests with methods that start with "debug_". This ensures that the necessary archive nodes are utilized for these requests.
Add a new `watched_addresses` config option that accepts a list of
Ethereum addresses. When a transaction's `from` or `to` field matches
any watched address, all available transaction details are logged
(hash, from, to, nonce, value, gas, gasPrice, gasTipCap, gasFeeCap,
chainId, txType, data, blobGas, etc.).

Supports eth_sendRawTransaction (full decoded tx details),
eth_sendTransaction, eth_call, and eth_estimateGas (call object fields).
Integrated into both HTTP RPC and WebSocket request paths.
When backends with limited archive retention return "no transactions
snapshot file" errors, proxyd now automatically retries with backends
that have fuller archive data (e.g., Alchemy with full chain history).

Changes:
- Added "no transactions snapshot file" pattern to containsArchiveRequiredError()
- Checks both Error.Message and Error.Data fields for the pattern
- Added unit tests verifying the error detection works correctly

This leverages the existing two-phase retry logic in ForwardRequestToBackendGroup,
which automatically tries archive backends when archive-required errors are detected.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ting

Route eth_getBlockReceipts to archive backends based on block age to prevent
non-archive nodes returning empty receipt arrays for old blocks. Make the
archive block threshold configurable (archive_block_threshold) instead of
hardcoded at 128 blocks, defaulting to 128 when unset.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Non-archive backends return "result": [] (valid JSON-RPC success) for
eth_getBlockReceipts on pruned blocks instead of an error. This causes
op-node to fail with "got 0 receipts but expected N". Detect empty
receipt arrays and retry on other backends including archive nodes,
reusing the existing archive retry infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Returns 200 OK when all backend groups have at least one healthy
backend, and 503 when any group has no healthy backends. This enables
GCP load balancers to detect proxyd instances that cannot serve requests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add /readyz readiness endpoint to proxyd
Change ConsensusMaxBlockLag from uint64 to *uint64 so that an
explicit 0 in config is distinguishable from "not set" (which
falls back to the default of 8). This enables zero-tolerance
block lag for testnet environments.
…ck-lag

proxyd: allow consensus_max_block_lag to be set to 0
Backends with consensus_forced_candidate=true are now excluded from
the consensus polling loop. They remain in the consensus group for
request routing (including archive requests) but generate zero health
check traffic (eth_syncing, net_peerCount, eth_getBlockByNumber).

This is useful for paid backends like Alchemy that should serve archive
requests but shouldn't be flooded with polling requests when idle.

Changes:
- Skip forced candidates in the primary and fallback polling loops
- Skip forced candidates in consensus block number calculations
- Skip forced candidates in block hash verification
- Skip forced candidates in the block lag filter
@jcortejoso
jcortejoso requested a review from a team as a code owner April 21, 2026 09:56
@jcortejoso
jcortejoso requested a review from ajsutton April 21, 2026 09:56
@ajsutton
ajsutton removed their request for review April 22, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants