From 612a5234ccbcc770f4bbed110ff4d82a0329f87e Mon Sep 17 00:00:00 2001 From: Charles Moyes Date: Fri, 14 Nov 2025 16:02:28 +0000 Subject: [PATCH] Update ELF laoder version mapping Mismatch log fixes Syscall macros for temporarily setting errors Error code aliasing Move syscall override log collector Macro cleanup Patch vote mismatch Create non-nuil, but empty treap / pools flamenco: unify instr error codes 20 and 33 properly (#7205) Validate accounts in zk-elgamal-proof process_close_proof_context Surgical edits to verify proof for v3.1 syscalls: revert special casing (#7209) 3.1 rekeys (#7216) Bump test vectors Update SHA Use mainline SHA Remove spurious loop Add old update features in ledger backtests Remove spurious loop Add old update features in ledger backtests --- contrib/test/test-vectors-commit-sha.txt | 2 +- src/ballet/sbpf/fd_sbpf_loader.c | 10 +---- src/flamenco/features/fd_features_generated.c | 15 ++++--- src/flamenco/features/fd_features_generated.h | 4 +- src/flamenco/features/feature_map.json | 6 +-- .../runtime/context/fd_exec_instr_ctx.c | 2 +- .../runtime/context/fd_exec_instr_ctx.h | 6 +-- .../runtime/context/fd_exec_txn_ctx.c | 2 +- src/flamenco/runtime/fd_executor.c | 2 +- .../runtime/program/fd_bpf_loader_program.c | 24 +++++----- .../runtime/program/fd_stake_program.c | 28 ++++++------ .../runtime/program/fd_system_program.c | 16 +++---- .../runtime/program/fd_system_program_nonce.c | 10 ++--- .../runtime/program/fd_vote_program.c | 45 +++++++++++++++---- src/flamenco/runtime/program/zksdk/fd_zksdk.c | 32 ++++++++++--- src/flamenco/runtime/sysvar/fd_sysvar.c | 2 +- .../runtime/tests/run_backtest_all.sh | 6 +-- src/flamenco/runtime/tests/run_backtest_ci.sh | 6 +-- src/flamenco/vm/syscall/fd_vm_syscall_cpi.c | 8 ++-- 19 files changed, 134 insertions(+), 92 deletions(-) diff --git a/contrib/test/test-vectors-commit-sha.txt b/contrib/test/test-vectors-commit-sha.txt index 1ce24b71acb..1aeb424e69e 100644 --- a/contrib/test/test-vectors-commit-sha.txt +++ b/contrib/test/test-vectors-commit-sha.txt @@ -1 +1 @@ -c8e3939ed100fda48240cc1b7a784e96415f5ffe +3bded3a6e883823f246ccdbe5b4e6ba49fbf26ed diff --git a/src/ballet/sbpf/fd_sbpf_loader.c b/src/ballet/sbpf/fd_sbpf_loader.c index e80fb8926ee..9bb5d0d5626 100644 --- a/src/ballet/sbpf/fd_sbpf_loader.c +++ b/src/ballet/sbpf/fd_sbpf_loader.c @@ -1466,14 +1466,8 @@ fd_sbpf_program_get_sbpf_version_or_err( void const * bin, } uint e_flags = FD_LOAD( uint, bin+E_FLAGS_OFFSET ); - uint sbpf_version = 0U; - if( FD_UNLIKELY( config->sbpf_max_version==FD_SBPF_V0 ) ) { - /* https://github.com/anza-xyz/sbpf/blob/v0.12.2/src/elf.rs#L384-L388 */ - sbpf_version = e_flags==E_FLAGS_SBPF_V2 ? FD_SBPF_RESERVED : FD_SBPF_V0; - } else { - /* https://github.com/anza-xyz/sbpf/blob/v0.12.2/src/elf.rs#L390-L396 */ - sbpf_version = e_flags < FD_SBPF_VERSION_COUNT ? e_flags : FD_SBPF_RESERVED; - } + /* https://github.com/anza-xyz/sbpf/blob/v0.13.0/src/elf.rs#L382-L390 */ + uint sbpf_version = ( e_flags < FD_SBPF_VERSION_COUNT ) ? e_flags : FD_SBPF_RESERVED; /* https://github.com/anza-xyz/sbpf/blob/v0.12.2/src/elf.rs#L399-L401 */ if( FD_UNLIKELY( !( config->sbpf_min_version <= sbpf_version && sbpf_version <= config->sbpf_max_version ) ) ) { diff --git a/src/flamenco/features/fd_features_generated.c b/src/flamenco/features/fd_features_generated.c index 8e5acc0a733..a185815082f 100644 --- a/src/flamenco/features/fd_features_generated.c +++ b/src/flamenco/features/fd_features_generated.c @@ -1504,7 +1504,8 @@ fd_feature_id_t const ids[] = { .id = {"\x08\xe8\xaa\x2e\x13\xc5\xc5\x54\xe2\xc3\xb4\x0e\x26\xb4\x64\x3b\xc7\xcb\x89\x6c\xc0\x06\x05\xaa\x65\x7f\x3a\x3d\x30\xee\xf9\x05"}, /* bn2puAyxUx6JUabAxYdKdJ5QHbNNmKw8dCGuGCyRrFN */ .name = "fix_alt_bn128_multiplication_input_length", - .cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} }, + .cleaned_up = {3, 1, 0}, + .hardcode_for_fuzzing = 1 }, { .index = offsetof(fd_features_t, lift_cpi_caller_restriction)>>3, .id = {"\xf6\xd3\x41\xcb\x4b\xa2\x65\x9e\xac\xe7\x83\xef\x30\xe5\xfc\xc1\x9a\x94\x8b\x9b\x00\xba\x8a\xad\xf5\x2a\x6b\x9f\x65\x24\x5e\xc8"}, @@ -1668,14 +1669,14 @@ fd_feature_id_t const ids[] = { .cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} }, { .index = offsetof(fd_features_t, stricter_abi_and_runtime_constraints)>>3, - .id = {"\xb1\xb1\x8b\xfe\x0c\x8c\xa8\x90\xaf\x61\x7d\x45\x2d\x08\xd5\x33\x88\xea\x0b\x0b\x87\x1f\xb6\x1c\x38\xc8\xeb\x19\x0f\xd7\x9f\x0a"}, - /* CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM */ + .id = {"\x0c\xdc\xaa\x60\x4d\xd8\x04\x50\x19\x27\xdb\xa5\x2d\x2a\x39\xcf\x51\xdb\xc9\xae\xd8\x06\xc9\xda\x36\x46\xb8\xf2\x41\x40\x59\xed"}, + /* sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r */ .name = "stricter_abi_and_runtime_constraints", .cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} }, { .index = offsetof(fd_features_t, account_data_direct_mapping)>>3, - .id = {"\x83\xaf\x45\x7d\x2d\x4b\x60\xe8\xb6\x8b\xde\xea\x1f\x99\x51\x97\x42\x3e\x2d\x9a\xd0\xe0\x8c\xa8\x44\x7f\x6a\xd4\x68\x43\x4e\x19"}, - /* 9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ */ + .id = {"\xb5\xfa\x43\x42\x67\x5e\x0c\x52\x3d\x10\xad\xbb\x78\x84\x1f\x16\x92\x1f\xf2\xb6\xe7\xcd\xe9\x60\x60\x84\x9a\xfd\x12\xb1\x01\x39"}, + /* DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA */ .name = "account_data_direct_mapping", .cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} }, @@ -1934,8 +1935,8 @@ fd_feature_id_query( ulong prefix ) { case 0x3711b30f40730240: return &ids[ 240 ]; case 0xc1309d1b0ae3e80c: return &ids[ 241 ]; case 0x5c64cc1a9be3790a: return &ids[ 242 ]; - case 0x90a88c0cfe8bb1b1: return &ids[ 243 ]; - case 0xe8604b2d7d45af83: return &ids[ 244 ]; + case 0x5004d84d60aadc0c: return &ids[ 243 ]; + case 0x520c5e674243fab5: return &ids[ 244 ]; case 0xf08a42c3c040e908: return &ids[ 245 ]; default: break; } diff --git a/src/flamenco/features/fd_features_generated.h b/src/flamenco/features/fd_features_generated.h index 0834ea044cb..a9d76f1d773 100644 --- a/src/flamenco/features/fd_features_generated.h +++ b/src/flamenco/features/fd_features_generated.h @@ -259,8 +259,8 @@ union fd_features { /* 0x3711b30f40730240 */ ulong enable_vote_address_leader_schedule; /* 0xc1309d1b0ae3e80c */ ulong enshrine_slashing_program; /* 0x5c64cc1a9be3790a */ ulong raise_account_cu_limit; - /* 0x90a88c0cfe8bb1b1 */ ulong stricter_abi_and_runtime_constraints; - /* 0xe8604b2d7d45af83 */ ulong account_data_direct_mapping; + /* 0x5004d84d60aadc0c */ ulong stricter_abi_and_runtime_constraints; + /* 0x520c5e674243fab5 */ ulong account_data_direct_mapping; /* 0xf08a42c3c040e908 */ ulong fix_alt_bn128_pairing_length_check; }; }; diff --git a/src/flamenco/features/feature_map.json b/src/flamenco/features/feature_map.json index 304349f44e1..11f7466dc40 100644 --- a/src/flamenco/features/feature_map.json +++ b/src/flamenco/features/feature_map.json @@ -216,7 +216,7 @@ {"name":"enable_get_epoch_stake_syscall","pubkey":"FKe75t4LXxGaQnVHdUKM6DSFifVVraGZ8LyNo7oPwy1Z","old":"7mScTYkJXsbdrcwTQRs7oeCSXoJm4WjzBsRyf8bCU3Np"}, {"name":"disable_account_loader_special_case","pubkey":"EQUMpNFr7Nacb1sva56xn1aLfBxppEoSBH8RRVdkcD1x","cleaned_up":[2,2,0],"hardcode_for_fuzzing":1}, {"name":"remove_accounts_executable_flag_checks","pubkey":"FXs1zh47QbNnhXcnB6YiAQoJ4sGB91tKF3UFHLcKT7PM","old":"FfgtauHUWKeXTzjXkua9Px4tNGBFHKZ9WaigM5VbbzFx","hardcode_for_fuzzing":1}, - {"name":"fix_alt_bn128_multiplication_input_length","pubkey":"bn2puAyxUx6JUabAxYdKdJ5QHbNNmKw8dCGuGCyRrFN"}, + {"name":"fix_alt_bn128_multiplication_input_length","pubkey":"bn2puAyxUx6JUabAxYdKdJ5QHbNNmKw8dCGuGCyRrFN","cleaned_up":[3,1,0],"hardcode_for_fuzzing":1}, {"name":"lift_cpi_caller_restriction","pubkey":"HcW8ZjBezYYgvcbxNJwqv1t484Y2556qJsfNDWvJGZRH","reverted":1}, {"name":"accounts_lt_hash","pubkey":"LTHasHQX6661DaDD4S6A2TFi6QBuiwXKv66fB1obfHq","old":"LtHaSHHsUge7EWTPVrmpuexKz6uVHZXZL6cgJa7W7Zn","cleaned_up":[3,0,0],"hardcode_for_fuzzing":1}, {"name":"remove_accounts_delta_hash","pubkey":"LTdLt9Ycbyoipz5fLysCi1NnDnASsZfmJLJXts5ZxZz","cleaned_up":[3,0,0],"hardcode_for_fuzzing":1}, @@ -242,7 +242,7 @@ {"name":"enable_vote_address_leader_schedule","pubkey":"5JsG4NWH8Jbrqdd8uL6BNwnyZK3dQSoieRXG5vmofj9y"}, {"name":"enshrine_slashing_program","pubkey":"sProgVaNWkYdP2eTRAy1CPrgb3b9p8yXCASrPEqo6VJ"}, {"name":"raise_account_cu_limit","pubkey":"htsptAwi2yRoZH83SKaUXykeZGtZHgxkS2QwW1pssR8"}, - {"name":"stricter_abi_and_runtime_constraints","pubkey":"CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM"}, - {"name":"account_data_direct_mapping","pubkey":"9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ"}, + {"name":"stricter_abi_and_runtime_constraints","pubkey":"sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r","old":"CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM"}, + {"name":"account_data_direct_mapping","pubkey":"DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA","old":"9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ"}, {"name":"fix_alt_bn128_pairing_length_check","pubkey":"bnYzodLwmybj7e1HAe98yZrdJTd7we69eMMLgCXqKZm"} ] diff --git a/src/flamenco/runtime/context/fd_exec_instr_ctx.c b/src/flamenco/runtime/context/fd_exec_instr_ctx.c index b79fc4708de..e6ae756c804 100644 --- a/src/flamenco/runtime/context/fd_exec_instr_ctx.c +++ b/src/flamenco/runtime/context/fd_exec_instr_ctx.c @@ -108,7 +108,7 @@ fd_exec_instr_ctx_try_borrow_instr_account_with_key( fd_exec_instr_ctx_t const * /* Return a NotEnoughAccountKeys error if the account is not found in the instruction context to match the error code returned by fd_exec_instr_ctx_try_borrow_instr_account. */ - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } int diff --git a/src/flamenco/runtime/context/fd_exec_instr_ctx.h b/src/flamenco/runtime/context/fd_exec_instr_ctx.h index 8435116fd73..9175a006949 100644 --- a/src/flamenco/runtime/context/fd_exec_instr_ctx.h +++ b/src/flamenco/runtime/context/fd_exec_instr_ctx.h @@ -41,7 +41,7 @@ FD_PROTOTYPES_BEGIN Assert that enough accounts were supplied to this instruction. Returns FD_EXECUTOR_INSTR_SUCCESS if the number of accounts is as expected and - FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS otherwise. + FD_EXECUTOR_INSTR_ERR_MISSING_ACC otherwise. https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L490 */ @@ -50,7 +50,7 @@ fd_exec_instr_ctx_check_num_insn_accounts( fd_exec_instr_ctx_t const * ctx, uint expected_accounts ) { if( FD_UNLIKELY( ctx->instr->acct_cnt=ctx->instr->acct_cnt ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } *idx_in_txn = ctx->instr->accounts[ idx_in_instr ].index_in_transaction; diff --git a/src/flamenco/runtime/context/fd_exec_txn_ctx.c b/src/flamenco/runtime/context/fd_exec_txn_ctx.c index 580d43359d6..6d405c55569 100644 --- a/src/flamenco/runtime/context/fd_exec_txn_ctx.c +++ b/src/flamenco/runtime/context/fd_exec_txn_ctx.c @@ -137,7 +137,7 @@ fd_exec_txn_ctx_get_key_of_account_at_index( fd_exec_txn_ctx_t * ctx, /* Return a NotEnoughAccountKeys error if idx is out of bounds. https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L218 */ if( FD_UNLIKELY( idx>=ctx->accounts.accounts_cnt ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } *key = &ctx->accounts.account_keys[ idx ]; diff --git a/src/flamenco/runtime/fd_executor.c b/src/flamenco/runtime/fd_executor.c index 346fed18132..d58f535dff7 100644 --- a/src/flamenco/runtime/fd_executor.c +++ b/src/flamenco/runtime/fd_executor.c @@ -1116,7 +1116,7 @@ fd_txn_ctx_push( fd_exec_txn_ctx_t * txn_ctx, fd_txn_account_t * sysvar_instructions_account = NULL; err = fd_exec_txn_ctx_get_account_at_index( txn_ctx, (ushort)idx, &sysvar_instructions_account, NULL ); if( FD_UNLIKELY( err ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.2.12/transaction-context/src/lib.rs#L401-L402 */ diff --git a/src/flamenco/runtime/program/fd_bpf_loader_program.c b/src/flamenco/runtime/program/fd_bpf_loader_program.c index 74efea54f7e..f985b18d997 100644 --- a/src/flamenco/runtime/program/fd_bpf_loader_program.c +++ b/src/flamenco/runtime/program/fd_bpf_loader_program.c @@ -925,7 +925,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L476-L493 */ case fd_bpf_upgradeable_loader_program_instruction_enum_initialize_buffer: { if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 2U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L479 */ @@ -966,7 +966,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L494-L525 */ case fd_bpf_upgradeable_loader_program_instruction_enum_write: { if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 2U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L497 */ @@ -1026,7 +1026,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { case fd_bpf_upgradeable_loader_program_instruction_enum_deploy_with_max_data_len: { /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L527-L541 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 4U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L529-L534 */ @@ -1063,7 +1063,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L538 */ if( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 8U ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L539-L541 */ @@ -1366,7 +1366,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { case fd_bpf_upgradeable_loader_program_instruction_enum_upgrade: { /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L704-L714 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 3U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L706-L708 */ @@ -1389,7 +1389,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { } if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 7U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L713-L715 */ @@ -1650,7 +1650,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { case fd_bpf_upgradeable_loader_program_instruction_enum_set_authority: { int err; if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 2U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L896-L897 */ @@ -1757,7 +1757,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { } if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 3U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L968-L969 */ @@ -1855,7 +1855,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { int err; /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L1032-L1046 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 2U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* It's safe to directly access the instruction accounts because we already checked for two @@ -1909,7 +1909,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { fd_borrowed_account_drop( &close_account ); if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 3U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } fd_bpf_upgradeable_loader_state_buffer_t * state_buf = &close_account_state->inner.buffer; @@ -1927,7 +1927,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { } else if( fd_bpf_upgradeable_loader_state_is_program_data( close_account_state ) ) { int err; if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 4U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.1.4/programs/bpf_loader/src/lib.rs#L1074 */ @@ -2037,7 +2037,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { /* https://github.com/anza-xyz/agave/blob/v2.2.6/programs/bpf_loader/src/lib.rs#L1346 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( instr_ctx, 3U ) ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } /* https://github.com/anza-xyz/agave/blob/v2.2.6/programs/bpf_loader/src/lib.rs#L1347-L1349 */ diff --git a/src/flamenco/runtime/program/fd_stake_program.c b/src/flamenco/runtime/program/fd_stake_program.c index 3d1f06c2fee..966b662108e 100644 --- a/src/flamenco/runtime/program/fd_stake_program.c +++ b/src/flamenco/runtime/program/fd_stake_program.c @@ -2649,7 +2649,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( !clock ) ) return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_SYSVAR; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L94 if( FD_UNLIKELY( ctx->instr->acct_cnt<3 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L95 fd_pubkey_t const * custodian_pubkey = NULL; rc = get_optional_pubkey( ctx, 3, 0, &custodian_pubkey ); @@ -2686,7 +2686,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L109 if( ctx->instr->acct_cnt<2 ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L110 rc = fd_sysvar_instr_acct_check( ctx, 2, &fd_sysvar_clock_id ); if( FD_UNLIKELY( rc ) ) return rc; @@ -2729,7 +2729,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( rc ) ) return rc; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L130 if( FD_UNLIKELY( ctx->instr->acct_cnt<2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L131 rc = fd_sysvar_instr_acct_check( ctx, 2, &fd_sysvar_clock_id ); if( FD_UNLIKELY( rc ) ) return rc; @@ -2744,7 +2744,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { } // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L138 if( FD_UNLIKELY( ctx->instr->acct_cnt<5 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_instruction.rs#L138 */ fd_borrowed_account_drop( &me ); @@ -2778,7 +2778,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( rc ) ) return rc; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L154 if( FD_UNLIKELY( ctx->instr->acct_cnt<2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_instruction.rs#L154 */ fd_borrowed_account_drop( &me ); @@ -2803,7 +2803,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( rc ) ) return rc; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L168 if( FD_UNLIKELY( ctx->instr->acct_cnt<2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L169 rc = fd_sysvar_instr_acct_check( ctx, 2, &fd_sysvar_clock_id ); if( FD_UNLIKELY( rc ) ) return rc; @@ -2844,7 +2844,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( rc ) ) return rc; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L190 if( FD_UNLIKELY( ctx->instr->acct_cnt<2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L191 rc = fd_sysvar_instr_acct_check( ctx, 2, &fd_sysvar_clock_id ); if( FD_UNLIKELY( rc ) ) return rc; @@ -2859,7 +2859,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { } // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L198 if( FD_UNLIKELY( ctx->instr->acct_cnt<5 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_instruction.rs#L198 */ fd_borrowed_account_drop( &me ); @@ -3019,7 +3019,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( !clock ) ) return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_SYSVAR; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L253 if( FD_UNLIKELY( ctx->instr->acct_cnt<4 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_instruction.rs#L253 fd_pubkey_t const * authorized_pubkey = NULL; @@ -3064,7 +3064,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L274 if( FD_UNLIKELY( ctx->instr->acct_cnt<2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L276 rc = fd_sysvar_instr_acct_check( ctx, 2, &fd_sysvar_clock_id ); if( FD_UNLIKELY( rc ) ) return rc; @@ -3073,7 +3073,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( !clock ) ) return FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_SYSVAR; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L277 if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( ctx, 4U) ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_instruction.rs#L277-L280 fd_pubkey_t const * authorized_pubkey = NULL; @@ -3168,7 +3168,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { if( FD_UNLIKELY( rc ) ) return rc; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L323 if( FD_UNLIKELY( ctx->instr->acct_cnt<3 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_instruction.rs#L325 fd_sol_sysvar_clock_t clock_; fd_sol_sysvar_clock_t const * clock = fd_sysvar_cache_clock_read( ctx->sysvar_cache, &clock_ ); @@ -3202,7 +3202,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { case fd_stake_instruction_enum_move_stake: { // https://github.com/anza-xyz/agave/blob/cdff19c7807b006dd63429114fb1d9573bf74172/programs/stake/src/stake_instruction.rs#L361 if( FD_UNLIKELY( ctx->instr->acct_cnt<3 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; ulong lamports = instruction->inner.move_stake; // https://github.com/anza-xyz/agave/blob/cdff19c7807b006dd63429114fb1d9573bf74172/programs/stake/src/stake_instruction.rs#L362 @@ -3226,7 +3226,7 @@ fd_stake_program_execute( fd_exec_instr_ctx_t * ctx ) { case fd_stake_instruction_enum_move_lamports: { // https://github.com/anza-xyz/agave/blob/cdff19c7807b006dd63429114fb1d9573bf74172/programs/stake/src/stake_instruction.rs#L380 if( FD_UNLIKELY( ctx->instr->acct_cnt<3 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; // https://github.com/anza-xyz/agave/blob/cdff19c7807b006dd63429114fb1d9573bf74172/programs/stake/src/stake_instruction.rs#L381 ulong lamports = instruction->inner.move_lamports; diff --git a/src/flamenco/runtime/program/fd_system_program.c b/src/flamenco/runtime/program/fd_system_program.c index b1e96c5b704..71a49218ada 100644 --- a/src/flamenco/runtime/program/fd_system_program.c +++ b/src/flamenco/runtime/program/fd_system_program.c @@ -309,7 +309,7 @@ fd_system_program_exec_create_account( fd_exec_instr_ctx_t * /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L332 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L333-L339 Authorization check is lifted out from 'allocate' to here. */ @@ -345,7 +345,7 @@ fd_system_program_exec_assign( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L382 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L383-L384 */ @@ -376,7 +376,7 @@ fd_system_program_exec_transfer( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L395 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L396-L402 */ @@ -394,7 +394,7 @@ fd_system_program_exec_create_account_with_seed( fd_exec_instr_ctx_t * /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L360 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( ctx, 2UL) ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L361-L367 */ @@ -440,7 +440,7 @@ fd_system_program_exec_allocate( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L505 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L506-L507 */ fd_guarded_borrowed_account_t account = {0}; @@ -472,7 +472,7 @@ fd_system_program_exec_allocate_with_seed( fd_exec_instr_ctx_t * /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L523 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#524-525 */ @@ -519,7 +519,7 @@ fd_system_program_exec_assign_with_seed( fd_exec_instr_ctx_t * /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#543 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L544-L545 */ @@ -559,7 +559,7 @@ fd_system_program_exec_transfer_with_seed( fd_exec_instr_ctx_t * /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L410 */ if( FD_UNLIKELY( fd_exec_instr_ctx_check_num_insn_accounts( ctx, 3UL ) ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.22/programs/system/src/system_processor.rs#L411-L421 Inlined call to system_processor::transfer_with_seed */ diff --git a/src/flamenco/runtime/program/fd_system_program_nonce.c b/src/flamenco/runtime/program/fd_system_program_nonce.c index 5dbc74ab28f..fc406feb3a5 100644 --- a/src/flamenco/runtime/program/fd_system_program_nonce.c +++ b/src/flamenco/runtime/program/fd_system_program_nonce.c @@ -246,7 +246,7 @@ fd_system_program_exec_advance_nonce_account( fd_exec_instr_ctx_t * ctx ) { /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L423-L441 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L425-L426 */ @@ -470,7 +470,7 @@ fd_system_program_exec_withdraw_nonce_account( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L443 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 2 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L445-L449 */ @@ -615,7 +615,7 @@ fd_system_program_exec_initialize_nonce_account( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L463 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L464-L465 */ @@ -781,7 +781,7 @@ fd_system_program_exec_authorize_nonce_account( fd_exec_instr_ctx_t * ctx, /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L483 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L484-L485 */ @@ -812,7 +812,7 @@ fd_system_program_exec_upgrade_nonce_account( fd_exec_instr_ctx_t * ctx ) { /* https://github.com/solana-labs/solana/blob/v1.17.23/programs/system/src/system_processor.rs#L489 */ if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; /* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/system/src/system_processor.rs#L474-475 */ diff --git a/src/flamenco/runtime/program/fd_vote_program.c b/src/flamenco/runtime/program/fd_vote_program.c index 2144fc06d61..a9a75626ff8 100644 --- a/src/flamenco/runtime/program/fd_vote_program.c +++ b/src/flamenco/runtime/program/fd_vote_program.c @@ -223,6 +223,19 @@ authorized_voters_new( ulong epoch, return authorized_voters; } +// Helper to create an empty AuthorizedVoters structure (for default/uninitialized states) +static fd_vote_authorized_voters_t * +authorized_voters_new_empty( uchar * mem ) { + FD_SCRATCH_ALLOC_INIT( l, mem ); + fd_vote_authorized_voters_t * authorized_voters = FD_SCRATCH_ALLOC_APPEND( l, fd_vote_authorized_voters_align(), sizeof(fd_vote_authorized_voters_t) ); + void * pool_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_vote_authorized_voters_pool_align(), fd_vote_authorized_voters_pool_footprint( FD_VOTE_AUTHORIZED_VOTERS_MIN ) ); + void * treap_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_vote_authorized_voters_treap_align(), fd_vote_authorized_voters_treap_footprint( FD_VOTE_AUTHORIZED_VOTERS_MIN ) ); + + authorized_voters->pool = fd_vote_authorized_voters_pool_join( fd_vote_authorized_voters_pool_new( pool_mem, FD_VOTE_AUTHORIZED_VOTERS_MIN ) ); + authorized_voters->treap = fd_vote_authorized_voters_treap_join( fd_vote_authorized_voters_treap_new( treap_mem, FD_VOTE_AUTHORIZED_VOTERS_MIN ) ); + return authorized_voters; +} + static inline int authorized_voters_is_empty( fd_vote_authorized_voters_t * self ) { return fd_vote_authorized_voters_treap_ele_cnt( self->treap ) == 0; @@ -394,9 +407,23 @@ convert_to_current( fd_vote_state_versioned_t * self, // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/vote_state_versions.rs#L19 case fd_vote_state_versioned_enum_v0_23_5: { fd_vote_state_0_23_5_t * state = &self->inner.v0_23_5; - // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/vote_state_versions.rs#L21 - fd_vote_authorized_voters_t * authorized_voters = authorized_voters_new( - state->authorized_voter_epoch, &state->authorized_voter, authorized_voters_mem ); + // Check if uninitialized (authorized_voter is all zeros) + int is_uninitialized = 1; + for( ulong i = 0; i < sizeof(fd_pubkey_t); i++ ) { + if( state->authorized_voter.uc[i] != 0 ) { + is_uninitialized = 0; + break; + } + } + + fd_vote_authorized_voters_t * authorized_voters; + if( is_uninitialized ) { + // Create empty AuthorizedVoters (default), initialized but with no entries + authorized_voters = authorized_voters_new_empty( authorized_voters_mem ); + } else { + authorized_voters = authorized_voters_new( + state->authorized_voter_epoch, &state->authorized_voter, authorized_voters_mem ); + } /* Temporary to hold current */ // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/vote_state_versions.rs#L23 @@ -2219,7 +2246,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { // https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_processor.rs#L64 if( FD_UNLIKELY( ctx->instr->acct_cnt < 1 ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } fd_guarded_borrowed_account_t me = {0}; @@ -2345,7 +2372,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { case fd_vote_instruction_enum_authorize_with_seed: { // https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_processor.rs#L99 if( FD_UNLIKELY( ctx->instr->acct_cnt < 3 ) ) { - rc = FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + rc = FD_EXECUTOR_INSTR_ERR_MISSING_ACC; break; } @@ -2377,7 +2404,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { // https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_processor.rs#L112 if( FD_UNLIKELY( ctx->instr->acct_cnt < 4 ) ) { - rc = FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + rc = FD_EXECUTOR_INSTR_ERR_MISSING_ACC; break; } @@ -2418,7 +2445,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { case fd_vote_instruction_enum_update_validator_identity: { // https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_processor.rs#L131 if( FD_UNLIKELY( ctx->instr->acct_cnt < 2 ) ) { - rc = FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + rc = FD_EXECUTOR_INSTR_ERR_MISSING_ACC; break; } @@ -2675,7 +2702,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { */ case fd_vote_instruction_enum_withdraw: { if( FD_UNLIKELY( ctx->instr->acct_cnt < 2 ) ) { - rc = FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + rc = FD_EXECUTOR_INSTR_ERR_MISSING_ACC; break; } fd_rent_t rent_; @@ -2712,7 +2739,7 @@ fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ) { */ case fd_vote_instruction_enum_authorize_checked: { if( FD_UNLIKELY( ctx->instr->acct_cnt < 4 ) ) { - rc = FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + rc = FD_EXECUTOR_INSTR_ERR_MISSING_ACC; break; } diff --git a/src/flamenco/runtime/program/zksdk/fd_zksdk.c b/src/flamenco/runtime/program/zksdk/fd_zksdk.c index 1d2a9586a21..6e0813aa936 100644 --- a/src/flamenco/runtime/program/zksdk/fd_zksdk.c +++ b/src/flamenco/runtime/program/zksdk/fd_zksdk.c @@ -53,6 +53,12 @@ fd_zksdk_process_close_context_state( fd_exec_instr_ctx_t * ctx ) { https://github.com/anza-xyz/agave/blob/master/programs/zk-elgamal-proof/src/lib.rs#L153-L154 */ FD_TRY_BORROW_INSTR_ACCOUNT_DEFAULT_ERR_CHECK(ctx, ACC_IDX_PROOF, &proof_acc ); + /* Check that the proof context account is owned by the zk-elgamal-proof program + https://github.com/anza-xyz/agave/blob/v3.1.0-beta.0/programs/zk-elgamal-proof/src/lib.rs#167-L171 */ + if( FD_UNLIKELY( !fd_memeq( fd_borrowed_account_get_owner( &proof_acc ), &fd_solana_zk_elgamal_proof_program_id, sizeof(fd_pubkey_t) ) ) ) { + return FD_EXECUTOR_INSTR_ERR_INVALID_ACC_OWNER; + } + /* https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L161-L162 Note: data also contains context data, but we only need the initial 33 bytes. */ if( FD_UNLIKELY( fd_borrowed_account_get_data_len( &proof_acc ) < sizeof(fd_zksdk_proof_ctx_state_meta_t) ) ) { @@ -60,6 +66,13 @@ fd_zksdk_process_close_context_state( fd_exec_instr_ctx_t * ctx ) { } fd_zksdk_proof_ctx_state_meta_t const * proof_ctx_state_meta = fd_type_pun_const( fd_borrowed_account_get_data( &proof_acc ) ); + /* Check that the proof context account is initialized (proof_type != 0) + ProofType::Uninitialized = 0 + https://github.com/anza-xyz/agave/blob/v3.1.0-beta.0/programs/zk-elgamal-proof/src/lib.rs#L161-L165 */ + if( FD_UNLIKELY( proof_ctx_state_meta->proof_type == 0 ) ) { + return FD_EXECUTOR_INSTR_ERR_UNINITIALIZED_ACCOUNT; + } + /* https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L155 */ fd_pubkey_t const * expected_owner_addr = &proof_ctx_state_meta->ctx_state_authority; @@ -213,13 +226,13 @@ fd_zksdk_process_verify_proof( fd_exec_instr_ctx_t * ctx ) { return FD_EXECUTOR_INSTR_ERR_INVALID_INSTR_DATA; } - /* Create context state if accounts are provided with the instruction - https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L92 */ - if( instr_acc_cnt > accessed_accounts ) { - fd_pubkey_t context_state_authority[1]; - + /* Create context state if we have both proof_context and authority accounts. + https://github.com/anza-xyz/agave/blob/v3.1.0-beta.0/programs/zk-elgamal-proof/src/lib.rs#L102-L106 */ + if( instr_acc_cnt >= accessed_accounts + 2UL ) { /* Obtain the context_state_authority by borrowing the account temporarily in a local scope. - https://github.com/anza-xyz/agave/blob/v2.1.14/programs/zk-elgamal-proof/src/lib.rs#L94-L99 */ + https://github.com/anza-xyz/agave/blob/v2.1.14/programs/zk-elgamal-proof/src/lib.rs#L94-L99 + https://github.com/anza-xyz/agave/blob/v3.1.0-beta.0/programs/zk-elgamal-proof/src/lib.rs#L107-L110 */ + fd_pubkey_t context_state_authority[1]; do { fd_guarded_borrowed_account_t _acc = {0}; FD_TRY_BORROW_INSTR_ACCOUNT_DEFAULT_ERR_CHECK( ctx, (ushort)(accessed_accounts+1), &_acc ); @@ -250,6 +263,13 @@ fd_zksdk_process_verify_proof( fd_exec_instr_ctx_t * ctx ) { return FD_EXECUTOR_INSTR_ERR_INVALID_ACC_DATA; } + /* Check writability for any account that passes validation. + Even with just 1 account, if it passes owner and data checks, it must be writable. + https://github.com/anza-xyz/agave/blob/v3.1.0-beta.0/programs/zk-elgamal-proof/src/lib.rs#L112-L113 */ + if( FD_UNLIKELY( !fd_instr_acc_is_writable_idx( ctx->instr, accessed_accounts ) ) ) { + return FD_EXECUTOR_INSTR_ERR_READONLY_DATA_MODIFIED; + } + /* https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L121 */ fd_memcpy( buffer, context_state_authority, sizeof(fd_pubkey_t) ); // buffer[0..31] buffer[ 32 ] = instr_id; // buffer[32] diff --git a/src/flamenco/runtime/sysvar/fd_sysvar.c b/src/flamenco/runtime/sysvar/fd_sysvar.c index af5fcb4212a..8414b19aea9 100644 --- a/src/flamenco/runtime/sysvar/fd_sysvar.c +++ b/src/flamenco/runtime/sysvar/fd_sysvar.c @@ -62,7 +62,7 @@ fd_sysvar_instr_acct_check( fd_exec_instr_ctx_t const * ctx, fd_pubkey_t const * addr_want ) { if( FD_UNLIKELY( idx >= ctx->instr->acct_cnt ) ) { - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } ushort idx_in_txn = ctx->instr->accounts[idx].index_in_transaction; diff --git a/src/flamenco/runtime/tests/run_backtest_all.sh b/src/flamenco/runtime/tests/run_backtest_all.sh index 3f2d42f26e3..511861a16d1 100755 --- a/src/flamenco/runtime/tests/run_backtest_all.sh +++ b/src/flamenco/runtime/tests/run_backtest_all.sh @@ -85,8 +85,8 @@ src/flamenco/runtime/tests/run_ledger_backtest.sh -l multi-bpf-loader-v2.3.0 -y src/flamenco/runtime/tests/run_ledger_backtest.sh -l local-multi-boundary -y 1 -m 1000 -e 2325 src/flamenco/runtime/tests/run_ledger_backtest.sh -l genesis-v3.0 -y 1 -m 3000 -e 1280 -g src/flamenco/runtime/tests/run_ledger_backtest.sh -l localnet-stake-v3.0.0 -y 1 -m 3000 -e 541 -src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-stricter-abi -y 5 -m 2000000 -e 368528527 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM -src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-direct-mapping -y 5 -m 2000000 -e 368528527 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM,9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ -src/flamenco/runtime/tests/run_ledger_backtest.sh -l testnet-362107883-direct-mapping-2 -y 1 -m 2000000 -e 362219427 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM,9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ +src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-stricter-abi -y 5 -m 2000000 -e 368528527 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r +src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-direct-mapping -y 5 -m 2000000 -e 368528527 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r,DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA +src/flamenco/runtime/tests/run_ledger_backtest.sh -l testnet-362107883-direct-mapping-2 -y 1 -m 2000000 -e 362219427 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r,DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA src/flamenco/runtime/tests/run_ledger_backtest.sh -l devnet-413869565 -y 40 -m 100000000 -e 413869600 src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-376969880 -y 1 -m 2000000 -e 376969900 diff --git a/src/flamenco/runtime/tests/run_backtest_ci.sh b/src/flamenco/runtime/tests/run_backtest_ci.sh index 3778629e2a1..72bd2ef5ba8 100755 --- a/src/flamenco/runtime/tests/run_backtest_ci.sh +++ b/src/flamenco/runtime/tests/run_backtest_ci.sh @@ -26,6 +26,6 @@ src/flamenco/runtime/tests/run_ledger_backtest.sh -l devnet-380592002-v2.3.0 -y src/flamenco/runtime/tests/run_ledger_backtest.sh -l local-multi-boundary -y 1 -m 1000 -e 2325 src/flamenco/runtime/tests/run_ledger_backtest.sh -l genesis-v3.0 -y 1 -m 3000 -e 1280 -g src/flamenco/runtime/tests/run_ledger_backtest.sh -l localnet-stake-v3.0.0 -y 1 -m 3000 -e 541 -src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-stricter-abi -y 5 -m 2000000 -e 368528527 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM -src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-direct-mapping -y 5 -m 2000000 -e 368528527 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM,9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ -src/flamenco/runtime/tests/run_ledger_backtest.sh -l testnet-362107883-direct-mapping-2 -y 1 -m 2000000 -e 362219427 -o CxeBn9PVeeXbmjbNwLv6U4C6svNxnC4JX6mfkvgeMocM,9s3RKimHWS44rJcJ9P1rwCmn2TvMqtZQBmz815ZUUHqJ +src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-stricter-abi -y 5 -m 2000000 -e 368528527 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r +src/flamenco/runtime/tests/run_ledger_backtest.sh -l mainnet-368528500-direct-mapping -y 5 -m 2000000 -e 368528527 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r,DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA +src/flamenco/runtime/tests/run_ledger_backtest.sh -l testnet-362107883-direct-mapping-2 -y 1 -m 2000000 -e 362219427 -o sD3uVpaavUXQRvDXrMFCQ2CqLqnbz5mK8ttWNXbtD3r,DFN8MyKpQqFW31qczcahgnnxcAHQc6P94wtTEX5EP1RA diff --git a/src/flamenco/vm/syscall/fd_vm_syscall_cpi.c b/src/flamenco/vm/syscall/fd_vm_syscall_cpi.c index 2d93707115d..7a1693e82da 100644 --- a/src/flamenco/vm/syscall/fd_vm_syscall_cpi.c +++ b/src/flamenco/vm/syscall/fd_vm_syscall_cpi.c @@ -105,8 +105,8 @@ fd_vm_prepare_instruction( fd_instr_info_t * callee_instr, /* TODO: this code would maybe be easier to read if we inverted the branches */ if( duplicate_index!=ULONG_MAX ) { if ( FD_UNLIKELY( duplicate_index >= deduplicated_instruction_accounts_cnt ) ) { - FD_TXN_ERR_FOR_LOG_INSTR( instr_ctx->txn_ctx, FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS, instr_ctx->txn_ctx->err.exec_err_idx ); - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + FD_TXN_ERR_FOR_LOG_INSTR( instr_ctx->txn_ctx, FD_EXECUTOR_INSTR_ERR_MISSING_ACC, instr_ctx->txn_ctx->err.exec_err_idx ); + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } duplicate_indices[duplicate_indicies_cnt++] = duplicate_index; @@ -170,8 +170,8 @@ fd_vm_prepare_instruction( fd_instr_info_t * callee_instr, callee_instr->accounts[i].is_writable = !!(instruction_accounts[i].is_writable); callee_instr->accounts[i].is_signer = !!(instruction_accounts[i].is_signer); } else { - FD_TXN_ERR_FOR_LOG_INSTR( instr_ctx->txn_ctx, FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS, instr_ctx->txn_ctx->err.exec_err_idx ); - return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS; + FD_TXN_ERR_FOR_LOG_INSTR( instr_ctx->txn_ctx, FD_EXECUTOR_INSTR_ERR_MISSING_ACC, instr_ctx->txn_ctx->err.exec_err_idx ); + return FD_EXECUTOR_INSTR_ERR_MISSING_ACC; } }