Skip to content

Commit 2ef4f1a

Browse files
authored
Update wasmtime, clap, and other dependencies (#153)
* Update wasmtime and other dependencies * Update clap to use derive macro * Fix clippy lints
1 parent 5de70d6 commit 2ef4f1a

File tree

20 files changed

+754
-741
lines changed

20 files changed

+754
-741
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ prometheus = ["dep:metrics-exporter-prometheus", "metrics"]
3434

3535
[dependencies]
3636
anyhow = "^1.0"
37-
clap = { version = "^3.2", features = ["cargo"] }
37+
clap = { version = "^4.0", features = ["cargo", "derive"] }
3838
lazy_static = "^1.4"
3939
tokio = { version = "^1.20", features = [
4040
"macros",
4141
"rt-multi-thread",
4242
"net",
4343
"time",
4444
] }
45-
wasmtime = "^1.0"
46-
wasmtime-wasi = "^1.0"
47-
wasi-common = "^1.0"
48-
wasmparser = "^0.88"
45+
wasmtime = "^2.0"
46+
wasmtime-wasi = "^2.0"
47+
wasi-common = "^2.0"
48+
wasmparser = "^0.94"
4949
env_logger = "^0.9"
5050
log = "^0.4"
5151
serde = "^1.0"
@@ -73,7 +73,7 @@ lunatic-distributed-api = { version = "^0.10", path = "crates/lunatic-distribute
7373
[dev-dependencies]
7474
wat = "^1.0"
7575
tokio = { version = "^1.20", features = ["rt-multi-thread"] }
76-
criterion = { version = "^0.3", features = ["async_tokio"] }
76+
criterion = { version = "^0.4", features = ["async_tokio"] }
7777

7878
[[bench]]
7979
name = "benchmark"
@@ -94,4 +94,4 @@ members = [
9494
"crates/lunatic-wasi-api",
9595
"crates/lunatic-registry-api",
9696
"crates/lunatic-distributed-api",
97-
]
97+
]

benches/benchmark.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, Criterion};
44
use dashmap::DashMap;
55
// TODO: Re-export this under lunatic_runtime
66
use lunatic_process::{
7-
env::Environment,
7+
env::LunaticEnvironment,
88
runtimes::wasmtime::{default_config, WasmtimeRuntime},
99
};
1010
use lunatic_runtime::{state::DefaultProcessState, DefaultProcessConfig};
@@ -23,7 +23,7 @@ fn criterion_benchmark(c: &mut Criterion) {
2323
.unwrap(),
2424
);
2525

26-
let env = Environment::new(0);
26+
let env = Arc::new(LunaticEnvironment::new(0));
2727
c.bench_function("spawn process", |b| {
2828
b.to_async(&rt).iter(|| async {
2929
let registry = Arc::new(DashMap::new());
@@ -36,13 +36,21 @@ fn criterion_benchmark(c: &mut Criterion) {
3636
registry,
3737
)
3838
.unwrap();
39-
env.spawn_wasm(runtime.clone(), &module, state, "hello", Vec::new(), None)
40-
.await
41-
.unwrap()
42-
.0
43-
.await
44-
.unwrap()
45-
.ok();
39+
lunatic_process::wasm::spawn_wasm(
40+
env.clone(),
41+
runtime.clone(),
42+
&module,
43+
state,
44+
"hello",
45+
Vec::new(),
46+
None,
47+
)
48+
.await
49+
.unwrap()
50+
.0
51+
.await
52+
.unwrap()
53+
.ok();
4654
});
4755
});
4856
}

crates/lunatic-common-api/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ homepage = "https://lunatic.solutions"
77
repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates/lunatic-common-api"
88
license = "Apache-2.0/MIT"
99

10-
1110
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1211

1312
[dependencies]
1413
anyhow = "^1.0"
15-
wasmtime = "^1" # managed by root Cargo.toml
14+
wasmtime = "^2" # managed by root Cargo.toml
1615
paste = "^1.0"

crates/lunatic-distributed-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ lunatic-distributed = { version = "^0.10", path = "../lunatic-distributed" }
1515
lunatic-error-api = { version = "^0.10", path = "../lunatic-error-api" }
1616
lunatic-process = { version = "^0.10", path = "../lunatic-process" }
1717
lunatic-process-api = { version = "^0.10", path = "../lunatic-process-api" }
18-
wasmtime = "^1" # managed by root Cargo.toml
18+
wasmtime = "^2" # managed by root Cargo.toml
1919
tokio = { version = "^1.20", features = ["macros", "net", "time"] }
2020
anyhow = "^1.0"
2121
serde = { version = "^1.0", features = ["derive"] }

crates/lunatic-distributed/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ anyhow = "^1.0"
2020
tokio = { version = "^1.20", features = ["macros", "rt-multi-thread", "net", "time", "io-util"] }
2121
serde = { version = "^1.0", features = ["derive"] }
2222
s2n-quic = { version = "1", default-features = false, features = ["provider-address-token-default", "provider-tls-rustls"], optional = true}
23-
wasmtime = "^1" # managed by root Cargo.toml
23+
wasmtime = "^2" # managed by root Cargo.toml
2424
dashmap = "5.3.4"
2525
bincode = "^1.3"
2626
bytes = "1"
2727
log = "^0.4"
2828
async_cell = "0.2.1"
29-
rcgen = { version="^0.9", features=["pem", "x509-parser"] }
29+
rcgen = { version="^0.10", features=["pem", "x509-parser"] }
3030
lunatic-process = { version = "^0.10", path = "../lunatic-process" }
31-
quinn = { version = "^0.8", optional = true}
31+
quinn = { version = "^0.9", optional = true}
3232
rustls = { version = "^0.20", optional = true }
3333
rustls-pemfile = { version = "^1.0", optional = true }
3434
futures-util = { version = "^0.3", optional = true}

crates/lunatic-distributed/src/quic/quin.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::{net::SocketAddr, sync::Arc, time::Duration};
22

33
use anyhow::{anyhow, Result};
44
use bytes::Bytes;
5-
use futures_util::StreamExt;
65
use lunatic_process::{env::Environment, state::ProcessState};
7-
use quinn::{ClientConfig, Connecting, Endpoint, Incoming, NewConnection, ServerConfig};
6+
use quinn::{ClientConfig, Connecting, ConnectionError, Endpoint, ServerConfig};
87
use rustls_pemfile::Item;
98
use wasmtime::ResourceLimiter;
109

@@ -53,10 +52,7 @@ impl Client {
5352
retry: u32,
5453
) -> Result<(SendStream, RecvStream)> {
5554
for _ in 0..retry {
56-
let new_conn = self.inner.connect(addr, name)?.await?;
57-
let NewConnection {
58-
connection: conn, ..
59-
} = new_conn;
55+
let conn = self.inner.connect(addr, name)?.await?;
6056
if let Ok((send, recv)) = conn.open_bi().await {
6157
return Ok((SendStream { stream: send }, RecvStream { stream: recv }));
6258
}
@@ -85,7 +81,7 @@ pub fn new_quic_client(ca_cert: &str) -> Result<Client> {
8581
Ok(Client { inner: endpoint })
8682
}
8783

88-
pub fn new_quic_server(addr: SocketAddr, cert: &str, key: &str) -> Result<(Endpoint, Incoming)> {
84+
pub fn new_quic_server(addr: SocketAddr, cert: &str, key: &str) -> Result<Endpoint> {
8985
let mut cert = cert.as_bytes();
9086
let mut key = key.as_bytes();
9187
let pk = rustls_pemfile::read_one(&mut key)?.unwrap();
@@ -112,10 +108,10 @@ pub fn new_quic_server(addr: SocketAddr, cert: &str, key: &str) -> Result<(Endpo
112108
}
113109

114110
pub async fn handle_accept_control(
115-
quic_server: &mut (Endpoint, Incoming),
111+
quic_server: &mut Endpoint,
116112
control_server: control::server::Server,
117113
) -> Result<()> {
118-
while let Some(conn) = quic_server.1.next().await {
114+
while let Some(conn) = quic_server.accept().await {
119115
tokio::spawn(handle_quic_stream(conn, control_server.clone()));
120116
}
121117
Ok(())
@@ -125,12 +121,19 @@ async fn handle_quic_stream(
125121
conn: Connecting,
126122
control_server: control::server::Server,
127123
) -> Result<()> {
128-
let NewConnection { mut bi_streams, .. } = conn.await?;
129-
while let Some(stream) = bi_streams.next().await {
130-
if let Ok((s, r)) = stream {
131-
let send = SendStream { stream: s };
132-
let recv = RecvStream { stream: r };
133-
tokio::spawn(handle_quic_connection(send, recv, control_server.clone()));
124+
let conn = conn.await?;
125+
loop {
126+
let stream = conn.accept_bi().await;
127+
match stream {
128+
Ok((s, r)) => {
129+
let send = SendStream { stream: s };
130+
let recv = RecvStream { stream: r };
131+
tokio::spawn(handle_quic_connection(send, recv, control_server.clone()));
132+
}
133+
Err(ConnectionError::LocallyClosed) => {
134+
break;
135+
}
136+
Err(_) => {}
134137
}
135138
}
136139
Ok(())
@@ -153,14 +156,14 @@ async fn handle_quic_connection(
153156
}
154157

155158
pub async fn handle_node_server<T, E>(
156-
quic_server: &mut (Endpoint, Incoming),
159+
quic_server: &mut Endpoint,
157160
ctx: distributed::server::ServerCtx<T, E>,
158161
) -> Result<()>
159162
where
160163
T: ProcessState + ResourceLimiter + DistributedCtx<E> + Send + 'static,
161164
E: Environment + 'static,
162165
{
163-
while let Some(conn) = quic_server.1.next().await {
166+
while let Some(conn) = quic_server.accept().await {
164167
tokio::spawn(handle_quic_connection_node(ctx.clone(), conn));
165168
}
166169
Ok(())
@@ -174,12 +177,17 @@ where
174177
T: ProcessState + ResourceLimiter + DistributedCtx<E> + Send + 'static,
175178
E: Environment + 'static,
176179
{
177-
let NewConnection { mut bi_streams, .. } = conn.await?;
178-
while let Some(stream) = bi_streams.next().await {
179-
if let Ok((s, r)) = stream {
180-
let send = SendStream { stream: s };
181-
let recv = RecvStream { stream: r };
182-
tokio::spawn(handle_quic_stream_node(ctx.clone(), send, recv));
180+
let conn = conn.await?;
181+
loop {
182+
let stream = conn.accept_bi().await;
183+
match stream {
184+
Ok((s, r)) => {
185+
let send = SendStream { stream: s };
186+
let recv = RecvStream { stream: r };
187+
tokio::spawn(handle_quic_stream_node(ctx.clone(), send, recv));
188+
}
189+
Err(ConnectionError::LocallyClosed) => break,
190+
Err(_) => {}
183191
}
184192
}
185193
Ok(())

crates/lunatic-error-api/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ homepage = "https://lunatic.solutions"
77
repository = "https://github.com/lunatic-solutions/lunatic/tree/main/crates"
88
license = "Apache-2.0/MIT"
99

10-
1110
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1211

1312
[dependencies]
1413
anyhow = "^1.0"
15-
wasmtime = "^1" # managed by root Cargo.toml
14+
wasmtime = "^2" # managed by root Cargo.toml
1615
hash-map-id = { version = "^0.10", path = "../hash-map-id" }
1716
lunatic-common-api = { version = "^0.10", path = "../lunatic-common-api" }

crates/lunatic-messaging-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "Apache-2.0/MIT"
1111

1212
[dependencies]
1313
anyhow = "^1.0"
14-
wasmtime = "^1" # managed by root Cargo.toml
14+
wasmtime = "^2" # managed by root Cargo.toml
1515
tokio = { version = "^1.20", features = ["macros", "net", "time"] }
1616
hash-map-id = { version = "^0.10", path = "../hash-map-id" }
1717
lunatic-process = { version = "^0.10", path = "../lunatic-process" }

crates/lunatic-networking-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ version = "0.10.0"
1111

1212
[dependencies]
1313
anyhow = "^1.0"
14-
wasmtime = "^1" # managed by root Cargo.toml
14+
wasmtime = "^2" # managed by root Cargo.toml
1515
tokio = { version = "^1.20", features = ["macros", "rt-multi-thread", "sync", "net", "time", "io-util"] }
1616
hash-map-id = { version = "^0.10", path = "../hash-map-id" }
1717
lunatic-common-api = { version = "^0.10", path = "../lunatic-common-api" }

0 commit comments

Comments
 (0)