diff --git a/accounts-db/src/accounts.rs b/accounts-db/src/accounts.rs index 49dbeca3437f61..96770405dd7802 100644 --- a/accounts-db/src/accounts.rs +++ b/accounts-db/src/accounts.rs @@ -1582,6 +1582,7 @@ mod tests { fee_details: FeeDetails::default(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let loaded1 = Ok(LoadedTransaction { @@ -1591,6 +1592,7 @@ mod tests { fee_details: FeeDetails::default(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let mut loaded = vec![loaded0, loaded1]; @@ -1968,6 +1970,7 @@ mod tests { fee_details: FeeDetails::default(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, }); let mut loaded = vec![loaded]; @@ -2073,6 +2076,7 @@ mod tests { fee_details: FeeDetails::default(), 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 87bfc34405d0d3..35df314add9a74 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}, @@ -4139,13 +4140,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 4e4f76146e3869..81f76dd0d10341 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -54,6 +54,7 @@ pub struct LoadedTransaction { pub fee_details: FeeDetails, pub rent: TransactionRent, pub rent_debits: RentDebits, + pub loaded_accounts_data_size: usize, } impl LoadedTransaction { @@ -390,6 +391,7 @@ fn load_transaction_accounts( fee_details, rent: tx_rent, rent_debits, + loaded_accounts_data_size: accumulated_accounts_data_size, }) } @@ -1523,7 +1525,8 @@ mod tests { nonce: None, fee_details, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -1728,7 +1731,8 @@ mod tests { fee_details, program_indices: vec![vec![1]], rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -1912,7 +1916,8 @@ mod tests { nonce: None, fee_details, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -2006,7 +2011,8 @@ mod tests { nonce: None, fee_details, rent: 0, - rent_debits: RentDebits::default() + rent_debits: RentDebits::default(), + loaded_accounts_data_size: 0, } ); } @@ -2169,7 +2175,8 @@ mod tests { )), fee_details: FeeDetails::default(), 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 819cb6828573d3..04b4f76afde80b 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -1001,6 +1001,7 @@ mod tests { fee_details: FeeDetails::default(), rent: 0, rent_debits: RentDebits::default(), + loaded_accounts_data_size: 32, }; let mut processing_config = TransactionProcessingConfig::default(); @@ -1126,6 +1127,7 @@ mod tests { fee_details: FeeDetails::default(), 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 f82fc47d04649c..8cf40a39d3eb57 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