Skip to content

Commit 3aa95f5

Browse files
wip
1 parent 717951c commit 3aa95f5

File tree

98 files changed

+8291
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+8291
-80
lines changed

src/flamenco/runtime/program/Local.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ $(call add-objs,fd_zk_elgamal_proof_program,fd_flamenco)
4848

4949
$(call add-hdrs,fd_native_cpi.h)
5050
$(call add-objs,fd_native_cpi,fd_flamenco)
51+
52+
### Unit tests
53+
54+
$(call make-unit-test,test_bpf_loader_serialization,test_bpf_loader_serialization,fd_flamenco fd_funk fd_ballet fd_util)
55+
$(call run-unit-test,test_bpf_loader_serialization)

src/flamenco/runtime/program/fd_bpf_loader_program.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,19 +402,17 @@ fd_bpf_execute( fd_exec_instr_ctx_t * instr_ctx,
402402
int provide_instruction_data_offset_in_vm_r2 = FD_FEATURE_ACTIVE_BANK( instr_ctx->bank, provide_instruction_data_offset_in_vm_r2 );
403403

404404
ulong instruction_data_offset = 0UL;
405-
uchar * input = NULL;
406-
err = fd_bpf_loader_input_serialize_parameters( instr_ctx, &input_sz, pre_lens,
405+
/* 16-byte aligned buffer:
406+
https://github.com/anza-xyz/agave/blob/v3.0.0/program-runtime/src/serialization.rs#L60 */
407+
uchar * input = instr_ctx->runtime->bpf_loader_serialization.serialization_mem[ instr_ctx->runtime->instr.stack_sz-1UL ];
408+
err = fd_bpf_loader_input_serialize_parameters( instr_ctx, pre_lens,
407409
input_mem_regions, &input_mem_regions_cnt,
408410
acc_region_metas, stricter_abi_and_runtime_constraints, direct_mapping, is_deprecated,
409-
&instruction_data_offset, &input );
411+
&instruction_data_offset, &input_sz, input );
410412
if( FD_UNLIKELY( err ) ) {
411413
return err;
412414
}
413415

414-
if( FD_UNLIKELY( input==NULL ) ) {
415-
return FD_EXECUTOR_INSTR_ERR_MISSING_ACC;
416-
}
417-
418416
fd_sha256_t _sha[1];
419417
fd_sha256_t * sha = fd_sha256_join( fd_sha256_new( _sha ) );
420418

@@ -437,7 +435,7 @@ fd_bpf_execute( fd_exec_instr_ctx_t * instr_ctx,
437435
instr_ctx->runtime->log.capture_ctx->dump_syscall_to_pb;
438436

439437
/* https://github.com/anza-xyz/agave/blob/v3.1.1/programs/bpf_loader/src/lib.rs#L1525-L1528 */
440-
ulong r2_initial_value = provide_instruction_data_offset_in_vm_r2 ? FD_VM_MEM_MAP_INPUT_REGION_START + instruction_data_offset : 0UL;
438+
ulong r2_initial_value = provide_instruction_data_offset_in_vm_r2 ? instruction_data_offset : 0UL;
441439

442440
/* TODO: (topointon): correctly set check_size in vm setup */
443441
vm = fd_vm_init(

src/flamenco/runtime/program/fd_bpf_loader_serialization.c

Lines changed: 78 additions & 49 deletions
Large diffs are not rendered by default.

src/flamenco/runtime/program/fd_bpf_loader_serialization.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ FD_PROTOTYPES_BEGIN
1010

1111
int
1212
fd_bpf_loader_input_serialize_parameters( fd_exec_instr_ctx_t * instr_ctx,
13-
ulong * sz,
1413
ulong * pre_lens,
1514
fd_vm_input_region_t * input_mem_regions,
1615
uint * input_mem_regions_cnt,
@@ -19,7 +18,8 @@ fd_bpf_loader_input_serialize_parameters( fd_exec_instr_ctx_t * instr_ctx,
1918
int direct_mapping,
2019
uchar is_deprecated,
2120
ulong * instr_data_offset,
22-
uchar ** out /* output */ );
21+
ulong * out_sz,
22+
uchar * out );
2323

2424
int
2525
fd_bpf_loader_input_deserialize_parameters( fd_exec_instr_ctx_t * ctx,

0 commit comments

Comments
 (0)