@@ -262,7 +262,8 @@ fd_bpf_loader_input_serialize_aligned( fd_exec_instr_ctx_t * ctx,
262262 uint * input_mem_regions_cnt ,
263263 fd_vm_acc_region_meta_t * acc_region_metas ,
264264 int stricter_abi_and_runtime_constraints ,
265- int direct_mapping ) {
265+ int direct_mapping ,
266+ ulong * instr_data_offset ) {
266267 fd_pubkey_t * txn_accs = ctx -> txn_out -> accounts .account_keys ;
267268
268269 uchar acc_idx_seen [ FD_INSTR_ACCT_MAX ] = {0 };
@@ -381,6 +382,14 @@ fd_bpf_loader_input_serialize_aligned( fd_exec_instr_ctx_t * ctx,
381382 FD_STORE ( ulong , serialized_params , instr_data_len );
382383 serialized_params += sizeof (ulong );
383384
385+ /* https://github.com/anza-xyz/agave/blob/v3.1.1/program-runtime/src/serialization.rs#L568 */
386+ ulong region_vaddr_offset = 0UL ;
387+ if ( * input_mem_regions_cnt > 0 ) {
388+ region_vaddr_offset = input_mem_regions [* input_mem_regions_cnt - 1U ].vaddr_offset +
389+ input_mem_regions [* input_mem_regions_cnt - 1U ].address_space_reserved ;
390+ }
391+ * instr_data_offset = region_vaddr_offset + (ulong )(serialized_params - curr_serialized_params_start );
392+
384393 /* https://github.com/anza-xyz/agave/blob/v3.0.0/program-runtime/src/serialization.rs#L559 */
385394 uchar * instr_data = ctx -> instr -> data ;
386395 fd_memcpy ( serialized_params , instr_data , instr_data_len );
@@ -538,7 +547,8 @@ fd_bpf_loader_input_serialize_unaligned( fd_exec_instr_ctx_t * ctx,
538547 uint * input_mem_regions_cnt ,
539548 fd_vm_acc_region_meta_t * acc_region_metas ,
540549 int stricter_abi_and_runtime_constraints ,
541- int direct_mapping ) {
550+ int direct_mapping ,
551+ ulong * instr_data_offset ) {
542552 fd_pubkey_t const * txn_accs = ctx -> txn_out -> accounts .account_keys ;
543553
544554 uchar acc_idx_seen [FD_INSTR_ACCT_MAX ] = {0 };
@@ -623,6 +633,14 @@ fd_bpf_loader_input_serialize_unaligned( fd_exec_instr_ctx_t * ctx,
623633 FD_STORE ( ulong , serialized_params , instr_data_len );
624634 serialized_params += sizeof (ulong );
625635
636+ /* https://github.com/anza-xyz/agave/blob/v3.1.1/program-runtime/src/serialization.rs#L400 */
637+ ulong region_vaddr_offset = 0UL ;
638+ if ( * input_mem_regions_cnt > 0 ) {
639+ region_vaddr_offset = input_mem_regions [* input_mem_regions_cnt - 1U ].vaddr_offset +
640+ input_mem_regions [* input_mem_regions_cnt - 1U ].address_space_reserved ;
641+ }
642+ * instr_data_offset = region_vaddr_offset + (ulong )(serialized_params - curr_serialized_params_start );
643+
626644 uchar * instr_data = (uchar * )ctx -> instr -> data ;
627645 fd_memcpy ( serialized_params , instr_data , instr_data_len );
628646 serialized_params += instr_data_len ;
@@ -740,6 +758,7 @@ fd_bpf_loader_input_serialize_parameters( fd_exec_instr_ctx_t * instr_ctx,
740758 int stricter_abi_and_runtime_constraints ,
741759 int direct_mapping ,
742760 uchar is_deprecated ,
761+ ulong * instr_data_offset ,
743762 uchar * * out /* output */ ) {
744763
745764 /* https://github.com/anza-xyz/agave/blob/v3.0.0/program-runtime/src/serialization.rs#L234-L237 */
@@ -755,12 +774,12 @@ fd_bpf_loader_input_serialize_parameters( fd_exec_instr_ctx_t * instr_ctx,
755774 * out = fd_bpf_loader_input_serialize_unaligned ( instr_ctx , sz , pre_lens ,
756775 input_mem_regions , input_mem_regions_cnt ,
757776 acc_region_metas , stricter_abi_and_runtime_constraints ,
758- direct_mapping );
777+ direct_mapping , instr_data_offset );
759778 } else {
760779 * out = fd_bpf_loader_input_serialize_aligned ( instr_ctx , sz , pre_lens ,
761780 input_mem_regions , input_mem_regions_cnt ,
762781 acc_region_metas , stricter_abi_and_runtime_constraints ,
763- direct_mapping );
782+ direct_mapping , instr_data_offset );
764783 }
765784
766785 return FD_EXECUTOR_INSTR_SUCCESS ;
0 commit comments