Skip to content

Commit

Permalink
flamenco: implement disable_account_loader_special_case
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhargava-jump committed Dec 13, 2024
1 parent 7152b42 commit 4141686
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/flamenco/features/fd_features_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,12 @@ fd_feature_id_t const ids[] = {
.name = "enable_get_epoch_stake_syscall",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = offsetof(fd_features_t, disable_account_loader_special_case)>>3,
.id = {"\xc7\x2b\x39\x35\x25\x63\x29\x7f\x69\x4f\x2d\x7f\x8c\x2c\xbb\x62\x13\x3e\x4d\xf8\xc9\xc0\x2d\x75\xed\xed\x28\x6a\x6f\x44\xe6\x8f"},
/* EQUMpNFr7Nacb1sva56xn1aLfBxppEoSBH8RRVdkcD1x */
.name = "disable_account_loader_special_case",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = ULONG_MAX }
};

Expand Down Expand Up @@ -1520,6 +1526,7 @@ fd_feature_id_query( ulong prefix ) {
case 0xa9a90df1904da912: return &ids[ 211 ];
case 0x2434a84be5b684a5: return &ids[ 212 ];
case 0xaebbcc5ad0a28864: return &ids[ 213 ];
case 0x7f29632535392bc7: return &ids[ 214 ];
default: break;
}

Expand Down Expand Up @@ -1742,5 +1749,6 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_feature_gate_program_to_core_
FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_config_program_to_core_bpf )>>3==211UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_address_lookup_table_program_to_core_bpf )>>3==212UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, enable_get_epoch_stake_syscall )>>3==213UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, disable_account_loader_special_case )>>3==214UL, layout );

FD_STATIC_ASSERT( sizeof( fd_features_t )>>3==FD_FEATURE_ID_CNT, layout );
3 changes: 2 additions & 1 deletion src/flamenco/features/fd_features_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/* FEATURE_ID_CNT is the number of features in ids */

#define FD_FEATURE_ID_CNT (214UL)
#define FD_FEATURE_ID_CNT (215UL)

union fd_features {

Expand Down Expand Up @@ -227,6 +227,7 @@ union fd_features {
/* 0xa9a90df1904da912 */ ulong migrate_config_program_to_core_bpf;
/* 0x2434a84be5b684a5 */ ulong migrate_address_lookup_table_program_to_core_bpf;
/* 0xaebbcc5ad0a28864 */ ulong enable_get_epoch_stake_syscall;
/* 0x7f29632535392bc7 */ ulong disable_account_loader_special_case;
};

};
3 changes: 2 additions & 1 deletion src/flamenco/features/feature_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,6 @@
{"name":"migrate_feature_gate_program_to_core_bpf","pubkey":"4eohviozzEeivk1y9UbrnekbAFMDQyJz5JjA9Y6gyvky"},
{"name":"migrate_config_program_to_core_bpf","pubkey":"2Fr57nzzkLYXW695UdDxDeR5fhnZWSttZeZYemrnpGFV"},
{"name":"migrate_address_lookup_table_program_to_core_bpf","pubkey":"C97eKZygrkU4JxJsZdjgbUY7iQR7rKTr4NyDWo2E5pRm"},
{"name":"enable_get_epoch_stake_syscall","pubkey":"7mScTYkJXsbdrcwTQRs7oeCSXoJm4WjzBsRyf8bCU3Np"}
{"name":"enable_get_epoch_stake_syscall","pubkey":"7mScTYkJXsbdrcwTQRs7oeCSXoJm4WjzBsRyf8bCU3Np"},
{"name":"disable_account_loader_special_case","pubkey": "EQUMpNFr7Nacb1sva56xn1aLfBxppEoSBH8RRVdkcD1x"}
]
9 changes: 7 additions & 2 deletions src/flamenco/runtime/fd_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fd_executor_load_transaction_accounts( fd_exec_txn_ctx_t * txn_ctx ) {
/* In agave, the only way for the account_found to be set to false, the following conditions must be met
1. account is not sysvar instruction
2. account is not a fee payer (for loop does not include the fee payer)
3. account is an instruction account or writable account (this is already checked for later in this function)
3. account is an instruction account or writable account (this is already checked for later in this function) or disable_account_loader_special_case is enabled
4. account does not exist in loaded account shared data */
if ( !is_sysvar_instruction && !account_exists ) {
accounts_found[i] = 0;
Expand Down Expand Up @@ -449,7 +449,12 @@ fd_executor_load_transaction_accounts( fd_exec_txn_ctx_t * txn_ctx ) {
https://github.com/anza-xyz/agave/blob/v2.0.9/svm/src/account_loader.rs#L239-249 */

/* If it is not writable */
if( fd_txn_account_is_writable_idx( txn_ctx, instr->program_id ) ) {
if( fd_txn_account_is_writable_idx( txn_ctx, instr->program_id )) {
return FD_RUNTIME_TXN_ERR_INVALID_PROGRAM_FOR_EXECUTION;
}

/* If disable_account_loader_special_case is active */
if ( FD_FEATURE_ACTIVE(txn_ctx->slot_ctx, disable_account_loader_special_case)) {
return FD_RUNTIME_TXN_ERR_INVALID_PROGRAM_FOR_EXECUTION;
}

Expand Down

0 comments on commit 4141686

Please sign in to comment.