File tree 3 files changed +21
-8
lines changed
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ fn execute_allocate_large_memory() {
412
412
// Gas consumption is relatively small
413
413
// Note: the exact gas usage depends on the Rust version used to compile Wasm,
414
414
// which we only fix when using rust-optimizer, not integration tests.
415
- assert_approx_eq ! ( gas_used, 4413600 , "0.2" ) ;
415
+ assert_approx_eq ! ( gas_used, 9470400 , "0.2" ) ;
416
416
let used = deps. memory_pages ( ) ;
417
417
assert_eq ! ( used, pages_before + 48 , "Memory used: {used} pages" ) ;
418
418
pages_before += 48 ;
@@ -431,7 +431,7 @@ fn execute_allocate_large_memory() {
431
431
// Gas consumption is relatively small
432
432
// Note: the exact gas usage depends on the Rust version used to compile Wasm,
433
433
// which we only fix when using rust-optimizer, not integration tests.
434
- let expected = 4859700 ; // +/- 20%
434
+ let expected = 9553320 ; // +/- 20%
435
435
assert ! ( gas_used > expected * 80 / 100 , "Gas used: {gas_used}" ) ;
436
436
assert ! ( gas_used < expected * 120 / 100 , "Gas used: {gas_used}" ) ;
437
437
let used = deps. memory_pages ( ) ;
Original file line number Diff line number Diff line change @@ -858,7 +858,7 @@ mod tests {
858
858
859
859
let report2 = instance. create_gas_report ( ) ;
860
860
assert_eq ! ( report2. used_externally, 251 ) ;
861
- assert_eq ! ( report2. used_internally, 8461548 ) ;
861
+ assert_eq ! ( report2. used_internally, 15479658 ) ;
862
862
assert_eq ! ( report2. limit, LIMIT ) ;
863
863
assert_eq ! (
864
864
report2. remaining,
@@ -1049,7 +1049,7 @@ mod tests {
1049
1049
. unwrap ( ) ;
1050
1050
1051
1051
let init_used = orig_gas - instance. get_gas_left ( ) ;
1052
- assert_eq ! ( init_used, 8461799 ) ;
1052
+ assert_eq ! ( init_used, 15479909 ) ;
1053
1053
}
1054
1054
1055
1055
#[ test]
@@ -1074,7 +1074,7 @@ mod tests {
1074
1074
. unwrap ( ) ;
1075
1075
1076
1076
let execute_used = gas_before_execute - instance. get_gas_left ( ) ;
1077
- assert_eq ! ( execute_used, 11181706 ) ;
1077
+ assert_eq ! ( execute_used, 20477581 ) ;
1078
1078
}
1079
1079
1080
1080
#[ test]
@@ -1117,6 +1117,6 @@ mod tests {
1117
1117
) ;
1118
1118
1119
1119
let query_used = gas_before_query - instance. get_gas_left ( ) ;
1120
- assert_eq ! ( query_used, 7142556 ) ;
1120
+ assert_eq ! ( query_used, 12737176 ) ;
1121
1121
}
1122
1122
}
Original file line number Diff line number Diff line change @@ -20,14 +20,27 @@ use super::limiting_tunables::LimitingTunables;
20
20
/// https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md
21
21
const MAX_WASM_PAGES : u32 = 65536 ;
22
22
23
- fn cost ( _operator : & Operator ) -> u64 {
23
+ fn cost ( operator : & Operator ) -> u64 {
24
24
// A flat fee for each operation
25
25
// The target is 1 Teragas per second (see GAS.md).
26
26
//
27
27
// In https://github.com/CosmWasm/cosmwasm/pull/1042 a profiler is developed to
28
28
// identify runtime differences between different Wasm operation, but this is not yet
29
29
// precise enough to derive insights from it.
30
- 150
30
+ const GAS_PER_OPERATION : u64 = 115 ;
31
+
32
+ match operator {
33
+ Operator :: Loop { .. }
34
+ | Operator :: End
35
+ | Operator :: Else
36
+ | Operator :: Br { .. }
37
+ | Operator :: BrTable { .. }
38
+ | Operator :: BrIf { .. }
39
+ | Operator :: Call { .. }
40
+ | Operator :: CallIndirect { .. }
41
+ | Operator :: Return => GAS_PER_OPERATION * 14 ,
42
+ _ => GAS_PER_OPERATION ,
43
+ }
31
44
}
32
45
33
46
/// Creates an engine without a compiler.
You can’t perform that action at this time.
0 commit comments