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 ffa72b4
Browse filesBrowse the repository at this point in the historyBrowse files
Return an error instead of panicking when RPC state is unavailable (#4430)
On a node with the state store disabled, `RPCContextProvider` can only
build a context for the latest committed height and panics for any other
height. `EncodeTmBlock` and `filterTransactions` always ask for the
parent height to compute the base fee and nonces, and the log fetcher
asks for the queried heights, so on such a node `eth_getBlockByNumber`
(even for `latest`) and `eth_getLogs` hit that panic on every call.
go-ethereum's RPC server recovers it and the client gets a bare `-32603
method handler crashed`, while seid logs a stack trace for each request.
atlantic-2's sei-node-1 currently logs roughly 130 of these an hour from
a single external client.
This adds `ctxAtHeight`, which calls the context provider and turns an
error it panics with into a returned error naming the height. Non-error
panics and runtime errors such as nil dereferences are re-raised, so
real bugs keep their stack. `EncodeTmBlock`, `filterTransactions`,
`tryFilterLogsRange`, `collectLogs` and the bloom read in
`readUncachedBlock` use it for their non-latest contexts, so these paths
now return an error such as `state at height N is unavailable: failed to
load state at height N; unable to load historical state with SS disabled
...` instead of panicking. The same applies to heights pruned from the
state store on SS-enabled nodes. Nothing changes for heights the node
can serve.
One caveat: the block-by-block fallback in `GetLogsByFilters` already
drops per-block errors from `GetLogsForBlockPooled` on main, so an
unfiltered `eth_getLogs` that takes that path still answers with the
affected blocks' logs missing rather than an error. That is pre-existing
and left for a follow-up.
This only touches the EVM RPC read path, with no consensus or state
impact. New unit tests cover `ctxAtHeight`, `EncodeTmBlock` with an
unavailable parent context, and the log fetcher's `tryFilterLogsRange`,
`collectLogs` and `readUncachedBlock` with unavailable state.
0 commit comments