Skip to content

feat: add per-method RPC timeout configuration - #110

Closed
KENILSHAHH wants to merge 1 commit into
megaeth-labs:mainfrom
KENILSHAHH:kenil/feat/per-method-rpc-timeouts
Closed

KENILSHAHH wants to merge 1 commit into
megaeth-labs:mainfrom
KENILSHAHH:kenil/feat/per-method-rpc-timeouts

Conversation

@KENILSHAHH

Copy link
Copy Markdown

Summary

  • Previously all RPC calls shared no timeout, making it impossible to balance
    the tradeoff between witness fetches (which can legitimately take several
    seconds on heavy blocks) and block/header fetches (which should return in
    milliseconds). A single tight timeout caused false witness failures; a single
    loose one left workers hanging on stuck block fetches.
  • Add block_timeout, witness_timeout, and code_timeout fields
    (Option<Duration>) to RpcClientConfig with corresponding with_* builder
    methods. All default to None — fully backwards compatible.
  • Add a private apply_timeout helper on RpcClient that wraps any future with
    tokio::time::timeout when a timeout is set, and passes through with zero
    overhead when None.
  • Apply code_timeout to get_code, block_timeout to get_block_unchecked /
    get_latest_block_number / get_header / get_transaction_by_hash, and
    witness_timeout to fetch_witness_from_provider (covers both primary and
    Cloudflare fallback paths).
  • Expose --block-timeout-secs, --witness-timeout-secs, --code-timeout-secs
    CLI flags (and STATELESS_VALIDATOR_*_TIMEOUT_SECS env vars) in the
    stateless-validator binary so operators can tune timeouts at deploy time
    without recompiling.

@flyq

flyq commented Sep 24, 2026

Copy link
Copy Markdown
Member

Closing as superseded. The problem this addressed — RPC calls with no timeout, so a stalled provider could hang a worker — was fixed on main by #129: every provider attempt is bounded by per_attempt_timeout (default 20s, --rpc-per-attempt-timeout-ms, crates/stateless-common/src/rpc_client.rs:115), and an expired attempt rotates to the next provider instead of surfacing a timeout error to the caller. #172 added a 3s connect timeout so unreachable hosts fail fast, and #182 added a witness-specific cap for deadline-bound witness fetches. The files this PR touches have also moved (crates/stateless-common/src/rpc_client.rs, bin/stateless-validator/src/app.rs). Thanks for the contribution.

@flyq flyq closed this Sep 24, 2026
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.

2 participants