Skip to content

rpc/jsonrpc: hold an undecided pre-merge probe for a short TTL - #24218

Merged
lupin012 merged 1 commit into
mainfrom
lupin012/premerge_probe_negative_ttl
Sep 22, 2026
Merged

lupin012 merged 1 commit into
mainfrom
lupin012/premerge_probe_negative_ttl

Conversation

@lupin012

@lupin012 lupin012 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review follow-up from #23322:
#23322 (comment)

_preMergeData is stored only when the probe decides, so a datadir whose block
data cannot be read was never remembered and the walk ran again on every gated
RPC: MinimumBlockAvailable plus about log2(mergeHeight)
CanonicalBodyForStorage reads, each one a gRPC round trip on a remote
rpcdaemon. #23939 closed the earlyTxnSpent branch of the same note; this
closes the remaining one.

An undecided answer is now held for a TTL of its own, one second, separate from
the 30s verdict TTL. A fresh verdict is still checked first, and only a probe
that neither decided nor failed is recorded, so a failed read is not inherited
by another caller. The answer is held, never stored as an observation, so a
datadir whose blocks have not arrived is still not read as an archive one.

Cost: up to one second before arriving blocks are noticed, inside the window
where the gate rejected them anyway.

Tests: TestPreMergeProbeHoldsAnUnansweredWalkForItsTTL pins the reads (20
across 5 requests before, 4 after);
TestPreMergeProbeWalksAgainOnceTheUnansweredTTLPasses pins the other
direction. TestBlocksGateDoesNotSettleExpiryBeforeBlocksArrive sets the new
TTL to zero, so it keeps observing one walk per call.

_preMergeData is stored only when the probe decides, so a datadir whose
block data cannot be read was never remembered and the walk ran again on
every gated RPC: MinimumBlockAvailable plus about log2(mergeHeight)
CanonicalBodyForStorage reads, each one a gRPC round trip on a remote
rpcdaemon.

An undecided answer is now held for a TTL of its own, one second, separate
from the 30s verdict TTL: the verdict expires because the segment set
widens, the non-verdict because the data it waits for can arrive at any
time. A fresh verdict is still checked first, and only a probe that neither
decided nor failed is recorded, so a failed read is still not inherited by
another caller.

The question stays unsettled: an undecided probe is held, never stored as
an observation, so a datadir whose blocks have not arrived is still not
read as an archive one.
@AskAlexSharov

Copy link
Copy Markdown
Collaborator

Lean already. Ship.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

An undecided refresh can renew a previous verdict for 30 seconds, bypassing the intended one-second TTL.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds short-lived caching for undecided pre-merge probes to avoid repeated remote block reads.

Changes:

  • Adds a separate one-second TTL for undecided probe results.
  • Adds tests for reuse and expiry of undecided results.
File Description
rpc/​jsonrpc/​eth_api.go Implements unsettled probe caching.
rpc/​jsonrpc/​pre_merge_probe_test.go Tests unsettled-result TTL behavior.
rpc/​jsonrpc/​check_prune_gates_test.go Disables the new TTL for an existing gate test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rpc/jsonrpc/eth_api.go
@lupin012
lupin012 added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 321591e Sep 22, 2026
144 checks passed
@lupin012
lupin012 deleted the lupin012/premerge_probe_negative_ttl branch September 22, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants