Struct solana_runtime::bank::Bank
source · pub struct Bank {Show 61 fields
pub rc: BankRc,
pub status_cache: Arc<RwLock<BankStatusCache>>,
blockhash_queue: RwLock<BlockhashQueue>,
pub ancestors: Ancestors,
hash: RwLock<Hash>,
parent_hash: Hash,
parent_slot: Slot,
hard_forks: Arc<RwLock<HardForks>>,
transaction_count: AtomicU64,
non_vote_transaction_count_since_restart: AtomicU64,
transaction_error_count: AtomicU64,
transaction_entries_count: AtomicU64,
transactions_per_entry_max: AtomicU64,
tick_height: AtomicU64,
signature_count: AtomicU64,
capitalization: AtomicU64,
max_tick_height: u64,
hashes_per_tick: Option<u64>,
ticks_per_slot: u64,
pub ns_per_slot: u128,
genesis_creation_time: UnixTimestamp,
slots_per_year: f64,
slot: Slot,
bank_id: BankId,
epoch: Epoch,
block_height: u64,
collector_id: Pubkey,
collector_fees: AtomicU64,
pub(crate) fee_calculator: FeeCalculator,
pub(crate) fee_rate_governor: FeeRateGovernor,
collected_rent: AtomicU64,
rent_collector: RentCollector,
epoch_schedule: EpochSchedule,
inflation: Arc<RwLock<Inflation>>,
stakes_cache: StakesCache,
epoch_stakes: HashMap<Epoch, EpochStakes>,
is_delta: AtomicBool,
builtin_programs: BuiltinPrograms,
runtime_config: Arc<RuntimeConfig>,
builtin_feature_transitions: Arc<Vec<BuiltinFeatureTransition>>,
pub rewards: RwLock<Vec<(Pubkey, RewardInfo)>>,
pub cluster_type: Option<ClusterType>,
pub lazy_rent_collection: AtomicBool,
pub rewards_pool_pubkeys: Arc<HashSet<Pubkey>>,
executor_cache: RwLock<BankExecutorCache>,
transaction_debug_keys: Option<Arc<HashSet<Pubkey>>>,
pub transaction_log_collector_config: Arc<RwLock<TransactionLogCollectorConfig>>,
pub transaction_log_collector: Arc<RwLock<TransactionLogCollector>>,
pub feature_set: Arc<FeatureSet>,
pub drop_callback: RwLock<OptionalDropCallback>,
pub freeze_started: AtomicBool,
vote_only_bank: bool,
cost_tracker: RwLock<CostTracker>,
sysvar_cache: RwLock<SysvarCache>,
accounts_data_size_initial: u64,
accounts_data_size_delta_on_chain: AtomicI64,
accounts_data_size_delta_off_chain: AtomicI64,
pub fee_structure: FeeStructure,
pub incremental_snapshot_persistence: Option<BankIncrementalSnapshotPersistence>,
pub loaded_programs_cache: Arc<RwLock<LoadedPrograms>>,
bank_freeze_or_destruction_incremented: AtomicBool,
}
Expand description
Manager for the state of all accounts and programs after processing its entries. AbiExample is needed even without Serialize/Deserialize; actual (de-)serialization are implemented elsewhere for versioning
Fields§
§rc: BankRc
References to accounts, parent and signature status
status_cache: Arc<RwLock<BankStatusCache>>
A cache of signature statuses
blockhash_queue: RwLock<BlockhashQueue>
FIFO queue of recent_blockhash
items
ancestors: Ancestors
The set of parents including this bank
hash: RwLock<Hash>
Hash of this Bank’s state. Only meaningful after freezing.
parent_hash: Hash
Hash of this Bank’s parent’s state
parent_slot: Slot
parent’s slot
hard_forks: Arc<RwLock<HardForks>>
slots to hard fork at
transaction_count: AtomicU64
The number of transactions processed without error
non_vote_transaction_count_since_restart: AtomicU64
The number of non-vote transactions processed without error since the most recent boot from
snapshot or genesis. This value is not shared though the network, nor retained within
snapshots, but is preserved in Bank::new_from_parent
.
transaction_error_count: AtomicU64
The number of transaction errors in this slot
transaction_entries_count: AtomicU64
The number of transaction entries in this slot
transactions_per_entry_max: AtomicU64
The max number of transaction in an entry in this slot
tick_height: AtomicU64
Bank tick height
signature_count: AtomicU64
The number of signatures from valid transactions in this slot
capitalization: AtomicU64
Total capitalization, used to calculate inflation
max_tick_height: u64
§hashes_per_tick: Option<u64>
The number of hashes in each tick. None value means hashing is disabled.
ticks_per_slot: u64
The number of ticks in each slot.
ns_per_slot: u128
length of a slot in ns
genesis_creation_time: UnixTimestamp
genesis time, used for computed clock
slots_per_year: f64
The number of slots per year, used for inflation
slot: Slot
Bank slot (i.e. block)
bank_id: BankId
§epoch: Epoch
Bank epoch
block_height: u64
Bank block_height
collector_id: Pubkey
The pubkey to send transactions fees to.
collector_fees: AtomicU64
Fees that have been collected
fee_calculator: FeeCalculator
Deprecated, do not use Latest transaction fees for transactions processed by this bank
fee_rate_governor: FeeRateGovernor
Track cluster signature throughput and adjust fee rate
collected_rent: AtomicU64
Rent that has been collected
rent_collector: RentCollector
latest rent collector, knows the epoch
epoch_schedule: EpochSchedule
initialized from genesis
inflation: Arc<RwLock<Inflation>>
inflation specs
stakes_cache: StakesCache
cache of vote_account and stake_account state for this fork
epoch_stakes: HashMap<Epoch, EpochStakes>
staked nodes on epoch boundaries, saved off when a bank.slot() is at a leader schedule calculation boundary
is_delta: AtomicBool
A boolean reflecting whether any entries were recorded into the PoH stream for the slot == self.slot
builtin_programs: BuiltinPrograms
The builtin programs
runtime_config: Arc<RuntimeConfig>
Optional config parameters that can override runtime behavior
builtin_feature_transitions: Arc<Vec<BuiltinFeatureTransition>>
Dynamic feature transitions for builtin programs
rewards: RwLock<Vec<(Pubkey, RewardInfo)>>
Protocol-level rewards that were distributed by this bank
cluster_type: Option<ClusterType>
§lazy_rent_collection: AtomicBool
§rewards_pool_pubkeys: Arc<HashSet<Pubkey>>
§executor_cache: RwLock<BankExecutorCache>
Cached executors
transaction_debug_keys: Option<Arc<HashSet<Pubkey>>>
§transaction_log_collector_config: Arc<RwLock<TransactionLogCollectorConfig>>
§transaction_log_collector: Arc<RwLock<TransactionLogCollector>>
§feature_set: Arc<FeatureSet>
§drop_callback: RwLock<OptionalDropCallback>
callback function only to be called when dropping and should only be called once
freeze_started: AtomicBool
§vote_only_bank: bool
§cost_tracker: RwLock<CostTracker>
§sysvar_cache: RwLock<SysvarCache>
§accounts_data_size_initial: u64
The initial accounts data size at the start of this Bank, before processing any transactions/etc
accounts_data_size_delta_on_chain: AtomicI64
The change to accounts data size in this Bank, due on-chain events (i.e. transactions)
accounts_data_size_delta_off_chain: AtomicI64
The change to accounts data size in this Bank, due to off-chain events (i.e. rent collection)
fee_structure: FeeStructure
Transaction fee structure
incremental_snapshot_persistence: Option<BankIncrementalSnapshotPersistence>
§loaded_programs_cache: Arc<RwLock<LoadedPrograms>>
§bank_freeze_or_destruction_incremented: AtomicBool
true when the bank’s freezing or destruction has completed
Implementations§
source§impl Bank
impl Bank
pub(crate) fn fill_missing_sysvar_cache_entries(&self)
pub(crate) fn reset_sysvar_cache(&self)
pub fn get_sysvar_cache_for_tests(&self) -> SysvarCache
source§impl Bank
impl Bank
pub(crate) fn get_transaction_account_state_info( &self, transaction_context: &TransactionContext, message: &SanitizedMessage ) -> Vec<TransactionAccountStateInfo>
pub(crate) fn verify_transaction_account_state_changes( &self, pre_state_infos: &[TransactionAccountStateInfo], post_state_infos: &[TransactionAccountStateInfo], transaction_context: &TransactionContext ) -> Result<()>
source§impl Bank
impl Bank
pub fn default_for_tests() -> Self
pub fn new_for_benches(genesis_config: &GenesisConfig) -> Self
pub fn new_for_tests(genesis_config: &GenesisConfig) -> Self
pub fn new_for_tests_with_config( genesis_config: &GenesisConfig, test_config: BankTestConfig ) -> Self
pub fn new_with_runtime_config_for_tests( genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig> ) -> Self
pub fn new_no_wallclock_throttle_for_tests( genesis_config: &GenesisConfig ) -> Self
pub(crate) fn new_with_config_for_tests( genesis_config: &GenesisConfig, account_indexes: AccountSecondaryIndexes, shrink_ratio: AccountShrinkThreshold ) -> Self
fn default_with_accounts(accounts: Accounts) -> Self
pub fn new_with_paths_for_tests( genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig>, paths: Vec<PathBuf>, account_indexes: AccountSecondaryIndexes, shrink_ratio: AccountShrinkThreshold ) -> Self
pub fn new_with_paths_for_benches( genesis_config: &GenesisConfig, paths: Vec<PathBuf> ) -> Self
pub fn new_with_paths( genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig>, paths: Vec<PathBuf>, debug_keys: Option<Arc<HashSet<Pubkey>>>, additional_builtins: Option<&Builtins>, account_indexes: AccountSecondaryIndexes, shrink_ratio: AccountShrinkThreshold, debug_do_not_add_builtins: bool, accounts_db_config: Option<AccountsDbConfig>, accounts_update_notifier: Option<AccountsUpdateNotifier>, exit: &Arc<AtomicBool> ) -> Self
sourcepub fn new_from_parent(
parent: &Arc<Bank>,
collector_id: &Pubkey,
slot: Slot
) -> Self
pub fn new_from_parent( parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot ) -> Self
Create a new bank that points to an immutable checkpoint of another bank.
pub fn new_from_parent_with_options( parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot, new_bank_options: NewBankOptions ) -> Self
pub fn new_from_parent_with_tracer( parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot, reward_calc_tracer: impl RewardCalcTracer ) -> Self
fn get_rent_collector_from( rent_collector: &RentCollector, epoch: Epoch ) -> RentCollector
fn _new_from_parent( parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot, reward_calc_tracer: Option<impl RewardCalcTracer>, new_bank_options: NewBankOptions ) -> Self
sourcefn process_new_epoch(
&mut self,
parent_epoch: Epoch,
parent_slot: Slot,
reward_calc_tracer: Option<impl RewardCalcTracer>
)
fn process_new_epoch( &mut self, parent_epoch: Epoch, parent_slot: Slot, reward_calc_tracer: Option<impl RewardCalcTracer> )
process for the start of a new epoch
pub fn byte_limit_for_scans(&self) -> Option<usize>
pub fn proper_ancestors_set(&self) -> HashSet<Slot>
sourcepub(crate) fn proper_ancestors(&self) -> impl Iterator<Item = Slot> + '_
pub(crate) fn proper_ancestors(&self) -> impl Iterator<Item = Slot> + '_
Returns all ancestors excluding self.slot.
pub fn set_callback( &self, callback: Option<Box<dyn DropCallback + Send + Sync>> )
pub fn vote_only_bank(&self) -> bool
fn bank_created(&self)
fn bank_frozen_or_destroyed(&self)
sourcepub fn warp_from_parent(
parent: &Arc<Bank>,
collector_id: &Pubkey,
slot: Slot,
data_source: CalcAccountsHashDataSource
) -> Self
pub fn warp_from_parent( parent: &Arc<Bank>, collector_id: &Pubkey, slot: Slot, data_source: CalcAccountsHashDataSource ) -> Self
Like new_from_parent
but additionally:
- Doesn’t assume that the parent is anywhere near
slot
, parent could be millions of slots in the past - Adjusts the new bank’s tick height to avoid having to run PoH for millions of slots
- Freezes the new bank, assuming that the user will
Bank::new_from_parent
from this bank - Calculates and sets the epoch accounts hash from the parent
sourcepub(crate) fn new_from_fields(
bank_rc: BankRc,
genesis_config: &GenesisConfig,
runtime_config: Arc<RuntimeConfig>,
fields: BankFieldsToDeserialize,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
debug_do_not_add_builtins: bool,
accounts_data_size_initial: u64
) -> Self
pub(crate) fn new_from_fields( bank_rc: BankRc, genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig>, fields: BankFieldsToDeserialize, debug_keys: Option<Arc<HashSet<Pubkey>>>, additional_builtins: Option<&Builtins>, debug_do_not_add_builtins: bool, accounts_data_size_initial: u64 ) -> Self
Create a bank from explicit arguments and deserialized fields from snapshot
sourcepub(crate) fn get_fields_to_serialize<'a>(
&'a self,
ancestors: &'a HashMap<Slot, usize>
) -> BankFieldsToSerialize<'a>
pub(crate) fn get_fields_to_serialize<'a>( &'a self, ancestors: &'a HashMap<Slot, usize> ) -> BankFieldsToSerialize<'a>
Return subset of bank fields representing serializable state
pub fn collector_id(&self) -> &Pubkey
pub fn genesis_creation_time(&self) -> UnixTimestamp
pub fn slot(&self) -> Slot
pub fn bank_id(&self) -> BankId
pub fn epoch(&self) -> Epoch
pub fn first_normal_epoch(&self) -> Epoch
pub fn freeze_lock(&self) -> RwLockReadGuard<'_, Hash>
pub fn hash(&self) -> Hash
pub fn is_frozen(&self) -> bool
pub fn freeze_started(&self) -> bool
pub fn status_cache_ancestors(&self) -> Vec<u64>
sourcepub fn unix_timestamp_from_genesis(&self) -> i64
pub fn unix_timestamp_from_genesis(&self) -> i64
computed unix_timestamp at this slot height
fn update_sysvar_account<F>(&self, pubkey: &Pubkey, updater: F)where F: Fn(&Option<AccountSharedData>) -> AccountSharedData,
fn inherit_specially_retained_account_fields( &self, old_account: &Option<AccountSharedData> ) -> InheritableAccountFields
pub fn clock(&self) -> Clock
fn update_clock(&self, parent_epoch: Option<Epoch>)
pub fn set_sysvar_for_tests<T>(&self, sysvar: &T)where T: Sysvar + SysvarId,
fn update_slot_history(&self)
fn update_slot_hashes(&self)
pub fn get_slot_history(&self) -> SlotHistory
fn update_epoch_stakes(&mut self, leader_schedule_epoch: Epoch)
fn update_fees(&self)
fn update_rent(&self)
fn update_epoch_schedule(&self)
fn update_stake_history(&self, epoch: Option<Epoch>)
pub fn epoch_duration_in_years(&self, prev_epoch: Epoch) -> f64
fn get_inflation_start_slot(&self) -> Slot
fn get_inflation_num_slots(&self) -> u64
pub fn slot_in_year_for_inflation(&self) -> f64
fn calculate_previous_epoch_inflation_rewards( &self, prev_epoch_capitalization: u64, prev_epoch: Epoch ) -> PrevEpochInflationRewards
fn update_rewards_with_thread_pool( &mut self, prev_epoch: Epoch, reward_calc_tracer: Option<impl Fn(&RewardCalculationEvent<'_, '_>) + Send + Sync>, thread_pool: &ThreadPool, metrics: &mut RewardsMetrics )
sourcefn _load_vote_and_stake_accounts_with_thread_pool(
&self,
thread_pool: &ThreadPool,
reward_calc_tracer: Option<impl RewardCalcTracer>
) -> LoadVoteAndStakeAccountsResult
fn _load_vote_and_stake_accounts_with_thread_pool( &self, thread_pool: &ThreadPool, reward_calc_tracer: Option<impl RewardCalcTracer> ) -> LoadVoteAndStakeAccountsResult
map stake delegations into resolved (pubkey, account) pairs returns a map (has to be copied) of loaded ( Vec<(staker info)> (voter account) ) keyed by voter pubkey
Filters out invalid pairs
fn filter_stake_delegations<'a>( &self, stakes: &'a Stakes<StakeAccount<Delegation>> ) -> Vec<(&'a Pubkey, &'a StakeAccount<Delegation>)>
fn _load_vote_and_stake_accounts( &self, thread_pool: &ThreadPool, reward_calc_tracer: Option<impl RewardCalcTracer> ) -> LoadVoteAndStakeAccountsResult
sourcefn pay_validator_rewards_with_thread_pool(
&mut self,
rewarded_epoch: Epoch,
rewards: u64,
reward_calc_tracer: Option<impl RewardCalcTracer>,
credits_auto_rewind: bool,
thread_pool: &ThreadPool,
metrics: &mut RewardsMetrics,
update_rewards_from_cached_accounts: bool
)
fn pay_validator_rewards_with_thread_pool( &mut self, rewarded_epoch: Epoch, rewards: u64, reward_calc_tracer: Option<impl RewardCalcTracer>, credits_auto_rewind: bool, thread_pool: &ThreadPool, metrics: &mut RewardsMetrics, update_rewards_from_cached_accounts: bool )
Load, calculate and payout epoch rewards for stake and vote accounts
fn load_vote_and_stake_accounts( &mut self, thread_pool: &ThreadPool, reward_calc_tracer: Option<impl RewardCalcTracer>, metrics: &mut RewardsMetrics, update_rewards_from_cached_accounts: bool ) -> DashMap<Pubkey, VoteWithStakeDelegations>
fn calculate_reward_points( &self, vote_with_stake_delegations_map: &DashMap<Pubkey, VoteWithStakeDelegations>, rewards: u64, stake_history: &StakeHistory, thread_pool: &ThreadPool, metrics: &mut RewardsMetrics ) -> Option<PointValue>
fn redeem_rewards( &self, vote_with_stake_delegations_map: DashMap<Pubkey, VoteWithStakeDelegations>, rewarded_epoch: Epoch, point_value: PointValue, credits_auto_rewind: bool, stake_history: &StakeHistory, thread_pool: &ThreadPool, reward_calc_tracer: Option<impl RewardCalcTracer>, metrics: &mut RewardsMetrics ) -> (DashMap<Pubkey, (AccountSharedData, u8, u64, bool)>, Vec<StakeReward>)
fn store_stake_accounts( &self, stake_rewards: &[StakeReward], metrics: &mut RewardsMetrics )
fn store_vote_accounts( &self, vote_account_rewards: DashMap<Pubkey, (AccountSharedData, u8, u64, bool)>, metrics: &mut RewardsMetrics ) -> Vec<(Pubkey, RewardInfo)>
fn update_reward_history( &self, stake_rewards: Vec<StakeReward>, vote_rewards: Vec<(Pubkey, RewardInfo)> )
fn update_recent_blockhashes_locked( &self, locked_blockhash_queue: &BlockhashQueue )
pub fn update_recent_blockhashes(&self)
fn get_timestamp_estimate( &self, max_allowable_drift: MaxAllowableDrift, epoch_start_timestamp: Option<(Slot, UnixTimestamp)> ) -> Option<UnixTimestamp>
fn collect_fees(&self)
pub fn rehash(&self)
pub fn freeze(&self)
pub fn unfreeze_for_ledger_tool(&self)
pub fn epoch_schedule(&self) -> &EpochSchedule
sourcepub fn squash(&self) -> SquashTiming
pub fn squash(&self) -> SquashTiming
squash the parent’s state up into this Bank, this Bank becomes a root
sourcepub fn parent(&self) -> Option<Arc<Bank>>
pub fn parent(&self) -> Option<Arc<Bank>>
Return the more recent checkpoint of this bank instance.
pub fn parent_slot(&self) -> Slot
pub fn parent_hash(&self) -> Hash
fn process_genesis_config(&mut self, genesis_config: &GenesisConfig)
fn burn_and_purge_account( &self, program_id: &Pubkey, account: AccountSharedData )
sourcepub fn add_builtin_account(
&self,
name: &str,
program_id: &Pubkey,
must_replace: bool
)
pub fn add_builtin_account( &self, name: &str, program_id: &Pubkey, must_replace: bool )
Add a builtin program account
sourcepub fn add_precompiled_account(&self, program_id: &Pubkey)
pub fn add_precompiled_account(&self, program_id: &Pubkey)
Add a precompiled program account
fn add_precompiled_account_with_owner(&self, program_id: &Pubkey, owner: Pubkey)
pub fn set_rent_burn_percentage(&mut self, burn_percent: u8)
pub fn set_hashes_per_tick(&mut self, hashes_per_tick: Option<u64>)
sourcepub fn last_blockhash(&self) -> Hash
pub fn last_blockhash(&self) -> Hash
Return the last block hash registered.
pub fn last_blockhash_and_lamports_per_signature(&self) -> (Hash, u64)
pub fn is_blockhash_valid(&self, hash: &Hash) -> bool
pub fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> u64
pub fn get_lamports_per_signature(&self) -> u64
pub fn get_lamports_per_signature_for_blockhash( &self, hash: &Hash ) -> Option<u64>
pub fn get_fee_rate_governor(&self) -> &FeeRateGovernor
get_fee_for_message
insteadpub fn get_fee_for_message(&self, message: &SanitizedMessage) -> Option<u64>
pub fn get_startup_verification_complete(&self) -> &Arc<AtomicBool>
pub fn is_startup_verification_complete(&self) -> bool
sourcepub fn set_startup_verification_complete(&self)
pub fn set_startup_verification_complete(&self)
This can occur because it completed in the background or if the verification was run in the foreground.
pub fn get_fee_for_message_with_lamports_per_signature( &self, message: &SanitizedMessage, lamports_per_signature: u64 ) -> u64
pub fn get_blockhash_last_valid_slot(&self, blockhash: &Hash) -> Option<Slot>
get_blockhash_last_valid_block_height
pub fn get_blockhash_last_valid_block_height( &self, blockhash: &Hash ) -> Option<Slot>
pub fn confirmed_last_blockhash(&self) -> Hash
sourcepub fn clear_signatures(&self)
pub fn clear_signatures(&self)
Forget all signatures. Useful for benchmarking.
pub fn clear_slot_signatures(&self, slot: Slot)
fn update_transaction_statuses( &self, sanitized_txs: &[SanitizedTransaction], execution_results: &[TransactionExecutionResult] )
sourcepub fn register_recent_blockhash(&self, blockhash: &Hash)
pub fn register_recent_blockhash(&self, blockhash: &Hash)
Register a new recent blockhash in the bank’s recent blockhash queue. Called when a bank reaches its max tick height. Can be called by tests to get new blockhashes for transaction processing without advancing to a new bank slot.
sourcepub fn register_tick(&self, hash: &Hash)
pub fn register_tick(&self, hash: &Hash)
Tell the bank which Entry IDs exist on the ledger. This function assumes subsequent calls
correspond to later entries, and will boot the oldest ones once its internal cache is full.
Once boot, the bank will reject transactions using that hash
.
This is NOT thread safe because if tick height is updated by two different threads, the block boundary condition could be missed.
pub fn is_complete(&self) -> bool
pub fn is_block_boundary(&self, tick_height: u64) -> bool
sourcepub fn get_transaction_account_lock_limit(&self) -> usize
pub fn get_transaction_account_lock_limit(&self) -> usize
Get the max number of accounts that a transaction may lock in this block
sourcepub fn prepare_batch_for_tests(
&self,
txs: Vec<Transaction>
) -> TransactionBatch<'_, '_>
pub fn prepare_batch_for_tests( &self, txs: Vec<Transaction> ) -> TransactionBatch<'_, '_>
Prepare a transaction batch from a list of legacy transactions. Used for tests only.
sourcepub fn prepare_entry_batch(
&self,
txs: Vec<VersionedTransaction>
) -> Result<TransactionBatch<'_, '_>>
pub fn prepare_entry_batch( &self, txs: Vec<VersionedTransaction> ) -> Result<TransactionBatch<'_, '_>>
Prepare a transaction batch from a list of versioned transactions from an entry. Used for tests only.
sourcepub fn prepare_sanitized_batch<'a, 'b>(
&'a self,
txs: &'b [SanitizedTransaction]
) -> TransactionBatch<'a, 'b>
pub fn prepare_sanitized_batch<'a, 'b>( &'a self, txs: &'b [SanitizedTransaction] ) -> TransactionBatch<'a, 'b>
Prepare a locked transaction batch from a list of sanitized transactions.
sourcepub fn prepare_sanitized_batch_with_results<'a, 'b>(
&'a self,
transactions: &'b [SanitizedTransaction],
transaction_results: impl Iterator<Item = &'b Result<()>>
) -> TransactionBatch<'a, 'b>
pub fn prepare_sanitized_batch_with_results<'a, 'b>( &'a self, transactions: &'b [SanitizedTransaction], transaction_results: impl Iterator<Item = &'b Result<()>> ) -> TransactionBatch<'a, 'b>
Prepare a locked transaction batch from a list of sanitized transactions, and their cost limited packing status
sourcepub(crate) fn prepare_simulation_batch(
&self,
transaction: SanitizedTransaction
) -> TransactionBatch<'_, '_>
pub(crate) fn prepare_simulation_batch( &self, transaction: SanitizedTransaction ) -> TransactionBatch<'_, '_>
Prepare a transaction batch without locking accounts for transaction simulation.
sourcepub fn simulate_transaction(
&self,
transaction: SanitizedTransaction
) -> TransactionSimulationResult
pub fn simulate_transaction( &self, transaction: SanitizedTransaction ) -> TransactionSimulationResult
Run transactions against a frozen bank without committing the results
sourcepub fn simulate_transaction_unchecked(
&self,
transaction: SanitizedTransaction
) -> TransactionSimulationResult
pub fn simulate_transaction_unchecked( &self, transaction: SanitizedTransaction ) -> TransactionSimulationResult
Run transactions against a bank without committing the results; does not check if the bank is frozen, enabling use in single-Bank test frameworks
fn get_account_overrides_for_simulation( &self, account_keys: &AccountKeys<'_> ) -> AccountOverrides
pub fn unlock_accounts(&self, batch: &mut TransactionBatch<'_, '_>)
pub fn remove_unrooted_slots(&self, slots: &[(Slot, BankId)])
pub fn set_shrink_paths(&self, paths: Vec<PathBuf>)
fn check_age<'a>( &self, txs: impl Iterator<Item = &'a SanitizedTransaction>, lock_results: &[Result<()>], max_age: usize, error_counters: &mut TransactionErrorMetrics ) -> Vec<TransactionCheckResult>
fn check_transaction_age( &self, tx: &SanitizedTransaction, max_age: usize, next_durable_nonce: &DurableNonce, hash_queue: &BlockhashQueue, error_counters: &mut TransactionErrorMetrics ) -> TransactionCheckResult
fn is_transaction_already_processed( &self, sanitized_tx: &SanitizedTransaction, status_cache: &BankStatusCache ) -> bool
fn check_status_cache( &self, sanitized_txs: &[SanitizedTransaction], lock_results: Vec<TransactionCheckResult>, error_counters: &mut TransactionErrorMetrics ) -> Vec<TransactionCheckResult>
pub fn get_hash_age(&self, hash: &Hash) -> Option<u64>
pub fn is_hash_valid_for_age(&self, hash: &Hash, max_age: usize) -> bool
fn check_message_for_nonce( &self, message: &SanitizedMessage ) -> Option<TransactionAccount>
fn check_transaction_for_nonce( &self, tx: &SanitizedTransaction, next_durable_nonce: &DurableNonce ) -> Option<TransactionAccount>
pub fn check_transactions( &self, sanitized_txs: &[SanitizedTransaction], lock_results: &[Result<()>], max_age: usize, error_counters: &mut TransactionErrorMetrics ) -> Vec<TransactionCheckResult>
pub fn collect_balances( &self, batch: &TransactionBatch<'_, '_> ) -> TransactionBalances
sourcefn store_executors_which_added_to_the_cache(
&self,
tx_executor_cache: &RefCell<TransactionExecutorCache>
)
fn store_executors_which_added_to_the_cache( &self, tx_executor_cache: &RefCell<TransactionExecutorCache> )
Add executors back to the bank’s cache if they were missing and not re-/deployed
sourcefn store_executors_which_were_deployed(
&self,
tx_executor_cache: &RefCell<TransactionExecutorCache>
)
fn store_executors_which_were_deployed( &self, tx_executor_cache: &RefCell<TransactionExecutorCache> )
Add re-/deployed executors to the bank’s cache
sourcefn remove_executor(&self, pubkey: &Pubkey)
fn remove_executor(&self, pubkey: &Pubkey)
Remove an executor from the bank’s cache
fn load_program(&self, pubkey: &Pubkey) -> Result<Arc<LoadedProgram>>
pub fn clear_executors(&self)
sourcefn execute_loaded_transaction(
&self,
tx: &SanitizedTransaction,
loaded_transaction: &mut LoadedTransaction,
compute_budget: ComputeBudget,
durable_nonce_fee: Option<DurableNonceFee>,
enable_cpi_recording: bool,
enable_log_recording: bool,
enable_return_data_recording: bool,
timings: &mut ExecuteTimings,
error_counters: &mut TransactionErrorMetrics,
log_messages_bytes_limit: Option<usize>,
tx_executor_cache: Rc<RefCell<TransactionExecutorCache>>
) -> TransactionExecutionResult
fn execute_loaded_transaction( &self, tx: &SanitizedTransaction, loaded_transaction: &mut LoadedTransaction, compute_budget: ComputeBudget, durable_nonce_fee: Option<DurableNonceFee>, enable_cpi_recording: bool, enable_log_recording: bool, enable_return_data_recording: bool, timings: &mut ExecuteTimings, error_counters: &mut TransactionErrorMetrics, log_messages_bytes_limit: Option<usize>, tx_executor_cache: Rc<RefCell<TransactionExecutorCache>> ) -> TransactionExecutionResult
Execute a transaction using the provided loaded accounts and update the executors cache if the transaction was successful.
fn enable_request_heap_frame_ix(&self) -> bool
fn load_and_get_programs_from_cache( &self, program_accounts_map: &HashMap<Pubkey, &Pubkey> ) -> HashMap<Pubkey, Arc<LoadedProgram>>
fn replenish_executor_cache( &self, program_accounts_map: &HashMap<Pubkey, &Pubkey> ) -> HashMap<Pubkey, Arc<LoadedProgram>>
pub fn load_and_execute_transactions( &self, batch: &TransactionBatch<'_, '_>, max_age: usize, enable_cpi_recording: bool, enable_log_recording: bool, enable_return_data_recording: bool, timings: &mut ExecuteTimings, account_overrides: Option<&AccountOverrides>, log_messages_bytes_limit: Option<usize> ) -> LoadAndExecuteTransactionsOutput
sourcepub fn accounts_data_size_limit(&self) -> u64
pub fn accounts_data_size_limit(&self) -> u64
The maximum allowed size, in bytes, of the accounts data
sourcepub fn load_accounts_data_size(&self) -> u64
pub fn load_accounts_data_size(&self) -> u64
Load the accounts data size, in bytes
sourcepub fn load_accounts_data_size_delta(&self) -> i64
pub fn load_accounts_data_size_delta(&self) -> i64
Load the change in accounts data size in this Bank, in bytes
sourcepub fn load_accounts_data_size_delta_on_chain(&self) -> i64
pub fn load_accounts_data_size_delta_on_chain(&self) -> i64
Load the change in accounts data size in this Bank, in bytes, from on-chain events i.e. transactions
sourcepub fn load_accounts_data_size_delta_off_chain(&self) -> i64
pub fn load_accounts_data_size_delta_off_chain(&self) -> i64
Load the change in accounts data size in this Bank, in bytes, from off-chain events i.e. rent collection
sourcefn update_accounts_data_size_delta_on_chain(&self, amount: i64)
fn update_accounts_data_size_delta_on_chain(&self, amount: i64)
Update the accounts data size delta from on-chain events by adding amount
.
The arithmetic saturates.
sourcefn update_accounts_data_size_delta_off_chain(&self, amount: i64)
fn update_accounts_data_size_delta_off_chain(&self, amount: i64)
Update the accounts data size delta from off-chain events by adding amount
.
The arithmetic saturates.
sourcefn calculate_and_update_accounts_data_size_delta_off_chain(
&self,
old_data_size: usize,
new_data_size: usize
)
fn calculate_and_update_accounts_data_size_delta_off_chain( &self, old_data_size: usize, new_data_size: usize )
Calculate the data size delta and update the off-chain accounts data size delta
sourcepub fn set_accounts_data_size_initial_for_tests(&mut self, amount: u64)
pub fn set_accounts_data_size_initial_for_tests(&mut self, amount: u64)
Set the initial accounts data size NOTE: This fn is ONLY FOR TESTS
sourcepub fn update_accounts_data_size_delta_off_chain_for_tests(&self, amount: i64)
pub fn update_accounts_data_size_delta_off_chain_for_tests(&self, amount: i64)
Update the accounts data size off-chain delta NOTE: This fn is ONLY FOR TESTS
fn get_num_signatures_in_message(message: &SanitizedMessage) -> u64
fn get_num_write_locks_in_message(message: &SanitizedMessage) -> u64
sourcepub fn calculate_fee(
message: &SanitizedMessage,
lamports_per_signature: u64,
fee_structure: &FeeStructure,
use_default_units_per_instruction: bool,
support_request_units_deprecated: bool,
remove_congestion_multiplier: bool,
enable_request_heap_frame_ix: bool,
support_set_accounts_data_size_limit_ix: bool,
include_loaded_account_data_size_in_fee: bool
) -> u64
pub fn calculate_fee( message: &SanitizedMessage, lamports_per_signature: u64, fee_structure: &FeeStructure, use_default_units_per_instruction: bool, support_request_units_deprecated: bool, remove_congestion_multiplier: bool, enable_request_heap_frame_ix: bool, support_set_accounts_data_size_limit_ix: bool, include_loaded_account_data_size_in_fee: bool ) -> u64
Calculate fee for SanitizedMessage
fn calculate_loaded_accounts_data_size_cost( compute_budget: &ComputeBudget ) -> u64
fn filter_program_errors_and_collect_fee( &self, txs: &[SanitizedTransaction], execution_results: &[TransactionExecutionResult] ) -> Vec<Result<()>>
sourcepub fn commit_transactions(
&self,
sanitized_txs: &[SanitizedTransaction],
loaded_txs: &mut [TransactionLoadResult],
execution_results: Vec<TransactionExecutionResult>,
last_blockhash: Hash,
lamports_per_signature: u64,
counts: CommitTransactionCounts,
timings: &mut ExecuteTimings
) -> TransactionResults
pub fn commit_transactions( &self, sanitized_txs: &[SanitizedTransaction], loaded_txs: &mut [TransactionLoadResult], execution_results: Vec<TransactionExecutionResult>, last_blockhash: Hash, lamports_per_signature: u64, counts: CommitTransactionCounts, timings: &mut ExecuteTimings ) -> TransactionResults
committed_transactions_count
is the number of transactions out of sanitized_txs
that was executed. Of those, committed_transactions_count
,
committed_with_failure_result_count
is the number of executed transactions that returned
a failure result.
fn distribute_rent_to_validators( &self, vote_accounts: &VoteAccountsHashMap, rent_to_be_distributed: u64 )
fn distribute_rent(&self)
fn collect_rent( &self, execution_results: &[TransactionExecutionResult], loaded_txs: &mut [TransactionLoadResult] ) -> Vec<RentDebits>
fn run_incinerator(&self)
sourcepub(crate) fn get_stake_accounts(&self, minimized_account_set: &DashSet<Pubkey>)
pub(crate) fn get_stake_accounts(&self, minimized_account_set: &DashSet<Pubkey>)
Get stake and stake node accounts
sourcefn get_partition_end_indexes(
partition: &(u64, u64, PartitionsPerCycle)
) -> Vec<u64>
fn get_partition_end_indexes( partition: &(u64, u64, PartitionsPerCycle) ) -> Vec<u64>
return all end partition indexes for the given partition partition could be (0, 1, N). In this case we only return [1] the single ‘end_index’ that covers this partition. partition could be (0, 2, N). In this case, we return [1, 2], which are all the ‘end_index’ values contained in that range. (0, 0, N) returns [0] as a special case. There is a relationship between
- ‘pubkey_range_from_partition’
- ‘partition_from_pubkey’
- this function
fn collect_rent_eagerly(&self)
fn rent_collection_partitions(&self) -> Vec<(u64, u64, PartitionsPerCycle)>
sourcefn bank_hash_skips_rent_rewrites(&self) -> bool
fn bank_hash_skips_rent_rewrites(&self) -> bool
true if rent collection does NOT rewrite accounts whose pubkey indicates it is time for rent collection, but the account is rent exempt. false if rent collection DOES rewrite accounts if the account is rent exempt This is the default behavior historically.
sourcefn collect_rent_from_accounts(
&self,
accounts: Vec<(Pubkey, AccountSharedData, Slot)>,
rent_paying_pubkeys: Option<&HashSet<Pubkey>>,
partition_index: u64
) -> CollectRentFromAccountsInfo
fn collect_rent_from_accounts( &self, accounts: Vec<(Pubkey, AccountSharedData, Slot)>, rent_paying_pubkeys: Option<&HashSet<Pubkey>>, partition_index: u64 ) -> CollectRentFromAccountsInfo
Collect rent from accounts
This fn is called inside a parallel loop from collect_rent_in_partition()
. Avoid adding
any code that causes contention on shared memory/data (i.e. do not update atomic metrics).
The return value is a struct of computed values that collect_rent_in_partition()
will
reduce at the end of its parallel loop. If possible, place data/computation that cause
contention/take locks in the return struct and process them in
collect_rent_from_partition()
after reducing the parallel loop.
sourcefn include_slot_in_hash(&self) -> IncludeSlotInHash
fn include_slot_in_hash(&self) -> IncludeSlotInHash
true if we should include the slot in account hash
sourcefn collect_rent_in_partition(
&self,
partition: (u64, u64, PartitionsPerCycle),
metrics: &RentMetrics
)
fn collect_rent_in_partition( &self, partition: (u64, u64, PartitionsPerCycle), metrics: &RentMetrics )
convert ‘partition’ to a pubkey range and ‘collect_rent_in_range’
sourcefn get_rent_paying_pubkeys(
&self,
partition: &(u64, u64, PartitionsPerCycle)
) -> Option<HashSet<Pubkey>>
fn get_rent_paying_pubkeys( &self, partition: &(u64, u64, PartitionsPerCycle) ) -> Option<HashSet<Pubkey>>
get all pubkeys that we expect to be rent-paying or None, if this was not initialized at load time (that should only exist in test cases)
sourcefn collect_rent_in_range(
&self,
partition: (u64, u64, PartitionsPerCycle),
subrange_full: RangeInclusive<Pubkey>,
metrics: &RentMetrics
)
fn collect_rent_in_range( &self, partition: (u64, u64, PartitionsPerCycle), subrange_full: RangeInclusive<Pubkey>, metrics: &RentMetrics )
load accounts with pubkeys in ‘subrange_full’ collect rent and update ‘account.rent_epoch’ as necessary store accounts, whether rent was collected or not (depending on whether we skipping rewrites is enabled) update bank’s rewrites set for all rewrites that were skipped if ‘just_rewrites’, function will only update bank’s rewrites set and not actually store any accounts. This flag is used when restoring from a snapshot to calculate and verify the initial bank’s delta hash.
sourcefn skip_rewrite(rent_amount: u64, account: &AccountSharedData) -> bool
fn skip_rewrite(rent_amount: u64, account: &AccountSharedData) -> bool
return true iff storing this account is just a rewrite and can be skipped
fn prefix_from_pubkey(pubkey: &Pubkey) -> u64
sourcepub fn partition_from_pubkey(
pubkey: &Pubkey,
partition_count: PartitionsPerCycle
) -> u64
pub fn partition_from_pubkey( pubkey: &Pubkey, partition_count: PartitionsPerCycle ) -> u64
This is the inverse of pubkey_range_from_partition. return the lowest end_index which would contain this pubkey
pub fn pubkey_range_from_partition( (start_index, end_index, partition_count): (u64, u64, PartitionsPerCycle) ) -> RangeInclusive<Pubkey>
pub fn get_partitions( slot: Slot, parent_slot: Slot, slot_count_in_two_day: SlotCount ) -> Vec<(u64, u64, PartitionsPerCycle)>
pub(crate) fn fixed_cycle_partitions_between_slots( &self, starting_slot: Slot, ending_slot: Slot ) -> Vec<(u64, u64, PartitionsPerCycle)>
fn fixed_cycle_partitions(&self) -> Vec<(u64, u64, PartitionsPerCycle)>
sourcepub fn variable_cycle_partition_from_previous_slot(
epoch_schedule: &EpochSchedule,
slot: Slot
) -> (u64, u64, PartitionsPerCycle)
pub fn variable_cycle_partition_from_previous_slot( epoch_schedule: &EpochSchedule, slot: Slot ) -> (u64, u64, PartitionsPerCycle)
used only by filler accounts in debug path previous means slot - 1, not parent
pub(crate) fn variable_cycle_partitions_between_slots( &self, starting_slot: Slot, ending_slot: Slot ) -> Vec<(u64, u64, PartitionsPerCycle)>
fn variable_cycle_partitions(&self) -> Vec<(u64, u64, PartitionsPerCycle)>
fn do_partition_from_slot_indexes( &self, start_slot_index: SlotIndex, end_slot_index: SlotIndex, epoch: Epoch, generated_for_gapped_epochs: bool ) -> (u64, u64, PartitionsPerCycle)
fn get_partition_from_slot_indexes( cycle_params: (Epoch, SlotCount, bool, Epoch, u64, PartitionsPerCycle), start_slot_index: SlotIndex, end_slot_index: SlotIndex, generated_for_gapped_epochs: bool ) -> (u64, u64, PartitionsPerCycle)
fn partition_from_normal_slot_indexes( &self, start_slot_index: SlotIndex, end_slot_index: SlotIndex, epoch: Epoch ) -> (u64, u64, PartitionsPerCycle)
fn partition_from_slot_indexes_with_gapped_epochs( &self, start_slot_index: SlotIndex, end_slot_index: SlotIndex, epoch: Epoch ) -> (u64, u64, PartitionsPerCycle)
fn rent_single_epoch_collection_cycle_params( epoch: Epoch, slot_count_per_epoch: SlotCount ) -> (Epoch, SlotCount, bool, Epoch, u64, PartitionsPerCycle)
fn determine_collection_cycle_params( &self, epoch: Epoch ) -> (Epoch, SlotCount, bool, Epoch, u64, PartitionsPerCycle)
fn partition_index_from_slot_index( slot_index_in_epoch: SlotIndex, (epoch, slot_count_per_epoch, _, base_epoch, epoch_count_per_cycle, _): (Epoch, SlotCount, bool, Epoch, u64, PartitionsPerCycle) ) -> u64
fn use_multi_epoch_collection_cycle(&self, epoch: Epoch) -> bool
pub(crate) fn use_fixed_collection_cycle(&self) -> bool
fn slot_count_in_two_day(&self) -> SlotCount
pub fn slot_count_in_two_day_helper(ticks_per_slot: SlotCount) -> SlotCount
fn slot_count_per_normal_epoch(&self) -> SlotCount
pub fn cluster_type(&self) -> ClusterType
sourcepub fn load_execute_and_commit_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
collect_balances: bool,
enable_cpi_recording: bool,
enable_log_recording: bool,
enable_return_data_recording: bool,
timings: &mut ExecuteTimings,
log_messages_bytes_limit: Option<usize>
) -> (TransactionResults, TransactionBalancesSet)
pub fn load_execute_and_commit_transactions( &self, batch: &TransactionBatch<'_, '_>, max_age: usize, collect_balances: bool, enable_cpi_recording: bool, enable_log_recording: bool, enable_return_data_recording: bool, timings: &mut ExecuteTimings, log_messages_bytes_limit: Option<usize> ) -> (TransactionResults, TransactionBalancesSet)
Process a batch of transactions.
sourcepub fn process_transaction(&self, tx: &Transaction) -> Result<()>
pub fn process_transaction(&self, tx: &Transaction) -> Result<()>
Process a Transaction. This is used for unit tests and simply calls the vector Bank::process_transactions method.
sourcepub fn process_transaction_with_metadata(
&self,
tx: impl Into<VersionedTransaction>
) -> TransactionExecutionResult
pub fn process_transaction_with_metadata( &self, tx: impl Into<VersionedTransaction> ) -> TransactionExecutionResult
Process a Transaction and store metadata. This is used for tests and the banks services. It replicates the vector Bank::process_transaction method with metadata recording enabled.
sourcepub fn process_transactions<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>
) -> Vec<Result<()>>
pub fn process_transactions<'a>( &self, txs: impl Iterator<Item = &'a Transaction> ) -> Vec<Result<()>>
Process multiple transaction in a single batch. This is used for benches and unit tests.
Panics
Panics if any of the transactions do not pass sanitization checks.
sourcepub fn try_process_transactions<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>
) -> Result<Vec<Result<()>>>
pub fn try_process_transactions<'a>( &self, txs: impl Iterator<Item = &'a Transaction> ) -> Result<Vec<Result<()>>>
Process multiple transaction in a single batch. This is used for benches and unit tests. Short circuits if any of the transactions do not pass sanitization checks.
sourcepub fn process_entry_transactions(
&self,
txs: Vec<VersionedTransaction>
) -> Vec<Result<()>>
pub fn process_entry_transactions( &self, txs: Vec<VersionedTransaction> ) -> Vec<Result<()>>
Process entry transactions in a single batch. This is used for benches and unit tests.
Panics
Panics if any of the transactions do not pass sanitization checks.
sourcepub fn try_process_entry_transactions(
&self,
txs: Vec<VersionedTransaction>
) -> Result<Vec<Result<()>>>
pub fn try_process_entry_transactions( &self, txs: Vec<VersionedTransaction> ) -> Result<Vec<Result<()>>>
Process multiple transaction in a single batch. This is used for benches and unit tests. Short circuits if any of the transactions do not pass sanitization checks.
fn process_transaction_batch( &self, batch: &TransactionBatch<'_, '_> ) -> Vec<Result<()>>
sourcepub fn transfer(
&self,
n: u64,
keypair: &Keypair,
to: &Pubkey
) -> Result<Signature>
pub fn transfer( &self, n: u64, keypair: &Keypair, to: &Pubkey ) -> Result<Signature>
Create, sign, and process a Transaction from keypair
to to
of
n
lamports where blockhash
is the last Entry ID observed by the client.
pub fn read_balance(account: &AccountSharedData) -> u64
sourcepub fn get_balance(&self, pubkey: &Pubkey) -> u64
pub fn get_balance(&self, pubkey: &Pubkey) -> u64
Each program would need to be able to introspect its own state this is hard-coded to the Budget language
sourcepub fn parents_inclusive(self: Arc<Self>) -> Vec<Arc<Bank>>
pub fn parents_inclusive(self: Arc<Self>) -> Vec<Arc<Bank>>
Compute all the parents of the bank including this bank itself
pub fn store_account<T: ReadableAccount + Sync + ZeroLamport>( &self, pubkey: &Pubkey, account: &T )
pub fn store_accounts<'a, T: ReadableAccount + Sync + ZeroLamport + 'a>( &self, accounts: impl StorableAccounts<'a, T> )
pub fn force_flush_accounts_cache(&self)
pub fn flush_accounts_cache_if_needed(&self)
pub fn expire_old_recycle_stores(&self)
sourcefn store_account_and_update_capitalization(
&self,
pubkey: &Pubkey,
new_account: &AccountSharedData
)
fn store_account_and_update_capitalization( &self, pubkey: &Pubkey, new_account: &AccountSharedData )
Technically this issues (or even burns!) new lamports, so be extra careful for its usage
fn withdraw(&self, pubkey: &Pubkey, lamports: u64) -> Result<()>
pub fn deposit( &self, pubkey: &Pubkey, lamports: u64 ) -> Result<u64, LamportsError>
pub fn accounts(&self) -> Arc<Accounts>
fn finish_init( &mut self, genesis_config: &GenesisConfig, additional_builtins: Option<&Builtins>, debug_do_not_add_builtins: bool )
pub fn set_inflation(&self, inflation: Inflation)
pub fn hard_forks(&self) -> Arc<RwLock<HardForks>>
pub fn get_account(&self, pubkey: &Pubkey) -> Option<AccountSharedData>
pub fn get_account_with_fixed_root( &self, pubkey: &Pubkey ) -> Option<AccountSharedData>
pub fn get_account_modified_slot( &self, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>
fn load_slow( &self, ancestors: &Ancestors, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>
fn load_slow_with_fixed_root( &self, ancestors: &Ancestors, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>
pub fn get_program_accounts( &self, program_id: &Pubkey, config: &ScanConfig ) -> ScanResult<Vec<TransactionAccount>>
pub fn get_filtered_program_accounts<F: Fn(&AccountSharedData) -> bool>( &self, program_id: &Pubkey, filter: F, config: &ScanConfig ) -> ScanResult<Vec<TransactionAccount>>
pub fn get_filtered_indexed_accounts<F: Fn(&AccountSharedData) -> bool>( &self, index_key: &IndexKey, filter: F, config: &ScanConfig, byte_limit_for_scan: Option<usize> ) -> ScanResult<Vec<TransactionAccount>>
pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool
pub fn get_all_accounts_with_modified_slots( &self ) -> ScanResult<Vec<PubkeyAccountSlot>>
pub fn scan_all_accounts_with_modified_slots<F>( &self, scan_func: F ) -> ScanResult<()>where F: FnMut(Option<(&Pubkey, AccountSharedData, Slot)>),
pub fn get_program_accounts_modified_since_parent( &self, program_id: &Pubkey ) -> Vec<TransactionAccount>
pub fn get_transaction_logs( &self, address: Option<&Pubkey> ) -> Option<Vec<TransactionLogInfo>>
pub fn get_all_accounts_modified_since_parent(&self) -> Vec<TransactionAccount>
fn get_account_modified_since_parent_with_fixed_root( &self, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>
pub fn get_largest_accounts( &self, num: usize, filter_by_address: &HashSet<Pubkey>, filter: AccountAddressFilter ) -> ScanResult<Vec<(Pubkey, u64)>>
sourcepub fn transaction_count(&self) -> u64
pub fn transaction_count(&self) -> u64
Return the accumulated executed transaction count
pub fn non_vote_transaction_count_since_restart(&self) -> u64
sourcepub fn executed_transaction_count(&self) -> u64
pub fn executed_transaction_count(&self) -> u64
Return the transaction count executed only in this bank
pub fn transaction_error_count(&self) -> u64
pub fn transaction_entries_count(&self) -> u64
pub fn transactions_per_entry_max(&self) -> u64
fn increment_transaction_count(&self, tx_count: u64)
fn increment_non_vote_transaction_count_since_restart(&self, tx_count: u64)
pub fn signature_count(&self) -> u64
fn increment_signature_count(&self, signature_count: u64)
pub fn get_signature_status_processed_since_parent( &self, signature: &Signature ) -> Option<Result<()>>
pub fn get_signature_status_with_blockhash( &self, signature: &Signature, blockhash: &Hash ) -> Option<Result<()>>
pub fn get_signature_status_slot( &self, signature: &Signature ) -> Option<(Slot, Result<()>)>
pub fn get_signature_status(&self, signature: &Signature) -> Option<Result<()>>
pub fn has_signature(&self, signature: &Signature) -> bool
sourcefn hash_internal_state(&self) -> Hash
fn hash_internal_state(&self) -> Hash
Hash the accounts
HashMap. This represents a validator’s interpretation
of the delta of the ledger since the last vote and up to now
sourcefn should_include_epoch_accounts_hash(&self) -> bool
fn should_include_epoch_accounts_hash(&self) -> bool
The epoch accounts hash is hashed into the bank’s hash once per epoch at a predefined slot. Should it be included in this bank?
sourcefn wait_get_epoch_accounts_hash(&self) -> EpochAccountsHash
fn wait_get_epoch_accounts_hash(&self) -> EpochAccountsHash
If the epoch accounts hash should be included in this Bank, then fetch it. If the EAH calculation has not completed yet, this fn will block until it does complete.
sourcepub fn verify_accounts_hash(
&self,
base: Option<(Slot, u64)>,
config: VerifyAccountsHashConfig
) -> bool
pub fn verify_accounts_hash( &self, base: Option<(Slot, u64)>, config: VerifyAccountsHashConfig ) -> bool
Recalculate the hash_internal_state from the account stores. Would be used to verify a snapshot. return true if all is good Only called from startup or test code.
sourcepub fn set_initial_accounts_hash_verification_completed(&self)
pub fn set_initial_accounts_hash_verification_completed(&self)
Specify that initial verification has completed. Called internally when verification runs in the foreground thread. Also has to be called by some tests which don’t do verification on startup.
sourcepub fn has_initial_accounts_hash_verification_completed(&self) -> bool
pub fn has_initial_accounts_hash_verification_completed(&self) -> bool
return true if bg hash verification is complete return false if bg hash verification has not completed yet if hash verification failed, a panic will occur
pub fn wait_for_initial_accounts_hash_verification_completed_for_tests(&self)
sourcepub fn get_snapshot_storages(
&self,
base_slot: Option<Slot>
) -> Vec<Arc<AccountStorageEntry>>
pub fn get_snapshot_storages( &self, base_slot: Option<Slot> ) -> Vec<Arc<AccountStorageEntry>>
Get this bank’s storages to use for snapshots.
If a base slot is provided, return only the storages that are higher than this slot.
fn verify_hash(&self) -> bool
pub fn verify_transaction( &self, tx: VersionedTransaction, verification_mode: TransactionVerificationMode ) -> Result<SanitizedTransaction>
pub fn fully_verify_transaction( &self, tx: VersionedTransaction ) -> Result<SanitizedTransaction>
sourcefn calculate_capitalization(&self, debug_verify: bool) -> u64
fn calculate_capitalization(&self, debug_verify: bool) -> u64
only called from ledger-tool or tests
sourcepub fn calculate_and_verify_capitalization(&self, debug_verify: bool) -> bool
pub fn calculate_and_verify_capitalization(&self, debug_verify: bool) -> bool
only called from tests or ledger tool
sourcepub fn set_capitalization(&self) -> u64
pub fn set_capitalization(&self) -> u64
Forcibly overwrites current capitalization by actually recalculating accounts’ balances. This should only be used for developing purposes.
pub fn get_accounts_hash(&self) -> Option<AccountsHash>
pub fn get_incremental_accounts_hash(&self) -> Option<IncrementalAccountsHash>
pub fn get_snapshot_hash(&self) -> SnapshotHash
pub fn get_thread_pool(&self) -> &ThreadPool
pub fn load_account_into_read_cache(&self, key: &Pubkey)
pub fn update_accounts_hash( &self, data_source: CalcAccountsHashDataSource, debug_verify: bool, is_startup: bool ) -> AccountsHash
pub fn update_accounts_hash_for_tests(&self) -> AccountsHash
sourcepub fn update_incremental_accounts_hash(
&self,
base_slot: Slot
) -> IncrementalAccountsHash
pub fn update_incremental_accounts_hash( &self, base_slot: Slot ) -> IncrementalAccountsHash
Calculate the incremental accounts hash from base_slot
to self
sourcepub fn verify_snapshot_bank(
&self,
test_hash_calculation: bool,
accounts_db_skip_shrink: bool,
last_full_snapshot_slot: Slot,
base: Option<(Slot, u64)>
) -> bool
pub fn verify_snapshot_bank( &self, test_hash_calculation: bool, accounts_db_skip_shrink: bool, last_full_snapshot_slot: Slot, base: Option<(Slot, u64)> ) -> bool
A snapshot bank should be purged of 0 lamport accounts which are not part of the hash calculation and could shield other real accounts.
sourcepub fn hashes_per_tick(&self) -> &Option<u64>
pub fn hashes_per_tick(&self) -> &Option<u64>
Return the number of hashes per tick
sourcepub fn ticks_per_slot(&self) -> u64
pub fn ticks_per_slot(&self) -> u64
Return the number of ticks per slot
sourcepub fn slots_per_year(&self) -> f64
pub fn slots_per_year(&self) -> f64
Return the number of slots per year
sourcepub fn tick_height(&self) -> u64
pub fn tick_height(&self) -> u64
Return the number of ticks since genesis.
pub fn rent_collector(&self) -> &RentCollector
sourcepub fn capitalization(&self) -> u64
pub fn capitalization(&self) -> u64
Return the total capitalization of the Bank
sourcepub fn max_tick_height(&self) -> u64
pub fn max_tick_height(&self) -> u64
Return this bank’s max_tick_height
sourcepub fn block_height(&self) -> u64
pub fn block_height(&self) -> u64
Return the block_height of this bank
sourcepub fn get_slots_in_epoch(&self, epoch: Epoch) -> u64
pub fn get_slots_in_epoch(&self, epoch: Epoch) -> u64
Return the number of slots per epoch for the given epoch
sourcepub fn get_leader_schedule_epoch(&self, slot: Slot) -> Epoch
pub fn get_leader_schedule_epoch(&self, slot: Slot) -> Epoch
returns the epoch for which this bank’s leader_schedule_slot_offset and slot would need to cache leader_schedule
sourcefn update_stakes_cache(
&self,
txs: &[SanitizedTransaction],
execution_results: &[TransactionExecutionResult],
loaded_txs: &[TransactionLoadResult]
)
fn update_stakes_cache( &self, txs: &[SanitizedTransaction], execution_results: &[TransactionExecutionResult], loaded_txs: &[TransactionLoadResult] )
a bank-level cache of vote accounts and stake delegation info
pub fn staked_nodes(&self) -> Arc<HashMap<Pubkey, u64>>
sourcepub fn vote_accounts(&self) -> Arc<VoteAccountsHashMap>
pub fn vote_accounts(&self) -> Arc<VoteAccountsHashMap>
current vote accounts for this bank along with the stake attributed to each account
sourcepub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<VoteAccount>
pub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<VoteAccount>
Vote account for the given vote account pubkey.
sourcepub fn epoch_stakes(&self, epoch: Epoch) -> Option<&EpochStakes>
pub fn epoch_stakes(&self, epoch: Epoch) -> Option<&EpochStakes>
Get the EpochStakes for a given epoch
pub fn epoch_stakes_map(&self) -> &HashMap<Epoch, EpochStakes>
pub fn epoch_staked_nodes( &self, epoch: Epoch ) -> Option<Arc<HashMap<Pubkey, u64>>>
sourcepub fn epoch_vote_accounts(&self, epoch: Epoch) -> Option<&VoteAccountsHashMap>
pub fn epoch_vote_accounts(&self, epoch: Epoch) -> Option<&VoteAccountsHashMap>
vote accounts for the specific epoch along with the stake attributed to each account
Get the fixed authorized voter for the given vote account for the current epoch
sourcepub fn epoch_vote_accounts_for_node_id(
&self,
node_id: &Pubkey
) -> Option<&NodeVoteAccounts>
pub fn epoch_vote_accounts_for_node_id( &self, node_id: &Pubkey ) -> Option<&NodeVoteAccounts>
Get the fixed set of vote accounts for the given node id for the current epoch
sourcepub fn total_epoch_stake(&self) -> u64
pub fn total_epoch_stake(&self) -> u64
Get the fixed total stake of all vote accounts for current epoch
sourcepub fn epoch_vote_account_stake(&self, vote_account: &Pubkey) -> u64
pub fn epoch_vote_account_stake(&self, vote_account: &Pubkey) -> u64
Get the fixed stake of the given vote account for the current epoch
sourcepub fn get_epoch_and_slot_index(&self, slot: Slot) -> (Epoch, SlotIndex)
pub fn get_epoch_and_slot_index(&self, slot: Slot) -> (Epoch, SlotIndex)
given a slot, return the epoch and offset into the epoch this slot falls e.g. with a fixed number for slots_per_epoch, the calculation is simply:
( slot/slots_per_epoch, slot % slots_per_epoch )
pub fn get_epoch_info(&self) -> EpochInfo
pub fn is_empty(&self) -> bool
sourcepub fn add_builtin(
&mut self,
name: &str,
program_id: &Pubkey,
process_instruction: ProcessInstructionWithContext
)
pub fn add_builtin( &mut self, name: &str, program_id: &Pubkey, process_instruction: ProcessInstructionWithContext )
Add an instruction processor to intercept instructions before the dynamic loader.
sourcepub fn remove_builtin(&mut self, program_id: &Pubkey)
pub fn remove_builtin(&mut self, program_id: &Pubkey)
Remove a builtin instruction processor if it already exists
pub fn add_precompile(&mut self, program_id: &Pubkey)
pub(crate) fn clean_accounts(&self, last_full_snapshot_slot: Option<Slot>)
pub fn print_accounts_stats(&self)
pub fn shrink_candidate_slots(&self) -> usize
pub fn no_overflow_rent_distribution_enabled(&self) -> bool
pub fn prevent_rent_paying_rent_recipients(&self) -> bool
pub fn versioned_tx_message_enabled(&self) -> bool
pub fn credits_auto_rewind(&self) -> bool
pub fn send_to_tpu_vote_port_enabled(&self) -> bool
pub fn read_cost_tracker(&self) -> LockResult<RwLockReadGuard<'_, CostTracker>>
pub fn write_cost_tracker( &self ) -> LockResult<RwLockWriteGuard<'_, CostTracker>>
pub fn should_bank_still_be_processing_txs( bank_creation_time: &Instant, max_tx_ingestion_nanos: u128 ) -> bool
pub fn deactivate_feature(&mut self, id: &Pubkey)
pub fn activate_feature(&mut self, id: &Pubkey)
pub fn fill_bank_with_ticks_for_tests(&self)
fn apply_feature_activations( &mut self, caller: ApplyFeatureActivationsCaller, debug_do_not_add_builtins: bool )
fn apply_updated_hashes_per_tick(&mut self, hashes_per_tick: u64)
fn adjust_sysvar_balance_for_rent(&self, account: &mut AccountSharedData)
fn compute_active_feature_set( &mut self, allow_new_activations: bool ) -> HashSet<Pubkey>
fn apply_builtin_program_feature_transitions( &mut self, only_apply_transitions_for_new_features: bool, new_feature_activations: &HashSet<Pubkey> )
fn replace_program_account( &mut self, old_address: &Pubkey, new_address: &Pubkey, datapoint_name: &'static str )
fn reconfigure_token2_native_mint(&mut self)
sourcepub fn get_total_accounts_stats(&self) -> ScanResult<TotalAccountsStats>
pub fn get_total_accounts_stats(&self) -> ScanResult<TotalAccountsStats>
Get all the accounts for this bank and calculate stats
sourcepub fn calculate_total_accounts_stats<'a>(
&self,
accounts: impl Iterator<Item = (&'a Pubkey, &'a AccountSharedData)>
) -> TotalAccountsStats
pub fn calculate_total_accounts_stats<'a>( &self, accounts: impl Iterator<Item = (&'a Pubkey, &'a AccountSharedData)> ) -> TotalAccountsStats
Given all the accounts for a bank, calculate stats
sourcepub fn get_epoch_accounts_hash_to_serialize(&self) -> Option<EpochAccountsHash>
pub fn get_epoch_accounts_hash_to_serialize(&self) -> Option<EpochAccountsHash>
Get the EAH that will be used by snapshots
Since snapshots are taken on roots, if the bank is in the EAH calculation window then an EAH must be included. This means if an EAH calculation is currently in-flight we will wait for it to complete.
sourcepub fn epoch_accounts_hash(&self) -> Option<EpochAccountsHash>
pub fn epoch_accounts_hash(&self) -> Option<EpochAccountsHash>
Convenience fn to get the Epoch Accounts Hash
sourcepub fn check_transactions_with_forwarding_delay(
&self,
transactions: &[SanitizedTransaction],
filter: &[Result<()>],
forward_transactions_to_leader_at_slot_offset: u64
) -> Vec<TransactionCheckResult>
pub fn check_transactions_with_forwarding_delay( &self, transactions: &[SanitizedTransaction], filter: &[Result<()>], forward_transactions_to_leader_at_slot_offset: u64 ) -> Vec<TransactionCheckResult>
Checks a batch of sanitized transactions again bank for age and status
Trait Implementations§
source§impl AddressLoader for &Bank
impl AddressLoader for &Bank
fn load_addresses( self, address_table_lookups: &[MessageAddressTableLookup] ) -> Result<LoadedAddresses, AddressLoaderError>
source§impl PartialEq<Bank> for Bank
impl PartialEq<Bank> for Bank
source§impl WorkingSlot for Bank
impl WorkingSlot for Bank
source§fn current_slot(&self) -> Slot
fn current_slot(&self) -> Slot
source§fn is_ancestor(&self, other: Slot) -> bool
fn is_ancestor(&self, other: Slot) -> bool
other
slot is an ancestor of self, false otherwise