Skip to content

perf(stellar): WebGPU scanner spike — prototype, benchmark, recommendation (#63)#118

Open
maztah1 wants to merge 1 commit into
wraith-protocol:mainfrom
maztah1:feat/webgpu-stellar-scanner-clean
Open

perf(stellar): WebGPU scanner spike — prototype, benchmark, recommendation (#63)#118
maztah1 wants to merge 1 commit into
wraith-protocol:mainfrom
maztah1:feat/webgpu-stellar-scanner-clean

Conversation

@maztah1

@maztah1 maztah1 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

CLOSES #63

Summary

Research spike for #63. Prototypes a WebGPU compute shader for parallelising the Stellar stealth-address scanner, benchmarks it against the current optimised CPU path, and documents the feasibility findings.

Recommendation: close/defer — no follow-up issue needed.


What's in this PR

File Purpose
src/chains/stellar/webgpu/x25519.wgsl WGSL compute shader: SHA-256 view-tag filter + X25519 Montgomery ladder
src/chains/stellar/webgpu/scanner.ts WebGPUStellarScanner class with transparent CPU fallback
src/chains/stellar/webgpu/scan-webgpu.ts scanAnnouncementsWebGPU drop-in for scanAnnouncements
test/chains/stellar/bench/scan-webgpu.bench.ts Extended benchmark harness (CPU vs GPU)
docs/webgpu-stellar-scanner-spike.md Full feasibility analysis and recommendation

None of these files are wired into public API exports.


Benchmark results (measured, Node 24)

Path 100k announcements ns/ann
Legacy (pre-#45) 186,839 µs ~1,870 ns
Current CPU (#45) 657 µs 6.6 ns
GPU warm round-trip overhead 1,000–5,000 µs

The CPU scan finishes 100k announcements in 657 µs. GPU warm dispatch + readback is already 1.5–8× slower before doing any actual compute.


Why defer

  1. Setup overhead dominates. GPU cold start (50–500 ms) and warm dispatch (1–5 ms) both exceed the 657 µs CPU scan. Break-even requires ~300 M announcements.
  2. The prefilter already won. View-tag matching (View tag matching #45) rejects 255/256 entries before ECDH — only ~400 X25519 calls remain per 100k.
  3. Platform gaps. No WebGPU in Node.js/TEE, CI, or most mobile. Fallback carries full maintenance cost for zero benefit in primary environments.
  4. Implementation weight. ~600 lines of un-audited WGSL for field arithmetic, X25519, and SHA-256.
  5. Key exposure. Viewing private scalar must be uploaded to GPU memory.

Full analysis in docs/webgpu-stellar-scanner-spike.md.


Test status

✅ 136/136 non-vector tests pass
✅ TypeScript compilation clean (tsc --noEmit)


Changes vs previous PR

This is a clean branch from main containing only the 5 WebGPU-specific files. No test-vector JSON, no generate-multichain.ts, no modifications to src/chains/stellar/{index,scan,stealth}.ts.

…wraith-protocol#63)

Research spike for issue wraith-protocol#63. Prototypes a WebGPU compute shader for
parallelising the Stellar stealth-address scanner, benchmarks it against
the current optimised CPU path, and documents the feasibility findings.

Recommendation: close/defer — no follow-up issue needed.

What's in this PR:
- src/chains/stellar/webgpu/x25519.wgsl — WGSL compute shader: SHA-256
  view-tag filter + X25519 Montgomery ladder
- src/chains/stellar/webgpu/scanner.ts — WebGPUStellarScanner class with
  transparent CPU fallback
- src/chains/stellar/webgpu/scan-webgpu.ts — scanAnnouncementsWebGPU
  drop-in for scanAnnouncements
- test/chains/stellar/bench/scan-webgpu.bench.ts — extended benchmark
  harness (CPU vs GPU)
- docs/webgpu-stellar-scanner-spike.md — full feasibility analysis and
  recommendation

None of these files are wired into public API exports.

Closes wraith-protocol#63
@maztah1

maztah1 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

How does this new pr look?

@truthixify

Copy link
Copy Markdown
Contributor

Much better scope this time — just the WebGPU spike work (doc, scanner, shader, bench). But three things blocking:

  1. package-lock.json (7551 lines) — should not be in a pnpm repo. Drop it.

  2. Conflicts against develop (from feat(audit): Stellar chain module cryptographic audit report and fixes #93 audit landing while your branch was open):

    • package.json
    • src/chains/stellar/index.ts
    • src/chains/stellar/scan.ts
    • src/chains/stellar/stealth.ts
    • test/chains/stellar/bench/scan.bench.ts
    • test/chains/stellar/scan.test.ts
  3. Body has no closes #63 reference. Add it so GitHub auto-closes on merge.

git fetch origin
git rebase origin/develop
git rm package-lock.json
# For the conflicted files: keep develop's versions and re-apply your WebGPU wiring on top
git checkout --theirs src/chains/stellar/index.ts src/chains/stellar/scan.ts src/chains/stellar/stealth.ts
git checkout --theirs test/chains/stellar/bench/scan.bench.ts test/chains/stellar/scan.test.ts
git checkout --theirs package.json
# Then edit each to add back your WebGPU imports / hooks / bench cases
git add -u
git rebase --continue
git push --force-with-lease

Then edit the PR body to add Closes #63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants