55
55
56
56
int
57
57
fd_runtime_should_use_vote_keyed_leader_schedule ( fd_bank_t * bank ) {
58
- /* Agave uses an option type for their ` effective_epoch` value. We represent None
59
- as ULONG_MAX and Some(value) as the value.
58
+ /* Agave uses an option type for their effective_epoch value. We
59
+ represent None as ULONG_MAX and Some(value) as the value.
60
60
https://github.com/anza-xyz/agave/blob/v2.3.1/runtime/src/bank.rs#L6149-L6165 */
61
61
if ( FD_FEATURE_ACTIVE_BANK ( bank , enable_vote_address_leader_schedule ) ) {
62
62
/* Return the first epoch if activated at genesis
@@ -69,7 +69,8 @@ fd_runtime_should_use_vote_keyed_leader_schedule( fd_bank_t * bank ) {
69
69
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query ( bank );
70
70
ulong activation_epoch = fd_slot_to_epoch ( epoch_schedule , activation_slot , NULL );
71
71
72
- /* The effective epoch is the epoch immediately after the activation epoch
72
+ /* The effective epoch is the epoch immediately after the activation
73
+ epoch.
73
74
https://github.com/anza-xyz/agave/blob/v2.3.1/runtime/src/bank.rs#L6162-L6164 */
74
75
ulong effective_epoch = activation_epoch + 1UL ;
75
76
ulong current_epoch = fd_bank_epoch_get ( bank );
@@ -78,8 +79,8 @@ fd_runtime_should_use_vote_keyed_leader_schedule( fd_bank_t * bank ) {
78
79
return !!( current_epoch >= effective_epoch );
79
80
}
80
81
81
- /* ...The rest of the logic in this function either returns ` None` or `Some(false)` so we
82
- will just return 0 by default. */
82
+ /* ...The rest of the logic in this function either returns None or
83
+ Some(false) so we will just return 0 by default. */
83
84
return 0 ;
84
85
}
85
86
@@ -1106,24 +1107,26 @@ fd_runtime_pre_execute_check( fd_txn_p_t * txn, fd_exec_txn_ctx_t * txn_ctx ) {
1106
1107
/* Set up the transaction accounts and other txn ctx metadata */
1107
1108
fd_executor_setup_accounts_for_txn ( txn_ctx );
1108
1109
1109
- /* Post-sanitization checks. Called from `prepare_sanitized_batch()` which, for now, only is used
1110
- to lock the accounts and perform a couple basic validations.
1110
+ /* Post-sanitization checks. Called from prepare_sanitized_batch()
1111
+ which, for now, only is used to lock the accounts and perform a
1112
+ couple basic validations.
1111
1113
https://github.com/anza-xyz/agave/blob/838c1952595809a31520ff1603a13f2c9123aa51/accounts-db/src/account_locks.rs#L118 */
1112
1114
err = fd_executor_validate_account_locks ( txn_ctx );
1113
1115
if ( FD_UNLIKELY ( err != FD_RUNTIME_EXECUTE_SUCCESS ) ) {
1114
1116
txn -> flags = 0U ;
1115
1117
return err ;
1116
1118
}
1117
1119
1118
- /* ` load_and_execute_transactions()` -> ` check_transactions()`
1120
+ /* load_and_execute_transactions() -> check_transactions()
1119
1121
https://github.com/anza-xyz/agave/blob/ced98f1ebe73f7e9691308afa757323003ff744f/runtime/src/bank.rs#L3667-L3672 */
1120
1122
err = fd_executor_check_transactions ( txn_ctx );
1121
1123
if ( FD_UNLIKELY ( err != FD_RUNTIME_EXECUTE_SUCCESS ) ) {
1122
1124
txn -> flags = 0U ;
1123
1125
return err ;
1124
1126
}
1125
1127
1126
- /* `load_and_execute_sanitized_transactions()` -> `validate_fees()` -> `validate_transaction_fee_payer()`
1128
+ /* load_and_execute_sanitized_transactions() -> validate_fees() ->
1129
+ validate_transaction_fee_payer()
1127
1130
https://github.com/anza-xyz/agave/blob/ced98f1ebe73f7e9691308afa757323003ff744f/svm/src/transaction_processor.rs#L236-L249 */
1128
1131
err = fd_executor_validate_transaction_fee_payer ( txn_ctx );
1129
1132
if ( FD_UNLIKELY ( err != FD_RUNTIME_EXECUTE_SUCCESS ) ) {
@@ -1616,12 +1619,16 @@ fd_update_next_epoch_stakes( fd_exec_slot_ctx_t * slot_ctx ) {
1616
1619
fd_bank_curr_epoch_stakes_end_locking_query ( slot_ctx -> bank );
1617
1620
}
1618
1621
1619
- /* Mimics `bank.new_target_program_account()`. Assumes `out_rec` is a modifiable record.
1622
+ /* Mimics bank.new_target_program_account(). Assumes out_rec is a
1623
+ modifiable record.
1620
1624
1621
- From the calling context, `out_rec` points to a native program record (e.g. Config, ALUT native programs).
1622
- There should be enough space in `out_rec->data` to hold at least 36 bytes (the size of a BPF upgradeable
1623
- program account) when calling this function. The native program account's owner is set to the BPF loader
1624
- upgradeable program ID, and lamports are increased / deducted to contain the rent exempt minimum balance.
1625
+ From the calling context, out_rec points to a native program record
1626
+ (e.g. Config, ALUT native programs). There should be enough space in
1627
+ out_rec->data to hold at least 36 bytes (the size of a BPF
1628
+ upgradeable program account) when calling this function. The native
1629
+ program account's owner is set to the BPF loader upgradeable program
1630
+ ID, and lamports are increased / deducted to contain the rent exempt
1631
+ minimum balance.
1625
1632
1626
1633
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L79-L95 */
1627
1634
static int
@@ -1665,12 +1672,15 @@ fd_new_target_program_account( fd_exec_slot_ctx_t * slot_ctx,
1665
1672
return FD_RUNTIME_EXECUTE_SUCCESS ;
1666
1673
}
1667
1674
1668
- /* Mimics `bank.new_target_program_data_account()`. Assumes `new_target_program_data_account` is a modifiable record.
1669
- `config_upgrade_authority_address` may be NULL.
1675
+ /* Mimics bank.new_target_program_data_account(). Assumes
1676
+ new_target_program_data_account is a modifiable record.
1677
+ config_upgrade_authority_address may be NULL.
1670
1678
1671
- This function uses an existing buffer account `buffer_acc_rec` to set the program data account data for a core
1672
- program BPF migration. Sets the lamports and data fields of `new_target_program_data_account` based on the
1673
- ELF data length, and sets the owner to the BPF loader upgradeable program ID.
1679
+ This function uses an existing buffer account buffer_acc_rec to set
1680
+ the program data account data for a core program BPF migration. Sets
1681
+ the lamports and data fields of new_target_program_data_account
1682
+ based on the ELF data length, and sets the owner to the BPF loader
1683
+ upgradeable program ID.
1674
1684
1675
1685
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L97-L153 */
1676
1686
static int
@@ -1746,7 +1756,7 @@ fd_new_target_program_data_account( fd_exec_slot_ctx_t * slot_ctx,
1746
1756
} FD_SPAD_FRAME_END ;
1747
1757
}
1748
1758
1749
- /* Mimics ` migrate_builtin_to_core_bpf()` . The arguments map as follows:
1759
+ /* Mimics migrate_builtin_to_core_bpf(). The arguments map as follows:
1750
1760
- builtin_program_id: builtin_program_id
1751
1761
- config
1752
1762
- source_buffer_address: source_buffer_address
@@ -1766,12 +1776,17 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
1766
1776
1767
1777
/* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L242-L243
1768
1778
1769
- The below logic is used to obtain a `TargetBuiltin` account. There are three fields of `TargetBuiltin` returned:
1779
+ The below logic is used to obtain a TargetBuiltin account. There
1780
+ are three fields of TargetBuiltin returned:
1770
1781
- target.program_address: builtin_program_id
1771
1782
- target.program_account:
1772
- - if stateless: an AccountSharedData::default() (i.e. system program id, 0 lamports, 0 data, non-executable, system program owner)
1773
- - if NOT stateless: the existing account (for us its called `target_program_account`)
1774
- - target.program_data_address: `target_program_data_address` for us, derived below. */
1783
+ - if stateless: an AccountSharedData::default() (i.e. system
1784
+ program id, 0 lamports, 0 data, non-executable, system
1785
+ program owner)
1786
+ - if NOT stateless: the existing account (for us its called
1787
+ target_program_account)
1788
+ - target.program_data_address: target_program_data_address for
1789
+ us, derived below. */
1775
1790
1776
1791
/* These checks will fail if the core program has already been migrated to BPF, since the account will exist + the program owner
1777
1792
will no longer be the native loader.
@@ -1823,7 +1838,7 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
1823
1838
1824
1839
/* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L244
1825
1840
1826
- Obtains a ` SourceBuffer` account. There are two fields returned:
1841
+ Obtains a SourceBuffer account. There are two fields returned:
1827
1842
- source.buffer_address: source_buffer_address
1828
1843
- source.buffer_account: the existing buffer account */
1829
1844
@@ -1850,8 +1865,9 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
1850
1865
return ;
1851
1866
}
1852
1867
1853
- /* The buffer account should have the correct state. We already check the buffer account state in `fd_new_target_program_data_account`,
1854
- so we can skip the checks here.
1868
+ /* The buffer account should have the correct state. We already check
1869
+ the buffer account state in fd_new_target_program_data_account, so
1870
+ we can skip the checks here.
1855
1871
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/source_buffer.rs#L37-L47 */
1856
1872
1857
1873
/* This check is done a bit prematurely because we calculate the previous account state's lamports. We use 0 for starting lamports
@@ -2009,9 +2025,10 @@ fd_apply_builtin_program_feature_transitions( fd_exec_slot_ctx_t * slot_ctx,
2009
2025
fd_spad_t * runtime_spad ) {
2010
2026
/* TODO: Set the upgrade authority properly from the core bpf migration config. Right now it's set to None.
2011
2027
2012
- Migrate any necessary stateless builtins to core BPF. So far, the only "stateless" builtin
2013
- is the Feature program. Beginning checks in the `migrate_builtin_to_core_bpf` function will
2014
- fail if the program has already been migrated to BPF. */
2028
+ Migrate any necessary stateless builtins to core BPF. So far,
2029
+ the only "stateless" builtin is the Feature program. Beginning
2030
+ checks in the migrate_builtin_to_core_bpf function will fail if the
2031
+ program has already been migrated to BPF. */
2015
2032
2016
2033
FD_SPAD_FRAME_BEGIN ( runtime_spad ) {
2017
2034
0 commit comments