ST wasm builds miden RwLocks as Spinlocks — a guard held across an await would halt the main thread forever (wallet#777 candidate)
- Vorherrschende Sprache
- Rust
- Sterne
- 78
- Forks
- 129
- Ø Merge
- 4 T. 14 Std.
- Gemergte PRs (30 T.)
- 52
Beschreibung
## Status: unconfirmed — an audit request, not an established bug
In 0xMiden/wallet#777 an idle mobile wallet's JS **main thread stopped entirely** (console silent, outstanding CDP `Runtime.evaluate` never answered) seconds after a burst of node-RPC 429s. A parked await cannot do that — the event loop stays alive — and the wallet-side repro (synthetic 429s and a hung sync RPC, iOS simulator) reproduced the lock wedge but **not** the thread stop. Something that can halt a single-threaded wasm main thread outright is needed to explain the recorded evidence.
## The candidate found
The ST (single-threaded) web-client wasm compiles `miden-utils-sync` with `std` off, so its `RwLock` is the `Spinlock` variant — documented as "blocking operations on the lock will spin until they succeed". Strings in the shipped `miden_client_web.wasm` (`@miden-sdk/miden-sdk@0.16.0-rc.3`) confirm `lock_api::RwLock` around `GrpcClient` state (`client` / `genesis_commitment` / `limits`, rpc/tonic_client/mod.rs). On a single-threaded wasm instance, a contended acquire — reachable only if some path holds a guard across an `await` while another future runs — spins forever with exactly the observed signature: no timers, no console, no CDP.
## What was checked, and what wasn't
- `tonic_client/mod.rs` itself looks clean: all guards appear statement-scoped, none held across an await.
- NOT yet audited: the note-transport client, store layers, and the other spin users compiled in (`spin` 0.9.9/0.12.2 via p3_dft caches, `rayon_core::SpinLatch`, `miden_debug_types` source_manager, RandomCoin).
- Also ruled out in the shipped ST glue: `Atomics.wait` (0 hits), sync XHR (0 hits).
## Ask
An audit for any `Spinlock`/`spin` guard held across an await point on the wasm32 single-threaded build — or a build-level guarantee (e.g. compile `miden-utils-sync` with `std` on for wasm32, or a non-spinning fallback) that contended acquisition on this target cannot spin.
Beitragsleitfaden
Rechercherichtung
Examine the wasm32 single-threaded build, focusing on `miden-utils-sync` and `spin` crate usage. Start by reviewing `rpc/tonic_client/mod.rs` for guard scopes, then audit note-transport client, store layers, and other spin users like `p3_dft`, `rayon_core::SpinLatch`, `miden_debug_types` source_manager, and RandomCoin. Look for any lock guard held across an await point. Confirm the build configuration to ensure `std` is on or a non-spinning fallback is used for wasm32.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rust, wasm
- Bereich
- backend, performance, web-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100