You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bd9355a
Browse filesBrowse the repository at this point in the historyBrowse files
Apply per-method deadlines to EVM JSON-RPC over HTTP and WebSocket (#4299)
Most EVM JSON-RPC read methods have no deadline. `eth_getBalance`,
`eth_getBlockByNumber`, `eth_getTransactionReceipt`, and friends run as
long as client keeps waiting. Slow or pathological query holds worker
goroutine and store read past point anyone still listens, degrading RPC
node.
Config knobs:
- `evm.rpc_default_timeout` (default `30s`): deadline for any covered
method with no override.
- `evm.rpc_method_timeouts`: `method=duration` overrides (e.g.
`eth_call=60s`). Defaults ship for `eth_call`, `eth_estimateGas`,
`eth_createAccessList` (`60s`) and `eth_estimateGasAfterCalls` (`5m`,
outer bound over whole call batch). An entry's method name may end in
`*` (e.g. `debug_trace*=0`) to match every method with that prefix
instead of one exact name; the longest matching prefix wins when more
than one could apply.
Zero disables default or a method's deadline. Negative durations
rejected at config time.
### Enforcement
`rpc.Server.SetDeadlineHook`
([sei-protocol/go-ethereum#102](sei-protocol/go-ethereum#102),
shipped in `v1.15.7-sei-21`, pinned via #4332) hooks into `runMethod`,
the single dispatch point every plain call and every `*_subscribe` setup
call passes through, on both HTTP and WebSocket. `evmrpc`'s
`EnableRPC`/`EnableWS` call `srv.SetDeadlineHook(withDeadline)`. Every
registered method gets a deadline uniformly, no per-handler opt-in
needed.
WebSocket requests get full configured deadline. HTTP responses still
bounded separately by `write_timeout`; raise it to allow longer method
deadline over HTTP.
### Methods that already have their own deadline
`SetDeadlineHook` fires uniformly for every method, including ones that
already apply a deadline inside their own handler:
`eth_sendRawTransaction`, `eth_sendTransaction`,
`eth_getTransactionCount` (`methodTimeout`, driven by `write_timeout`)
and `debug_trace*` (`TraceTimeout`). Left alone, this enforcer would
silently shorten those to `rpc_default_timeout` whenever an operator
raises `write_timeout` or `trace_timeout` past it, since the composed
context takes the earlier of the two deadlines.
`DefaultConfig.RPCMethodTimeouts` ships explicit `=0` entries for
`eth_sendRawTransaction`, `eth_sendTransaction`,
`eth_getTransactionCount`, and `debug_trace*` (using the wildcard syntax
above), so this enforcer applies no deadline of its own to them and the
handler's existing deadline is untouched regardless of how
`write_timeout`/`trace_timeout` are configured.
### GetReceiptWithRetry
`x/evm/keeper.GetReceiptWithRetry` (used by `eth_feeHistory`'s
congestion/gas-ratio helpers) takes a `context.Context` and waits on
`select { <-goCtx.Done(); ... }` for its retry backoff, so a
cancelled/expired context aborts the wait immediately. Request context
threaded through from both `evmrpc/info.go` call sites. Same signature
in `giga/deps/xevm` copy. Covered by
`TestGetReceiptWithRetryCancelledContext`.
No consensus or state impact, RPC-serving goroutines only. Config and
deadline resolution covered by `evmrpc/config` and
`evmrpc/deadline_test.go`; existing handler tests cover `eth_getLogs`
and `eth_feeHistory` wiring.
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments