Repository navigation
build: opt-in no-threads flavour of the wallet (no SharedArrayBuffer, no COOP/COEP) - #34
danielgorgonha wants to merge 6 commits into
Conversation
…pace zcash_primitives, zcash_proofs and zcash_client_memory pulled `multicore` (rayon) through their default features or a hard-set feature, so no crate could switch it off. Take them without it at the workspace level and add a `multicore` feature to webzjs-common and webzjs-keys (default on). webzjs-requests and `just build-keys` ask for it explicitly, so those builds resolve the same third-party features as before. Assisted-by: Claude Code
`no-threads` builds the wasm wallet without wasm_thread, the rayon pool and wasm-bindgen-rayon, so it needs no SharedArrayBuffer. `sync` and `create_proposed_transactions` then run in the caller's context instead of a spawned worker. The `wasm-parallel` build keeps the same code path as before. - `multicore` now forwards to webzjs-keys and webzjs-common, and no longer rides on the zcash_proofs dependency line. - `wasm_thread` and `rayon` are optional and enabled by `wasm-parallel` only. - `no-threads` and `wasm-parallel` together fail with `compile_error!`. Assisted-by: Claude Code
`build-wallet-single` builds the `no-threads` flavour with RUSTFLAGS="" (so the atomics flags in .cargo/config.toml are not applied), without -Z build-std and without add-worker-module.sh. `scripts/check-no-threads.sh` fails if the no-threads graph has wasm_thread, wasm-bindgen-rayon or any multicore/threads feature, and, given a built .wasm, if it has shared memory or atomics. CI runs the graph part. Assisted-by: Claude Code
…eads build The no-threads path used unwrap_throw, so a failure became a raw JS throw that skips destructors and loses the error. Use `?` like the rest of the file, so the caller gets the same Err as in the threaded build. Also say in the WebWallet and sync docs that the no-threads build runs in the caller's context and cannot report a panic as an Error. Assisted-by: Claude Code
wasm-pack names both packages after the crate, and yarn refuses two workspaces with the same name, which broke every yarn command once the single build had run. Rename the generated package.json in `build-wallet-single`. Assisted-by: Claude Code
… threads proposal - CI job `no-threads` also runs `cargo check` of the wasm32 no-threads build. - check-no-threads.sh uses `wasm-tools validate --features=-threads`, which also rejects atomic.fence and no longer loads the whole module as text; the failure message shows the overridden FEATURES. - README: say that `wasm` without `wasm-parallel` now behaves like no-threads, and name the single package. Assisted-by: Claude Code
|
In the threaded build, How I ran it. Both builds come from this branch with the
🤖 Generated with Claude Code |
Changes
no-threadsonwebzjs-wallet: a build with nowasm_thread, nowasm-bindgen-rayon, no thread pool, no shared memory and no atomics, so a page served without COOP/COEP can load the wallet. Therayoncrate stays in the graph with no features, becausezcash_client_backendandzcash_client_memorydepend on it; no pool is created.no-threadsandwasm-parallelare mutually exclusive (compile_error!).syncandcreate_proposed_transactionsnow have two versions. Withwasm-parallelthey are unchanged. Without it they await their work in the caller's context instead of spawning awasm_threadworker, so the caller should host theWebWalletin its own Worker. Behaviour change: a build withwasmand nowasm-parallelused to spawnwasm_threadworkers and now takes the caller-context path.just build-walletalways passeswasm-parallel. Also in this flavour, a panic during sync aborts the module (no worker to contain it).multicoreis opt-in per crate instead of forced by the workspace (default-features = falseonzcash_primitivesandzcash_client_memory,multicoredropped from thezcash_proofsline, amulticorefeature onwebzjs-commonandwebzjs-keys, on by default, andwebzjs-requestsasking for it directly). The default build enables the same third-party features as before (checked withcargo treeon the earlier base c045717). Only thedefaultmarker features ofzcash_primitivesandzcash_client_memoryleave the graph, with the same members.just build-wallet-singlebuilds the no-threads package (packages/webzjs-wallet-single).just check-no-threads(scripts/check-no-threads.sh) checks the graph and, given a.wasm, that it has no shared memory and no atomic instruction. A CI job runs the graph check and a type-check of the flavour.Tests
What we ran, and on which base:
.cargo/config.tomlflags. TheRUSTFLAGS=""line above is the CI step's and was not run locally.no-threadsfeature; on the threaded graph it listswasm_thread,wasm-bindgen-rayonand 17 thread-pool features) and passes with it. We built both flavours. The threaded package had the same exports, imports, memory and.d.tsas the base, and the same JS glue after closure renumbering, but not the same bytes. The single package had no shared memory and no atomics. The threaded package was not rebuilt after the review fixes or the rebase.crossOriginIsolatedfalse).sync()on a new account with a birthday 100 blocks below the tip logged "Scanning ChainTip(...)" and did not return in 12 minutes, with no error or panic and the page still responsive. The cause is inzcash_client_backend: scan_cached_blocks hangs on wasm32 without atomics (rayon::spawn_fifo with no thread pool) zcash/librustzcash#3270. With the inline change proposed there patched in locally,sync()returned (one run, an account with no notes, built without wasm-opt; the scan then occupies the Worker). Not rerun on 9ad0a58.Not checked: spending in the no-threads build; a sync with an account that has notes; the CI job itself (not run); clippy on the pinned nightly; the snap and its keys
.wasm; a build on stable rustc.Issues
zcash_client_backend) lands. That issue is open and a fix is proposed there. A native reproduction of the hang (no browser, no network, no wasm) is on our fork: https://github.com/deegalabs/WebZjs/tree/repro/scan-hang/repro/scan-hang (POOL=currentdoes not return, rayon's normal pool does; run on 2026-11-23 withzcash_client_backend0.25.0 and rayon-core 1.13.0).feat/nu7-portable-keys) because the NU7 crates it touches are there. Is that the right base, or should it go tomainafter Feat/nu7 portable keys #27? I can retarget it or fold it into Feat/nu7 portable keys #27. Could you also check the workspaceCargo.toml? Your exact revision pin ofzcash_client_memoryis kept; I only addeddefault-features = false.wallet.rsas your Bounded sync steps, instance ids, close and worker poisoning #18 (bounded sync steps): in this flavour sync holds the wallet lock on the caller's thread for its whole run, so Bounded sync steps, instance ids, close and worker poisoning #18 matters here. Isno-threadsa good name for the feature, and would you rather land Bounded sync steps, instance ids, close and worker poisoning #18 first? If it lands first, I'll rebase on it..github/workflows/rust-checks.yml, as fix(vendor): forward the gRPC-web trailer frame to tonic #28 does; I'll rebase whichever lands second.🤖 Generated with Claude Code