Skip to content

Commit

Permalink
syscall_cpi_error: Fix a bunch of return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpsiegel committed Jul 12, 2024
1 parent e4f9d36 commit 91a8e41
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/flamenco/vm/syscall/fd_vm_syscall_cpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ fd_vm_prepare_instruction( fd_instr_info_t const * caller_instr,
}
if( index_in_transaction==USHORT_MAX) {
/* In this case the callee instruction is referencing an unknown account not listed in the
transactions accounts.
TODO: return InstructionError::MissingAccount */
return 1;
transactions accounts. */
return FD_EXECUTOR_INSTR_ERR_MISSING_ACC;
}

/* If there was an instruction account before this one which referenced the same
Expand All @@ -113,8 +112,7 @@ fd_vm_prepare_instruction( fd_instr_info_t const * caller_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 ) ) {
// TODO: return InstructionError::NotEnoughAccountKeys
return 1;
return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS;
}

duplicate_indices[duplicate_indicies_cnt++] = duplicate_index;
Expand All @@ -136,8 +134,7 @@ fd_vm_prepare_instruction( fd_instr_info_t const * caller_instr,
}

if( index_in_caller==USHORT_MAX ) {
/* TODO: return InstructionError::MissingAccount */
return 1;
return FD_EXECUTOR_INSTR_ERR_MISSING_ACC;
}

/* Add the instruction account to the duplicate indicies array */
Expand Down Expand Up @@ -186,8 +183,7 @@ fd_vm_prepare_instruction( fd_instr_info_t const * caller_instr,
( !!(instruction_accounts[i].is_writable) * FD_INSTR_ACCT_FLAGS_IS_WRITABLE ) |
( !!(instruction_accounts[i].is_signer ) * FD_INSTR_ACCT_FLAGS_IS_SIGNER ) );
} else {
// TODO: return InstructionError::NotEnoughAccountKeys
return 1;
return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS;
}
}

Expand All @@ -197,7 +193,7 @@ fd_vm_prepare_instruction( fd_instr_info_t const * caller_instr,
fd_borrowed_account_t * program_rec = NULL;
int err = fd_txn_borrowed_account_view( instr_ctx->txn_ctx, &callee_instr->program_id_pubkey, &program_rec );
if( FD_UNLIKELY( err ) ) {
return 1;
return FD_EXECUTOR_INSTR_ERR_MISSING_ACC;
}

if( FD_UNLIKELY( fd_account_find_idx_of_insn_account( instr_ctx, &callee_instr->program_id_pubkey )==-1 ) ) {
Expand Down

0 comments on commit 91a8e41

Please sign in to comment.