Skip to content

About

No description or website provided.

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Repository files navigation

Testing CertiCoq-Wasm

This repo contains scripts and examples for testing CertiCoq-Wasm. CertiCoq-Wasm has been merged into upstream CertiRocq.

Setup (Nix)

git clone https://github.com/womeier/certicoqwasm-testing && cd certicoqwasm-testing

cachix use womeier # optional
nix develop

# Check the setup
cd examples/certicoqwasm && make

Usage

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.

Performance Evaluation

Setup

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

Generating benchmarks

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

Adding new CertiCoq-Wasm binaries for evaluation

  1. Create branch in main repo benchmarks_<NAME>
  2. Stage the binaries of the CertiRocq pinned in flake.nix, which also records the description in the folder (INFO.txt, read by benchmark.py):
    # in evaluation/
    ./stage-binaries.py <NAME> -d "short description"
    
    Pass --result ../result to stage an existing build instead of running nix build. Binaries staged before the nixpkgs release live in ./evaluation/binaries/old/ and are instead described by benchmarks_info in ./evaluation/benchmark.py; possibly update the program list there.
  3. Then you can run the benchmark as described above.
  4. Add the expected result in file in ./evaluation/results
  5. Run the ./evaluation/sanity-checks.py script.

Evaluation of other extraction mechanisms

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/

Demo applications

SHA256 website demo (integrate with JavaScript)

In demo_website_sha256/, start dev-browser by:

make develop

Blockchain demo (integrate with Wasm)

In demo_blockchain_smartcontract/, run some tests (more information) for the smart contract counter by:

make run-concordium-test

Miscellaneous

  • Small Wasm example programs in examples/wasm/
  • Small WasmCert example proofs in examples/wasmcert/ (including a script wasm_to_coq.py to import .wasm file to Rocq)

About

No description or website provided.

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages