Skip to content

db/kv/kvcache: rename SimpleCache to LatestBatchCache - #22278

Merged
AskAlexSharov merged 3 commits into
mainfrom
yperbasis/latest-batch-cache
Jul 18, 2026
Merged

db/kv/kvcache: rename SimpleCache to LatestBatchCache#22278
AskAlexSharov merged 3 commits into
mainfrom
yperbasis/latest-batch-cache

Conversation

@yperbasis

@yperbasis yperbasis commented Jul 6, 2026

Copy link
Copy Markdown
Member

Renames SimpleCacheLatestBatchCache (with NewSimpleNewLatestBatchCache, SimpleViewLatestBatchView, simple.golatest_batch.go).

"Simple" described the implementation rather than the contract, and suggested Simple and Coherent sit on a complexity spectrum. They actually sit on opposite sides of a semantic fork:

  • Coherent — snapshot-consistency first: entries are keyed by PlainStateVersion, so a reader stays consistent with its own committed view and never sees fresher data.
  • LatestBatchCache — freshness first: version-blind, it serves the most recent announced state-change batch on top of the caller's tx, deliberately showing announced-but-not-yet-committed account data; staleness is bounded to one batch by FCU serialization.

That fork is what decides which cache is safe where (in-process txpool vs RPC reads — see #22532 / #22269), and the new name carries it: content (the latest batch), lifetime (replaced wholesale per batch), and the trade-off (by contrast with Coherent). Also updates the type doc comment to lead with the contract.

One cleanup rider in the same spirit: the dead Evict() int { return 0 } stub is removed (no callers, not part of the Cache interface — a DummyCache-era leftover).

Mechanical rename + dead-code removal, no behavior change (TDD not applicable).

@yperbasis
yperbasis force-pushed the yperbasis/latest-batch-cache branch from 0deb297 to 4741ed8 Compare July 17, 2026 08:30
@yperbasis
yperbasis changed the base branch from alex/fcu_bg_commit_35 to yperbasis/coherent-state-cache July 17, 2026 08:30
The old name described the implementation, not the contract, and suggested
Simple and Coherent sit on a complexity spectrum. They differ semantically:
Coherent is snapshot-consistency-first (version-keyed; readers stay
consistent with their own committed view), LatestBatchCache is
freshness-first (version-blind; readers see the latest announced
state-change batch on top of their tx, staleness bounded to one batch by
FCU serialization). The new name carries the content, the lifetime
(replaced per batch), and the trade-off.

Mechanical rename (SimpleCache -> LatestBatchCache, NewSimple ->
NewLatestBatchCache, SimpleView -> LatestBatchView, simple.go ->
latest_batch.go), plus the type doc comment and the --state.cache help
text updated to match. No behavior change.
Evict had no callers and is not part of the Cache interface (leftover from
the DummyCache era).
@yperbasis
yperbasis force-pushed the yperbasis/latest-batch-cache branch from 4741ed8 to 1a3db61 Compare July 18, 2026 08:23
@yperbasis
yperbasis changed the base branch from yperbasis/coherent-state-cache to main July 18, 2026 08:23
@yperbasis
yperbasis marked this pull request as ready for review July 18, 2026 08:28
@yperbasis
yperbasis requested a review from Copilot July 18, 2026 08:28

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.

Pull request overview

This PR clarifies the state-cache semantics in db/kv/kvcache by renaming the former SimpleCache to LatestBatchCache, aligning the API and filenames with the cache’s actual contract (“serve the latest announced batch”, rather than “simple implementation”). This helps distinguish it from the version-keyed, snapshot-consistent Coherent cache.

Changes:

  • Renamed SimpleCacheLatestBatchCache (and NewSimpleNewLatestBatchCache, SimpleViewLatestBatchView, simple.golatest_batch.go).
  • Updated call sites across txpool, rpcdaemon, and RPC gasprice tests/benchmarks to use the new constructor.
  • Removed the dead Evict() int { return 0 } stub from the cache implementation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
db/kv/kvcache/latest_batch.go Renames the cache/view types and constructor; updates the type doc comment to describe the “latest batch” contract; removes the unused Evict stub.
txnprovider/txpool/pool_test.go Updates txpool tests and explanatory comments to reference LatestBatchCache / NewLatestBatchCache.
rpc/gasprice/gasprice_test.go Switches gasprice tests to construct BaseApi with NewLatestBatchCache.
rpc/gasprice/feehistory_test.go Switches fee history tests to construct BaseApi with NewLatestBatchCache.
rpc/gasprice/bench_test.go Switches gasprice benchmarks to construct BaseApi with NewLatestBatchCache.
node/eth/backend.go Updates embedded txpool assembly to use NewLatestBatchCache.
execution/execmodule/execmoduletester/exec_module_tester.go Updates exec-module test harness txpool assembly to use NewLatestBatchCache.
cmd/rpcdaemon/cli/config.go Updates rpcdaemon wiring to use NewLatestBatchCache where it previously used NewSimple.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yperbasis
yperbasis enabled auto-merge July 18, 2026 08:32
@yperbasis
yperbasis added this pull request to the merge queue Jul 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 18, 2026
@AskAlexSharov
AskAlexSharov enabled auto-merge July 18, 2026 11:31
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jul 18, 2026
Merged via the queue into main with commit 10c9c27 Jul 18, 2026
93 checks passed
@AskAlexSharov
AskAlexSharov deleted the yperbasis/latest-batch-cache branch July 18, 2026 12:57
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.

3 participants