diff --git a/accounts-db/src/accounts.rs b/accounts-db/src/accounts.rs index e0ed2639bf53b6..8f85d0f1a744ff 100644 --- a/accounts-db/src/accounts.rs +++ b/accounts-db/src/accounts.rs @@ -1580,6 +1580,7 @@ mod tests { nonce: None, rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let loaded1 = Ok(LoadedTransaction { @@ -1588,6 +1589,7 @@ mod tests { nonce: None, rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let mut loaded = vec![loaded0, loaded1]; @@ -1964,6 +1966,7 @@ mod tests { nonce: nonce.clone(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let mut loaded = vec![loaded]; @@ -2068,6 +2071,7 @@ mod tests { nonce: nonce.clone(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let mut loaded = vec![loaded]; diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index bf35919896962a..f6d926332b6cb9 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -177,7 +177,8 @@ use { TransactionProcessingConfig, }, transaction_results::{ - TransactionExecutionDetails, TransactionExecutionResult, TransactionResults, + TransactionExecutionDetails, TransactionExecutionResult, + TransactionLoadedAccountsStats, TransactionResults, }, }, solana_system_program::{get_system_account_kind, SystemAccountKind}, @@ -4193,13 +4194,36 @@ impl Bank { update_transaction_statuses_time.as_us(), ); + let loaded_accounts_stats = Self::collect_loaded_accounts_stats(loaded_txs); + assert_eq!( + loaded_accounts_stats.len(), + execution_results.len(), + "loaded_account_stats and execution_results are not the same size" + ); + TransactionResults { fee_collection_results, + loaded_accounts_stats, execution_results, rent_debits, } } + fn collect_loaded_accounts_stats( + loaded_txs: &[TransactionLoadResult], + ) -> Vec> { + loaded_txs + .iter() + .map(|load_result| match load_result { + Ok(loaded_tx) => Ok(TransactionLoadedAccountsStats { + loaded_accounts_data_size: loaded_tx.loaded_accounts_data_size, + loaded_accounts_count: loaded_tx.accounts.len(), + }), + Err(err) => Err(err.clone()), + }) + .collect() + } + fn collect_rent( &self, execution_results: &[TransactionExecutionResult], diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index 412526eee656f2..dee1fe2eacff43 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -53,6 +53,7 @@ pub struct LoadedTransaction { pub nonce: Option, pub rent: TransactionRent, pub rent_debits: RentDebits, + pub loaded_accounts_data_size: usize, } impl LoadedTransaction { @@ -388,6 +389,7 @@ fn load_transaction_accounts( nonce, rent: tx_rent, rent_debits, + loaded_accounts_data_size: accumulated_accounts_data_size, }) } @@ -1519,7 +1521,8 @@ mod tests { program_indices: vec![vec![]], nonce: None, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -1722,7 +1725,8 @@ mod tests { nonce: None, program_indices: vec![vec![1]], rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -1914,7 +1918,8 @@ mod tests { program_indices: vec![vec![2, 1]], nonce: None, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -2006,7 +2011,8 @@ mod tests { program_indices: vec![vec![3, 1], vec![3, 1]], nonce: None, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -2168,7 +2174,8 @@ mod tests { Some(mock_bank.accounts_map[&key2.pubkey()].clone()) )), rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 3b8d61ecbd15fe..9645eaf281ba51 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -1000,6 +1000,7 @@ mod tests { nonce: None, rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 32, }; let mut processing_config = TransactionProcessingConfig::default(); @@ -1124,6 +1125,7 @@ mod tests { nonce: None, rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }; let processing_config = TransactionProcessingConfig { diff --git a/svm/src/transaction_results.rs b/svm/src/transaction_results.rs index d6f0c8a304433c..8cbc6e77da5f65 100644 --- a/svm/src/transaction_results.rs +++ b/svm/src/transaction_results.rs @@ -16,10 +16,17 @@ use { pub struct TransactionResults { pub fee_collection_results: Vec>, + pub loaded_accounts_stats: Vec>, pub execution_results: Vec, pub rent_debits: Vec, } +#[derive(Debug, Default, Clone)] +pub struct TransactionLoadedAccountsStats { + pub loaded_accounts_data_size: usize, + pub loaded_accounts_count: usize, +} + /// Type safe representation of a transaction execution attempt which /// differentiates between a transaction that was executed (will be /// committed to the ledger) and a transaction which wasn't executed