anoma / vamp-ir

Vamp-IR is a proof-system-agnostic language for writing arithmetic circuits
https://anoma.github.io/VampIR-Book/
Apache License 2.0
156 stars 44 forks source link

Add halo2 compile API #119

Closed paulcadman closed 1 year ago

paulcadman commented 1 year ago

Add a proposed halo2 compile API that consumers of vamp-ir as a library can call.

pub fn compile(source: impl AsRef<str>, config: &Config) -> Result<HaloCircuitData, Error>

The vamp-ir source can be passed in as a string reference or an owned string. The resulting HaloCircuitData is the type that's serialized out by the CLI.

The Config is currently only used for log level configuration.

An audit of panics should be made to see thich ones we should convert to Errors. This function currently panics on type errors (as illustrated by a test), this is an example of something that should be converted to an Error.

This commit adds some basic tests for compile and an integration test that compiles files in the tests/ directory. Some files are excluded because they are slow to compile or cause a stack overflow when compiled with the debug profile (the default for cargo test).

This PR also enables testing on CI for PRs https://github.com/anoma/vamp-ir/pull/119/commits/045005fccf16d95cc0284f1ec4782d5298ef8e42