solana_runtime

Module bank

Source
Expand description

The bank module tracks client accounts and the progress of on-chain programs.

A single bank relates to a block produced by a single leader and each bank except for the genesis bank points back to a parent bank.

The bank is the main entrypoint for processing verified transactions with the function Bank::process_transactions

It does this by loading the accounts using the reference it holds on the account store, and then passing those to an InvokeContext which handles loading the programs specified by the Transaction and executing it.

The bank then stores the results to the accounts store.

It then has APIs for retrieving if a transaction has been processed and it’s status. See get_signature_status et al.

Bank lifecycle:

A bank is newly created and open to transactions. Transactions are applied until either the bank reached the tick count when the node is the leader for that slot, or the node has applied all transactions present in all Entrys in the slot.

Once it is complete, the bank can then be frozen. After frozen, no more transactions can be applied or state changes made. At the frozen step, rent will be applied and various sysvar special accounts update to the new state of the system.

After frozen, and the bank has had the appropriate number of votes on it, then it can become rooted. At this point, it will not be able to be removed from the chain and the state is finalized.

It offers a high-level API that signs transactions on behalf of the caller, and a low-level API for when they have already been signed and verified.

Modules§

bank_hash_details
Container to capture information relevant to computing a bank hash
builtins
epoch_accounts_hash_utils
Utility functions and types for Epoch Accounts Hash
test_utils
utility function used for testing and benchmarking.

Structs§

Bank
Manager for the state of all accounts and programs after processing its entries.
BankFieldsToDeserialize
Bank’s common fields shared by all supported snapshot versions for deserialization. Sync fields with BankFieldsToSerialize! This is paired with it. All members are made public to remain Bank’s members private and to make versioned deserializer workable on this Note that some fields are missing from the serializer struct. This is because of fields added later. Since it is difficult to insert fields to serialize/deserialize against existing code already deployed, new fields can be optionally serialized and optionally deserialized. At some point, the serialization and deserialization will use a new mechanism or otherwise be in sync more clearly.
BankFieldsToSerialize
Bank’s common fields shared by all supported snapshot versions for serialization. This was separated from BankFieldsToDeserialize to avoid cloning by using refs. So, sync fields with BankFieldsToDeserialize! all members are made public to keep Bank private and to make versioned serializer workable on this. Note that some fields are missing from the serializer struct. This is because of fields added later. Since it is difficult to insert fields to serialize/deserialize against existing code already deployed, new fields can be optionally serialized and optionally deserialized. At some point, the serialization and deserialization will use a new mechanism or otherwise be in sync more clearly.
BankRc
KeyedRewardsAndNumPartitions
LoadAndExecuteTransactionsOutput
NewBankOptions
OptionalDropCallback
ProcessedTransactionCounts
SquashTiming
TotalAccountsStats
Struct to collect stats when scanning all accounts in get_total_accounts_stats()
TransactionBalancesSet
TransactionLogCollector
TransactionLogCollectorConfig
TransactionLogInfo
TransactionSimulationResult

Enums§

RewardCalculationEvent
RewardType
TransactionLogCollectorFilter

Constants§

MAX_LEADER_SCHEDULE_STAKES
SECONDS_PER_YEAR

Traits§

DropCallback
RewardCalcTracer
type alias is not supported for trait in rust yet. As a workaround, we define the RewardCalcTracer trait explicitly and implement it on any type that implement Fn(&RewardCalculationEvent) + Send + Sync.

Type Aliases§

BankSlotDelta
BankStatusCache
TransactionBalances