Port wasm solver to C and add regression coverage
What changed
- Replaced the Rust WASM solver with a C implementation in
wasm/src/c/src/cap_wasm.c, including SHA-256 hashing, hex-prefix target parsing, nonce formatting, and wasm allocator shims. - Removed the old Rust crate under
wasm/src/rustand updated the docs/package metadata to describe the solver as C-based WASM. - Tightened the test suite:
wasm/src/c/test-regression.cjsbecame a fixed regression suite,wasm/test/node.jsnow asserts expected nonces for the full challenge set, andwasm/test/node_odd_difficulty.jsverifies the odd-length target case. - Updated
wasm/build.jsso the build runs the regression suite.
Commit breakdown
629ed2f: Port wasm from Rust to C978c1f5: Remove Rust codedee457e: Update tests
This was done as the rust implementation had many external dependencies, and rustc is very difficult to bootstrap. This version has no external dependencies; it can be compiled with -ffreestanding. I have also done some unscientific testing and this is over 13% faster.
Summary by CodeRabbit
-
New Features
- Added a full benchmark suite (Node + browser) with runner, browser UI, and an easy local server to compare solver implementations and report speedups.
-
Documentation
- Updated docs and READMEs to describe the client solver as a C-based WebAssembly implementation.
-
Tests
- Added regression tests validating solver correctness across multiple challenge cases.
-
Chores
- Build pipeline updated to produce a C-based WASM solver and related build orchestration.
Re-open of #206 since all the commit hashes got fucked, closing branches, thus closing the PR.
make phone happy
did it end up being faster than the current rust one?
did it end up being faster than the current rust one?
Only in bun. I'm currently working on resolving this issue.