fix(evm): guard nil upstream on cached eth_getBlockByNumber stale metrics - #26
Merged
shpookas merged 2 commits intoSep 28, 2026
Merged
Conversation
…rics A cached "latest" or "finalized" block carries no upstream. When it lags the tip, enforceHighestBlock falls through to the stale-block metric and dereferences nr.Upstream(), panicking the per-request handler and returning -32603 to the client. Label cached stale hits as upstream="cache" instead, so the request continues to the tip re-fetch and the metric still shows how often cached blocks lag.
…ockNumber Drop the staleResponseLabels helper and its "cache" label. The stale-block metrics count upstreams returning stale blocks, so a cache hit should not be attributed there. Guard with `ups != nil` as eth_blockNumber already does since erpc#932.
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
latestorfinalizedresponse has no upstream attached. Since the cache change in fix(ws): refuse stale latest below TipHW (FOOS) #11, a cached block that lags the tip falls throughenforceHighestBlockto the stale-block metric, which callsnr.Upstream().VendorName()on nil and panics the per-request handler (-32603to the client).ups != nil, the same wayeth_blockNumberdoes since fix(evm): enforce highest block on eth_blockNumber across cache hits, directives, and selector-scoped tips erpc/erpc#932. A cache hit is not an upstream returning a stale block, so it is not counted there; the request still continues to the tip re-fetch.Context
Only reachable when
eth_getBlockByNumberis cached atfinality: realtime, so thatlatestcan be served from cache. Upstream main returns early for any cachedeth_getBlockByNumberresponse, so it does not hit this. erpc#932 removed the same early return foreth_blockNumberand added the guard there; #11 made the equivalent change here without it.Test plan
TestEnforceHighestBlock_CachedResponseWithoutUpstream(latest + finalized): panics on the base commit, passes with the fixmake test: no new failures. The existing failures (race-detector failures, flakyTestEvmJsonRpcCache_FanOut_*,TestEvmJsonRpcCache_BlockAgeValidationunder-race,TestNetwork_Forward/ForwardLlamaRPCEndpointRateLimitResponseSingle) fail identically on c7c89e5erpc_unexpected_panic_totalstays at 0