-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(raiko): generalized build pipeline for ZkVMs guests #133
Conversation
pipeline small fixes + makefile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be merging this one already, but a few things to follow up in future PRs:
- Update CI/scripts to use the same scripts/makefile (with perhaps extra flags for special CI logic).
- maybe gitignoring the generated files because they are big and potentially hard to keep up to date (though difficulties with CI right now with not checking them in so will have to see for this)
- some other minor things
The makefile approach already available locally for building so people can already get used to that, but still needs to be extended for installing everything as well.
? dude what's the point of making this a point lol |
Minor things that I can't be bothered to type out. 🦆 |
update path for chmod default.json Added step install nodejs feat(raiko): enable kzg blob check (taikoxyz#148) * feat(raiko): enable kzg blob check * update build script * update ci * fix ci * keep fixing ci * keep fixing ci - sgx docker build * fix ci risc0 * update ci env feat(raiko): generalized build pipeline for ZkVMs guests (taikoxyz#133) * init + some taiko_util -> util * pipeline * example * r0 bins & tests done * exmple-sp1 done * gen proof with unittests * test harness for sp1 doen + split the builder and driver * make example a workspace * change dest param * harness upgrade * image id compute * cleanup * pipeline api change * r0 switch builder-driver * r0 switch builder-driver * sp1 prover -> driver rename * sp1 builder * cargo check passed * name changes * commented out sp1 & ris0 flags in irrelavent setup * fixes + makefile * update * clean up * update CI r0 * update sp1 * add builder to workspace * sp1 CI permission denied * add example test in guest + clippy * add test to CI * fmt & fix CI bug * test with --release + toolchain * fix * fix docker * add CC support for c-kzg * trait Pipeline impl in specific builder * fix ci * download & verify riscv-gcc-prebuilt * Update pipeline/src/lib.rs * update script * Updated readme + fix local building * cargo: -> cargo:: --------- Co-authored-by: Brechtpd <Brechtp.devos@gmail.com> fix(lib): temporarily disable kzg check in sgx/sp1 provers (taikoxyz#157) * temporarily disable kzg check in sgx/sp1 provers * fix typo fast on-chain register + change path before clone repo
Problem:
#[test]
, which means we need to compile Rust's test harness into risv32 elfSolution
I'm gonna make the build pipeline myself so that I don't want to bother about the upstream, and also to test and benchmark my code however i want. also. Here are some of the design considerations:
In embedded system compilation, you need the correct target & toolchain for cargo and rustc, under the hood you might need to swap out gcc or llvm, which means you need to set a bunch of flags and args that go into the compilers.
Currently most ZkVM build the guest in
build.rs
, and gen proofs & verify inmain.rs
, which means these are the processes actually being run:build.rs
, resulting in binarytarget/debug/build/hello-world-b4166fd/build-script-build
build-script-build
, which invokes another cargo process that builds the guest ELF; here's how the command can look like:main.rs
which loads the ELF into our VM runtime and generates a proof.I'm making the build stage explicit, which means having a
builder
crate to replacebuild.rs
. Within the pipeline, there are two steps: 1) configure the right flags and env to generate a correct command 2) execute the command and place the ELFs in some user-specified directories. Resulting file structure:Workflow
Build the ELFs
Run the ELFs
Builder
The resultant pipeline starts with parsing the Cargo manifest, then setup the
Builder
with the right flags.The executor runs the desired action (e.g.
cargo build
orcargo test
) and finally place the ELF to specified dest directory.Test Harness
I implemented a light-weight harness to build test suits and run them in the ELF's main. The main with normal
cargo test
compilation is an alternative entrypoint is created that collide with the ZkVM entrypoint. The resulted test workflow looks like this:After you write tests in the guest program, compile them:
This will gives you binaries equivalent to
cargo test --no-run --bin example -- bin foo
. Then in the host: