diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 000000000..2c1df2856 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,12 @@ +[profile.ci] +# Print out output for failing tests as soon as they fail, and also at the end +# of the run (for easy scrollability). +failure-output = "immediate-final" +# Show skipped tests in the CI output. +status-level = "skip" +# Do not cancel the test run on the first failure. +fail-fast = false +# Mark tests as slow after 5mins, kill them after 20mins +slow-timeout = { period = "300s", terminate-after = 4 } +# Retry failed tests once, marked flaky if test then passes +retries = 1 \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..98e028a25 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: / + pull-request-branch-name: + separator: "-" + schedule: + interval: weekly + groups: + rust-dependencies: + patterns: + - "*" + open-pull-requests-limit: 5 + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ba4ed36ed..d9bcd31ef 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,36 +1,62 @@ name: Build and Test Nova on: + merge_group: push: - branches: [ main ] + branches: [ dev ] pull_request: - branches: [ main ] + types: [opened, synchronize, reopened, ready_for_review] + branches: [ dev ] + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + RUST_BACKTRACE: short + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: build: runs-on: ubuntu-latest + env: + RUSTFLAGS: -D warnings steps: - uses: actions/checkout@v2 - - name: Install - run: rustup default stable - - name: Install rustfmt Components - run: rustup component add rustfmt - - name: Install clippy - run: rustup component add clippy - - name: Install Wasm target - run: rustup target add wasm32-unknown-unknown - - name: Build - run: cargo build --verbose - - name: Wasm build - run: cargo build --target wasm32-unknown-unknown - - name: Build examples - run: cargo build --examples --verbose - - name: Build benches - run: cargo build --benches --verbose - - name: Run tests - run: cargo +stable test --release --verbose - - name: Check Rustfmt Code Style - run: cargo fmt --all -- --check - - name: Check clippy warnings - run: cargo clippy --all-targets -- -D warnings + - name: Setup Rust + uses: actions-rs/toolchain@v1 + - uses: taiki-e/install-action@nextest + - uses: Swatinem/rust-cache@v2 + - name: Build, with benches & examples + run: cargo build --profile dev-ci --benches --examples + - name: Linux Tests in parallel, with nextest profile ci and cargo profile dev-ci + run: | + cargo nextest run --profile ci --workspace --cargo-profile dev-ci + misc: + runs-on: ubuntu-latest + strategy: + fail-fast: false + env: + RUSTFLAGS: -D warnings + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + - run: rustup target add wasm32-unknown-unknown + - name: Wasm build + run: cargo build --target wasm32-unknown-unknown + - name: Check Rustfmt Code Style + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + - name: Check clippy warnings + run: cargo clippy --all-targets -- -D warnings + - name: Doctests + run: cargo test --doc --workspace diff --git a/Cargo.toml b/Cargo.toml index d6d77f604..3c56ffce7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ halo2curves = { version = "0.4.0", features = ["derive_serde"] } group = "0.13.0" log = "0.4.17" abomonation = "0.7.3" -abomonation_derive = { git = "https://github.com/winston-h-zhang/abomonation_derive.git" } +abomonation_derive = { git = "https://github.com/lurk-lab/abomonation_derive.git" } [target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies] pasta-msm = { git="https://github.com/lurk-lab/pasta-msm", branch="dev", version = "0.1.4" } @@ -88,3 +88,11 @@ supernova = [] # This is needed to ensure halo2curves, which imports pasta-curves, uses the *same* traits in bn256_grumpkin [patch.crates-io] pasta_curves = { git="https://github.com/lurk-lab/pasta_curves", branch="dev" } + +[profile.dev-ci] +inherits = "dev" +# By compiling dependencies with optimizations, performing tests gets much faster. +opt-level = 3 +lto = "thin" +incremental = false +codegen-units = 16 diff --git a/examples/minroot_serde.rs b/examples/minroot_serde.rs index a92fede5a..377f7a696 100644 --- a/examples/minroot_serde.rs +++ b/examples/minroot_serde.rs @@ -36,7 +36,7 @@ unsafe fn entomb_F(f: &F, bytes: &mut W) -> std::io::Re } /// this is **incredibly, INCREDIBLY** dangerous -unsafe fn exhume_F<'a, 'b, F: PrimeField>(f: &mut F, bytes: &'a mut [u8]) -> Option<&'a mut [u8]> { +unsafe fn exhume_F<'a, F: PrimeField>(f: &mut F, bytes: &'a mut [u8]) -> Option<&'a mut [u8]> { let (mine, rest) = bytes.split_at_mut(size_of::()); let mine = (mine as *const [u8]) as *const F; std::ptr::write(f, std::ptr::read(mine)); @@ -60,7 +60,7 @@ impl abomonation::Abomonation for MinRootIteration { Ok(()) } - unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { + unsafe fn exhume<'b>(&mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { let bytes = exhume_F(&mut self.x_i, bytes)?; let bytes = exhume_F(&mut self.y_i, bytes)?; let bytes = exhume_F(&mut self.x_i_plus_1, bytes)?; @@ -195,7 +195,7 @@ fn main() { TrivialTestCircuit<::Scalar>, >::setup(&circuit_primary, &circuit_secondary); assert!(result.clone() == pp, "not equal!"); - assert!(remaining.len() == 0); + assert!(remaining.is_empty()); } else { println!("Something terrible happened"); } diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 000000000..832e9afb6 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +1.70.0 diff --git a/src/gadgets/r1cs.rs b/src/gadgets/r1cs.rs index 4ab4ddf96..2b1dfcd92 100644 --- a/src/gadgets/r1cs.rs +++ b/src/gadgets/r1cs.rs @@ -385,6 +385,7 @@ pub fn conditionally_select_alloc_relaxed_r1cs< Ok(c) } +#[allow(dead_code)] /// c = cond ? a: b, where a, b: vec[AllocatedRelaxedR1CSInstance] pub fn conditionally_select_vec_allocated_relaxed_r1cs_instance< G: Group,