From 48bf5d970c2f47412493ed91e560da3d5a67cd0d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 11:08:01 -0700 Subject: [PATCH 01/12] use git wasmtime so we can use the only_interfaces feature on host bindgen --- Cargo.lock | 228 +++++++++++++++++++++++++++--------------------- host/Cargo.toml | 2 +- 2 files changed, 131 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72b88894..2864b9e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,6 +83,12 @@ version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" + [[package]] name = "async-trait" version = "0.1.68" @@ -350,23 +356,22 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862eb053fc21f991db27c73bc51494fe77aadfa09ea257cb43b62a2656fd4cc1" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038a74bc85da2f6f9e237c51b7998b47229c0f9da69b4c6b0590cf6621c45d46" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-control", "cranelift-entity", "cranelift-isle", "gimli", @@ -379,33 +384,37 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb720a7955cf7cc92c58f3896952589062e6f12d8eb35ef4337e708ed2e738" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0954f9426cf0fa7ad57910ea5822a09c5da590222a767a6c38080a8534a0af8" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" + +[[package]] +name = "cranelift-control" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +dependencies = [ + "arbitrary", +] [[package]] name = "cranelift-entity" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68c7096c1a66cfa73899645f0a46a6f5c91641e678eeafb0fc47a19ab34069ca" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697f2fdaceb228fea413ea91baa7c6b8533fc2e61ac5a08db7acc1b31e673a2a" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-codegen", "log", @@ -415,15 +424,13 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f41037f4863e0c6716dbe60e551d501f4197383cb43d75038c0170159fc8fb5b" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" [[package]] name = "cranelift-native" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "797c6e5643eb654bb7bf496f1f03518323a89b937b84020b786620f910364a52" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-codegen", "libc", @@ -432,9 +439,8 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b5fae12cefda3a2c43837e562dd525ab1d75b27989eece66de5b2c8fe120f9" +version = "0.96.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -442,7 +448,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.100.0", + "wasmparser 0.102.0", "wasmtime-types", ] @@ -1713,19 +1719,10 @@ dependencies = [ "byte-array", "object", "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-encoder 0.25.0", + "wasm-encoder", "wit-bindgen", ] -[[package]] -name = "wasm-encoder" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c3e4bc09095436c8e7584d86d33e6c3ee67045af8fb262cbb9cc321de553428" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.25.0" @@ -1744,7 +1741,7 @@ dependencies = [ "anyhow", "indexmap", "serde", - "wasm-encoder 0.25.0", + "wasm-encoder", "wasmparser 0.102.0", ] @@ -1757,16 +1754,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "wasmparser" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" -dependencies = [ - "indexmap", - "url", -] - [[package]] name = "wasmparser" version = "0.102.0" @@ -1789,9 +1776,8 @@ dependencies = [ [[package]] name = "wasmtime" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d137f87df6e037b2bcb960c2db7ea174e04fb897051380c14b5e5475a870669e" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "async-trait", @@ -1808,7 +1794,7 @@ dependencies = [ "rayon", "serde", "target-lexicon", - "wasmparser 0.100.0", + "wasmparser 0.102.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -1817,24 +1803,23 @@ dependencies = [ "wasmtime-fiber", "wasmtime-jit", "wasmtime-runtime", + "wasmtime-winch", "wat", "windows-sys 0.45.0", ] [[package]] name = "wasmtime-asm-macros" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad63d4175d6af44af2046186c87deae4e9a8150b92de2d4809c6f745d5ee9b38" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3055fb327f795b4639f47b9dadad9d3d9b185fd3001adf8db08f5fa06d07032" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "base64", @@ -1852,9 +1837,8 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cf4906f990d6ab3065d042cf5a15eb7a2a5406d1c001a45ab9615de876458a" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "proc-macro2", @@ -1867,18 +1851,17 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ccf49c18c1ce3f682310e642dcdc00ffc67f1ce0767c89a16fc8fcf5eaeb97" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" [[package]] name = "wasmtime-cranelift" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274590ecbb1179d45a5c8d9f54b9d236e9414d9ca3b861cd8956cec085508eb0" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "cranelift-codegen", + "cranelift-control", "cranelift-entity", "cranelift-frontend", "cranelift-native", @@ -1888,15 +1871,30 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.100.0", + "wasmparser 0.102.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-control", + "cranelift-native", + "gimli", + "object", + "target-lexicon", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b4a897e6ce1f2567ba98e7b1948c0e12cae1202fd88e7639f901b8ce9203f7" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "cranelift-entity", @@ -1907,8 +1905,8 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasm-encoder 0.23.0", - "wasmparser 0.100.0", + "wasm-encoder", + "wasmparser 0.102.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -1916,9 +1914,8 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b1192624694399f601de28db78975ed20fa859da8e048bf8250bd3b38d302b" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cc", "cfg-if", @@ -1929,9 +1926,8 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f035bfe27ce5129c9d081d6288480f2e6ae9d16d0eb035a5d9e3b5b6c36658" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "addr2line", "anyhow", @@ -1954,9 +1950,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17e35d335dd2461c631ba24d2326d993bd3a4bdb4b0217e5bda4f518ba0e29f3" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "object", "once_cell", @@ -1965,9 +1960,8 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8c01a070f55343f7afd309a9609c12378548b26c3f53c599bc711bb1ce42ee" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cfg-if", "libc", @@ -1976,9 +1970,8 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac02cc14c8247f6e4e48c7653a79c226babac8f2cacdd933d3f15ca2a6ab20b" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "cc", @@ -2002,21 +1995,36 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8dc0062ab053e1aa22d2355a2de4df482a0007fecae82ea02cc596c2329971d" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.100.0", + "wasmparser 0.102.0", +] + +[[package]] +name = "wasmtime-winch" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser 0.102.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "winch-codegen", + "winch-environ", ] [[package]] name = "wasmtime-wit-bindgen" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2cf93f3c8a6f443d8a9098fddc5fd887783c0fe725dc10c54ca9280546421d" +version = "9.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ "anyhow", "heck", @@ -2032,7 +2040,7 @@ dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.25.0", + "wasm-encoder", ] [[package]] @@ -2075,6 +2083,30 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winch-codegen" +version = "0.7.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser 0.102.0", +] + +[[package]] +name = "winch-environ" +version = "0.7.0" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +dependencies = [ + "wasmparser 0.102.0", + "wasmtime-environ", + "winch-codegen", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -2287,7 +2319,7 @@ dependencies = [ "indexmap", "log", "url", - "wasm-encoder 0.25.0", + "wasm-encoder", "wasm-metadata", "wasmparser 0.102.0", "wit-parser", diff --git a/host/Cargo.toml b/host/Cargo.toml index 8e594175..e4f8e5a9 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -12,7 +12,7 @@ cap-rand = { workspace = true } cap-net-ext = { workspace = true } tokio = { version = "1.22.0", features = [ "rt", "macros" ] } tracing = { workspace = true } -wasmtime = { version = "7.0.0", features = ["component-model"] } +wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "f684a5fbeea6ab95cb763d370e6ae7665aa1190d", features = ["component-model"] } wasi-common = { path = "../wasi-common" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" } clap = { version = "4.1.9", features = ["derive"] } From 9ad50789842429c539b82088730b7df99d6ac2a0 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 11:09:09 -0700 Subject: [PATCH 02/12] de-duplicate command and proxy definitions, useing only_interfaces --- host/src/clocks.rs | 4 +- host/src/command.rs | 38 --------- host/src/default_outgoing_http.rs | 6 +- host/src/env.rs | 2 +- host/src/exit.rs | 2 +- host/src/filesystem.rs | 4 +- host/src/http_types.rs | 6 +- host/src/io.rs | 137 +----------------------------- host/src/ip_name_lookup.rs | 6 +- host/src/lib.rs | 3 +- host/src/logging.rs | 2 +- host/src/main.rs | 14 +-- host/src/network.rs | 4 +- host/src/poll.rs | 34 +++----- host/src/proxy.rs | 27 ------ host/src/random.rs | 20 +---- host/src/tcp.rs | 14 +-- host/src/udp.rs | 8 +- host/src/wasi/command.rs | 57 +++++++++++++ host/src/wasi/mod.rs | 14 +++ host/src/wasi/proxy.rs | 46 ++++++++++ wit/command.wit | 4 + 22 files changed, 177 insertions(+), 275 deletions(-) delete mode 100644 host/src/command.rs delete mode 100644 host/src/proxy.rs create mode 100644 host/src/wasi/command.rs create mode 100644 host/src/wasi/mod.rs create mode 100644 host/src/wasi/proxy.rs diff --git a/host/src/clocks.rs b/host/src/clocks.rs index b2d4c05f..16f6490b 100644 --- a/host/src/clocks.rs +++ b/host/src/clocks.rs @@ -1,12 +1,12 @@ #![allow(unused_variables)] -use crate::command::wasi::{ +use crate::poll::PollableEntry; +use crate::wasi::{ monotonic_clock::{self, Instant}, poll::Pollable, timezone::{self, Timezone, TimezoneDisplay}, wall_clock::{self, Datetime}, }; -use crate::poll::PollableEntry; use crate::WasiCtx; use cap_std::time::SystemTime; diff --git a/host/src/command.rs b/host/src/command.rs deleted file mode 100644 index 8d2824d4..00000000 --- a/host/src/command.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::WasiCtx; - -pub mod wasi { - wasmtime::component::bindgen!({ - path: "../wit", - world: "command", - tracing: true, - async: true, - trappable_error_type: { - "filesystem"::"error-code": Error, - "streams"::"stream-error": Error, - } - }); -} - -pub fn add_to_linker( - l: &mut wasmtime::component::Linker, - f: impl (Fn(&mut T) -> &mut WasiCtx) + Copy + Send + Sync + 'static, -) -> anyhow::Result<()> { - wasi::wall_clock::add_to_linker(l, f)?; - wasi::monotonic_clock::add_to_linker(l, f)?; - wasi::timezone::add_to_linker(l, f)?; - wasi::filesystem::add_to_linker(l, f)?; - wasi::poll::add_to_linker(l, f)?; - wasi::streams::add_to_linker(l, f)?; - wasi::random::add_to_linker(l, f)?; - wasi::tcp::add_to_linker(l, f)?; - wasi::tcp_create_socket::add_to_linker(l, f)?; - wasi::udp::add_to_linker(l, f)?; - wasi::udp_create_socket::add_to_linker(l, f)?; - wasi::ip_name_lookup::add_to_linker(l, f)?; - wasi::instance_network::add_to_linker(l, f)?; - wasi::network::add_to_linker(l, f)?; - wasi::exit::add_to_linker(l, f)?; - wasi::environment::add_to_linker(l, f)?; - wasi::preopens::add_to_linker(l, f)?; - Ok(()) -} diff --git a/host/src/default_outgoing_http.rs b/host/src/default_outgoing_http.rs index ec16c828..3a3d7bcb 100644 --- a/host/src/default_outgoing_http.rs +++ b/host/src/default_outgoing_http.rs @@ -1,8 +1,6 @@ use crate::{ - proxy::wasi, - proxy::wasi::types::{ - FutureIncomingResponse as Response, OutgoingRequest as Request, RequestOptions, - }, + wasi, + wasi::types::{FutureIncomingResponse as Response, OutgoingRequest as Request, RequestOptions}, WasiCtx, }; diff --git a/host/src/env.rs b/host/src/env.rs index 3c50191c..5461fb8b 100644 --- a/host/src/env.rs +++ b/host/src/env.rs @@ -1,4 +1,4 @@ -use crate::command::wasi; +use crate::wasi; use crate::WasiCtx; #[async_trait::async_trait] diff --git a/host/src/exit.rs b/host/src/exit.rs index 5707a4d0..3ddefb2b 100644 --- a/host/src/exit.rs +++ b/host/src/exit.rs @@ -1,4 +1,4 @@ -use crate::command::wasi::exit; +use crate::wasi::exit; use crate::WasiCtx; #[async_trait::async_trait] diff --git a/host/src/filesystem.rs b/host/src/filesystem.rs index 9a39424e..328852b4 100644 --- a/host/src/filesystem.rs +++ b/host/src/filesystem.rs @@ -1,7 +1,7 @@ #![allow(unused_variables)] -use crate::command::wasi; -use crate::command::wasi::streams::{InputStream, OutputStream}; +use crate::wasi; +use crate::wasi::streams::{InputStream, OutputStream}; use crate::WasiCtx; use anyhow::anyhow; use std::{ diff --git a/host/src/http_types.rs b/host/src/http_types.rs index 195e56e2..681bebb0 100644 --- a/host/src/http_types.rs +++ b/host/src/http_types.rs @@ -1,7 +1,7 @@ use crate::{ - proxy::wasi, - proxy::wasi::poll::Pollable, - proxy::wasi::types::{ + wasi, + wasi::poll::Pollable, + wasi::types::{ Error, Fields, FutureIncomingResponse, Headers, IncomingRequest, IncomingResponse, IncomingStream, Method, OutgoingRequest, OutgoingResponse, OutgoingStream, ResponseOutparam, Scheme, StatusCode, Trailers, diff --git a/host/src/io.rs b/host/src/io.rs index 47e89377..8c62c3cd 100644 --- a/host/src/io.rs +++ b/host/src/io.rs @@ -1,9 +1,8 @@ use crate::{ - command, - command::wasi::poll::Pollable, - command::wasi::streams::{self, InputStream, OutputStream, StreamError}, poll::PollableEntry, - proxy, WasiCtx, + wasi::poll::Pollable, + wasi::streams::{self, InputStream, OutputStream, StreamError}, + WasiCtx, }; use anyhow::anyhow; use wasi_common::stream::TableStreamExt; @@ -18,16 +17,6 @@ impl From for streams::Error { } } -impl From for proxy::wasi::streams::Error { - fn from(error: streams::Error) -> proxy::wasi::streams::Error { - if let Some(_) = error.downcast_ref() { - proxy::wasi::streams::StreamError {}.into() - } else { - proxy::wasi::streams::Error::trap(anyhow!(error)) - } - } -} - async fn drop_input_stream(ctx: &mut WasiCtx, stream: InputStream) -> anyhow::Result<()> { ctx.table_mut() .delete::>(stream)?; @@ -227,7 +216,7 @@ async fn subscribe_to_output_stream( // bindings to facilitate this kind of sharing. #[async_trait::async_trait] -impl command::wasi::streams::Host for WasiCtx { +impl streams::Host for WasiCtx { async fn drop_input_stream(&mut self, stream: InputStream) -> anyhow::Result<()> { drop_input_stream(self, stream).await } @@ -329,121 +318,3 @@ impl command::wasi::streams::Host for WasiCtx { subscribe_to_output_stream(self, stream).await } } - -#[async_trait::async_trait] -impl proxy::wasi::streams::Host for WasiCtx { - async fn drop_input_stream(&mut self, stream: InputStream) -> anyhow::Result<()> { - drop_input_stream(self, stream).await - } - - async fn drop_output_stream(&mut self, stream: OutputStream) -> anyhow::Result<()> { - drop_output_stream(self, stream).await - } - - async fn read( - &mut self, - stream: InputStream, - len: u64, - ) -> Result<(Vec, bool), proxy::wasi::streams::Error> { - read(self, stream, len).await.map_err(|e| e.into()) - } - - async fn blocking_read( - &mut self, - stream: InputStream, - len: u64, - ) -> Result<(Vec, bool), proxy::wasi::streams::Error> { - blocking_read(self, stream, len).await.map_err(|e| e.into()) - } - - async fn write( - &mut self, - stream: OutputStream, - bytes: Vec, - ) -> Result { - write(self, stream, bytes).await.map_err(|e| e.into()) - } - - async fn blocking_write( - &mut self, - stream: OutputStream, - bytes: Vec, - ) -> Result { - blocking_write(self, stream, bytes) - .await - .map_err(|e| e.into()) - } - - async fn skip( - &mut self, - stream: InputStream, - len: u64, - ) -> Result<(u64, bool), proxy::wasi::streams::Error> { - skip(self, stream, len).await.map_err(|e| e.into()) - } - - async fn blocking_skip( - &mut self, - stream: InputStream, - len: u64, - ) -> Result<(u64, bool), proxy::wasi::streams::Error> { - blocking_skip(self, stream, len).await.map_err(|e| e.into()) - } - - async fn write_zeroes( - &mut self, - stream: OutputStream, - len: u64, - ) -> Result { - write_zeroes(self, stream, len).await.map_err(|e| e.into()) - } - - async fn blocking_write_zeroes( - &mut self, - stream: OutputStream, - len: u64, - ) -> Result { - blocking_write_zeroes(self, stream, len) - .await - .map_err(|e| e.into()) - } - - async fn splice( - &mut self, - src: InputStream, - dst: OutputStream, - len: u64, - ) -> Result<(u64, bool), proxy::wasi::streams::Error> { - splice(self, src, dst, len).await.map_err(|e| e.into()) - } - - async fn blocking_splice( - &mut self, - src: InputStream, - dst: OutputStream, - len: u64, - ) -> Result<(u64, bool), proxy::wasi::streams::Error> { - blocking_splice(self, src, dst, len) - .await - .map_err(|e| e.into()) - } - - async fn forward( - &mut self, - src: InputStream, - dst: OutputStream, - ) -> Result { - forward(self, src, dst).await.map_err(|e| e.into()) - } - - async fn subscribe_to_input_stream(&mut self, stream: InputStream) -> anyhow::Result { - subscribe_to_input_stream(self, stream).await - } - - async fn subscribe_to_output_stream( - &mut self, - stream: OutputStream, - ) -> anyhow::Result { - subscribe_to_output_stream(self, stream).await - } -} diff --git a/host/src/ip_name_lookup.rs b/host/src/ip_name_lookup.rs index 55d36bfd..6e06105b 100644 --- a/host/src/ip_name_lookup.rs +++ b/host/src/ip_name_lookup.rs @@ -1,9 +1,9 @@ #![allow(unused_variables)] use crate::{ - command::wasi::ip_name_lookup::{self, ResolveAddressStream}, - command::wasi::network::{Error, IpAddress, IpAddressFamily, Network}, - command::wasi::poll::Pollable, + wasi::ip_name_lookup::{self, ResolveAddressStream}, + wasi::network::{Error, IpAddress, IpAddressFamily, Network}, + wasi::poll::Pollable, HostResult, WasiCtx, }; diff --git a/host/src/lib.rs b/host/src/lib.rs index 228b0fe0..c77f323f 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -16,5 +16,4 @@ pub use wasi_common::{table::Table, WasiCtx}; type HostResult = anyhow::Result>; -pub mod command; -pub mod proxy; +pub mod wasi; diff --git a/host/src/logging.rs b/host/src/logging.rs index 676bf2a4..b7669d5f 100644 --- a/host/src/logging.rs +++ b/host/src/logging.rs @@ -1,4 +1,4 @@ -use crate::proxy::wasi::console; +use crate::wasi::console; use crate::WasiCtx; #[async_trait::async_trait] diff --git a/host/src/main.rs b/host/src/main.rs index 7cc453da..1ecf80cd 100644 --- a/host/src/main.rs +++ b/host/src/main.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use host::{command, command::wasi::Command, proxy, proxy::wasi::Proxy, WasiCtx}; +use host::{wasi, WasiCtx}; use wasi_cap_std_sync::WasiCtxBuilder; use wasmtime::{ component::{Component, Linker}, @@ -52,7 +52,7 @@ async fn run_command( component: &Component, args: &[String], ) -> anyhow::Result<()> { - command::add_to_linker(linker, |x| x)?; + wasi::command::add_to_linker(linker, |x| x)?; let mut argv: Vec<&str> = vec!["wasm"]; argv.extend(args.iter().map(String::as_str)); @@ -66,7 +66,8 @@ async fn run_command( .build(), ); - let (wasi, _instance) = Command::instantiate_async(&mut store, component, linker).await?; + let (wasi, _instance) = + wasi::command::Command::instantiate_async(&mut store, component, linker).await?; let result: Result<(), ()> = wasi.call_main(&mut store).await?; @@ -83,7 +84,7 @@ async fn run_proxy( component: &Component, args: &[String], ) -> anyhow::Result<()> { - proxy::add_to_linker(linker, |x| x)?; + wasi::proxy::add_to_linker(linker, |x| x)?; let mut argv: Vec<&str> = vec!["wasm"]; argv.extend(args.iter().map(String::as_str)); @@ -93,14 +94,15 @@ async fn run_proxy( WasiCtxBuilder::new().inherit_stdio().args(&argv).build(), ); - let (wasi, _instance) = Proxy::instantiate_async(&mut store, component, linker).await?; + let (wasi, _instance) = + wasi::proxy::Proxy::instantiate_async(&mut store, component, linker).await?; // TODO: do something let _ = wasi; let result: Result<(), ()> = Ok(()); if result.is_err() { - anyhow::bail!("command returned with failing exit status"); + anyhow::bail!("proxy returned with failing exit status"); } Ok(()) diff --git a/host/src/network.rs b/host/src/network.rs index f4bbb0d7..ba87a9a9 100644 --- a/host/src/network.rs +++ b/host/src/network.rs @@ -1,6 +1,6 @@ use crate::{ - command::wasi::instance_network, - command::wasi::network::{self, Network}, + wasi::instance_network, + wasi::network::{self, Network}, WasiCtx, }; use cap_std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; diff --git a/host/src/poll.rs b/host/src/poll.rs index 7247fa6b..f698a484 100644 --- a/host/src/poll.rs +++ b/host/src/poll.rs @@ -1,10 +1,10 @@ use crate::{ - command, - command::wasi::monotonic_clock::Instant, - command::wasi::poll::Pollable, - command::wasi::streams::{InputStream, OutputStream, StreamError}, - command::wasi::tcp::TcpSocket, - proxy, WasiCtx, + wasi, + wasi::monotonic_clock::Instant, + wasi::poll::Pollable, + wasi::streams::{InputStream, OutputStream, StreamError}, + wasi::tcp::TcpSocket, + WasiCtx, }; use wasi_common::stream::TableStreamExt; use wasi_common::tcp_socket::TableTcpSocketExt; @@ -79,24 +79,14 @@ async fn poll_oneoff(ctx: &mut WasiCtx, futures: Vec) -> anyhow::Resul Ok(results) } -// Implementatations of the traits for both the command and proxy worlds. -// The bodies have been pulled out into functions above to allow them to -// be shared between the two. Ideally, we should add features to the -// bindings to facilitate this kind of sharing. +// Implementatations of the interface. The bodies had been pulled out into +// functions above to allow them to be shared between the two worlds, which +// used to require different traits . Features have been added to facilitate +// sharing between worlds, but I want to avoid the huge whitespace diff on +// this PR. #[async_trait::async_trait] -impl command::wasi::poll::Host for WasiCtx { - async fn drop_pollable(&mut self, pollable: Pollable) -> anyhow::Result<()> { - drop_pollable(self, pollable).await - } - - async fn poll_oneoff(&mut self, futures: Vec) -> anyhow::Result> { - poll_oneoff(self, futures).await - } -} - -#[async_trait::async_trait] -impl proxy::wasi::poll::Host for WasiCtx { +impl wasi::poll::Host for WasiCtx { async fn drop_pollable(&mut self, pollable: Pollable) -> anyhow::Result<()> { drop_pollable(self, pollable).await } diff --git a/host/src/proxy.rs b/host/src/proxy.rs deleted file mode 100644 index 7204ddfe..00000000 --- a/host/src/proxy.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::WasiCtx; - -pub mod wasi { - wasmtime::component::bindgen!({ - path: "../wit", - world: "proxy", - tracing: true, - async: true, - trappable_error_type: { - "filesystem"::"error-code": Error, - "streams"::"stream-error": Error, - } - }); -} - -pub fn add_to_linker( - l: &mut wasmtime::component::Linker, - f: impl (Fn(&mut T) -> &mut WasiCtx) + Copy + Send + Sync + 'static, -) -> anyhow::Result<()> { - wasi::random::add_to_linker(l, f)?; - wasi::console::add_to_linker(l, f)?; - wasi::types::add_to_linker(l, f)?; - wasi::poll::add_to_linker(l, f)?; - wasi::streams::add_to_linker(l, f)?; - wasi::default_outgoing_http::add_to_linker(l, f)?; - Ok(()) -} diff --git a/host/src/random.rs b/host/src/random.rs index 64b3fbf3..2cf9b514 100644 --- a/host/src/random.rs +++ b/host/src/random.rs @@ -1,6 +1,7 @@ use cap_rand::{distributions::Standard, Rng}; -use crate::{command, proxy, WasiCtx}; +use crate::wasi; +use crate::WasiCtx; async fn get_random_bytes(ctx: &mut WasiCtx, len: u64) -> anyhow::Result> { Ok((&mut ctx.random) @@ -23,22 +24,7 @@ async fn insecure_random(_ctx: &mut WasiCtx) -> anyhow::Result<(u64, u64)> { // bindings to facilitate this kind of sharing. #[async_trait::async_trait] -impl command::wasi::random::Host for WasiCtx { - async fn get_random_bytes(&mut self, len: u64) -> anyhow::Result> { - get_random_bytes(self, len).await - } - - async fn get_random_u64(&mut self) -> anyhow::Result { - get_random_u64(self).await - } - - async fn insecure_random(&mut self) -> anyhow::Result<(u64, u64)> { - insecure_random(self).await - } -} - -#[async_trait::async_trait] -impl proxy::wasi::random::Host for WasiCtx { +impl wasi::random::Host for WasiCtx { async fn get_random_bytes(&mut self, len: u64) -> anyhow::Result> { get_random_bytes(self, len).await } diff --git a/host/src/tcp.rs b/host/src/tcp.rs index 94d24b5b..9ef9cb64 100644 --- a/host/src/tcp.rs +++ b/host/src/tcp.rs @@ -1,16 +1,16 @@ #![allow(unused_variables)] use crate::{ - command::wasi::network::{ + network::convert, + poll::PollableEntry, + wasi::network::{ Error, IpAddressFamily, Ipv4Address, Ipv4SocketAddress, Ipv6Address, Ipv6SocketAddress, Network, }, - command::wasi::poll::Pollable, - command::wasi::streams::{InputStream, OutputStream}, - command::wasi::tcp::{self, IpSocketAddress, ShutdownType, TcpSocket}, - command::wasi::tcp_create_socket, - network::convert, - poll::PollableEntry, + wasi::poll::Pollable, + wasi::streams::{InputStream, OutputStream}, + wasi::tcp::{self, IpSocketAddress, ShutdownType, TcpSocket}, + wasi::tcp_create_socket, HostResult, WasiCtx, }; use cap_net_ext::AddressFamily; diff --git a/host/src/udp.rs b/host/src/udp.rs index e75c4dbf..9e3ebcac 100644 --- a/host/src/udp.rs +++ b/host/src/udp.rs @@ -1,10 +1,10 @@ #![allow(unused_variables)] use crate::{ - command::wasi::network::{Error, IpAddressFamily, Network}, - command::wasi::poll::Pollable, - command::wasi::udp::{self, Datagram, IpSocketAddress, UdpSocket}, - command::wasi::udp_create_socket, + wasi::network::{Error, IpAddressFamily, Network}, + wasi::poll::Pollable, + wasi::udp::{self, Datagram, IpSocketAddress, UdpSocket}, + wasi::udp_create_socket, HostResult, WasiCtx, }; use wasi_common::udp_socket::TableUdpSocketExt; diff --git a/host/src/wasi/command.rs b/host/src/wasi/command.rs new file mode 100644 index 00000000..727ddbd5 --- /dev/null +++ b/host/src/wasi/command.rs @@ -0,0 +1,57 @@ +use crate::WasiCtx; + +wasmtime::component::bindgen!({ + path: "../wit", + world: "command", + tracing: true, + async: true, + trappable_error_type: { + "filesystem"::"error-code": Error, + "streams"::"stream-error": Error, + }, + with: { + "filesystem": crate::wasi::filesystem, + "instance_monotonic_clock": crate::wasi::instance_monotonic_clock, + "instance_network": crate::wasi::instance_network, + "instance_wall_clock": crate::wasi::instance_wall_clock, + "ip_name_lookup": crate::wasi::ip_name_lookup, + "monotonic_clock": crate::wasi::monotonic_clock, + "network": crate::wasi::network, + "poll": crate::wasi::poll, + "streams": crate::wasi::streams, + "tcp": crate::wasi::tcp, + "tcp_create_socket": crate::wasi::tcp_create_socket, + "timezone": crate::wasi::timezone, + "udp": crate::wasi::udp, + "udp_create_socket": crate::wasi::udp_create_socket, + "wall_clock": crate::wasi::wall_clock, + "random": crate::wasi::random, + "environment": crate::wasi::environment, + "exit": crate::wasi::exit, + "preopens": crate::wasi::preopens, + }, +}); + +pub fn add_to_linker( + l: &mut wasmtime::component::Linker, + f: impl (Fn(&mut T) -> &mut WasiCtx) + Copy + Send + Sync + 'static, +) -> anyhow::Result<()> { + crate::wasi::wall_clock::add_to_linker(l, f)?; + crate::wasi::monotonic_clock::add_to_linker(l, f)?; + crate::wasi::timezone::add_to_linker(l, f)?; + crate::wasi::filesystem::add_to_linker(l, f)?; + crate::wasi::poll::add_to_linker(l, f)?; + crate::wasi::streams::add_to_linker(l, f)?; + crate::wasi::random::add_to_linker(l, f)?; + crate::wasi::tcp::add_to_linker(l, f)?; + crate::wasi::tcp_create_socket::add_to_linker(l, f)?; + crate::wasi::udp::add_to_linker(l, f)?; + crate::wasi::udp_create_socket::add_to_linker(l, f)?; + crate::wasi::ip_name_lookup::add_to_linker(l, f)?; + crate::wasi::instance_network::add_to_linker(l, f)?; + crate::wasi::network::add_to_linker(l, f)?; + crate::wasi::exit::add_to_linker(l, f)?; + crate::wasi::environment::add_to_linker(l, f)?; + crate::wasi::preopens::add_to_linker(l, f)?; + Ok(()) +} diff --git a/host/src/wasi/mod.rs b/host/src/wasi/mod.rs new file mode 100644 index 00000000..a99f0ceb --- /dev/null +++ b/host/src/wasi/mod.rs @@ -0,0 +1,14 @@ +pub mod command; +pub mod proxy; + +wasmtime::component::bindgen!({ + path: "../wit", + world: "command", + only_interfaces: true, + tracing: true, + async: true, + trappable_error_type: { + "filesystem"::"error-code": Error, + "streams"::"stream-error": Error, + } +}); diff --git a/host/src/wasi/proxy.rs b/host/src/wasi/proxy.rs new file mode 100644 index 00000000..a146b97c --- /dev/null +++ b/host/src/wasi/proxy.rs @@ -0,0 +1,46 @@ +use crate::WasiCtx; + +wasmtime::component::bindgen!({ + path: "../wit", + world: "proxy", + tracing: true, + async: true, + trappable_error_type: { + "filesystem"::"error-code": Error, + "streams"::"stream-error": Error, + }, + with: { + "filesystem": crate::wasi::filesystem, + "instance_monotonic_clock": crate::wasi::instance_monotonic_clock, + "instance_network": crate::wasi::instance_network, + "instance_wall_clock": crate::wasi::instance_wall_clock, + "ip_name_lookup": crate::wasi::ip_name_lookup, + "monotonic_clock": crate::wasi::monotonic_clock, + "network": crate::wasi::network, + "poll": crate::wasi::poll, + "streams": crate::wasi::streams, + "tcp": crate::wasi::tcp, + "tcp_create_socket": crate::wasi::tcp_create_socket, + "timezone": crate::wasi::timezone, + "udp": crate::wasi::udp, + "udp_create_socket": crate::wasi::udp_create_socket, + "wall_clock": crate::wasi::wall_clock, + "random": crate::wasi::random, + "environment": crate::wasi::environment, + "exit": crate::wasi::exit, + "preopens": crate::wasi::preopens, + }, +}); + +pub fn add_to_linker( + l: &mut wasmtime::component::Linker, + f: impl (Fn(&mut T) -> &mut WasiCtx) + Copy + Send + Sync + 'static, +) -> anyhow::Result<()> { + crate::wasi::random::add_to_linker(l, f)?; + crate::wasi::console::add_to_linker(l, f)?; + crate::wasi::types::add_to_linker(l, f)?; + crate::wasi::poll::add_to_linker(l, f)?; + crate::wasi::streams::add_to_linker(l, f)?; + crate::wasi::default_outgoing_http::add_to_linker(l, f)?; + Ok(()) +} diff --git a/wit/command.wit b/wit/command.wit index f61c6a92..eb61b05d 100644 --- a/wit/command.wit +++ b/wit/command.wit @@ -17,5 +17,9 @@ default world command { import preopens: pkg.preopens import exit: pkg.exit + // TEMPORARY: need to teach only_interfaces about unions of worlds + import console: logging.handler + import default-outgoing-HTTP: http.outgoing-handler + export main: func() -> result } From 5eec5e5105b4436fe04f7d0c143a9cf1a4fdbf4d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 11:46:05 -0700 Subject: [PATCH 03/12] use latest wit-component, and fix tests --- Cargo.lock | 111 ++++++++++++++---- host/tests/command.rs | 2 +- host/tests/reactor.rs | 13 +- test-programs/macros/Cargo.toml | 2 +- .../reactor-tests/wit/test-reactor.wit | 3 +- 5 files changed, 100 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2864b9e4..776cbbd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-types", ] @@ -1429,7 +1429,7 @@ dependencies = [ "cargo_metadata", "heck", "quote", - "wit-component", + "wit-component 0.7.4 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", ] [[package]] @@ -1719,7 +1719,7 @@ dependencies = [ "byte-array", "object", "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-encoder", + "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", "wit-bindgen", ] @@ -1732,6 +1732,14 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.25.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511#b17fc48a23152735bafd8f7ee95e3b55683d9511" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-metadata" version = "0.3.1" @@ -1741,8 +1749,20 @@ dependencies = [ "anyhow", "indexmap", "serde", - "wasm-encoder", - "wasmparser 0.102.0", + "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-metadata" +version = "0.3.1" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511#b17fc48a23152735bafd8f7ee95e3b55683d9511" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "wasm-encoder 0.25.0 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", + "wasmparser 0.102.0 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", ] [[package]] @@ -1764,6 +1784,15 @@ dependencies = [ "url", ] +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511#b17fc48a23152735bafd8f7ee95e3b55683d9511" +dependencies = [ + "indexmap", + "url", +] + [[package]] name = "wasmprinter" version = "0.2.54" @@ -1771,7 +1800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc17ae63836d010a2bf001c26a5fedbb9a05e5f71117fb63e0ab878bfbe1ca3" dependencies = [ "anyhow", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1794,7 +1823,7 @@ dependencies = [ "rayon", "serde", "target-lexicon", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -1846,7 +1875,7 @@ dependencies = [ "syn 1.0.109", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser", + "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1871,7 +1900,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-cranelift-shared", "wasmtime-environ", ] @@ -1905,8 +1934,8 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasm-encoder", - "wasmparser 0.102.0", + "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2001,7 +2030,7 @@ dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2014,7 +2043,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2028,7 +2057,7 @@ source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95c dependencies = [ "anyhow", "heck", - "wit-parser", + "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2040,7 +2069,7 @@ dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder", + "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2094,7 +2123,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2102,7 +2131,7 @@ name = "winch-environ" version = "0.7.0" source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" dependencies = [ - "wasmparser 0.102.0", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ", "winch-codegen", ] @@ -2267,8 +2296,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef177b73007d86c720931d0e2ea7e30eb8c9776e58361717743fc1e83cfacfe5" dependencies = [ "anyhow", - "wit-component", - "wit-parser", + "wit-component 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2278,10 +2307,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efdf5b00935b7b52d0e56cae1960f8ac13019a285f5aa762ff6bd7139a5c28a2" dependencies = [ "heck", - "wasm-metadata", + "wasm-metadata 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "wit-bindgen-core", "wit-bindgen-rust-lib", - "wit-component", + "wit-component 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2305,7 +2334,7 @@ dependencies = [ "syn 1.0.109", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component", + "wit-component 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2319,10 +2348,26 @@ dependencies = [ "indexmap", "log", "url", - "wasm-encoder", - "wasm-metadata", - "wasmparser 0.102.0", - "wit-parser", + "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-metadata 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wit-component" +version = "0.7.4" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511#b17fc48a23152735bafd8f7ee95e3b55683d9511" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "url", + "wasm-encoder 0.25.0 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", + "wasm-metadata 0.3.1 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", + "wasmparser 0.102.0 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", + "wit-parser 0.6.4 (git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511)", ] [[package]] @@ -2340,6 +2385,20 @@ dependencies = [ "url", ] +[[package]] +name = "wit-parser" +version = "0.6.4" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b17fc48a23152735bafd8f7ee95e3b55683d9511#b17fc48a23152735bafd8f7ee95e3b55683d9511" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "unicode-xid", + "url", +] + [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/host/tests/command.rs b/host/tests/command.rs index 73588bb5..87ef93fe 100644 --- a/host/tests/command.rs +++ b/host/tests/command.rs @@ -1,7 +1,7 @@ use anyhow::Result; use cap_rand::RngCore; use cap_std::{ambient_authority, fs::Dir, time::Duration}; -use host::{command::add_to_linker, command::wasi::Command, WasiCtx}; +use host::{wasi::command::add_to_linker, wasi::command::Command, WasiCtx}; use std::{ io::{Cursor, Write}, sync::Mutex, diff --git a/host/tests/reactor.rs b/host/tests/reactor.rs index 77f8c40f..1862b507 100644 --- a/host/tests/reactor.rs +++ b/host/tests/reactor.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use host::{command::add_to_linker, WasiCtx}; +use host::WasiCtx; use wasi_cap_std_sync::WasiCtxBuilder; use wasmtime::{ component::{Component, Linker}, @@ -24,7 +24,16 @@ async fn instantiate(path: &str) -> Result<(Store, TestReactor)> { let engine = Engine::new(&config)?; let component = Component::from_file(&engine, &path)?; let mut linker = Linker::new(&engine); - add_to_linker(&mut linker, |x| x)?; + + // The test-reactor wit is not faithful: we need to provide all of these + // in the world as well, in order for the adapter to link. + // However, if we make them available as imports in the world, wit-component + // denies us because the imports are duplicated. + host::wasi::filesystem::add_to_linker(&mut linker, |x| x)?; + host::wasi::streams::add_to_linker(&mut linker, |x| x)?; + host::wasi::environment::add_to_linker(&mut linker, |x| x)?; + host::wasi::preopens::add_to_linker(&mut linker, |x| x)?; + host::wasi::exit::add_to_linker(&mut linker, |x| x)?; let mut store = Store::new(&engine, WasiCtxBuilder::new().build()); diff --git a/test-programs/macros/Cargo.toml b/test-programs/macros/Cargo.toml index 08766bb8..1619b9e3 100644 --- a/test-programs/macros/Cargo.toml +++ b/test-programs/macros/Cargo.toml @@ -13,6 +13,6 @@ test = false quote = "1.0" [build-dependencies] -wit-component = "0.7.0" +wit-component = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b17fc48a23152735bafd8f7ee95e3b55683d9511" } cargo_metadata = "0.15.3" heck = "0.4.0" diff --git a/test-programs/reactor-tests/wit/test-reactor.wit b/test-programs/reactor-tests/wit/test-reactor.wit index bc670c89..50df5599 100644 --- a/test-programs/reactor-tests/wit/test-reactor.wit +++ b/test-programs/reactor-tests/wit/test-reactor.wit @@ -1,6 +1,7 @@ default world test-reactor { - import wasi-environment: wasi.environment +// import environment: wasi.environment +// import streams: io.streams export add-strings: func(s: list) -> u32 export get-strings: func() -> list From 84a09f672252967b4765c0149c7ae29e148e2507 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 16:07:04 -0700 Subject: [PATCH 04/12] move environment, preopens, and exit into a package `wasi-base` so they can be reused in other packages --- wit/command-extended.wit | 6 +++--- wit/command.wit | 10 +++------- wit/{ => deps/wasi-base}/environment.wit | 0 wit/{ => deps/wasi-base}/exit.wit | 0 wit/{ => deps/wasi-base}/preopens.wit | 0 wit/reactor.wit | 6 +++--- 6 files changed, 9 insertions(+), 13 deletions(-) rename wit/{ => deps/wasi-base}/environment.wit (100%) rename wit/{ => deps/wasi-base}/exit.wit (100%) rename wit/{ => deps/wasi-base}/preopens.wit (100%) diff --git a/wit/command-extended.wit b/wit/command-extended.wit index d3785093..39ba8111 100644 --- a/wit/command-extended.wit +++ b/wit/command-extended.wit @@ -13,9 +13,9 @@ default world command-extended { import random: random.random import poll: poll.poll import streams: io.streams - import environment: pkg.environment - import preopens: pkg.preopens - import exit: pkg.exit + import environment: wasi-base.environment + import preopens: wasi-base.preopens + import exit: wasi-base.exit // We should replace all others with `include self.command` // as soon as the unioning of worlds is available: diff --git a/wit/command.wit b/wit/command.wit index eb61b05d..3eaac479 100644 --- a/wit/command.wit +++ b/wit/command.wit @@ -13,13 +13,9 @@ default world command { import random: random.random import poll: poll.poll import streams: io.streams - import environment: pkg.environment - import preopens: pkg.preopens - import exit: pkg.exit - - // TEMPORARY: need to teach only_interfaces about unions of worlds - import console: logging.handler - import default-outgoing-HTTP: http.outgoing-handler + import environment: wasi-base.environment + import preopens: wasi-base.preopens + import exit: wasi-base.exit export main: func() -> result } diff --git a/wit/environment.wit b/wit/deps/wasi-base/environment.wit similarity index 100% rename from wit/environment.wit rename to wit/deps/wasi-base/environment.wit diff --git a/wit/exit.wit b/wit/deps/wasi-base/exit.wit similarity index 100% rename from wit/exit.wit rename to wit/deps/wasi-base/exit.wit diff --git a/wit/preopens.wit b/wit/deps/wasi-base/preopens.wit similarity index 100% rename from wit/preopens.wit rename to wit/deps/wasi-base/preopens.wit diff --git a/wit/reactor.wit b/wit/reactor.wit index 653a6f67..5d1b9d0b 100644 --- a/wit/reactor.wit +++ b/wit/reactor.wit @@ -15,7 +15,7 @@ default world reactor { import streams: io.streams import console: logging.handler import default-outgoing-HTTP: http.outgoing-handler - import environment: pkg.environment - import preopens: pkg.preopens - import exit: pkg.exit + import environment: wasi-base.environment + import preopens: wasi-base.preopens + import exit: wasi-base.exit } From f443f97aab9d136e04fe608945cf19af143f07ab Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 16:11:49 -0700 Subject: [PATCH 05/12] reactor-tests: fixes to use wasi-base packages --- test-programs/reactor-tests/wit/deps/wasi-base | 1 + test-programs/reactor-tests/wit/deps/wasi/environment.wit | 1 - test-programs/reactor-tests/wit/test-reactor.wit | 7 +++++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 120000 test-programs/reactor-tests/wit/deps/wasi-base delete mode 120000 test-programs/reactor-tests/wit/deps/wasi/environment.wit diff --git a/test-programs/reactor-tests/wit/deps/wasi-base b/test-programs/reactor-tests/wit/deps/wasi-base new file mode 120000 index 00000000..ba2dff29 --- /dev/null +++ b/test-programs/reactor-tests/wit/deps/wasi-base @@ -0,0 +1 @@ +../../../../wit/deps/wasi-base \ No newline at end of file diff --git a/test-programs/reactor-tests/wit/deps/wasi/environment.wit b/test-programs/reactor-tests/wit/deps/wasi/environment.wit deleted file mode 120000 index 65d13af8..00000000 --- a/test-programs/reactor-tests/wit/deps/wasi/environment.wit +++ /dev/null @@ -1 +0,0 @@ -../../../../../wit/environment.wit \ No newline at end of file diff --git a/test-programs/reactor-tests/wit/test-reactor.wit b/test-programs/reactor-tests/wit/test-reactor.wit index 50df5599..9dbf706e 100644 --- a/test-programs/reactor-tests/wit/test-reactor.wit +++ b/test-programs/reactor-tests/wit/test-reactor.wit @@ -1,7 +1,10 @@ default world test-reactor { -// import environment: wasi.environment -// import streams: io.streams + import environment: wasi-base.environment + import streams: io.streams + import preopens: wasi-base.preopens + import filesystem: filesystem.filesystem + import exit: wasi-base.exit export add-strings: func(s: list) -> u32 export get-strings: func() -> list From 0343755a7f0693037413de33a1afdbf1549fef4d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 16:12:12 -0700 Subject: [PATCH 06/12] host bindgen macros: fixes * probably there should be a lint if a name provided to `with` doesnt exist --- host/src/wasi/command.rs | 2 -- host/src/wasi/mod.rs | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/host/src/wasi/command.rs b/host/src/wasi/command.rs index 727ddbd5..a3cb3d0c 100644 --- a/host/src/wasi/command.rs +++ b/host/src/wasi/command.rs @@ -11,9 +11,7 @@ wasmtime::component::bindgen!({ }, with: { "filesystem": crate::wasi::filesystem, - "instance_monotonic_clock": crate::wasi::instance_monotonic_clock, "instance_network": crate::wasi::instance_network, - "instance_wall_clock": crate::wasi::instance_wall_clock, "ip_name_lookup": crate::wasi::ip_name_lookup, "monotonic_clock": crate::wasi::monotonic_clock, "network": crate::wasi::network, diff --git a/host/src/wasi/mod.rs b/host/src/wasi/mod.rs index a99f0ceb..f1ae919f 100644 --- a/host/src/wasi/mod.rs +++ b/host/src/wasi/mod.rs @@ -3,7 +3,8 @@ pub mod proxy; wasmtime::component::bindgen!({ path: "../wit", - world: "command", + // The commmand-extended world happens to encompass all of the available interfaces: + world: "command-extended", only_interfaces: true, tracing: true, async: true, From 6023374a8d5b8fff704c378fc0c61366a33bc235 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 16:23:27 -0700 Subject: [PATCH 07/12] io: inline implementation --- host/src/io.rs | 320 ++++++++++++++++--------------------------------- 1 file changed, 102 insertions(+), 218 deletions(-) diff --git a/host/src/io.rs b/host/src/io.rs index 8c62c3cd..8f887c0a 100644 --- a/host/src/io.rs +++ b/host/src/io.rs @@ -17,212 +17,18 @@ impl From for streams::Error { } } -async fn drop_input_stream(ctx: &mut WasiCtx, stream: InputStream) -> anyhow::Result<()> { - ctx.table_mut() - .delete::>(stream)?; - Ok(()) -} - -async fn drop_output_stream(ctx: &mut WasiCtx, stream: OutputStream) -> anyhow::Result<()> { - ctx.table_mut() - .delete::>(stream)?; - Ok(()) -} - -async fn read( - ctx: &mut WasiCtx, - stream: InputStream, - len: u64, -) -> Result<(Vec, bool), streams::Error> { - let s: &mut Box = ctx.table_mut().get_input_stream_mut(stream)?; - - // Len could be any `u64` value, but we don't want to - // allocate too much up front, so make a wild guess - // of an upper bound for the buffer size. - let buffer_len = std::cmp::min(len, 0x400000) as _; - let mut buffer = vec![0; buffer_len]; - - let (bytes_read, end) = s.read(&mut buffer).await?; - - buffer.truncate(bytes_read as usize); - - Ok((buffer, end)) -} - -async fn blocking_read( - ctx: &mut WasiCtx, - stream: InputStream, - len: u64, -) -> Result<(Vec, bool), streams::Error> { - // TODO: When this is really async make this block. - read(ctx, stream, len).await -} - -async fn write( - ctx: &mut WasiCtx, - stream: OutputStream, - bytes: Vec, -) -> Result { - let s: &mut Box = - ctx.table_mut().get_output_stream_mut(stream)?; - - let bytes_written: u64 = s.write(&bytes).await?; - - Ok(u64::try_from(bytes_written).unwrap()) -} - -async fn blocking_write( - ctx: &mut WasiCtx, - stream: OutputStream, - bytes: Vec, -) -> Result { - // TODO: When this is really async make this block. - write(ctx, stream, bytes).await -} - -async fn skip( - ctx: &mut WasiCtx, - stream: InputStream, - len: u64, -) -> Result<(u64, bool), streams::Error> { - let s: &mut Box = ctx.table_mut().get_input_stream_mut(stream)?; - - let (bytes_skipped, end) = s.skip(len).await?; - - Ok((bytes_skipped, end)) -} - -async fn blocking_skip( - ctx: &mut WasiCtx, - stream: InputStream, - len: u64, -) -> Result<(u64, bool), streams::Error> { - // TODO: When this is really async make this block. - skip(ctx, stream, len).await -} - -async fn write_zeroes( - ctx: &mut WasiCtx, - stream: OutputStream, - len: u64, -) -> Result { - let s: &mut Box = - ctx.table_mut().get_output_stream_mut(stream)?; - - let bytes_written: u64 = s.write_zeroes(len).await?; - - Ok(bytes_written) -} - -async fn blocking_write_zeroes( - ctx: &mut WasiCtx, - stream: OutputStream, - len: u64, -) -> Result { - // TODO: When this is really async make this block. - write_zeroes(ctx, stream, len).await -} - -async fn splice( - _ctx: &mut WasiCtx, - _src: InputStream, - _dst: OutputStream, - _len: u64, -) -> Result<(u64, bool), streams::Error> { - // TODO: We can't get two streams at the same time because they both - // carry the exclusive lifetime of `ctx`. When [`get_many_mut`] is - // stabilized, that could allow us to add a `get_many_stream_mut` or - // so which lets us do this. - // - // [`get_many_mut`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.get_many_mut - /* - let s: &mut Box = ctx - .table_mut() - .get_input_stream_mut(src) - ?; - let d: &mut Box = ctx - .table_mut() - .get_output_stream_mut(dst) - ?; - - let bytes_spliced: u64 = s.splice(&mut **d, len).await?; - - Ok(bytes_spliced) - */ - - todo!() -} - -async fn blocking_splice( - ctx: &mut WasiCtx, - src: InputStream, - dst: OutputStream, - len: u64, -) -> Result<(u64, bool), streams::Error> { - // TODO: When this is really async make this block. - splice(ctx, src, dst, len).await -} - -async fn forward( - _ctx: &mut WasiCtx, - _src: InputStream, - _dst: OutputStream, -) -> Result { - // TODO: We can't get two streams at the same time because they both - // carry the exclusive lifetime of `ctx`. When [`get_many_mut`] is - // stabilized, that could allow us to add a `get_many_stream_mut` or - // so which lets us do this. - // - // [`get_many_mut`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.get_many_mut - /* - let s: &mut Box = ctx - .table_mut() - .get_input_stream_mut(src) - ?; - let d: &mut Box = ctx - .table_mut() - .get_output_stream_mut(dst) - ?; - - let bytes_spliced: u64 = s.splice(&mut **d, len).await?; - - Ok(bytes_spliced) - */ - - todo!() -} - -async fn subscribe_to_input_stream( - ctx: &mut WasiCtx, - stream: InputStream, -) -> anyhow::Result { - Ok(ctx - .table_mut() - .push(Box::new(PollableEntry::Read(stream)))?) -} - -async fn subscribe_to_output_stream( - ctx: &mut WasiCtx, - stream: OutputStream, -) -> anyhow::Result { - Ok(ctx - .table_mut() - .push(Box::new(PollableEntry::Write(stream)))?) -} - -// Implementatations of the traits for both the command and proxy worlds. -// The bodies have been pulled out into functions above to allow them to -// be shared between the two. Ideally, we should add features to the -// bindings to facilitate this kind of sharing. - #[async_trait::async_trait] impl streams::Host for WasiCtx { async fn drop_input_stream(&mut self, stream: InputStream) -> anyhow::Result<()> { - drop_input_stream(self, stream).await + self.table_mut() + .delete::>(stream)?; + Ok(()) } async fn drop_output_stream(&mut self, stream: OutputStream) -> anyhow::Result<()> { - drop_output_stream(self, stream).await + self.table_mut() + .delete::>(stream)?; + Ok(()) } async fn read( @@ -230,7 +36,20 @@ impl streams::Host for WasiCtx { stream: InputStream, len: u64, ) -> Result<(Vec, bool), streams::Error> { - read(self, stream, len).await + let s: &mut Box = + self.table_mut().get_input_stream_mut(stream)?; + + // Len could be any `u64` value, but we don't want to + // allocate too much up front, so make a wild guess + // of an upper bound for the buffer size. + let buffer_len = std::cmp::min(len, 0x400000) as _; + let mut buffer = vec![0; buffer_len]; + + let (bytes_read, end) = s.read(&mut buffer).await?; + + buffer.truncate(bytes_read as usize); + + Ok((buffer, end)) } async fn blocking_read( @@ -238,11 +57,17 @@ impl streams::Host for WasiCtx { stream: InputStream, len: u64, ) -> Result<(Vec, bool), streams::Error> { - blocking_read(self, stream, len).await + // TODO: When this is really async make this block. + self.read(stream, len).await } async fn write(&mut self, stream: OutputStream, bytes: Vec) -> Result { - write(self, stream, bytes).await + let s: &mut Box = + self.table_mut().get_output_stream_mut(stream)?; + + let bytes_written: u64 = s.write(&bytes).await?; + + Ok(u64::try_from(bytes_written).unwrap()) } async fn blocking_write( @@ -250,11 +75,17 @@ impl streams::Host for WasiCtx { stream: OutputStream, bytes: Vec, ) -> Result { - blocking_write(self, stream, bytes).await + // TODO: When this is really async make this block. + self.write(stream, bytes).await } async fn skip(&mut self, stream: InputStream, len: u64) -> Result<(u64, bool), streams::Error> { - skip(self, stream, len).await + let s: &mut Box = + self.table_mut().get_input_stream_mut(stream)?; + + let (bytes_skipped, end) = s.skip(len).await?; + + Ok((bytes_skipped, end)) } async fn blocking_skip( @@ -262,7 +93,8 @@ impl streams::Host for WasiCtx { stream: InputStream, len: u64, ) -> Result<(u64, bool), streams::Error> { - blocking_skip(self, stream, len).await + // TODO: When this is really async make this block. + self.skip(stream, len).await } async fn write_zeroes( @@ -270,7 +102,12 @@ impl streams::Host for WasiCtx { stream: OutputStream, len: u64, ) -> Result { - write_zeroes(self, stream, len).await + let s: &mut Box = + self.table_mut().get_output_stream_mut(stream)?; + + let bytes_written: u64 = s.write_zeroes(len).await?; + + Ok(bytes_written) } async fn blocking_write_zeroes( @@ -278,16 +115,37 @@ impl streams::Host for WasiCtx { stream: OutputStream, len: u64, ) -> Result { - blocking_write_zeroes(self, stream, len).await + // TODO: When this is really async make this block. + self.write_zeroes(stream, len).await } async fn splice( &mut self, - src: InputStream, - dst: OutputStream, - len: u64, + _src: InputStream, + _dst: OutputStream, + _len: u64, ) -> Result<(u64, bool), streams::Error> { - splice(self, src, dst, len).await + // TODO: We can't get two streams at the same time because they both + // carry the exclusive lifetime of `ctx`. When [`get_many_mut`] is + // stabilized, that could allow us to add a `get_many_stream_mut` or + // so which lets us do this. + // + // [`get_many_mut`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.get_many_mut + /* + let s: &mut Box = ctx + .table_mut() + .get_input_stream_mut(src) + ?; + let d: &mut Box = ctx + .table_mut() + .get_output_stream_mut(dst) + ?; + + let bytes_spliced: u64 = s.splice(&mut **d, len).await?; + + Ok(bytes_spliced) + */ + todo!() } async fn blocking_splice( @@ -296,25 +154,51 @@ impl streams::Host for WasiCtx { dst: OutputStream, len: u64, ) -> Result<(u64, bool), streams::Error> { - blocking_splice(self, src, dst, len).await + // TODO: When this is really async make this block. + self.splice(src, dst, len).await } async fn forward( &mut self, - src: InputStream, - dst: OutputStream, + _src: InputStream, + _dst: OutputStream, ) -> Result { - forward(self, src, dst).await + // TODO: We can't get two streams at the same time because they both + // carry the exclusive lifetime of `ctx`. When [`get_many_mut`] is + // stabilized, that could allow us to add a `get_many_stream_mut` or + // so which lets us do this. + // + // [`get_many_mut`]: https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.get_many_mut + /* + let s: &mut Box = ctx + .table_mut() + .get_input_stream_mut(src) + ?; + let d: &mut Box = ctx + .table_mut() + .get_output_stream_mut(dst) + ?; + + let bytes_spliced: u64 = s.splice(&mut **d, len).await?; + + Ok(bytes_spliced) + */ + + todo!() } async fn subscribe_to_input_stream(&mut self, stream: InputStream) -> anyhow::Result { - subscribe_to_input_stream(self, stream).await + Ok(self + .table_mut() + .push(Box::new(PollableEntry::Read(stream)))?) } async fn subscribe_to_output_stream( &mut self, stream: OutputStream, ) -> anyhow::Result { - subscribe_to_output_stream(self, stream).await + Ok(self + .table_mut() + .push(Box::new(PollableEntry::Write(stream)))?) } } From ee807043b8549cdec102f7683f4807d0ab047979 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 17:42:29 -0700 Subject: [PATCH 08/12] poll: inline definitions into single trait --- host/src/poll.rs | 99 +++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/host/src/poll.rs b/host/src/poll.rs index f698a484..c4fa8a46 100644 --- a/host/src/poll.rs +++ b/host/src/poll.rs @@ -30,55 +30,6 @@ pub(crate) enum PollableEntry { TcpSocket(TcpSocket), } -async fn drop_pollable(ctx: &mut WasiCtx, pollable: Pollable) -> anyhow::Result<()> { - ctx.table_mut() - .delete::(pollable) - .map_err(convert)?; - Ok(()) -} - -async fn poll_oneoff(ctx: &mut WasiCtx, futures: Vec) -> anyhow::Result> { - use wasi_common::sched::{Poll, Userdata}; - - // Convert `futures` into `Poll` subscriptions. - let mut poll = Poll::new(); - let len = futures.len(); - for (index, future) in futures.into_iter().enumerate() { - let userdata = Userdata::from(index as u64); - - match *ctx.table().get(future).map_err(convert)? { - PollableEntry::Read(stream) => { - let wasi_stream: &dyn wasi_common::InputStream = - ctx.table().get_input_stream(stream).map_err(convert)?; - poll.subscribe_read(wasi_stream, userdata); - } - PollableEntry::Write(stream) => { - let wasi_stream: &dyn wasi_common::OutputStream = - ctx.table().get_output_stream(stream).map_err(convert)?; - poll.subscribe_write(wasi_stream, userdata); - } - PollableEntry::MonotonicClock(when, absolute) => { - poll.subscribe_monotonic_clock(&*ctx.clocks.monotonic, when, absolute, userdata); - } - PollableEntry::TcpSocket(tcp_socket) => { - let wasi_tcp_socket: &dyn wasi_common::WasiTcpSocket = - ctx.table().get_tcp_socket(tcp_socket).map_err(convert)?; - poll.subscribe_tcp_socket(wasi_tcp_socket, userdata); - } - } - } - - // Do the poll. - ctx.sched.poll_oneoff(&mut poll).await?; - - // Convert the results into a list of `u8` to return. - let mut results = vec![0_u8; len]; - for (_result, data) in poll.results() { - results[u64::from(data) as usize] = u8::from(true); - } - Ok(results) -} - // Implementatations of the interface. The bodies had been pulled out into // functions above to allow them to be shared between the two worlds, which // used to require different traits . Features have been added to facilitate @@ -88,10 +39,56 @@ async fn poll_oneoff(ctx: &mut WasiCtx, futures: Vec) -> anyhow::Resul #[async_trait::async_trait] impl wasi::poll::Host for WasiCtx { async fn drop_pollable(&mut self, pollable: Pollable) -> anyhow::Result<()> { - drop_pollable(self, pollable).await + self.table_mut() + .delete::(pollable) + .map_err(convert)?; + Ok(()) } async fn poll_oneoff(&mut self, futures: Vec) -> anyhow::Result> { - poll_oneoff(self, futures).await + use wasi_common::sched::{Poll, Userdata}; + + // Convert `futures` into `Poll` subscriptions. + let mut poll = Poll::new(); + let len = futures.len(); + for (index, future) in futures.into_iter().enumerate() { + let userdata = Userdata::from(index as u64); + + match *self.table().get(future).map_err(convert)? { + PollableEntry::Read(stream) => { + let wasi_stream: &dyn wasi_common::InputStream = + self.table().get_input_stream(stream).map_err(convert)?; + poll.subscribe_read(wasi_stream, userdata); + } + PollableEntry::Write(stream) => { + let wasi_stream: &dyn wasi_common::OutputStream = + self.table().get_output_stream(stream).map_err(convert)?; + poll.subscribe_write(wasi_stream, userdata); + } + PollableEntry::MonotonicClock(when, absolute) => { + poll.subscribe_monotonic_clock( + &*self.clocks.monotonic, + when, + absolute, + userdata, + ); + } + PollableEntry::TcpSocket(tcp_socket) => { + let wasi_tcp_socket: &dyn wasi_common::WasiTcpSocket = + self.table().get_tcp_socket(tcp_socket).map_err(convert)?; + poll.subscribe_tcp_socket(wasi_tcp_socket, userdata); + } + } + } + + // Do the poll. + self.sched.poll_oneoff(&mut poll).await?; + + // Convert the results into a list of `u8` to return. + let mut results = vec![0_u8; len]; + for (_result, data) in poll.results() { + results[u64::from(data) as usize] = u8::from(true); + } + Ok(results) } } From 949b988642cd9f199ddcf8ef8cc3f119286997b9 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Apr 2023 17:42:39 -0700 Subject: [PATCH 09/12] random: inline implementations into single trait --- host/src/random.rs | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/host/src/random.rs b/host/src/random.rs index 2cf9b514..6d1d3963 100644 --- a/host/src/random.rs +++ b/host/src/random.rs @@ -3,37 +3,20 @@ use cap_rand::{distributions::Standard, Rng}; use crate::wasi; use crate::WasiCtx; -async fn get_random_bytes(ctx: &mut WasiCtx, len: u64) -> anyhow::Result> { - Ok((&mut ctx.random) - .sample_iter(Standard) - .take(len as usize) - .collect()) -} - -async fn get_random_u64(ctx: &mut WasiCtx) -> anyhow::Result { - Ok(ctx.random.sample(Standard)) -} - -async fn insecure_random(_ctx: &mut WasiCtx) -> anyhow::Result<(u64, u64)> { - Ok((0, 0)) -} - -// Implementatations of the traits for both the command and proxy worlds. -// The bodies have been pulled out into functions above to allow them to -// be shared between the two. Ideally, we should add features to the -// bindings to facilitate this kind of sharing. - #[async_trait::async_trait] impl wasi::random::Host for WasiCtx { async fn get_random_bytes(&mut self, len: u64) -> anyhow::Result> { - get_random_bytes(self, len).await + Ok((&mut self.random) + .sample_iter(Standard) + .take(len as usize) + .collect()) } async fn get_random_u64(&mut self) -> anyhow::Result { - get_random_u64(self).await + Ok(self.random.sample(Standard)) } async fn insecure_random(&mut self) -> anyhow::Result<(u64, u64)> { - insecure_random(self).await + Ok((0, 0)) } } From 345306e1c17d14b77e8c3b93edc41b52d0284083 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 14 Apr 2023 08:10:23 -0700 Subject: [PATCH 10/12] bump wasmtime and use new syntax, but it doesnt quite work yet --- Cargo.lock | 56 ++++++++++++++++++++++---------------------- host/Cargo.toml | 2 +- host/src/wasi/mod.rs | 27 +++++++++++++++++---- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 776cbbd7..26d0b82c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,7 +357,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-entity", ] @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "bumpalo", "cranelift-bforest", @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-codegen-shared", ] @@ -393,12 +393,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" [[package]] name = "cranelift-control" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "arbitrary", ] @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "serde", ] @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-codegen", "log", @@ -425,12 +425,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" [[package]] name = "cranelift-native" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-codegen", "libc", @@ -440,7 +440,7 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1806,7 +1806,7 @@ dependencies = [ [[package]] name = "wasmtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "async-trait", @@ -1840,7 +1840,7 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cfg-if", ] @@ -1848,7 +1848,7 @@ dependencies = [ [[package]] name = "wasmtime-cache" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "base64", @@ -1867,7 +1867,7 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "proc-macro2", @@ -1881,12 +1881,12 @@ dependencies = [ [[package]] name = "wasmtime-component-util" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" [[package]] name = "wasmtime-cranelift" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cranelift-codegen", @@ -1908,7 +1908,7 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cranelift-codegen", @@ -1923,7 +1923,7 @@ dependencies = [ [[package]] name = "wasmtime-environ" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cranelift-entity", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "wasmtime-fiber" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cc", "cfg-if", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "addr2line", "anyhow", @@ -1980,7 +1980,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "object", "once_cell", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cfg-if", "libc", @@ -2000,7 +2000,7 @@ dependencies = [ [[package]] name = "wasmtime-runtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cc", @@ -2025,7 +2025,7 @@ dependencies = [ [[package]] name = "wasmtime-types" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "cranelift-entity", "serde", @@ -2036,7 +2036,7 @@ dependencies = [ [[package]] name = "wasmtime-winch" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cranelift-codegen", @@ -2053,7 +2053,7 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "heck", @@ -2115,7 +2115,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "anyhow", "cranelift-codegen", @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "winch-environ" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=f684a5fbeea6ab95cb763d370e6ae7665aa1190d#f684a5fbeea6ab95cb763d370e6ae7665aa1190d" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" dependencies = [ "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ", diff --git a/host/Cargo.toml b/host/Cargo.toml index e4f8e5a9..f4a609fb 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -12,7 +12,7 @@ cap-rand = { workspace = true } cap-net-ext = { workspace = true } tokio = { version = "1.22.0", features = [ "rt", "macros" ] } tracing = { workspace = true } -wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "f684a5fbeea6ab95cb763d370e6ae7665aa1190d", features = ["component-model"] } +wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "9425a252bb00294194f7ca259f50ca09bd333138", features = ["component-model"] } wasi-common = { path = "../wasi-common" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" } clap = { version = "4.1.9", features = ["derive"] } diff --git a/host/src/wasi/mod.rs b/host/src/wasi/mod.rs index f1ae919f..e053a5db 100644 --- a/host/src/wasi/mod.rs +++ b/host/src/wasi/mod.rs @@ -2,10 +2,29 @@ pub mod command; pub mod proxy; wasmtime::component::bindgen!({ - path: "../wit", - // The commmand-extended world happens to encompass all of the available interfaces: - world: "command-extended", - only_interfaces: true, + // path: "../wit", + // This is a union of the imports in the command and proxy worlds: + interfaces: " + import wall-clock: clocks.wall-clock + import monotonic-clock: clocks.monotonic-clock + import timezone: clocks.timezone + import filesystem: filesystem.filesystem + import instance-network: sockets.instance-network + import ip-name-lookup: sockets.ip-name-lookup + import network: sockets.network + import tcp-create-socket: sockets.tcp-create-socket + import tcp: sockets.tcp + import udp-create-socket: sockets.udp-create-socket + import udp: sockets.udp + import random: random.random + import poll: poll.poll + import streams: io.streams + import environment: wasi-base.environment + import preopens: wasi-base.preopens + import exit: wasi-base.exit + import console: logging.handler + import default-outgoing-HTTP: http.outgoing-handler + ", tracing: true, async: true, trappable_error_type: { From d59a45e19562b374f257e0699bd3c8e6693a7415 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 14 Apr 2023 10:19:28 -0700 Subject: [PATCH 11/12] wasmtime matches trace pr --- Cargo.lock | 56 ++++++++++++++++++++++++------------------------- host/Cargo.toml | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26d0b82c..8e329759 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,7 +357,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-entity", ] @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "bumpalo", "cranelift-bforest", @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-codegen-shared", ] @@ -393,12 +393,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" [[package]] name = "cranelift-control" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "arbitrary", ] @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "serde", ] @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-codegen", "log", @@ -425,12 +425,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" [[package]] name = "cranelift-native" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-codegen", "libc", @@ -440,7 +440,7 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1806,7 +1806,7 @@ dependencies = [ [[package]] name = "wasmtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "async-trait", @@ -1840,7 +1840,7 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cfg-if", ] @@ -1848,7 +1848,7 @@ dependencies = [ [[package]] name = "wasmtime-cache" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "base64", @@ -1867,7 +1867,7 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "proc-macro2", @@ -1881,12 +1881,12 @@ dependencies = [ [[package]] name = "wasmtime-component-util" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" [[package]] name = "wasmtime-cranelift" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cranelift-codegen", @@ -1908,7 +1908,7 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cranelift-codegen", @@ -1923,7 +1923,7 @@ dependencies = [ [[package]] name = "wasmtime-environ" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cranelift-entity", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "wasmtime-fiber" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cc", "cfg-if", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "addr2line", "anyhow", @@ -1980,7 +1980,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "object", "once_cell", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cfg-if", "libc", @@ -2000,7 +2000,7 @@ dependencies = [ [[package]] name = "wasmtime-runtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cc", @@ -2025,7 +2025,7 @@ dependencies = [ [[package]] name = "wasmtime-types" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "cranelift-entity", "serde", @@ -2036,7 +2036,7 @@ dependencies = [ [[package]] name = "wasmtime-winch" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cranelift-codegen", @@ -2053,7 +2053,7 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "heck", @@ -2115,7 +2115,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "anyhow", "cranelift-codegen", @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "winch-environ" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=9425a252bb00294194f7ca259f50ca09bd333138#9425a252bb00294194f7ca259f50ca09bd333138" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" dependencies = [ "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ", diff --git a/host/Cargo.toml b/host/Cargo.toml index f4a609fb..a4f06f2e 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -12,7 +12,7 @@ cap-rand = { workspace = true } cap-net-ext = { workspace = true } tokio = { version = "1.22.0", features = [ "rt", "macros" ] } tracing = { workspace = true } -wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "9425a252bb00294194f7ca259f50ca09bd333138", features = ["component-model"] } +wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "cc1c14ac913be13329e5cfc91c33e053ab722132", features = ["component-model"] } wasi-common = { path = "../wasi-common" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" } clap = { version = "4.1.9", features = ["derive"] } From cc6da7e2e57fa4fc0c47cd2275cff63d93c63b82 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 18 Apr 2023 10:34:26 -0700 Subject: [PATCH 12/12] latest wasmtime, where path works with interfaces needed to bump the wit crate as well --- Cargo.lock | 115 ++++++++++++++++++++++++++----------------- host/Cargo.toml | 2 +- host/src/wasi/mod.rs | 2 +- verify/Cargo.toml | 2 +- 4 files changed, 73 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e329759..bf3cff2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,7 +357,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-entity", ] @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "bumpalo", "cranelift-bforest", @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-codegen-shared", ] @@ -393,12 +393,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" [[package]] name = "cranelift-control" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "arbitrary", ] @@ -406,7 +406,7 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "serde", ] @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-codegen", "log", @@ -425,12 +425,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" [[package]] name = "cranelift-native" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-codegen", "libc", @@ -440,7 +440,7 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.96.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -448,7 +448,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmtime-types", ] @@ -1793,20 +1793,30 @@ dependencies = [ "url", ] +[[package]] +name = "wasmparser" +version = "0.103.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" +dependencies = [ + "indexmap", + "url", +] + [[package]] name = "wasmprinter" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc17ae63836d010a2bf001c26a5fedbb9a05e5f71117fb63e0ab878bfbe1ca3" +checksum = "51befda9d7eefac615a2ef75f42d2f2bd243cdabaa141a8ea0f9ffa3fc79ccf4" dependencies = [ "anyhow", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", ] [[package]] name = "wasmtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "async-trait", @@ -1823,7 +1833,7 @@ dependencies = [ "rayon", "serde", "target-lexicon", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -1840,7 +1850,7 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cfg-if", ] @@ -1848,7 +1858,7 @@ dependencies = [ [[package]] name = "wasmtime-cache" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "base64", @@ -1867,7 +1877,7 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "proc-macro2", @@ -1875,18 +1885,18 @@ dependencies = [ "syn 1.0.109", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wit-parser 0.7.0", ] [[package]] name = "wasmtime-component-util" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" [[package]] name = "wasmtime-cranelift" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cranelift-codegen", @@ -1900,7 +1910,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmtime-cranelift-shared", "wasmtime-environ", ] @@ -1908,7 +1918,7 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cranelift-codegen", @@ -1923,7 +1933,7 @@ dependencies = [ [[package]] name = "wasmtime-environ" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cranelift-entity", @@ -1935,7 +1945,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasm-encoder 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -1944,7 +1954,7 @@ dependencies = [ [[package]] name = "wasmtime-fiber" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cc", "cfg-if", @@ -1956,7 +1966,7 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "addr2line", "anyhow", @@ -1980,7 +1990,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "object", "once_cell", @@ -1990,7 +2000,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cfg-if", "libc", @@ -2000,7 +2010,7 @@ dependencies = [ [[package]] name = "wasmtime-runtime" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cc", @@ -2025,25 +2035,25 @@ dependencies = [ [[package]] name = "wasmtime-types" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", ] [[package]] name = "wasmtime-winch" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2053,18 +2063,18 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" version = "9.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "heck", - "wit-parser 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wit-parser 0.7.0", ] [[package]] name = "wast" -version = "55.0.0" +version = "56.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05" +checksum = "6b54185c051d7bbe23757d50fe575880a2426a2f06d2e9f6a10fd9a4a42920c0" dependencies = [ "leb128", "memchr", @@ -2074,9 +2084,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091" +checksum = "56681922808216ab86d96bb750f70d500b5a7800e41564290fd46bb773581299" dependencies = [ "wast", ] @@ -2115,7 +2125,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ "anyhow", "cranelift-codegen", @@ -2123,15 +2133,15 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", ] [[package]] name = "winch-environ" version = "0.7.0" -source = "git+https://github.com/bytecodealliance/wasmtime?rev=cc1c14ac913be13329e5cfc91c33e053ab722132#cc1c14ac913be13329e5cfc91c33e053ab722132" +source = "git+https://github.com/bytecodealliance/wasmtime?rev=299131ae2d6655c49138bfab2c4469650763ef3b#299131ae2d6655c49138bfab2c4469650763ef3b" dependencies = [ - "wasmparser 0.102.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.103.0", "wasmtime-environ", "winch-codegen", ] @@ -2399,6 +2409,21 @@ dependencies = [ "url", ] +[[package]] +name = "wit-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "365273e457e2cacf762df10df4b1e0d4d9912b5332ff4cf2a172760fd67b7ec4" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "unicode-xid", + "url", +] + [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/host/Cargo.toml b/host/Cargo.toml index 2649e9a2..0f851d9e 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -12,7 +12,7 @@ cap-rand = { workspace = true } cap-net-ext = { workspace = true } tokio = { version = "1.22.0", features = [ "rt", "macros" ] } tracing = { workspace = true } -wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "cc1c14ac913be13329e5cfc91c33e053ab722132", features = ["component-model"] } +wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "299131ae2d6655c49138bfab2c4469650763ef3b", features = ["component-model"] } wasi-common = { path = "../wasi-common" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" } clap = { version = "4.1.9", features = ["derive"] } diff --git a/host/src/wasi/mod.rs b/host/src/wasi/mod.rs index e053a5db..4c0d121b 100644 --- a/host/src/wasi/mod.rs +++ b/host/src/wasi/mod.rs @@ -2,7 +2,7 @@ pub mod command; pub mod proxy; wasmtime::component::bindgen!({ - // path: "../wit", + path: "../wit", // This is a union of the imports in the command and proxy worlds: interfaces: " import wall-clock: clocks.wall-clock diff --git a/verify/Cargo.toml b/verify/Cargo.toml index 70d6d05a..ab13d93f 100644 --- a/verify/Cargo.toml +++ b/verify/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] wasmparser = "0.92.0" -wat = "1.0.61" +wat = "1.0.62" anyhow = "1"