subsystem-summary-of-bucket
Bucket Subsystem Technical Summary
Overview
The bucket subsystem implements a log-structured merge tree (LSM-tree) data structure called the BucketList. It maintains a canonical, hash-verifiable representation of all ledger state. There are two BucketList instances: the LiveBucketList (current ledger state) and the HotArchiveBucketList (recently evicted entries). Each is organized into 11 temporal levels (level 0 being youngest/smallest, level 10 being oldest/largest), where older levels are exponentially larger and change less frequently.
The system is designed to:
- Provide a single canonical hash of all ledger entries without rehashing the entire database on each ledger close.
- Enable efficient "catch-up" via incremental bucket downloads from history archives.
- Support point and bulk lookups of ledger entries via indexed bucket files (BucketListDB).
Key Classes and Data Structures
Bucket Types (CRTP Hierarchy)
-
BucketBase<BucketT, IndexT>— Abstract CRTP base for immutable, sorted, hashed containers of XDR entries. Holds a filename, hash, size, and optional index (shared_ptr<IndexT>). Provides the coremerge()andmergeInternal()static methods. Buckets are designed to be held inshared_ptrand shared across threads. -
LiveBucket— StoresBucketEntry(INITENTRY, LIVEENTRY, DEADENTRY, METAENTRY). Supports shadows, INIT/DEAD annihilation, and in-memory level-0 merges. Has an optionalmEntriesvector for in-memory-only buckets. Index type:LiveBucketIndex. Key methods:fresh()— Creates a new bucket from init/live/dead entry vectors, sorts, hashes, writes to disk.
More from stellar/stellar-core
running-tests
running tests at various levels from smoke tests to full suite to randomized tests
1subsystem-summary-of-test
read this skill for a token-efficient summary of the test subsystem
1subsystem-summary-of-scp
read this skill for a token-efficient summary of the scp subsystem
1running-make-to-build
how to run make correctly to get a good build, and otherwise understand the build system
1subsystem-summary-of-history
read this skill for a token-efficient summary of the history subsystem
1subsystem-summary-of-invariant
read this skill for a token-efficient summary of the invariant subsystem
1