Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/flamenco/runtime/fd_runtime_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx,
uchar const acct[ static 32 ],
fd_spad_t * runtime_spad ) {

/* Skip reverted features */
if( FD_UNLIKELY( id->reverted ) ) {
return;
}

FD_TXN_ACCOUNT_DECL( acct_rec );
int err = fd_txn_account_init_from_funk_readonly( acct_rec,
(fd_pubkey_t *)acct,
Expand All @@ -226,16 +231,20 @@ fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx,
return;
}

/* Skip accounts that are not owned by the feature program */
/* Skip accounts that are not owned by the feature program
https://github.com/anza-xyz/solana-sdk/blob/6512aca61167088ce10f2b545c35c9bcb1400e70/feature-gate-interface/src/lib.rs#L42-L44 */
if( FD_UNLIKELY( memcmp( acct_rec->vt->get_owner( acct_rec ), fd_solana_feature_program_id.key, sizeof(fd_pubkey_t) ) ) ) {
return;
}

/* Skip reverted features */
if( FD_UNLIKELY( id->reverted ) ) {
/* Account data size must be >= FD_FEATURE_SIZEOF (9 bytes)
https://github.com/anza-xyz/solana-sdk/blob/6512aca61167088ce10f2b545c35c9bcb1400e70/feature-gate-interface/src/lib.rs#L45-L47 */
if( FD_UNLIKELY( acct_rec->vt->get_data_len( acct_rec )<FD_FEATURE_SIZEOF ) ) {
return;
}

/* Deserialize the feature account data
https://github.com/anza-xyz/solana-sdk/blob/6512aca61167088ce10f2b545c35c9bcb1400e70/feature-gate-interface/src/lib.rs#L48-L50 */
FD_SPAD_FRAME_BEGIN( runtime_spad ) {
int decode_err;
fd_feature_t * feature = fd_bincode_decode_spad(
Expand All @@ -244,7 +253,7 @@ fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx,
acct_rec->vt->get_data_len( acct_rec ),
&decode_err );
if( FD_UNLIKELY( decode_err ) ) {
FD_LOG_ERR(( "Failed to decode feature account %s (%d)", FD_BASE58_ENC_32_ALLOCA( acct ), decode_err ));
return;
}

if( feature->has_activated_at ) {
Expand Down
3 changes: 3 additions & 0 deletions src/flamenco/runtime/fd_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#define FD_RUNTIME_ENC_BINCODE 0xB13C0DEFU /* classic bincode encoding */
#define FD_RUNTIME_ENC_ARCHIVE 0xA3C417EAU /* archival encoding */

/* https://github.com/anza-xyz/solana-sdk/blob/6512aca61167088ce10f2b545c35c9bcb1400e70/feature-gate-interface/src/lib.rs#L36-L38 */
#define FD_FEATURE_SIZEOF (9UL)

FD_PROTOTYPES_BEGIN

static inline fd_funk_rec_key_t
Expand Down
Loading