Skip to content

Port wasm solver to C and add regression coverage#218

Open
Soccera1 wants to merge 6 commits intotiagozip:mainfrom
Soccera1:main
Open

Port wasm solver to C and add regression coverage#218
Soccera1 wants to merge 6 commits intotiagozip:mainfrom
Soccera1:main

Conversation

@Soccera1
Copy link
Copy Markdown

@Soccera1 Soccera1 commented Apr 9, 2026

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/rust and updated the docs/package metadata to describe the solver as C-based WASM.
  • Tightened the test suite: wasm/src/c/test-regression.cjs became a fixed regression suite, wasm/test/node.js now asserts expected nonces for the full challenge set, and wasm/test/node_odd_difficulty.js verifies the odd-length target case.
  • Updated wasm/build.js so the build runs the regression suite.

Commit breakdown

  • 629ed2f: Port wasm from Rust to C
  • 978c1f5: Remove Rust code
  • dee457e: 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.

Soccera1 added 6 commits April 9, 2026 21:52
- Convert wasm test scripts to `bun test`
- Rename test files to `.test.js`
- Keep node and browser solver regression coverage
@Soccera1 Soccera1 changed the title Port wasm solver to C and add regression coverage#206 Port wasm solver to C and add regression coverage Apr 9, 2026
@Soccera1
Copy link
Copy Markdown
Author

Soccera1 commented Apr 9, 2026

Re-open of #206 since all the commit hashes got fucked, closing branches, thus closing the PR.

@opuadm
Copy link
Copy Markdown

opuadm commented Apr 9, 2026

make phone happy

@tiagozip
Copy link
Copy Markdown
Owner

did it end up being faster than the current rust one?

@Soccera1
Copy link
Copy Markdown
Author

did it end up being faster than the current rust one?

Only in bun. I'm currently working on resolving this issue.

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.

3 participants