Skip to content

Bucket snapshot state refactor#5212

Merged
SirTyson merged 3 commits into
stellar:masterfrom
SirTyson:bucket-snapshot-state-refactor
Apr 18, 2026
Merged

Bucket snapshot state refactor#5212
SirTyson merged 3 commits into
stellar:masterfrom
SirTyson:bucket-snapshot-state-refactor

Conversation

@SirTyson
Copy link
Copy Markdown
Contributor

@SirTyson SirTyson commented Apr 9, 2026

Description

This completes step 4 of the ledger state refactor, namely removing BucketSnapshotState. This was a pretty hacky struct, where we kept a redundant, mutable LedgerHeader in order to verify against ledgerSeq lcl + 1 when doing checkValid in the TX queue. Commits as follows:

  1. Makes the redundant BucketSnapshotState header const and add a validationLedgerSeq override to checkValid when set, this uses the override ledgerSeq instead of the LedgerHeader.
  2. Removes BucketSnapshotState entirely. This also cleans up some of the snapshot interface in general. Specifically, we load the network config a lot, and this can now be done from our LedgerStateSnapshot struct.
  3. Rename LedgerSnapshot to LedgerReadView. This is a lot of loc but is just a rename. We had LedgerStateSnapshot, which actually held the snapshot data and did loads, and another class LedgerSnapshot, which was just a thin compatibility wrapper around LedgerStateSnapshot and LedgerTxn. I've renamed LedgerSnapshot to LedgerReadView to separate it further and get the point across that it's really just a read-only wrapper.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Comment thread src/transactions/TransactionFrame.cpp
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 completes step 4 of the ledger state refactor by removing BucketSnapshotState, tightening snapshot/header mutability, and renaming the read-only snapshot wrapper from LedgerSnapshot to LedgerReadView. It also introduces an explicit validationLedgerSeq override to support pre-consensus validation against LCL+1 without mutating snapshot headers.

Changes:

  • Add validationLedgerSeq parameter to TransactionFrameBase::checkValid and thread it through transaction validation paths (TX queue / txset utils).
  • Remove BucketSnapshotState; make LedgerHeaderWrapper bucket-backed headers immutable and update snapshot interfaces accordingly.
  • Rename LedgerSnapshotLedgerReadView and update call sites across core, overlay, simulation, and tests.

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/transactions/TransactionFrameBase.h Extends checkValid API with optional validationLedgerSeq; updates snapshot type to LedgerReadView.
src/transactions/TransactionFrame.h Threads LedgerReadView + validationLedgerSeq through validation helpers and signature checks.
src/transactions/TransactionFrame.cpp Implements validation override behavior (ledger-seq-dependent preconditions) and updates snapshot usage.
src/transactions/test/TransactionTestFrame.h Updates test wrapper to accept LedgerReadView and propagate optional validationLedgerSeq.
src/transactions/test/TransactionTestFrame.cpp Updates test wrapper implementation to construct/use LedgerReadView.
src/transactions/test/SorobanTxTestUtils.cpp Updates validation helpers to use LedgerReadView.
src/transactions/test/PaymentTests.cpp Replaces LedgerSnapshot usage with LedgerReadView.
src/transactions/test/ParallelApplyTest.cpp Replaces LedgerSnapshot usage with LedgerReadView in apply tests.
src/transactions/test/InvokeHostFunctionTests.cpp Replaces LedgerSnapshot usage with LedgerReadView in Soroban tests.
src/transactions/test/FrozenLedgerKeysTests.cpp Replaces LedgerSnapshot usage with LedgerReadView throughout frozen-keys tests.
src/transactions/OperationFrame.h Updates operation validation/signature APIs to use LedgerReadView.
src/transactions/OperationFrame.cpp Uses LedgerReadView during apply/validation and account loading.
src/transactions/FeeBumpTransactionFrame.h Updates fee-bump validation/signature APIs to use LedgerReadView and new checkValid signature.
src/transactions/FeeBumpTransactionFrame.cpp Threads LedgerReadView + validationLedgerSeq into inner-tx validation.
src/test/TxTests.cpp Updates helper snapshot usage to LedgerReadView.
src/test/TestAccount.cpp Updates read-only lookups to LedgerReadView (plus minor local refactors).
src/test/FuzzerImpl.cpp Updates fuzzer validation snapshot wrapper to LedgerReadView.
src/simulation/TxGenerator.cpp Updates ledger lookups to use LedgerReadView.
src/simulation/LoadGenerator.cpp Updates state-sync checks to use LedgerReadView.
src/simulation/ApplyLoad.cpp Updates generated-tx validation to use LedgerReadView.
src/overlay/test/OverlayTests.cpp Updates overlay tests to use LedgerReadView for validation.
src/overlay/Peer.cpp Uses overlay-thread snapshot via LedgerReadView during background signature cache population.
src/main/CommandHandler.cpp Updates CLI handlers that read config upgrade sets / config entries to use LedgerReadView.
src/ledger/NetworkConfig.h Switches config loader API to accept AbstractLedgerStateSnapshot instead of LedgerSnapshot.
src/ledger/NetworkConfig.cpp Implements snapshot-agnostic Soroban config loading via AbstractLedgerStateSnapshot.
src/ledger/LedgerStateSnapshot.h Removes BucketSnapshotState, makes bucket-backed headers immutable, renames LedgerSnapshotLedgerReadView, and formalizes snapshot interface inheritance.
src/ledger/LedgerStateSnapshot.cpp Removes BucketSnapshotState, implements LedgerReadView, and adds CompleteConstLedgerState::createAndMaybeLoadConfig.
src/ledger/LedgerManagerImpl.cpp Moves Soroban config bootstrapping into CompleteConstLedgerState::createAndMaybeLoadConfig and updates upgrade validation snapshot type.
src/ledger/InMemorySorobanState.cpp Loads Soroban config directly from ApplyLedgerStateSnapshot via snapshot-agnostic API.
src/invariant/ConservationOfLumens.cpp Updates ledger-header access to account for wrapper-based header retrieval.
src/invariant/BucketListStateConsistency.cpp Updates ledger-header access and loads Soroban config from snapshot-agnostic API.
src/invariant/ArchivedStateConsistency.cpp Updates ledger-header access to account for wrapper-based header retrieval.
src/herder/Upgrades.h Renames upgrade inspection/validation APIs to take LedgerReadView.
src/herder/Upgrades.cpp Updates upgrade creation/validation/config-upgrade loading to use LedgerReadView.
src/herder/TxSetUtils.cpp Uses validationLedgerSeq override instead of mutating snapshot header.
src/herder/TransactionQueue.cpp Uses validationLedgerSeq override instead of mutating snapshot header during pre-consensus checks.
src/herder/test/UpgradesTests.cpp Updates tests to use LedgerReadView.
src/herder/test/TxSetTests.cpp Updates tests to use LedgerReadView.
src/herder/test/HerderTests.cpp Updates tests to use LedgerReadView.
src/bucket/test/BucketTestUtils.cpp Updates test-only config bootstrapping for bucket-injected upgrades via createAndMaybeLoadConfig.
src/bucket/test/BucketListTests.cpp Updates tests to use LedgerReadView for config entry lookups.
src/bucket/BucketManager.cpp Updates eviction scan resolution to use snapshot-agnostic config loading and wrapper-based header access.
src/bucket/BucketListSnapshot.h Removes BucketSnapshotState friendship (now deleted).

Comment thread src/ledger/ImmutableLedgerView.cpp
Comment thread src/test/TestAccount.cpp Outdated
@SirTyson SirTyson force-pushed the bucket-snapshot-state-refactor branch from ceef55c to edb405a Compare April 9, 2026 03:46
dmkozh
dmkozh previously approved these changes Apr 10, 2026
Comment thread src/transactions/TransactionFrame.cpp
Comment thread src/ledger/ImmutableLedgerView.cpp
@SirTyson SirTyson force-pushed the bucket-snapshot-state-refactor branch 4 times, most recently from 284cc96 to 7817145 Compare April 13, 2026 20:11
Comment thread src/ledger/ImmutableLedgerView.h
Comment thread src/ledger/ImmutableLedgerView.h
Comment thread src/ledger/test/LedgerStateSnapshotTests.cpp Outdated
@SirTyson SirTyson force-pushed the bucket-snapshot-state-refactor branch from 7817145 to 5e39b5c Compare April 15, 2026 23:36
@SirTyson SirTyson force-pushed the bucket-snapshot-state-refactor branch from 5e39b5c to 0c6d574 Compare April 17, 2026 18:10
@SirTyson SirTyson enabled auto-merge April 17, 2026 23:21
@SirTyson SirTyson added this pull request to the merge queue Apr 17, 2026
Merged via the queue into stellar:master with commit 26b3c56 Apr 18, 2026
54 checks passed
@SirTyson SirTyson deleted the bucket-snapshot-state-refactor branch April 18, 2026 00:21
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.

4 participants