From 4d131b0e4c6ddbf6211068e114dad4ca3d6d87db Mon Sep 17 00:00:00 2001
From: steviez <steven@solana.com>
Date: Wed, 13 Dec 2023 19:38:06 -0600
Subject: [PATCH] blockstore: Allow fallback for AddressSignature index()
 (#34440)

blockstore: Allow fallback for AddressSignature index

A change landed somewhat recently in master that changed the key format
of the transaction metadata columns. A compatibility backport was
introduced to allow a blockstore that had been populated with this newer
version to still be readable by v1.17 (backwards software compat).

However, there was an oversight in the backport. Namely, the index()
function for AddressSignatures column did a regular unwrap() on the
try_current_index() result. try_current_index() can fail if a key with
an unknown size is encountered. This would be exactly the case for
encountering a key that was populated by the newer software version with
the different key format.

So, use .unwrap_or_else() in the index() implementation for
AddressSignatures; this will now be consistent with the implementation
of index() for TransactionStatus column.
---
 ledger/src/blockstore_db.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs
index 6dd7f4dbe4c4f2..30cb4b2e9779a4 100644
--- a/ledger/src/blockstore_db.rs
+++ b/ledger/src/blockstore_db.rs
@@ -875,7 +875,8 @@ impl Column for columns::AddressSignatures {
     }
 
     fn index(key: &[u8]) -> (u64, Pubkey, Slot, Signature) {
-        <columns::AddressSignatures as ColumnIndexDeprecation>::try_current_index(key).unwrap()
+        <columns::AddressSignatures as ColumnIndexDeprecation>::try_current_index(key)
+            .unwrap_or_else(|_| Self::as_index(0))
     }
 
     fn primary_index(index: Self::Index) -> u64 {