Skip to content

Commit 5443c61

Browse files
committed
chore: fix poor comment style in fd_runtime.c
1 parent 7c1bc58 commit 5443c61

File tree

1 file changed

+47
-30
lines changed

1 file changed

+47
-30
lines changed

src/flamenco/runtime/fd_runtime.c

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555

5656
int
5757
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.
6060
https://github.com/anza-xyz/agave/blob/v2.3.1/runtime/src/bank.rs#L6149-L6165 */
6161
if( FD_FEATURE_ACTIVE_BANK( bank, enable_vote_address_leader_schedule ) ) {
6262
/* Return the first epoch if activated at genesis
@@ -69,7 +69,8 @@ fd_runtime_should_use_vote_keyed_leader_schedule( fd_bank_t * bank ) {
6969
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query( bank );
7070
ulong activation_epoch = fd_slot_to_epoch( epoch_schedule, activation_slot, NULL );
7171

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.
7374
https://github.com/anza-xyz/agave/blob/v2.3.1/runtime/src/bank.rs#L6162-L6164 */
7475
ulong effective_epoch = activation_epoch + 1UL;
7576
ulong current_epoch = fd_bank_epoch_get( bank );
@@ -78,8 +79,8 @@ fd_runtime_should_use_vote_keyed_leader_schedule( fd_bank_t * bank ) {
7879
return !!( current_epoch >= effective_epoch );
7980
}
8081

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. */
8384
return 0;
8485
}
8586

@@ -1106,24 +1107,26 @@ fd_runtime_pre_execute_check( fd_txn_p_t * txn, fd_exec_txn_ctx_t * txn_ctx ) {
11061107
/* Set up the transaction accounts and other txn ctx metadata */
11071108
fd_executor_setup_accounts_for_txn( txn_ctx );
11081109

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.
11111113
https://github.com/anza-xyz/agave/blob/838c1952595809a31520ff1603a13f2c9123aa51/accounts-db/src/account_locks.rs#L118 */
11121114
err = fd_executor_validate_account_locks( txn_ctx );
11131115
if( FD_UNLIKELY( err!=FD_RUNTIME_EXECUTE_SUCCESS ) ) {
11141116
txn->flags = 0U;
11151117
return err;
11161118
}
11171119

1118-
/* `load_and_execute_transactions()` -> `check_transactions()`
1120+
/* load_and_execute_transactions() -> check_transactions()
11191121
https://github.com/anza-xyz/agave/blob/ced98f1ebe73f7e9691308afa757323003ff744f/runtime/src/bank.rs#L3667-L3672 */
11201122
err = fd_executor_check_transactions( txn_ctx );
11211123
if( FD_UNLIKELY( err!=FD_RUNTIME_EXECUTE_SUCCESS ) ) {
11221124
txn->flags = 0U;
11231125
return err;
11241126
}
11251127

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()
11271130
https://github.com/anza-xyz/agave/blob/ced98f1ebe73f7e9691308afa757323003ff744f/svm/src/transaction_processor.rs#L236-L249 */
11281131
err = fd_executor_validate_transaction_fee_payer( txn_ctx );
11291132
if( FD_UNLIKELY( err!=FD_RUNTIME_EXECUTE_SUCCESS ) ) {
@@ -1616,12 +1619,16 @@ fd_update_next_epoch_stakes( fd_exec_slot_ctx_t * slot_ctx ) {
16161619
fd_bank_curr_epoch_stakes_end_locking_query( slot_ctx->bank );
16171620
}
16181621

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.
16201624
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.
16251632
16261633
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L79-L95 */
16271634
static int
@@ -1665,12 +1672,15 @@ fd_new_target_program_account( fd_exec_slot_ctx_t * slot_ctx,
16651672
return FD_RUNTIME_EXECUTE_SUCCESS;
16661673
}
16671674

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.
16701678
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.
16741684
16751685
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L97-L153 */
16761686
static int
@@ -1746,7 +1756,7 @@ fd_new_target_program_data_account( fd_exec_slot_ctx_t * slot_ctx,
17461756
} FD_SPAD_FRAME_END;
17471757
}
17481758

1749-
/* Mimics `migrate_builtin_to_core_bpf()`. The arguments map as follows:
1759+
/* Mimics migrate_builtin_to_core_bpf(). The arguments map as follows:
17501760
- builtin_program_id: builtin_program_id
17511761
- config
17521762
- source_buffer_address: source_buffer_address
@@ -1766,12 +1776,17 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
17661776

17671777
/* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L242-L243
17681778
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:
17701781
- target.program_address: builtin_program_id
17711782
- 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. */
17751790

17761791
/* These checks will fail if the core program has already been migrated to BPF, since the account will exist + the program owner
17771792
will no longer be the native loader.
@@ -1823,7 +1838,7 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
18231838

18241839
/* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L244
18251840
1826-
Obtains a `SourceBuffer` account. There are two fields returned:
1841+
Obtains a SourceBuffer account. There are two fields returned:
18271842
- source.buffer_address: source_buffer_address
18281843
- source.buffer_account: the existing buffer account */
18291844

@@ -1850,8 +1865,9 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
18501865
return;
18511866
}
18521867

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.
18551871
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/source_buffer.rs#L37-L47 */
18561872

18571873
/* 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,
20092025
fd_spad_t * runtime_spad ) {
20102026
/* TODO: Set the upgrade authority properly from the core bpf migration config. Right now it's set to None.
20112027
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. */
20152032

20162033
FD_SPAD_FRAME_BEGIN( runtime_spad ) {
20172034

0 commit comments

Comments
 (0)