Skip to content

Commit

Permalink
blockstore: Allow fallback for AddressSignature index() (#34440)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
steviez authored Dec 14, 2023
1 parent 28e8af4 commit 4d131b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4d131b0

Please sign in to comment.