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

Commit

Permalink
Prevent transaction status match outside of primary-index bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Aug 6, 2020
1 parent e9318fb commit 3aefd75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,9 @@ impl Blockstore {
(transaction_status_cf_primary_index, signature, 0),
IteratorDirection::Forward,
))?;
for ((_, sig, slot), data) in index_iterator {
for ((i, sig, slot), data) in index_iterator {
counter += 1;
if sig != signature {
if i != transaction_status_cf_primary_index || sig != signature {
break;
}
if self.is_root(slot) {
Expand Down Expand Up @@ -1842,8 +1842,9 @@ impl Blockstore {
("method", "get_confirmed_transaction".to_string(), String)
);
if let Some((slot, status)) = self.get_transaction_status(signature)? {
let transaction = self.find_transaction_in_slot(slot, signature)?
.expect("Transaction to exist in slot entries if it exists in statuses and hasn't been cleaned up");
let transaction = self
.find_transaction_in_slot(slot, signature)?
.ok_or(BlockstoreError::TransactionStatusSlotMismatch)?; // Should not happen
let encoding = encoding.unwrap_or(UiTransactionEncoding::Json);
let encoded_transaction = EncodedTransaction::encode(transaction, encoding);
Ok(Some(ConfirmedTransaction {
Expand Down
1 change: 1 addition & 0 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum BlockstoreError {
SlotCleanedUp,
UnpackError(#[from] UnpackError),
UnableToSetOpenFileDescriptorLimit,
TransactionStatusSlotMismatch,
}
pub type Result<T> = std::result::Result<T, BlockstoreError>;

Expand Down

0 comments on commit 3aefd75

Please sign in to comment.