Skip to content

Commit

Permalink
feat: optimization wasm gas meter (#1853)
Browse files Browse the repository at this point in the history
* feat: refactor wasm gas meter

* feat: add test case for prohibit ops

* feat: add unit test
  • Loading branch information
yubing744 authored Jun 11, 2024
1 parent 1eb1b21 commit 5d19391
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 31 deletions.
205 changes: 192 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ base64 = "0.21.3"
#criterion-cpu-time = "0.1.0"
wasmer = "4.2.5"
wasmer-types = "4.2.5"
wasmer-compiler-singlepass = "4.3.1"
ciborium = "0.2.1"
pprof = { version = "0.13.0", features = ["flamegraph", "criterion", "cpp", "frame-pointer", "protobuf-codec"] }
celestia-rpc = { git = "https://github.com/eigerco/celestia-node-rs.git", rev = "129272e8d926b4c7badf27a26dea915323dd6489" }
Expand Down
15 changes: 15 additions & 0 deletions frameworks/moveos-stdlib/sources/wasm.move
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,19 @@ module moveos_std::wasm {
// 3. Release the WASM VM instance (required step)
release_wasm_instance(wasm_instance);
}

#[test]
fun test_call_indirect() {
// Enable all features for testing
features::init_and_enable_all_features_for_test();

// Define WASM code with a CallIndirect instruction
let wasm_code: vector<u8> = b"(module (type $t0 (func (param i32) (result i32))) (table 1 1 funcref) (elem (i32.const 0) $f) (func $f (type $t0) (param $p i32) (result i32) local.get $p) (func (export \"call_indirect_test\") (param i32) (result i32) local.get 0 i32.const 0 call_indirect (type $t0)))";

// 1. Create WASM VM instance (required step)
let wasm_instance_option = create_wasm_instance_option(wasm_code);
assert!(option::is_none(&wasm_instance_option), 1);
option::destroy_none(wasm_instance_option);
}

}
1 change: 1 addition & 0 deletions moveos/moveos-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ serde_json = { workspace = true }
once_cell = { workspace = true }
wasmer = { workspace = true }
wasmer-types = { workspace = true }
wasmer-compiler-singlepass = { workspace = true }
ciborium = { workspace = true }
rand = { workspace = true }
anyhow = { workspace = true }
Expand Down
Loading

0 comments on commit 5d19391

Please sign in to comment.