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

feat: Sync from aztec-packages #6931

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5e4b46d577ebf63114a5a5a1c5b6d2947d3b2567
dc12c2b678e0c450c05cbd4748296e17ae73860b
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ tooling/noir_js/lib

# docs autogen build
/docs/docs/noir_js/reference/

codegen
14 changes: 9 additions & 5 deletions acvm-repo/acir/codegen/acir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ namespace Program {
struct ToRadix {
Program::MemoryAddress input;
Program::MemoryAddress radix;
Program::HeapArray output;
bool output_bits;
Program::MemoryAddress output_pointer;
Program::MemoryAddress num_limbs;
Program::MemoryAddress output_bits;

friend bool operator==(const ToRadix&, const ToRadix&);
std::vector<uint8_t> bincodeSerialize() const;
Expand Down Expand Up @@ -3898,7 +3899,8 @@ namespace Program {
inline bool operator==(const BlackBoxOp::ToRadix &lhs, const BlackBoxOp::ToRadix &rhs) {
if (!(lhs.input == rhs.input)) { return false; }
if (!(lhs.radix == rhs.radix)) { return false; }
if (!(lhs.output == rhs.output)) { return false; }
if (!(lhs.output_pointer == rhs.output_pointer)) { return false; }
if (!(lhs.num_limbs == rhs.num_limbs)) { return false; }
if (!(lhs.output_bits == rhs.output_bits)) { return false; }
return true;
}
Expand All @@ -3925,7 +3927,8 @@ template <typename Serializer>
void serde::Serializable<Program::BlackBoxOp::ToRadix>::serialize(const Program::BlackBoxOp::ToRadix &obj, Serializer &serializer) {
serde::Serializable<decltype(obj.input)>::serialize(obj.input, serializer);
serde::Serializable<decltype(obj.radix)>::serialize(obj.radix, serializer);
serde::Serializable<decltype(obj.output)>::serialize(obj.output, serializer);
serde::Serializable<decltype(obj.output_pointer)>::serialize(obj.output_pointer, serializer);
serde::Serializable<decltype(obj.num_limbs)>::serialize(obj.num_limbs, serializer);
serde::Serializable<decltype(obj.output_bits)>::serialize(obj.output_bits, serializer);
}

Expand All @@ -3935,7 +3938,8 @@ Program::BlackBoxOp::ToRadix serde::Deserializable<Program::BlackBoxOp::ToRadix>
Program::BlackBoxOp::ToRadix obj;
obj.input = serde::Deserializable<decltype(obj.input)>::deserialize(deserializer);
obj.radix = serde::Deserializable<decltype(obj.radix)>::deserialize(deserializer);
obj.output = serde::Deserializable<decltype(obj.output)>::deserialize(deserializer);
obj.output_pointer = serde::Deserializable<decltype(obj.output_pointer)>::deserialize(deserializer);
obj.num_limbs = serde::Deserializable<decltype(obj.num_limbs)>::deserialize(deserializer);
obj.output_bits = serde::Deserializable<decltype(obj.output_bits)>::deserialize(deserializer);
return obj;
}
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/node/build_info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('returns the correct build info', () => {
let revision: string;

try {
revision = child_process.execSync('git rev-parse HEAD').toString().trim();
revision = process.env.GIT_COMMIT || child_process.execSync('git rev-parse HEAD').toString().trim();
} catch (error) {
console.log('Failed to get revision, skipping test.');
return;
Expand Down
5 changes: 3 additions & 2 deletions acvm-repo/brillig/src/black_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ pub enum BlackBoxOp {
ToRadix {
input: MemoryAddress,
radix: MemoryAddress,
output: HeapArray,
output_bits: bool,
output_pointer: MemoryAddress,
num_limbs: MemoryAddress,
output_bits: MemoryAddress,
},
}
16 changes: 11 additions & 5 deletions acvm-repo/brillig_vm/src/black_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
to_u8_vec(read_heap_array(memory, key)).try_into().map_err(|_| {
BlackBoxResolutionError::Failed(bb_func, "Invalid key length".to_string())
})?;
let ciphertext = aes128_encrypt(&inputs, iv, key)?;

Check warning on line 62 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)

memory.write(outputs.size, ciphertext.len().into());

Check warning on line 64 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)
memory.write_slice(memory.read_ref(outputs.pointer), &to_value_vec(&ciphertext));

Check warning on line 65 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)

Ok(())
}
Expand Down Expand Up @@ -310,21 +310,27 @@
memory.write_slice(memory.read_ref(output.pointer), &state);
Ok(())
}
BlackBoxOp::ToRadix { input, radix, output, output_bits } => {
BlackBoxOp::ToRadix { input, radix, output_pointer, num_limbs, output_bits } => {
let input: F = *memory.read(*input).extract_field().expect("ToRadix input not a field");
let radix = memory
.read(*radix)
.expect_integer_with_bit_size(IntegerBitSize::U32)
.expect("ToRadix opcode's radix bit size does not match expected bit size 32");
let num_limbs = memory.read(*num_limbs).to_usize();
let output_bits = !memory
.read(*output_bits)
.expect_integer_with_bit_size(IntegerBitSize::U1)
.expect("ToRadix opcode's output_bits size does not match expected bit size 1")
.is_zero();

let mut input = BigUint::from_bytes_be(&input.to_be_bytes());
let radix = BigUint::from_bytes_be(&radix.to_be_bytes());

let mut limbs: Vec<MemoryValue<F>> = vec![MemoryValue::default(); output.size];
let mut limbs: Vec<MemoryValue<F>> = vec![MemoryValue::default(); num_limbs];

for i in (0..output.size).rev() {
for i in (0..num_limbs).rev() {
let limb = &input % &radix;
if *output_bits {
if output_bits {
limbs[i] = MemoryValue::new_integer(
if limb.is_zero() { 0 } else { 1 },
IntegerBitSize::U1,
Expand All @@ -336,7 +342,7 @@
input /= &radix;
}

memory.write_slice(memory.read_ref(output.pointer), &limbs);
memory.write_slice(memory.read_ref(*output_pointer), &limbs);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
},
"dependencies": {
"@aztec/bb.js": "0.66.0",
"@aztec/bb.js": "0.68.1",
"@noir-lang/noir_js": "workspace:*",
"@noir-lang/noir_wasm": "workspace:*",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,27 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
assert!(source_field.bit_size == F::max_num_bits());
assert!(radix.bit_size == 32);

let bits_register = self.make_constant_instruction(output_bits.into(), 1);
self.codegen_initialize_array(target_array);

let heap_array = self.codegen_brillig_array_to_heap_array(target_array);
let pointer = self.codegen_make_array_items_pointer(target_array);
let num_limbs = self.make_usize_constant_instruction(target_array.size.into());

// Perform big-endian ToRadix
self.black_box_op_instruction(BlackBoxOp::ToRadix {
input: source_field.address,
radix: radix.address,
output: heap_array,
output_bits,
output_pointer: pointer,
num_limbs: num_limbs.address,
output_bits: bits_register.address,
});

if little_endian {
let items_len = self.make_usize_constant_instruction(target_array.size.into());
self.codegen_array_reverse(heap_array.pointer, items_len.address);
self.codegen_array_reverse(pointer, items_len.address);
self.deallocate_single_addr(items_len);
}
self.deallocate_register(heap_array.pointer);
self.deallocate_register(pointer);
self.deallocate_single_addr(bits_register);
self.deallocate_single_addr(num_limbs);
}
}
7 changes: 4 additions & 3 deletions compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,14 @@ impl DebugShow {
output
);
}
BlackBoxOp::ToRadix { input, radix, output, output_bits: _ } => {
BlackBoxOp::ToRadix { input, radix, output_pointer, num_limbs, output_bits: _ } => {
debug_println!(
self.enable_debug_trace,
" TO_RADIX {} {} -> {}",
" TO_RADIX {} {} {} -> {}",
input,
radix,
output
num_limbs,
output_pointer
);
}
}
Expand Down
23 changes: 23 additions & 0 deletions compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl<'local, 'context> Interpreter<'local, 'context> {
"array_len" => array_len(interner, arguments, location),
"array_refcount" => Ok(Value::U32(0)),
"assert_constant" => Ok(Value::Bool(true)),
"as_field" => as_field(interner, arguments, location),
"as_slice" => as_slice(interner, arguments, location),
"ctstring_eq" => ctstring_eq(arguments, location),
"ctstring_hash" => ctstring_hash(arguments, location),
Expand Down Expand Up @@ -116,6 +117,7 @@ impl<'local, 'context> Interpreter<'local, 'context> {
"field_less_than" => field_less_than(arguments, location),
"fmtstr_as_ctstring" => fmtstr_as_ctstring(interner, arguments, location),
"fmtstr_quoted_contents" => fmtstr_quoted_contents(interner, arguments, location),
"from_field" => from_field(interner, arguments, return_type, location),
"fresh_type_variable" => fresh_type_variable(interner),
"function_def_add_attribute" => function_def_add_attribute(self, arguments, location),
"function_def_body" => function_def_body(interner, arguments, location),
Expand Down Expand Up @@ -287,6 +289,16 @@ fn array_as_str_unchecked(
Ok(Value::String(Rc::new(string)))
}

// fn as_field<T>(x: T) -> Field {}
fn as_field(
interner: &NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
) -> IResult<Value> {
let (value, value_location) = check_one_argument(arguments, location)?;
Interpreter::evaluate_cast_one_step(&Type::FieldElement, value_location, value, interner)
}

fn as_slice(
interner: &NodeInterner,
arguments: Vec<(Value, Location)>,
Expand Down Expand Up @@ -2221,6 +2233,17 @@ fn fmtstr_quoted_contents(
Ok(Value::Quoted(Rc::new(tokens)))
}

// fn from_field<T>(x: Field) -> T {}
fn from_field(
interner: &NodeInterner,
arguments: Vec<(Value, Location)>,
return_type: Type,
location: Location,
) -> IResult<Value> {
let (value, value_location) = check_one_argument(arguments, location)?;
Interpreter::evaluate_cast_one_step(&return_type, value_location, value, interner)
}

// fn fresh_type_variable() -> Type
fn fresh_type_variable(interner: &NodeInterner) -> IResult<Value> {
Ok(Value::Type(interner.next_type_variable_with_kind(Kind::Any)))
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_bb.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.66.0"
VERSION="0.68.1"

BBUP_PATH=~/.bb/bbup

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This circuit aggregates two Honk proof from `assert_statement`.
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 463;
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 459;
global HONK_IDENTIFIER: u32 = 1;
fn main(
verification_key: [Field; 128],
Expand Down
4 changes: 2 additions & 2 deletions test_programs/execution_success/verify_honk_proof/Prover.toml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This circuit aggregates a single Honk proof from `assert_statement`.
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 463;
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 459;
global HONK_IDENTIFIER: u32 = 1;
fn main(
verification_key: [Field; 128],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "verify_rollup_honk_proof"
type = "bin"
authors = [""]

[dependencies]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This circuit aggregates a single Honk proof from `assert_statement`.
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 469 + 65;
global ROLLUP_HONK_IDENTIFIER: u32 = 5;
fn main(
verification_key: [Field; 139],
// This is the proof without public inputs attached.
// This means: the size of this does not change with the number of public inputs.
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],
public_inputs: pub [Field; 1],
// This is currently not public. It is fine given that the vk is a part of the circuit definition.
// I believe we want to eventually make it public too though.
key_hash: Field,
) {
std::verify_proof_with_type(
verification_key,
proof,
public_inputs,
key_hash,
ROLLUP_HONK_IDENTIFIER,
);
}
2 changes: 1 addition & 1 deletion test_programs/gates_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
BACKEND=${BACKEND:-bb}

# These tests are incompatible with gas reporting
excluded_dirs=("workspace" "workspace_default_member" "databus" "double_verify_honk_proof" "verify_honk_proof")
excluded_dirs=("workspace" "workspace_default_member" "databus" "double_verify_honk_proof" "verify_honk_proof" "verify_honk_rollup_proof")

current_dir=$(pwd)
artifacts_path="$current_dir/acir_artifacts"
Expand Down
2 changes: 1 addition & 1 deletion test_programs/rebuild.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status, treat unset variables as an error, and print commands as they are executed
set -e

process_dir() {
set -e
local dir=$1
local current_dir=$2
local dir_name=$(basename "$dir")
Expand Down
22 changes: 21 additions & 1 deletion tooling/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME};
use noirc_driver::{
check_crate, compute_function_abi, CompileOptions, CrateId, NOIR_ARTIFACT_VERSION_STRING,
};
use noirc_frontend::hir::{Context, ParsedFiles};
use noirc_frontend::{
hir::{Context, ParsedFiles},
monomorphization::monomorphize,
};

use super::NargoConfig;
use super::{fs::write_to_file, PackageOptions};
Expand All @@ -28,6 +31,10 @@ pub(crate) struct CheckCommand {
#[clap(long = "overwrite")]
allow_overwrite: bool,

/// Show the program hash.
#[clap(long)]
show_program_hash: bool,

#[clap(flatten)]
compile_options: CompileOptions,
}
Expand All @@ -46,6 +53,19 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro
let parsed_files = parse_all(&workspace_file_manager);

for package in &workspace {
if args.show_program_hash {
let (mut context, crate_id) =
prepare_package(&workspace_file_manager, &parsed_files, package);
check_crate(&mut context, crate_id, &args.compile_options).unwrap();
let Some(main) = context.get_main_function(&crate_id) else {
continue;
};
let program = monomorphize(main, &mut context.def_interner).unwrap();
let hash = fxhash::hash64(&program);
println!("{}: {:x}", package.name, hash);
continue;
}
Comment on lines +56 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panics on any error... fun.


let any_file_written = check_package(
&workspace_file_manager,
&parsed_files,
Expand Down
13 changes: 13 additions & 0 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub(crate) struct TestCommand {
#[clap(long)]
exact: bool,

/// Print all matching test names.
#[clap(long)]
list_tests: bool,

#[clap(flatten)]
pub(super) package_options: PackageOptions,

Expand Down Expand Up @@ -171,6 +175,15 @@ impl<'a> TestRunner<'a> {
// First compile all packages and collect their tests
let packages_tests = self.collect_packages_tests()?;

if self.args.list_tests {
for (package_name, package_tests) in packages_tests {
for test in package_tests {
println!("{} {}", package_name, test.name);
}
}
return Ok(());
}

// Now gather all tests and how many are per packages
let mut tests = Vec::new();
let mut test_count_per_package = BTreeMap::new();
Expand Down
Loading
Loading