Skip to content

Commit 6bf029b

Browse files
committed
Update wasmtime/wasm-tools dependencies
This updates the Wasmtime dependency from 29.0.1 to 32.0.0 released today. Changes here are mostly around WASI APIs and a few minor differences here and there. Most updates were mechanical. Additionally this updates wasm-tools dependencies to their latest 229 versions. This is mostly to just keep things up-to-date as opposed to having a burning need to get any one particular update. Signed-off-by: Alex Crichton <[email protected]>
1 parent 4c6f0e2 commit 6bf029b

File tree

10 files changed

+584
-447
lines changed

10 files changed

+584
-447
lines changed

Cargo.lock

Lines changed: 249 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ toml = "0.8"
147147
tracing = { version = "0.1", features = ["log"] }
148148
tracing-opentelemetry = { version = "0.29", default-features = false, features = ["metrics"] }
149149
url = "2"
150-
wasi-common-preview1 = { version = "25.0.0", package = "wasi-common", features = [
150+
wasi-common-preview1 = { version = "32.0.0", package = "wasi-common", features = [
151151
"tokio",
152152
] }
153153
wasm-pkg-client = "0.10"
154154
wasm-pkg-common = "0.10"
155-
wasmtime = "29.0.1"
156-
wasmtime-wasi = "29.0.1"
157-
wasmtime-wasi-http = "29.0.1"
155+
wasmtime = "32.0.0"
156+
wasmtime-wasi = "32.0.0"
157+
wasmtime-wasi-http = "32.0.0"
158158

159-
wasm-encoder = "0.227"
160-
wasm-metadata = "0.227"
161-
wasmparser = "0.227"
162-
wit-component = "0.227"
163-
wit-parser = "0.227"
159+
wasm-encoder = "0.229"
160+
wasm-metadata = "0.229"
161+
wasmparser = "0.229"
162+
wit-component = "0.229"
163+
wit-parser = "0.229"
164164

165165
spin-componentize = { path = "crates/componentize" }
166166

crates/factor-outbound-http/src/wasi.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use spin_factor_outbound_networking::{ComponentTlsConfigs, OutboundAllowedHosts}
99
use spin_factors::{wasmtime::component::ResourceTable, RuntimeFactorsInstanceState};
1010
use tokio::{net::TcpStream, time::timeout};
1111
use tracing::{field::Empty, instrument, Instrument};
12+
use wasmtime_wasi::{IoImpl, IoView};
1213
use wasmtime_wasi_http::{
1314
bindings::http::types::ErrorCode,
1415
body::HyperOutgoingBody,
@@ -34,7 +35,7 @@ pub(crate) fn add_to_linker<T: Send + 'static>(
3435
let get_data_with_table = ctx.get_data_with_table_fn();
3536
let closure = type_annotate(move |data| {
3637
let (state, table) = get_data_with_table(data);
37-
WasiHttpImpl(WasiHttpImplInner { state, table })
38+
WasiHttpImpl(IoImpl(WasiHttpImplInner { state, table }))
3839
});
3940
let linker = ctx.linker();
4041
wasmtime_wasi_http::bindings::http::outgoing_handler::add_to_linker_get_host(linker, closure)?;
@@ -51,7 +52,7 @@ impl OutboundHttpFactor {
5152
runtime_instance_state: &mut impl RuntimeFactorsInstanceState,
5253
) -> Option<WasiHttpImpl<impl WasiHttpView + '_>> {
5354
let (state, table) = runtime_instance_state.get_with_table::<OutboundHttpFactor>()?;
54-
Some(WasiHttpImpl(WasiHttpImplInner { state, table }))
55+
Some(WasiHttpImpl(IoImpl(WasiHttpImplInner { state, table })))
5556
}
5657
}
5758

@@ -60,15 +61,17 @@ pub(crate) struct WasiHttpImplInner<'a> {
6061
table: &'a mut ResourceTable,
6162
}
6263

64+
impl IoView for WasiHttpImplInner<'_> {
65+
fn table(&mut self) -> &mut ResourceTable {
66+
self.table
67+
}
68+
}
69+
6370
impl WasiHttpView for WasiHttpImplInner<'_> {
6471
fn ctx(&mut self) -> &mut WasiHttpCtx {
6572
&mut self.state.wasi_http_ctx
6673
}
6774

68-
fn table(&mut self) -> &mut ResourceTable {
69-
self.table
70-
}
71-
7275
#[instrument(
7376
name = "spin_outbound_http.send_request",
7477
skip_all,

crates/factor-wasi/src/io.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ use std::sync::{Arc, Mutex};
33

44
use async_trait::async_trait;
55
use spin_factors::anyhow;
6-
use wasmtime_wasi::{
7-
HostInputStream, HostOutputStream, StdinStream, StdoutStream, StreamError, Subscribe,
8-
};
6+
use wasmtime_wasi::{InputStream, OutputStream, Pollable, StdinStream, StdoutStream, StreamError};
97

10-
/// A [`HostOutputStream`] that writes to a `Write` type.
8+
/// A [`OutputStream`] that writes to a `Write` type.
119
///
1210
/// `StdinStream::stream` and `StdoutStream::new` can be called more than once in components
1311
/// which are composed of multiple subcomponents, since each subcomponent will potentially want
@@ -32,7 +30,7 @@ impl<T> Clone for PipedWriteStream<T> {
3230
}
3331
}
3432

35-
impl<T: Write + Send + Sync + 'static> HostOutputStream for PipedWriteStream<T> {
33+
impl<T: Write + Send + Sync + 'static> OutputStream for PipedWriteStream<T> {
3634
fn write(&mut self, bytes: bytes::Bytes) -> Result<(), StreamError> {
3735
self.0
3836
.lock()
@@ -55,7 +53,7 @@ impl<T: Write + Send + Sync + 'static> HostOutputStream for PipedWriteStream<T>
5553
}
5654

5755
impl<T: Write + Send + Sync + 'static> StdoutStream for PipedWriteStream<T> {
58-
fn stream(&self) -> Box<dyn HostOutputStream> {
56+
fn stream(&self) -> Box<dyn OutputStream> {
5957
Box::new(self.clone())
6058
}
6159

@@ -65,11 +63,11 @@ impl<T: Write + Send + Sync + 'static> StdoutStream for PipedWriteStream<T> {
6563
}
6664

6765
#[async_trait]
68-
impl<T: Write + Send + Sync + 'static> Subscribe for PipedWriteStream<T> {
66+
impl<T: Write + Send + Sync + 'static> Pollable for PipedWriteStream<T> {
6967
async fn ready(&mut self) {}
7068
}
7169

72-
/// A [`HostInputStream`] that reads to a `Read` type.
70+
/// A [`InputStream`] that reads to a `Read` type.
7371
///
7472
/// See [`PipedWriteStream`] for more information on why this is synchronous.
7573
pub struct PipeReadStream<T> {
@@ -95,7 +93,7 @@ impl<T> Clone for PipeReadStream<T> {
9593
}
9694
}
9795

98-
impl<T: Read + Send + Sync + 'static> HostInputStream for PipeReadStream<T> {
96+
impl<T: Read + Send + Sync + 'static> InputStream for PipeReadStream<T> {
9997
fn read(&mut self, size: usize) -> wasmtime_wasi::StreamResult<bytes::Bytes> {
10098
let size = size.min(self.buffer.len());
10199

@@ -105,18 +103,21 @@ impl<T: Read + Send + Sync + 'static> HostInputStream for PipeReadStream<T> {
105103
.unwrap()
106104
.read(&mut self.buffer[..size])
107105
.map_err(|e| StreamError::LastOperationFailed(anyhow::anyhow!(e)))?;
106+
if count == 0 {
107+
return Err(wasmtime_wasi::StreamError::Closed);
108+
}
108109

109110
Ok(bytes::Bytes::copy_from_slice(&self.buffer[..count]))
110111
}
111112
}
112113

113114
#[async_trait]
114-
impl<T: Read + Send + Sync + 'static> Subscribe for PipeReadStream<T> {
115+
impl<T: Read + Send + Sync + 'static> Pollable for PipeReadStream<T> {
115116
async fn ready(&mut self) {}
116117
}
117118

118119
impl<T: Read + Send + Sync + 'static> StdinStream for PipeReadStream<T> {
119-
fn stream(&self) -> Box<dyn HostInputStream> {
120+
fn stream(&self) -> Box<dyn InputStream> {
120121
Box::new(self.clone())
121122
}
122123

crates/factor-wasi/src/lib.rs

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use spin_factors::{
1616
RuntimeFactors, RuntimeFactorsInstanceState,
1717
};
1818
use wasmtime_wasi::{
19-
DirPerms, FilePerms, ResourceTable, StdinStream, StdoutStream, WasiCtx, WasiCtxBuilder,
20-
WasiImpl, WasiView,
19+
DirPerms, FilePerms, IoImpl, IoView, ResourceTable, StdinStream, StdoutStream, WasiCtx,
20+
WasiCtxBuilder, WasiImpl, WasiView,
2121
};
2222

2323
pub use wasmtime_wasi::SocketAddrUse;
@@ -37,10 +37,10 @@ impl WasiFactor {
3737
runtime_instance_state: &mut impl RuntimeFactorsInstanceState,
3838
) -> Option<WasiImpl<impl WasiView + '_>> {
3939
let (state, table) = runtime_instance_state.get_with_table::<WasiFactor>()?;
40-
Some(WasiImpl(WasiImplInner {
40+
Some(WasiImpl(IoImpl(WasiImplInner {
4141
ctx: &mut state.ctx,
4242
table,
43-
}))
43+
})))
4444
}
4545
}
4646

@@ -50,52 +50,63 @@ impl Factor for WasiFactor {
5050
type InstanceBuilder = InstanceBuilder;
5151

5252
fn init<T: Send + 'static>(&mut self, mut ctx: InitContext<T, Self>) -> anyhow::Result<()> {
53-
fn type_annotate<T, F>(f: F) -> F
53+
fn type_annotate_wasi<T, F>(f: F) -> F
5454
where
5555
F: Fn(&mut T) -> WasiImpl<WasiImplInner>,
5656
{
5757
f
5858
}
59+
fn type_annotate_io<T, F>(f: F) -> F
60+
where
61+
F: Fn(&mut T) -> IoImpl<WasiImplInner>,
62+
{
63+
f
64+
}
5965
let get_data_with_table = ctx.get_data_with_table_fn();
60-
let closure = type_annotate(move |data| {
66+
let io_closure = type_annotate_io(move |data| {
6167
let (state, table) = get_data_with_table(data);
62-
WasiImpl(WasiImplInner {
68+
IoImpl(WasiImplInner {
6369
ctx: &mut state.ctx,
6470
table,
6571
})
6672
});
73+
let wasi_closure = type_annotate_wasi(move |data| WasiImpl(io_closure(data)));
6774
let linker = ctx.linker();
6875
use wasmtime_wasi::bindings;
69-
bindings::clocks::wall_clock::add_to_linker_get_host(linker, closure)?;
70-
bindings::clocks::monotonic_clock::add_to_linker_get_host(linker, closure)?;
71-
bindings::filesystem::types::add_to_linker_get_host(linker, closure)?;
72-
bindings::filesystem::preopens::add_to_linker_get_host(linker, closure)?;
73-
bindings::io::error::add_to_linker_get_host(linker, closure)?;
74-
bindings::io::poll::add_to_linker_get_host(linker, closure)?;
75-
bindings::io::streams::add_to_linker_get_host(linker, closure)?;
76-
bindings::random::random::add_to_linker_get_host(linker, closure)?;
77-
bindings::random::insecure::add_to_linker_get_host(linker, closure)?;
78-
bindings::random::insecure_seed::add_to_linker_get_host(linker, closure)?;
79-
bindings::cli::exit::add_to_linker_get_host(linker, &Default::default(), closure)?;
80-
bindings::cli::environment::add_to_linker_get_host(linker, closure)?;
81-
bindings::cli::stdin::add_to_linker_get_host(linker, closure)?;
82-
bindings::cli::stdout::add_to_linker_get_host(linker, closure)?;
83-
bindings::cli::stderr::add_to_linker_get_host(linker, closure)?;
84-
bindings::cli::terminal_input::add_to_linker_get_host(linker, closure)?;
85-
bindings::cli::terminal_output::add_to_linker_get_host(linker, closure)?;
86-
bindings::cli::terminal_stdin::add_to_linker_get_host(linker, closure)?;
87-
bindings::cli::terminal_stdout::add_to_linker_get_host(linker, closure)?;
88-
bindings::cli::terminal_stderr::add_to_linker_get_host(linker, closure)?;
89-
bindings::sockets::tcp::add_to_linker_get_host(linker, closure)?;
90-
bindings::sockets::tcp_create_socket::add_to_linker_get_host(linker, closure)?;
91-
bindings::sockets::udp::add_to_linker_get_host(linker, closure)?;
92-
bindings::sockets::udp_create_socket::add_to_linker_get_host(linker, closure)?;
93-
bindings::sockets::instance_network::add_to_linker_get_host(linker, closure)?;
94-
bindings::sockets::network::add_to_linker_get_host(linker, &Default::default(), closure)?;
95-
bindings::sockets::ip_name_lookup::add_to_linker_get_host(linker, closure)?;
96-
97-
wasi_2023_10_18::add_to_linker(linker, closure)?;
98-
wasi_2023_11_10::add_to_linker(linker, closure)?;
76+
bindings::clocks::wall_clock::add_to_linker_get_host(linker, wasi_closure)?;
77+
bindings::clocks::monotonic_clock::add_to_linker_get_host(linker, wasi_closure)?;
78+
bindings::filesystem::types::add_to_linker_get_host(linker, wasi_closure)?;
79+
bindings::filesystem::preopens::add_to_linker_get_host(linker, wasi_closure)?;
80+
bindings::io::error::add_to_linker_get_host(linker, io_closure)?;
81+
bindings::io::poll::add_to_linker_get_host(linker, io_closure)?;
82+
bindings::io::streams::add_to_linker_get_host(linker, io_closure)?;
83+
bindings::random::random::add_to_linker_get_host(linker, wasi_closure)?;
84+
bindings::random::insecure::add_to_linker_get_host(linker, wasi_closure)?;
85+
bindings::random::insecure_seed::add_to_linker_get_host(linker, wasi_closure)?;
86+
bindings::cli::exit::add_to_linker_get_host(linker, &Default::default(), wasi_closure)?;
87+
bindings::cli::environment::add_to_linker_get_host(linker, wasi_closure)?;
88+
bindings::cli::stdin::add_to_linker_get_host(linker, wasi_closure)?;
89+
bindings::cli::stdout::add_to_linker_get_host(linker, wasi_closure)?;
90+
bindings::cli::stderr::add_to_linker_get_host(linker, wasi_closure)?;
91+
bindings::cli::terminal_input::add_to_linker_get_host(linker, wasi_closure)?;
92+
bindings::cli::terminal_output::add_to_linker_get_host(linker, wasi_closure)?;
93+
bindings::cli::terminal_stdin::add_to_linker_get_host(linker, wasi_closure)?;
94+
bindings::cli::terminal_stdout::add_to_linker_get_host(linker, wasi_closure)?;
95+
bindings::cli::terminal_stderr::add_to_linker_get_host(linker, wasi_closure)?;
96+
bindings::sockets::tcp::add_to_linker_get_host(linker, wasi_closure)?;
97+
bindings::sockets::tcp_create_socket::add_to_linker_get_host(linker, wasi_closure)?;
98+
bindings::sockets::udp::add_to_linker_get_host(linker, wasi_closure)?;
99+
bindings::sockets::udp_create_socket::add_to_linker_get_host(linker, wasi_closure)?;
100+
bindings::sockets::instance_network::add_to_linker_get_host(linker, wasi_closure)?;
101+
bindings::sockets::network::add_to_linker_get_host(
102+
linker,
103+
&Default::default(),
104+
wasi_closure,
105+
)?;
106+
bindings::sockets::ip_name_lookup::add_to_linker_get_host(linker, wasi_closure)?;
107+
108+
wasi_2023_10_18::add_to_linker(linker, wasi_closure)?;
109+
wasi_2023_11_10::add_to_linker(linker, wasi_closure)?;
99110

100111
Ok(())
101112
}
@@ -288,7 +299,9 @@ impl WasiView for WasiImplInner<'_> {
288299
fn ctx(&mut self) -> &mut WasiCtx {
289300
self.ctx
290301
}
302+
}
291303

304+
impl IoView for WasiImplInner<'_> {
292305
fn table(&mut self) -> &mut ResourceTable {
293306
self.table
294307
}

0 commit comments

Comments
 (0)