Skip to content
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

Add feature gating for slow tests and cache SRS using git LFS #27

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.srs filter=lfs diff=lfs merge=lfs -text
15 changes: 12 additions & 3 deletions .github/workflows/foundry-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: test
name: Foundry Tests

on: workflow_dispatch
on:
pull_request:
branches:
- main
push:
branches:
- main

env:
FOUNDRY_PROFILE: ci
Expand All @@ -12,6 +18,10 @@ jobs:

name: Foundry project
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./contracts

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -24,7 +34,6 @@ jobs:

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,30 @@ jobs:
test:
name: build-and-test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Give GitHub Actions access to sygmaprotocol/zipline
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SYGMA_REPO_PULL_KEY }}
- uses: actions/checkout@v3
- name: Install latest nightly-2022-10-28
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2022-10-28
override: true
components: rustfmt
lfs: true

- name: Checkout LFS objects # used for structured reference strings for tests (.srs files)
run: git lfs checkout

- name: Read toolchain file
id: rust-toolchain
run: |
RUST_TOOLCHAIN=$(grep 'channel' rust-toolchain.toml | awk '{split($0,a," = "); print a[2]}' | tr -d '"')
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
shell: bash

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain.outputs.RUST_TOOLCHAIN }}
components: rustfmt

- name: Install just
uses: extractions/setup-just@v1
Expand All @@ -41,11 +52,9 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1

- name: Build contracts
run: just build-contracts

# skip this in favour of compiling in the `Test` action.
# - name: Check
# run: cargo check --all
run: just build-contracts

- name: Test
run: RUST_LOG="lightclient-circuits=debug" PARAMS_DIR="./test_data" cargo test --release test_eth2_spec_mock_1 -- --nocapture
# currently this is skipping the rotation circuit spec tests because they use too much memory on CI and cause it to be stopped
# This should be fixed in a future PR and tests re-enabled
run: RUST_LOG="lightclient-circuits=debug" FLEX_SHA_SPREAD_COLUMNS=2 cargo test --release -- --nocapture --skip test_sync_circuit --skip test_committee_update_circuit
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ minimal.tar.gz
/target
node_modules

/zkcasper-circuits/build
/zkcasper-circuits/params

lightclient-circuits/params/

lightclient-circuits/build/

build/

params/

.env

*.pk
Expand Down
3 changes: 3 additions & 0 deletions contract-tests/params/kzg_bn254_20.srs
Git LFS file not shown
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ set positional-arguments
test:
cargo test --workspace

test-full-prover:
cargo test --workspace --features test-full-prover

test-evm-verifier:
cargo test --workspace --features test-evm-verifier

fmt:
cargo fmt --all

Expand Down
3 changes: 3 additions & 0 deletions lightclient-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ lazy_static = "1.4"

[dev-dependencies]
rstest = "0.18.2"
serial_test = "2.0.0"
test-utils = { workspace = true }

[features]
default = []
test-full-prover = []
test-evm-verifier = []
3 changes: 3 additions & 0 deletions lightclient-circuits/params/kzg_bn254_10.srs
Git LFS file not shown
3 changes: 3 additions & 0 deletions lightclient-circuits/params/kzg_bn254_15.srs
Git LFS file not shown
3 changes: 3 additions & 0 deletions lightclient-circuits/params/kzg_bn254_18.srs
Git LFS file not shown
3 changes: 3 additions & 0 deletions lightclient-circuits/params/kzg_bn254_21.srs
Git LFS file not shown
4 changes: 4 additions & 0 deletions lightclient-circuits/src/committee_update_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-full-prover")]
fn test_committee_update_proofgen() {
const K: u32 = 18;
let params = gen_srs(K);
Expand Down Expand Up @@ -404,6 +405,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-full-prover")]
fn test_circuit_aggregation_proofgen() {
const AGG_CONFIG_PATH: &str = "./config/committee_update_aggregation.json";
const APP_K: u32 = 20;
Expand Down Expand Up @@ -451,6 +453,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-evm-verifier")]
fn test_circuit_aggregation_evm() {
const AGG_CONFIG_PATH: &str = "./config/committee_update_a.json";
const APP_K: u32 = 21;
Expand Down Expand Up @@ -510,6 +513,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-evm-verifier")]
fn test_circuit_aggregation_2_evm() {
const K0: u32 = 20;
const K1: u32 = 24;
Expand Down
4 changes: 3 additions & 1 deletion lightclient-circuits/src/gadget/crypto/hash2curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ mod test {
use halo2_proofs::circuit::Value;
use halo2curves::bls12_381::G2;
use sha2::{Digest, Sha256};
use serial_test::serial;

fn get_circuit<F: Field>(
k: usize,
Expand Down Expand Up @@ -679,8 +680,9 @@ mod test {
}

#[test]
#[serial]
fn test_hash_to_g2() {
let k = 17;
let k = 20;

let test_input = vec![0u8; 32];
let builder = ShaThreadBuilder::<Fr>::mock();
Expand Down
5 changes: 4 additions & 1 deletion lightclient-circuits/src/gadget/crypto/sha256_flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ mod test {

use crate::gadget::crypto::ShaCircuitBuilder;
use crate::util::{full_prover, full_verifier, gen_pkey, Challenges, IntoWitness};

use super::*;
use ark_std::{end_timer, start_timer};
use eth_types::Testnet;
Expand All @@ -228,6 +227,7 @@ mod test {
},
};
use sha2::{Digest, Sha256};
use serial_test::serial;

fn test_circuit<F: Field>(
k: usize,
Expand All @@ -246,6 +246,7 @@ mod test {
}

#[test]
#[serial]
fn test_sha256_chip_constant_size() {
let k = 15;

Expand All @@ -260,6 +261,7 @@ mod test {
}

#[test]
#[serial]
fn test_sha256_params_gen() {
let k = 15;
let test_input = vec![0u8; 64];
Expand All @@ -272,6 +274,7 @@ mod test {
}

#[test]
#[cfg(feature = "test-full-prover")]
fn test_sha256_proof_gen() {
let k = 15;
let test_input = vec![0u8; 64];
Expand Down
11 changes: 10 additions & 1 deletion lightclient-circuits/src/gadget/crypto/sha256_flex/spread.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::env::var;
use std::marker::PhantomData;

use crate::util::{ThreadBuilderBase, ThreadBuilderConfigBase};
Expand Down Expand Up @@ -45,6 +46,7 @@ impl<F: Field> SpreadConfig<F> {
num_bits_lookup: usize,
num_advice_columns: usize,
) -> Self {
println!("num_advice_columns: {}", num_advice_columns);
debug_assert_eq!(16 % num_bits_lookup, 0);

let denses = (0..num_advice_columns)
Expand Down Expand Up @@ -94,7 +96,14 @@ impl<F: Field> SpreadConfig<F> {

impl<F: Field> ThreadBuilderConfigBase<F> for SpreadConfig<F> {
fn configure(meta: &mut ConstraintSystem<F>, params: FlexGateConfigParams) -> Self {
Self::configure(meta, 8, 1) // TODO configure num_advice_columns
Self::configure(
meta,
8,
var("FLEX_SHA_SPREAD_COLUMNS")
.unwrap_or_else(|_| "1".to_string())
.parse()
.unwrap(),
) // TODO configure num_advice_columns
}

fn load(&self, layouter: &mut impl Layouter<F>) -> Result<(), Error> {
Expand Down
3 changes: 3 additions & 0 deletions lightclient-circuits/src/gadget/crypto/sha256_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ mod test {
},
};
use sha2::{Digest, Sha256};
use serial_test::serial;

fn test_circuit<F: Field>(
k: usize,
Expand All @@ -286,6 +287,7 @@ mod test {
}

#[test]
#[serial]
fn test_sha256_chip_constant_size() {
let k = 10;

Expand All @@ -303,6 +305,7 @@ mod test {
}

#[test]
#[serial]
fn test_sha256_wide_params_gen() {
let k = 10;
let test_input = vec![1u8; 64];
Expand Down
2 changes: 2 additions & 0 deletions lightclient-circuits/src/sync_step_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-full-prover")]
fn test_sync_proofgen() {
const K: u32 = 22;
let params = gen_srs(K);
Expand Down Expand Up @@ -597,6 +598,7 @@ mod tests {
}

#[test]
#[cfg(feature = "test-evm-verifier")]
fn test_sync_evm_verify() {
const K: u32 = 22;
let params = gen_srs(K);
Expand Down
2 changes: 2 additions & 0 deletions lightclient-circuits/tests/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn run_test_eth2_spec_mock<const K_ROTATION: u32, const K_SYNC: u32>(path: PathB
}

#[rstest]
#[cfg(feature = "test-full-prover")]
fn test_eth2_spec_proofgen(
#[files("../consensus-spec-tests/tests/minimal/capella/light_client/sync/pyspec_tests/**")]
#[exclude("deneb*")]
Expand Down Expand Up @@ -119,6 +120,7 @@ fn test_eth2_spec_proofgen(
}

#[rstest]
#[cfg(feature = "test-evm-verifier")]
fn test_eth2_spec_evm_verify(
#[files("../consensus-spec-tests/tests/minimal/capella/light_client/sync/pyspec_tests/**")]
#[exclude("deneb*")]
Expand Down
3 changes: 3 additions & 0 deletions preprocessor/params/kzg_bn254_21.srs
Git LFS file not shown
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2023-04-18"
Loading