Prevent transaction status match outside of primary-index bounds
This commit is contained in:
@ -1804,9 +1804,9 @@ impl Blockstore {
|
|||||||
(transaction_status_cf_primary_index, signature, 0),
|
(transaction_status_cf_primary_index, signature, 0),
|
||||||
IteratorDirection::Forward,
|
IteratorDirection::Forward,
|
||||||
))?;
|
))?;
|
||||||
for ((_, sig, slot), data) in index_iterator {
|
for ((i, sig, slot), data) in index_iterator {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
if sig != signature {
|
if i != transaction_status_cf_primary_index || sig != signature {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if self.is_root(slot) {
|
if self.is_root(slot) {
|
||||||
@ -1842,8 +1842,9 @@ impl Blockstore {
|
|||||||
("method", "get_confirmed_transaction".to_string(), String)
|
("method", "get_confirmed_transaction".to_string(), String)
|
||||||
);
|
);
|
||||||
if let Some((slot, status)) = self.get_transaction_status(signature)? {
|
if let Some((slot, status)) = self.get_transaction_status(signature)? {
|
||||||
let transaction = self.find_transaction_in_slot(slot, signature)?
|
let transaction = self
|
||||||
.expect("Transaction to exist in slot entries if it exists in statuses and hasn't been cleaned up");
|
.find_transaction_in_slot(slot, signature)?
|
||||||
|
.ok_or(BlockstoreError::TransactionStatusSlotMismatch)?; // Should not happen
|
||||||
let encoding = encoding.unwrap_or(UiTransactionEncoding::Json);
|
let encoding = encoding.unwrap_or(UiTransactionEncoding::Json);
|
||||||
let encoded_transaction = EncodedTransaction::encode(transaction, encoding);
|
let encoded_transaction = EncodedTransaction::encode(transaction, encoding);
|
||||||
Ok(Some(ConfirmedTransaction {
|
Ok(Some(ConfirmedTransaction {
|
||||||
|
@ -58,6 +58,7 @@ pub enum BlockstoreError {
|
|||||||
SlotCleanedUp,
|
SlotCleanedUp,
|
||||||
UnpackError(#[from] UnpackError),
|
UnpackError(#[from] UnpackError),
|
||||||
UnableToSetOpenFileDescriptorLimit,
|
UnableToSetOpenFileDescriptorLimit,
|
||||||
|
TransactionStatusSlotMismatch,
|
||||||
}
|
}
|
||||||
pub type Result<T> = std::result::Result<T, BlockstoreError>;
|
pub type Result<T> = std::result::Result<T, BlockstoreError>;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user