Get transactions from LockedAccountsResults when possible (#5923)
This commit is contained in:
@ -480,7 +480,6 @@ impl BankingStage {
|
|||||||
|
|
||||||
fn process_and_record_transactions_locked(
|
fn process_and_record_transactions_locked(
|
||||||
bank: &Bank,
|
bank: &Bank,
|
||||||
txs: &[Transaction],
|
|
||||||
poh: &Arc<Mutex<PohRecorder>>,
|
poh: &Arc<Mutex<PohRecorder>>,
|
||||||
lock_results: &LockedAccountsResults,
|
lock_results: &LockedAccountsResults,
|
||||||
) -> (Result<usize>, Vec<usize>) {
|
) -> (Result<usize>, Vec<usize>) {
|
||||||
@ -489,8 +488,9 @@ impl BankingStage {
|
|||||||
// the likelihood of any single thread getting starved and processing old ids.
|
// the likelihood of any single thread getting starved and processing old ids.
|
||||||
// TODO: Banking stage threads should be prioritized to complete faster then this queue
|
// TODO: Banking stage threads should be prioritized to complete faster then this queue
|
||||||
// expires.
|
// expires.
|
||||||
|
let txs = lock_results.transactions();
|
||||||
let (mut loaded_accounts, results, mut retryable_txs, tx_count, signature_count) =
|
let (mut loaded_accounts, results, mut retryable_txs, tx_count, signature_count) =
|
||||||
bank.load_and_execute_transactions(txs, lock_results, MAX_PROCESSING_AGE);
|
bank.load_and_execute_transactions(lock_results, MAX_PROCESSING_AGE);
|
||||||
load_execute_time.stop();
|
load_execute_time.stop();
|
||||||
|
|
||||||
let freeze_lock = bank.freeze_lock();
|
let freeze_lock = bank.freeze_lock();
|
||||||
@ -547,7 +547,7 @@ impl BankingStage {
|
|||||||
lock_time.stop();
|
lock_time.stop();
|
||||||
|
|
||||||
let (result, mut retryable_txs) =
|
let (result, mut retryable_txs) =
|
||||||
Self::process_and_record_transactions_locked(bank, txs, poh, &lock_results);
|
Self::process_and_record_transactions_locked(bank, poh, &lock_results);
|
||||||
retryable_txs.iter_mut().for_each(|x| *x += chunk_offset);
|
retryable_txs.iter_mut().for_each(|x| *x += chunk_offset);
|
||||||
|
|
||||||
let mut unlock_time = Measure::start("unlock_time");
|
let mut unlock_time = Measure::start("unlock_time");
|
||||||
|
@ -43,23 +43,22 @@ fn par_execute_entries(bank: &Bank, entries: &[(&Entry, LockedAccountsResults)])
|
|||||||
thread_pool.borrow().install(|| {
|
thread_pool.borrow().install(|| {
|
||||||
entries
|
entries
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|(e, locked_accounts)| {
|
.map(|(entry, locked_accounts)| {
|
||||||
let results = bank.load_execute_and_commit_transactions(
|
let results = bank.load_execute_and_commit_transactions(
|
||||||
&e.transactions,
|
|
||||||
locked_accounts,
|
locked_accounts,
|
||||||
MAX_RECENT_BLOCKHASHES,
|
MAX_RECENT_BLOCKHASHES,
|
||||||
);
|
);
|
||||||
let mut first_err = None;
|
let mut first_err = None;
|
||||||
for (r, tx) in results.iter().zip(e.transactions.iter()) {
|
for (r, tx) in results.iter().zip(entry.transactions.iter()) {
|
||||||
if let Err(ref e) = r {
|
if let Err(ref entry) = r {
|
||||||
if first_err.is_none() {
|
if first_err.is_none() {
|
||||||
first_err = Some(r.clone());
|
first_err = Some(r.clone());
|
||||||
}
|
}
|
||||||
if !Bank::can_commit(&r) {
|
if !Bank::can_commit(&r) {
|
||||||
warn!("Unexpected validator error: {:?}, tx: {:?}", e, tx);
|
warn!("Unexpected validator error: {:?}, tx: {:?}", entry, tx);
|
||||||
datapoint_error!(
|
datapoint_error!(
|
||||||
"validator_process_entry_error",
|
"validator_process_entry_error",
|
||||||
("error", format!("error: {:?}, tx: {:?}", e, tx), String)
|
("error", format!("error: {:?}, tx: {:?}", entry, tx), String)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -975,7 +975,6 @@ impl Bank {
|
|||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn load_and_execute_transactions(
|
pub fn load_and_execute_transactions(
|
||||||
&self,
|
&self,
|
||||||
txs: &[Transaction],
|
|
||||||
lock_results: &LockedAccountsResults,
|
lock_results: &LockedAccountsResults,
|
||||||
max_age: usize,
|
max_age: usize,
|
||||||
) -> (
|
) -> (
|
||||||
@ -985,6 +984,7 @@ impl Bank {
|
|||||||
usize,
|
usize,
|
||||||
usize,
|
usize,
|
||||||
) {
|
) {
|
||||||
|
let txs = lock_results.transactions();
|
||||||
debug!("processing transactions: {}", txs.len());
|
debug!("processing transactions: {}", txs.len());
|
||||||
inc_new_counter_info!("bank-process_transactions", txs.len());
|
inc_new_counter_info!("bank-process_transactions", txs.len());
|
||||||
let mut error_counters = ErrorCounters::default();
|
let mut error_counters = ErrorCounters::default();
|
||||||
@ -1161,15 +1161,14 @@ impl Bank {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn load_execute_and_commit_transactions(
|
pub fn load_execute_and_commit_transactions(
|
||||||
&self,
|
&self,
|
||||||
txs: &[Transaction],
|
|
||||||
lock_results: &LockedAccountsResults,
|
lock_results: &LockedAccountsResults,
|
||||||
max_age: usize,
|
max_age: usize,
|
||||||
) -> Vec<Result<()>> {
|
) -> Vec<Result<()>> {
|
||||||
let (mut loaded_accounts, executed, _, tx_count, signature_count) =
|
let (mut loaded_accounts, executed, _, tx_count, signature_count) =
|
||||||
self.load_and_execute_transactions(txs, lock_results, max_age);
|
self.load_and_execute_transactions(lock_results, max_age);
|
||||||
|
|
||||||
self.commit_transactions(
|
self.commit_transactions(
|
||||||
txs,
|
lock_results.transactions(),
|
||||||
lock_results.txs_iteration_order(),
|
lock_results.txs_iteration_order(),
|
||||||
&mut loaded_accounts,
|
&mut loaded_accounts,
|
||||||
&executed,
|
&executed,
|
||||||
@ -1181,7 +1180,7 @@ impl Bank {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
|
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
|
||||||
let lock_results = self.lock_accounts(txs, None);
|
let lock_results = self.lock_accounts(txs, None);
|
||||||
self.load_execute_and_commit_transactions(txs, &lock_results, MAX_RECENT_BLOCKHASHES)
|
self.load_execute_and_commit_transactions(&lock_results, MAX_RECENT_BLOCKHASHES)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create, sign, and process a Transaction from `keypair` to `to` of
|
/// Create, sign, and process a Transaction from `keypair` to `to` of
|
||||||
@ -2128,11 +2127,8 @@ mod tests {
|
|||||||
let pay_alice = vec![tx1];
|
let pay_alice = vec![tx1];
|
||||||
|
|
||||||
let lock_result = bank.lock_accounts(&pay_alice, None);
|
let lock_result = bank.lock_accounts(&pay_alice, None);
|
||||||
let results_alice = bank.load_execute_and_commit_transactions(
|
let results_alice =
|
||||||
&pay_alice,
|
bank.load_execute_and_commit_transactions(&lock_result, MAX_RECENT_BLOCKHASHES);
|
||||||
&lock_result,
|
|
||||||
MAX_RECENT_BLOCKHASHES,
|
|
||||||
);
|
|
||||||
assert_eq!(results_alice[0], Ok(()));
|
assert_eq!(results_alice[0], Ok(()));
|
||||||
|
|
||||||
// try executing an interleaved transfer twice
|
// try executing an interleaved transfer twice
|
||||||
|
@ -17,6 +17,10 @@ impl<'a, 'b> LockedAccountsResults<'a, 'b> {
|
|||||||
transactions: &'b [Transaction],
|
transactions: &'b [Transaction],
|
||||||
txs_iteration_order: Option<Vec<usize>>,
|
txs_iteration_order: Option<Vec<usize>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
assert_eq!(locked_accounts_results.len(), transactions.len());
|
||||||
|
if let Some(txs_iteration_order) = &txs_iteration_order {
|
||||||
|
assert_eq!(transactions.len(), txs_iteration_order.len());
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
locked_accounts_results,
|
locked_accounts_results,
|
||||||
bank,
|
bank,
|
||||||
|
Reference in New Issue
Block a user