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 noir #8619

Merged
merged 10 commits into from
Sep 18, 2024
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
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5bbd9ba9a6d6494fd16813b44036b78c871f6613
78262c96d5b116c77e50653f9059da60824db812
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::protocol_types::{address::AztecAddress};
use dep::protocol_types::address::AztecAddress;

global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: u64 = 17;
global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: u32 = 17;

// Obtains membership witness (index and sibling path) for a message in the L1 to L2 message tree.
#[oracle(getL1ToL2MembershipWitness)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
};

// INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT
global NULLIFIER_MEMBERSHIP_WITNESS: Field = 24;
global NULLIFIER_MEMBERSHIP_WITNESS: u32 = 24;

struct NullifierMembershipWitness {
index: Field,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::protocol_types::{constants::PUBLIC_DATA_TREE_HEIGHT, data::PublicDataTreeLeafPreimage, utils::arr_copy_slice};

global LEAF_PREIMAGE_LENGTH: u32 = 4;
global PUBLIC_DATA_WITNESS: Field = 45;
global PUBLIC_DATA_WITNESS: u32 = 45;

struct PublicDataWitness {
index: Field,
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/Nargo.template.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"crates/types",
"crates/blob",
# "crates/blob",
"crates/parity-base",
"crates/parity-lib",
"crates/parity-root",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = [""]
compiler_version = ">=0.30.0"

[dependencies]
bigint = {tag = "v0.3.3", git = "https://github.com/noir-lang/noir-bignum" }
bigint = {tag = "v0.3.4", git = "https://github.com/noir-lang/noir-bignum" }
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/generate_variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function generateVariants(originalFolder, variantsArray) {
for ([variableName, variableValue] of Object.entries(replacements)) {
mainDotNoirCode = mainDotNoirCode.replace(
new RegExp(`^global\\s+${variableName}\\s=\\s.*;.*$`, "m"),
`global ${variableName} = ${variableValue};`
`global ${variableName}: u32 = ${variableValue};`
);
}

Expand Down
6 changes: 3 additions & 3 deletions noir/noir-repo/aztec_macros/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn signature_of_type(typ: &Type) -> String {
Type::FieldElement => "Field".to_owned(),
Type::Bool => "bool".to_owned(),
Type::Array(len, typ) => {
if let Type::Constant(len) = **len {
if let Type::Constant(len, _) = **len {
format!("[{};{len}]", signature_of_type(typ))
} else {
unimplemented!("Cannot generate signature for array with length type {:?}", typ)
Expand All @@ -90,7 +90,7 @@ pub fn signature_of_type(typ: &Type) -> String {
format!("({})", fields.join(","))
}
Type::String(len_typ) => {
if let Type::Constant(len) = **len_typ {
if let Type::Constant(len, _) = **len_typ {
format!("str<{len}>")
} else {
unimplemented!(
Expand Down Expand Up @@ -326,7 +326,7 @@ pub fn get_serialized_length(
let serialized_trait_impl = serialized_trait_impl_shared.borrow();

match serialized_trait_impl.trait_generics.first().unwrap() {
Type::Constant(value) => Ok(*value),
Type::Constant(value, _) => Ok(*value),
_ => Err(MacroError {
primary_message: format!("{} length for {} must be a constant", trait_name, typ),
secondary_message: None,
Expand Down
2 changes: 1 addition & 1 deletion noir/noir-repo/compiler/noirc_driver/src/abi_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(super) fn abi_type_from_hir_type(context: &Context, typ: &Type) -> AbiType {
}
Type::Error
| Type::Unit
| Type::Constant(_)
| Type::Constant(..)
| Type::InfixExpr(..)
| Type::TraitAsType(..)
| Type::TypeVariable(_, _)
Expand Down
11 changes: 1 addition & 10 deletions noir/noir-repo/compiler/noirc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,11 @@ pub use reporter::{CustomDiagnostic, DiagnosticKind};
pub struct FileDiagnostic {
pub file_id: fm::FileId,
pub diagnostic: CustomDiagnostic,

/// An optional call stack to display the full runtime call stack
/// leading up to a runtime error. If this is empty it will not be displayed.
pub call_stack: Vec<Location>,
}

impl FileDiagnostic {
pub fn new(file_id: fm::FileId, diagnostic: CustomDiagnostic) -> FileDiagnostic {
FileDiagnostic { file_id, diagnostic, call_stack: Vec::new() }
}

pub fn with_call_stack(mut self, call_stack: Vec<Location>) -> Self {
self.call_stack = call_stack;
self
FileDiagnostic { file_id, diagnostic }
}
}

Expand Down
17 changes: 14 additions & 3 deletions noir/noir-repo/compiler/noirc_errors/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pub struct CustomDiagnostic {
pub kind: DiagnosticKind,
pub deprecated: bool,
pub unnecessary: bool,

/// An optional call stack to display the full runtime call stack
/// leading up to a runtime error. If this is empty it will not be displayed.
pub call_stack: Vec<Location>,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
Expand All @@ -39,6 +43,7 @@ impl CustomDiagnostic {
kind: DiagnosticKind::Error,
deprecated: false,
unnecessary: false,
call_stack: Default::default(),
}
}

Expand All @@ -55,6 +60,7 @@ impl CustomDiagnostic {
kind,
deprecated: false,
unnecessary: false,
call_stack: Default::default(),
}
}

Expand Down Expand Up @@ -109,13 +115,19 @@ impl CustomDiagnostic {
kind: DiagnosticKind::Bug,
deprecated: false,
unnecessary: false,
call_stack: Default::default(),
}
}

pub fn in_file(self, file_id: fm::FileId) -> FileDiagnostic {
FileDiagnostic::new(file_id, self)
}

pub fn with_call_stack(mut self, call_stack: Vec<Location>) -> Self {
self.call_stack = call_stack;
self
}

pub fn add_note(&mut self, message: String) {
self.notes.push(message);
}
Expand Down Expand Up @@ -204,7 +216,7 @@ impl FileDiagnostic {
files: &'files impl Files<'files, FileId = fm::FileId>,
deny_warnings: bool,
) -> bool {
report(files, &self.diagnostic, Some(self.file_id), &self.call_stack, deny_warnings)
report(files, &self.diagnostic, Some(self.file_id), deny_warnings)
}
}

Expand All @@ -213,15 +225,14 @@ pub fn report<'files>(
files: &'files impl Files<'files, FileId = fm::FileId>,
custom_diagnostic: &CustomDiagnostic,
file: Option<fm::FileId>,
call_stack: &[Location],
deny_warnings: bool,
) -> bool {
let color_choice =
if std::io::stderr().is_terminal() { ColorChoice::Auto } else { ColorChoice::Never };
let writer = StandardStream::stderr(color_choice);
let config = codespan_reporting::term::Config::default();

let stack_trace = stack_trace(files, call_stack);
let stack_trace = stack_trace(files, &custom_diagnostic.call_stack);
let diagnostic = convert_diagnostic(custom_diagnostic, file, stack_trace, deny_warnings);
term::emit(&mut writer.lock(), &config, files, &diagnostic).unwrap();

Expand Down
6 changes: 3 additions & 3 deletions noir/noir-repo/compiler/noirc_evaluator/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl From<SsaReport> for FileDiagnostic {
let location = call_stack.last().expect("Expected RuntimeError to have a location");
let diagnostic =
Diagnostic::simple_warning(message, secondary_message, location.span);
diagnostic.in_file(file_id).with_call_stack(call_stack)
diagnostic.with_call_stack(call_stack).in_file(file_id)
}
SsaReport::Bug(bug) => {
let message = bug.to_string();
Expand All @@ -101,7 +101,7 @@ impl From<SsaReport> for FileDiagnostic {
let file_id = call_stack.last().map(|location| location.file).unwrap_or_default();
let location = call_stack.last().expect("Expected RuntimeError to have a location");
let diagnostic = Diagnostic::simple_bug(message, secondary_message, location.span);
diagnostic.in_file(file_id).with_call_stack(call_stack)
diagnostic.with_call_stack(call_stack).in_file(file_id)
}
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl From<RuntimeError> for FileDiagnostic {
let call_stack = vecmap(error.call_stack(), |location| *location);
let file_id = call_stack.last().map(|location| location.file).unwrap_or_default();
let diagnostic = error.into_diagnostic();
diagnostic.in_file(file_id).with_call_stack(call_stack)
diagnostic.with_call_stack(call_stack).in_file(file_id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ impl<'f> FunctionInserter<'f> {
self.function.dfg[block].set_terminator(terminator);
}

/// Maps the data bus in place, replacing any ValueId in the data bus with the
/// resolved version of that value id from this FunctionInserter's internal value mapping.
pub(crate) fn map_data_bus_in_place(&mut self) {
let data_bus = self.function.dfg.data_bus.clone();
let data_bus = data_bus.map_values(|value| self.resolve(value));
self.function.dfg.data_bus = data_bus;
}

/// Push a new instruction to the given block and return its new InstructionId.
/// If the instruction was simplified out of the program, None is returned.
pub(crate) fn push_instruction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ impl<'f> Context<'f> {
}
}
}
self.inserter.map_data_bus_in_place();
}

/// Returns the updated condition so that
Expand Down
Loading
Loading