Skip to content

Commit

Permalink
feat: Sync from aztec-packages (#5877)
Browse files Browse the repository at this point in the history
Automated pull of Noir development from
[aztec-packages](https://github.com/AztecProtocol/aztec-packages).
BEGIN_COMMIT_OVERRIDE
feat: Sync from noir
(AztecProtocol/aztec-packages#8237)
fix: Export brillig names in contract functions
(AztecProtocol/aztec-packages#8212)
feat: Sync from noir
(AztecProtocol/aztec-packages#8125)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <[email protected]>
  • Loading branch information
AztecBot and TomAFrench authored Sep 1, 2024
1 parent e29d4b3 commit f0c2686
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57f3c9bdc99103862a165bc235efdc8ef01b4e92
cf5b667c9566019853a5dc2a7f16ed024ab9182b
4 changes: 2 additions & 2 deletions acvm-repo/brillig/src/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub enum ValueOrArray {
pub enum BrilligOpcode<F> {
/// Takes the fields in addresses `lhs` and `rhs`
/// Performs the specified binary operation
/// and stores the value in the `result` address.
/// and stores the value in the `result` address.
BinaryFieldOp {
destination: MemoryAddress,
op: BinaryFieldOp,
Expand All @@ -180,7 +180,7 @@ pub enum BrilligOpcode<F> {
},
/// Takes the `bit_size` size integers in addresses `lhs` and `rhs`
/// Performs the specified binary operation
/// and stores the value in the `result` address.
/// and stores the value in the `result` address.
BinaryIntOp {
destination: MemoryAddress,
op: BinaryIntOp,
Expand Down
3 changes: 3 additions & 0 deletions compiler/noirc_driver/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ pub struct ContractFunction {

/// Names of the functions in the program. These are used for more informative debugging and benchmarking.
pub names: Vec<String>,

/// Names of the unconstrained functions in the program.
pub brillig_names: Vec<String>,
}
1 change: 1 addition & 0 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ fn compile_contract_inner(
debug: function.debug,
is_unconstrained: modifiers.is_unconstrained,
names: function.names,
brillig_names: function.brillig_names,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "sha256_var_witness_const_regression"
type = "bin"
authors = [""]
compiler_version = ">=0.33.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
input = [0, 0]
toggle = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main(input: [u8; 2], toggle: bool) {
let size: Field = 1 + toggle as Field;
assert(!toggle);

let variable_sha = std::sha256::sha256_var(input, size as u64);
let constant_sha = std::sha256::sha256_var(input, 1);

assert_eq(variable_sha, constant_sha);
}
46 changes: 23 additions & 23 deletions tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,30 @@ fn compile_programs(
.map(|p| p.into())
};

let program_results: Vec<CompilationResult<()>> = binary_packages
.par_iter()
.map(|package| {
let (program, warnings) = compile_program(
file_manager,
parsed_files,
workspace,
package,
compile_options,
load_cached_program(package),
)?;

let target_width =
get_target_width(package.expression_width, compile_options.expression_width);
let program = nargo::ops::transform_program(program, target_width);
let compile_package = |package| {
let (program, warnings) = compile_program(
file_manager,
parsed_files,
workspace,
package,
compile_options,
load_cached_program(package),
)?;

let target_width =
get_target_width(package.expression_width, compile_options.expression_width);
let program = nargo::ops::transform_program(program, target_width);

save_program_to_file(&program.into(), &package.name, workspace.target_directory_path());

Ok(((), warnings))
};

save_program_to_file(
&program.clone().into(),
&package.name,
workspace.target_directory_path(),
);
Ok(((), warnings))
})
.collect();
// Configure a thread pool with a larger stack size to prevent overflowing stack in large programs.
// Default is 2MB.
let pool = rayon::ThreadPoolBuilder::new().stack_size(4 * 1024 * 1024).build().unwrap();
let program_results: Vec<CompilationResult<()>> =
pool.install(|| binary_packages.par_iter().map(compile_package).collect());

// Collate any warnings/errors which were encountered during compilation.
collect_errors(program_results).map(|(_, warnings)| ((), warnings))
Expand Down
39 changes: 22 additions & 17 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,28 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError
None => FunctionNameMatch::Anything,
};

let test_reports: Vec<Vec<(String, TestStatus)>> = workspace
.into_iter()
.par_bridge()
.map(|package| {
run_tests::<Bn254BlackBoxSolver>(
&workspace_file_manager,
&parsed_files,
package,
pattern,
args.show_output,
args.oracle_resolver.as_deref(),
Some(workspace.root_dir.clone()),
Some(package.name.to_string()),
&args.compile_options,
)
})
.collect::<Result<_, _>>()?;
// Configure a thread pool with a larger stack size to prevent overflowing stack in large programs.
// Default is 2MB.
let pool = rayon::ThreadPoolBuilder::new().stack_size(4 * 1024 * 1024).build().unwrap();
let test_reports: Vec<Vec<(String, TestStatus)>> = pool.install(|| {
workspace
.into_iter()
.par_bridge()
.map(|package| {
run_tests::<Bn254BlackBoxSolver>(
&workspace_file_manager,
&parsed_files,
package,
pattern,
args.show_output,
args.oracle_resolver.as_deref(),
Some(workspace.root_dir.clone()),
Some(package.name.to_string()),
&args.compile_options,
)
})
.collect::<Result<_, _>>()
})?;
let test_report: Vec<(String, TestStatus)> = test_reports.into_iter().flatten().collect();

if test_report.is_empty() {
Expand Down
3 changes: 3 additions & 0 deletions tooling/noirc_artifacts/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct ContractFunctionArtifact {
deserialize_with = "ProgramDebugInfo::deserialize_compressed_base64_json"
)]
pub debug_symbols: ProgramDebugInfo,

pub brillig_names: Vec<String>,
}

impl From<ContractFunction> for ContractFunctionArtifact {
Expand All @@ -82,6 +84,7 @@ impl From<ContractFunction> for ContractFunctionArtifact {
custom_attributes: func.custom_attributes,
abi: func.abi,
bytecode: func.bytecode,
brillig_names: func.brillig_names,
debug_symbols: ProgramDebugInfo { debug_infos: func.debug },
}
}
Expand Down

0 comments on commit f0c2686

Please sign in to comment.