Skip to content

Commit

Permalink
Add more messages to notification
Browse files Browse the repository at this point in the history
  • Loading branch information
godmodegalactus committed Jan 1, 2024
1 parent 1fe9f20 commit 38002d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,13 @@ impl Consumer {
// Re-sanitized transaction should be equal to the original transaction,
// but whether it will pass sanitization needs to be checked.
let resanitized_tx =
bank.fully_verify_transaction(tx.to_versioned_transaction())?;
match bank.fully_verify_transaction(tx.to_versioned_transaction()) {
Ok(resanitized_tx) => resanitized_tx,
Err(e) => {
bank.notify_transaction_error(tx, Some(e.clone()));
return Err(e);
}
};
if resanitized_tx != *tx {
// Sanitization before/after epoch give different transaction data - do not execute.
return Err(TransactionError::ResanitizationNeeded);
Expand Down
27 changes: 27 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4145,6 +4145,9 @@ impl Bank {
let mut status_cache = self.status_cache.write().unwrap();
assert_eq!(sanitized_txs.len(), execution_results.len());
for (tx, execution_result) in sanitized_txs.iter().zip(execution_results) {
if let TransactionExecutionResult::NotExecuted(err) = execution_result {
self.notify_transaction_error(tx, Some(err.clone()));
}
if let Some(details) = execution_result.details() {
// Add the message hash to the status cache to ensure that this message
// won't be processed again with a different signature.
Expand Down Expand Up @@ -4486,6 +4489,7 @@ impl Bank {
(Ok(()), Some(NoncePartial::new(address, account)))
} else {
error_counters.blockhash_not_found += 1;
self.notify_transaction_error(tx, Some(TransactionError::BlockhashNotFound));
(Err(TransactionError::BlockhashNotFound), None)
}
}
Expand Down Expand Up @@ -4518,6 +4522,10 @@ impl Bank {
&& self.is_transaction_already_processed(sanitized_tx, &rcache)
{
error_counters.already_processed += 1;
self.notify_transaction_error(
sanitized_tx,
Some(TransactionError::AlreadyProcessed),
);
return (Err(TransactionError::AlreadyProcessed), None);
}

Expand Down Expand Up @@ -4932,6 +4940,7 @@ impl Bank {
error_counters.instruction_error += 1;
}
}
self.notify_transaction_error(tx, Some(err.clone()));
err
});

Expand Down Expand Up @@ -4962,6 +4971,7 @@ impl Bank {
.filter(|lamports_after_tx| lamports_before_tx == *lamports_after_tx)
.is_none()
{
self.notify_transaction_error(tx, Some(TransactionError::UnbalancedTransaction));
status = Err(TransactionError::UnbalancedTransaction);
}
let status = status.map(|_| ());
Expand Down Expand Up @@ -5113,6 +5123,23 @@ impl Bank {
result
}

pub fn notify_transaction_error(
&self,
transaction: &SanitizedTransaction,
result: Option<TransactionError>,
) {
if let Some(transaction_result_notifier_lock) = &self.banking_transaction_result_notifier {
let transaction_error_notifier = transaction_result_notifier_lock.lock.read();
if let Ok(transaction_error_notifier) = transaction_error_notifier {
transaction_error_notifier.notify_banking_transaction_result(
transaction,
result,
self.slot,
);
}
}
}

#[allow(clippy::type_complexity)]
pub fn load_and_execute_transactions(
&self,
Expand Down

0 comments on commit 38002d5

Please sign in to comment.