Skip to content

Commit

Permalink
change signature to message hash
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Feb 5, 2025
1 parent 2ea4f77 commit bae70c0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ use {
TransactionProcessingConfig, TransactionProcessingEnvironment,
},
},
solana_svm_transaction::{svm_message::SVMMessage, svm_transaction::SVMTransaction},
solana_svm_transaction::svm_message::SVMMessage,
solana_timings::{ExecuteTimingType, ExecuteTimings},
solana_vote::vote_account::{VoteAccount, VoteAccountsHashMap},
std::{
Expand Down Expand Up @@ -3156,7 +3156,7 @@ impl Bank {
}

/// Prepare a locked transaction batch from a list of sanitized transactions.
pub fn prepare_sanitized_batch<'a, 'b, Tx: SVMTransaction>(
pub fn prepare_sanitized_batch<'a, 'b, Tx: TransactionWithMeta>(
&'a self,
txs: &'b [Tx],
) -> TransactionBatch<'a, 'b, Tx> {
Expand All @@ -3165,7 +3165,7 @@ impl Bank {

/// Prepare a locked transaction batch from a list of sanitized transactions, and their cost
/// limited packing status
pub fn prepare_sanitized_batch_with_results<'a, 'b, Tx: SVMTransaction>(
pub fn prepare_sanitized_batch_with_results<'a, 'b, Tx: TransactionWithMeta>(
&'a self,
transactions: &'b [Tx],
transaction_results: impl Iterator<Item = Result<()>>,
Expand All @@ -3176,18 +3176,23 @@ impl Bank {
.feature_set
.is_active(&feature_set::relax_intrabatch_account_locks::id());

// with simd83 enabled, we must deduplicate transactions by signature
// previously, conflicting account locks would do it as a side effect
let mut batch_signatures = AHashSet::with_capacity(transactions.len());
// with simd83 enabled, we must deduplicate transactions by message hash
// previously, conflicting account locks would dedupe transactions as a side effect
let mut batch_message_hashes = AHashSet::with_capacity(transactions.len());
let transaction_results =
transaction_results
.enumerate()
.map(|(i, tx_result)| match tx_result {
Ok(())
if relax_intrabatch_account_locks
&& !batch_signatures.insert(transactions[i].signature()) =>
{
Err(TransactionError::AccountInUse)
Ok(()) if relax_intrabatch_account_locks => {
let message_hash =
*transactions[i].as_sanitized_transaction().message_hash();

// `HashSet::insert()` returns `true` when the value does *not* already exist
if batch_message_hashes.insert(message_hash) {
Ok(())
} else {
Err(TransactionError::AccountInUse)
}
}
Ok(()) => Ok(()),
Err(e) => Err(e),
Expand Down

0 comments on commit bae70c0

Please sign in to comment.