Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Fail gracefully if older AddressSignatures rocksdb keys are present #9611

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 11 additions & 0 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,17 @@ fn analyze_storage(database: &Database) -> Result<(), String> {
"TransactionStatus",
TransactionStatus::key_size(),
)?;
analyze_column::<TransactionStatus>(
database,
"TransactionStatusIndex",
TransactionStatusIndex::key_size(),
)?;
analyze_column::<AddressSignatures>(
database,
"AddressSignatures",
AddressSignatures::key_size(),
)?;
analyze_column::<Rewards>(database, "Rewards", Rewards::key_size())?;

Ok(())
}
Expand Down
14 changes: 9 additions & 5 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,15 @@ impl Column for columns::AddressSignatures {
}

fn index(key: &[u8]) -> (u64, Pubkey, Slot, Signature) {
let index = BigEndian::read_u64(&key[0..8]);
let pubkey = Pubkey::new(&key[8..40]);
let slot = BigEndian::read_u64(&key[40..48]);
let signature = Signature::new(&key[48..112]);
(index, pubkey, slot, signature)
if key.len() != 112 {
(0, Pubkey::default(), 0, Signature::default())
} else {
let index = BigEndian::read_u64(&key[0..8]);
let pubkey = Pubkey::new(&key[8..40]);
let slot = BigEndian::read_u64(&key[40..48]);
let signature = Signature::new(&key[48..112]);
(index, pubkey, slot, signature)
}
}

fn primary_index(index: Self::Index) -> u64 {
Expand Down