Skip to content

Commit

Permalink
Merge pull request #84 from han0110/feature/abstraction-squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
han0110 authored Aug 19, 2022
2 parents 2a19e44 + 3e4b27f commit 0cccba0
Show file tree
Hide file tree
Showing 129 changed files with 6,214 additions and 2,818 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/bench.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/book.yml

This file was deleted.

38 changes: 6 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
override: false
- name: Run tests
uses: actions-rs/cargo@v1
with:
Expand All @@ -35,8 +34,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
override: false
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: cargo build
Expand All @@ -53,35 +51,14 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
override: false
# Build benchmarks to prevent bitrot
- name: Build benchmarks
uses: actions-rs/cargo@v1
with:
command: build
args: --benches --examples --all-features

book:
name: Book tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.5'
- name: Test halo2 book
run: mdbook test -L target/debug/deps book/

codecov:
name: Code coverage
runs-on: ubuntu-latest
Expand All @@ -91,8 +68,7 @@ jobs:
# Use stable for this to ensure that cargo-tarpaulin can be built.
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
override: false
- name: Install cargo-tarpaulin
uses: actions-rs/cargo@v1
with:
Expand All @@ -114,8 +90,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
override: false
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
Expand All @@ -137,8 +112,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
override: true
override: false
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lints-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: beta
components: clippy
override: true
override: false
- name: Run Clippy (beta)
uses: actions-rs/clippy-check@v1
continue-on-error: true
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lints-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.1
components: clippy
override: true
override: false
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/trigger_proverbench_dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Prover Bench on halo2 PR
on:
pull_request:
types: [labeled , ready_for_review]
jobs:
Prover-benches-via-repo-dispatch-from-halo2-fork:
if: ${{ github.event.label.name == 'benchmarks' }}
runs-on: ubuntu-latest
env:
GH_USER: ${{ github.actor }}
_TOKEN: ${{ secrets.BENCHMARKER }}
REVISION: ${{ github.event.pull_request.head.sha }}
REPO: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.number }}
steps:
- name: Install curl
run: |
sudo apt-get update
sudo apt-get install curl
- name: Send repo api call
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u ZKEVMBOT:${{ env._TOKEN }} \
https://github.com/gitapi/repos/appliedzkp/zkevm-circuits/actions/workflows/ProverBenchFromHalo2.yml/dispatches \
-d "{\"ref\":\"main\",\"inputs\":{\"halo2pr\":\"${{ env.PR_NUMBER }}\",\"revision\":\"${{ env.REVISION }}\",\"event-type\":\"halo2_wfdispatch\",\"ghuser\": \"${{ env.GH_USER }}\"}}"
2 changes: 1 addition & 1 deletion halo2_gadgets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ff = "0.12"
group = "0.12"
halo2_proofs = { version = "0.2", path = "../halo2_proofs" }
lazy_static = "1"
pasta_curves = "0.4"
halo2curves = { git = 'https://github.com/privacy-scaling-explorations/halo2curves', tag = 'v0.2.0' }
proptest = { version = "1.0.0", optional = true }
rand = "0.8"
subtle = "2.3"
Expand Down
49 changes: 37 additions & 12 deletions halo2_gadgets/benches/poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use ff::Field;
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner, Value},
pasta::Fp,
plonk::{
create_proof, keygen_pk, keygen_vk, verify_proof, Advice, Circuit, Column,
ConstraintSystem, Error, SingleVerifier,
ConstraintSystem, Error,
},
poly::commitment::Params,
transcript::{Blake2bRead, Blake2bWrite, Challenge255},
};
use pasta_curves::{pallas, vesta};
use halo2curves::pasta::{pallas, vesta, EqAffine, Fp};

use halo2_gadgets::poseidon::{
primitives::{self as poseidon, ConstantLength, Spec},
Expand All @@ -21,6 +19,19 @@ use std::marker::PhantomData;
use criterion::{criterion_group, criterion_main, Criterion};
use rand::rngs::OsRng;

use halo2_proofs::{
poly::{
commitment::ParamsProver,
ipa::{
commitment::{IPACommitmentScheme, ParamsIPA},
multiopen::ProverIPA,
strategy::SingleStrategy,
},
VerificationStrategy,
},
transcript::{TranscriptReadBuffer, TranscriptWriterBuffer},
};

#[derive(Clone, Copy)]
struct HashCircuit<S, const WIDTH: usize, const RATE: usize, const L: usize>
where
Expand Down Expand Up @@ -184,7 +195,7 @@ fn bench_poseidon<S, const WIDTH: usize, const RATE: usize, const L: usize>(
S: Spec<Fp, WIDTH, RATE> + Copy + Clone,
{
// Initialize the polynomial commitment parameters
let params: Params<vesta::Affine> = Params::new(K);
let params: ParamsIPA<vesta::Affine> = ParamsIPA::new(K);

let empty_circuit = HashCircuit::<S, WIDTH, RATE, L> {
message: Value::unknown(),
Expand Down Expand Up @@ -216,21 +227,35 @@ fn bench_poseidon<S, const WIDTH: usize, const RATE: usize, const L: usize>(
c.bench_function(&prover_name, |b| {
b.iter(|| {
// Create a proof
let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]);
create_proof(&params, &pk, &[circuit], &[&[]], &mut rng, &mut transcript)
.expect("proof generation should not fail")
let mut transcript = Blake2bWrite::<_, EqAffine, Challenge255<_>>::init(vec![]);
create_proof::<IPACommitmentScheme<_>, ProverIPA<_>, _, _, _, _>(
&params,
&pk,
&[circuit],
&[&[]],
&mut rng,
&mut transcript,
)
.expect("proof generation should not fail")
})
});

// Create a proof
let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]);
create_proof(&params, &pk, &[circuit], &[&[]], &mut rng, &mut transcript)
.expect("proof generation should not fail");
let mut transcript = Blake2bWrite::<_, EqAffine, Challenge255<_>>::init(vec![]);
create_proof::<IPACommitmentScheme<_>, ProverIPA<_>, _, _, _, _>(
&params,
&pk,
&[circuit],
&[&[]],
&mut rng,
&mut transcript,
)
.expect("proof generation should not fail");
let proof = transcript.finalize();

c.bench_function(&verifier_name, |b| {
b.iter(|| {
let strategy = SingleVerifier::new(&params);
let strategy = SingleStrategy::new(&params);
let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]);
assert!(verify_proof(&params, pk.get_vk(), strategy, &[&[]], &mut transcript).is_ok());
});
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/benches/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use halo2_gadgets::{
sinsemilla::primitives as sinsemilla,
};

use pasta_curves::pallas;
use halo2curves::pasta::pallas;
#[cfg(unix)]
use pprof::criterion::{Output, PProfProfiler};
use rand::{rngs::OsRng, Rng};
Expand Down
Loading

0 comments on commit 0cccba0

Please sign in to comment.