@rolly-dev/witness-core
v0.2.2
Published
Authoritative native witness-state engine for Rolly ZK-Rollup (Node-API addon)
Maintainers
Readme
@rolly-dev/witness-core
Authoritative native witness-state engine for the Rolly ZK-Rollup, shipped to Node.js as a Node-API addon via napi-rs.
It is the single source of truth for the rollup witness state (Merkle tree, server-seed chain, TL) and processes each transaction exactly once. Node keeps only IO / RPC / orchestration. See the migration plan for the full rationale (removing the TS/Rust double-recompute and the wasm Poseidon bottleneck).
Status: scaffolding stage. The Node-API surface and a placeholder
MerkleEnginehandle exist; the real state,process_tx, andflush_blockland in later stages.
Design
One crate, crate-type = ["cdylib", "rlib"] with napi bindings inline (no
separate binding crate), mirroring how wasm-signer ships cdylib + rlib:
cdylib-> the.nodeaddon consumed by the backend.rlib-> native unit tests + (later) circuit differential tests live in this same crate, so engine logic is testable without going through Node.
Build
Host platform (release):
npm install # installs @napi-rs/cli
npm run build # -> witness-core.<platform>.node, index.js, index.d.tsor bash build.sh.
Prebuild for Linux x64 (production target)
Production likely runs Linux x64, so the package is configured to emit a
x86_64-unknown-linux-gnu artifact:
npm run build:linux-x64Cross-compiling from macOS requires a Linux linker and the Rust target:
rustup target add x86_64-unknown-linux-gnuThen pick one of:
- GNU cross-linker (used here): install the GNU cross toolchain so
x86_64-linux-gnu-gccis onPATH..cargo/config.tomlalready points the target's linker at it, sonpm run build:linux-x64produces a strippedwitness-core.linux-x64-gnu.nodeELF directly. - Linux x64 CI runner: run
npm run build:linux-x64there natively (.cargo/config.toml's cross-linker entry is simply unused). Recommended for release. - zig:
cargo install cargo-zigbuild+ azigonPATH, then add--cross-compileto the napi build.
The release flow uses napi prepublish / napi artifacts to collect the
per-platform .node files before publishing.
Test
npm test # builds nothing; runs ./test.js against the already-built addonConsuming from the backend
Same pattern as @rolly-dev/wasm-signer:
const { MerkleEngine, engineVersion } = require('@rolly-dev/witness-core');
const engine = new MerkleEngine();