Skip to content

Commit d69fbc7

Browse files
authored
linera-base: expunge wasmtimer in favour of kywasmtime (#4561)
## Motivation We ran into a variant of whizsid/wasmtimer-rs#22, which was drastically slowing down the operation of `@linera/client` (see #4444 for details). Additionally, `wasmtimer` doesn't look thread-safe: it uses [`parking_lot`](https://crates.io/crates/parking_lot), which will panic on Wasm if the lock ever tries to park. ## Proposal Replace our dependency on `wasmtimer` with a [Linera fork](https://github.com/linera-io/kywasmtime/) of [`kywasmtime`](https://github.com/rom1v/kywasmtime), a package that exposes the same API but using the browser `clearTimeout` APIs instead of implementing its own priority queue. I made a couple of patches to be more helpful for our usage, which are PR'd upstream as rom1v/kywasmtime#3 and rom1v/kywasmtime#4. Since `kywasmtime` isn't published to crates.io, we use it as a git dependency. This is okay, since `linera-web` is also never published to crates.io (only to npm), and the SDK crates that we do publish don't rely on it. ## Test Plan Manually tested. ## Release Plan - These changes should be backported to the latest `testnet` branch, then - be released in a new SDK. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist) - Fixes #4444.
1 parent bd32785 commit d69fbc7

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ wasmtime = { version = "25.0.0", default-features = false, features = [
271271
"runtime",
272272
"std",
273273
] }
274-
wasmtimer = "0.2.0"
275274
web-sys = "0.3.69"
276275
web-time = "1.1.0"
277276
wit-bindgen = "0.24.0"
@@ -328,6 +327,10 @@ default-features = false
328327
features = ["rt-tokio", "rustls"]
329328
version = "1.76.0"
330329

330+
[workspace.dependencies.kywasmtime]
331+
git = "https://github.com/linera-io/kywasmtime"
332+
rev = "480df00badbe80520d5b990855138d3638c56159"
333+
331334
[profile.release]
332335
lto = "thin"
333336
debug = true

linera-base/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ revm = []
2121
test = ["test-strategy", "proptest"]
2222
web = [
2323
"getrandom/js",
24+
"kywasmtime",
2425
"rand/getrandom",
2526
"rand/std",
2627
"rand/std_rng",
2728
"tracing-web",
28-
"wasmtimer",
2929
"wasm-bindgen",
3030
"wasm-bindgen-futures",
3131
"wasm_thread",
32-
"web-time",
3332
"web-sys",
33+
"web-time",
3434
]
3535

3636
[dependencies]
@@ -50,6 +50,7 @@ getrandom = { workspace = true, optional = true }
5050
hex.workspace = true
5151
is-terminal.workspace = true
5252
k256.workspace = true
53+
kywasmtime = { workspace = true, optional = true }
5354
linera-witty = { workspace = true, features = ["macros"] }
5455
prometheus = { workspace = true, optional = true }
5556
proptest = { workspace = true, optional = true, features = ["alloc"] }
@@ -70,7 +71,6 @@ trait-variant.workspace = true
7071
wasm-bindgen = { workspace = true, optional = true }
7172
wasm-bindgen-futures = { workspace = true, optional = true }
7273
wasm_thread = { workspace = true, optional = true }
73-
wasmtimer = { workspace = true, optional = true }
7474
web-sys = { workspace = true, optional = true }
7575
web-time = { workspace = true, optional = true }
7676

linera-base/src/time.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ Abstractions over time that can be used natively or on the Web.
77

88
cfg_if::cfg_if! {
99
if #[cfg(web)] {
10+
// This must remain conditional as otherwise it pulls in JavaScript symbols
11+
// on-chain (on any Wasm target).
1012
pub use web_time::*;
11-
pub use wasmtimer::tokio as timer;
13+
pub use kywasmtime as timer;
1214
} else {
1315
pub use std::time::*;
1416
pub use tokio::time as timer;

0 commit comments

Comments
 (0)