Skip to content

Commit

Permalink
Adds ABIv2 de/serialization interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Oct 9, 2024
1 parent 50d13d1 commit 8b97af6
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 21 deletions.
3 changes: 2 additions & 1 deletion ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
.transaction_context
.get_current_instruction_context()
.unwrap(),
true, // copy_account_data
true, // copy_account_data
false, // is_abi_v2
)
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub fn invoke_builtin_function(
transaction_context,
instruction_context,
true, // copy_account_data // There is no VM so direct mapping can not be implemented here
false, // is_abi_v2
)?;

// Deserialize data back into instruction params
Expand Down
18 changes: 12 additions & 6 deletions programs/bpf_loader/benches/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ fn bench_serialize_unaligned(bencher: &mut Bencher) {
.get_current_instruction_context()
.unwrap();
bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, false).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, false, false).unwrap();
});
}

Expand All @@ -137,7 +138,8 @@ fn bench_serialize_unaligned_copy_account_data(bencher: &mut Bencher) {
.get_current_instruction_context()
.unwrap();
bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, true).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, true, false).unwrap();
});
}

Expand All @@ -149,7 +151,8 @@ fn bench_serialize_aligned(bencher: &mut Bencher) {
.unwrap();

bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, false).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, false, false).unwrap();
});
}

Expand All @@ -161,7 +164,8 @@ fn bench_serialize_aligned_copy_account_data(bencher: &mut Bencher) {
.unwrap();

bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, true).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, true, false).unwrap();
});
}

Expand All @@ -172,7 +176,8 @@ fn bench_serialize_unaligned_max_accounts(bencher: &mut Bencher) {
.get_current_instruction_context()
.unwrap();
bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, false).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, false, false).unwrap();
});
}

Expand All @@ -184,6 +189,7 @@ fn bench_serialize_aligned_max_accounts(bencher: &mut Bencher) {
.unwrap();

bencher.iter(|| {
let _ = serialize_parameters(&transaction_context, instruction_context, false).unwrap();
let _ =
serialize_parameters(&transaction_context, instruction_context, false, false).unwrap();
});
}
2 changes: 2 additions & 0 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,7 @@ pub fn execute<'a, 'b: 'a>(
invoke_context.transaction_context,
instruction_context,
!direct_mapping,
false,
)?;
serialize_time.stop();

Expand Down Expand Up @@ -1488,6 +1489,7 @@ pub fn execute<'a, 'b: 'a>(
.transaction_context
.get_current_instruction_context()?,
copy_account_data,
false,
parameter_bytes,
&invoke_context.get_syscall_context()?.accounts_metadata,
)
Expand Down
Loading

0 comments on commit 8b97af6

Please sign in to comment.