Skip to content

Commit

Permalink
Update the rust-starter template to match new API (risc0#519)
Browse files Browse the repository at this point in the history
* Update the rust-starter template to match new API

* Incorporate testing the template within CI
  • Loading branch information
mothran authored Apr 19, 2023
1 parent 1f6a230 commit e862e0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,19 @@ jobs:
- uses: ./.github/actions/rustup
- uses: ./.github/actions/sccache
- run: RISC0_SKIP_BUILD=1 cargo doc --no-deps --exclude=risc0-zkvm-methods --workspace

check_template:
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}"]
strategy:
fail-fast: false
matrix:
os: [Linux, macOS]

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/rustup
- run: |
cargo run -p cargo-risczero risczero new --template templates/rust-starter --templ-subdir="" --path $(pwd) --dest ${{ runner.temp }} template-test
shell: bash
- run: cargo build --release --manifest-path ${{ runner.temp }}/template-test/Cargo.toml
- run: ${{ runner.temp }}/template-test/target/release/host
5 changes: 3 additions & 2 deletions templates/rust-starter/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// is `multiply`, replace `METHOD_NAME_ELF` with `MULTIPLY_ELF` and replace
// `METHOD_NAME_ID` with `MULTIPLY_ID`
use methods::{METHOD_NAME_ELF, METHOD_NAME_ID};
use risc0_zkvm::ExecutorEnv;
use risc0_zkvm::{prove::default_hal, Executor, ExecutorEnv};
// TODO: Uncomment the `use` line below for serialization helper functions for
// communication with the guest
// use risc0_zkvm::serde::{from_slice, to_vec}
Expand All @@ -11,7 +11,8 @@ fn main() {
let env = ExecutorEnv::default();
let mut exec = Executor::from_elf(env, METHOD_NAME_ELF).unwrap();
let session = exec.run().unwrap();
let receipt = session.prove().unwrap();
let (hal, eval) = default_hal();
let receipt = session.prove(hal.as_ref(), &eval).unwrap();

// TODO: Implement code for transmitting or serializing the receipt for
// other parties to verify here
Expand Down

0 comments on commit e862e0a

Please sign in to comment.