Skip to content

Commit

Permalink
Merge 4d77db2 into fed729d
Browse files Browse the repository at this point in the history
  • Loading branch information
AztecBot authored Mar 7, 2024
2 parents fed729d + 4d77db2 commit 1531ba5
Show file tree
Hide file tree
Showing 25 changed files with 499 additions and 415 deletions.
4 changes: 2 additions & 2 deletions noir/noir-repo/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/noir-lang/noir
branch = master
commit = 5f57ebb7ff4b810802f90699a10f4325ef904f2e
parent = 8307dadd853d5091841e169c841ab6b09c223efb
commit = 2a555a041dbd3e40cbf768ca131f508570f4ba50
parent = 481e46b2091080e5c9498f248a29caafc122508e
method = merge
cmdver = 0.4.6
9 changes: 0 additions & 9 deletions noir/noir-repo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions noir/noir-repo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[workspace]

members = [
# Macros crates for metaprogramming
# Aztec Macro crate for metaprogramming
"aztec_macros",
"noirc_macros",
# Compiler crates
"compiler/noirc_evaluator",
"compiler/noirc_frontend",
Expand Down
1 change: 0 additions & 1 deletion noir/noir-repo/compiler/noirc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ tracing.workspace = true
thiserror.workspace = true

aztec_macros = { path = "../../aztec_macros" }
noirc_macros = { path = "../../noirc_macros" }
10 changes: 2 additions & 8 deletions noir/noir-repo/compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,8 @@ pub fn check_crate(
deny_warnings: bool,
disable_macros: bool,
) -> CompilationResult<()> {
let macros: Vec<&dyn MacroProcessor> = if disable_macros {
vec![&noirc_macros::AssertMessageMacro as &dyn MacroProcessor]
} else {
vec![
&aztec_macros::AztecMacro as &dyn MacroProcessor,
&noirc_macros::AssertMessageMacro as &dyn MacroProcessor,
]
};
let macros: &[&dyn MacroProcessor] =
if disable_macros { &[] } else { &[&aztec_macros::AztecMacro as &dyn MacroProcessor] };

let mut errors = vec![];
let diagnostics = CrateDefMap::collect_defs(crate_id, context, macros);
Expand Down
543 changes: 312 additions & 231 deletions noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl DefCollector {
context: &mut Context,
ast: SortedModule,
root_file_id: FileId,
macro_processors: Vec<&dyn MacroProcessor>,
macro_processors: &[&dyn MacroProcessor],
) -> Vec<(CompilationError, FileId)> {
let mut errors: Vec<(CompilationError, FileId)> = vec![];
let crate_id = def_map.krate;
Expand All @@ -220,11 +220,7 @@ impl DefCollector {
let crate_graph = &context.crate_graph[crate_id];

for dep in crate_graph.dependencies.clone() {
errors.extend(CrateDefMap::collect_defs(
dep.crate_id,
context,
macro_processors.clone(),
));
errors.extend(CrateDefMap::collect_defs(dep.crate_id, context, macro_processors));

let dep_def_root =
context.def_map(&dep.crate_id).expect("ice: def map was just created").root;
Expand Down Expand Up @@ -257,7 +253,7 @@ impl DefCollector {
context.def_maps.insert(crate_id, def_collector.def_map);

// TODO(#4653): generalize this function
for macro_processor in &macro_processors {
for macro_processor in macro_processors {
macro_processor
.process_unresolved_traits_impls(
&crate_id,
Expand Down
12 changes: 3 additions & 9 deletions noir/noir-repo/compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl CrateDefMap {
pub fn collect_defs(
crate_id: CrateId,
context: &mut Context,
macro_processors: Vec<&dyn MacroProcessor>,
macro_processors: &[&dyn MacroProcessor],
) -> Vec<(CompilationError, FileId)> {
// Check if this Crate has already been compiled
// XXX: There is probably a better alternative for this.
Expand All @@ -90,7 +90,7 @@ impl CrateDefMap {
let (ast, parsing_errors) = context.parsed_file_results(root_file_id);
let mut ast = ast.into_sorted();

for macro_processor in &macro_processors {
for macro_processor in macro_processors {
match macro_processor.process_untyped_ast(ast.clone(), &crate_id, context) {
Ok(processed_ast) => {
ast = processed_ast;
Expand All @@ -115,13 +115,7 @@ impl CrateDefMap {
};

// Now we want to populate the CrateDefMap using the DefCollector
errors.extend(DefCollector::collect(
def_map,
context,
ast,
root_file_id,
macro_processors.clone(),
));
errors.extend(DefCollector::collect(def_map, context, ast, root_file_id, macro_processors));

errors.extend(
parsing_errors.iter().map(|e| (e.clone().into(), root_file_id)).collect::<Vec<_>>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1256,13 +1256,17 @@ impl<'a> Resolver<'a> {
let is_in_stdlib = self.path_resolver.module_id().krate.is_stdlib();
let assert_msg_call_path = if is_in_stdlib {
ExpressionKind::Variable(Path {
segments: vec![Ident::from("resolve_assert_message")],
segments: vec![Ident::from("internal"), Ident::from("resolve_assert_message")],
kind: PathKind::Crate,
span,
})
} else {
ExpressionKind::Variable(Path {
segments: vec![Ident::from("std"), Ident::from("resolve_assert_message")],
segments: vec![
Ident::from("std"),
Ident::from("internal"),
Ident::from("resolve_assert_message"),
],
kind: PathKind::Dep,
span,
})
Expand Down
2 changes: 1 addition & 1 deletion noir/noir-repo/compiler/noirc_frontend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod test {
&mut context,
program.clone().into_sorted(),
root_file_id,
Vec::new(), // No macro processors
&[], // No macro processors
));
}
(program, context, errors)
Expand Down
7 changes: 6 additions & 1 deletion noir/noir-repo/compiler/wasm/src/noir/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ export class Package {
handles
.filter((handle) => SOURCE_EXTENSIONS.find((ext) => handle.endsWith(ext)))
.map(async (file) => {
const suffix = file.replace(this.#srcPath, '');
// Github deps are directly added to the file manager, which causes them to be missing the absolute path to the source file
// and only include the extraction directory relative to the fm root directory
// This regexp ensures we remove the "real" source path for all dependencies, providing the compiler with what it expects for each source file:
// <absoluteSourcePath> -> <sourceAsString> for bin/contract packages
// <depAlias/relativePathToSource> -> <sourceAsString> for libs
const suffix = file.replace(new RegExp(`.*${this.#srcPath}`), '');
return {
path: this.getType() === 'lib' ? `${alias ? alias : this.#config.package.name}${suffix}` : file,
source: (await fm.readFile(file, 'utf-8')).toString(),
Expand Down
13 changes: 7 additions & 6 deletions noir/noir-repo/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# More documentation for the advisories section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
[advisories]
vulnerability = "deny"
unmaintained = "warn"
unsound = "warn"
version = 2
yanked = "warn"
notice = "warn"

ignore = [
"RUSTSEC-2020-0168", # mach unmaintained
"RUSTSEC-2020-0016" # net2 unmaintained
]

# This section is considered when running `cargo deny check bans`.
# More documentation about the 'bans' section can be found here:
Expand All @@ -32,9 +34,8 @@ skip = []
skip-tree = []

[licenses]
unlicensed = "deny"
version = 2
confidence-threshold = 0.9
# copyleft = "deny"

# List of explicitly allowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
Expand Down
12 changes: 12 additions & 0 deletions noir/noir-repo/noir_stdlib/src/internal.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file contains functions which should only be used in calls injected by the Noir compiler.
// These functions should not be called manually in user code.
//
// Changes to this file will not be considered breaking.

#[oracle(assert_message)]
unconstrained fn assert_message_oracle<T>(_input: T) {}
unconstrained pub fn resolve_assert_message<T>(input: T, condition: bool) {
if !condition {
assert_message_oracle(input);
}
}
1 change: 1 addition & 0 deletions noir/noir-repo/noir_stdlib/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod default;
mod prelude;
mod uint128;
mod bigint;
mod internal;

// Oracle calls are required to be wrapped in an unconstrained function
// Thus, the only argument to the `println` oracle is expected to always be an ident
Expand Down
14 changes: 0 additions & 14 deletions noir/noir-repo/noirc_macros/Cargo.toml

This file was deleted.

73 changes: 0 additions & 73 deletions noir/noir-repo/noirc_macros/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_4449"
type = "bin"
authors = [""]

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

x = 0xbd
result = [204, 59, 83, 197, 18, 1, 128, 43, 247, 28, 104, 225, 106, 13, 20, 187, 42, 26, 67, 150, 48, 75, 238, 168, 121, 247, 142, 160, 71, 222, 97, 188]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test for issue #4449
use dep::std;

fn main(x: u8, result: [u8; 32]) {
let x = x % 31;
let mut digest = [0; 32];
for i in 0..70 {
let y = x + i;
let a = [y, x, 32, 0, y + 1, y - 1, y - 2, 5];
digest = std::sha256::digest(a);
}

assert(digest == result);
}
2 changes: 1 addition & 1 deletion noir/noir-repo/tooling/bb_abstraction_leaks/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use const_format::formatcp;

const USERNAME: &str = "AztecProtocol";
const REPO: &str = "aztec-packages";
const VERSION: &str = "0.24.0";
const VERSION: &str = "0.26.3";
const TAG: &str = formatcp!("aztec-packages-v{}", VERSION);

const API_URL: &str =
Expand Down
2 changes: 1 addition & 1 deletion noir/noir-repo/tooling/lsp/src/requests/test_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn on_test_run_request_inner(
let test_result = run_test(
&state.solver,
&mut context,
test_function,
&test_function,
false,
None,
&CompileOptions::default(),
Expand Down
Loading

0 comments on commit 1531ba5

Please sign in to comment.