Skip to content

Commit

Permalink
flamenco: make transaction parsing errors return sanitize failure err…
Browse files Browse the repository at this point in the history
…or in test harness
  • Loading branch information
cali-jumptrading committed Jan 30, 2025
1 parent 6790db1 commit b75e740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2778,3 +2778,4 @@ dump/test-vectors/txn/fixtures/programs/2ab448fbadb0b964c56472758c7a46920f8591e5
dump/test-vectors/txn/fixtures/programs/e54e613fb6cab91a508bda54fff4d5ea2e238ee3_1777641.fix
dump/test-vectors/txn/fixtures/programs/b7d8956145950269da4dc2215fd6f149d1261e0b_1768662.fix
dump/test-vectors/txn/fixtures/programs/39376265439c3d3765a1a9b94d1beb3e643b6653_1769070.fix
dump/test-vectors/txn/fixtures/programs/a6d7f4390dadb86e7aa5414a054cc6e239eec615_1094896.fix
12 changes: 12 additions & 0 deletions src/flamenco/runtime/tests/fd_exec_instr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
/* Create the raw txn (https://solana.com/docs/core/transactions#transaction-size) */
uchar * txn_raw_begin = fd_scratch_alloc( alignof(uchar), 10000 ); // max txn size is 1232 but we allocate extra for safety
uchar * txn_raw_cur_ptr = txn_raw_begin;
int txn_parse_error = 0;

/* Compact array of signatures (https://solana.com/docs/core/transactions#transaction)
Note that although documentation interchangably refers to the signature cnt as a compact-u16
Expand Down Expand Up @@ -842,6 +843,11 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
// Compact array of 8-bit data
pb_bytes_array_t * data = test_ctx->tx.message.instructions[i].data;
if( data ) {
uint data_len_raw = data->size;
if( data_len_raw > USHORT_MAX ) {
txn_parse_error = -1;
}

ushort data_len = (ushort) data->size;
_add_compact_u16( &txn_raw_cur_ptr, data_len );
_add_to_data( &txn_raw_cur_ptr, data->bytes, data_len );
Expand Down Expand Up @@ -908,6 +914,12 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner,
/* Setup the spad for account allocation */
task_info->txn_ctx->spad = runner->spad;

/* Set the sanitize error if the txn was incorrectly formatted. */
if( txn_parse_error ) {
txn->flags = 0U;
task_info->exec_res = FD_RUNTIME_TXN_ERR_SANITIZE_FAILURE;
}

fd_runtime_pre_execute_check( task_info );

if( !task_info->exec_res ) {
Expand Down

0 comments on commit b75e740

Please sign in to comment.