diff --git a/contrib/test/test-vectors-fixtures/txn-fixtures/program-tests.list b/contrib/test/test-vectors-fixtures/txn-fixtures/program-tests.list index 834e2c91c3c..122aa7e06d1 100644 --- a/contrib/test/test-vectors-fixtures/txn-fixtures/program-tests.list +++ b/contrib/test/test-vectors-fixtures/txn-fixtures/program-tests.list @@ -1919,6 +1919,7 @@ dump/test-vectors/txn/fixtures/programs/9d45f7478d50b40dd4883e5eb4970b075a5deb45 dump/test-vectors/txn/fixtures/programs/9d45f7478d50b40dd4883e5eb4970b075a5deb45_3293287.fix dump/test-vectors/txn/fixtures/programs/9d763cea6739a560ce16ef2f9d47812c00aec14a_265678.fix dump/test-vectors/txn/fixtures/programs/9d98845ab80ae919a4c32b43c7ce2db8b2da2bb0_265678.fix +dump/test-vectors/txn/fixtures/programs/9da3a0d88d15613311e43d03cb97e28961bdca77_3938735.fix dump/test-vectors/txn/fixtures/programs/9da4f42a875bafad9ebbdec34e463e7424101540_265678.fix dump/test-vectors/txn/fixtures/programs/9dacaaaf67b58eb8428385fc80972cd1f7f74260_265678.fix dump/test-vectors/txn/fixtures/programs/9db0d6ac727a2378226657a9b039ab9a89310ed6_265678.fix diff --git a/src/flamenco/runtime/fd_executor.c b/src/flamenco/runtime/fd_executor.c index b4dd7640eb3..e0e6a70d3b4 100644 --- a/src/flamenco/runtime/fd_executor.c +++ b/src/flamenco/runtime/fd_executor.c @@ -113,15 +113,27 @@ typedef struct fd_native_prog_info fd_native_prog_info_t; #include "../../util/tmpl/fd_map_perfect.c" #undef PERFECT_HASH -/* https://github.com/anza-xyz/agave/blob/9efdd74b1b65ecfd85b0db8ad341c6bd4faddfef/program-runtime/src/invoke_context.rs#L461-L488 */ -fd_exec_instr_fn_t -fd_executor_lookup_native_program( fd_txn_account_t const * prog_acc ) { +/* https://github.com/anza-xyz/agave/blob/v2.2.6/program-runtime/src/invoke_context.rs#L520-L544 */ +int +fd_executor_lookup_native_program( fd_txn_account_t const * prog_acc, + fd_exec_txn_ctx_t * txn_ctx, + fd_exec_instr_fn_t * native_prog_fn ) { fd_pubkey_t const * pubkey = prog_acc->pubkey; fd_pubkey_t const * owner = (fd_pubkey_t const *)prog_acc->const_meta->info.owner; /* Native programs should be owned by the native loader... This will not be the case though once core programs are migrated to BPF. */ int is_native_program = !memcmp( owner, fd_solana_native_loader_id.key, sizeof(fd_pubkey_t) ); + + if( !is_native_program && FD_FEATURE_ACTIVE( txn_ctx->slot, txn_ctx->features, remove_accounts_executable_flag_checks ) ) { + if ( FD_UNLIKELY( memcmp( owner, fd_solana_bpf_loader_deprecated_program_id.key, sizeof(fd_pubkey_t) ) && + memcmp( owner, fd_solana_bpf_loader_program_id.key, sizeof(fd_pubkey_t) ) && + memcmp( owner, fd_solana_bpf_loader_upgradeable_program_id.key, sizeof(fd_pubkey_t) ) && + memcmp( owner, fd_solana_bpf_loader_v4_program_id.key, sizeof(fd_pubkey_t) ) ) ) { + return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_PROGRAM_ID; + } + } + if( FD_UNLIKELY( !memcmp( pubkey, fd_solana_ed25519_sig_verify_program_id.key, sizeof(fd_pubkey_t) ) && !memcmp( owner, fd_solana_system_program_id.key, sizeof(fd_pubkey_t) ) ) ) { /* ... except for the special case for testnet ed25519, which is @@ -130,7 +142,8 @@ fd_executor_lookup_native_program( fd_txn_account_t const * prog_acc ) { } fd_pubkey_t const * lookup_pubkey = is_native_program ? pubkey : owner; const fd_native_prog_info_t null_function = {0}; - return fd_native_program_fn_lookup_tbl_query( lookup_pubkey, &null_function )->fn; + *native_prog_fn = fd_native_program_fn_lookup_tbl_query( lookup_pubkey, &null_function )->fn; + return 0; } fd_exec_instr_fn_t @@ -1065,7 +1078,12 @@ fd_execute_instr( fd_exec_txn_ctx_t * txn_ctx, if( FD_LIKELY( native_prog_fn == NULL ) ) { /* Lookup a native builtin program if the program is not a precompiled program */ - native_prog_fn = fd_executor_lookup_native_program( &txn_ctx->accounts[ instr->program_id ] ); + int err = fd_executor_lookup_native_program( &txn_ctx->accounts[ instr->program_id ], txn_ctx, &native_prog_fn ); + if( FD_UNLIKELY( err ) ) { + FD_TXN_PREPARE_ERR_OVERWRITE( txn_ctx ); + FD_TXN_ERR_FOR_LOG_INSTR( txn_ctx, err, txn_ctx->instr_err_idx ); + return err; + } /* Only reset the return data when executing a native builtin program (not a precompile) https://github.com/anza-xyz/agave/blob/v2.1.6/program-runtime/src/invoke_context.rs#L536-L537 */ fd_exec_txn_ctx_reset_return_data( txn_ctx ); diff --git a/src/flamenco/runtime/fd_executor.h b/src/flamenco/runtime/fd_executor.h index 98b60116a52..9cab1d4e275 100644 --- a/src/flamenco/runtime/fd_executor.h +++ b/src/flamenco/runtime/fd_executor.h @@ -45,8 +45,10 @@ typedef int (* fd_exec_instr_fn_t)( fd_exec_instr_ctx_t * ctx ); processor for the given native program ID. Returns NULL if given ID is not a recognized native program. */ -fd_exec_instr_fn_t -fd_executor_lookup_native_program( fd_txn_account_t const * account ); +int +fd_executor_lookup_native_program( fd_txn_account_t const * prog_acc, + fd_exec_txn_ctx_t * txn_ctx, + fd_exec_instr_fn_t * native_prog_fn ); fd_exec_instr_fn_t fd_executor_lookup_native_precompile_program( fd_txn_account_t const * prog_acc );