Skip to content

fix(evm): guard nil upstream on cached eth_getBlockByNumber stale metrics - #26

Merged
shpookas merged 2 commits into
feat/websocket-supportfrom
fix/evm-cached-stale-block-nil-upstream
Sep 28, 2026
Merged

shpookas merged 2 commits into
feat/websocket-supportfrom
fix/evm-cached-stale-block-nil-upstream

Conversation

@shpookas

@shpookas shpookas commented Sep 25, 2026 •

Copy link
Copy Markdown

Summary

Context

Only reachable when eth_getBlockByNumber is cached at finality: realtime, so that latest can be served from cache. Upstream main returns early for any cached eth_getBlockByNumber response, so it does not hit this. erpc#932 removed the same early return for eth_blockNumber and 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 fix
  • make test: no new failures. The existing failures (race-detector failures, flaky TestEvmJsonRpcCache_FanOut_*, TestEvmJsonRpcCache_BlockAgeValidation under -race, TestNetwork_Forward/ForwardLlamaRPCEndpointRateLimitResponseSingle) fail identically on c7c89e5
  • Build an image from this branch and roll it to internal-erpc-canary
  • Confirm erpc_unexpected_panic_total stays at 0

…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.
@shpookas
shpookas merged commit 4c7a584 into feat/websocket-support Sep 28, 2026
1 check failed
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.

1 participant