diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index 36db2aaa75a6d3..600bb6ca192b66 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "dev-context-only-utils")] +use qualifier_attr::field_qualifiers; use { crate::{ account_overrides::AccountOverrides, @@ -42,10 +44,10 @@ use { pub(crate) type TransactionRent = u64; pub(crate) type TransactionProgramIndices = Vec>; pub type TransactionCheckResult = Result; -pub type TransactionValidationResult = Result; +type TransactionValidationResult = Result; #[derive(PartialEq, Eq, Debug)] -pub enum TransactionLoadResult { +pub(crate) enum TransactionLoadResult { /// All transaction accounts were loaded successfully Loaded(LoadedTransaction), /// Some transaction accounts needed for execution were unable to be loaded @@ -66,16 +68,16 @@ pub struct CheckedTransactionDetails { #[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr(feature = "dev-context-only-utils", derive(Default))] -pub struct ValidatedTransactionDetails { - pub rollback_accounts: RollbackAccounts, - pub compute_budget_limits: ComputeBudgetLimits, - pub fee_details: FeeDetails, - pub loaded_fee_payer_account: LoadedTransactionAccount, +pub(crate) struct ValidatedTransactionDetails { + pub(crate) rollback_accounts: RollbackAccounts, + pub(crate) compute_budget_limits: ComputeBudgetLimits, + pub(crate) fee_details: FeeDetails, + pub(crate) loaded_fee_payer_account: LoadedTransactionAccount, } #[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr(feature = "dev-context-only-utils", derive(Default))] -pub struct LoadedTransactionAccount { +pub(crate) struct LoadedTransactionAccount { pub(crate) account: AccountSharedData, pub(crate) loaded_size: usize, pub(crate) rent_collected: u64, @@ -83,12 +85,16 @@ pub struct LoadedTransactionAccount { #[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr(feature = "dev-context-only-utils", derive(Default))] +#[cfg_attr( + feature = "dev-context-only-utils", + field_qualifiers(program_indices(pub), compute_budget_limits(pub)) +)] pub struct LoadedTransaction { pub accounts: Vec, - pub program_indices: TransactionProgramIndices, + pub(crate) program_indices: TransactionProgramIndices, pub fee_details: FeeDetails, pub rollback_accounts: RollbackAccounts, - pub compute_budget_limits: ComputeBudgetLimits, + pub(crate) compute_budget_limits: ComputeBudgetLimits, pub rent: TransactionRent, pub rent_debits: RentDebits, pub loaded_accounts_data_size: u32, @@ -110,7 +116,7 @@ pub(crate) struct AccountLoader<'a, CB: TransactionProcessingCallback> { pub(crate) feature_set: Arc, } impl<'a, CB: TransactionProcessingCallback> AccountLoader<'a, CB> { - pub fn new_with_account_cache_capacity( + pub(crate) fn new_with_account_cache_capacity( account_overrides: Option<&'a AccountOverrides>, program_cache: ProgramCacheForTxBatch, program_accounts: HashMap, @@ -137,7 +143,7 @@ impl<'a, CB: TransactionProcessingCallback> AccountLoader<'a, CB> { } } - pub fn load_account( + pub(crate) fn load_account( &mut self, account_key: &Pubkey, usage_pattern: AccountUsagePattern, @@ -196,7 +202,7 @@ impl<'a, CB: TransactionProcessingCallback> AccountLoader<'a, CB> { }) } - pub fn update_accounts_for_executed_tx( + pub(crate) fn update_accounts_for_executed_tx( &mut self, message: &impl SVMMessage, executed_transaction: &ExecutedTransaction, @@ -217,7 +223,7 @@ impl<'a, CB: TransactionProcessingCallback> AccountLoader<'a, CB> { } } - pub fn update_accounts_for_failed_tx( + pub(crate) fn update_accounts_for_failed_tx( &mut self, message: &impl SVMMessage, rollback_accounts: &RollbackAccounts, @@ -274,7 +280,7 @@ pub(crate) enum AccountUsagePattern { ReadOnlyInvisible, } impl AccountUsagePattern { - pub fn new(message: &impl SVMMessage, account_index: usize) -> Self { + fn new(message: &impl SVMMessage, account_index: usize) -> Self { let is_writable = message.is_writable(account_index); let is_instruction_account = message.is_instruction_account(account_index); @@ -414,11 +420,11 @@ pub(crate) fn load_transaction( #[derive(PartialEq, Eq, Debug, Clone)] struct LoadedTransactionAccounts { - pub accounts: Vec, - pub program_indices: TransactionProgramIndices, - pub rent: TransactionRent, - pub rent_debits: RentDebits, - pub loaded_accounts_data_size: u32, + pub(crate) accounts: Vec, + pub(crate) program_indices: TransactionProgramIndices, + pub(crate) rent: TransactionRent, + pub(crate) rent_debits: RentDebits, + pub(crate) loaded_accounts_data_size: u32, } fn load_transaction_accounts( diff --git a/svm/src/account_overrides.rs b/svm/src/account_overrides.rs index 7381852965f06d..f548c1cb092f00 100644 --- a/svm/src/account_overrides.rs +++ b/svm/src/account_overrides.rs @@ -28,7 +28,7 @@ impl AccountOverrides { } /// Gets the account if it's found in the list of overrides - pub fn get(&self, pubkey: &Pubkey) -> Option<&AccountSharedData> { + pub(crate) fn get(&self, pubkey: &Pubkey) -> Option<&AccountSharedData> { self.accounts.get(pubkey) } } diff --git a/svm/src/message_processor.rs b/svm/src/message_processor.rs index 99c0fa5206d05e..a3bd07f1e8c0a8 100644 --- a/svm/src/message_processor.rs +++ b/svm/src/message_processor.rs @@ -11,7 +11,7 @@ use { }; #[derive(Debug, Default, Clone, serde_derive::Deserialize, serde_derive::Serialize)] -pub struct MessageProcessor {} +pub(crate) struct MessageProcessor {} #[cfg(feature = "frozen-abi")] impl ::solana_frozen_abi::abi_example::AbiExample for MessageProcessor { @@ -28,7 +28,7 @@ impl MessageProcessor { /// For each instruction it calls the program entrypoint method and verifies that the result of /// the call does not violate the bank's accounting rules. /// The accounts are committed back to the bank only if every instruction succeeds. - pub fn process_message( + pub(crate) fn process_message( message: &impl SVMMessage, program_indices: &[Vec], invoke_context: &mut InvokeContext, diff --git a/svm/src/nonce_info.rs b/svm/src/nonce_info.rs index 0fa36bb5eb0328..4008578e263b97 100644 --- a/svm/src/nonce_info.rs +++ b/svm/src/nonce_info.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "dev-context-only-utils")] +use qualifier_attr::qualifiers; use { solana_account::{state_traits::StateMut, AccountSharedData}, solana_nonce::{ @@ -16,7 +18,8 @@ pub struct NonceInfo { } #[derive(Error, Debug, PartialEq)] -pub enum AdvanceNonceError { +#[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))] +enum AdvanceNonceError { #[error("Invalid account")] Invalid, #[error("Uninitialized nonce")] @@ -31,7 +34,8 @@ impl NonceInfo { // Advance the stored blockhash to prevent fee theft by someone // replaying nonce transactions that have failed with an // `InstructionError`. - pub fn try_advance_nonce( + #[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))] + fn try_advance_nonce( &mut self, durable_nonce: DurableNonce, lamports_per_signature: u64, diff --git a/svm/src/program_loader.rs b/svm/src/program_loader.rs index f45bf5bdde67b6..4b1201d27c6d94 100644 --- a/svm/src/program_loader.rs +++ b/svm/src/program_loader.rs @@ -275,8 +275,8 @@ mod tests { } #[derive(Default, Clone)] - pub struct MockBankCallback { - pub account_shared_data: RefCell>, + pub(crate) struct MockBankCallback { + pub(crate) account_shared_data: RefCell>, } impl TransactionProcessingCallback for MockBankCallback { diff --git a/svm/src/rollback_accounts.rs b/svm/src/rollback_accounts.rs index fec3cb27e3cc16..e25f507499463d 100644 --- a/svm/src/rollback_accounts.rs +++ b/svm/src/rollback_accounts.rs @@ -31,7 +31,7 @@ impl Default for RollbackAccounts { } impl RollbackAccounts { - pub fn new( + pub(crate) fn new( nonce: Option, fee_payer_address: Pubkey, mut fee_payer_account: AccountSharedData, diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 01c4af21b55a42..41f7bd619afd90 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -240,7 +240,8 @@ impl TransactionBatchProcessor { /// /// The cache will still not contain any builtin programs. It's advisable to /// call `add_builtin` to add the required builtins before using the processor. - pub fn new( + #[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))] + fn new( slot: Slot, epoch: Epoch, fork_graph: Weak>, @@ -1191,8 +1192,8 @@ impl TransactionBatchProcessor { debug!("Added program {} under {:?}", name, program_id); } - #[cfg(feature = "dev-context-only-utils")] - pub fn writable_sysvar_cache(&self) -> &RwLock { + #[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))] + fn writable_sysvar_cache(&self) -> &RwLock { &self.sysvar_cache } } @@ -1250,10 +1251,10 @@ mod tests { } #[derive(Default, Clone)] - pub struct MockBankCallback { - pub account_shared_data: Arc>>, + struct MockBankCallback { + account_shared_data: Arc>>, #[allow(clippy::type_complexity)] - pub inspected_accounts: + inspected_accounts: Arc, /* is_writable */ bool)>>>>, }