Created
August 12, 2024 08:05
-
-
Save webmaster128/c674a02158e7c8e1b07f1d9ac9a31f8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/vm/src/wasm_backend/engine.rs b/packages/vm/src/wasm_backend/engine.rs | |
index 7b2f6190a9..a6bdb62e09 100644 | |
--- a/packages/vm/src/wasm_backend/engine.rs | |
+++ b/packages/vm/src/wasm_backend/engine.rs | |
@@ -16,14 +16,27 @@ use super::limiting_tunables::LimitingTunables; | |
/// https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md | |
const MAX_WASM_PAGES: u32 = 65536; | |
-fn cost(_operator: &Operator) -> u64 { | |
+fn cost(operator: &Operator) -> u64 { | |
// A flat fee for each operation | |
// The target is 1 Teragas per second (see GAS.md). | |
// | |
// In https://github.com/CosmWasm/cosmwasm/pull/1042 a profiler is developed to | |
// identify runtime differences between different Wasm operation, but this is not yet | |
// precise enough to derive insights from it. | |
- 170 | |
+ const GAS_PER_OPERATION: u64 = 115; | |
+ | |
+ match operator { | |
+ Operator::Loop { .. } | |
+ | Operator::End | |
+ | Operator::Else | |
+ | Operator::Br { .. } | |
+ | Operator::BrTable { .. } | |
+ | Operator::BrIf { .. } | |
+ | Operator::Call { .. } | |
+ | Operator::CallIndirect { .. } | |
+ | Operator::Return => GAS_PER_OPERATION * 14, | |
+ _ => GAS_PER_OPERATION, | |
+ } | |
} | |
/// Use Cranelift as the compiler backend if the feature is enabled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment