Skip to content

Commit

Permalink
[chore] fix dev graph tests (#212)
Browse files Browse the repository at this point in the history
* chore: CI uses clippy all-targets

* fix: dev-graph tests (only works for halo2-pse)

Didn't bother refactoring halo2-axiom to support dev-graph
  • Loading branch information
jonathanpwang authored Nov 3, 2023
1 parent 4bc9f0a commit 4e78e40
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all -- -D warnings
run: cargo clippy --all --all-targets -- -D warnings

- name: Generate Cargo.lock
run: cargo generate-lockfile
Expand Down
7 changes: 1 addition & 6 deletions halo2-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.gi
poseidon-rs = { git = "https://github.com/axiom-crypto/poseidon-circuit.git", rev = "1aee4a1" }
# plotting circuit layout
plotters = { version = "0.3.0", optional = true }
tabbycat = { version = "0.1", features = ["attributes"], optional = true }

# test-utils
rand = { version = "0.8", optional = true }
Expand All @@ -54,11 +53,7 @@ mimalloc = { version = "0.1", default-features = false, optional = true }
[features]
default = ["halo2-axiom", "display", "test-utils"]
asm = ["halo2_proofs_axiom?/asm"]
dev-graph = [
"halo2_proofs?/dev-graph",
"halo2_proofs_axiom?/dev-graph",
"plotters",
]
dev-graph = ["halo2_proofs/dev-graph", "plotters"] # only works with halo2-pse for now
halo2-pse = ["halo2_proofs/circuit-params"]
halo2-axiom = ["halo2_proofs_axiom"]
display = []
Expand Down
12 changes: 5 additions & 7 deletions halo2-base/src/gates/tests/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,26 @@ fn test_multithread_gates() {
);
}

/*
#[cfg(feature = "dev-graph")]
#[test]
fn plot_gates() {
let k = 5;
use plotters::prelude::*;

use crate::gates::circuit::builder::BaseCircuitBuilder;

let root = BitMapBackend::new("layout.png", (1024, 1024)).into_drawing_area();
root.fill(&WHITE).unwrap();
let root = root.titled("Gates Layout", ("sans-serif", 60)).unwrap();

let inputs = [Fr::zero(); 3];
let builder = GateThreadBuilder::new(false);
let mut builder = BaseCircuitBuilder::new(false).use_k(k);
gate_tests(builder.main(0), inputs);

// auto-tune circuit
builder.config(k, Some(9));
// create circuit
let circuit = RangeCircuitBuilder::keygen(builder);
halo2_proofs::dev::CircuitLayout::default().render(k, &circuit, &root).unwrap();
builder.calculate_params(Some(9));
halo2_proofs::dev::CircuitLayout::default().render(k as u32, &builder, &root).unwrap();
}
*/

fn range_tests<F: BigPrimeField>(
ctx: &mut Context<F>,
Expand Down
13 changes: 6 additions & 7 deletions halo2-ecc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ itertools = "0.10"
num-bigint = { version = "0.4", features = ["rand"] }
num-integer = "0.1"
num-traits = "0.2"
rand_core = { version = "0.6", default-features = false, features = [
"getrandom",
] }
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
rand = "0.8"
rand_chacha = "0.3.1"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -20,20 +18,21 @@ test-case = "3.1.0"

halo2-base = { path = "../halo2-base", default-features = false }

# plotting circuit layout
plotters = { version = "0.3.0", optional = true }

[dev-dependencies]
ark-std = { version = "0.3.0", features = ["print-trace"] }
pprof = { version = "0.13", features = ["criterion", "flamegraph"] }
criterion = "0.5.1"
criterion-macro = "0.4"
halo2-base = { path = "../halo2-base", default-features = false, features = [
"test-utils",
] }
halo2-base = { path = "../halo2-base", default-features = false, features = ["test-utils"] }
test-log = "0.2.12"
env_logger = "0.10.0"

[features]
default = ["jemallocator", "halo2-axiom", "display"]
dev-graph = ["halo2-base/dev-graph"]
dev-graph = ["halo2-base/dev-graph", "plotters"]
display = ["halo2-base/display"]
asm = ["halo2-base/asm"]
halo2-pse = ["halo2-base/halo2-pse"]
Expand Down
16 changes: 11 additions & 5 deletions halo2-ecc/src/fields/tests/fp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ fn test_range_check() {
#[cfg(feature = "dev-graph")]
#[test]
fn plot_fp() {
use halo2_base::gates::circuit::builder::BaseCircuitBuilder;
use halo2_base::halo2_proofs;
use plotters::prelude::*;

let root = BitMapBackend::new("layout.png", (1024, 1024)).into_drawing_area();
Expand All @@ -72,10 +74,14 @@ fn plot_fp() {
let a = Fq::zero();
let b = Fq::zero();

let mut builder = GateThreadBuilder::keygen();
fp_mul_test(builder.main(0), k - 1, 88, 3, a, b);
let mut builder = BaseCircuitBuilder::new(false).use_k(k).use_lookup_bits(k - 1);
let range = builder.range_chip();
let chip = FpChip::<Fr, Fq>::new(&range, 88, 3);
let ctx = builder.main(0);
let [a, b] = [a, b].map(|x| chip.load_private(ctx, x));
let c = chip.mul(ctx, a, b);

let config_params = builder.config(k, Some(10), Some(k - 1));
let circuit = RangeCircuitBuilder::keygen(builder, config_params);
halo2_proofs::dev::CircuitLayout::default().render(k as u32, &circuit, &root).unwrap();
let cp = builder.calculate_params(Some(10));
dbg!(cp);
halo2_proofs::dev::CircuitLayout::default().render(k as u32, &builder, &root).unwrap();
}

0 comments on commit 4e78e40

Please sign in to comment.