diff --git a/src/flamenco/runtime/fd_runtime_init.c b/src/flamenco/runtime/fd_runtime_init.c index 124d5892f0e..24d1c470027 100644 --- a/src/flamenco/runtime/fd_runtime_init.c +++ b/src/flamenco/runtime/fd_runtime_init.c @@ -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, @@ -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 )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 ) { diff --git a/src/flamenco/runtime/fd_runtime_init.h b/src/flamenco/runtime/fd_runtime_init.h index 0617b79f811..6405ef35734 100644 --- a/src/flamenco/runtime/fd_runtime_init.h +++ b/src/flamenco/runtime/fd_runtime_init.h @@ -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