File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
Expand file tree Collapse file tree 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() {
412412 // Gas consumption is relatively small
413413 // Note: the exact gas usage depends on the Rust version used to compile Wasm,
414414 // 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" ) ;
416416 let used = deps. memory_pages ( ) ;
417417 assert_eq ! ( used, pages_before + 48 , "Memory used: {used} pages" ) ;
418418 pages_before += 48 ;
@@ -431,7 +431,7 @@ fn execute_allocate_large_memory() {
431431 // Gas consumption is relatively small
432432 // Note: the exact gas usage depends on the Rust version used to compile Wasm,
433433 // which we only fix when using rust-optimizer, not integration tests.
434- let expected = 4859700 ; // +/- 20%
434+ let expected = 9553320 ; // +/- 20%
435435 assert ! ( gas_used > expected * 80 / 100 , "Gas used: {gas_used}" ) ;
436436 assert ! ( gas_used < expected * 120 / 100 , "Gas used: {gas_used}" ) ;
437437 let used = deps. memory_pages ( ) ;
Original file line number Diff line number Diff line change @@ -914,7 +914,7 @@ mod tests {
914914
915915 let report2 = instance. create_gas_report ( ) ;
916916 assert_eq ! ( report2. used_externally, 251 ) ;
917- assert_eq ! ( report2. used_internally, 11473730 ) ;
917+ assert_eq ! ( report2. used_internally, 16995280 ) ;
918918 assert_eq ! ( report2. limit, LIMIT ) ;
919919 assert_eq ! (
920920 report2. remaining,
@@ -1105,7 +1105,7 @@ mod tests {
11051105 . unwrap ( ) ;
11061106
11071107 let init_used = orig_gas - instance. get_gas_left ( ) ;
1108- assert_eq ! ( init_used, 11473981 ) ;
1108+ assert_eq ! ( init_used, 16995531 ) ;
11091109 }
11101110
11111111 #[ test]
@@ -1130,7 +1130,7 @@ mod tests {
11301130 . unwrap ( ) ;
11311131
11321132 let execute_used = gas_before_execute - instance. get_gas_left ( ) ;
1133- assert_eq ! ( execute_used, 12086566 ) ;
1133+ assert_eq ! ( execute_used, 19589666 ) ;
11341134 }
11351135
11361136 #[ test]
@@ -1173,6 +1173,6 @@ mod tests {
11731173 ) ;
11741174
11751175 let query_used = gas_before_query - instance. get_gas_left ( ) ;
1176- assert_eq ! ( query_used, 7570446 ) ;
1176+ assert_eq ! ( query_used, 11942871 ) ;
11771177 }
11781178}
Original file line number Diff line number Diff line change @@ -16,14 +16,27 @@ use super::limiting_tunables::LimitingTunables;
1616/// https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md
1717const MAX_WASM_PAGES : u32 = 65536 ;
1818
19- fn cost ( _operator : & Operator ) -> u64 {
19+ fn cost ( operator : & Operator ) -> u64 {
2020 // A flat fee for each operation
2121 // The target is 1 Teragas per second (see GAS.md).
2222 //
2323 // In https://github.com/CosmWasm/cosmwasm/pull/1042 a profiler is developed to
2424 // identify runtime differences between different Wasm operation, but this is not yet
2525 // precise enough to derive insights from it.
26- 170
26+ const GAS_PER_OPERATION : u64 = 115 ;
27+
28+ match operator {
29+ Operator :: Loop { .. }
30+ | Operator :: End
31+ | Operator :: Else
32+ | Operator :: Br { .. }
33+ | Operator :: BrTable { .. }
34+ | Operator :: BrIf { .. }
35+ | Operator :: Call { .. }
36+ | Operator :: CallIndirect { .. }
37+ | Operator :: Return => GAS_PER_OPERATION * 14 ,
38+ _ => GAS_PER_OPERATION ,
39+ }
2740}
2841
2942/// Use Cranelift as the compiler backend if the feature is enabled
You can’t perform that action at this time.
0 commit comments