Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dummy entries in Blockstore special columns (part 2) #33649

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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