Skip to content

Commit 40b9f6c

Browse files
michael-weigeltMichael Weigelt
andauthored
fix: [EXC-1842] Charge for ic0_cycles_burn128 (dfinity#3542)
Co-authored-by: Michael Weigelt <[email protected]>
1 parent 82576ad commit 40b9f6c

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

rs/embedders/src/wasmtime_embedder/system_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ pub fn syscalls<
12051205
linker
12061206
.func_wrap("ic0", "cycles_burn128", {
12071207
move |mut caller: Caller<'_, StoreData>, amount_high: u64, amount_low: u64, dst: I| {
1208+
charge_for_cpu(&mut caller, overhead::CYCLES_BURN128)?;
12081209
with_memory_and_system_api(&mut caller, |s, memory| {
12091210
let dst: usize = dst.try_into().expect("Failed to convert I to usize");
12101211
s.ic0_cycles_burn128(Cycles::from_parts(amount_high, amount_low), dst, memory)

rs/embedders/src/wasmtime_embedder/system_api_complexity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub mod overhead {
2525
pub const CALL_ON_CLEANUP: NumInstructions = NumInstructions::new(500);
2626
pub const CALL_PERFORM: NumInstructions = NumInstructions::new(5_000);
2727
pub const CALL_WITH_BEST_EFFORT_RESPONSE: NumInstructions = NumInstructions::new(500);
28+
pub const CYCLES_BURN128: NumInstructions = NumInstructions::new(500);
2829
pub const CANISTER_CYCLE_BALANCE: NumInstructions = NumInstructions::new(500);
2930
pub const CANISTER_CYCLE_BALANCE128: NumInstructions = NumInstructions::new(500);
3031
pub const CANISTER_SELF_COPY: NumInstructions = NumInstructions::new(500);

rs/execution_environment/benches/system_api/execute_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ pub fn execute_update_bench(c: &mut Criterion) {
946946
Result::No,
947947
Wasm64::Disabled,
948948
),
949-
19000006,
949+
519000006,
950950
),
951951
common::Benchmark(
952952
"wasm64/ic0_cycles_burn128()".into(),
@@ -956,7 +956,7 @@ pub fn execute_update_bench(c: &mut Criterion) {
956956
Result::No,
957957
Wasm64::Enabled,
958958
),
959-
19000006,
959+
519000006,
960960
),
961961
common::Benchmark(
962962
"wasm32/ic0_msg_deadline()".into(),

0 commit comments

Comments
 (0)