From 383aef218dee5a0fa64b126828d06b64d29999ba Mon Sep 17 00:00:00 2001 From: steviez Date: Thu, 19 Oct 2023 23:28:53 +0200 Subject: [PATCH] Make Blockstore populate TransactionStatusIndex entries (#33756) 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). --- ledger/src/blockstore.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 74440cdd0c..ce9336e113 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -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); @@ -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);