solana_runtime::bank

Struct Bank

Source
pub struct Bank {
Show 13 fields pub rc: BankRc, pub status_cache: Arc<RwLock<BankStatusCache>>, pub ancestors: Ancestors, pub ns_per_slot: u128, pub rewards: RwLock<Vec<(Pubkey, RewardInfo)>>, pub cluster_type: Option<ClusterType>, pub lazy_rent_collection: AtomicBool, pub rewards_pool_pubkeys: 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, /* private fields */
}
Expand description

Manager for the state of all accounts and programs after processing its entries.

Fields§

§rc: BankRc

References to accounts, parent and signature status

§status_cache: Arc<RwLock<BankStatusCache>>

A cache of signature statuses

§ancestors: Ancestors

The set of parents including this bank

§ns_per_slot: u128

length of a slot in ns

§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>>§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

Implementations§

Source§

impl Bank

Source

pub fn is_accounts_lt_hash_enabled(&self) -> bool

Returns if the accounts lt hash is enabled

Source

pub fn update_accounts_lt_hash(&self)

Updates the accounts lt hash

When freezing a bank, we compute and update the accounts lt hash. For each account modified in this bank, we:

  • mix out its previous state, and
  • mix in its current state

Since this function is non-idempotent, it should only be called once per bank.

Source

pub fn inspect_account_for_accounts_lt_hash( &self, address: &Pubkey, account_state: &AccountState<'_>, is_writable: bool, )

Caches initial state of writeable accounts

If a transaction account is writeable, cache its initial account state. The initial state is needed when computing the accounts lt hash for the slot, and caching the initial state saves us from having to look it up on disk later.

Source§

impl Bank

Source

pub fn load_addresses_from_ref<'a>( &self, address_table_lookups: impl Iterator<Item = SVMMessageAddressTableLookup<'a>>, ) -> Result<(LoadedAddresses, Slot), AddressLoaderError>

Load addresses from an iterator of SVMMessageAddressTableLookup, additionally returning the minimum deactivation slot across all referenced ALTs

Source§

impl Bank

Source

pub fn check_transactions_with_forwarding_delay( &self, transactions: &[SanitizedTransaction], filter: &[TransactionResult<()>], forward_transactions_to_leader_at_slot_offset: u64, ) -> Vec<TransactionCheckResult>

Checks a batch of sanitized transactions again bank for age and status

Source

pub fn check_transactions( &self, sanitized_txs: &[impl Borrow<SanitizedTransaction>], lock_results: &[TransactionResult<()>], max_age: usize, error_counters: &mut TransactionErrorMetrics, ) -> Vec<TransactionCheckResult>

Source§

impl Bank

Source

pub fn calculate_reward_for_transaction( &self, transaction: &SanitizedTransaction, fee_budget_limits: &FeeBudgetLimits, ) -> u64

Source§

impl Bank

Source§

impl Bank

Source

pub fn new_with_paths( genesis_config: &GenesisConfig, runtime_config: Arc<RuntimeConfig>, paths: Vec<PathBuf>, debug_keys: Option<Arc<HashSet<Pubkey>>>, additional_builtins: Option<&[BuiltinPrototype]>, debug_do_not_add_builtins: bool, accounts_db_config: Option<AccountsDbConfig>, accounts_update_notifier: Option<AccountsUpdateNotifier>, collector_id_for_tests: Option<Pubkey>, exit: Arc<AtomicBool>, genesis_hash: Option<Hash>, feature_set: Option<FeatureSet>, ) -> Self

Source

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.

Source

pub fn new_from_parent_with_options( parent: Arc<Bank>, collector_id: &Pubkey, slot: Slot, new_bank_options: NewBankOptions, ) -> Self

Source

pub fn new_from_parent_with_tracer( parent: Arc<Bank>, collector_id: &Pubkey, slot: Slot, reward_calc_tracer: impl RewardCalcTracer, ) -> Self

Source

pub fn set_fork_graph_in_program_cache( &self, fork_graph: Weak<RwLock<BankForks>>, )

Source

pub fn prune_program_cache(&self, new_root_slot: Slot, new_root_epoch: Epoch)

Source

pub fn prune_program_cache_by_deployment_slot(&self, deployment_slot: Slot)

Source

pub fn new_warmup_cooldown_rate_epoch(&self) -> Option<Epoch>

Epoch in which the new cooldown warmup rate for stake was activated

Source

pub fn byte_limit_for_scans(&self) -> Option<usize>

Source

pub fn proper_ancestors_set(&self) -> HashSet<Slot>

Source

pub fn set_callback( &self, callback: Option<Box<dyn DropCallback + Send + Sync>>, )

Source

pub fn vote_only_bank(&self) -> bool

Source

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
Source

pub fn collector_id(&self) -> &Pubkey

Source

pub fn genesis_creation_time(&self) -> UnixTimestamp

Source

pub fn slot(&self) -> Slot

Source

pub fn bank_id(&self) -> BankId

Source

pub fn epoch(&self) -> Epoch

Source

pub fn first_normal_epoch(&self) -> Epoch

Source

pub fn freeze_lock(&self) -> RwLockReadGuard<'_, Hash>

Source

pub fn hash(&self) -> Hash

Source

pub fn is_frozen(&self) -> bool

Source

pub fn freeze_started(&self) -> bool

Source

pub fn status_cache_ancestors(&self) -> Vec<u64>

Source

pub fn unix_timestamp_from_genesis(&self) -> i64

computed unix_timestamp at this slot height

Source

pub fn clock(&self) -> Clock

Source

pub fn update_last_restart_slot(&self)

Source

pub fn set_sysvar_for_tests<T>(&self, sysvar: &T)
where T: Sysvar + SysvarId,

Source

pub fn get_slot_history(&self) -> SlotHistory

Source

pub fn epoch_duration_in_years(&self, prev_epoch: Epoch) -> f64

Source

pub fn slot_in_year_for_inflation(&self) -> f64

Source

pub fn update_recent_blockhashes(&self)

Source

pub fn rehash(&self)

Recalculates the bank hash

This is used by ledger-tool when creating a snapshot, which recalcuates the bank hash.

Note that the account state is not allowed to change by rehashing. If it does, this function will panic. If modifying accounts in ledger-tool is needed, create a new bank.

Source

pub fn freeze(&self)

Source

pub fn epoch_schedule(&self) -> &EpochSchedule

Source

pub fn squash(&self) -> SquashTiming

squash the parent’s state up into this Bank, this Bank becomes a root Note that this function is not thread-safe. If it is called concurrently on the same bank by multiple threads, the end result could be inconsistent. Calling code does not currently call this concurrently.

Source

pub fn parent(&self) -> Option<Arc<Bank>>

Return the more recent checkpoint of this bank instance.

Source

pub fn parent_slot(&self) -> Slot

Source

pub fn parent_hash(&self) -> Hash

Source

pub fn add_precompiled_account(&self, program_id: &Pubkey)

Add a precompiled program account

Source

pub fn set_rent_burn_percentage(&mut self, burn_percent: u8)

Source

pub fn set_hashes_per_tick(&mut self, hashes_per_tick: Option<u64>)

Source

pub fn last_blockhash(&self) -> Hash

Return the last block hash registered.

Source

pub fn last_blockhash_and_lamports_per_signature(&self) -> (Hash, u64)

Source

pub fn is_blockhash_valid(&self, hash: &Hash) -> bool

Source

pub fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> u64

Source

pub fn get_lamports_per_signature(&self) -> u64

Source

pub fn get_lamports_per_signature_for_blockhash( &self, hash: &Hash, ) -> Option<u64>

Source

pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> Option<u64>

Source

pub fn get_startup_verification_complete(&self) -> &Arc<AtomicBool>

Returns true when startup accounts hash verification has completed or never had to run in background.

Source

pub fn is_startup_verification_complete(&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

Source

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.

Source

pub fn get_fee_for_message_with_lamports_per_signature( &self, message: &impl SVMMessage, lamports_per_signature: u64, ) -> u64

Source

pub fn get_blockhash_last_valid_block_height( &self, blockhash: &Hash, ) -> Option<Slot>

Source

pub fn confirmed_last_blockhash(&self) -> Hash

Source

pub fn clear_signatures(&self)

Forget all signatures. Useful for benchmarking.

Source

pub fn clear_slot_signatures(&self, slot: Slot)

Source

pub fn register_unique_recent_blockhash_for_test(&self)

Source

pub fn register_tick(&self, hash: &Hash, scheduler: &InstalledSchedulerRwLock)

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.

Source

pub fn is_complete(&self) -> bool

Source

pub fn is_block_boundary(&self, tick_height: u64) -> bool

Source

pub fn get_transaction_account_lock_limit(&self) -> usize

Get the max number of accounts that a transaction may lock in this block

Source

pub fn prepare_entry_batch( &self, txs: Vec<VersionedTransaction>, ) -> Result<TransactionBatch<'_, '_, SanitizedTransaction>>

Prepare a transaction batch from a list of versioned transactions from an entry. Used for tests only.

Source

pub fn try_lock_accounts(&self, txs: &[SanitizedTransaction]) -> Vec<Result<()>>

Attempt to take locks on the accounts in a transaction batch

Source

pub fn prepare_sanitized_batch<'a, 'b>( &'a self, txs: &'b [SanitizedTransaction], ) -> TransactionBatch<'a, 'b, SanitizedTransaction>

Prepare a locked transaction batch from a list of sanitized transactions.

Source

pub fn prepare_sanitized_batch_with_results<'a, 'b>( &'a self, transactions: &'b [SanitizedTransaction], transaction_results: impl Iterator<Item = Result<()>>, ) -> TransactionBatch<'a, 'b, SanitizedTransaction>

Prepare a locked transaction batch from a list of sanitized transactions, and their cost limited packing status

Source

pub fn prepare_unlocked_batch_from_single_tx<'a>( &'a self, transaction: &'a SanitizedTransaction, ) -> TransactionBatch<'_, '_, SanitizedTransaction>

Prepare a transaction batch from a single transaction without locking accounts

Source

pub fn simulate_transaction( &self, transaction: &SanitizedTransaction, enable_cpi_recording: bool, ) -> TransactionSimulationResult

Run transactions against a frozen bank without committing the results

Source

pub fn simulate_transaction_unchecked( &self, transaction: &SanitizedTransaction, enable_cpi_recording: bool, ) -> 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

Source

pub fn unlock_accounts<'a, Tx: SVMMessage + 'a>( &self, txs_and_results: impl Iterator<Item = (&'a Tx, &'a Result<()>)> + Clone, )

Source

pub fn remove_unrooted_slots(&self, slots: &[(Slot, BankId)])

Source

pub fn get_hash_age(&self, hash: &Hash) -> Option<u64>

Source

pub fn is_hash_valid_for_age(&self, hash: &Hash, max_age: usize) -> bool

Source

pub fn collect_balances( &self, batch: &TransactionBatch<'_, '_, impl SVMMessage>, ) -> TransactionBalances

Source

pub fn load_and_execute_transactions( &self, batch: &TransactionBatch<'_, '_, SanitizedTransaction>, max_age: usize, timings: &mut ExecuteTimings, error_counters: &mut TransactionErrorMetrics, processing_config: TransactionProcessingConfig<'_>, ) -> LoadAndExecuteTransactionsOutput

Source

pub fn load_accounts_data_size(&self) -> u64

Load the accounts data size, in bytes

Source

pub fn load_accounts_data_size_delta(&self) -> i64

Load the change in accounts data size in this Bank, in bytes

Source

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

Source

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

Source

pub fn commit_transactions( &self, sanitized_txs: &[SanitizedTransaction], processing_results: Vec<TransactionProcessingResult>, processed_counts: &ProcessedTransactionCounts, timings: &mut ExecuteTimings, ) -> Vec<TransactionCommitResult>

Source

pub fn slot_count_in_two_day_helper(ticks_per_slot: SlotCount) -> SlotCount

Source

pub fn cluster_type(&self) -> ClusterType

Source

pub fn load_execute_and_commit_transactions( &self, batch: &TransactionBatch<'_, '_, SanitizedTransaction>, max_age: usize, collect_balances: bool, recording_config: ExecutionRecordingConfig, timings: &mut ExecuteTimings, log_messages_bytes_limit: Option<usize>, ) -> (Vec<TransactionCommitResult>, TransactionBalancesSet)

Process a batch of transactions.

Source

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.

Source

pub fn process_transaction_with_metadata( &self, tx: impl Into<VersionedTransaction>, ) -> Result<CommittedTransaction>

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.

Source

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.

Source

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.

Source

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.

Source

pub fn read_balance(account: &AccountSharedData) -> u64

Source

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

Source

pub fn parents(&self) -> Vec<Arc<Bank>>

Compute all the parents of the bank in order

Source

pub fn parents_inclusive(self: Arc<Self>) -> Vec<Arc<Bank>>

Compute all the parents of the bank including this bank itself

Source

pub fn store_account(&self, pubkey: &Pubkey, account: &AccountSharedData)

fn store the single account with pubkey. Uses store_accounts, which works on a vector of accounts.

Source

pub fn store_accounts<'a>(&self, accounts: impl StorableAccounts<'a>)

Source

pub fn force_flush_accounts_cache(&self)

Source

pub fn flush_accounts_cache_if_needed(&self)

Source

pub fn accounts(&self) -> Arc<Accounts>

Source

pub fn set_inflation(&self, inflation: Inflation)

Source

pub fn hard_forks(&self) -> HardForks

Get a snapshot of the current set of hard forks

Source

pub fn register_hard_fork(&self, new_hard_fork_slot: Slot)

Source

pub fn get_account_with_fixed_root_no_cache( &self, pubkey: &Pubkey, ) -> Option<AccountSharedData>

Source

pub fn get_account(&self, pubkey: &Pubkey) -> Option<AccountSharedData>

Source

pub fn get_account_with_fixed_root( &self, pubkey: &Pubkey, ) -> Option<AccountSharedData>

Source

pub fn get_account_modified_slot_with_fixed_root( &self, pubkey: &Pubkey, ) -> Option<(AccountSharedData, Slot)>

Source

pub fn get_account_modified_slot( &self, pubkey: &Pubkey, ) -> Option<(AccountSharedData, Slot)>

Source

pub fn get_program_accounts( &self, program_id: &Pubkey, config: &ScanConfig, ) -> ScanResult<Vec<TransactionAccount>>

Source

pub fn get_filtered_program_accounts<F: Fn(&AccountSharedData) -> bool>( &self, program_id: &Pubkey, filter: F, config: &ScanConfig, ) -> ScanResult<Vec<TransactionAccount>>

Source

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>>

Source

pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool

Source

pub fn get_all_accounts( &self, sort_results: bool, ) -> ScanResult<Vec<PubkeyAccountSlot>>

Returns all the accounts this bank can load

Source

pub fn scan_all_accounts<F>( &self, scan_func: F, sort_results: bool, ) -> ScanResult<()>

Source

pub fn get_program_accounts_modified_since_parent( &self, program_id: &Pubkey, ) -> Vec<TransactionAccount>

Source

pub fn get_transaction_logs( &self, address: Option<&Pubkey>, ) -> Option<Vec<TransactionLogInfo>>

Source

pub fn get_all_accounts_modified_since_parent(&self) -> Vec<TransactionAccount>

Returns all the accounts stored in this slot

Source

pub fn get_largest_accounts( &self, num: usize, filter_by_address: &HashSet<Pubkey>, filter: AccountAddressFilter, sort_results: bool, ) -> ScanResult<Vec<(Pubkey, u64)>>

Source

pub fn transaction_count(&self) -> u64

Return the accumulated executed transaction count

Source

pub fn non_vote_transaction_count_since_restart(&self) -> u64

Returns 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.

Source

pub fn executed_transaction_count(&self) -> u64

Return the transaction count executed only in this bank

Source

pub fn transaction_error_count(&self) -> u64

Source

pub fn transaction_entries_count(&self) -> u64

Source

pub fn transactions_per_entry_max(&self) -> u64

Source

pub fn signature_count(&self) -> u64

Source

pub fn get_signature_status_processed_since_parent( &self, signature: &Signature, ) -> Option<Result<()>>

Source

pub fn get_signature_status_with_blockhash( &self, signature: &Signature, blockhash: &Hash, ) -> Option<Result<()>>

Source

pub fn get_signature_status_slot( &self, signature: &Signature, ) -> Option<(Slot, Result<()>)>

Source

pub fn get_signature_status(&self, signature: &Signature) -> Option<Result<()>>

Source

pub fn has_signature(&self, signature: &Signature) -> bool

Source

pub fn run_final_hash_calc(&self, on_halt_store_hash_raw_data_for_debug: bool)

Used by ledger tool to run a final hash calculation once all ledger replay has completed. This should not be called by validator code.

Source

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.

Source

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

Source

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.

Source

pub fn verify_transaction( &self, tx: VersionedTransaction, verification_mode: TransactionVerificationMode, ) -> Result<SanitizedTransaction>

Source

pub fn fully_verify_transaction( &self, tx: VersionedTransaction, ) -> Result<SanitizedTransaction>

Source

pub fn check_reserved_keys(&self, tx: &impl SVMMessage) -> Result<()>

Checks if the transaction violates the bank’s reserved keys. This needs to be checked upon epoch boundary crosses because the reserved key set may have changed since the initial sanitization.

Source

pub fn calculate_and_verify_capitalization(&self, debug_verify: bool) -> bool

only called from tests or ledger tool

Source

pub fn set_capitalization(&self) -> u64

Forcibly overwrites current capitalization by actually recalculating accounts’ balances. This should only be used for developing purposes.

Source

pub fn get_accounts_hash(&self) -> Option<AccountsHash>

Returns the AccountsHash that was calculated for this bank’s slot

This fn is used when creating a snapshot with ledger-tool, or when packaging a snapshot into an archive (used to get the SnapshotHash).

Source

pub fn get_incremental_accounts_hash(&self) -> Option<IncrementalAccountsHash>

Returns the IncrementalAccountsHash that was calculated for this bank’s slot

This fn is used when creating an incremental snapshot with ledger-tool, or when packaging a snapshot into an archive (used to get the SnapshotHash).

Source

pub fn get_snapshot_hash(&self) -> SnapshotHash

Returns the SnapshotHash for this bank’s slot

This fn is used at startup to verify the bank was rebuilt correctly.

§Panics

Panics if there is both-or-neither of an AccountsHash and an IncrementalAccountsHash for this bank’s slot. There may only be one or the other.

Source

pub fn load_account_into_read_cache(&self, key: &Pubkey)

Source

pub fn update_accounts_hash( &self, data_source: CalcAccountsHashDataSource, debug_verify: bool, is_startup: bool, ) -> AccountsHash

Source

pub fn update_incremental_accounts_hash( &self, base_slot: Slot, ) -> IncrementalAccountsHash

Calculate the incremental accounts hash from base_slot to self

Source

pub fn verify_snapshot_bank( &self, test_hash_calculation: bool, skip_shrink: bool, force_clean: bool, latest_full_snapshot_slot: Slot, base: Option<(Slot, u64)>, duplicates_lt_hash: Option<Box<DuplicatesLtHash>>, ) -> 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.

Source

pub fn hashes_per_tick(&self) -> &Option<u64>

Return the number of hashes per tick

Source

pub fn ticks_per_slot(&self) -> u64

Return the number of ticks per slot

Source

pub fn slots_per_year(&self) -> f64

Return the number of slots per year

Source

pub fn tick_height(&self) -> u64

Return the number of ticks since genesis.

Source

pub fn inflation(&self) -> Inflation

Return the inflation parameters of the Bank

Source

pub fn rent_collector(&self) -> &RentCollector

Return the rent collector for this Bank

Source

pub fn capitalization(&self) -> u64

Return the total capitalization of the Bank

Source

pub fn max_tick_height(&self) -> u64

Return this bank’s max_tick_height

Source

pub fn block_height(&self) -> u64

Return the block_height of this bank

Source

pub fn get_slots_in_epoch(&self, epoch: Epoch) -> u64

Return the number of slots per epoch for the given epoch

Source

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

Source

pub fn vote_accounts(&self) -> Arc<VoteAccountsHashMap>

current vote accounts for this bank along with the stake attributed to each account

Source

pub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<VoteAccount>

Vote account for the given vote account pubkey.

Source

pub fn current_epoch_stakes(&self) -> &EpochStakes

Get the EpochStakes for the current Bank::epoch

Source

pub fn epoch_stakes(&self, epoch: Epoch) -> Option<&EpochStakes>

Get the EpochStakes for a given epoch

Source

pub fn epoch_stakes_map(&self) -> &HashMap<Epoch, EpochStakes>

Source

pub fn current_epoch_staked_nodes(&self) -> Arc<HashMap<Pubkey, u64>>

Get the staked nodes map for the current Bank::epoch

Source

pub fn epoch_staked_nodes( &self, epoch: Epoch, ) -> Option<Arc<HashMap<Pubkey, u64>>>

Source

pub fn epoch_total_stake(&self, epoch: Epoch) -> Option<u64>

Get the total epoch stake for the given epoch.

Source

pub fn get_current_epoch_total_stake(&self) -> u64

Get the total epoch stake for the current Bank::epoch

Source

pub fn epoch_vote_accounts(&self, epoch: Epoch) -> Option<&VoteAccountsHashMap>

vote accounts for the specific epoch along with the stake attributed to each account

Source

pub fn get_current_epoch_vote_accounts(&self) -> &VoteAccountsHashMap

Get the vote accounts along with the stake attributed to each account for the current Bank::epoch

Source

pub fn epoch_authorized_voter(&self, vote_account: &Pubkey) -> Option<&Pubkey>

Get the fixed authorized voter for the given vote account for the current epoch

Source

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

Source

pub fn epoch_node_id_to_stake( &self, epoch: Epoch, node_id: &Pubkey, ) -> Option<u64>

Get the total stake belonging to vote accounts associated with the given node id for the given epoch.

Source

pub fn total_epoch_stake(&self) -> u64

Get the fixed total stake of all vote accounts for current epoch

Source

pub fn epoch_vote_account_stake(&self, vote_account: &Pubkey) -> u64

Get the fixed stake of the given vote account for the current epoch

Source

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 )

Source

pub fn get_epoch_info(&self) -> EpochInfo

Source

pub fn is_empty(&self) -> bool

Source

pub fn add_mockup_builtin( &mut self, program_id: Pubkey, builtin_function: BuiltinFunctionWithContext, )

Source

pub fn add_precompile(&mut self, program_id: &Pubkey)

Source

pub fn print_accounts_stats(&self)

Source

pub fn shrink_candidate_slots(&self) -> usize

Source

pub fn are_ancient_storages_enabled(&self) -> bool

Returns if ancient storages are enabled or not

Source

pub fn read_cost_tracker(&self) -> LockResult<RwLockReadGuard<'_, CostTracker>>

Source

pub fn write_cost_tracker( &self, ) -> LockResult<RwLockWriteGuard<'_, CostTracker>>

Source

pub fn should_bank_still_be_processing_txs( bank_creation_time: &Instant, max_tx_ingestion_nanos: u128, ) -> bool

Source

pub fn deactivate_feature(&mut self, id: &Pubkey)

Source

pub fn activate_feature(&mut self, id: &Pubkey)

Source

pub fn fill_bank_with_ticks_for_tests(&self)

Source

pub fn get_reserved_account_keys(&self) -> &HashSet<Pubkey>

Get a set of all actively reserved account keys that are not allowed to be write-locked during transaction processing.

Source

pub fn get_total_accounts_stats(&self) -> ScanResult<TotalAccountsStats>

Get all the accounts for this bank and calculate stats

Source

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

Source

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.

Source

pub fn epoch_accounts_hash(&self) -> Option<EpochAccountsHash>

Convenience fn to get the Epoch Accounts Hash

Source

pub fn is_in_slot_hashes_history(&self, slot: &Slot) -> bool

Source

pub fn check_program_modification_slot(&self) -> bool

Source

pub fn set_check_program_modification_slot(&mut self, check: bool)

Source

pub fn fee_structure(&self) -> &FeeStructure

Source

pub fn block_id(&self) -> Option<Hash>

Source

pub fn set_block_id(&self, block_id: Option<Hash>)

Source

pub fn compute_budget(&self) -> Option<ComputeBudget>

Source

pub fn add_builtin( &self, program_id: Pubkey, name: &str, builtin: ProgramCacheEntry, )

Trait Implementations§

Source§

impl AddressLoader for &Bank

Source§

impl Debug for Bank

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Bank

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl TransactionProcessingCallback for Bank

Source§

fn add_builtin_account(&self, name: &str, program_id: &Pubkey)

Add a builtin program account

Source§

fn account_matches_owners( &self, account: &Pubkey, owners: &[Pubkey], ) -> Option<usize>

Source§

fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<AccountSharedData>

Source§

fn inspect_account( &self, address: &Pubkey, account_state: AccountState<'_>, is_writable: bool, )

Auto Trait Implementations§

§

impl !Freeze for Bank

§

impl !RefUnwindSafe for Bank

§

impl Send for Bank

§

impl Sync for Bank

§

impl Unpin for Bank

§

impl !UnwindSafe for Bank

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T