Struct solana_runtime::bank::Bank
source · [−]pub struct Bank {Show 14 fields
pub rc: BankRc,
pub src: StatusCacheRc,
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,
pub cost_tracker: RwLock<CostTracker>,
/* private fields */
}
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
src: StatusCacheRc
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>
freeze_started: AtomicBool
cost_tracker: RwLock<CostTracker>
Implementations
pub fn new_with_paths_for_tests(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold,
debug_do_not_add_builtins: bool
) -> Self
pub fn new_with_paths_for_benches(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold,
debug_do_not_add_builtins: bool
) -> Self
pub fn new_with_paths(
genesis_config: &GenesisConfig,
paths: Vec<PathBuf>,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold,
debug_do_not_add_builtins: bool,
accounts_db_config: Option<AccountsDbConfig>,
accounts_update_notifier: Option<AccountsUpdateNotifier>
) -> 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 Fn(&RewardCalculationEvent<'_, '_>) + Send + Sync
) -> 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
pub fn status_cache_ancestors(&self) -> Vec<u64>ⓘ
computed unix_timestamp at this slot height
squash the parent’s state up into this Bank, this Bank becomes a root
Return the more recent checkpoint of this bank instance.
Add a builtin program account
Add a precompiled program account
Return the last block hash registered.
Please use get_fee_for_message
instead
pub fn get_fee_for_message_with_lamports_per_signature(
message: &SanitizedMessage,
lamports_per_signature: u64
) -> u64
Please use get_blockhash_last_valid_block_height
Forget all signatures. Useful for benchmarking.
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
.
Prepare a transaction batch from a list of legacy transactions. Used for tests only.
pub 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.
pub 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.
pub fn prepare_sanitized_batch_with_results<'a, 'b>(
&'a self,
transactions: &'b [SanitizedTransaction],
transaction_results: impl Iterator<Item = Result<()>>
) -> TransactionBatch<'a, 'b>
pub fn prepare_sanitized_batch_with_results<'a, 'b>(
&'a self,
transactions: &'b [SanitizedTransaction],
transaction_results: impl Iterator<Item = Result<()>>
) -> TransactionBatch<'a, 'b>
Prepare a locked transaction batch from a list of sanitized transactions, and their cost limited packing status
pub 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
pub 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
pub fn check_transaction_for_nonce(
&self,
tx: &SanitizedTransaction
) -> Option<(Pubkey, AccountSharedData)>
pub fn check_transactions(
&self,
sanitized_txs: &[SanitizedTransaction],
lock_results: &[Result<()>],
max_age: usize,
error_counters: &mut ErrorCounters
) -> Vec<TransactionCheckResult>ⓘ
pub fn load_lookup_table_addresses(
&self,
address_table_lookups: &[MessageAddressTableLookup]
) -> Result<LoadedAddresses>
pub fn load_and_execute_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
enable_cpi_recording: bool,
enable_log_recording: bool,
timings: &mut ExecuteTimings
) -> (Vec<TransactionLoadResult>, Vec<TransactionExecutionResult>, Vec<usize>, u64, u64)
Calculate fee for SanitizedMessage
pub fn commit_transactions(
&self,
sanitized_txs: &[SanitizedTransaction],
loaded_txs: &mut [TransactionLoadResult],
execution_results: Vec<TransactionExecutionResult>,
tx_count: u64,
signature_count: u64,
timings: &mut ExecuteTimings
) -> TransactionResults
pub fn pubkey_range_from_partition(
(start_index, end_index, partition_count): (u64, u64, u64)
) -> RangeInclusive<Pubkey>
pub fn get_partitions(
slot: Slot,
parent_slot: Slot,
slot_count_in_two_day: SlotCount
) -> Vec<(u64, u64, u64)>ⓘ
used only by filler accounts in debug path previous means slot - 1, not parent
pub fn load_execute_and_commit_transactions(
&self,
batch: &TransactionBatch<'_, '_>,
max_age: usize,
collect_balances: bool,
enable_cpi_recording: bool,
enable_log_recording: bool,
timings: &mut ExecuteTimings
) -> (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,
timings: &mut ExecuteTimings
) -> (TransactionResults, TransactionBalancesSet)
Process a batch of transactions.
Process a Transaction. This is used for unit tests and simply calls the vector Bank::process_transactions method.
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.
pub 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.
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.
pub 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.
Create, sign, and process a Transaction from keypair
to to
of
n
lamports where blockhash
is the last Entry ID observed by the client.
Each program would need to be able to introspect its own state this is hard-coded to the Budget language
Compute all the parents of the bank in order
Compute all the parents of the bank including this bank itself
pub fn get_account_modified_slot(
&self,
pubkey: &Pubkey
) -> Option<(AccountSharedData, Slot)>
pub fn get_program_accounts(
&self,
program_id: &Pubkey,
config: &ScanConfig
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn get_filtered_program_accounts<F: Fn(&AccountSharedData) -> bool>(
&self,
program_id: &Pubkey,
filter: F,
config: &ScanConfig
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
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<(Pubkey, AccountSharedData)>>
pub fn get_all_accounts_with_modified_slots(
&self
) -> ScanResult<Vec<(Pubkey, AccountSharedData, Slot)>>
pub fn get_program_accounts_modified_since_parent(
&self,
program_id: &Pubkey
) -> Vec<(Pubkey, AccountSharedData)>ⓘ
pub fn get_transaction_logs(
&self,
address: Option<&Pubkey>
) -> Option<Vec<TransactionLogInfo>>
pub fn get_all_accounts_modified_since_parent(
&self
) -> Vec<(Pubkey, AccountSharedData)>ⓘ
pub fn get_largest_accounts(
&self,
num: usize,
filter_by_address: &HashSet<Pubkey>,
filter: AccountAddressFilter
) -> ScanResult<Vec<(Pubkey, 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 verify_transaction(
&self,
tx: VersionedTransaction,
verification_mode: TransactionVerificationMode
) -> Result<SanitizedTransaction>
Forcibly overwrites current capitalization by actually recalculating accounts’ balances. This should only be used for developing purposes.
pub fn update_accounts_hash_with_index_option(
&self,
use_index: bool,
debug_verify: bool,
slots_per_epoch: Option<Slot>,
is_startup: bool
) -> Hash
A snapshot bank should be purged of 0 lamport accounts which are not part of the hash calculation and could shield other real accounts.
Return the number of hashes per tick
Return the number of ticks per slot
Return the number of slots per year
Return the number of ticks since genesis.
Return the total capitalization of the Bank
Return this bank’s max_tick_height
Return the block_height of this bank
Return the number of slots per epoch for the given epoch
returns the epoch for which this bank’s leader_schedule_slot_offset and slot would need to cache leader_schedule
current vote accounts for this bank along with the stake attributed to each account
Vote account for the given vote account pubkey along with the stake.
Get the EpochStakes for a given epoch
pub fn epoch_vote_accounts(
&self,
epoch: Epoch
) -> Option<&HashMap<Pubkey, (u64, VoteAccount)>>
pub fn epoch_vote_accounts(
&self,
epoch: Epoch
) -> Option<&HashMap<Pubkey, (u64, VoteAccount)>>
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
Get the fixed set of vote accounts for the given node id for the current epoch
Get the fixed total stake of all vote accounts for current epoch
Get the fixed stake of the given vote account for the current epoch
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 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.
pub fn replace_builtin(
&mut self,
name: &str,
program_id: &Pubkey,
process_instruction: ProcessInstructionWithContext
)
pub fn replace_builtin(
&mut self,
name: &str,
program_id: &Pubkey,
process_instruction: ProcessInstructionWithContext
)
Replace a builtin instruction processor if it already exists
Remove a builtin instruction processor if it already exists
pub fn clean_accounts(
&self,
skip_last: bool,
is_startup: bool,
last_full_snapshot_slot: Option<Slot>
)
pub fn process_stale_slot_with_budget(
&self,
consumed_budget: usize,
budget_recovery_delta: usize
) -> usize
pub fn should_bank_still_be_processing_txs(
bank_creation_time: &Instant,
max_tx_ingestion_nanos: u128
) -> bool
Get all the accounts for this bank and calculate stats
pub 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
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Bank
impl !UnwindSafe for Bank
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more