This repo contains scripts and examples for testing CertiCoq-Wasm. CertiCoq-Wasm has been merged into upstream CertiRocq.
git clone https://github.com/womeier/certicoqwasm-testing && cd certicoqwasm-testing
cachix use womeier # optional
nix develop
# Check the setup
cd examples/certicoqwasm && make
For some small examples see foo.v, sha.v and the Makefile in examples/certicoqwasm/.
Compiling each Rocq file generates a .wasm file that can be run with e.g. Node.js, run make help to see how.
The JavaScript files specify pretty-printing the result. For Rocq's most common types we have pp functions in evaluation/pp.js, see sha.js on how to use.
The generation of pp functions is not yet automated, the reader is welcome to create an issue for help.
(We currently use CertiCoq-Wasm's debugging branch and CertiCoq Generate Wasm -debug to get the constructor environment,
and the constructors' ordinals, they're the same as with CertiRocq's C backend.)
Note that a package.json may be required for JavaScript imports.
The nix develop shell of this repo provides everything below, with the wasmtime CLI and
its python bindings pinned to the same version (benchmark.py --engine=wasmtime-compile requires this).
Alternatively, install manually:
- wabt
- binaryen (version 117 or higher)
- wasmtime (most recent version, at least version 18)
- python bindings for wasmtime (pip install wasmtime, must be same version as wasmtime)
- python packages click and tqdm
# in evaluation/
./benchmark.py --engine=node --folder ./binaries/old/non-cps-cleanup-oct-13-24 --wasm-opt -O2
./benchmark.py --help
To compile the benchmarks (benchmarks/wasm/tests.v) of the CertiRocq pinned in flake.nix
with that same CertiRocq, run:
nix build .#wasm-benchmarks # the .wasm files end up in ./result/
# in evaluation/
./benchmark.py --engine=node --folder ../result
More evaluation
- Create branch in main repo
benchmarks_<NAME> - Stage the binaries of the CertiRocq pinned in
flake.nix, which also records the description in the folder (INFO.txt, read bybenchmark.py):Pass# in evaluation/ ./stage-binaries.py <NAME> -d "short description"--result ../resultto stage an existing build instead of runningnix build. Binaries staged before the nixpkgs release live in./evaluation/binaries/old/and are instead described bybenchmarks_infoin./evaluation/benchmark.py; possibly update the program list there. - Then you can run the benchmark as described above.
- Add the expected result in file in
./evaluation/results - Run the
./evaluation/sanity-checks.pyscript.
To evaluate the extraction via Rust (more information), run the following in evaluation/rust_to_wasm/:
./benchmark.py --folder ./binaries/unchecked_arith/
To evaluate the extraction via OCaml (more information), run the following in evaluation/ocaml_to_wasm/:
./benchmark.py --folder ./binaries/
To evaluate the extraction via C and emscripten (more information), run the following in evaluation/c_to_wasm:
./benchmark.py --folder ./binaries/
To evaluate the extraction via Malfunction (more information), run the following in evaluation/malfunction_to_wasm:
./benchmark.py --folder ./binaries/
In demo_website_sha256/, start dev-browser by:
make develop
In demo_blockchain_smartcontract/, run some tests (more information) for the smart contract counter by:
make run-concordium-test
- Small Wasm example programs in
examples/wasm/ - Small WasmCert example proofs in
examples/wasmcert/(including a scriptwasm_to_coq.pyto import .wasm file to Rocq)