Cleanup historical ledger query#5221
Open
SirTyson wants to merge 3 commits intostellar:masterfrom
Open
Conversation
66a30bb to
3cc6f16
Compare
3cc6f16 to
b01b1a3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the ledger state refactor by removing historical snapshot management from ImmutableLedgerData/ImmutableLedgerView and shifting responsibility for retaining historical queryable snapshots to QueryServer (primarily used by captive-core/RPC query server).
Changes:
- Move historical snapshot retention from
ImmutableLedgerData/BucketListSnapshotintoQueryServer, with a shared snapshot map plus per-threadImmutableLedgerViewcaches. - Wire snapshot publication from
LedgerManagerImpl→CommandHandler→QueryServeron ledger close. - Update/add tests to exercise QueryServer snapshot window behavior and concurrent snapshot access.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/test/QueryServerTests.cpp | Switch tests to use CommandHandler’s QueryServer and add snapshot-window coverage (0 snapshots + eviction behavior). |
| src/main/QueryServer.h | Add shared snapshot store (mStates), per-thread snapshot cache, and test hooks (registerThread, resetForTesting). |
| src/main/QueryServer.cpp | Implement addSnapshot() and getSnapshotForLedger() and route query lookups through retained snapshots. |
| src/main/Config.h | Add QUERY_SERVER_FOR_TESTING (tests-only) to allow direct QueryServer usage without network IO. |
| src/main/CommandHandler.h / src/main/CommandHandler.cpp | Add addSnapshot() forwarding and a test-only QueryServer instantiation path; expose getQueryServer() in tests. |
| src/main/ApplicationImpl.cpp | Construct CommandHandler earlier so ledger loading can publish snapshots; add test-only QueryServer reset to avoid duplicate-seq assertions. |
| src/ledger/test/ImmutableLedgerViewTests.cpp | Update stress test to use QueryServer-provided snapshots and register worker threads for per-thread caching. |
| src/ledger/LedgerManagerImpl.h / src/ledger/LedgerManagerImpl.cpp | Remove historical snapshot plumbing from ledger state construction and publish snapshots to CommandHandler after advancing LCL. |
| src/ledger/ImmutableLedgerView.h / src/ledger/ImmutableLedgerView.cpp | Remove historical snapshot APIs and historical snapshot storage from ImmutableLedgerData. |
| src/bucket/test/BucketTestUtils.cpp | Update ImmutableLedgerData::createAndMaybeLoadConfig call signature. |
| src/bucket/test/BucketIndexTests.cpp | Remove historical snapshot test that depended on the removed historical snapshot API. |
| src/bucket/BucketListSnapshot.h / src/bucket/BucketListSnapshot.cpp | Remove historical snapshot routing/storage from SearchableBucketListSnapshot; simplify constructors and loads. |
dmkozh
previously approved these changes
Apr 27, 2026
|
|
||
| auto keys = inKeys; | ||
| std::vector<LedgerEntry> entries; | ||
| auto loadKeysLoop = [&](std::shared_ptr<LiveBucket const> const& bucket) { |
Contributor
There was a problem hiding this comment.
nit: Can we dedup this with SearchableHotArchiveBucketListSnapshot::loadKeys with a helper?
b01b1a3 to
64f0279
Compare
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.
Description
This is another follow up in the ledger state refactor.
Currently,
CompleteConstLedgerStatemanages historical snapshots. These are only used by captive-core for the RPC query server, but add complexity to the core LedgerState interface. This PR makes it such that the QueryServer is responsible for maintaining it's own historical states, soCompleteConstLedgerStateis simplified to just containing the minimum LCL state.Checklist
clang-formatv8.0.0 (viamake formator the Visual Studio extension)