diff --git a/Cargo.lock b/Cargo.lock index 6443194..c29c7fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1124,7 +1124,6 @@ dependencies = [ "hex", "owasm-crypto", "sha2 0.9.9", - "tempfile", "wasm-instrument", "wasmer", "wasmer-middlewares", @@ -1722,12 +1721,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-width" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" - [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -1830,16 +1823,6 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" -[[package]] -name = "wasm-encoder" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" -dependencies = [ - "leb128", - "wasmparser 0.220.0", -] - [[package]] name = "wasm-instrument" version = "0.4.0" @@ -1901,7 +1884,7 @@ dependencies = [ "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser 0.121.2", + "wasmparser", "winapi", "xxhash-rust", ] @@ -2030,34 +2013,20 @@ dependencies = [ "semver", ] -[[package]] -name = "wasmparser" -version = "0.220.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" -dependencies = [ - "bitflags 2.6.0", - "indexmap 2.6.0", -] - [[package]] name = "wast" -version = "220.0.0" +version = "33.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e708c8de08751fd66e70961a32bae9d71901f14a70871e181cb8461a3bb3165" +checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" dependencies = [ - "bumpalo", "leb128", - "memchr", - "unicode-width", - "wasm-encoder", ] [[package]] name = "wat" -version = "1.220.0" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4f1d7d59614ba690541360102b995c4eb1b9ed373701d5102cc1a968b1c5a3" +checksum = "7ec9c6ee01ae07a26adadcdfed22c7a97e0b8cbee9c06e0e96076ece5aeb5cfe" dependencies = [ "wast", ] diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 6744b20..773290f 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -14,11 +14,10 @@ clru = "0.2.0" hex = "0.4" owasm-crypto = {path = "../crypto", version = "0.3.1"} sha2 = "0.9.1" -tempfile = "3.1.0" wasm-instrument = { version = "0.4.0", default-features = false, features = [ "sign_ext" ] } wasmer = {version = "=4.3.3", default-features = false, features = ["singlepass", "compiler"]} wasmer-middlewares = "=4.3.3" wasmer-types = "=4.3.3" -wat = "1.0" \ No newline at end of file +wat = "=1.0.34" \ No newline at end of file diff --git a/packages/vm/fuzz/Cargo.toml b/packages/vm/fuzz/Cargo.toml index 1aa6c29..5828b93 100644 --- a/packages/vm/fuzz/Cargo.toml +++ b/packages/vm/fuzz/Cargo.toml @@ -10,7 +10,6 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -tempfile = "3.1.0" [dependencies.owasm-vm] path = ".." diff --git a/packages/vm/fuzz/fuzz_targets/fuzz_target_1.rs b/packages/vm/fuzz/fuzz_targets/fuzz_target_1.rs index 95afe02..eb7a1e7 100644 --- a/packages/vm/fuzz/fuzz_targets/fuzz_target_1.rs +++ b/packages/vm/fuzz/fuzz_targets/fuzz_target_1.rs @@ -4,9 +4,6 @@ extern crate owasm_vm; use crate::owasm_vm::cache::*; use crate::owasm_vm::error::Error; use owasm_vm::vm::Querier; -use std::io::{Read, Write}; -use std::process::Command; -use tempfile::NamedTempFile; pub struct MockQuerier {} @@ -47,21 +44,8 @@ impl Querier for MockQuerier { } fn wat2wasm(wat: impl AsRef<[u8]>) -> Vec { - let mut input_file = NamedTempFile::new().unwrap(); - let mut output_file = NamedTempFile::new().unwrap(); - input_file.write_all(wat.as_ref()).unwrap(); - Command::new("wat2wasm") - .args(&[ - input_file.path().to_str().unwrap(), - "-o", - output_file.path().to_str().unwrap(), - "--no-check", - ]) - .output() - .unwrap(); - let mut wasm = Vec::new(); - output_file.read_to_end(&mut wasm).unwrap(); - wasm + let wat_bytes = wat.as_ref(); + wat::parse_bytes(wat_bytes).unwrap().into_owned() } fn generate_wat(imported_function: String) -> String { diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index b1fc9cb..e034819 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -3,8 +3,6 @@ use std::{ sync::{Arc, RwLock}, }; -use wat; - use clru::CLruCache; use wasmer::{Engine, Instance, Module, Store}; @@ -101,11 +99,6 @@ impl Cache { #[cfg(test)] mod tests { - use std::io::{Read, Write}; - use std::process::Command; - - use tempfile::NamedTempFile; - use crate::store::make_engine; use crate::vm::Querier; diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index dd9ed4d..ee50708 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -53,11 +53,6 @@ where #[cfg(test)] mod tests { - use std::io::{Read, Write}; - use std::process::Command; - - use tempfile::NamedTempFile; - use crate::cache::CacheOptions; use crate::compile::compile; @@ -102,20 +97,8 @@ mod tests { } fn wat2wasm(wat: impl AsRef<[u8]>) -> Vec { - let mut input_file = NamedTempFile::new().unwrap(); - let mut output_file = NamedTempFile::new().unwrap(); - input_file.write_all(wat.as_ref()).unwrap(); - Command::new("wat2wasm") - .args(&[ - input_file.path().to_str().unwrap(), - "-o", - output_file.path().to_str().unwrap(), - ]) - .output() - .unwrap(); - let mut wasm = Vec::new(); - output_file.read_to_end(&mut wasm).unwrap(); - wasm + let wat_bytes = wat.as_ref(); + wat::parse_bytes(wat_bytes).unwrap().into_owned() } #[test] diff --git a/packages/vm/src/compile.rs b/packages/vm/src/compile.rs index 8a3a4f9..1110d73 100644 --- a/packages/vm/src/compile.rs +++ b/packages/vm/src/compile.rs @@ -116,25 +116,10 @@ mod tests { use super::*; use assert_matches::assert_matches; - use std::io::{Read, Write}; - use std::process::Command; - use tempfile::NamedTempFile; fn wat2wasm(wat: impl AsRef<[u8]>) -> Vec { - let mut input_file = NamedTempFile::new().unwrap(); - let mut output_file = NamedTempFile::new().unwrap(); - input_file.write_all(wat.as_ref()).unwrap(); - Command::new("wat2wasm") - .args(&[ - input_file.path().to_str().unwrap(), - "-o", - output_file.path().to_str().unwrap(), - ]) - .output() - .unwrap(); - let mut wasm = Vec::new(); - output_file.read_to_end(&mut wasm).unwrap(); - wasm + let wat_bytes = wat.as_ref(); + wat::parse_bytes(wat_bytes).unwrap().into_owned() } fn get_module_from_wasm(code: &[u8]) -> Module { @@ -221,16 +206,16 @@ mod tests { r#"(module (type (;0;) (func)) (func (;0;) (type 0) - (local i32) + (local $idx i32) i32.const 0 - local.set 0 + local.set $idx block ;; label = @1 loop ;; label = @2 local.get 0 i32.const 1 i32.add - local.set 0 - local.get 0 + local.set $idx + local.get $idx i32.const 1000000000 i32.lt_u br_if 0 (;@2;) @@ -351,16 +336,16 @@ mod tests { (type (;1;) (func)) (import "env" "ask_external_data" (func (;0;) (type 0))) (func (;1;) (type 1) - (local i32) + (local $idx i32) i32.const 0 - local.set 0 + local.set $idx block ;; label = @1 loop ;; label = @2 - local.get 0 + local.get $idx i32.const 1 i32.add - local.set 0 - local.get 0 + local.set $idx + local.get $idx i32.const 1000000000 i32.lt_u br_if 0 (;@2;) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 37b330e..334a8be 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -330,10 +330,7 @@ mod test { use crate::compile::compile; use crate::store::{make_engine, make_store}; - use std::io::{Read, Write}; - use std::process::Command; use std::ptr::NonNull; - use tempfile::NamedTempFile; use wasmer::ExternType::Function; use wasmer::{FunctionType, Store}; use wasmer::Instance; @@ -378,20 +375,8 @@ mod test { } fn wat2wasm(wat: impl AsRef<[u8]>) -> Vec { - let mut input_file = NamedTempFile::new().unwrap(); - let mut output_file = NamedTempFile::new().unwrap(); - input_file.write_all(wat.as_ref()).unwrap(); - Command::new("wat2wasm") - .args(&[ - input_file.path().to_str().unwrap(), - "-o", - output_file.path().to_str().unwrap(), - ]) - .output() - .unwrap(); - let mut wasm = Vec::new(); - output_file.read_to_end(&mut wasm).unwrap(); - wasm + let wat_bytes = wat.as_ref(); + wat::parse_bytes(wat_bytes).unwrap().into_owned() } fn create_owasm_env() -> (Environment, Instance, Store) { diff --git a/packages/vm/src/vm.rs b/packages/vm/src/vm.rs index 4f73f79..d78bc8a 100644 --- a/packages/vm/src/vm.rs +++ b/packages/vm/src/vm.rs @@ -159,13 +159,6 @@ where #[cfg(test)] mod tests { - use std::{ - io::{Read, Write}, - process::Command, - }; - - use tempfile::NamedTempFile; - use crate::cache::{Cache, CacheOptions}; use crate::store::make_engine; @@ -210,20 +203,8 @@ mod tests { } fn wat2wasm(wat: impl AsRef<[u8]>) -> Vec { - let mut input_file = NamedTempFile::new().unwrap(); - let mut output_file = NamedTempFile::new().unwrap(); - input_file.write_all(wat.as_ref()).unwrap(); - Command::new("wat2wasm") - .args(&[ - input_file.path().to_str().unwrap(), - "-o", - output_file.path().to_str().unwrap(), - ]) - .output() - .unwrap(); - let mut wasm = Vec::new(); - output_file.read_to_end(&mut wasm).unwrap(); - wasm + let wat_bytes = wat.as_ref(); + wat::parse_bytes(wat_bytes).unwrap().into_owned() } #[test]