Skip to content

Commit

Permalink
Remove dummy entries in Blockstore special columns (part 2) (solana-l…
Browse files Browse the repository at this point in the history
…abs#33649)

* Always call initialize_transaction_status_index() at startup,
  doing so will ensure dummy entries are actually cleaned
* Rename initialize_transaction_status_index()
* Stop initializing TransactionStatusIndex column entries, these
  are no longer needed and old software will initialize if needed
  • Loading branch information
steviez authored Oct 11, 2023
1 parent 0f82662 commit 6009d49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
25 changes: 6 additions & 19 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ impl Blockstore {
.unwrap_or(0);
let last_root = RwLock::new(max_root);

// Initialize transaction status index if entries are not present
let initialize_transaction_status_index = db
.iter::<cf::TransactionStatusIndex>(IteratorMode::Start)?
.next()
.is_none();

measure.stop();
info!("{:?} {}", blockstore_path, measure);
let blockstore = Blockstore {
Expand Down Expand Up @@ -364,9 +358,8 @@ impl Blockstore {
lowest_cleanup_slot: RwLock::<Slot>::default(),
slots_stats: SlotsStats::default(),
};
if initialize_transaction_status_index {
blockstore.initialize_transaction_status_index()?;
}
blockstore.cleanup_old_entries()?;

Ok(blockstore)
}

Expand Down Expand Up @@ -2109,16 +2102,10 @@ impl Blockstore {
.collect()
}

/// Initializes the TransactionStatusIndex column family with two records, `0` and `1`,
/// which are used as the primary index for entries in the TransactionStatus and
/// AddressSignatures columns. At any given time, one primary index is active (ie. new records
/// are stored under this index), the other is frozen.
fn initialize_transaction_status_index(&self) -> Result<()> {
self.transaction_status_index_cf
.put(0, &TransactionStatusIndexMeta::default())?;
self.transaction_status_index_cf
.put(1, &TransactionStatusIndexMeta::default())?;

fn cleanup_old_entries(&self) -> Result<()> {
if !self.is_primary_access() {
return Ok(());
}
// If present, delete dummy entries inserted by old software
// https://github.com/solana-labs/solana/blob/bc2b372/ledger/src/blockstore.rs#L2130-L2137
let transaction_status_dummy_key = cf::TransactionStatus::as_index(2);
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/blockstore/blockstore_purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ pub mod tests {
.transaction_status_index_cf
.get(0)
.unwrap()
.unwrap();
.unwrap_or_default();
index0.frozen = true;
index0.max_slot = 4;
blockstore
Expand All @@ -772,7 +772,7 @@ pub mod tests {
.transaction_status_index_cf
.get(1)
.unwrap()
.unwrap();
.unwrap_or_default();
index1.frozen = false;
index1.max_slot = 9;
blockstore
Expand Down

0 comments on commit 6009d49

Please sign in to comment.