Skip to content

Commit

Permalink
fuzz: remove deprecated vm validate fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
mjain-jump committed Dec 12, 2024
1 parent 21245e8 commit 00c2974
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 449 deletions.
3 changes: 0 additions & 3 deletions contrib/test/run_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ cat contrib/test/test-vectors-fixtures/elf-loader-fixtures/*.list | xargs -P 4 -
LOG=$LOG_PATH/test_exec_instr
cat contrib/test/test-vectors-fixtures/instr-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_instr --log-path $LOG

LOG=$LOG_PATH/test_vm_validate
cat contrib/test/test-vectors-fixtures/vm-validate-fixtures/*.list | xargs -P 4 -n 1000 ./$OBJDIR/unit-test/test_exec_sol_compat --log-path $LOG

# check if ./$OBJDIR/unit-test/test_exec_sol_compat_stubbed exists
if [ -f ./$OBJDIR/unit-test/test_exec_sol_compat_stubbed ]; then
LOG=$LOG_PATH/test_exec_cpi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,6 @@ dump/test-vectors/instr/fixtures/address-lookup-table/crash-0f656dcd033e5a44b4a8
dump/test-vectors/instr/fixtures/address-lookup-table/crash-1f3cff85b351a070fa572e17f61439fff44d4eda.fix
dump/test-vectors/instr/fixtures/address-lookup-table/crash-3a1871a7a6c5bfbf761d9b5d493342f3be10dcbd.fix
dump/test-vectors/instr/fixtures/address-lookup-table/crash-68c04614af9e9bebe693e7e24f5c9a7e2778d402.fix
dump/test-vectors/instr/fixtures/address-lookup-table/crash-f2e925185043128e1cda0e21f2ab338321383ee4.fix
dump/test-vectors/instr/fixtures/address-lookup-table/d02c74e2066af419348b38fcb0378c848908966f_2789718.fix
dump/test-vectors/instr/fixtures/address-lookup-table/d04b7e66a20914710135a3188a8c2c41030e2abb_2789718.fix
dump/test-vectors/instr/fixtures/address-lookup-table/d05dc0007836b1079feead169b4e116f51f94153_2789718.fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ dump/test-vectors/instr/fixtures/stake/crash-ee9d61c57649c2eae4ada0e441af06c5d51
dump/test-vectors/instr/fixtures/stake/crash-eeeb2dee8366925a173368a7ca34a3ac6db9b4c3.fix
dump/test-vectors/instr/fixtures/stake/crash-f02bc78a2f9ad840fba3f688014fc2609ceec439.fix
dump/test-vectors/instr/fixtures/stake/crash-f06e9f3003ca1b182c09e7b4c05ecbae7ec626b4.fix
dump/test-vectors/instr/fixtures/stake/crash-f2e925185043128e1cda0e21f2ab338321383ee4.fix
dump/test-vectors/instr/fixtures/stake/crash-f45fe6d2812e3d454829a50c50a524add63c83b0.fix
dump/test-vectors/instr/fixtures/stake/crash-f59dab30dc88938ae9d2de5729efa76937242178.fix
dump/test-vectors/instr/fixtures/stake/crash-f6a94dfea4a0bc6488a9e3b5f2c56f4b3d514171.fix
Expand Down

This file was deleted.

62 changes: 1 addition & 61 deletions src/flamenco/runtime/tests/fd_exec_sol_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ sol_compat_txn_fixture( fd_exec_instr_test_runner_t * runner,

// Compare effects
fd_exec_test_txn_result_t * effects = (fd_exec_test_txn_result_t *) output;
int ok = sol_compat_cmp_txn( effects, &fixture->output );
int ok = sol_compat_cmp_txn( &fixture->output, effects );

// Cleanup
pb_release( &fd_exec_test_txn_fixture_t_msg, fixture );
Expand Down Expand Up @@ -566,29 +566,6 @@ sol_compat_vm_interp_fixture( fd_exec_instr_test_runner_t * runner,
return ok;
}

int
sol_compat_validate_vm_fixture( fd_exec_instr_test_runner_t * runner,
uchar const * in,
ulong in_sz ) {
// Decode fixture
fd_exec_test_validate_vm_fixture_t fixture[1] = {0};
if( !sol_compat_decode( &fixture, in, in_sz, &fd_exec_test_validate_vm_fixture_t_msg ) ) {
FD_LOG_WARNING(( "Invalid validate_vm fixture." ));
return 0;
}

// Execute
void * output = NULL;
sol_compat_execute_wrapper( runner, &fixture->input, &output, fd_exec_vm_validate_test_run );

// Compare effects
int ok = sol_compat_cmp_binary_strict( output, &fixture->output, &fd_exec_test_validate_vm_effects_t_msg );

// Cleanup
pb_release( &fd_exec_test_validate_vm_fixture_t_msg, fixture );
return ok;
}

/*
* execute_v1
*/
Expand Down Expand Up @@ -755,43 +732,6 @@ sol_compat_vm_syscall_execute_v1( uchar * out,
return ok;
}

int
sol_compat_vm_validate_v1( uchar * out,
ulong * out_sz,
uchar const * in,
ulong in_sz ) {
// Setup
ulong fmem[ 64 ];
fd_exec_instr_test_runner_t * runner = sol_compat_setup_scratch_and_runner( fmem );

// Decode context
fd_exec_test_full_vm_context_t input[1] = {0};
void * res = sol_compat_decode( &input, in, in_sz, &fd_exec_test_full_vm_context_t_msg );
if ( res==NULL ) {
sol_compat_cleanup_scratch_and_runner( runner );
return 0;
}

// Execute
void * output = NULL;
sol_compat_execute_wrapper( runner, input, &output, fd_exec_vm_validate_test_run );

// Encode effects
int ok = 0;
if( output ) {
ok = !!sol_compat_encode( out, out_sz, output, &fd_exec_test_validate_vm_effects_t_msg );
}

// cleanup
pb_release( &fd_exec_test_full_vm_context_t_msg, input );
sol_compat_cleanup_scratch_and_runner( runner );

// Check wksp usage is 0
sol_compat_check_wksp_usage();

return ok;
}

/* We still need a separate entrypoint since other harnesses (namely sfuzz-agave)
do something other than wrap their vm_syscall equivalent */
int
Expand Down
5 changes: 0 additions & 5 deletions src/flamenco/runtime/tests/fd_exec_sol_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ sol_compat_syscall_fixture( fd_exec_instr_test_runner_t * runner,
uchar const * in,
ulong in_sz );

int
sol_compat_validate_vm_fixture( fd_exec_instr_test_runner_t * runner,
uchar const * in,
ulong in_sz );

int
sol_compat_vm_interp_fixture( fd_exec_instr_test_runner_t * runner,
uchar const * in,
Expand Down
83 changes: 0 additions & 83 deletions src/flamenco/runtime/tests/fd_vm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,89 +28,6 @@ fd_vm_syscall_noop( void * _vm,
return 0;
}

ulong
fd_exec_vm_validate_test_run( fd_exec_instr_test_runner_t * runner,
void const * input_,
void ** output_,
void * output_buf,
ulong output_bufsz ) {
(void) runner;
fd_exec_test_full_vm_context_t const * input = fd_type_pun_const( input_ );
fd_exec_test_validate_vm_effects_t ** output = fd_type_pun( output_ );

if( FD_UNLIKELY( !input->has_vm_ctx ) ) {
return 0UL;
}

fd_exec_instr_ctx_t * ctx = test_vm_minimal_exec_instr_ctx( fd_libc_alloc_virtual() );

FD_TEST( output_bufsz >= sizeof(fd_exec_test_validate_vm_effects_t) );

/* Capture outputs */
FD_SCRATCH_ALLOC_INIT( l, output_buf );

fd_exec_test_validate_vm_effects_t * effects =
FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_exec_test_validate_vm_effects_t),
sizeof (fd_exec_test_validate_vm_effects_t) );
FD_SCRATCH_ALLOC_FINI( l, 1UL );

fd_valloc_t valloc = fd_scratch_virtual();
do{
fd_exec_test_vm_context_t const * vm_ctx = &input->vm_ctx;

/* Follows prost/solfuzz-agave behavior for empty bytes field */
uchar * rodata = NULL;
ulong rodata_sz = 0UL;
if( FD_LIKELY( vm_ctx->rodata ) ) {
rodata = vm_ctx->rodata->bytes;
rodata_sz = vm_ctx->rodata->size;
}

ulong * text = (ulong *) (rodata + vm_ctx->rodata_text_section_offset);
ulong text_cnt = vm_ctx->rodata_text_section_length / 8UL;

fd_vm_t * vm = fd_vm_join( fd_vm_new( fd_valloc_malloc( valloc, fd_vm_align(), fd_vm_footprint() ) ) );
FD_TEST( vm );

fd_vm_init(
vm,
ctx,
0, /* heap_max */
0, /* cu_avail */
rodata,
rodata_sz,
text,
text_cnt,
vm_ctx->rodata_text_section_offset,
vm_ctx->rodata_text_section_length,
0, /* entry_pc, not used in validate at the moment */
NULL, /* calldests */
TEST_VM_DEFAULT_SBPF_VERSION,
NULL, /* syscalls */
NULL, /* trace */
NULL, /* sha */
NULL, /* mem regions */
0, /* mem regions count */
NULL, /* mem regions accs */
0, /* is deprecated */
FD_FEATURE_ACTIVE( ctx->slot_ctx, bpf_account_data_direct_mapping ) /* direct mapping */
);
effects->result = fd_vm_validate( vm );

fd_valloc_free( valloc, fd_vm_delete( fd_vm_leave( vm ) ) );

} while(0);


/* Run vm validate and capture result */

effects->success = (effects->result == FD_VM_SUCCESS);
*output = effects;

test_vm_exec_instr_ctx_delete( ctx );
return sizeof (fd_exec_test_validate_vm_effects_t);
}

void
fd_setup_vm_acc_region_metas( fd_vm_acc_region_meta_t * acc_regions_meta,
fd_vm_t * vm,
Expand Down
8 changes: 0 additions & 8 deletions src/flamenco/runtime/tests/fd_vm_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
// void * output_buf,
// ulong output_bufsz );


ulong
fd_exec_vm_validate_test_run( fd_exec_instr_test_runner_t * runner,
void const * input_,
void ** output_,
void * output_buf,
ulong output_bufsz );

ulong
fd_exec_vm_interp_test_run( fd_exec_instr_test_runner_t * runner,
fd_exec_test_syscall_context_t const *input,
Expand Down
2 changes: 0 additions & 2 deletions src/flamenco/runtime/tests/test_exec_sol_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ run_test( fd_exec_instr_test_runner_t * runner,
ok = sol_compat_syscall_fixture( runner, buf, file_sz );
} else if( strstr( path, "/cpi/" ) != NULL ) {
ok = sol_compat_syscall_fixture( runner, buf, file_sz );
} else if( strstr( path, "/vm_validate/" ) != NULL ) {
ok = sol_compat_validate_vm_fixture( runner, buf, file_sz );
} else if( strstr( path, "/vm_interp/" ) != NULL ){
ok = sol_compat_vm_interp_fixture( runner, buf, file_sz );
} else {
Expand Down

0 comments on commit 00c2974

Please sign in to comment.