Skip to content
Merged
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
481 changes: 231 additions & 250 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions compiler/noirc_evaluator/src/ssa/opt/as_slice_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl Ssa {
/// necessary when the value of the array is unknown.
///
/// Note that this pass must be placed before loop unrolling to be useful.
#[expect(clippy::wrong_self_convention)]
#[tracing::instrument(level = "trace", skip(self))]
pub(crate) fn as_slice_optimization(mut self) -> Self {
for func in self.functions.values_mut() {
Expand Down
5 changes: 5 additions & 0 deletions compiler/wasm/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build]
target = "wasm32-unknown-unknown"

[target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
1 change: 1 addition & 0 deletions compiler/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ nargo.workspace = true
# This is an unused dependency, we are adding it
# so that we can enable the js feature in getrandom.
getrandom = { workspace = true, features = ["js"] }
getrandomv3 = { package = "getrandom", version = "^0.3.3", features = ["wasm_js"] }

# This is an unused dependency, we are adding it
# so that we can enable the debug-embed feature in rust-embed.
Expand Down
1 change: 1 addition & 0 deletions compiler/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// See Cargo.toml for explanation.
use getrandom as _;
use getrandomv3 as _;

Check warning on line 7 in compiler/wasm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (getrandomv)
use rust_embed as _;

use gloo_utils::format::JsValueSerdeExt;
Expand Down
13 changes: 5 additions & 8 deletions tooling/ast_fuzzer/src/compare/interpreted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}

pub fn exec(&self) -> eyre::Result<CompareInterpretedResult> {
// Debug prints up fron tin case the interpreter panics. Turn them on with `RUST_LOG=debug cargo test ...`

Check warning on line 77 in tooling/ast_fuzzer/src/compare/interpreted.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (fron)
log::debug!("Program: \n{}\n", crate::DisplayAstAsNoir(&self.program));
log::debug!(
"ABI inputs: \n{}\n",
Expand Down Expand Up @@ -123,7 +123,7 @@
false
}
(Overflow { instruction: i1 }, Overflow { instruction: i2 }) => {
// Overflows can occur or uncomparable instructions, but in a parentheses it contains the values that caused it.

Check warning on line 126 in tooling/ast_fuzzer/src/compare/interpreted.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (uncomparable)
fn details(s: &str) -> Option<&str> {
let start = s.find("(")?;
let end = s.find(")")?;
Expand Down Expand Up @@ -236,15 +236,12 @@
AbiType::Tuple { fields } => {
assert_eq!(fields.len(), input_values.len(), "tuple size != input length");

let elements = vecmap(fields.iter().zip(input_values), |(typ, input)| {
input_value_to_ssa(typ, input)
})
.into_iter()
.flatten()
.collect();

// Tuples are not wrapped into arrays, they are returned as a vector.
elements
fields
.iter()
.zip(input_values)
.flat_map(|(typ, input)| input_value_to_ssa(typ, input))
.collect()
}
other => {
panic!("unexpected ABI type for vector input: {other:?}")
Expand Down
10 changes: 5 additions & 5 deletions tooling/ast_fuzzer/src/input/int.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use proptest::{
prelude::Rng,
strategy::{NewTree, Strategy},
test_runner::TestRunner,
};
use rand::Rng;

type BinarySearch = proptest::num::i128::BinarySearch;

Expand Down Expand Up @@ -33,9 +33,9 @@ impl IntStrategy {
fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let rng = runner.rng();

let offset = rng.gen_range(0..4);
let offset = rng.random_range(0..4);
// Choose if we want values around min, -0, +0, or max
let kind = rng.gen_range(0..4);
let kind = rng.random_range(0..4);
let start = match kind {
0 => self.type_min() + offset,
1 => -offset - 1i128,
Expand All @@ -49,7 +49,7 @@ impl IntStrategy {

fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let rng = runner.rng();
let start: i128 = rng.gen_range(self.type_min()..=self.type_max());
let start: i128 = rng.random_range(self.type_min()..=self.type_max());
Ok(BinarySearch::new(start))
}

Expand All @@ -70,7 +70,7 @@ impl Strategy for IntStrategy {

fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let total_weight = self.random_weight + self.edge_weight;
let bias = runner.rng().gen_range(0..total_weight);
let bias = runner.rng().random_range(0..total_weight);
// randomly select one of 2 strategies
match bias {
x if x < self.edge_weight => self.generate_edge_tree(runner),
Expand Down
12 changes: 6 additions & 6 deletions tooling/ast_fuzzer/src/input/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BTreeSet;

use acvm::{AcirField, FieldElement};
use proptest::{
prelude::Rng,
strategy::{NewTree, Strategy},
test_runner::TestRunner,
};
use rand::Rng;

type BinarySearch = proptest::num::u128::BinarySearch;

Expand Down Expand Up @@ -48,8 +48,8 @@ impl UintStrategy {
fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let rng = runner.rng();
// Choose if we want values around 0 or max
let is_min = rng.gen_bool(0.5);
let offset = rng.gen_range(0..4);
let is_min = rng.random_bool(0.5);
let offset = rng.random_range(0..4);
let start = if is_min {
offset.min(self.type_max())
} else {
Expand All @@ -67,15 +67,15 @@ impl UintStrategy {
}

// Generate value tree from fixture.
let fixture = &self.fixtures[runner.rng().gen_range(0..self.fixtures.len())];
let fixture = &self.fixtures[runner.rng().random_range(0..self.fixtures.len())];

Ok(BinarySearch::new(fixture.to_u128()))
}

/// Generate random values between 0 and the MAX with the given bit width.
fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let rng = runner.rng();
let start = rng.gen_range(0..=self.type_max());
let start = rng.random_range(0..=self.type_max());

Ok(BinarySearch::new(start))
}
Expand All @@ -93,7 +93,7 @@ impl Strategy for UintStrategy {
/// Pick randomly from the 3 available strategies for generating unsigned integers.
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
let total_weight = self.random_weight + self.fixtures_weight + self.edge_weight;
let bias = runner.rng().gen_range(0..total_weight);
let bias = runner.rng().random_range(0..total_weight);
// randomly select one of 3 strategies
match bias {
x if x < self.edge_weight => self.generate_edge_tree(runner),
Expand Down
2 changes: 2 additions & 0 deletions tooling/ast_fuzzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#![warn(clippy::semicolon_if_nothing_returned)]
#![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))]

use rand as _;

mod abi;
pub mod compare;
mod input;
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo/src/ops/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ where
Some(ref dir) => PathBuf::from(dir),
None => {
let corpus_dir = tempfile::tempdir().expect("Couldn't create temporary directory");
let corpus_dir = corpus_dir.into_path();
let corpus_dir = corpus_dir.keep();
temporary_dirs_to_delete.push(corpus_dir.clone());
corpus_dir
}
Expand Down
6 changes: 3 additions & 3 deletions tooling/nargo_cli/tests/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}

// Enable enums and ownership as unstable features
nargo.arg("-Zenums");

Check warning on line 63 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)

if force_brillig.0 {
{
Expand Down Expand Up @@ -138,7 +138,7 @@
force_brillig: ForceBrillig,
inliner: Inliner,
) {
let target_dir = tempfile::tempdir().unwrap().into_path();
let target_dir = tempfile::tempdir().unwrap().keep();

nargo.arg(format!("--target-dir={}", target_dir.to_string_lossy()));

Expand Down Expand Up @@ -307,7 +307,7 @@
nargo.arg("execute").arg("--force").arg("--disable-comptime-printing");

// Enable enums as an unstable feature
nargo.arg("-Zenums");

Check warning on line 310 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)

// Enable pedantic solving
nargo.arg("--pedantic-solving");
Expand All @@ -322,7 +322,7 @@
nargo.arg("expand").arg("--force").arg("--disable-comptime-printing");

// Enable enums as an unstable feature
nargo.arg("-Zenums");

Check warning on line 325 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)

// Enable pedantic solving
nargo.arg("--pedantic-solving");
Expand All @@ -343,10 +343,10 @@
});

// Create a new directory where we'll put the expanded code
let temp_dir = tempfile::tempdir().unwrap().into_path();
let temp_dir = tempfile::tempdir().unwrap().keep();

// Copy everything from the original directory to the new directory
// (because some depdendencies might be there and might be needed for the expanded code to work)

Check warning on line 349 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (depdendencies)
copy_dir_all(test_program_dir.clone(), temp_dir.clone()).unwrap();

// Create a main file for the expanded code
Expand All @@ -361,7 +361,7 @@
nargo.arg("execute").arg("--force").arg("--disable-comptime-printing");

// Enable enums as an unstable feature
nargo.arg("-Zenums");

Check warning on line 364 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)

// Enable pedantic solving
nargo.arg("--pedantic-solving");
Expand All @@ -383,7 +383,7 @@
nargo.arg("expand").arg("--force").arg("--disable-comptime-printing");

// Enable enums as an unstable feature
nargo.arg("-Zenums");

Check warning on line 386 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)

// Enable pedantic solving
nargo.arg("--pedantic-solving");
Expand All @@ -404,10 +404,10 @@
});

// Create a new directory where we'll put the expanded code
let temp_dir = tempfile::tempdir().unwrap().into_path();
let temp_dir = tempfile::tempdir().unwrap().keep();

// Copy everything from the original directory to the new directory
// (because some depdendencies might be there and might be needed for the expanded code to work)

Check warning on line 410 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (depdendencies)
copy_dir_all(test_program_dir.clone(), temp_dir.clone()).unwrap();

// Create a main file for the expanded code
Expand Down
2 changes: 1 addition & 1 deletion tooling/profiler/src/cli/execution_flamegraph_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ mod tests {
&artifact_path,
&prover_toml_path,
&flamegraph_generator,
&Some(temp_dir.into_path()),
&Some(temp_dir.keep()),
false,
false,
false
Expand Down
Loading