From 910dc0fc89bdcd7e1d22ca2c0cdca84dfd47b8f0 Mon Sep 17 00:00:00 2001 From: Brennan Date: Fri, 9 Aug 2024 15:37:17 +0000 Subject: [PATCH] pass slot instead of bank --- core/src/banking_stage/committer.rs | 2 +- ledger-tool/src/main.rs | 6 ++---- ledger/src/blockstore_processor.rs | 10 ++++------ rpc/src/transaction_status_service.rs | 5 ++--- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/core/src/banking_stage/committer.rs b/core/src/banking_stage/committer.rs index d91900299107c8..ed97a0cfc14207 100644 --- a/core/src/banking_stage/committer.rs +++ b/core/src/banking_stage/committer.rs @@ -155,7 +155,7 @@ impl Committer { }) .collect(); transaction_status_sender.send_transaction_status_batch( - bank.clone(), + bank.slot(), txs, commit_results, TransactionBalancesSet::new( diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 1005f30a71cd65..60154480f4dd3e 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -683,8 +683,6 @@ fn record_transactions( ) { for tsm in recv { if let TransactionStatusMessage::Batch(batch) = tsm { - let slot = batch.bank.slot(); - assert_eq!(batch.transactions.len(), batch.commit_results.len()); let transactions: Vec<_> = batch @@ -725,11 +723,11 @@ fn record_transactions( let mut slots = slots.lock().unwrap(); - if let Some(recorded_slot) = slots.iter_mut().find(|f| f.slot == slot) { + if let Some(recorded_slot) = slots.iter_mut().find(|f| f.slot == batch.slot) { recorded_slot.transactions.extend(transactions); } else { slots.push(SlotDetails { - slot, + slot: batch.slot, transactions, ..Default::default() }); diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 24ff5ce8fb7baa..aae4718f18f829 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -207,7 +207,7 @@ pub fn execute_batch( TransactionTokenBalancesSet::new(pre_token_balances, post_token_balances); transaction_status_sender.send_transaction_status_batch( - bank.clone(), + bank.slot(), transactions, commit_results, balances, @@ -2108,7 +2108,7 @@ pub enum TransactionStatusMessage { } pub struct TransactionStatusBatch { - pub bank: Arc, + pub slot: Slot, pub transactions: Vec, pub commit_results: Vec, pub balances: TransactionBalancesSet, @@ -2124,19 +2124,17 @@ pub struct TransactionStatusSender { impl TransactionStatusSender { pub fn send_transaction_status_batch( &self, - bank: Arc, + slot: Slot, transactions: Vec, commit_results: Vec, balances: TransactionBalancesSet, token_balances: TransactionTokenBalancesSet, transaction_indexes: Vec, ) { - let slot = bank.slot(); - if let Err(e) = self .sender .send(TransactionStatusMessage::Batch(TransactionStatusBatch { - bank, + slot, transactions, commit_results, balances, diff --git a/rpc/src/transaction_status_service.rs b/rpc/src/transaction_status_service.rs index 8a44c37229db2c..96e2d88a13c550 100644 --- a/rpc/src/transaction_status_service.rs +++ b/rpc/src/transaction_status_service.rs @@ -69,14 +69,13 @@ impl TransactionStatusService { ) -> Result<(), RecvTimeoutError> { match write_transaction_status_receiver.recv_timeout(Duration::from_secs(1))? { TransactionStatusMessage::Batch(TransactionStatusBatch { - bank, + slot, transactions, commit_results, balances, token_balances, transaction_indexes, }) => { - let slot = bank.slot(); for ( transaction, commit_result, @@ -384,7 +383,7 @@ pub(crate) mod tests { let signature = *transaction.signature(); let transaction_index: usize = bank.transaction_count().try_into().unwrap(); let transaction_status_batch = TransactionStatusBatch { - bank, + slot, transactions: vec![transaction], commit_results: vec![commit_result], balances,