Skip to content

Commit

Permalink
opcode: add/sub trace integration and ci pipeline (#209)
Browse files Browse the repository at this point in the history
- [x] add/sub assignment from trace 
- [x] add integration test ci pipeline
   > it will run `riscv_add.rs` with end 2 end test
  • Loading branch information
hero78119 committed Sep 30, 2024
1 parent e595b2d commit d646e95
Show file tree
Hide file tree
Showing 13 changed files with 465 additions and 135 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Integrations

on:
merge_group:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
push:
branches:
- master

jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/README.md"]'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule", "merge_group"]'

lints:
needs: [skip_check]
if: |
github.event.pull_request.draft == false &&
(github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true')
name: Various lints
timeout-minutes: 30
runs-on: ubuntu-latest

strategy:
matrix:
target: [x86_64-unknown-linux-gnu, riscv32im-unknown-none-elf]
# Exclude the riscv32im-unknown-none-elf target
exclude:
- target: riscv32im-unknown-none-elf

steps:
- uses: actions/checkout@v2
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: integration-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run example
uses: actions-rs/cargo@v1
env:
RAYON_NUM_THREADS: 2
with:
command: run
args: --package ceno_zkvm --example riscv_add --target ${{ matrix.target }} -- --start 10 --end 11

1 change: 0 additions & 1 deletion .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Lints

# We only run these lints on trial-merges of PRs to reduce noise.
on:
merge_group:
pull_request:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Tests

# We only run these lints on trial-merges of PRs to reduce noise.
on:
merge_group:
pull_request:
Expand Down
105 changes: 97 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ceno_zkvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ tracing = "0.1.40"
rand = "0.8"
thread_local = "1.1.8"
generic_static = "0.2.0"
clap = { version = "4.5.17", features = ["derive"] }

[dev-dependencies]
pprof = { version = "0.13", features = ["flamegraph"]}
Expand Down
25 changes: 19 additions & 6 deletions ceno_zkvm/benches/riscv_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::time::{Duration, Instant};

use ark_std::test_rng;
use ceno_zkvm::{
circuit_builder::{CircuitBuilder, ConstraintSystem},
self,
instructions::{riscv::addsub::AddInstruction, Instruction},
scheme::prover::ZKVMProver,
structs::{ZKVMConstraintSystem, ZKVMFixedTraces},
};
use const_env::from_env;
use criterion::*;
Expand Down Expand Up @@ -62,11 +63,22 @@ fn bench_add(c: &mut Criterion) {
RAYON_NUM_THREADS
}
};
let mut cs = ConstraintSystem::new(|| "risv_add");
let mut circuit_builder = CircuitBuilder::<GoldilocksExt2>::new(&mut cs);
let _ = AddInstruction::construct_circuit(&mut circuit_builder);
let pk = cs.key_gen(None);
let num_witin = pk.get_cs().num_witin;
let mut zkvm_cs = ZKVMConstraintSystem::default();
let _ = zkvm_cs.register_opcode_circuit::<AddInstruction<E>>();
let mut zkvm_fixed_traces = ZKVMFixedTraces::default();
zkvm_fixed_traces.register_opcode_circuit::<AddInstruction<E>>(&zkvm_cs);

let pk = zkvm_cs
.clone()
.key_gen(zkvm_fixed_traces)
.expect("keygen failed");

let circuit_pk = pk
.circuit_pks
.get(&AddInstruction::<E>::name())
.unwrap()
.clone();
let num_witin = circuit_pk.get_cs().num_witin;

let prover = ZKVMProver::new(pk);
let mut transcript = Transcript::new(b"riscv");
Expand Down Expand Up @@ -101,6 +113,7 @@ fn bench_add(c: &mut Criterion) {
let timer = Instant::now();
let _ = prover
.create_opcode_proof(
&circuit_pk,
wits_in,
num_instances,
max_threads,
Expand Down
Loading

0 comments on commit d646e95

Please sign in to comment.