Skip to content

Commit

Permalink
Make Blockstore populate TransactionStatusIndex entries (#33756)
Browse files Browse the repository at this point in the history
A previous change removed logic that populated the
TransactionStatusIndex entries at each of the legacy primary index keys
(0 and 1). While these entries will not be read or written in the
future, these entries are necessary for backwards compatibility. Namely,
branches <= v1.17 expect these entries to be present and .unwrap()'s
could fail if they are not.

So, add the initialization of these entries back into Blockstore logic.
We can remove initialization of these entries once our stable and beta
branches are both versions that do not expect these entries to be
present (should be v1.18).
  • Loading branch information
steviez authored Oct 19, 2023
1 parent f13c78b commit 383aef2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,17 @@ impl Blockstore {
if !self.is_primary_access() {
return Ok(());
}

// Initialize TransactionStatusIndexMeta if they are not present already
if self.transaction_status_index_cf.get(0)?.is_none() {
self.transaction_status_index_cf
.put(0, &TransactionStatusIndexMeta::default())?;
}
if self.transaction_status_index_cf.get(1)?.is_none() {
self.transaction_status_index_cf
.put(1, &TransactionStatusIndexMeta::default())?;
}

// 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 Expand Up @@ -2152,7 +2163,7 @@ impl Blockstore {
highest_primary_index_slot = Some(meta.max_slot);
}
}
if highest_primary_index_slot.is_some() {
if highest_primary_index_slot.is_some_and(|slot| slot != 0) {
self.set_highest_primary_index_slot(highest_primary_index_slot);
} else {
self.db.set_clean_slot_0(true);
Expand Down

0 comments on commit 383aef2

Please sign in to comment.