feat/rayon_parallel_wasm - #2658
Open
hitchho wants to merge 20 commits into
Open
Conversation
Add wasm-bindgen-rayon integration for multi-threaded WASM execution. This enables parallel proving across CPU cores using rayon's thread pool. - Add rayon and wasm-bindgen-rayon dependencies behind 'parallel' feature - Export initThreadPool for rayon thread pool initialization - Add build_parallel_native function for parallel action proving - Requires SharedArrayBuffer and cross-origin isolation headers
- Add .cargo/config.toml with SIMD128 target features - Add build-wasm-parallel.sh for nightly toolchain builds - Add compile:parallel npm script with atomics and 4GB memory limit - Export wasm-parallel directory in package.json
- Add init.ts with initWasmWithParallel for SharedArrayBuffer setup - Create shared memory with 4GB max for rayon thread pool - Add buildWithRayon wrapper in build.ts for parallel proving - Support dynamic import to avoid bundling in restricted contexts
- Add buildParallelWithRayon to offscreen-client for worker communication - Add optimisticParallelBuild generator in build-tx-parallel.ts - Update build-tx.ts to use parallel path when SharedArrayBuffer available - Add ParallelBuildRequest/Response types for offscreen messaging - Default to parallel build, fallback to JS worker approach
two-phase progress animation: - auth phase (5% -> 20%): slow rise while user approves tx - build phase (20% -> 90%): slower 3s curve for wasm init + proof fixes race condition where build could complete before animation starts. minimum 500ms animation ensures users see smooth progress.
|
erwanor
pushed a commit
that referenced
this pull request
Nov 30, 2025
Add a comprehensive context document for expert review of PR #2658, which proposes adding Rayon-based WASM threading alongside the existing JavaScript-level parallelization for transaction building.
With wasm-pack --target web, the WASM module needs explicit initialization before use. Updated all exported functions to call initWasm() automatically. - init.ts: initWasm() now actually initializes the regular wasm module - keys.ts: All functions now async with auto-init - address.ts: All functions now async with auto-init - build.ts: All functions now async with auto-init 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated test files and view-server.ts to handle async WASM functions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Check that Address has inner bytes or alt_bech32m string before calling isControlledAddress, to avoid "Address proto has neither inner nor alt_bech32m fields set" error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
to not break service worker for penumbra syncing block
Fix/wasm compile bundler
feat: add compute_effect_hash WASM function for airgap signing
Bumps next, @next/bundle-analyzer, eslint-config-next to 15.5.18 and regenerates the lockfile so this branch can't ship the vulnerable next@15.3.1 runtime. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This reverts commit 8785019e7e2d. The lockfile regeneration silently failed on this branch due to a stale workspace structure (packages/storage depends on @penumbra-zone/wasm@workspace:*, which no longer exists in the workspace). The previous commit only updated package.json, leaving the lockfile at next@15.3.1 — recreating the exact mismatch we were trying to fix. Revert to keep the branch consistent. The Next.js bump on this branch needs a workspace fix first (or rebase onto patched main). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ename The wasm package was renamed to @rotko/penumbra-wasm in commits 0f20b93 / 705b4a9 / 4b68bbd, but the 3 consumer packages (storage, services, perspective) plus 30 TS imports still asked for @penumbra-zone/wasm@workspace:*. pnpm therefore refused to install on this branch, which blocked any lockfile-touching security patch. This commit finishes the rename across consumers + TS imports + the wasm package's own JSDoc, so pnpm install resolves the workspace again. With the workspace healthy, also bumps apps/veil to next@15.5.18 (closing the App Router RCE, same as main) and regenerates the lockfile. Parallel wasm build and rotko-specific WASM functions are unaffected — this only changes the package identifier and consumer imports. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adds rayon-based parallel proof generation for transaction building. enables multi-threaded wasm execution using wasm-bindgen-rayon, significantly improving transaction build times on multi-core systems. working prax demo / video / praxPR.
rayon parallel proof generation (
packages/wasm/crate)added
build_parallel_nativefunction that uses rayon'spar_iter()to build all transaction actions concurrently in wasm. the parallel build leverages all available cpu cores through web workers spawnedby wasm-bindgen-rayon.
src/build.rs- newbuild_parallel_nativeentry pointsrc/lib.rs- feature-gated parallel module exportCargo.toml- added rayon, wasm-bindgen-rayon dependencies withparallelfeaturebuild scripts and config (
packages/wasm/crate)created build infrastructure for compiling wasm with atomics and shared memory support required for rayon threading.
scripts/build-wasm-parallel.sh- build script with proper rustflags.cargo/config.toml- target-specific linker configurationpackage.json- addedcompile:parallelscript with--max-memory=4294967296for 4gb heapwasm initialization (
packages/wasm/src)added explicit initialization module that creates sharedarraybuffer-backed memory and initializes the rayon thread pool before use.
src/init.ts-initWasmWithParallel(numThreads)functionsrc/build.ts- re-exports parallel build functionsservices integration (
packages/services)integrated parallel building into the view service with optimistic authorization flow and smooth progress animation using a logarithmic curve.
src/view-service/util/build-tx-parallel.ts- async generator with progress updatessrc/offscreen-client.ts-buildParallelWithRayonrpc methodpackages/types/src/internal-msg/offscreen.ts- message types for parallel buildscompatibility and fallback
automatic runtime detection with graceful fallback:
SharedArrayBufferavailability at runtimeprogress bar animation
two-phase smooth progress animation: