From bebf5b561e0ea258200d5029120a0fffa8c31e05 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Wed, 7 Feb 2024 20:09:59 +0000 Subject: [PATCH 01/33] add initial work for inserting an aztec prelude and remove imports from noir-contracts --- noir/aztec_macros/src/lib.rs | 199 +++++++++++++++--- .../src/hir/def_collector/dc_crate.rs | 16 +- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- noir/compiler/noirc_frontend/src/hir/mod.rs | 4 + noir/compiler/noirc_frontend/src/lib.rs | 16 +- .../assert_statement/src/main.nr | 2 +- .../slow-updates-tree/src/slow_map.nr | 5 +- yarn-project/aztec-nr/value-note/src/utils.nr | 4 +- .../contracts/avm_test_contract/src/main.nr | 6 - .../benchmarking_contract/src/main.nr | 13 +- .../contracts/card_game_contract/src/cards.nr | 16 -- .../contracts/card_game_contract/src/game.nr | 4 - .../contracts/card_game_contract/src/main.nr | 25 --- .../contracts/child_contract/src/main.nr | 11 - .../src/main.nr | 10 +- .../contracts/counter_contract/src/main.nr | 18 +- .../docs_example_contract/src/main.nr | 36 ++-- .../easy_private_token_contract/src/main.nr | 9 - .../easy_private_voting_contract/src/main.nr | 16 +- .../ecdsa_account_contract/src/main.nr | 22 +- .../contracts/escrow_contract/src/main.nr | 28 +-- .../import_test_contract/src/main.nr | 2 +- .../inclusion_proofs_contract/src/main.nr | 53 +---- .../contracts/lending_contract/src/asset.nr | 5 - .../contracts/lending_contract/src/helpers.nr | 1 - .../lending_contract/src/interfaces.nr | 10 - .../contracts/lending_contract/src/main.nr | 11 - .../contracts/parent_contract/src/main.nr | 5 - .../pending_commitments_contract/src/main.nr | 10 - .../contracts/price_feed_contract/src/main.nr | 8 - .../contracts/reader_contract/src/main.nr | 5 - .../schnorr_account_contract/src/main.nr | 8 - .../src/public_key_note.nr | 18 -- .../src/main.nr | 4 - .../src/auth_oracle.nr | 4 - .../src/main.nr | 1 - .../src/util.nr | 1 - .../contracts/slow_tree_contract/src/main.nr | 13 -- .../stateful_test_contract/src/main.nr | 14 +- .../contracts/test_contract/src/interface.nr | 6 - .../contracts/test_contract/src/main.nr | 46 +--- .../src/interfaces.nr | 7 - .../token_blacklist_contract/src/main.nr | 28 +-- .../src/types/balances_map.nr | 19 -- .../src/types/token_note.nr | 22 -- .../src/types/transparent_note.nr | 10 - .../token_bridge_contract/src/main.nr | 14 -- .../src/token_interface.nr | 11 - .../contracts/token_contract/src/main.nr | 15 -- .../token_contract/src/types/balances_map.nr | 19 -- .../token_contract/src/types/token_note.nr | 20 -- .../src/types/transparent_note.nr | 10 - .../token_portal_content_hash_lib/src/lib.nr | 7 - .../uniswap_contract/src/interfaces.nr | 11 - .../contracts/uniswap_contract/src/main.nr | 13 -- .../contracts/uniswap_contract/src/util.nr | 7 - 56 files changed, 283 insertions(+), 617 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 138bcafb1d6..689a3a3f856 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -2,19 +2,21 @@ use std::borrow::{Borrow, BorrowMut}; use std::vec; use iter_extended::vecmap; +use noirc_frontend::macros_api::parse_program; +use noirc_frontend::macros_api::HirImportDirective; use noirc_frontend::macros_api::FieldElement; use noirc_frontend::macros_api::{ BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionDefinition, FunctionReturnType, FunctionVisibility, - HirContext, HirExpression, HirLiteral, HirStatement, Ident, ImportStatement, IndexExpression, + HirContext, HirExpression, HirLiteral, HirStatement, Ident, IndexExpression, LetStatement, Literal, MemberAccessExpression, MethodCallExpression, NoirFunction, NoirStruct, - Param, Path, PathKind, Pattern, PrefixExpression, SecondaryAttribute, Signedness, Span, + Param, Path, Pattern, PrefixExpression, SecondaryAttribute, Signedness, Span, Statement, StatementKind, StructType, Type, TypeImpl, UnaryOp, UnresolvedType, UnresolvedTypeData, Visibility, }; use noirc_frontend::macros_api::{CrateId, FileId}; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; -use noirc_frontend::macros_api::{ModuleDefId, NodeInterner, SortedModule, StructId}; +use noirc_frontend::macros_api::{LocalModuleId, ModuleDefId, NodeInterner, SortedModule, StructId}; use noirc_frontend::node_interner::{TraitId, TraitImplKind}; use noirc_frontend::Lambda; @@ -30,6 +32,31 @@ impl MacroProcessor for AztecMacro { transform(ast, crate_id, context) } + fn process_crate_prelude( + &self, + crate_id: &CrateId, + context: &HirContext, + collected_imports: &mut Vec, + submodules: &[LocalModuleId], + ) -> Result<(), (MacroError, FileId)> { + if !has_aztec_dependency(crate_id, context) { + return Ok(()); + } + let def_map = context.def_map(crate_id).expect("Should have a def map"); + + let crate_root = def_map.root(); + inject_aztec_prelude(*crate_id, crate_root, collected_imports); + for submodule in submodules.iter() { + inject_aztec_prelude( + *crate_id, + *submodule, + collected_imports, + ); + } + + Ok(()) + } + fn process_typed_ast( &self, crate_id: &CrateId, @@ -215,19 +242,6 @@ macro_rules! chained_path { } } -macro_rules! chained_dep { - ( $base:expr $(, $tail:expr)* ) => { - { - let mut base_path = ident_path($base); - base_path.kind = PathKind::Dep; - $( - base_path.segments.push(ident($tail)); - )* - base_path - } - } -} - fn cast(lhs: Expression, ty: UnresolvedTypeData) -> Expression { expression(ExpressionKind::Cast(Box::new(CastExpression { lhs, r#type: make_type(ty) }))) } @@ -250,10 +264,6 @@ fn index_array_variable(array: Expression, index: &str) -> Expression { }))) } -fn import(path: Path) -> ImportStatement { - ImportStatement { path, alias: None } -} - // // Create AST Nodes for Aztec // @@ -273,7 +283,6 @@ fn transform( .map_err(|(err, file_id)| (err.into(), file_id))? { check_for_aztec_dependency(crate_id, context)?; - include_relevant_imports(&mut submodule.contents); } } Ok(ast) @@ -292,19 +301,129 @@ fn transform_hir( assign_storage_slots(crate_id, context) } -/// Includes an import to the aztec library if it has not been included yet -fn include_relevant_imports(ast: &mut SortedModule) { - // Create the aztec import path using the assumed chained_dep! macro - let aztec_import_path = import(chained_dep!("aztec")); +fn inject_aztec_prelude( + crate_id: CrateId, + crate_root: LocalModuleId, + collected_imports: &mut Vec, +) { + let (imports_ast, errors) = parse_program(aztec_prelude_source()); + if !errors.is_empty() { + dbg!(errors.clone()); + } + assert_eq!(errors.len(), 0, "Failed to parse Noir macro code. This is either a bug in the compiler or the Noir macro code"); + + let imports_ast = imports_ast.into_sorted(); + + if !crate_id.is_stdlib() { + for import in imports_ast.imports { + collected_imports.insert( + 0, + HirImportDirective { + module_id: crate_root, + path: import.path, + alias: import.alias, + is_prelude: true, + }, + ); + } + } +} - // Check if the aztec import already exists - let is_aztec_imported = - ast.imports.iter().any(|existing_import| existing_import.path == aztec_import_path.path); +fn aztec_prelude_source() -> &'static str { + let aztec_imports = " + use dep::aztec; - // If aztec is not imported, add the import at the beginning - if !is_aztec_imported { - ast.imports.insert(0, aztec_import_path); - } + use dep::aztec::{ + protocol_types::{ + abis::function_selector::FunctionSelector, + address::{ + AztecAddress, + EthAddress, + PartialAddress, + PublicKeysHash, + }, + contract_class::ContractClassId, + constants::{ + MAX_NOTES_PER_PAGE, + MAX_READ_REQUESTS_PER_CALL, + ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, + FUNCTION_TREE_HEIGHT, + MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, + REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, + RETURN_VALUES_LENGTH, + }, + grumpkin_point::GrumpkinPoint, + hash::sha256_to_field, + traits::{Serialize, Deserialize}, + }, + context::{PrivateContext, PublicContext, Context}, + abi, + abi::{ + CallContext, Hasher, PrivateContextInputs, + }, + note::{ + utils as note_utils, + lifecycle::{create_note, destroy_note}, + utils::compute_note_hash_for_consumption, + note_getter_options::NoteGetterOptions, + note_getter_options::NoteStatus, + note_viewer_options::NoteViewerOptions, + note_getter::{get_notes, view_notes}, + note_header::NoteHeader, + note_interface::NoteInterface, + }, + oracle::{ + nullifier_key::get_nullifier_secret_key, + get_public_key::get_public_key, + context::get_portal_address, + rand::rand, + }, + log::{ + emit_unencrypted_log, + emit_unencrypted_log_from_private, + emit_encrypted_log, + }, + hash::{ + pedersen_hash, + compute_secret_hash, + }, + state_vars::{ + map::Map, + public_state::PublicState, + singleton::Singleton, + immutable_singleton::ImmutableSingleton, + set::Set, + stable_public_state::StablePublicState, + }, + history::{ + contract_inclusion::{ + prove_contract_inclusion, + prove_contract_inclusion_at, + }, + note_inclusion::{ + prove_note_inclusion, + prove_note_inclusion_at, + }, + note_validity::{ + prove_note_validity, + prove_note_validity_at, + }, + nullifier_inclusion::{ + prove_nullifier_inclusion, + prove_nullifier_inclusion_at, + }, + nullifier_non_inclusion::{ + prove_note_not_nullified, + prove_note_not_nullified_at, + }, + public_value_inclusion::{ + prove_public_value_inclusion, + prove_public_value_inclusion_at, + }, + }, + }; + "; + aztec_imports } /// Creates an error alerting the user that they have not downloaded the Aztec-noir library @@ -312,12 +431,24 @@ fn check_for_aztec_dependency( crate_id: &CrateId, context: &HirContext, ) -> Result<(), (MacroError, FileId)> { + if has_aztec_dependency(crate_id, context) { + Ok(()) + } else { + let crate_graph = &context.crate_graph[crate_id]; + Err((AztecMacroError::AztecDepNotFound.into(), crate_graph.root_file_id)) + } +} + +fn has_aztec_dependency( + crate_id: &CrateId, + context: &HirContext, +) -> bool { let crate_graph = &context.crate_graph[crate_id]; let has_aztec_dependency = crate_graph.dependencies.iter().any(|dep| dep.as_name() == "aztec"); if has_aztec_dependency { - Ok(()) + true } else { - Err((AztecMacroError::AztecDepNotFound.into(), crate_graph.root_file_id)) + false } } diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index f7441750fc8..a1182afe8a1 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -252,20 +252,28 @@ impl DefCollector { context, )); - let submodules = vecmap(def_collector.def_map.modules().iter(), |(index, _)| index); + let submodules = vecmap(def_collector.def_map.modules().iter(), |(index, _)| LocalModuleId(index)); // Add the current crate to the collection of DefMaps context.def_maps.insert(crate_id, def_collector.def_map); inject_prelude(crate_id, context, crate_root, &mut def_collector.collected_imports); - for submodule in submodules { + for submodule in submodules.iter() { inject_prelude( crate_id, context, - LocalModuleId(submodule), + *submodule, &mut def_collector.collected_imports, ); } + for macro_processor in macro_processors.clone() { + macro_processor.process_crate_prelude(&crate_id, context, &mut def_collector.collected_imports, &submodules).unwrap_or_else( + |(macro_err, file_id)| { + errors.push((macro_err.into(), file_id)); + }, + ); + } + // Resolve unresolved imports collected from the crate, one by one. for collected_import in def_collector.collected_imports { match resolve_import(crate_id, collected_import, &context.def_maps) { @@ -405,7 +413,7 @@ fn inject_prelude( let prelude = context.module(module_id).scope().names(); for path in prelude { - let mut segments = segments.clone(); + let mut segments: Vec = segments.clone(); segments.push(Ident::new(path.to_string(), Span::default())); collected_imports.insert( diff --git a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs index 8c985e88e0b..6ab1e8c77f3 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -84,7 +84,7 @@ impl CrateDefMap { if context.def_map(&crate_id).is_some() { return errors; } - + // First parse the root file. let root_file_id = context.crate_graph[crate_id].root_file_id; let (ast, parsing_errors) = context.parsed_file_results(root_file_id); diff --git a/noir/compiler/noirc_frontend/src/hir/mod.rs b/noir/compiler/noirc_frontend/src/hir/mod.rs index 2124b5281f4..b500610c41e 100644 --- a/noir/compiler/noirc_frontend/src/hir/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/mod.rs @@ -86,6 +86,10 @@ impl Context<'_, '_> { self.def_maps.get(crate_id) } + pub fn def_maps(&self) -> &BTreeMap { + &self.def_maps + } + /// Return the CrateId for each crate that has been compiled /// successfully pub fn crates(&self) -> impl Iterator + '_ { diff --git a/noir/compiler/noirc_frontend/src/lib.rs b/noir/compiler/noirc_frontend/src/lib.rs index b6d4c568334..27ae14e4059 100644 --- a/noir/compiler/noirc_frontend/src/lib.rs +++ b/noir/compiler/noirc_frontend/src/lib.rs @@ -48,10 +48,13 @@ pub mod macros_api { pub use crate::hir_def::expr::{HirExpression, HirLiteral}; pub use crate::hir_def::stmt::HirStatement; pub use crate::node_interner::{NodeInterner, StructId}; - pub use crate::parser::SortedModule; + pub use crate::parser::{parse_program, SortedModule}; pub use crate::token::SecondaryAttribute; - pub use crate::hir::def_map::ModuleDefId; + pub use crate::hir::def_collector::dc_crate::DefCollector as HirDefCollector; + pub use crate::hir::resolution::import::ImportDirective as HirImportDirective; + pub use crate::hir::resolution::path_resolver; + pub use crate::hir::def_map::{LocalModuleId, ModuleId, ModuleDefId}; pub use crate::{ hir::Context as HirContext, BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, FunctionReturnType, Ident, IndexExpression, LetStatement, @@ -73,6 +76,15 @@ pub mod macros_api { crate_id: &CrateId, context: &HirContext, ) -> Result; + /// Function to manipulate the crate definition before type checking has been completed. + /// This is needed to process module declarations as the original AST will not yet have them. + fn process_crate_prelude( + &self, + crate_id: &CrateId, + context: &HirContext, + def_collector: &mut Vec, + submodules: &[LocalModuleId], + ) -> Result<(), (MacroError, FileId)>; /// Function to manipulate the AST after type checking has been completed. /// The AST after type checking has been done is called the HIR. fn process_typed_ast( diff --git a/noir/test_programs/execution_success/assert_statement/src/main.nr b/noir/test_programs/execution_success/assert_statement/src/main.nr index 2646a0b85c2..01e1353253d 100644 --- a/noir/test_programs/execution_success/assert_statement/src/main.nr +++ b/noir/test_programs/execution_success/assert_statement/src/main.nr @@ -1,7 +1,7 @@ // Tests a very simple program. // // The features being tested is assertion -fn main(x: Field, y: pub Field) { +fn main(x: Field, y: pub Field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); } diff --git a/yarn-project/aztec-nr/slow-updates-tree/src/slow_map.nr b/yarn-project/aztec-nr/slow-updates-tree/src/slow_map.nr index 065ab009197..4a93fb734a0 100644 --- a/yarn-project/aztec-nr/slow-updates-tree/src/slow_map.nr +++ b/yarn-project/aztec-nr/slow-updates-tree/src/slow_map.nr @@ -1,7 +1,6 @@ use dep::aztec::context::{PrivateContext, PublicContext, Context}; use dep::aztec::oracle::storage::{storage_read, storage_write}; use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; -use dep::std::hash::pedersen_hash; use dep::std::merkle::compute_merkle_root; use dep::std::option::Option; @@ -141,7 +140,7 @@ impl SlowMap { // docs:start:read_leaf_at pub fn read_leaf_at(self: Self, key: Field) -> Leaf { - let derived_storage_slot = pedersen_hash([self.storage_slot, key]); + let derived_storage_slot = dep::std::hash::pedersen_hash([self.storage_slot, key]); let fields = storage_read(derived_storage_slot); Leaf::deserialize(fields) } @@ -247,7 +246,7 @@ impl SlowMap { // Updates the value in the in storage with no checks. fn update_unsafe(self: Self, index: Field, leaf: Leaf, root: Leaf) { - let derived_storage_slot = pedersen_hash([self.storage_slot, index]); + let derived_storage_slot = dep::std::hash::pedersen_hash([self.storage_slot, index]); let fields = leaf.serialize(); storage_write(derived_storage_slot, fields); diff --git a/yarn-project/aztec-nr/value-note/src/utils.nr b/yarn-project/aztec-nr/value-note/src/utils.nr index d7ef7c948dc..d1ded533297 100644 --- a/yarn-project/aztec-nr/value-note/src/utils.nr +++ b/yarn-project/aztec-nr/value-note/src/utils.nr @@ -47,7 +47,7 @@ pub fn decrement_by_at_most(balance: Set, max_amount: Field, owner: A let mut decremented = 0; for i in 0..opt_notes.len() { if opt_notes[i].is_some() { - decremented += destroy_note(balance, owner, opt_notes[i].unwrap_unchecked()); + decremented += destroy_value_note(balance, owner, opt_notes[i].unwrap_unchecked()); } } @@ -64,7 +64,7 @@ pub fn decrement_by_at_most(balance: Set, max_amount: Field, owner: A // Removes the note from the owner's set of notes. // Returns the value of the destroyed note. -pub fn destroy_note(balance: Set, owner: AztecAddress, note: ValueNote) -> Field { +fn destroy_value_note(balance: Set, owner: AztecAddress, note: ValueNote) -> Field { // Ensure the note is actually owned by the owner (to prevent user from generating a valid proof while // spending someone else's notes). assert(note.owner.eq(owner)); diff --git a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr index 405432acb7c..296c34cf50f 100644 --- a/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -1,12 +1,6 @@ // contract AvmTest { - // Libs - use dep::aztec::protocol_types::address::{ - AztecAddress, - EthAddress, - }; - // avm lib use dep::aztec::avm::context::AvmContext; diff --git a/yarn-project/noir-contracts/contracts/benchmarking_contract/src/main.nr b/yarn-project/noir-contracts/contracts/benchmarking_contract/src/main.nr index ce43fb06dee..a32497b4833 100644 --- a/yarn-project/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -10,17 +10,6 @@ contract Benchmarking { value_note::{VALUE_NOTE_LEN, ValueNote}, }; - use dep::aztec::{ - protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }, - context::{Context}, - note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, - log::emit_unencrypted_log, - state_vars::{map::Map, public_state::PublicState, set::Set}, - }; - struct Storage { notes: Map>, balances: Map>, @@ -31,7 +20,7 @@ contract Benchmarking { // Creates a new value note for the target owner. Use this method to seed an initial set of notes. #[aztec(private)] - fn create_note(owner: AztecAddress, value: Field) { + fn create_new_note(owner: AztecAddress, value: Field) { increment(storage.notes.at(owner), value, owner); } diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr index 9569a41b774..1e2592b37dc 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -1,19 +1,3 @@ -use dep::aztec::{ - protocol_types::{ - address::AztecAddress, - constants::{ - MAX_NOTES_PER_PAGE, - MAX_READ_REQUESTS_PER_CALL, - }, - }, - context::{PrivateContext, PublicContext, Context}, - note::{ - note_getter_options::NoteGetterOptions, - note_viewer_options::NoteViewerOptions, - note_getter::view_notes, - }, - state_vars::set::Set, -}; use dep::std; use dep::std::{ option::Option, diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/game.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/game.nr index 4e9c75a77f7..364d619a298 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/game.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/game.nr @@ -1,7 +1,3 @@ -use dep::aztec::protocol_types::{ - address::AztecAddress, - traits::{Serialize, Deserialize}, -}; use crate::cards::Card; global NUMBER_OF_PLAYERS = 2; diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr index 46461faf1fb..54b5261888c 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr @@ -2,20 +2,6 @@ mod cards; mod game; contract CardGame { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - constants::MAX_NOTES_PER_PAGE, - }; - use dep::aztec::{ - context::Context, - hash::pedersen_hash, - state_vars::{ - map::Map, - public_state::PublicState, - }, - }; - use dep::std::option::Option; use dep::value_note::{ balance_utils, @@ -25,17 +11,6 @@ contract CardGame { }, }; - use dep::aztec::{ - abi, - abi::{ - Hasher, PrivateContextInputs, - }, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - }; - use crate::cards::{ PACK_CARDS, Deck, diff --git a/yarn-project/noir-contracts/contracts/child_contract/src/main.nr b/yarn-project/noir-contracts/contracts/child_contract/src/main.nr index 1298819f326..e0b02180998 100644 --- a/yarn-project/noir-contracts/contracts/child_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/child_contract/src/main.nr @@ -2,17 +2,6 @@ contract Child { use dep::std::option::Option; - use dep::aztec::{ - abi::CallContext, - context::{PrivateContext, PublicContext, Context}, - log::emit_unencrypted_log, - state_vars::public_state::PublicState, - }; - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; - struct Storage { current_value: PublicState, } diff --git a/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 050a5a5ccd9..3867d7d6332 100644 --- a/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -2,15 +2,7 @@ mod events; contract ContractClassRegisterer { use dep::std::option::Option; - use dep::aztec::protocol_types::{ - address::{ AztecAddress, EthAddress }, - contract_class::ContractClassId, - constants::{ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE}, - traits::{Serialize} - }; - - use dep::aztec::log::{ emit_unencrypted_log, emit_unencrypted_log_from_private}; - + use crate::events::{ class_registered::ContractClassRegistered, private_function_broadcasted::{ClassPrivateFunctionBroadcasted, PrivateFunction}, diff --git a/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr b/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr index 3d3e85cfd95..c62fc53f855 100644 --- a/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr @@ -1,14 +1,14 @@ contract Counter { // docs:start:imports - use dep::aztec::protocol_types::address::AztecAddress; - use dep::aztec::{ - context::{PrivateContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - state_vars::map::Map, - }; + // use dep::aztec::protocol_types::address::AztecAddress; + // use dep::aztec::{ + // context::{PrivateContext, Context}, + // note::{ + // note_header::NoteHeader, + // utils as note_utils, + // }, + // state_vars::map::Map, + // }; use dep::value_note::{ balance_utils, value_note::{ diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr index 7182013b426..bb7d28dbc37 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -13,20 +13,20 @@ mod types; contract DocsExample { // how to import dependencies defined in your workspace - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; - use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_getter_options::{NoteGetterOptions, Comparator}, - note_viewer_options::{NoteViewerOptions}, - utils as note_utils, - }, - context::{PrivateContext, PublicContext, Context}, - state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton, set::Set, stable_public_state::StablePublicState}, - }; + // use dep::aztec::protocol_types::{ + // abis::function_selector::FunctionSelector, + // address::AztecAddress, + // }; + // use dep::aztec::{ + // note::{ + // note_header::NoteHeader, + // note_getter_options::{NoteGetterOptions, Comparator}, + // note_viewer_options::{NoteViewerOptions}, + // utils as note_utils, + // }, + // context::{PrivateContext, PublicContext, Context}, + // state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton, set::Set, stable_public_state::StablePublicState}, + // }; // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; use crate::types::{ @@ -244,10 +244,10 @@ contract DocsExample { } /// Macro equivalence section - use dep::aztec::abi; - use dep::aztec::abi::Hasher; - use dep::aztec::abi::PrivateContextInputs; - use dep::aztec::abi::PrivateCircuitPublicInputs; + // use dep::aztec::abi; + // use dep::aztec::abi::Hasher; + // use dep::aztec::abi::PrivateContextInputs; + // use dep::aztec::abi::PrivateCircuitPublicInputs; // docs:start:simple_macro_example #[aztec(private)] diff --git a/yarn-project/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/yarn-project/noir-contracts/contracts/easy_private_token_contract/src/main.nr index 741edd43d29..8f6298df401 100644 --- a/yarn-project/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -1,15 +1,6 @@ // docs:start:easy_private_token_contract contract EasyPrivateToken { - use dep::aztec::protocol_types::address::AztecAddress; use dep::std::option::Option; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - state_vars::map::Map, - }; use dep::value_note::{ balance_utils, value_note::{ diff --git a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 731976633cc..67ced5856b5 100644 --- a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -1,13 +1,13 @@ contract EasyPrivateVoting { // docs:start:imports - use dep::aztec::{ - protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress - }, - context::{PrivateContext, Context}, - state_vars::{ map::Map, public_state::PublicState}, - }; + // use dep::aztec::{ + // protocol_types::{ + // abis::function_selector::FunctionSelector, + // address::AztecAddress + // }, + // context::{PrivateContext, Context}, + // state_vars::{ map::Map, public_state::PublicState}, + // }; // docs:end:imports // docs:start:storage_struct struct Storage { diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index d343f255f0a..60826b3ba55 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -3,19 +3,19 @@ mod ecdsa_public_key_note; // Account contract that uses ECDSA signatures for authentication on the same curve as Ethereum. // The signing key is stored in an immutable private note and should be different from the signing key. contract EcdsaAccount { - use dep::aztec::protocol_types::address::AztecAddress; + // use dep::aztec::protocol_types::address::AztecAddress; use dep::std; use dep::std::option::Option; - use dep::aztec::{ - abi::CallContext, - context::{PrivateContext, PublicContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - oracle::get_public_key::get_public_key, - state_vars::immutable_singleton::ImmutableSingleton, - }; + // use dep::aztec::{ + // abi::CallContext, + // context::{PrivateContext, PublicContext, Context}, + // note::{ + // note_header::NoteHeader, + // utils as note_utils, + // }, + // oracle::get_public_key::get_public_key, + // state_vars::immutable_singleton::ImmutableSingleton, + // }; use dep::authwit:: { entrypoint::{ EntrypointPayload, ENTRYPOINT_PAYLOAD_SIZE }, account::AccountActions, diff --git a/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr b/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr index 125e5ea6815..55a6524d95c 100644 --- a/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr @@ -2,21 +2,21 @@ contract Escrow { use dep::std::option::Option; - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; + // use dep::aztec::protocol_types::{ + // abis::function_selector::FunctionSelector, + // address::AztecAddress, + // }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, - oracle::get_public_key::get_public_key, - state_vars::set::Set, - }; + // use dep::aztec::{ + // context::{PrivateContext, PublicContext, Context}, + // note::{ + // note_getter_options::NoteGetterOptions, + // note_header::NoteHeader, + // utils as note_utils, + // }, + // oracle::get_public_key::get_public_key, + // state_vars::set::Set, + // }; use dep::address_note::address_note::{ AddressNote, diff --git a/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr index 82ac8a1bd2e..b3ebf54f87c 100644 --- a/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr @@ -3,7 +3,7 @@ mod test_contract_interface; // Contract that uses the autogenerated interface of the Test contract for calling its functions. // Used for testing calling into other contracts via autogenerated interfaces. contract ImportTest { - use dep::aztec::protocol_types::address::AztecAddress; + // use dep::aztec::protocol_types::address::AztecAddress; use crate::test_contract_interface::{ TestPrivateContextInterface, TestPublicContextInterface, diff --git a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index a02bc09740f..3efb9646fbf 100644 --- a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -1,56 +1,5 @@ // A demonstration of inclusion and non-inclusion proofs. contract InclusionProofs { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, - grumpkin_point::GrumpkinPoint, - contract_class::ContractClassId, - }; - use dep::aztec::{ - state_vars::{ - map::Map, - set::Set, - public_state::PublicState, - }, - context::Context, - note::{ - note_getter_options::NoteGetterOptions, - note_getter_options::NoteStatus, - note_header::NoteHeader, - utils as note_utils, - }, - // docs:start:imports - history::{ - contract_inclusion::{ - prove_contract_inclusion, - prove_contract_inclusion_at, - }, - note_inclusion::{ - prove_note_inclusion, - prove_note_inclusion_at, - }, - note_validity::{ - prove_note_validity, - prove_note_validity_at, - }, - nullifier_inclusion::{ - prove_nullifier_inclusion, - prove_nullifier_inclusion_at, - }, - nullifier_non_inclusion::{ - prove_note_not_nullified, - prove_note_not_nullified_at, - }, - public_value_inclusion::{ - prove_public_value_inclusion, - prove_public_value_inclusion_at, - }, - }, - // docs:end:imports - }; // docs:start:value_note_imports use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; // docs:end:value_note_imports @@ -74,7 +23,7 @@ contract InclusionProofs { // docs:start:create_note // Creates a value note owned by `owner`. #[aztec(private)] - fn create_note(owner: AztecAddress, value: Field) { + fn create_new_note(owner: AztecAddress, value: Field) { let owner_private_values = storage.private_values.at(owner); let mut note = ValueNote::new(value, owner); owner_private_values.insert(&mut note, true); diff --git a/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr b/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr index 5fbbb83a855..eb409fc55fc 100644 --- a/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr +++ b/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr @@ -1,8 +1,3 @@ -use dep::aztec::protocol_types::{ - address::AztecAddress, - traits::{Deserialize, Serialize} -}; - // Struct to be used to represent "totals". Generally, there should be one per asset. // It stores the global values that are shared among all users, such as an accumulator // and last time it was updated. diff --git a/yarn-project/noir-contracts/contracts/lending_contract/src/helpers.nr b/yarn-project/noir-contracts/contracts/lending_contract/src/helpers.nr index 63e72fc7aa2..304f1d5547b 100644 --- a/yarn-project/noir-contracts/contracts/lending_contract/src/helpers.nr +++ b/yarn-project/noir-contracts/contracts/lending_contract/src/helpers.nr @@ -1,6 +1,5 @@ use crate::interest_math::compute_multiplier; use dep::safe_math::SafeU120; -use dep::aztec::hash::pedersen_hash; // Utility used to easily get a "id" for a private user that sits in the same // "space" as the public users. diff --git a/yarn-project/noir-contracts/contracts/lending_contract/src/interfaces.nr b/yarn-project/noir-contracts/contracts/lending_contract/src/interfaces.nr index 22af86c6457..f7c27c4f9ae 100644 --- a/yarn-project/noir-contracts/contracts/lending_contract/src/interfaces.nr +++ b/yarn-project/noir-contracts/contracts/lending_contract/src/interfaces.nr @@ -1,14 +1,4 @@ -use dep::aztec::context::{ - PrivateContext, - PublicContext -}; - use crate::asset::Asset; -use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - constants::RETURN_VALUES_LENGTH, -}; struct PriceFeed { address: AztecAddress, diff --git a/yarn-project/noir-contracts/contracts/lending_contract/src/main.nr b/yarn-project/noir-contracts/contracts/lending_contract/src/main.nr index 2dd9bc1c16a..4e775c5e2e0 100644 --- a/yarn-project/noir-contracts/contracts/lending_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/lending_contract/src/main.nr @@ -11,19 +11,8 @@ mod interfaces; // - A way to repay all debt at once // - Liquidations contract Lending { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; use dep::safe_math::SafeU120; use dep::std::option::Option; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - state_vars::{ - map::Map, - public_state::PublicState, - } - }; use crate::asset::Asset; use crate::interest_math::compute_multiplier; use crate::helpers::{covered_by_collateral, DebtReturn, debt_updates, debt_value, compute_identifier}; diff --git a/yarn-project/noir-contracts/contracts/parent_contract/src/main.nr b/yarn-project/noir-contracts/contracts/parent_contract/src/main.nr index 7992b1b83e8..1881f9c3954 100644 --- a/yarn-project/noir-contracts/contracts/parent_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/parent_contract/src/main.nr @@ -1,10 +1,5 @@ // A contract used along with `Child` contract to test nested calls. contract Parent { - use dep::aztec::protocol_types::{ - address::AztecAddress, - abis::function_selector::FunctionSelector, - }; - #[aztec(private)] fn constructor() {} diff --git a/yarn-project/noir-contracts/contracts/pending_commitments_contract/src/main.nr b/yarn-project/noir-contracts/contracts/pending_commitments_contract/src/main.nr index aa4035ffdbc..46313e42313 100644 --- a/yarn-project/noir-contracts/contracts/pending_commitments_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/pending_commitments_contract/src/main.nr @@ -10,16 +10,6 @@ contract PendingCommitments { filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}, }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - log::emit_encrypted_log, - note::{ - note_getter::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, - state_vars::{map::Map, set::Set}, - }; use dep::aztec::protocol_types::{ address::AztecAddress, abis::function_selector::FunctionSelector, diff --git a/yarn-project/noir-contracts/contracts/price_feed_contract/src/main.nr b/yarn-project/noir-contracts/contracts/price_feed_contract/src/main.nr index b1ee56c8991..1dacf98412a 100644 --- a/yarn-project/noir-contracts/contracts/price_feed_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/price_feed_contract/src/main.nr @@ -2,14 +2,6 @@ mod asset; contract PriceFeed { use dep::std::option::Option; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - state_vars::{ - map::Map, - public_state::PublicState, - }, - }; - use dep::aztec::protocol_types::address::AztecAddress; use crate::asset::Asset; // Storage structure, containing all storage, and specifying what slots they use. diff --git a/yarn-project/noir-contracts/contracts/reader_contract/src/main.nr b/yarn-project/noir-contracts/contracts/reader_contract/src/main.nr index 7139b9332dc..632d993226b 100644 --- a/yarn-project/noir-contracts/contracts/reader_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/reader_contract/src/main.nr @@ -1,9 +1,4 @@ contract Reader { - use dep::aztec::protocol_types::{ - address::AztecAddress, - abis::function_selector::FunctionSelector, - }; - use dep::compressed_string::FieldCompressedString; #[aztec(private)] diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr index a784d7ce91c..c3f81bcdb11 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -6,14 +6,6 @@ contract SchnorrAccount { use dep::std; use dep::std::option::Option; - use dep::aztec::protocol_types::address::AztecAddress; - - use dep::aztec::{ - context::{PrivateContext, Context}, - note::{ note_header::NoteHeader, utils as note_utils }, - oracle::get_public_key::get_public_key, - state_vars::immutable_singleton::ImmutableSingleton, - }; use dep::authwit:: { entrypoint::{ EntrypointPayload, ENTRYPOINT_PAYLOAD_SIZE }, account::AccountActions, diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 24a620e4ca6..041fdc60fd4 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -1,21 +1,3 @@ -use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - hash::pedersen_hash, - oracle::{ - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, - }, - log::emit_encrypted_log, - context::PrivateContext, - protocol_types::{ - address::AztecAddress, - } -}; - global PUBLIC_KEY_NOTE_LEN: Field = 3; // Stores a public key composed of two fields diff --git a/yarn-project/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index 6226024e39f..c992fa19c6a 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -2,10 +2,6 @@ // Account contract that uses Schnorr signatures for authentication using a hardcoded public key. contract SchnorrHardcodedAccount { use dep::std; - use dep::aztec::{ - abi::{ PrivateCircuitPublicInputs, PrivateContextInputs, Hasher }, - context::PrivateContext, - }; use dep::authwit:: { entrypoint::{ EntrypointPayload, ENTRYPOINT_PAYLOAD_SIZE }, diff --git a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr index 1d43cb0816a..01b94814f61 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr @@ -1,8 +1,4 @@ use dep::authwit::auth_witness; -use dep::aztec::protocol_types::{ - address::PartialAddress, - grumpkin_point::GrumpkinPoint, -}; struct AuthWitness { owner: GrumpkinPoint, diff --git a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr index 0b20f873917..4f502063e15 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr @@ -5,7 +5,6 @@ contract SchnorrSingleKeyAccount { use dep::std::{ option::Option, }; - use dep::aztec::context::{ PrivateContext, PublicContext, Context }; use dep::authwit::{ entrypoint::EntrypointPayload, diff --git a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr index fff77376e94..cc8adff439f 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr @@ -1,4 +1,3 @@ -use dep::aztec::protocol_types::address::{AztecAddress, PublicKeysHash}; use dep::std::{schnorr::verify_signature}; use crate::auth_oracle::{AuthWitness}; diff --git a/yarn-project/noir-contracts/contracts/slow_tree_contract/src/main.nr b/yarn-project/noir-contracts/contracts/slow_tree_contract/src/main.nr index ca25b3c193b..d89f0fac9b9 100644 --- a/yarn-project/noir-contracts/contracts/slow_tree_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/slow_tree_contract/src/main.nr @@ -6,25 +6,12 @@ mod types; // https://github.com/AztecProtocol/aztec-packages/issues/1291 // This is made as a separate contract for one thing mainly. Making it simpler to use. contract SlowTree { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; use dep::std::option::Option; use dep::value_note::{ balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}, }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - state_vars::{map::Map, public_state::PublicState, set::Set}, - protocol_types::type_serialization::FIELD_SERIALIZED_LEN, - }; use dep::slow_updates_tree::slow_map::{ SlowMap, Leaf, SlowUpdateProof, compute_merkle_root, deserialize_slow_update_proof }; diff --git a/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr index ca90157034c..8a5c3f87967 100644 --- a/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -1,23 +1,11 @@ // A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests. contract StatefulTest { - use dep::aztec::protocol_types::{ - address::AztecAddress, - abis::function_selector::FunctionSelector, - }; use dep::std::option::Option; use dep::value_note::{ balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}, }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, - state_vars::{map::Map, public_state::PublicState, set::Set}, - }; struct Storage { notes: Map>, @@ -31,7 +19,7 @@ contract StatefulTest { } #[aztec(private)] - fn create_note(owner: AztecAddress, value: Field) { + fn create_new_note(owner: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); increment(loc, value, owner); diff --git a/yarn-project/noir-contracts/contracts/test_contract/src/interface.nr b/yarn-project/noir-contracts/contracts/test_contract/src/interface.nr index 0a42157be18..757f7b6aeeb 100644 --- a/yarn-project/noir-contracts/contracts/test_contract/src/interface.nr +++ b/yarn-project/noir-contracts/contracts/test_contract/src/interface.nr @@ -1,12 +1,6 @@ /* Autogenerated file, do not edit! */ use dep::std; -use dep::aztec::context::{ PrivateContext, PublicContext }; -use dep::aztec::protocol_types::{ - address::AztecAddress, - abis::function_selector::FunctionSelector, - constants::RETURN_VALUES_LENGTH, -}; struct AStructTestCodeGenStruct { amount: Field, diff --git a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr index 6741ecb8ebe..4f9d3447bf5 100644 --- a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr @@ -1,47 +1,7 @@ // A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests. contract Test { use dep::std::option::Option; - use dep::aztec::protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, - constants::{ - MAX_READ_REQUESTS_PER_CALL, - MAX_NOTES_PER_PAGE - } - }; - // The following import is here in order to make the event macro work because the macro doesn't add the import. - // It doesn't add the import because in the future we will re-export all the types via aztec-nr and aztec-nr is - // already auto-imported by the macros. - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/3590): Remove this once the issue is fixed. - use dep::aztec::protocol_types; - // docs:start:unencrypted_import - use dep::aztec::log::emit_unencrypted_log; - // docs:end:unencrypted_import - - use dep::aztec::{ - context::Context, - abi, - abi::PrivateContextInputs, - hash::pedersen_hash, - context::PrivateContext, - note::{ - note_header::NoteHeader, - utils as note_utils, - lifecycle::{create_note, destroy_note}, - note_getter::{get_notes, view_notes}, - note_getter_options::{NoteGetterOptions, NoteStatus}, - note_viewer_options::NoteViewerOptions, - }, - oracle::{ - get_public_key::get_public_key as get_public_key_oracle, - context::get_portal_address, - rand::rand - }, - state_vars::immutable_singleton::ImmutableSingleton, - log::emit_unencrypted_log_from_private, - }; + use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash}; use dep::field_note::field_note::FieldNote; use dep::value_note::value_note::{ValueNote,VALUE_NOTE_LEN}; @@ -61,8 +21,8 @@ contract Test { // docs:end:empty-constructor #[aztec(private)] - fn get_public_key(address: AztecAddress) -> [Field; 2] { - let pub_key = get_public_key_oracle(address); + fn get_pub_key(address: AztecAddress) -> [Field; 2] { + let pub_key = get_public_key(address); [pub_key.x, pub_key.y] } diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr index 713bf20a4a5..e46e946aa54 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr @@ -1,10 +1,3 @@ -use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, -}; - -use dep::aztec::context::{PrivateContext, PublicContext, Context}; - struct SlowMap { address: AztecAddress, } diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr index af3d757b1be..58689ccd96d 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -17,20 +17,20 @@ contract TokenBlacklist { use dep::std::option::Option; use dep::safe_math::SafeU120; - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress, - }; - use dep::aztec::{ - note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, - context::{PrivateContext, PublicContext, Context}, - hash::{compute_secret_hash}, - state_vars::{map::Map, public_state::PublicState, set::Set, immutable_singleton::ImmutableSingleton}, - }; + // use dep::aztec::protocol_types::{ + // abis::function_selector::FunctionSelector, + // address::AztecAddress, + // }; + // use dep::aztec::{ + // note::{ + // note_getter_options::NoteGetterOptions, + // note_header::NoteHeader, + // utils as note_utils, + // }, + // context::{PrivateContext, PublicContext, Context}, + // hash::{compute_secret_hash}, + // state_vars::{map::Map, public_state::PublicState, set::Set, immutable_singleton::ImmutableSingleton}, + // }; use dep::field_note::field_note::{FieldNote, FIELD_NOTE_LEN}; diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index 3b4c0607528..2011fac7692 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -1,24 +1,5 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; -use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - hash::pedersen_hash, - protocol_types::{ - address::AztecAddress, - constants::MAX_READ_REQUESTS_PER_CALL, - }, - state_vars::{ - set::Set, - map::Map - }, - note::{ - note_getter::view_notes, - note_getter_options::{NoteGetterOptions, SortOrder}, - note_viewer_options::NoteViewerOptions, - note_header::NoteHeader, - note_interface::NoteInterface, - } -}; use crate::types::token_note::{TokenNote, OwnedNote}; struct BalancesMap { diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 0988df4842e..356276e191d 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,25 +1,3 @@ -use dep::aztec::{ - protocol_types::{ - address::AztecAddress, - constants::{ - MAX_READ_REQUESTS_PER_CALL - }, - }, - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - context::PrivateContext, - state_vars::set::Set, - log::emit_encrypted_log, - hash::pedersen_hash, -}; -use dep::aztec::oracle::{ - rand::rand, - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, -}; use dep::safe_math::SafeU120; use dep::std::option::Option; diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 8754cf2f889..265ef93ff17 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -1,14 +1,4 @@ // docs:start:token_types_all -use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - hash::{compute_secret_hash, pedersen_hash}, - context::PrivateContext, -}; - global TRANSPARENT_NOTE_LEN: Field = 2; // Transparent note represents a note that is created in the clear (public execution), diff --git a/yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr index 489c95cb26c..27d0eb59d03 100644 --- a/yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -7,20 +7,6 @@ mod token_interface; // Bridge has to be set as a minter on the token before it can be used contract TokenBridge { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, - }; - - use dep::aztec::{ - context::{Context}, - hash::{compute_secret_hash}, - state_vars::{public_state::PublicState}, - }; - use dep::token_portal_content_hash_lib::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash}; use crate::token_interface::Token; diff --git a/yarn-project/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr b/yarn-project/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr index 130083d4b1d..049bd2e2123 100644 --- a/yarn-project/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr +++ b/yarn-project/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr @@ -1,15 +1,4 @@ // docs:start:token_bridge_token_interface -use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, -}; -use dep::aztec::{ - context::{ PrivateContext, PublicContext, Context }, -}; - struct Token { address: AztecAddress, } diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_contract/src/main.nr index 01af0454f6a..9b2a6cf0a01 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/main.nr @@ -16,21 +16,6 @@ contract Token { use dep::safe_math::SafeU120; use dep::compressed_string::FieldCompressedString; - use dep::aztec::{ - note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, - context::{PrivateContext, PublicContext, Context}, - hash::{compute_secret_hash}, - state_vars::{map::Map, public_state::PublicState, stable_public_state::StablePublicState, set::Set}, - protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress - } - }; - // docs:start:import_authwit use dep::authwit::{ auth::{ diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/balances_map.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/balances_map.nr index 3b4c0607528..2011fac7692 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/balances_map.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/balances_map.nr @@ -1,24 +1,5 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; -use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - hash::pedersen_hash, - protocol_types::{ - address::AztecAddress, - constants::MAX_READ_REQUESTS_PER_CALL, - }, - state_vars::{ - set::Set, - map::Map - }, - note::{ - note_getter::view_notes, - note_getter_options::{NoteGetterOptions, SortOrder}, - note_viewer_options::NoteViewerOptions, - note_header::NoteHeader, - note_interface::NoteInterface, - } -}; use crate::types::token_note::{TokenNote, OwnedNote}; struct BalancesMap { diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr index 7c11144e1fb..61d59ba818b 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,23 +1,3 @@ -use dep::aztec::{ - protocol_types::{ - address::AztecAddress, - constants::MAX_READ_REQUESTS_PER_CALL - }, - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - context::PrivateContext, - state_vars::set::Set, - log::emit_encrypted_log, - hash::pedersen_hash, -}; -use dep::aztec::oracle::{ - rand::rand, - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, -}; use dep::safe_math::SafeU120; use dep::std::option::Option; diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 8754cf2f889..265ef93ff17 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -1,14 +1,4 @@ // docs:start:token_types_all -use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - hash::{compute_secret_hash, pedersen_hash}, - context::PrivateContext, -}; - global TRANSPARENT_NOTE_LEN: Field = 2; // Transparent note represents a note that is created in the clear (public execution), diff --git a/yarn-project/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr b/yarn-project/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr index 2106b0a585d..3553fa752aa 100644 --- a/yarn-project/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr +++ b/yarn-project/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr @@ -1,11 +1,4 @@ // docs:start:mint_public_content_hash_nr -use dep::aztec::protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, - hash::sha256_to_field, -}; // Computes a content hash of a deposit/mint_public message. // Refer TokenPortal.sol for reference on L1. diff --git a/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr b/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr index 1d9c2985eb9..d5ed62b4cc7 100644 --- a/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr +++ b/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr @@ -1,15 +1,4 @@ // docs:start:interfaces -use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, - }; -use dep::aztec::{ - context::{ PrivateContext, PublicContext, Context }, -}; - struct Token { address: AztecAddress, } diff --git a/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr b/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr index 65f9a8ea590..0aee3230960 100644 --- a/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -6,19 +6,6 @@ mod util; // Has two separate flows for private and public respectively // Uses the token bridge contract, which tells which input token we need to talk to and handles the exit funds to L1 contract Uniswap { - use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, - address::{ - AztecAddress, - EthAddress, - }, - }; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - oracle::{context::get_portal_address}, - state_vars::{map::Map, public_state::PublicState}, - }; - use dep::authwit::auth::{IS_VALID_SELECTOR, assert_current_call_valid_authwit_public, compute_authwit_message_hash}; use crate::interfaces::{Token, TokenBridge}; diff --git a/yarn-project/noir-contracts/contracts/uniswap_contract/src/util.nr b/yarn-project/noir-contracts/contracts/uniswap_contract/src/util.nr index d4e7399fad7..10997df8a4e 100644 --- a/yarn-project/noir-contracts/contracts/uniswap_contract/src/util.nr +++ b/yarn-project/noir-contracts/contracts/uniswap_contract/src/util.nr @@ -1,11 +1,4 @@ // docs:start:uniswap_public_content_hash -use dep::aztec::protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, - hash::sha256_to_field, -}; // This method computes the L2 to L1 message content hash for the public // refer `l1-contracts/test/portals/UniswapPortal.sol` on how L2 to L1 message is expected From e67eb7888f113d79a5395703639fbe8e503c74f9 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Wed, 7 Feb 2024 20:23:29 +0000 Subject: [PATCH 02/33] delete more aztec deps in the contracts --- .../contracts/counter_contract/src/main.nr | 9 ------- .../docs_example_contract/src/main.nr | 27 +++++++------------ .../easy_private_voting_contract/src/main.nr | 10 ------- .../ecdsa_account_contract/src/main.nr | 11 -------- .../contracts/escrow_contract/src/main.nr | 16 ----------- .../import_test_contract/src/main.nr | 1 - .../token_blacklist_contract/src/main.nr | 15 ----------- 7 files changed, 9 insertions(+), 80 deletions(-) diff --git a/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr b/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr index c62fc53f855..6445b6a9b5c 100644 --- a/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/counter_contract/src/main.nr @@ -1,14 +1,5 @@ contract Counter { // docs:start:imports - // use dep::aztec::protocol_types::address::AztecAddress; - // use dep::aztec::{ - // context::{PrivateContext, Context}, - // note::{ - // note_header::NoteHeader, - // utils as note_utils, - // }, - // state_vars::map::Map, - // }; use dep::value_note::{ balance_utils, value_note::{ diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr index bb7d28dbc37..f6a570887a6 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -13,20 +13,11 @@ mod types; contract DocsExample { // how to import dependencies defined in your workspace - // use dep::aztec::protocol_types::{ - // abis::function_selector::FunctionSelector, - // address::AztecAddress, - // }; - // use dep::aztec::{ - // note::{ - // note_header::NoteHeader, - // note_getter_options::{NoteGetterOptions, Comparator}, - // note_viewer_options::{NoteViewerOptions}, - // utils as note_utils, - // }, - // context::{PrivateContext, PublicContext, Context}, - // state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton, set::Set, stable_public_state::StablePublicState}, - // }; + // TODO: maybe switch this to use a different dependency as `aztec` is now supported as a prelude + use dep::aztec::protocol_types::{ + abis::function_selector::FunctionSelector, + address::AztecAddress, + }; // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; use crate::types::{ @@ -244,10 +235,10 @@ contract DocsExample { } /// Macro equivalence section - // use dep::aztec::abi; - // use dep::aztec::abi::Hasher; - // use dep::aztec::abi::PrivateContextInputs; - // use dep::aztec::abi::PrivateCircuitPublicInputs; + use dep::aztec::abi; + use dep::aztec::abi::Hasher; + use dep::aztec::abi::PrivateContextInputs; + use dep::aztec::abi::PrivateCircuitPublicInputs; // docs:start:simple_macro_example #[aztec(private)] diff --git a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 67ced5856b5..5cb2b605bf7 100644 --- a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -1,14 +1,4 @@ contract EasyPrivateVoting { - // docs:start:imports - // use dep::aztec::{ - // protocol_types::{ - // abis::function_selector::FunctionSelector, - // address::AztecAddress - // }, - // context::{PrivateContext, Context}, - // state_vars::{ map::Map, public_state::PublicState}, - // }; - // docs:end:imports // docs:start:storage_struct struct Storage { admin: PublicState, // admin can end vote diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index 60826b3ba55..850bcdb61d1 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -3,19 +3,8 @@ mod ecdsa_public_key_note; // Account contract that uses ECDSA signatures for authentication on the same curve as Ethereum. // The signing key is stored in an immutable private note and should be different from the signing key. contract EcdsaAccount { - // use dep::aztec::protocol_types::address::AztecAddress; use dep::std; use dep::std::option::Option; - // use dep::aztec::{ - // abi::CallContext, - // context::{PrivateContext, PublicContext, Context}, - // note::{ - // note_header::NoteHeader, - // utils as note_utils, - // }, - // oracle::get_public_key::get_public_key, - // state_vars::immutable_singleton::ImmutableSingleton, - // }; use dep::authwit:: { entrypoint::{ EntrypointPayload, ENTRYPOINT_PAYLOAD_SIZE }, account::AccountActions, diff --git a/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr b/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr index 55a6524d95c..62097353879 100644 --- a/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/escrow_contract/src/main.nr @@ -2,22 +2,6 @@ contract Escrow { use dep::std::option::Option; - // use dep::aztec::protocol_types::{ - // abis::function_selector::FunctionSelector, - // address::AztecAddress, - // }; - - // use dep::aztec::{ - // context::{PrivateContext, PublicContext, Context}, - // note::{ - // note_getter_options::NoteGetterOptions, - // note_header::NoteHeader, - // utils as note_utils, - // }, - // oracle::get_public_key::get_public_key, - // state_vars::set::Set, - // }; - use dep::address_note::address_note::{ AddressNote, ADDRESS_NOTE_LEN, diff --git a/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr index a8c70d63f7d..a6b13d5522f 100644 --- a/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/import_test_contract/src/main.nr @@ -3,7 +3,6 @@ mod test_contract_interface; // Contract that uses the autogenerated interface of the Test contract for calling its functions. // Used for testing calling into other contracts via autogenerated interfaces. contract ImportTest { - // use dep::aztec::protocol_types::address::AztecAddress; use crate::test_contract_interface::{ TestPrivateContextInterface, TestPublicContextInterface, diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 58689ccd96d..725664b399f 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -17,21 +17,6 @@ contract TokenBlacklist { use dep::std::option::Option; use dep::safe_math::SafeU120; - // use dep::aztec::protocol_types::{ - // abis::function_selector::FunctionSelector, - // address::AztecAddress, - // }; - // use dep::aztec::{ - // note::{ - // note_getter_options::NoteGetterOptions, - // note_header::NoteHeader, - // utils as note_utils, - // }, - // context::{PrivateContext, PublicContext, Context}, - // hash::{compute_secret_hash}, - // state_vars::{map::Map, public_state::PublicState, set::Set, immutable_singleton::ImmutableSingleton}, - // }; - use dep::field_note::field_note::{FieldNote, FIELD_NOTE_LEN}; use dep::authwit::{ From 537c3d23443e3a14a989615fd1befffc4d2dad68 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 14:00:31 +0000 Subject: [PATCH 03/33] update methods in e2e tests --- .../end-to-end/src/e2e_inclusion_proofs_contract.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts index 459fddef998..7a8f10475a9 100644 --- a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts @@ -61,7 +61,7 @@ describe('e2e_inclusion_proofs_contract', () => { it('should return the correct values for creating a note', async () => { // Create a note - const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); + const receipt = await contract.methods.create_new_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; ({ newCommitments, visibleNotes } = receipt.debugInfo!); From 54d0be26300ebbd6d7a8cf045fbb5002467fef30 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 14:23:14 +0000 Subject: [PATCH 04/33] remove remaining imports from ecdsa_account_contract --- .../src/ecdsa_public_key_note.nr | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 9778bab59d2..cfadc883b70 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -1,19 +1,3 @@ -use dep::aztec::protocol_types::address::AztecAddress; -use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, - oracle::{ - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, - }, - log::emit_encrypted_log, - hash::pedersen_hash, - context::PrivateContext, -}; - global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5; // Stores an ECDSA public key composed of two 32-byte elements From ceaba2cd317062ee57e82a36780ded5802897e63 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 14:45:59 +0000 Subject: [PATCH 05/33] fix e2e test and move prelude source to bottom of file --- noir/aztec_macros/src/lib.rs | 194 +++++++++--------- .../src/e2e_inclusion_proofs_contract.test.ts | 2 +- 2 files changed, 98 insertions(+), 98 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index c2bca179ed1..410956654cb 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -330,103 +330,6 @@ fn inject_aztec_prelude( } } -fn aztec_prelude_source() -> &'static str { - let aztec_imports = " - use dep::aztec; - - use dep::aztec::{ - protocol_types::{ - abis::{ - function_selector::FunctionSelector, - call_context::CallContext, - private_circuit_public_inputs::PrivateCircuitPublicInputs, - }, - address::{ - AztecAddress, - EthAddress, - PartialAddress, - PublicKeysHash, - }, - contract_class::ContractClassId, - constants::{ - MAX_NOTES_PER_PAGE, - MAX_READ_REQUESTS_PER_CALL, - ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, - FUNCTION_TREE_HEIGHT, - MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, - REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, - RETURN_VALUES_LENGTH, - }, - grumpkin_point::GrumpkinPoint, - hash::{sha256_to_field, hash_args}, - traits::{Serialize, Deserialize}, - }, - context::{PrivateContext, PublicContext, Context, inputs::private_context_inputs::PrivateContextInputs}, - note::{ - utils as note_utils, - lifecycle::{create_note, destroy_note}, - utils::compute_note_hash_for_consumption, - note_getter_options::NoteGetterOptions, - note_getter_options::NoteStatus, - note_viewer_options::NoteViewerOptions, - note_getter::{get_notes, view_notes}, - note_header::NoteHeader, - note_interface::NoteInterface, - }, - oracle::{ - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, - context::get_portal_address, - rand::rand, - }, - log::{ - emit_unencrypted_log, - emit_unencrypted_log_from_private, - emit_encrypted_log, - }, - hash::{ - pedersen_hash, - compute_secret_hash, - }, - state_vars::{ - map::Map, - public_state::PublicState, - singleton::Singleton, - immutable_singleton::ImmutableSingleton, - set::Set, - stable_public_state::StablePublicState, - }, - history::{ - contract_inclusion::{ - prove_contract_inclusion, - prove_contract_inclusion_at, - }, - note_inclusion::{ - prove_note_inclusion, - prove_note_inclusion_at, - }, - note_validity::{ - prove_note_validity, - prove_note_validity_at, - }, - nullifier_inclusion::{ - prove_nullifier_inclusion, - prove_nullifier_inclusion_at, - }, - nullifier_non_inclusion::{ - prove_note_not_nullified, - prove_note_not_nullified_at, - }, - public_value_inclusion::{ - prove_public_value_inclusion, - prove_public_value_inclusion_at, - }, - }, - }; - "; - aztec_imports -} - /// Creates an error alerting the user that they have not downloaded the Aztec-noir library fn check_for_aztec_dependency( crate_id: &CrateId, @@ -1728,3 +1631,100 @@ fn event_signature(event: &StructType) -> String { let fields = vecmap(event.get_fields(&[]), |(_, typ)| signature_of_type(&typ)); format!("{}({})", event.name.0.contents, fields.join(",")) } + +fn aztec_prelude_source() -> &'static str { + let aztec_imports = " + use dep::aztec; + + use dep::aztec::{ + protocol_types::{ + abis::{ + function_selector::FunctionSelector, + call_context::CallContext, + private_circuit_public_inputs::PrivateCircuitPublicInputs, + }, + address::{ + AztecAddress, + EthAddress, + PartialAddress, + PublicKeysHash, + }, + contract_class::ContractClassId, + constants::{ + MAX_NOTES_PER_PAGE, + MAX_READ_REQUESTS_PER_CALL, + ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, + FUNCTION_TREE_HEIGHT, + MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, + REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, + RETURN_VALUES_LENGTH, + }, + grumpkin_point::GrumpkinPoint, + hash::{sha256_to_field, hash_args}, + traits::{Serialize, Deserialize}, + }, + context::{PrivateContext, PublicContext, Context, inputs::private_context_inputs::PrivateContextInputs}, + note::{ + utils as note_utils, + lifecycle::{create_note, destroy_note}, + utils::compute_note_hash_for_consumption, + note_getter_options::NoteGetterOptions, + note_getter_options::NoteStatus, + note_viewer_options::NoteViewerOptions, + note_getter::{get_notes, view_notes}, + note_header::NoteHeader, + note_interface::NoteInterface, + }, + oracle::{ + nullifier_key::get_nullifier_secret_key, + get_public_key::get_public_key, + context::get_portal_address, + rand::rand, + }, + log::{ + emit_unencrypted_log, + emit_unencrypted_log_from_private, + emit_encrypted_log, + }, + hash::{ + pedersen_hash, + compute_secret_hash, + }, + state_vars::{ + map::Map, + public_state::PublicState, + singleton::Singleton, + immutable_singleton::ImmutableSingleton, + set::Set, + stable_public_state::StablePublicState, + }, + history::{ + contract_inclusion::{ + prove_contract_inclusion, + prove_contract_inclusion_at, + }, + note_inclusion::{ + prove_note_inclusion, + prove_note_inclusion_at, + }, + note_validity::{ + prove_note_validity, + prove_note_validity_at, + }, + nullifier_inclusion::{ + prove_nullifier_inclusion, + prove_nullifier_inclusion_at, + }, + nullifier_non_inclusion::{ + prove_note_not_nullified, + prove_note_not_nullified_at, + }, + public_value_inclusion::{ + prove_public_value_inclusion, + prove_public_value_inclusion_at, + }, + }, + }; + "; + aztec_imports +} diff --git a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts index 7a8f10475a9..b7e6d68b3f4 100644 --- a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts @@ -156,7 +156,7 @@ describe('e2e_inclusion_proofs_contract', () => { { // Create a note const value = 100n; - const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); + const receipt = await contract.methods.create_new_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; const { newCommitments, visibleNotes } = receipt.debugInfo!; From 188ffe7d3215945d8318f3e70ced6f17935d4524 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 15:07:25 +0000 Subject: [PATCH 06/33] update benchmarks e2e --- yarn-project/end-to-end/src/benchmarks/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/benchmarks/utils.ts b/yarn-project/end-to-end/src/benchmarks/utils.ts index 348932f7b60..878badad074 100644 --- a/yarn-project/end-to-end/src/benchmarks/utils.ts +++ b/yarn-project/end-to-end/src/benchmarks/utils.ts @@ -69,7 +69,7 @@ export function getFolderSize(path: string): number { export function makeCall(index: number, context: EndToEndContext, contract: BenchmarkingContract) { const owner = context.wallet.getAddress(); return new BatchCall(context.wallet, [ - contract.methods.create_note(owner, index + 1).request(), + contract.methods.create_new_note(owner, index + 1).request(), contract.methods.increment_balance(owner, index + 1).request(), ]); } From a117ec3e1a19b3b83fca91b17360c05c2b028256 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 15:11:55 +0000 Subject: [PATCH 07/33] stateful test create_new_note --- yarn-project/simulator/src/client/private_execution.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 2ea03803d01..74aee31db92 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -329,8 +329,8 @@ describe('Private Execution test suite', () => { ); }); - it('should run the create_note function', async () => { - const artifact = getFunctionArtifact(StatefulTestContractArtifact, 'create_note'); + it('should run the create_new_note function', async () => { + const artifact = getFunctionArtifact(StatefulTestContractArtifact, 'create_new_note'); const result = await runSimulator({ args: [owner, 140], artifact }); From 401261507be5ecae4444d4d34be4b7755022262c Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 15:38:23 +0000 Subject: [PATCH 08/33] format --- .../contracts/contract_class_registerer_contract/src/main.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 3867d7d6332..f8f405e9bfe 100644 --- a/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -2,7 +2,7 @@ mod events; contract ContractClassRegisterer { use dep::std::option::Option; - + use crate::events::{ class_registered::ContractClassRegistered, private_function_broadcasted::{ClassPrivateFunctionBroadcasted, PrivateFunction}, From d91f69c70f37e0ed9752abbd39234cc4148769c3 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 15:59:09 +0000 Subject: [PATCH 09/33] run tests on single thread --- yarn-project/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/package.json b/yarn-project/package.json index 4d68e44fc0b..22a0eb3a063 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -6,7 +6,7 @@ "prepare": "node ./yarn-project-base/scripts/update_package_jsons.mjs && yarn workspaces foreach run prepare && workspaces-to-typescript-project-references --tsconfigPath tsconfig.json && prettier -w */tsconfig.json", "prepare:check": "node ./yarn-project-base/scripts/update_package_jsons.mjs --check && workspaces-to-typescript-project-references --check --tsconfigPath tsconfig.json", "docs": "typedoc --out docs/dist && cd docs && yarn serve", - "formatting": "./run_nargo_fmt.sh --check && FORCE_COLOR=true yarn workspaces foreach -p -j unlimited -v run formatting", + "formatting": "./run_nargo_fmt.sh --check && FORCE_COLOR=true yarn workspaces foreach -p -j 1 -v run formatting", "formatting:fix": "./run_nargo_fmt.sh && FORCE_COLOR=true yarn workspaces foreach -p -v run formatting:fix", "lint": "yarn eslint --cache --ignore-pattern l1-artifacts .", "format": "yarn prettier --cache -w .", From 1dbf3d55f18a71f71c5f66796efc056c6af4fe1e Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 16:17:47 +0000 Subject: [PATCH 10/33] missing maxWorkers --- yarn-project/simulator/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yarn-project/simulator/package.json b/yarn-project/simulator/package.json index 0a84d51627b..78376bc9d32 100644 --- a/yarn-project/simulator/package.json +++ b/yarn-project/simulator/package.json @@ -27,7 +27,8 @@ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1" }, "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", - "rootDir": "./src" + "rootDir": "./src", + "maxWorkers": 1 }, "dependencies": { "@aztec/circuit-types": "workspace:^", From 8aa6ad882f5872b01501af84873eb3703b8847cb Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 16:39:47 +0000 Subject: [PATCH 11/33] fix stateful constructor and run tests on many threads --- .../contracts/stateful_test_contract/src/main.nr | 2 +- yarn-project/package.json | 2 +- yarn-project/simulator/package.json | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr index db0f19b1d77..bf06c848ae1 100644 --- a/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -14,7 +14,7 @@ contract StatefulTest { #[aztec(private)] fn constructor(owner: AztecAddress, value: Field) { - let selector = FunctionSelector::from_signature("create_note((Field),Field)"); + let selector = FunctionSelector::from_signature("create_new_note((Field),Field)"); let _res = context.call_private_function(context.this_address(), selector, [owner.to_field(), value]); } diff --git a/yarn-project/package.json b/yarn-project/package.json index 22a0eb3a063..4d68e44fc0b 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -6,7 +6,7 @@ "prepare": "node ./yarn-project-base/scripts/update_package_jsons.mjs && yarn workspaces foreach run prepare && workspaces-to-typescript-project-references --tsconfigPath tsconfig.json && prettier -w */tsconfig.json", "prepare:check": "node ./yarn-project-base/scripts/update_package_jsons.mjs --check && workspaces-to-typescript-project-references --check --tsconfigPath tsconfig.json", "docs": "typedoc --out docs/dist && cd docs && yarn serve", - "formatting": "./run_nargo_fmt.sh --check && FORCE_COLOR=true yarn workspaces foreach -p -j 1 -v run formatting", + "formatting": "./run_nargo_fmt.sh --check && FORCE_COLOR=true yarn workspaces foreach -p -j unlimited -v run formatting", "formatting:fix": "./run_nargo_fmt.sh && FORCE_COLOR=true yarn workspaces foreach -p -v run formatting:fix", "lint": "yarn eslint --cache --ignore-pattern l1-artifacts .", "format": "yarn prettier --cache -w .", diff --git a/yarn-project/simulator/package.json b/yarn-project/simulator/package.json index 78376bc9d32..0a84d51627b 100644 --- a/yarn-project/simulator/package.json +++ b/yarn-project/simulator/package.json @@ -27,8 +27,7 @@ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1" }, "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", - "rootDir": "./src", - "maxWorkers": 1 + "rootDir": "./src" }, "dependencies": { "@aztec/circuit-types": "workspace:^", From f03ca68c0855f4a2a9b928cb69ecfbe54c36d3a6 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 16:59:37 +0000 Subject: [PATCH 12/33] fix get public key test --- yarn-project/simulator/src/client/private_execution.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 949e22ee948..cf7f8345317 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -1074,7 +1074,7 @@ describe('Private Execution test suite', () => { describe('get public key', () => { it('gets the public key for an address', async () => { // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'get_public_key'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_pub_key'); artifact.returnTypes = [{ kind: 'array', length: 2, type: { kind: 'field' } }]; // Generate a partial address, pubkey, and resulting address From f834222f6476824cff671506f69fbe22fc054cde Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 8 Feb 2024 20:07:27 +0000 Subject: [PATCH 13/33] update e2e_deploy_contract test after master merge --- yarn-project/end-to-end/src/e2e_deploy_contract.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 6dfc3d9e208..2c215fee681 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -118,7 +118,7 @@ describe('e2e_deploy_contract', () => { const contract = await Contract.at(receipt.contractAddress!, TestContractArtifact, wallet); logger(`Sending TX to contract ${index + 1}...`); - await contract.methods.get_public_key(accounts[0].address).send().wait(); + await contract.methods.get_pub_key(accounts[0].address).send().wait(); } }, 60_000); From 87bdde6cb97f5fd7a346a68f90732aab16bc27c0 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 16:52:03 +0000 Subject: [PATCH 14/33] all contracts working with new prelde --- .../aztec-nr/value-note/src/utils.nr | 4 +- .../benchmarking_contract/src/main.nr | 5 +- .../contracts/card_game_contract/src/cards.nr | 15 ++++ .../contracts/card_game_contract/src/game.nr | 3 + .../contracts/counter_contract/src/main.nr | 7 ++ .../docs_example_contract/src/main.nr | 11 ++- .../easy_private_token_contract/src/main.nr | 7 ++ .../inclusion_proofs_contract/src/main.nr | 6 +- .../contracts/lending_contract/src/asset.nr | 4 + .../contracts/lending_contract/src/helpers.nr | 1 + .../lending_contract/src/interfaces.nr | 8 ++ .../contracts/lending_contract/src/main.nr | 6 ++ .../src/main.nr | 1 + .../src/util.nr | 1 + .../stateful_test_contract/src/main.nr | 7 +- .../contracts/test_contract/src/main.nr | 4 +- .../token_blacklist_contract/src/main.nr | 13 ++++ .../contracts/token_contract/src/main.nr | 12 +++ .../token_portal_content_hash_lib/src/lib.nr | 3 + noir/aztec_macros/src/lib.rs | 77 +------------------ .../src/hir/def_collector/dc_crate.rs | 2 +- noir/noirc_macros/src/lib.rs | 12 +++ 22 files changed, 119 insertions(+), 90 deletions(-) diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index d1ded533297..d7ef7c948dc 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -47,7 +47,7 @@ pub fn decrement_by_at_most(balance: Set, max_amount: Field, owner: A let mut decremented = 0; for i in 0..opt_notes.len() { if opt_notes[i].is_some() { - decremented += destroy_value_note(balance, owner, opt_notes[i].unwrap_unchecked()); + decremented += destroy_note(balance, owner, opt_notes[i].unwrap_unchecked()); } } @@ -64,7 +64,7 @@ pub fn decrement_by_at_most(balance: Set, max_amount: Field, owner: A // Removes the note from the owner's set of notes. // Returns the value of the destroyed note. -fn destroy_value_note(balance: Set, owner: AztecAddress, note: ValueNote) -> Field { +pub fn destroy_note(balance: Set, owner: AztecAddress, note: ValueNote) -> Field { // Ensure the note is actually owned by the owner (to prevent user from generating a valid proof while // spending someone else's notes). assert(note.owner.eq(owner)); diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 132b716eb19..1fcebb24bae 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -8,10 +8,9 @@ contract Benchmarking { use dep::value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, + protocol_types::{abis::function_selector::FunctionSelector}, context::{Context}, note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, - log::emit_unencrypted_log, state_vars::{map::Map, public_state::PublicState, set::Set} }; struct Storage { @@ -24,7 +23,7 @@ contract Benchmarking { // Creates a new value note for the target owner. Use this method to seed an initial set of notes. #[aztec(private)] - fn create_new_note(owner: AztecAddress, value: Field) { + fn create_note(owner: AztecAddress, value: Field) { increment(storage.notes.at(owner), value, owner); } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index 1e2592b37dc..f2978489e47 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -1,3 +1,18 @@ +use dep::aztec::{ + protocol_types::{ + address::AztecAddress, + constants::{ + MAX_NOTES_PER_PAGE, + MAX_READ_REQUESTS_PER_CALL, + }, + }, + context::{PrivateContext, PublicContext, Context}, + note::{ + note_getter_options::NoteGetterOptions, + note_viewer_options::NoteViewerOptions, + note_getter::view_notes, + }, +}; use dep::std; use dep::std::{ option::Option, diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr index 6f2f46ce5df..00c45dfe8da 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr @@ -1,3 +1,6 @@ +use dep::aztec::protocol_types::{ + traits::{Serialize, Deserialize}, +}; use crate::cards::Card; global NUMBER_OF_PLAYERS = 2; diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index f806819b15a..a20865ea98a 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -1,5 +1,12 @@ contract Counter { // docs:start:imports + use dep::aztec::{ + context::{PrivateContext, Context}, + note::{ + note_header::NoteHeader, + utils as note_utils, + }, + }; use dep::value_note::{ balance_utils, value_note::{ diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 0258d3fc6af..1bd0473c470 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -13,10 +13,17 @@ mod types; contract DocsExample { // how to import dependencies defined in your workspace - // TODO: maybe switch this to use a different dependency as `aztec` is now supported as a prelude use dep::aztec::protocol_types::{ abis::function_selector::FunctionSelector, - address::AztecAddress, + }; + use dep::aztec::{ + note::{ + note_header::NoteHeader, + note_getter_options::{NoteGetterOptions, Comparator}, + note_viewer_options::{NoteViewerOptions}, + utils as note_utils, + }, + context::{PrivateContext, PublicContext, Context}, }; // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index cd156cf85fa..d933689ab51 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -1,5 +1,12 @@ // docs:start:easy_private_token_contract contract EasyPrivateToken { + use dep::aztec::{ + context::{PrivateContext, PublicContext, Context}, + note::{ + note_header::NoteHeader, + utils as note_utils, + }, + }; use dep::std::option::Option; use dep::value_note::{ balance_utils, diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 84a976c7157..36a1d4bf4e6 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -1,11 +1,11 @@ // A demonstration of inclusion and non-inclusion proofs. contract InclusionProofs { use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}, + abis::function_selector::FunctionSelector, grumpkin_point::GrumpkinPoint, contract_class::ContractClassId }; use dep::aztec::{ - state_vars::{map::Map, set::Set, public_state::PublicState}, context::Context, + context::Context, note::{ note_getter_options::NoteGetterOptions, note_getter_options::NoteStatus, note_header::NoteHeader, utils as note_utils @@ -50,7 +50,7 @@ contract InclusionProofs { // docs:start:create_note // Creates a value note owned by `owner`. #[aztec(private)] - fn create_new_note(owner: AztecAddress, value: Field) { + fn create_note(owner: AztecAddress, value: Field) { let owner_private_values = storage.private_values.at(owner); let mut note = ValueNote::new(value, owner); owner_private_values.insert(&mut note, true); diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr index b9caea80f52..d3dc691ba28 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr @@ -1,3 +1,7 @@ +use dep::aztec::protocol_types::{ + traits::{Deserialize, Serialize} +}; + // Struct to be used to represent "totals". Generally, there should be one per asset. // It stores the global values that are shared among all users, such as an accumulator // and last time it was updated. diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr index 304f1d5547b..63e72fc7aa2 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/helpers.nr @@ -1,5 +1,6 @@ use crate::interest_math::compute_multiplier; use dep::safe_math::SafeU120; +use dep::aztec::hash::pedersen_hash; // Utility used to easily get a "id" for a private user that sits in the same // "space" as the public users. diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr index 3eda4ccebe2..b298cb635ca 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr @@ -1,4 +1,12 @@ +use dep::aztec::context::{ + PrivateContext, + PublicContext +}; use crate::asset::Asset; +use dep::aztec::protocol_types::{ + abis::function_selector::FunctionSelector, + constants::RETURN_VALUES_LENGTH, +}; struct PriceFeed { address: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index c7fcde4a096..76af9bcfd38 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -11,8 +11,14 @@ mod interfaces; // - A way to repay all debt at once // - Liquidations contract Lending { + use dep::aztec::protocol_types::{ + abis::function_selector::FunctionSelector, + }; use dep::safe_math::SafeU120; use dep::std::option::Option; + use dep::aztec::{ + context::{PrivateContext, PublicContext, Context}, + }; use crate::asset::Asset; use crate::interest_math::compute_multiplier; use crate::helpers::{covered_by_collateral, DebtReturn, debt_updates, debt_value, compute_identifier}; diff --git a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index 7d451e040b1..c5293bac24c 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -2,6 +2,7 @@ // Account contract that uses Schnorr signatures for authentication using a hardcoded public key. contract SchnorrHardcodedAccount { use dep::std; + use dep::aztec::context::PrivateContext; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr index cc8adff439f..fff77376e94 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr @@ -1,3 +1,4 @@ +use dep::aztec::protocol_types::address::{AztecAddress, PublicKeysHash}; use dep::std::{schnorr::verify_signature}; use crate::auth_oracle::{AuthWitness}; diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 1915ac21871..15057c2c720 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -1,12 +1,11 @@ // A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests. contract StatefulTest { - use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector}; + use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector}; use dep::std::option::Option; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, note::{note_header::NoteHeader, utils as note_utils}, - state_vars::{map::Map, public_state::PublicState, set::Set} }; struct Storage { @@ -16,12 +15,12 @@ contract StatefulTest { #[aztec(private)] fn constructor(owner: AztecAddress, value: Field) { - let selector = FunctionSelector::from_signature("create_new_note((Field),Field)"); + let selector = FunctionSelector::from_signature("create_note((Field),Field)"); let _res = context.call_private_function(context.this_address(), selector, [owner.to_field(), value]); } #[aztec(private)] - fn create_new_note(owner: AztecAddress, value: Field) { + fn create_note(owner: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); increment(loc, value, owner); diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 2f76d210e50..b0c081ead82 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -40,8 +40,8 @@ contract Test { // docs:end:empty-constructor #[aztec(private)] - fn get_pub_key(address: AztecAddress) -> [Field; 2] { - let pub_key = get_public_key(address); + fn get_public_key(address: AztecAddress) -> [Field; 2] { + let pub_key = get_public_key_oracle(address); [pub_key.x, pub_key.y] } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index f892dca4dea..a2a4979693f 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -17,6 +17,19 @@ contract TokenBlacklist { use dep::std::option::Option; use dep::safe_math::SafeU120; + use dep::aztec::protocol_types::{ + abis::function_selector::FunctionSelector, + }; + use dep::aztec::{ + note::{ + note_getter_options::NoteGetterOptions, + note_header::NoteHeader, + utils as note_utils, + }, + context::{PrivateContext, PublicContext, Context}, + hash::{compute_secret_hash}, + }; + use dep::field_note::field_note::{FieldNote, FIELD_NOTE_LEN}; use dep::authwit::{ diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 6941630ae2f..acf2306fdf3 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -16,6 +16,18 @@ contract Token { use dep::safe_math::SafeU120; use dep::compressed_string::FieldCompressedString; + use dep::aztec::{ + note::{ + note_getter_options::NoteGetterOptions, + note_header::NoteHeader, + utils as note_utils, + }, + hash::{compute_secret_hash}, + protocol_types::{ + abis::function_selector::FunctionSelector, + } + }; + // docs:start:import_authwit use dep::authwit::{ auth::{ diff --git a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr index 3553fa752aa..ac66f75f13b 100644 --- a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr @@ -1,4 +1,7 @@ // docs:start:mint_public_content_hash_nr +use dep::aztec::protocol_types::{ + hash::sha256_to_field, +}; // Computes a content hash of a deposit/mint_public message. // Refer TokenPortal.sol for reference on L1. diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 097aa075d3b..d3946e07cdd 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -1642,57 +1642,10 @@ fn aztec_prelude_source() -> &'static str { use dep::aztec::{ protocol_types::{ - abis::{ - function_selector::FunctionSelector, - call_context::CallContext, - private_circuit_public_inputs::PrivateCircuitPublicInputs, - }, address::{ AztecAddress, EthAddress, - PartialAddress, - PublicKeysHash, - }, - contract_class::ContractClassId, - constants::{ - MAX_NOTES_PER_PAGE, - MAX_READ_REQUESTS_PER_CALL, - ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, - FUNCTION_TREE_HEIGHT, - MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, - REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, - RETURN_VALUES_LENGTH, }, - grumpkin_point::GrumpkinPoint, - hash::{sha256_to_field, hash_args}, - traits::{Serialize, Deserialize}, - }, - context::{PrivateContext, PublicContext, Context, inputs::private_context_inputs::PrivateContextInputs}, - note::{ - utils as note_utils, - lifecycle::{create_note, destroy_note}, - utils::compute_note_hash_for_consumption, - note_getter_options::NoteGetterOptions, - note_getter_options::NoteStatus, - note_viewer_options::NoteViewerOptions, - note_getter::{get_notes, view_notes}, - note_header::NoteHeader, - note_interface::NoteInterface, - }, - oracle::{ - nullifier_key::get_nullifier_secret_key, - get_public_key::get_public_key, - context::get_portal_address, - rand::rand, - }, - log::{ - emit_unencrypted_log, - emit_unencrypted_log_from_private, - emit_encrypted_log, - }, - hash::{ - pedersen_hash, - compute_secret_hash, }, state_vars::{ map::Map, @@ -1702,32 +1655,10 @@ fn aztec_prelude_source() -> &'static str { set::Set, stable_public_state::StablePublicState, }, - history::{ - contract_inclusion::{ - prove_contract_inclusion, - prove_contract_inclusion_at, - }, - note_inclusion::{ - prove_note_inclusion, - prove_note_inclusion_at, - }, - note_validity::{ - prove_note_validity, - prove_note_validity_at, - }, - nullifier_inclusion::{ - prove_nullifier_inclusion, - prove_nullifier_inclusion_at, - }, - nullifier_non_inclusion::{ - prove_note_not_nullified, - prove_note_not_nullified_at, - }, - public_value_inclusion::{ - prove_public_value_inclusion, - prove_public_value_inclusion_at, - }, - }, + log::{ + emit_unencrypted_log, + emit_encrypted_log, + } }; "; aztec_imports diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 31d3275e368..f0992456214 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -266,7 +266,7 @@ impl DefCollector { ); } - for macro_processor in macro_processors.clone() { + for macro_processor in macro_processors.iter() { macro_processor.process_crate_prelude(&crate_id, context, &mut def_collector.collected_imports, &submodules).unwrap_or_else( |(macro_err, file_id)| { errors.push((macro_err.into(), file_id)); diff --git a/noir/noirc_macros/src/lib.rs b/noir/noirc_macros/src/lib.rs index 4337214d69f..33f7f2294b3 100644 --- a/noir/noirc_macros/src/lib.rs +++ b/noir/noirc_macros/src/lib.rs @@ -2,7 +2,9 @@ use noirc_frontend::macros_api::parse_program; use noirc_frontend::macros_api::HirContext; use noirc_frontend::macros_api::SortedModule; use noirc_frontend::macros_api::{CrateId, FileId}; +use noirc_frontend::macros_api::LocalModuleId; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; +use noirc_frontend::macros_api::HirImportDirective; pub struct AssertMessageMacro; @@ -16,6 +18,16 @@ impl MacroProcessor for AssertMessageMacro { transform(ast, crate_id) } + fn process_crate_prelude( + &self, + _crate_id: &CrateId, + _context: &HirContext, + _collected_imports: &mut Vec, + _submodules: &[LocalModuleId], + ) -> Result<(), (MacroError, FileId)> { + Ok(()) + } + // This macro does not need to process any information after name resolution fn process_typed_ast( &self, From 159980dd91c9e93aa1160654cb8853018fda67f1 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 16:52:54 +0000 Subject: [PATCH 15/33] fix e2e tests --- yarn-project/end-to-end/src/benchmarks/utils.ts | 2 +- yarn-project/end-to-end/src/e2e_deploy_contract.test.ts | 2 +- .../end-to-end/src/e2e_inclusion_proofs_contract.test.ts | 4 ++-- yarn-project/simulator/src/client/private_execution.test.ts | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/yarn-project/end-to-end/src/benchmarks/utils.ts b/yarn-project/end-to-end/src/benchmarks/utils.ts index c2c85fdd220..8ae3d6a0eb8 100644 --- a/yarn-project/end-to-end/src/benchmarks/utils.ts +++ b/yarn-project/end-to-end/src/benchmarks/utils.ts @@ -69,7 +69,7 @@ export function getFolderSize(path: string): number { export function makeCall(index: number, context: EndToEndContext, contract: BenchmarkingContract) { const owner = context.wallet.getAddress(); return new BatchCall(context.wallet, [ - contract.methods.create_new_note(owner, index + 1).request(), + contract.methods.create_note(owner, index + 1).request(), contract.methods.increment_balance(owner, index + 1).request(), ]); } diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 07010dba116..f0413d1fcb6 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -118,7 +118,7 @@ describe('e2e_deploy_contract', () => { const contract = await Contract.at(receipt.contractAddress!, TestContractArtifact, wallet); logger(`Sending TX to contract ${index + 1}...`); - await contract.methods.get_pub_key(accounts[0].address).send().wait(); + await contract.methods.get_public_key(accounts[0].address).send().wait(); } }, 60_000); diff --git a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts index 17ea963493e..53adc6a61ad 100644 --- a/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_inclusion_proofs_contract.test.ts @@ -61,7 +61,7 @@ describe('e2e_inclusion_proofs_contract', () => { it('should return the correct values for creating a note', async () => { // Create a note - const receipt = await contract.methods.create_new_note(owner, value).send().wait({ debug: true }); + const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; ({ newCommitments, visibleNotes } = receipt.debugInfo!); @@ -156,7 +156,7 @@ describe('e2e_inclusion_proofs_contract', () => { { // Create a note const value = 100n; - const receipt = await contract.methods.create_new_note(owner, value).send().wait({ debug: true }); + const receipt = await contract.methods.create_note(owner, value).send().wait({ debug: true }); noteCreationBlockNumber = receipt.blockNumber!; const { newCommitments, visibleNotes } = receipt.debugInfo!; diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index cdacdc4c36f..2ae86f45b90 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -336,8 +336,8 @@ describe('Private Execution test suite', () => { ); }); - it('should run the create_new_note function', async () => { - const artifact = getFunctionArtifact(StatefulTestContractArtifact, 'create_new_note'); + it('should run the create_note function', async () => { + const artifact = getFunctionArtifact(StatefulTestContractArtifact, 'create_note'); const result = await runSimulator({ args: [owner, 140], artifact }); @@ -1114,7 +1114,7 @@ describe('Private Execution test suite', () => { describe('get public key', () => { it('gets the public key for an address', async () => { // Tweak the contract artifact so we can extract return values - const artifact = getFunctionArtifact(TestContractArtifact, 'get_pub_key'); + const artifact = getFunctionArtifact(TestContractArtifact, 'get_public_key'); artifact.returnTypes = [{ kind: 'array', length: 2, type: { kind: 'field' } }]; // Generate a partial address, pubkey, and resulting address From 872d70e97b34efd4ae53118dee9d21ec10142678 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 16:55:42 +0000 Subject: [PATCH 16/33] cargo fmt --- noir/aztec_macros/src/lib.rs | 28 ++++++++----------- .../src/hir/def_collector/dc_crate.rs | 23 +++++++-------- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- noir/compiler/noirc_frontend/src/lib.rs | 2 +- noir/noirc_macros/src/lib.rs | 4 +-- 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index d3946e07cdd..8a3ba42719d 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -4,20 +4,21 @@ use std::vec; use convert_case::{Case, Casing}; use iter_extended::vecmap; use noirc_frontend::macros_api::parse_program; -use noirc_frontend::macros_api::HirImportDirective; use noirc_frontend::macros_api::FieldElement; +use noirc_frontend::macros_api::HirImportDirective; use noirc_frontend::macros_api::{ BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionDefinition, FunctionReturnType, FunctionVisibility, - HirContext, HirExpression, HirLiteral, HirStatement, Ident, IndexExpression, - LetStatement, Literal, MemberAccessExpression, MethodCallExpression, NoirFunction, NoirStruct, - Param, Path, Pattern, PrefixExpression, SecondaryAttribute, Signedness, Span, - Statement, StatementKind, StructType, Type, TypeImpl, UnaryOp, UnresolvedType, - UnresolvedTypeData, Visibility, + HirContext, HirExpression, HirLiteral, HirStatement, Ident, IndexExpression, LetStatement, + Literal, MemberAccessExpression, MethodCallExpression, NoirFunction, NoirStruct, Param, Path, + Pattern, PrefixExpression, SecondaryAttribute, Signedness, Span, Statement, StatementKind, + StructType, Type, TypeImpl, UnaryOp, UnresolvedType, UnresolvedTypeData, Visibility, }; use noirc_frontend::macros_api::{CrateId, FileId}; +use noirc_frontend::macros_api::{ + LocalModuleId, ModuleDefId, NodeInterner, SortedModule, StructId, +}; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; -use noirc_frontend::macros_api::{LocalModuleId, ModuleDefId, NodeInterner, SortedModule, StructId}; use noirc_frontend::node_interner::{TraitId, TraitImplKind}; use noirc_frontend::Lambda; @@ -48,13 +49,9 @@ impl MacroProcessor for AztecMacro { let crate_root = def_map.root(); inject_aztec_prelude(*crate_id, crate_root, collected_imports); for submodule in submodules.iter() { - inject_aztec_prelude( - *crate_id, - *submodule, - collected_imports, - ); + inject_aztec_prelude(*crate_id, *submodule, collected_imports); } - + Ok(()) } @@ -343,10 +340,7 @@ fn check_for_aztec_dependency( } } -fn has_aztec_dependency( - crate_id: &CrateId, - context: &HirContext, -) -> bool { +fn has_aztec_dependency(crate_id: &CrateId, context: &HirContext) -> bool { let crate_graph = &context.crate_graph[crate_id]; let has_aztec_dependency = crate_graph.dependencies.iter().any(|dep| dep.as_name() == "aztec"); if has_aztec_dependency { diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index f0992456214..372ca67b9bc 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -252,26 +252,27 @@ impl DefCollector { context, )); - let submodules = vecmap(def_collector.def_map.modules().iter(), |(index, _)| LocalModuleId(index)); + let submodules = + vecmap(def_collector.def_map.modules().iter(), |(index, _)| LocalModuleId(index)); // Add the current crate to the collection of DefMaps context.def_maps.insert(crate_id, def_collector.def_map); inject_prelude(crate_id, context, crate_root, &mut def_collector.collected_imports); for submodule in submodules.iter() { - inject_prelude( - crate_id, - context, - *submodule, - &mut def_collector.collected_imports, - ); + inject_prelude(crate_id, context, *submodule, &mut def_collector.collected_imports); } for macro_processor in macro_processors.iter() { - macro_processor.process_crate_prelude(&crate_id, context, &mut def_collector.collected_imports, &submodules).unwrap_or_else( - |(macro_err, file_id)| { + macro_processor + .process_crate_prelude( + &crate_id, + context, + &mut def_collector.collected_imports, + &submodules, + ) + .unwrap_or_else(|(macro_err, file_id)| { errors.push((macro_err.into(), file_id)); - }, - ); + }); } // Resolve unresolved imports collected from the crate, one by one. diff --git a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs index 6ab1e8c77f3..8c985e88e0b 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -84,7 +84,7 @@ impl CrateDefMap { if context.def_map(&crate_id).is_some() { return errors; } - + // First parse the root file. let root_file_id = context.crate_graph[crate_id].root_file_id; let (ast, parsing_errors) = context.parsed_file_results(root_file_id); diff --git a/noir/compiler/noirc_frontend/src/lib.rs b/noir/compiler/noirc_frontend/src/lib.rs index 7a81124da15..425dcd2b6d2 100644 --- a/noir/compiler/noirc_frontend/src/lib.rs +++ b/noir/compiler/noirc_frontend/src/lib.rs @@ -53,9 +53,9 @@ pub mod macros_api { pub use crate::token::SecondaryAttribute; pub use crate::hir::def_collector::dc_crate::DefCollector as HirDefCollector; + pub use crate::hir::def_map::{LocalModuleId, ModuleDefId, ModuleId}; pub use crate::hir::resolution::import::ImportDirective as HirImportDirective; pub use crate::hir::resolution::path_resolver; - pub use crate::hir::def_map::{LocalModuleId, ModuleId, ModuleDefId}; pub use crate::{ hir::Context as HirContext, BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, FunctionReturnType, Ident, IndexExpression, LetStatement, diff --git a/noir/noirc_macros/src/lib.rs b/noir/noirc_macros/src/lib.rs index 33f7f2294b3..bad0a49e04a 100644 --- a/noir/noirc_macros/src/lib.rs +++ b/noir/noirc_macros/src/lib.rs @@ -1,10 +1,10 @@ use noirc_frontend::macros_api::parse_program; use noirc_frontend::macros_api::HirContext; +use noirc_frontend::macros_api::HirImportDirective; +use noirc_frontend::macros_api::LocalModuleId; use noirc_frontend::macros_api::SortedModule; use noirc_frontend::macros_api::{CrateId, FileId}; -use noirc_frontend::macros_api::LocalModuleId; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; -use noirc_frontend::macros_api::HirImportDirective; pub struct AssertMessageMacro; From 8f968951f369e2eaae1f5446453af4ded6bbd28a Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 17:38:50 +0000 Subject: [PATCH 17/33] remove changes to slow_map.nr --- noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr | 5 +++-- .../noir-contracts/contracts/avm_test_contract/src/main.nr | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr b/noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr index 4a93fb734a0..065ab009197 100644 --- a/noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr +++ b/noir-projects/aztec-nr/slow-updates-tree/src/slow_map.nr @@ -1,6 +1,7 @@ use dep::aztec::context::{PrivateContext, PublicContext, Context}; use dep::aztec::oracle::storage::{storage_read, storage_write}; use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; +use dep::std::hash::pedersen_hash; use dep::std::merkle::compute_merkle_root; use dep::std::option::Option; @@ -140,7 +141,7 @@ impl SlowMap { // docs:start:read_leaf_at pub fn read_leaf_at(self: Self, key: Field) -> Leaf { - let derived_storage_slot = dep::std::hash::pedersen_hash([self.storage_slot, key]); + let derived_storage_slot = pedersen_hash([self.storage_slot, key]); let fields = storage_read(derived_storage_slot); Leaf::deserialize(fields) } @@ -246,7 +247,7 @@ impl SlowMap { // Updates the value in the in storage with no checks. fn update_unsafe(self: Self, index: Field, leaf: Leaf, root: Leaf) { - let derived_storage_slot = dep::std::hash::pedersen_hash([self.storage_slot, index]); + let derived_storage_slot = pedersen_hash([self.storage_slot, index]); let fields = leaf.serialize(); storage_write(derived_storage_slot, fields); diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index 8f2d554a811..5def09d5280 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -1,9 +1,6 @@ // contract AvmTest { - // Libs - use dep::aztec::protocol_types::address::{AztecAddress, EthAddress}; - // avm lib use dep::aztec::avm::context::AvmContext; From 33a2d9c35d4e0d3f2c7c9c3aa1885590b0f66cdd Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 17:46:44 +0000 Subject: [PATCH 18/33] cleanup has_aztec_dep func --- noir/aztec_macros/src/lib.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 8a3ba42719d..888e1da33db 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -342,12 +342,7 @@ fn check_for_aztec_dependency( fn has_aztec_dependency(crate_id: &CrateId, context: &HirContext) -> bool { let crate_graph = &context.crate_graph[crate_id]; - let has_aztec_dependency = crate_graph.dependencies.iter().any(|dep| dep.as_name() == "aztec"); - if has_aztec_dependency { - true - } else { - false - } + crate_graph.dependencies.iter().any(|dep| dep.as_name() == "aztec") } // Check to see if the user has defined a storage struct From d795c2719afcb12756b107cb20a18e0d048dd78d Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 18:17:29 +0000 Subject: [PATCH 19/33] use prelude.nr inside of aztec-nr --- noir-projects/aztec-nr/aztec/src/lib.nr | 1 + noir-projects/aztec-nr/aztec/src/prelude.nr | 20 +++++ noir/aztec_macros/src/lib.rs | 80 +++++-------------- .../src/hir/def_collector/dc_crate.rs | 43 ++++++---- noir/compiler/noirc_frontend/src/lib.rs | 7 +- noir/noirc_macros/src/lib.rs | 8 +- 6 files changed, 72 insertions(+), 87 deletions(-) create mode 100644 noir-projects/aztec-nr/aztec/src/prelude.nr diff --git a/noir-projects/aztec-nr/aztec/src/lib.nr b/noir-projects/aztec-nr/aztec/src/lib.nr index 2ca0b281a5a..961e93cc397 100644 --- a/noir-projects/aztec-nr/aztec/src/lib.nr +++ b/noir-projects/aztec-nr/aztec/src/lib.nr @@ -8,5 +8,6 @@ mod log; mod messaging; mod note; mod oracle; +mod prelude; mod state_vars; use dep::protocol_types; diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr new file mode 100644 index 00000000000..9b49fe2bbc5 --- /dev/null +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -0,0 +1,20 @@ +use dep::protocol_types::{ + address::{ + AztecAddress, + EthAddress, + }, +}; +use crate::{ + state_vars::{ + map::Map, + public_state::PublicState, + singleton::Singleton, + immutable_singleton::ImmutableSingleton, + set::Set, + stable_public_state::StablePublicState, + }, + log::{ + emit_unencrypted_log, + emit_encrypted_log, + } +}; \ No newline at end of file diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 888e1da33db..baab6a23be4 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -5,7 +5,6 @@ use convert_case::{Case, Casing}; use iter_extended::vecmap; use noirc_frontend::macros_api::parse_program; use noirc_frontend::macros_api::FieldElement; -use noirc_frontend::macros_api::HirImportDirective; use noirc_frontend::macros_api::{ BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionDefinition, FunctionReturnType, FunctionVisibility, @@ -16,7 +15,7 @@ use noirc_frontend::macros_api::{ }; use noirc_frontend::macros_api::{CrateId, FileId}; use noirc_frontend::macros_api::{ - LocalModuleId, ModuleDefId, NodeInterner, SortedModule, StructId, + ModuleDefId, NodeInterner, SortedModule, StructId, }; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; use noirc_frontend::node_interner::{TraitId, TraitImplKind}; @@ -38,21 +37,11 @@ impl MacroProcessor for AztecMacro { &self, crate_id: &CrateId, context: &HirContext, - collected_imports: &mut Vec, - submodules: &[LocalModuleId], - ) -> Result<(), (MacroError, FileId)> { - if !has_aztec_dependency(crate_id, context) { - return Ok(()); - } - let def_map = context.def_map(crate_id).expect("Should have a def map"); - - let crate_root = def_map.root(); - inject_aztec_prelude(*crate_id, crate_root, collected_imports); - for submodule in submodules.iter() { - inject_aztec_prelude(*crate_id, *submodule, collected_imports); + ) -> Result, (MacroError, FileId)> { + if has_aztec_dependency(crate_id, context) { + return Ok(Some("aztec::prelude")) } - - Ok(()) + Ok(None) } fn process_typed_ast( @@ -281,6 +270,7 @@ fn transform( .map_err(|(err, file_id)| (err.into(), file_id))? { check_for_aztec_dependency(crate_id, context)?; + include_relevant_imports(&mut submodule.contents); } } Ok(ast) @@ -299,12 +289,9 @@ fn transform_hir( assign_storage_slots(crate_id, context) } -fn inject_aztec_prelude( - crate_id: CrateId, - crate_root: LocalModuleId, - collected_imports: &mut Vec, -) { - let (imports_ast, errors) = parse_program(aztec_prelude_source()); +/// Includes an import to the aztec library if it has not been included yet +fn include_relevant_imports(ast: &mut SortedModule) { + let (imports_ast, errors) = parse_program(aztec_import_path_source()); if !errors.is_empty() { dbg!(errors.clone()); } @@ -312,17 +299,14 @@ fn inject_aztec_prelude( let imports_ast = imports_ast.into_sorted(); - if !crate_id.is_stdlib() { - for import in imports_ast.imports { - collected_imports.insert( - 0, - HirImportDirective { - module_id: crate_root, - path: import.path, - alias: import.alias, - is_prelude: true, - }, - ); + for aztec_import in imports_ast.imports { + // Check if the aztec import already exists + let is_aztec_imported = + ast.imports.iter().any(|existing_import| existing_import.path == aztec_import.path); + + // If aztec is not imported, add the import at the beginning + if !is_aztec_imported { + ast.imports.insert(0, aztec_import); } } } @@ -1625,30 +1609,6 @@ fn event_signature(event: &StructType) -> String { format!("{}({})", event.name.0.contents, fields.join(",")) } -fn aztec_prelude_source() -> &'static str { - let aztec_imports = " - use dep::aztec; - - use dep::aztec::{ - protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, - }, - state_vars::{ - map::Map, - public_state::PublicState, - singleton::Singleton, - immutable_singleton::ImmutableSingleton, - set::Set, - stable_public_state::StablePublicState, - }, - log::{ - emit_unencrypted_log, - emit_encrypted_log, - } - }; - "; - aztec_imports -} +fn aztec_import_path_source() -> &'static str { + "use dep::aztec;" +} \ No newline at end of file diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 372ca67b9bc..ceb5478f662 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -257,22 +257,32 @@ impl DefCollector { // Add the current crate to the collection of DefMaps context.def_maps.insert(crate_id, def_collector.def_map); - inject_prelude(crate_id, context, crate_root, &mut def_collector.collected_imports); - for submodule in submodules.iter() { - inject_prelude(crate_id, context, *submodule, &mut def_collector.collected_imports); - } + let mut preludes = Vec::new(); + preludes.push("std::prelude"); for macro_processor in macro_processors.iter() { - macro_processor - .process_crate_prelude( - &crate_id, - context, - &mut def_collector.collected_imports, - &submodules, - ) - .unwrap_or_else(|(macro_err, file_id)| { - errors.push((macro_err.into(), file_id)); - }); + match macro_processor + .process_crate_prelude( + &crate_id, + context) { + Ok(Some(prelude)) => { + preludes.push(prelude); + } + Ok(None) => { + // Do nothing + }, + Err((error, file_id)) => { + let def_error = DefCollectorErrorKind::MacroError(error); + errors.push((def_error.into(), file_id)); + } + } + } + + for prelude in preludes { + inject_prelude(crate_id, context, crate_root, prelude, &mut def_collector.collected_imports); + for submodule in submodules.iter() { + inject_prelude(crate_id, context, *submodule, prelude, &mut def_collector.collected_imports); + } } // Resolve unresolved imports collected from the crate, one by one. @@ -394,9 +404,10 @@ fn inject_prelude( crate_id: CrateId, context: &Context, crate_root: LocalModuleId, + prelude_path: &str, collected_imports: &mut Vec, ) { - let segments: Vec<_> = "std::prelude" + let segments: Vec<_> = prelude_path .split("::") .map(|segment| crate::Ident::new(segment.into(), Span::default())) .collect(); @@ -410,7 +421,7 @@ fn inject_prelude( ModuleId { krate: crate_id, local_id: crate_root }, path, ) { - let module_id = module_def.as_module().expect("std::prelude should be a module"); + let module_id = module_def.as_module().unwrap_or_else(|| panic!("{prelude_path} should be a module")); let prelude = context.module(module_id).scope().names(); for path in prelude { diff --git a/noir/compiler/noirc_frontend/src/lib.rs b/noir/compiler/noirc_frontend/src/lib.rs index 425dcd2b6d2..1b2b290503d 100644 --- a/noir/compiler/noirc_frontend/src/lib.rs +++ b/noir/compiler/noirc_frontend/src/lib.rs @@ -53,8 +53,7 @@ pub mod macros_api { pub use crate::token::SecondaryAttribute; pub use crate::hir::def_collector::dc_crate::DefCollector as HirDefCollector; - pub use crate::hir::def_map::{LocalModuleId, ModuleDefId, ModuleId}; - pub use crate::hir::resolution::import::ImportDirective as HirImportDirective; + pub use crate::hir::def_map::{ModuleDefId, ModuleId}; pub use crate::hir::resolution::path_resolver; pub use crate::{ hir::Context as HirContext, BlockExpression, CallExpression, CastExpression, Distinctness, @@ -83,9 +82,7 @@ pub mod macros_api { &self, crate_id: &CrateId, context: &HirContext, - def_collector: &mut Vec, - submodules: &[LocalModuleId], - ) -> Result<(), (MacroError, FileId)>; + ) -> Result, (MacroError, FileId)>; /// Function to manipulate the AST after type checking has been completed. /// The AST after type checking has been done is called the HIR. fn process_typed_ast( diff --git a/noir/noirc_macros/src/lib.rs b/noir/noirc_macros/src/lib.rs index bad0a49e04a..d9c42a3e8b0 100644 --- a/noir/noirc_macros/src/lib.rs +++ b/noir/noirc_macros/src/lib.rs @@ -1,7 +1,5 @@ use noirc_frontend::macros_api::parse_program; use noirc_frontend::macros_api::HirContext; -use noirc_frontend::macros_api::HirImportDirective; -use noirc_frontend::macros_api::LocalModuleId; use noirc_frontend::macros_api::SortedModule; use noirc_frontend::macros_api::{CrateId, FileId}; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; @@ -22,10 +20,8 @@ impl MacroProcessor for AssertMessageMacro { &self, _crate_id: &CrateId, _context: &HirContext, - _collected_imports: &mut Vec, - _submodules: &[LocalModuleId], - ) -> Result<(), (MacroError, FileId)> { - Ok(()) + ) -> Result, (MacroError, FileId)> { + Ok(None) } // This macro does not need to process any information after name resolution From 9d4844f016aa304dbcfe68b03be1a31e07c2851d Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 18:18:06 +0000 Subject: [PATCH 20/33] cargo fmt --- noir/aztec_macros/src/lib.rs | 8 ++--- .../src/hir/def_collector/dc_crate.rs | 31 +++++++++++++------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index baab6a23be4..024f5d6e66c 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -14,10 +14,8 @@ use noirc_frontend::macros_api::{ StructType, Type, TypeImpl, UnaryOp, UnresolvedType, UnresolvedTypeData, Visibility, }; use noirc_frontend::macros_api::{CrateId, FileId}; -use noirc_frontend::macros_api::{ - ModuleDefId, NodeInterner, SortedModule, StructId, -}; use noirc_frontend::macros_api::{MacroError, MacroProcessor}; +use noirc_frontend::macros_api::{ModuleDefId, NodeInterner, SortedModule, StructId}; use noirc_frontend::node_interner::{TraitId, TraitImplKind}; use noirc_frontend::Lambda; @@ -39,7 +37,7 @@ impl MacroProcessor for AztecMacro { context: &HirContext, ) -> Result, (MacroError, FileId)> { if has_aztec_dependency(crate_id, context) { - return Ok(Some("aztec::prelude")) + return Ok(Some("aztec::prelude")); } Ok(None) } @@ -1611,4 +1609,4 @@ fn event_signature(event: &StructType) -> String { fn aztec_import_path_source() -> &'static str { "use dep::aztec;" -} \ No newline at end of file +} diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index ceb5478f662..a7b7732beed 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -261,16 +261,13 @@ impl DefCollector { preludes.push("std::prelude"); for macro_processor in macro_processors.iter() { - match macro_processor - .process_crate_prelude( - &crate_id, - context) { + match macro_processor.process_crate_prelude(&crate_id, context) { Ok(Some(prelude)) => { preludes.push(prelude); } - Ok(None) => { - // Do nothing - }, + Ok(None) => { + // Do nothing + } Err((error, file_id)) => { let def_error = DefCollectorErrorKind::MacroError(error); errors.push((def_error.into(), file_id)); @@ -279,9 +276,21 @@ impl DefCollector { } for prelude in preludes { - inject_prelude(crate_id, context, crate_root, prelude, &mut def_collector.collected_imports); + inject_prelude( + crate_id, + context, + crate_root, + prelude, + &mut def_collector.collected_imports, + ); for submodule in submodules.iter() { - inject_prelude(crate_id, context, *submodule, prelude, &mut def_collector.collected_imports); + inject_prelude( + crate_id, + context, + *submodule, + prelude, + &mut def_collector.collected_imports, + ); } } @@ -421,7 +430,9 @@ fn inject_prelude( ModuleId { krate: crate_id, local_id: crate_root }, path, ) { - let module_id = module_def.as_module().unwrap_or_else(|| panic!("{prelude_path} should be a module")); + let module_id = module_def + .as_module() + .unwrap_or_else(|| panic!("{prelude_path} should be a module")); let prelude = context.module(module_id).scope().names(); for path in prelude { From f8467e745102e4d7d11d154bd3727dd0906efa1b Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 18:26:09 +0000 Subject: [PATCH 21/33] rename process_crate_prelude to fetch_crate_prelude --- noir/aztec_macros/src/lib.rs | 2 +- .../compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs | 4 +++- noir/compiler/noirc_frontend/src/lib.rs | 2 +- noir/noirc_macros/src/lib.rs | 2 +- .../execution_success/assert_statement/src/main.nr | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 024f5d6e66c..9bca7f43295 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -31,7 +31,7 @@ impl MacroProcessor for AztecMacro { transform(ast, crate_id, context) } - fn process_crate_prelude( + fn fetch_crate_prelude( &self, crate_id: &CrateId, context: &HirContext, diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index a7b7732beed..17a7ac268b5 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -261,7 +261,9 @@ impl DefCollector { preludes.push("std::prelude"); for macro_processor in macro_processors.iter() { - match macro_processor.process_crate_prelude(&crate_id, context) { + // Aside from the stdlib prelude, check whether the crate we are processing has dependencies + // which supply their own prelude and add it to the list of preludes to be injected. + match macro_processor.fetch_crate_prelude(&crate_id, context) { Ok(Some(prelude)) => { preludes.push(prelude); } diff --git a/noir/compiler/noirc_frontend/src/lib.rs b/noir/compiler/noirc_frontend/src/lib.rs index 1b2b290503d..75e7e95cef6 100644 --- a/noir/compiler/noirc_frontend/src/lib.rs +++ b/noir/compiler/noirc_frontend/src/lib.rs @@ -78,7 +78,7 @@ pub mod macros_api { ) -> Result; /// Function to manipulate the crate definition before type checking has been completed. /// This is needed to process module declarations as the original AST will not yet have them. - fn process_crate_prelude( + fn fetch_crate_prelude( &self, crate_id: &CrateId, context: &HirContext, diff --git a/noir/noirc_macros/src/lib.rs b/noir/noirc_macros/src/lib.rs index d9c42a3e8b0..08978e523d7 100644 --- a/noir/noirc_macros/src/lib.rs +++ b/noir/noirc_macros/src/lib.rs @@ -16,7 +16,7 @@ impl MacroProcessor for AssertMessageMacro { transform(ast, crate_id) } - fn process_crate_prelude( + fn fetch_crate_prelude( &self, _crate_id: &CrateId, _context: &HirContext, diff --git a/noir/test_programs/execution_success/assert_statement/src/main.nr b/noir/test_programs/execution_success/assert_statement/src/main.nr index 01e1353253d..2646a0b85c2 100644 --- a/noir/test_programs/execution_success/assert_statement/src/main.nr +++ b/noir/test_programs/execution_success/assert_statement/src/main.nr @@ -1,7 +1,7 @@ // Tests a very simple program. // // The features being tested is assertion -fn main(x: Field, y: pub Field) { +fn main(x: Field, y: pub Field) { assert(x == y, "x and y are not equal"); assert_eq(x, y, "x and y are not equal"); } From 84b2c24f9a1fb4ff288bcdaad443e04cb7c1e620 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 15 Feb 2024 18:28:55 +0000 Subject: [PATCH 22/33] add note imports to prelude --- noir-projects/aztec-nr/aztec/src/prelude.nr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index 9b49fe2bbc5..0ccb8cf2cba 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -16,5 +16,12 @@ use crate::{ log::{ emit_unencrypted_log, emit_encrypted_log, + }, + context::PrivateContext, + note::{ + note_header::NoteHeader, + note_interface::NoteInterface, + note_getter_options::NoteGetterOptions, + note_viewer_options::NoteViewerOptions, } }; \ No newline at end of file From 187b17e3a5ab2dc9bad28f420dfd827b74f627d2 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 16 Feb 2024 16:07:34 +0000 Subject: [PATCH 23/33] remove more imports due to prelude --- boxes/token/src/contracts/src/main.nr | 12 ++---------- .../token/src/contracts/src/types/balances_map.nr | 14 ++------------ boxes/token/src/contracts/src/types/token_note.nr | 13 ++----------- .../src/contracts/src/types/transparent_note.nr | 6 +----- .../contracts/benchmarking_contract/src/main.nr | 6 +++--- .../contracts/card_game_contract/src/main.nr | 6 +++--- .../contracts/counter_contract/src/main.nr | 5 +---- .../contracts/docs_example_contract/src/main.nr | 4 +--- .../docs_example_contract/src/types/card_note.nr | 6 +++--- .../easy_private_token_contract/src/main.nr | 5 +---- .../src/ecdsa_public_key_note.nr | 5 ++--- .../contracts/ecdsa_account_contract/src/main.nr | 5 ++--- .../contracts/escrow_contract/src/main.nr | 6 +++--- .../inclusion_proofs_contract/src/main.nr | 4 ++-- .../pending_commitments_contract/src/main.nr | 7 +++---- .../contracts/schnorr_account_contract/src/main.nr | 6 ++---- .../src/public_key_note.nr | 4 ++-- .../contracts/slow_tree_contract/src/main.nr | 5 ++--- .../contracts/stateful_test_contract/src/main.nr | 4 ++-- .../contracts/test_contract/src/main.nr | 11 +++-------- .../contracts/token_blacklist_contract/src/main.nr | 6 +----- .../src/types/balances_map.nr | 8 +++----- .../src/types/token_note.nr | 6 +++--- .../src/types/transparent_note.nr | 2 +- .../contracts/token_contract/src/main.nr | 2 -- .../token_contract/src/types/balances_map.nr | 8 +++----- .../token_contract/src/types/token_note.nr | 6 +++--- .../token_contract/src/types/transparent_note.nr | 2 +- 28 files changed, 57 insertions(+), 117 deletions(-) diff --git a/boxes/token/src/contracts/src/main.nr b/boxes/token/src/contracts/src/main.nr index f48b637ef6d..386d26ede3e 100644 --- a/boxes/token/src/contracts/src/main.nr +++ b/boxes/token/src/contracts/src/main.nr @@ -17,17 +17,9 @@ contract Token { use dep::compressed_string::FieldCompressedString; use dep::aztec::{ - note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, + note::utils as note_utils, hash::{compute_secret_hash}, - state_vars::{map::Map, public_state::PublicState, stable_public_state::StablePublicState, set::Set}, - protocol_types::{ - abis::function_selector::FunctionSelector, - address::AztecAddress - } + protocol_types::abis::function_selector::FunctionSelector, }; // docs:start:import_authwit diff --git a/boxes/token/src/contracts/src/types/balances_map.nr b/boxes/token/src/contracts/src/types/balances_map.nr index 8452ba327a7..78b4ac761ea 100644 --- a/boxes/token/src/contracts/src/types/balances_map.nr +++ b/boxes/token/src/contracts/src/types/balances_map.nr @@ -2,20 +2,10 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; use dep::aztec::{ context::Context, - protocol_types::{ - address::AztecAddress, - constants::MAX_READ_REQUESTS_PER_CALL, - }, - state_vars::{ - set::Set, - map::Map - }, + protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::{ note_getter::view_notes, - note_getter_options::{NoteGetterOptions, SortOrder}, - note_viewer_options::NoteViewerOptions, - note_header::NoteHeader, - note_interface::NoteInterface, + note_getter_options::SortOrder, } }; use crate::types::token_note::{TokenNote, OwnedNote}; diff --git a/boxes/token/src/contracts/src/types/token_note.nr b/boxes/token/src/contracts/src/types/token_note.nr index 7dfe681f395..dce6a48851f 100644 --- a/boxes/token/src/contracts/src/types/token_note.nr +++ b/boxes/token/src/contracts/src/types/token_note.nr @@ -1,16 +1,7 @@ use dep::aztec::{ - protocol_types::{ - address::AztecAddress, - constants::MAX_READ_REQUESTS_PER_CALL - }, - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, + protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, + note::utils::compute_note_hash_for_consumption, context::PrivateContext, - state_vars::set::Set, - log::emit_encrypted_log, hash::pedersen_hash, }; use dep::aztec::oracle::{ diff --git a/boxes/token/src/contracts/src/types/transparent_note.nr b/boxes/token/src/contracts/src/types/transparent_note.nr index 6ac87c783fb..7341ca2aae3 100644 --- a/boxes/token/src/contracts/src/types/transparent_note.nr +++ b/boxes/token/src/contracts/src/types/transparent_note.nr @@ -1,10 +1,6 @@ // docs:start:token_types_all use dep::aztec::{ - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - utils::compute_note_hash_for_consumption, - }, + note::utils::compute_note_hash_for_consumption, hash::{compute_secret_hash, pedersen_hash}, context::PrivateContext, }; diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 1fcebb24bae..7f507fdc699 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -8,9 +8,9 @@ contract Benchmarking { use dep::value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector}, - context::{Context}, - note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, + protocol_types::abis::function_selector::FunctionSelector, + context::Context, + note::utils as note_utils, }; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr index ef3b161cfdd..8bf70f48562 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr @@ -2,13 +2,13 @@ mod cards; mod game; contract CardGame { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress, constants::MAX_NOTES_PER_PAGE}; - use dep::aztec::{context::Context, hash::pedersen_hash, state_vars::{map::Map, public_state::PublicState}}; + use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, constants::MAX_NOTES_PER_PAGE}; + use dep::aztec::{context::Context, hash::pedersen_hash}; use dep::std::option::Option; use dep::value_note::{balance_utils, value_note::{ValueNote, VALUE_NOTE_LEN}}; - use dep::aztec::note::{note_header::NoteHeader, utils as note_utils}; + use dep::aztec::note::utils as note_utils; use crate::cards::{PACK_CARDS, Deck, Card, get_pack_cards, compute_deck_strength}; use crate::game::{NUMBER_OF_PLAYERS, NUMBER_OF_CARDS_DECK, PLAYABLE_CARDS, PlayerEntry, Game, GAME_SERIALIZED_LEN}; diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index a20865ea98a..fbd2b81398d 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -2,10 +2,7 @@ contract Counter { // docs:start:imports use dep::aztec::{ context::{PrivateContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, + note::utils as note_utils, }; use dep::value_note::{ balance_utils, diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 1bd0473c470..6dbbcfb8cce 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -18,9 +18,7 @@ contract DocsExample { }; use dep::aztec::{ note::{ - note_header::NoteHeader, - note_getter_options::{NoteGetterOptions, Comparator}, - note_viewer_options::{NoteViewerOptions}, + note_getter_options::Comparator, utils as note_utils, }, context::{PrivateContext, PublicContext, Context}, diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index 356e6421c21..e57aaced5c1 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -1,8 +1,8 @@ use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, + note::utils::compute_note_hash_for_consumption, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - log::emit_encrypted_log, hash::pedersen_hash, context::PrivateContext, - protocol_types::{address::AztecAddress, traits::Empty} + hash::pedersen_hash, context::PrivateContext, + protocol_types::traits::Empty, }; // Shows how to create a custom note diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index d933689ab51..97759fb9ad9 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -2,10 +2,7 @@ contract EasyPrivateToken { use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, + note::utils as note_utils, }; use dep::std::option::Option; use dep::value_note::{ diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 1ac71be5690..91998dab51e 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -1,8 +1,7 @@ -use dep::aztec::protocol_types::address::AztecAddress; use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, + note::utils::compute_note_hash_for_consumption, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - log::emit_encrypted_log, hash::pedersen_hash, context::PrivateContext + hash::pedersen_hash, context::PrivateContext }; global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5; diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index dfe804c0fa3..590eb506683 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -3,13 +3,12 @@ mod ecdsa_public_key_note; // Account contract that uses ECDSA signatures for authentication on the same curve as Ethereum. // The signing key is stored in an immutable private note and should be different from the signing key. contract EcdsaAccount { - use dep::aztec::protocol_types::{abis::call_context::CallContext, address::AztecAddress}; + use dep::aztec::protocol_types::abis::call_context::CallContext; use dep::std; use dep::std::option::Option; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, - note::{note_header::NoteHeader, utils as note_utils}, oracle::get_public_key::get_public_key, - state_vars::immutable_singleton::ImmutableSingleton + note::utils as note_utils, oracle::get_public_key::get_public_key, }; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index 1bc3de696df..d155042084e 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -2,12 +2,12 @@ contract Escrow { use dep::std::option::Option; - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; + use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, - note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader, utils as note_utils}, - oracle::get_public_key::get_public_key, state_vars::set::Set + note::utils as note_utils, + oracle::get_public_key::get_public_key, }; use dep::address_note::address_note::{AddressNote, ADDRESS_NOTE_LEN}; diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 36a1d4bf4e6..446408e64be 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -7,8 +7,8 @@ contract InclusionProofs { use dep::aztec::{ context::Context, note::{ - note_getter_options::NoteGetterOptions, note_getter_options::NoteStatus, - note_header::NoteHeader, utils as note_utils + note_getter_options::NoteStatus, + utils as note_utils, } }; // docs:start:imports diff --git a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr index 6c09247b61a..6e8475d6663 100644 --- a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr @@ -7,11 +7,10 @@ contract PendingCommitments { use dep::std::option::Option; use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, log::emit_encrypted_log, - note::{note_getter::NoteGetterOptions, note_header::NoteHeader, utils as note_utils}, - state_vars::{map::Map, set::Set} + context::{PrivateContext, PublicContext, Context}, + note::utils as note_utils, }; - use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector}; + use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; struct Storage { balances: Map>, diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index 9eb15c3f691..4d2d21ea9b9 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -6,11 +6,9 @@ contract SchnorrAccount { use dep::std; use dep::std::option::Option; - use dep::aztec::protocol_types::address::AztecAddress; - use dep::aztec::{ - context::{PrivateContext, Context}, note::{note_header::NoteHeader, utils as note_utils}, - oracle::get_public_key::get_public_key, state_vars::immutable_singleton::ImmutableSingleton + context::{PrivateContext, Context}, note::utils as note_utils, + oracle::get_public_key::get_public_key, }; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index d552a44f4a0..ca78fc56590 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -1,8 +1,8 @@ use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, + note::utils::compute_note_hash_for_consumption, hash::pedersen_hash, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - log::emit_encrypted_log, context::PrivateContext, protocol_types::{address::AztecAddress} + context::PrivateContext, }; global PUBLIC_KEY_NOTE_LEN: Field = 3; diff --git a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr index b8a0d2525d8..af92cf58d4e 100644 --- a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr @@ -6,13 +6,12 @@ mod types; // https://github.com/AztecProtocol/aztec-packages/issues/1291 // This is made as a separate contract for one thing mainly. Making it simpler to use. contract SlowTree { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; + use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::std::option::Option; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, - note::{note_header::NoteHeader, utils as note_utils}, - state_vars::{map::Map, public_state::PublicState, set::Set}, + note::utils as note_utils, protocol_types::type_serialization::FIELD_SERIALIZED_LEN }; use dep::slow_updates_tree::slow_map::{SlowMap, Leaf, SlowUpdateProof, compute_merkle_root, deserialize_slow_update_proof}; diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 15057c2c720..92424a6ba54 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -1,11 +1,11 @@ // A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests. contract StatefulTest { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector}; + use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::std::option::Option; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, - note::{note_header::NoteHeader, utils as note_utils}, + note::utils as note_utils, }; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index b0c081ead82..a5c53521164 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -3,23 +3,18 @@ contract Test { use dep::std::option::Option; use dep::aztec::protocol_types::{ abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, - address::{AztecAddress, EthAddress}, constants::{MAX_READ_REQUESTS_PER_CALL, MAX_NOTES_PER_PAGE}, hash::hash_args }; - // docs:start:unencrypted_import - use dep::aztec::log::emit_unencrypted_log; - // docs:end:unencrypted_import use dep::aztec::{ context::{Context, inputs::private_context_inputs::PrivateContextInputs}, hash::pedersen_hash, context::PrivateContext, note::{ - note_header::NoteHeader, utils as note_utils, lifecycle::{create_note, destroy_note}, - note_getter::{get_notes, view_notes}, note_getter_options::{NoteGetterOptions, NoteStatus}, - note_viewer_options::NoteViewerOptions + utils as note_utils, lifecycle::{create_note, destroy_note}, + note_getter::{get_notes, view_notes}, note_getter_options::NoteStatus, }, oracle::{get_public_key::get_public_key as get_public_key_oracle, context::get_portal_address, rand::rand}, - state_vars::immutable_singleton::ImmutableSingleton, log::emit_unencrypted_log_from_private + log::emit_unencrypted_log_from_private }; use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash}; use dep::field_note::field_note::FieldNote; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index a2a4979693f..ee318f17395 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -21,11 +21,7 @@ contract TokenBlacklist { abis::function_selector::FunctionSelector, }; use dep::aztec::{ - note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, - utils as note_utils, - }, + note::utils as note_utils, context::{PrivateContext, PublicContext, Context}, hash::{compute_secret_hash}, }; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index cbc423cc4ff..9090482a7ae 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -1,12 +1,10 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; use dep::aztec::{ - context::Context, protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}, - state_vars::{set::Set, map::Map}, + context::Context, protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::{ - note_getter::view_notes, note_getter_options::{NoteGetterOptions, SortOrder}, - note_viewer_options::NoteViewerOptions, note_header::NoteHeader, note_interface::NoteInterface -} + note_getter::view_notes, note_getter_options::SortOrder, + } }; use crate::types::token_note::{TokenNote, OwnedNote}; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index a7e2a45f1ec..23b1d899bb8 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ - protocol_types::{address::AztecAddress, constants::{MAX_READ_REQUESTS_PER_CALL}}, - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, - context::PrivateContext, state_vars::set::Set, log::emit_encrypted_log, hash::pedersen_hash + protocol_types::constants::{MAX_READ_REQUESTS_PER_CALL}, + note::utils::compute_note_hash_for_consumption, + context::PrivateContext, hash::pedersen_hash }; use dep::aztec::oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}; use dep::safe_math::SafeU120; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index a444d27df26..221016d7c3f 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -1,6 +1,6 @@ // docs:start:token_types_all use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, + note::utils::compute_note_hash_for_consumption, hash::{compute_secret_hash, pedersen_hash}, context::PrivateContext }; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index acf2306fdf3..93bb2679f10 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -18,8 +18,6 @@ contract Token { use dep::aztec::{ note::{ - note_getter_options::NoteGetterOptions, - note_header::NoteHeader, utils as note_utils, }, hash::{compute_secret_hash}, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr index a47fdce4f3f..9153fb38ec5 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr @@ -2,12 +2,10 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; use dep::aztec::{ context::{PrivateContext, PublicContext, Context}, hash::pedersen_hash, - protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}, - state_vars::{set::Set, map::Map}, + protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::{ - note_getter::view_notes, note_getter_options::{NoteGetterOptions, SortOrder}, - note_viewer_options::NoteViewerOptions, note_header::NoteHeader, note_interface::NoteInterface -} + note_getter::view_notes, note_getter_options::SortOrder, + } }; use crate::types::token_note::{TokenNote, OwnedNote}; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index 2be2ecb3e00..a0d86534155 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ - protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}, - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, - context::PrivateContext, state_vars::set::Set, log::emit_encrypted_log, hash::pedersen_hash + protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, + note::utils::compute_note_hash_for_consumption, + context::PrivateContext, hash::pedersen_hash }; use dep::aztec::oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}; use dep::safe_math::SafeU120; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index a444d27df26..221016d7c3f 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -1,6 +1,6 @@ // docs:start:token_types_all use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, + note::utils::compute_note_hash_for_consumption, hash::{compute_secret_hash, pedersen_hash}, context::PrivateContext }; From 701519be6dc58e6ac6efbe8185884ccc9c42cfcf Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 16 Feb 2024 17:31:12 +0000 Subject: [PATCH 24/33] remove PrivateContext import --- boxes/token/src/contracts/src/types/token_note.nr | 1 - boxes/token/src/contracts/src/types/transparent_note.nr | 1 - .../noir-contracts/contracts/card_game_contract/src/cards.nr | 2 +- .../noir-contracts/contracts/child_contract/src/main.nr | 2 +- .../noir-contracts/contracts/counter_contract/src/main.nr | 2 +- .../contracts/docs_example_contract/src/main.nr | 2 +- .../contracts/docs_example_contract/src/types/card_note.nr | 2 +- .../contracts/easy_private_token_contract/src/main.nr | 2 +- .../contracts/easy_private_voting_contract/src/main.nr | 4 ++-- .../ecdsa_account_contract/src/ecdsa_public_key_note.nr | 2 +- .../contracts/ecdsa_account_contract/src/main.nr | 2 +- .../noir-contracts/contracts/escrow_contract/src/main.nr | 2 +- .../contracts/lending_contract/src/interfaces.nr | 1 - .../contracts/pending_commitments_contract/src/main.nr | 2 +- .../contracts/schnorr_account_contract/src/main.nr | 2 +- .../contracts/schnorr_account_contract/src/public_key_note.nr | 1 - .../contracts/schnorr_hardcoded_account_contract/src/main.nr | 1 - .../contracts/schnorr_single_key_account_contract/src/main.nr | 2 +- .../noir-contracts/contracts/slow_tree_contract/src/main.nr | 2 +- .../contracts/stateful_test_contract/src/main.nr | 2 +- .../noir-contracts/contracts/test_contract/src/interface.nr | 4 ++-- .../noir-contracts/contracts/test_contract/src/main.nr | 1 - .../contracts/token_blacklist_contract/src/interfaces.nr | 4 ++-- .../contracts/token_blacklist_contract/src/main.nr | 2 +- .../token_blacklist_contract/src/types/token_note.nr | 2 +- .../token_blacklist_contract/src/types/transparent_note.nr | 2 +- .../contracts/token_bridge_contract/src/token_interface.nr | 4 ++-- .../contracts/token_contract/src/types/balances_map.nr | 2 +- .../contracts/token_contract/src/types/token_note.nr | 2 +- .../contracts/token_contract/src/types/transparent_note.nr | 2 +- .../contracts/uniswap_contract/src/interfaces.nr | 4 ++-- 31 files changed, 30 insertions(+), 36 deletions(-) diff --git a/boxes/token/src/contracts/src/types/token_note.nr b/boxes/token/src/contracts/src/types/token_note.nr index dce6a48851f..c3f33082955 100644 --- a/boxes/token/src/contracts/src/types/token_note.nr +++ b/boxes/token/src/contracts/src/types/token_note.nr @@ -1,7 +1,6 @@ use dep::aztec::{ protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::utils::compute_note_hash_for_consumption, - context::PrivateContext, hash::pedersen_hash, }; use dep::aztec::oracle::{ diff --git a/boxes/token/src/contracts/src/types/transparent_note.nr b/boxes/token/src/contracts/src/types/transparent_note.nr index 7341ca2aae3..f0713d94a5c 100644 --- a/boxes/token/src/contracts/src/types/transparent_note.nr +++ b/boxes/token/src/contracts/src/types/transparent_note.nr @@ -2,7 +2,6 @@ use dep::aztec::{ note::utils::compute_note_hash_for_consumption, hash::{compute_secret_hash, pedersen_hash}, - context::PrivateContext, }; global TRANSPARENT_NOTE_LEN: Field = 2; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index f2978489e47..a9ffb519dca 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -6,7 +6,7 @@ use dep::aztec::{ MAX_READ_REQUESTS_PER_CALL, }, }, - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::{ note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index 6305b118317..7363cd878a4 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -3,7 +3,7 @@ contract Child { use dep::std::option::Option; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, log::emit_unencrypted_log, state_vars::{ public_state::PublicState, diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index fbd2b81398d..c6da56f6361 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -1,7 +1,7 @@ contract Counter { // docs:start:imports use dep::aztec::{ - context::{PrivateContext, Context}, + context::Context, note::utils as note_utils, }; use dep::value_note::{ diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 6dbbcfb8cce..324f31f7e64 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -21,7 +21,7 @@ contract DocsExample { note_getter_options::Comparator, utils as note_utils, }, - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, }; // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index e57aaced5c1..2fbc87fd6da 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ note::utils::compute_note_hash_for_consumption, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - hash::pedersen_hash, context::PrivateContext, + hash::pedersen_hash, protocol_types::traits::Empty, }; diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index 97759fb9ad9..034b82865a4 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -1,7 +1,7 @@ // docs:start:easy_private_token_contract contract EasyPrivateToken { use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, }; use dep::std::option::Option; diff --git a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index ea919f4eb7d..4f8fa0fd242 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -1,8 +1,8 @@ contract EasyPrivateVoting { // docs:start:imports use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, - context::{PrivateContext, Context}, state_vars::{map::Map, public_state::PublicState} + protocol_types::abis::function_selector::FunctionSelector, + context::Context, }; // docs:end:imports // docs:start:storage_struct diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 91998dab51e..bf17764b156 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ note::utils::compute_note_hash_for_consumption, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - hash::pedersen_hash, context::PrivateContext + hash::pedersen_hash, }; global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5; diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index 590eb506683..53f3ef36057 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -7,7 +7,7 @@ contract EcdsaAccount { use dep::std; use dep::std::option::Option; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, oracle::get_public_key::get_public_key, }; use dep::authwit::{ diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index d155042084e..f0478fb8836 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -5,7 +5,7 @@ contract Escrow { use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, oracle::get_public_key::get_public_key, }; diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr index b298cb635ca..ffa11736046 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr @@ -1,5 +1,4 @@ use dep::aztec::context::{ - PrivateContext, PublicContext }; use crate::asset::Asset; diff --git a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr index 6e8475d6663..15a1b90cf37 100644 --- a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr @@ -7,7 +7,7 @@ contract PendingCommitments { use dep::std::option::Option; use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, }; use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index 4d2d21ea9b9..af18899dc37 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -7,7 +7,7 @@ contract SchnorrAccount { use dep::std::option::Option; use dep::aztec::{ - context::{PrivateContext, Context}, note::utils as note_utils, + context::Context, note::utils as note_utils, oracle::get_public_key::get_public_key, }; use dep::authwit::{ diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index ca78fc56590..b01cab8ae57 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -2,7 +2,6 @@ use dep::aztec::{ note::utils::compute_note_hash_for_consumption, hash::pedersen_hash, oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - context::PrivateContext, }; global PUBLIC_KEY_NOTE_LEN: Field = 3; diff --git a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index c5293bac24c..7d451e040b1 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -2,7 +2,6 @@ // Account contract that uses Schnorr signatures for authentication using a hardcoded public key. contract SchnorrHardcodedAccount { use dep::std; - use dep::aztec::context::PrivateContext; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr index f01b3237bfe..f4c532a402a 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr @@ -3,7 +3,7 @@ mod auth_oracle; contract SchnorrSingleKeyAccount { use dep::std::{option::Option}; - use dep::aztec::context::{PrivateContext, PublicContext, Context}; + use dep::aztec::context::{PublicContext, Context}; use dep::authwit::{entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions}; diff --git a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr index af92cf58d4e..9b37fe7024c 100644 --- a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr @@ -10,7 +10,7 @@ contract SlowTree { use dep::std::option::Option; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, protocol_types::type_serialization::FIELD_SERIALIZED_LEN }; diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 92424a6ba54..ed06e0fc620 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -4,7 +4,7 @@ contract StatefulTest { use dep::std::option::Option; use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, note::utils as note_utils, }; diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr b/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr index 6af1d50e42e..97120144a36 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr @@ -1,8 +1,8 @@ /* Autogenerated file, do not edit! */ use dep::std; -use dep::aztec::context::{PrivateContext, PublicContext}; -use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector, constants::RETURN_VALUES_LENGTH}; +use dep::aztec::context::PublicContext; +use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, constants::RETURN_VALUES_LENGTH}; struct AStructTestCodeGenStruct { amount: Field, diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index a5c53521164..6508bf5e4d5 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -8,7 +8,6 @@ contract Test { use dep::aztec::{ context::{Context, inputs::private_context_inputs::PrivateContextInputs}, hash::pedersen_hash, - context::PrivateContext, note::{ utils as note_utils, lifecycle::{create_note, destroy_note}, note_getter::{get_notes, view_notes}, note_getter_options::NoteStatus, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr index 3f4bf9983be..ec786a73d1f 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr @@ -1,6 +1,6 @@ -use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; +use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; -use dep::aztec::context::{PrivateContext, PublicContext, Context}; +use dep::aztec::context::{PublicContext, Context}; struct SlowMap { address: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index ee318f17395..ba95a31ba17 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -22,7 +22,7 @@ contract TokenBlacklist { }; use dep::aztec::{ note::utils as note_utils, - context::{PrivateContext, PublicContext, Context}, + context::{PublicContext, Context}, hash::{compute_secret_hash}, }; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 23b1d899bb8..54f16870ba7 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ protocol_types::constants::{MAX_READ_REQUESTS_PER_CALL}, note::utils::compute_note_hash_for_consumption, - context::PrivateContext, hash::pedersen_hash + hash::pedersen_hash }; use dep::aztec::oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}; use dep::safe_math::SafeU120; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 221016d7c3f..4bacb567420 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -1,7 +1,7 @@ // docs:start:token_types_all use dep::aztec::{ note::utils::compute_note_hash_for_consumption, - hash::{compute_secret_hash, pedersen_hash}, context::PrivateContext + hash::{compute_secret_hash, pedersen_hash}, }; global TRANSPARENT_NOTE_LEN: Field = 2; diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr index 4f0ef61e978..1b43190ac8b 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr @@ -1,6 +1,6 @@ // docs:start:token_bridge_token_interface -use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; -use dep::aztec::{context::{PrivateContext, PublicContext, Context}}; +use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; +use dep::aztec::{context::{PublicContext, Context}}; struct Token { address: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr index 9153fb38ec5..4465b5560a7 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr @@ -1,7 +1,7 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, hash::pedersen_hash, + context::{PublicContext, Context}, hash::pedersen_hash, protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::{ note_getter::view_notes, note_getter_options::SortOrder, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index a0d86534155..debc77adfe8 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,7 +1,7 @@ use dep::aztec::{ protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, note::utils::compute_note_hash_for_consumption, - context::PrivateContext, hash::pedersen_hash + hash::pedersen_hash }; use dep::aztec::oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}; use dep::safe_math::SafeU120; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 221016d7c3f..4bacb567420 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -1,7 +1,7 @@ // docs:start:token_types_all use dep::aztec::{ note::utils::compute_note_hash_for_consumption, - hash::{compute_secret_hash, pedersen_hash}, context::PrivateContext + hash::{compute_secret_hash, pedersen_hash}, }; global TRANSPARENT_NOTE_LEN: Field = 2; diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr index f70a2f93c38..d532a0c5cd5 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr @@ -1,6 +1,6 @@ // docs:start:interfaces -use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; -use dep::aztec::{context::{PrivateContext, PublicContext}}; +use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; +use dep::aztec::context::PublicContext; struct Token { address: AztecAddress, From 9b919f6e952b806b5f1ec75aee559fcaf0b35f33 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Fri, 16 Feb 2024 18:21:18 +0000 Subject: [PATCH 25/33] dont edit test_contract autogen file --- .../noir-contracts/contracts/test_contract/src/interface.nr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr b/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr index 97120144a36..6af1d50e42e 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/interface.nr @@ -1,8 +1,8 @@ /* Autogenerated file, do not edit! */ use dep::std; -use dep::aztec::context::PublicContext; -use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, constants::RETURN_VALUES_LENGTH}; +use dep::aztec::context::{PrivateContext, PublicContext}; +use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector, constants::RETURN_VALUES_LENGTH}; struct AStructTestCodeGenStruct { amount: Field, From 3ccd7dc27c8e2e60dd098a7ca6acd0fcfafb3bf2 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Mon, 19 Feb 2024 11:27:23 +0000 Subject: [PATCH 26/33] remove unused method --- noir/compiler/noirc_frontend/src/hir/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/noir/compiler/noirc_frontend/src/hir/mod.rs b/noir/compiler/noirc_frontend/src/hir/mod.rs index 7f1a6610ad5..4d3800f1a50 100644 --- a/noir/compiler/noirc_frontend/src/hir/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/mod.rs @@ -91,10 +91,6 @@ impl Context<'_, '_> { self.def_maps.get(crate_id) } - pub fn def_maps(&self) -> &BTreeMap { - &self.def_maps - } - /// Return the CrateId for each crate that has been compiled /// successfully pub fn crates(&self) -> impl Iterator + '_ { From 359f25958a9d402a91921e501879e812da1cb20f Mon Sep 17 00:00:00 2001 From: vezenovm Date: Mon, 19 Feb 2024 15:40:06 +0000 Subject: [PATCH 27/33] cargo fmt --- noir/aztec_macros/src/lib.rs | 95 +++++++++++++------ .../src/hir/def_collector/dc_crate.rs | 15 ++- noir/noirc_macros/src/lib.rs | 2 +- 3 files changed, 77 insertions(+), 35 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 9751fee4ceb..3aa4c90990f 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -3,8 +3,10 @@ use std::vec; use convert_case::{Case, Casing}; use iter_extended::vecmap; +use noirc_errors::Location; use noirc_frontend::hir::def_collector::dc_crate::{UnresolvedFunctions, UnresolvedTraitImpl}; use noirc_frontend::hir::def_map::{LocalModuleId, ModuleId}; +use noirc_frontend::macros_api::parse_program; use noirc_frontend::macros_api::FieldElement; use noirc_frontend::macros_api::{ BlockExpression, CallExpression, CastExpression, Distinctness, Expression, ExpressionKind, @@ -19,8 +21,6 @@ use noirc_frontend::macros_api::{MacroError, MacroProcessor}; use noirc_frontend::macros_api::{ModuleDefId, NodeInterner, SortedModule, StructId}; use noirc_frontend::node_interner::{FuncId, TraitId, TraitImplId, TraitImplKind}; use noirc_frontend::Lambda; -use noirc_frontend::macros_api::parse_program; -use noirc_errors::Location; pub struct AztecMacro; impl MacroProcessor for AztecMacro { @@ -43,7 +43,7 @@ impl MacroProcessor for AztecMacro { } Ok(None) } - + fn process_unresolved_traits_impls( &self, crate_id: &CrateId, @@ -52,7 +52,12 @@ impl MacroProcessor for AztecMacro { collected_functions: &mut Vec, ) -> Result<(), (MacroError, FileId)> { if has_aztec_dependency(crate_id, context) { - inject_compute_note_hash_and_nullifier(crate_id, context, unresolved_traits_impls, collected_functions) + inject_compute_note_hash_and_nullifier( + crate_id, + context, + unresolved_traits_impls, + collected_functions, + ) } else { Ok(()) } @@ -355,7 +360,10 @@ fn check_for_storage_implementation(module: &SortedModule) -> bool { } // Check if "compute_note_hash_and_nullifier(AztecAddress,Field,Field,Field,[Field; N]) -> [Field; 4]" is defined -fn check_for_compute_note_hash_and_nullifier_definition(functions_data: &Vec<(LocalModuleId, FuncId, NoirFunction)>, module_id: LocalModuleId) -> bool { +fn check_for_compute_note_hash_and_nullifier_definition( + functions_data: &Vec<(LocalModuleId, FuncId, NoirFunction)>, + module_id: LocalModuleId, +) -> bool { functions_data.iter().filter(|func_data| func_data.0 == module_id).any(|func_data| { func_data.2.def.name.0.contents == "compute_note_hash_and_nullifier" && func_data.2.def.parameters.len() == 5 @@ -1619,8 +1627,11 @@ fn inject_compute_note_hash_and_nullifier( collected_functions: &mut Vec, ) -> Result<(), (MacroError, FileId)> { // We first fetch modules in this crate which correspond to contracts, along with their file id. - let contract_module_file_ids: Vec<(LocalModuleId, FileId)> = context.def_map(crate_id).expect("ICE: Missing crate in def_map") - .modules().iter() + let contract_module_file_ids: Vec<(LocalModuleId, FileId)> = context + .def_map(crate_id) + .expect("ICE: Missing crate in def_map") + .modules() + .iter() .filter(|(_, module)| module.is_contract) .map(|(idx, module)| (LocalModuleId(idx), module.location.file)) .collect(); @@ -1637,7 +1648,9 @@ fn inject_compute_note_hash_and_nullifier( // If compute_note_hash_and_nullifier is already defined by the user, we skip auto-generation in order to provide an // escape hatch for this mechanism. // TODO(#4647): improve this diagnosis and error messaging. - if collected_functions.iter().any(|coll_funcs_data| check_for_compute_note_hash_and_nullifier_definition(&coll_funcs_data.functions, module_id)) { + if collected_functions.iter().any(|coll_funcs_data| { + check_for_compute_note_hash_and_nullifier_definition(&coll_funcs_data.functions, module_id) + }) { return Ok(()); } @@ -1651,7 +1664,7 @@ fn inject_compute_note_hash_and_nullifier( // And inject the newly created function into the contract. - // TODO(#4373): We don't have a reasonable location for the source code of this autogenerated function, so we simply + // TODO(#4373): We don't have a reasonable location for the source code of this autogenerated function, so we simply // pass an empty span. This function should not produce errors anyway so this should not matter. let location = Location::new(Span::empty(0), file_id); @@ -1660,7 +1673,12 @@ fn inject_compute_note_hash_and_nullifier( // on collected but unresolved functions. let func_id = context.def_interner.push_empty_fn(); - context.def_interner.push_function(func_id, &func.def, ModuleId { krate: *crate_id, local_id: module_id }, location); + context.def_interner.push_function( + func_id, + &func.def, + ModuleId { krate: *crate_id, local_id: module_id }, + location, + ); context.def_map_mut(crate_id).unwrap() .modules_mut()[module_id.0] @@ -1670,8 +1688,10 @@ fn inject_compute_note_hash_and_nullifier( "Failed to declare the autogenerated compute_note_hash_and_nullifier function, likely due to a duplicate definition. See https://github.com/AztecProtocol/aztec-packages/issues/4647." ); - collected_functions.iter_mut() - .find(|fns| fns.file_id == file_id).expect("ICE: no functions found in contract file") + collected_functions + .iter_mut() + .find(|fns| fns.file_id == file_id) + .expect("ICE: no functions found in contract file") .push_fn(module_id, func_id, func.clone()); Ok(()) @@ -1681,11 +1701,11 @@ fn inject_compute_note_hash_and_nullifier( fn fetch_struct_trait_impls( context: &mut HirContext, unresolved_traits_impls: &Vec, - trait_name: &str + trait_name: &str, ) -> Vec { let mut struct_typenames: Vec = Vec::new(); - // These structs can be declared in either external crates or the current one. External crates that contain + // These structs can be declared in either external crates or the current one. External crates that contain // dependencies have already been processed and resolved, but are available here via the NodeInterner. Note that // crates on which the current crate does not depend on may not have been processed, and will be ignored. for trait_impl_id in 0..(&context.def_interner.next_trait_impl_id()).0 { @@ -1701,13 +1721,26 @@ fn fetch_struct_trait_impls( } // This crate's traits and impls have not yet been resolved, so we look for impls in unresolved_trait_impls. - struct_typenames.extend(unresolved_traits_impls.iter() - .filter(|trait_impl| - trait_impl.trait_path.segments.last().expect("ICE: empty trait_impl path").0.contents == *trait_name) - .filter_map(|trait_impl| match &trait_impl.object_type.typ { - UnresolvedTypeData::Named(path, _, _) => Some(path.segments.last().unwrap().0.contents.clone()), - _ => None, - })); + struct_typenames.extend( + unresolved_traits_impls + .iter() + .filter(|trait_impl| { + trait_impl + .trait_path + .segments + .last() + .expect("ICE: empty trait_impl path") + .0 + .contents + == *trait_name + }) + .filter_map(|trait_impl| match &trait_impl.object_type.typ { + UnresolvedTypeData::Named(path, _, _) => { + Some(path.segments.last().unwrap().0.contents.clone()) + } + _ => None, + }), + ); struct_typenames } @@ -1726,11 +1759,11 @@ fn generate_compute_note_hash_and_nullifier(note_types: &Vec) -> NoirFun } fn generate_compute_note_hash_and_nullifier_source(note_types: &Vec) -> String { - // TODO(#4649): The serialized_note parameter is a fixed-size array, but we don't know what length it should have. + // TODO(#4649): The serialized_note parameter is a fixed-size array, but we don't know what length it should have. // For now we hardcode it to 20, which is the same as MAX_NOTE_FIELDS_LENGTH. if note_types.len() == 0 { - // TODO(#4520): Even if the contract does not include any notes, other parts of the stack expect for this + // TODO(#4520): Even if the contract does not include any notes, other parts of the stack expect for this // function to exist, so we include a dummy version. We likely should error out here instead. " unconstrained fn compute_note_hash_and_nullifier( @@ -1741,7 +1774,8 @@ fn generate_compute_note_hash_and_nullifier_source(note_types: &Vec) -> serialized_note: [Field; 20] ) -> pub [Field; 4] { [0, 0, 0, 0] - }".to_string() + }" + .to_string() } else { // For contracts that include notes we do a simple if-else chain comparing note_type_id with the different // get_note_type_id of each of the note types. @@ -1753,12 +1787,14 @@ fn generate_compute_note_hash_and_nullifier_source(note_types: &Vec) -> , note_type)).collect(); // TODO(#4520): error out on the else instead of returning a zero array - let full_if_statement = if_statements.join(" else ") + " + let full_if_statement = if_statements.join(" else ") + + " else { [0, 0, 0, 0] }"; - format!(" + format!( + " unconstrained fn compute_note_hash_and_nullifier( contract_address: AztecAddress, nonce: Field, @@ -1769,7 +1805,8 @@ fn generate_compute_note_hash_and_nullifier_source(note_types: &Vec) -> let note_header = NoteHeader::new(contract_address, nonce, storage_slot); {} - }}", full_if_statement) -} - + }}", + full_if_statement + ) + } } diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 002911258df..731b78e33e5 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -259,18 +259,23 @@ impl DefCollector { // TODO(#4653): generalize this function for macro_processor in ¯o_processors { - macro_processor.process_unresolved_traits_impls(&crate_id, context, &def_collector.collected_traits_impls, &mut def_collector.collected_functions).unwrap_or_else( - |(macro_err, file_id)| { + macro_processor + .process_unresolved_traits_impls( + &crate_id, + context, + &def_collector.collected_traits_impls, + &mut def_collector.collected_functions, + ) + .unwrap_or_else(|(macro_err, file_id)| { errors.push((macro_err.into(), file_id)); - }, - ); + }); } let mut preludes = Vec::new(); preludes.push("std::prelude"); for macro_processor in ¯o_processors { - // Aside from the stdlib prelude, check whether the crate we are processing has dependencies + // Aside from the stdlib prelude, check whether the crate we are processing has dependencies // which supply their own prelude and add it to the list of preludes to be injected. match macro_processor.fetch_crate_prelude(&crate_id, context) { Ok(Some(prelude)) => { diff --git a/noir/noirc_macros/src/lib.rs b/noir/noirc_macros/src/lib.rs index 9e44ff57fdb..349f17a492d 100644 --- a/noir/noirc_macros/src/lib.rs +++ b/noir/noirc_macros/src/lib.rs @@ -25,7 +25,7 @@ impl MacroProcessor for AssertMessageMacro { ) -> Result, (MacroError, FileId)> { Ok(None) } - + fn process_unresolved_traits_impls( &self, _crate_id: &CrateId, From 266c2b97661a9a5fafa9199d97fe705cf0699d82 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 29 Feb 2024 11:43:10 +0000 Subject: [PATCH 28/33] fixes after merge --- noir-projects/aztec-nr/aztec/src/prelude.nr | 36 ++++++------------- .../contracts/counter_contract/src/main.nr | 1 + .../easy_private_token_contract/src/main.nr | 1 + .../inclusion_proofs_contract/src/main.nr | 9 ++--- .../contracts/slow_tree_contract/src/main.nr | 1 + yarn-project/noir-contracts.js/package.json | 2 +- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index 16408884855..78aed2bece6 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -1,28 +1,14 @@ -use dep::protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, -}; +use dep::protocol_types::{address::{AztecAddress, EthAddress}}; use crate::{ state_vars::{ - map::Map, - public_state::PublicState, - singleton::Singleton, - immutable_singleton::ImmutableSingleton, - set::Set, - stable_public_state::StablePublicState, - }, - log::{ - emit_unencrypted_log, - emit_encrypted_log, - }, - context::PrivateContext, + map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, + public_immutable::PublicImmutable, public_mutable::PublicMutable, private_set::PrivateSet, + shared_immutable::SharedImmutable +}, + log::{emit_unencrypted_log, emit_encrypted_log}, context::PrivateContext, note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - note_getter_options::NoteGetterOptions, - note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_and_nullifier as utils_compute_note_hash_and_nullifier, - } -}; \ No newline at end of file + note_header::NoteHeader, note_interface::NoteInterface, note_getter_options::NoteGetterOptions, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_and_nullifier as utils_compute_note_hash_and_nullifier +} +}; diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index c39c7586a67..4c968cb82d2 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -3,6 +3,7 @@ contract Counter { use dep::aztec::protocol_types::address::AztecAddress; use dep::aztec::state_vars::Map; use dep::value_note::balance_utils; + use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; use dep::easy_private_state::EasyPrivateUint; // docs:end:imports diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index 510277a24fb..d498a6aa78e 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -2,6 +2,7 @@ contract EasyPrivateToken { use dep::aztec::{protocol_types::address::AztecAddress, state_vars::Map}; use dep::value_note::balance_utils; + use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; use dep::easy_private_state::EasyPrivateUint; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 79390937996..e3928ec17de 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -3,11 +3,11 @@ contract InclusionProofs { // docs:start:imports use dep::aztec::{ protocol_types::{ - abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}, - grumpkin_point::GrumpkinPoint, contract_class_id::ContractClassId + abis::function_selector::FunctionSelector, grumpkin_point::GrumpkinPoint, + contract_class_id::ContractClassId }, - state_vars::{Map, PrivateSet, PublicMutable}, note::note_getter_options::{NoteGetterOptions, NoteStatus}, - history::{ + note::note_getter_options::NoteStatus, + history::{ contract_inclusion::{prove_contract_inclusion, prove_contract_inclusion_at}, note_inclusion::{prove_note_inclusion, prove_note_inclusion_at}, note_validity::{prove_note_validity, prove_note_validity_at}, @@ -17,6 +17,7 @@ contract InclusionProofs { }, nullifier_non_inclusion::{prove_note_not_nullified, prove_note_not_nullified_at}, public_value_inclusion::{prove_public_value_inclusion, prove_public_value_inclusion_at} + } }; // docs:end:imports // docs:start:value_note_imports diff --git a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr index 281c8db14c2..db2affbec84 100644 --- a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr @@ -7,6 +7,7 @@ mod types; // This is made as a separate contract for one thing mainly. Making it simpler to use. // TODO(#4760): Rename slow updates to shared mutable and ideally move the impl to state-vars in aztec-nr. contract SlowTree { + use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; use dep::aztec::{protocol_types::abis::function_selector::FunctionSelector, state_vars::Map}; use dep::slow_updates_tree::{SlowMap, Leaf, SlowUpdateProof, compute_merkle_root, deserialize_slow_update_proof}; diff --git a/yarn-project/noir-contracts.js/package.json b/yarn-project/noir-contracts.js/package.json index 8efbdbd1bc4..cdfa4bd68ea 100644 --- a/yarn-project/noir-contracts.js/package.json +++ b/yarn-project/noir-contracts.js/package.json @@ -49,4 +49,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} From 4b809874a716e2ecd4e91a31660d4b08c81a9c4e Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 29 Feb 2024 12:12:49 +0000 Subject: [PATCH 29/33] import cleanup --- .../contracts/writing_contracts/events/emit_event.md | 8 +------- .../tutorials/writing_private_voting_contract.md | 4 ---- noir-projects/aztec-nr/aztec/src/prelude.nr | 2 +- .../app_subscription_contract/src/dapp_payload.nr | 6 +----- .../contracts/app_subscription_contract/src/main.nr | 9 +-------- .../app_subscription_contract/src/subscription_note.nr | 6 ++---- .../contracts/benchmarking_contract/src/main.nr | 7 +------ .../contracts/card_game_contract/src/cards.nr | 9 ++------- .../contracts/card_game_contract/src/game.nr | 2 +- .../contracts/card_game_contract/src/main.nr | 4 ++-- .../noir-contracts/contracts/child_contract/src/main.nr | 6 +----- .../src/events/private_function_broadcasted.nr | 2 +- .../src/events/unconstrained_function_broadcasted.nr | 2 +- .../contract_class_registerer_contract/src/main.nr | 5 ++--- .../src/events/instance_deployed.nr | 3 +-- .../src/interface/ContractInstanceDeployer.nr | 4 +--- .../contract_instance_deployer_contract/src/main.nr | 6 ++---- .../contracts/counter_contract/src/main.nr | 2 -- .../contracts/delegated_on_contract/src/main.nr | 9 ++------- .../contracts/delegator_contract/src/main.nr | 6 +----- .../contracts/docs_example_contract/src/main.nr | 7 +------ .../contracts/docs_example_contract/src/options.nr | 4 ++-- .../contracts/docs_example_contract/src/types/leader.nr | 2 +- .../contracts/easy_private_token_contract/src/main.nr | 1 - .../contracts/easy_private_voting_contract/src/main.nr | 6 ------ .../contracts/ecdsa_account_contract/src/main.nr | 2 +- .../noir-contracts/contracts/escrow_contract/src/main.nr | 7 +------ .../noir-contracts/contracts/fpc_contract/src/main.nr | 3 --- .../contracts/gas_token_contract/src/lib.nr | 2 +- .../contracts/gas_token_contract/src/main.nr | 4 +--- .../contracts/inclusion_proofs_contract/src/main.nr | 5 +---- .../contracts/lending_contract/src/asset.nr | 2 +- .../contracts/lending_contract/src/interfaces.nr | 4 ++-- .../contracts/lending_contract/src/main.nr | 4 +--- .../noir-contracts/contracts/parent_contract/src/main.nr | 2 -- .../contracts/pending_commitments_contract/src/main.nr | 7 +------ .../contracts/price_feed_contract/src/main.nr | 1 - .../noir-contracts/contracts/reader_contract/src/main.nr | 2 -- .../contracts/schnorr_account_contract/src/main.nr | 2 +- .../schnorr_hardcoded_account_contract/src/main.nr | 1 - .../schnorr_single_key_account_contract/src/main.nr | 1 - .../contracts/slow_tree_contract/src/main.nr | 1 - .../contracts/stateful_test_contract/src/main.nr | 4 +--- .../noir-contracts/contracts/test_contract/src/main.nr | 2 +- .../contracts/token_blacklist_contract/src/interfaces.nr | 2 -- .../contracts/token_blacklist_contract/src/main.nr | 6 +----- .../token_blacklist_contract/src/types/balances_map.nr | 2 +- .../token_blacklist_contract/src/types/token_note.nr | 6 +----- .../contracts/token_bridge_contract/src/main.nr | 4 +--- .../token_bridge_contract/src/token_interface.nr | 1 - .../noir-contracts/contracts/token_contract/src/main.nr | 8 +------- .../contracts/token_contract/src/types/balances_map.nr | 5 +---- .../contracts/token_contract/src/types/token_note.nr | 4 +--- .../contracts/uniswap_contract/src/interfaces.nr | 1 - .../contracts/uniswap_contract/src/main.nr | 3 +-- .../contracts/uniswap_contract/src/util.nr | 2 +- 56 files changed, 50 insertions(+), 172 deletions(-) diff --git a/docs/docs/developers/contracts/writing_contracts/events/emit_event.md b/docs/docs/developers/contracts/writing_contracts/events/emit_event.md index 0c4204b3d67..ff7354e6a6f 100644 --- a/docs/docs/developers/contracts/writing_contracts/events/emit_event.md +++ b/docs/docs/developers/contracts/writing_contracts/events/emit_event.md @@ -96,15 +96,9 @@ They can be emitted by both public and private functions. - Unencrypted events are currently **NOT** linked to the contract emitting them, so it is practically a [`debug_log`](../oracles/main.md#a-few-useful-inbuilt-oracles). ::: -### Import library - -To emit unencrypted logs first import the `emit_unencrypted_log` utility function inside your contract: - -#include_code unencrypted_import /noir-projects/noir-contracts/contracts/test_contract/src/main.nr rust - ### Call emit_unencrypted_log -After importing, you can call the function: +To emit unencrypted log you can call: #include_code emit_unencrypted /noir-projects/noir-contracts/contracts/test_contract/src/main.nr rust diff --git a/docs/docs/developers/tutorials/writing_private_voting_contract.md b/docs/docs/developers/tutorials/writing_private_voting_contract.md index cf69867fe26..fc0a48e961a 100644 --- a/docs/docs/developers/tutorials/writing_private_voting_contract.md +++ b/docs/docs/developers/tutorials/writing_private_voting_contract.md @@ -64,10 +64,6 @@ contract Voting { This defines a contract called `Voter`. Everything will sit inside this block. -Inside this, paste these imports: - -#include_code imports noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust - We are using various utils within the Aztec library: - `context` - exposes things such as the contract address, msg_sender, etc diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index 78aed2bece6..9d65d3f1dc6 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::{address::{AztecAddress, EthAddress}}; +use dep::protocol_types::{address::{AztecAddress, EthAddress}, abis::function_selector::FunctionSelector}; use crate::{ state_vars::{ map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr index 941f86472f0..265b5f62e83 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr @@ -1,8 +1,4 @@ -use dep::aztec::context::PrivateContext; -use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}, - address::AztecAddress -}; +use dep::aztec::protocol_types::{constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::pedersen_hash, traits::{Hash, Serialize}}; use dep::authwit::entrypoint::function_call::{FunctionCall, FUNCTION_CALL_SIZE_IN_BYTES}; diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index feee4ecfecc..f50d1a87ae5 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -3,16 +3,9 @@ mod dapp_payload; contract AppSubscriptionContract { use dep::std; - use dep::std::option::Option; use crate::dapp_payload::DAppPayload; - use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector}; - - use dep::aztec::{ - context::{PrivateContext, Context}, note::{note_header::NoteHeader, utils as note_utils}, - oracle::get_public_key::get_public_key, - state_vars::{Map, PrivateMutable, PublicMutable, SharedImmutable} - }; + use dep::aztec::{context::Context, note::utils as note_utils, oracle::get_public_key::get_public_key}; use dep::authwit::{account::AccountActions, auth_witness::get_auth_witness, auth::assert_current_call_valid_authwit}; use crate::subscription_note::{SubscriptionNote, SUBSCRIPTION_NOTE_LEN}; diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index 8bb87a798ac..6af6e80491e 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -1,8 +1,6 @@ use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, - hash::pedersen_hash, - oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - log::emit_encrypted_log, context::PrivateContext, protocol_types::{address::AztecAddress} + note::utils::compute_note_hash_for_consumption, hash::pedersen_hash, + oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key} }; global SUBSCRIPTION_NOTE_LEN: Field = 3; diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 4044cdd6920..f7678be5b50 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -7,12 +7,7 @@ contract Benchmarking { use dep::value_note::{utils::{increment, decrement}, value_note::ValueNote}; - use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, - context::{Context}, - note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader}, - log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet} - }; + use dep::aztec::{context::Context, note::utils as note_utils}; struct Storage { notes: Map>, diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index 9e783f914bb..0f1bb63e200 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -1,11 +1,6 @@ use dep::aztec::{ - protocol_types::{address::AztecAddress, constants::{MAX_NOTES_PER_PAGE, MAX_READ_REQUESTS_PER_CALL}}, - context::{PrivateContext, Context}, - note::{ - note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, - note_getter::view_notes -}, - state_vars::PrivateSet + protocol_types::constants::{MAX_NOTES_PER_PAGE, MAX_READ_REQUESTS_PER_CALL}, context::Context, + note::note_getter::view_notes }; use dep::std; use dep::std::{option::Option}; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr index 1a1415284db..5fd3b4ea37b 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; use crate::cards::Card; global NUMBER_OF_PLAYERS = 2; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr index ee1689741fb..83e548adc6f 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr @@ -2,8 +2,8 @@ mod cards; mod game; contract CardGame { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress, constants::MAX_NOTES_PER_PAGE}; - use dep::aztec::{context::Context, hash::pedersen_hash, state_vars::{Map, PublicMutable}}; + use dep::aztec::protocol_types::constants::MAX_NOTES_PER_PAGE; + use dep::aztec::{context::Context, hash::pedersen_hash}; use dep::std::option::Option; use dep::value_note::{balance_utils, value_note::{ValueNote, VALUE_NOTE_LEN}}; diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index ee0cfe03f2c..d161c830a82 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -2,11 +2,7 @@ contract Child { use dep::std::option::Option; - use dep::aztec::{ - log::emit_unencrypted_log, state_vars::{PublicMutable, PrivateSet}, - protocol_types::{abis::{function_selector::FunctionSelector, call_context::CallContext}, address::AztecAddress}, - note::note_getter_options::NoteGetterOptions - }; + use dep::aztec::protocol_types::abis::call_context::CallContext; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr index 99092cf70e3..0a102e548cf 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr @@ -1,6 +1,6 @@ use dep::aztec::protocol_types; use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, abis::function_selector::FunctionSelector, + contract_class_id::ContractClassId, constants::{ FUNCTION_TREE_HEIGHT, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS, diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr index aeaeaeaf627..3338fcd1d0f 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr @@ -1,6 +1,6 @@ use dep::aztec::protocol_types; use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, abis::function_selector::FunctionSelector, + contract_class_id::ContractClassId, constants::{ ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS, REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 760b4e5ff64..f9cbb2d9bd1 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -2,9 +2,8 @@ mod events; mod capsule; contract ContractClassRegisterer { - use dep::std::option::Option; use dep::aztec::protocol_types::{ - address::{AztecAddress, EthAddress}, contract_class_id::ContractClassId, + contract_class_id::ContractClassId, constants::{ ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE @@ -12,7 +11,7 @@ contract ContractClassRegisterer { traits::{Serialize} }; - use dep::aztec::log::{emit_unencrypted_log, emit_unencrypted_log_from_private}; + use dep::aztec::log::emit_unencrypted_log_from_private; use crate::events::{ class_registered::ContractClassRegistered, diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr index 1a01b992246..98f53428545 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/events/instance_deployed.nr @@ -1,6 +1,5 @@ use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, - address::{AztecAddress, EthAddress, PublicKeysHash, PartialAddress}, + contract_class_id::ContractClassId, address::{PublicKeysHash, PartialAddress}, constants::{DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE}, traits::{Serialize} }; diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/interface/ContractInstanceDeployer.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/interface/ContractInstanceDeployer.nr index 810cdccc248..6a2e26a7cae 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/interface/ContractInstanceDeployer.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/interface/ContractInstanceDeployer.nr @@ -1,8 +1,6 @@ /* Autogenerated file, do not edit! */ -use dep::std; -use dep::aztec::context::{PrivateContext, PublicContext}; -use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector, constants::RETURN_VALUES_LENGTH}; +use dep::aztec::protocol_types::constants::RETURN_VALUES_LENGTH; struct ContractClassIdDeployStruct { inner: Field, diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index aceccc3ab11..c32f9c70d11 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -1,14 +1,12 @@ mod events; contract ContractInstanceDeployer { - use dep::std::option::Option; use dep::aztec::protocol_types::{ - address::{AztecAddress, EthAddress, PublicKeysHash, PartialAddress}, - contract_class_id::ContractClassId, + address::{PublicKeysHash, PartialAddress}, contract_class_id::ContractClassId, constants::{DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE}, traits::{Serialize} }; - use dep::aztec::log::{emit_unencrypted_log, emit_unencrypted_log_from_private}; + use dep::aztec::log::emit_unencrypted_log_from_private; use crate::events::{instance_deployed::ContractInstanceDeployed}; diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index 4c968cb82d2..a4811772ae3 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -1,7 +1,5 @@ contract Counter { // docs:start:imports - use dep::aztec::protocol_types::address::AztecAddress; - use dep::aztec::state_vars::Map; use dep::value_note::balance_utils; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; use dep::easy_private_state::EasyPrivateUint; diff --git a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr index 928760f048f..ec78ff7353a 100644 --- a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr @@ -3,13 +3,8 @@ contract DelegatedOn { use dep::std::option::Option; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, log::emit_unencrypted_log, - state_vars::{PublicMutable, PrivateSet}, - protocol_types::{abis::{function_selector::FunctionSelector, call_context::CallContext}, address::AztecAddress}, - note::{ - note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, - utils as note_utils, note_header::NoteHeader - } + context::{PublicContext, Context}, protocol_types::abis::call_context::CallContext, + note::utils as note_utils }; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; diff --git a/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr b/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr index d93629e4fea..c20fd9edda6 100644 --- a/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr @@ -2,11 +2,7 @@ contract Delegator { use dep::std::option::Option; - use dep::aztec::{ - log::emit_unencrypted_log, state_vars::{PublicMutable, PrivateSet}, - protocol_types::{abis::{function_selector::FunctionSelector}, address::AztecAddress}, - note::{note_viewer_options::NoteViewerOptions, utils as note_utils, note_header::NoteHeader} - }; + use dep::aztec::note::utils as note_utils; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index bc1f9ed9500..a583fb32cd8 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -13,12 +13,7 @@ mod types; contract DocsExample { // how to import dependencies defined in your workspace - use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, - note::{note_header::NoteHeader, note_viewer_options::NoteViewerOptions}, - context::{PrivateContext, Context}, - state_vars::{Map, PublicMutable, PublicImmutable, PrivateMutable, PrivateImmutable, PrivateSet, SharedImmutable} - }; + use dep::aztec::context::Context; // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; use crate::types::{card_note::CardNote, leader::Leader}; diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr index d2f56953138..287150f6ca5 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr @@ -1,6 +1,6 @@ use crate::types::card_note::{CardNote, CARD_NOTE_LEN}; -use dep::aztec::protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}; -use dep::aztec::note::note_getter_options::{NoteGetterOptions, Sort, SortOrder}; +use dep::aztec::protocol_types::constants::MAX_READ_REQUESTS_PER_CALL; +use dep::aztec::note::note_getter_options::{Sort, SortOrder}; use dep::std::option::Option; // Shows how to use NoteGetterOptions and query for notes. diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr index 85f1b08199d..a75529a0503 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; // Shows how to create a custom struct in Public struct Leader { diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index d498a6aa78e..c0570ff23ef 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -1,6 +1,5 @@ // docs:start:easy_private_token_contract contract EasyPrivateToken { - use dep::aztec::{protocol_types::address::AztecAddress, state_vars::Map}; use dep::value_note::balance_utils; use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; use dep::easy_private_state::EasyPrivateUint; diff --git a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index d19e2720e9f..16d60d4c440 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -1,10 +1,4 @@ contract EasyPrivateVoting { - // docs:start:imports - use dep::aztec::{ - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, - state_vars::{Map, PublicMutable} - }; - // docs:end:imports // docs:start:storage_struct struct Storage { admin: PublicMutable, // admin can end vote diff --git a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index 91da4a7bb0d..61147f1e43e 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -4,7 +4,7 @@ mod ecdsa_public_key_note; // The signing key is stored in an immutable private note and should be different from the signing key. contract EcdsaAccount { use dep::std; - use dep::aztec::{context::{PrivateContext, Context}, state_vars::PrivateImmutable}; + use dep::aztec::context::Context; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, auth_witness::get_auth_witness diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index b34b3d68ba0..5aff6b6f507 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -1,12 +1,7 @@ // Sample escrow contract that stores a balance of a private token on behalf of an owner. contract Escrow { use dep::std::option::Option; - - use dep::aztec::{ - note::note_getter_options::NoteGetterOptions, oracle::get_public_key::get_public_key, - protocol_types::abis::function_selector::FunctionSelector, state_vars::PrivateSet - }; - + use dep::aztec::oracle::get_public_key::get_public_key; use dep::address_note::address_note::{AddressNote, ADDRESS_NOTE_LEN}; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index 70333ebcd7e..af291c565ce 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -1,9 +1,6 @@ mod interfaces; contract FPC { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; - use dep::aztec::state_vars::SharedImmutable; - use crate::interfaces::Token; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/gas_token_contract/src/lib.nr b/noir-projects/noir-contracts/contracts/gas_token_contract/src/lib.nr index 9d7dbf3b74e..27212f89696 100644 --- a/noir-projects/noir-contracts/contracts/gas_token_contract/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/gas_token_contract/src/lib.nr @@ -1,5 +1,5 @@ use dep::aztec::context::PublicContext; -use dep::aztec::protocol_types::{address::{AztecAddress, EthAddress}, hash::sha256_to_field}; +use dep::aztec::protocol_types::hash::sha256_to_field; pub fn calculate_fee(_context: PublicContext) -> U128 { U128::from_integer(1) diff --git a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr index 663c2cfbde2..21dad5b27b8 100644 --- a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr @@ -1,9 +1,7 @@ mod lib; contract GasToken { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; - use dep::aztec::{hash::{compute_secret_hash}, state_vars::{PublicMutable, Map}}; - + use dep::aztec::hash::compute_secret_hash; use crate::lib::{calculate_fee, get_bridge_gas_msg_hash}; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index e3928ec17de..7c4ba298486 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -2,10 +2,7 @@ contract InclusionProofs { // docs:start:imports use dep::aztec::{ - protocol_types::{ - abis::function_selector::FunctionSelector, grumpkin_point::GrumpkinPoint, - contract_class_id::ContractClassId - }, + protocol_types::{grumpkin_point::GrumpkinPoint, contract_class_id::ContractClassId}, note::note_getter_options::NoteStatus, history::{ contract_inclusion::{prove_contract_inclusion, prove_contract_inclusion_at}, diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr index 88f95f6e848..74dabde0ca7 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/asset.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}}; +use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; // Struct to be used to represent "totals". Generally, there should be one per asset. // It stores the global values that are shared among all users, such as an accumulator diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr index 631f5eed5ca..97fac91f5ca 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/interfaces.nr @@ -1,7 +1,7 @@ -use dep::aztec::context::{PrivateContext, PublicContext}; +use dep::aztec::context::PublicContext; use crate::asset::Asset; -use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress, constants::RETURN_VALUES_LENGTH}; +use dep::aztec::protocol_types::constants::RETURN_VALUES_LENGTH; struct PriceFeed { address: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index bc039a499be..a04cfbc69f2 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -11,9 +11,7 @@ mod interfaces; // - A way to repay all debt at once // - Liquidations contract Lending { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; - use dep::std::option::Option; - use dep::aztec::{context::{PrivateContext, PublicContext, Context}, state_vars::{Map, PublicMutable}}; + use dep::aztec::context::{PublicContext, Context}; use crate::asset::Asset; use crate::interest_math::compute_multiplier; use crate::helpers::{covered_by_collateral, DebtReturn, debt_updates, debt_value, compute_identifier}; diff --git a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr index b89dcb83d39..977020f6048 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -1,7 +1,5 @@ // A contract used along with `Child` contract to test nested calls. contract Parent { - use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector}; - #[aztec(private)] fn constructor() {} diff --git a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr index 0afe246eaf4..8d70dba0d16 100644 --- a/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_commitments_contract/src/main.nr @@ -4,13 +4,8 @@ // be read/nullified before their creation etc. contract PendingCommitments { // Libs - use dep::std::option::Option; use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; - use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, log::emit_encrypted_log, - note::{note_getter::NoteGetterOptions}, state_vars::{Map, PrivateSet}, - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress} - }; + use dep::aztec::context::{PublicContext, Context}; struct Storage { balances: Map>, diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr index 48827307494..04ecb565a61 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr @@ -1,7 +1,6 @@ mod asset; contract PriceFeed { - use dep::aztec::{state_vars::{Map, PublicMutable}}; use crate::asset::Asset; // Storage structure, containing all storage, and specifying what slots they use. diff --git a/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr b/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr index cfe709c3ee8..632d993226b 100644 --- a/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr @@ -1,6 +1,4 @@ contract Reader { - use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector}; - use dep::compressed_string::FieldCompressedString; #[aztec(private)] diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index bb8731f2ecc..b61c18109fd 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -5,7 +5,7 @@ mod public_key_note; contract SchnorrAccount { use dep::std; - use dep::aztec::{context::{PrivateContext, Context}, state_vars::PrivateImmutable}; + use dep::aztec::context::Context; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, auth_witness::get_auth_witness diff --git a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index fb8bff46b38..ab2951f5f8d 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -2,7 +2,6 @@ // Account contract that uses Schnorr signatures for authentication using a hardcoded public key. contract SchnorrHardcodedAccount { use dep::std; - use dep::aztec::context::PrivateContext; use dep::authwit::{ entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr index c8fc40af8c0..835951aba53 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr @@ -2,7 +2,6 @@ mod util; mod auth_oracle; contract SchnorrSingleKeyAccount { - use dep::aztec::context::PrivateContext; use dep::authwit::{entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions}; use crate::{util::recover_address, auth_oracle::get_auth_witness}; diff --git a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr index db2affbec84..68e4cbb92e6 100644 --- a/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/slow_tree_contract/src/main.nr @@ -8,7 +8,6 @@ mod types; // TODO(#4760): Rename slow updates to shared mutable and ideally move the impl to state-vars in aztec-nr. contract SlowTree { use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN}; - use dep::aztec::{protocol_types::abis::function_selector::FunctionSelector, state_vars::Map}; use dep::slow_updates_tree::{SlowMap, Leaf, SlowUpdateProof, compute_merkle_root, deserialize_slow_update_proof}; // docs:start:import_pop_capsule diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 0cf1dd3a764..f851ebf47c9 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -3,9 +3,7 @@ contract StatefulTest { use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::ValueNote}; use dep::aztec::{ deploy::{deploy_contract as aztec_deploy_contract}, - state_vars::{Map, PublicMutable, PrivateSet}, - initializer::{mark_as_initialized, assert_is_initialized}, - protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector} + initializer::{mark_as_initialized, assert_is_initialized} }; struct Storage { diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 6e9e75594fa..22f3f630f96 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -13,7 +13,7 @@ contract Test { note_getter::{get_notes, view_notes}, note_getter_options::NoteStatus }, oracle::{get_public_key::get_public_key as get_public_key_oracle, context::get_portal_address, rand::rand}, - state_vars::PrivateImmutable, log::emit_unencrypted_log_from_private + log::emit_unencrypted_log_from_private }; use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash}; use dep::field_note::field_note::FieldNote; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr index ec786a73d1f..9f24b3aaf7e 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/interfaces.nr @@ -1,5 +1,3 @@ -use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; - use dep::aztec::context::{PublicContext, Context}; struct SlowMap { diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index d9162281f42..ce2a8b48f6e 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -16,11 +16,7 @@ contract TokenBlacklist { // Libs use dep::std::option::Option; - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; - use dep::aztec::{ - note::note_getter_options::NoteGetterOptions, hash::compute_secret_hash, - state_vars::{Map, PublicMutable, PrivateSet, SharedImmutable} - }; + use dep::aztec::hash::compute_secret_hash; use dep::field_note::field_note::FieldNote; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index 425eb7305b1..4a677b8f3f7 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -1,6 +1,6 @@ use dep::std::option::Option; use dep::aztec::{ - context::Context, protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}, + context::Context, protocol_types::constants::MAX_READ_REQUESTS_PER_CALL, state_vars::{PrivateSet, Map}, note::{note_getter::view_notes} }; use crate::types::token_note::{TokenNote, OwnedNote}; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index b64647759e7..ffb4f71fab7 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,8 +1,4 @@ -use dep::aztec::{ - protocol_types::address::AztecAddress, - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, - context::PrivateContext, log::emit_encrypted_log, hash::pedersen_hash -}; +use dep::aztec::{note::utils::compute_note_hash_for_consumption, hash::pedersen_hash}; use dep::aztec::oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}; trait OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index 8a00972b733..9bce6ff7f48 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -7,9 +7,7 @@ mod token_interface; // Bridge has to be set as a minter on the token before it can be used contract TokenBridge { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; - - use dep::aztec::{context::{Context}, hash::{compute_secret_hash}, state_vars::{PublicMutable}}; + use dep::aztec::{context::{Context}, hash::{compute_secret_hash}}; use dep::token_portal_content_hash_lib::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash}; diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr index 1b43190ac8b..5387571e005 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/token_interface.nr @@ -1,5 +1,4 @@ // docs:start:token_bridge_token_interface -use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::aztec::{context::{PublicContext, Context}}; struct Token { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 4b02630f7b1..15076410b18 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -12,14 +12,8 @@ mod types; contract Token { // Libs use dep::std::option::Option; - use dep::compressed_string::FieldCompressedString; - - use dep::aztec::{ - note::note_getter_options::NoteGetterOptions, hash::compute_secret_hash, - state_vars::{Map, PublicMutable, SharedImmutable, PrivateSet}, - protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress} - }; + use dep::aztec::hash::compute_secret_hash; // docs:start:import_authwit use dep::authwit::{auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public}}; diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr index 38a61224923..78aa15f84f9 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balances_map.nr @@ -1,8 +1,5 @@ use dep::std::option::Option; -use dep::aztec::{ - context::Context, protocol_types::{address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL}, - state_vars::{PrivateSet, Map} -}; +use dep::aztec::{context::Context, protocol_types::constants::MAX_READ_REQUESTS_PER_CALL}; use crate::types::token_note::{TokenNote, OwnedNote}; struct BalancesMap { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index 8e24eb37155..79bfc7469e3 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,8 +1,6 @@ use dep::aztec::{ oracle::{rand::rand, nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key}, - protocol_types::address::AztecAddress, - note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption}, - context::PrivateContext, log::emit_encrypted_log, hash::pedersen_hash + note::utils::compute_note_hash_for_consumption, hash::pedersen_hash }; trait OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr index d532a0c5cd5..0c65040d48c 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr @@ -1,5 +1,4 @@ // docs:start:interfaces -use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; use dep::aztec::context::PublicContext; struct Token { diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index 1188a027c8e..ff9d4c5bb64 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -6,8 +6,7 @@ mod util; // Has two separate flows for private and public respectively // Uses the token bridge contract, which tells which input token we need to talk to and handles the exit funds to L1 contract Uniswap { - use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress}}; - use dep::aztec::{oracle::{context::get_portal_address}, state_vars::{Map, PublicMutable}}; + use dep::aztec::oracle::context::get_portal_address; use dep::authwit::auth::{ IS_VALID_SELECTOR, assert_current_call_valid_authwit_public, compute_call_authwit_hash, diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr index 6be6bab884e..42ef5893124 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/util.nr @@ -1,5 +1,5 @@ // docs:start:uniswap_public_content_hash -use dep::aztec::protocol_types::{address::{AztecAddress, EthAddress}, hash::sha256_to_field}; +use dep::aztec::protocol_types::hash::sha256_to_field; // This method computes the L2 to L1 message content hash for the public // refer `l1-contracts/test/portals/UniswapPortal.sol` on how L2 to L1 message is expected From 5e30067f1b8290c58e071d0186a4a3872363af09 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 4 Mar 2024 15:08:06 +0000 Subject: [PATCH 30/33] chore: undo unwanted formatting changes --- .../proof_system/execution_trace/execution_trace.cpp | 2 +- .../stdlib/hash/poseidon2/poseidon2_permutation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp index 6baf321d376..f18aa9d9350 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp @@ -164,4 +164,4 @@ template class ExecutionTrace_; template class ExecutionTrace_; template class ExecutionTrace_; -} // namespace bb \ No newline at end of file +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp index fb68fa55fba..087360b7a18 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp @@ -296,4 +296,4 @@ void Poseidon2Permutation::matrix_multiplication_external( template class Poseidon2Permutation; template class Poseidon2Permutation; -} // namespace bb::stdlib \ No newline at end of file +} // namespace bb::stdlib From 1269ed7d45757ec645a6a88d122d564d89657efb Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 4 Mar 2024 15:09:30 +0000 Subject: [PATCH 31/33] chore: prevent formatter from running --- .../circuit_builder/ultra_circuit_builder.hpp | 5 +--- .../execution_trace/execution_trace.cpp | 13 ++++++----- .../hash/poseidon2/poseidon2_permutation.cpp | 23 ++++++++++--------- .../sumcheck/instance/prover_instance.hpp | 9 +++++--- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp index 9bc092f4b66..ee7a85944bc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp @@ -482,10 +482,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase::add_wires_and_selectors_to_proving_key( } template -void ExecutionTrace_::add_memory_records_to_proving_key( - TraceData& trace_data, - Builder& builder, - const std::shared_ptr& proving_key) requires IsUltraPlonkOrHonk +void ExecutionTrace_::add_memory_records_to_proving_key(TraceData& trace_data, + Builder& builder, + const std::shared_ptr& proving_key) + requires IsUltraPlonkOrHonk { ASSERT(proving_key->memory_read_records.empty() && proving_key->memory_write_records.empty()); @@ -131,8 +131,9 @@ template void ExecutionTrace_::populate_public_inputs_blo } template -void ExecutionTrace_::add_ecc_op_wires_to_proving_key( - Builder& builder, const std::shared_ptr& proving_key) requires IsGoblinFlavor +void ExecutionTrace_::add_ecc_op_wires_to_proving_key(Builder& builder, + const std::shared_ptr& proving_key) + requires IsGoblinFlavor { // Initialize the ecc op wire polynomials to zero on the whole domain std::array op_wire_polynomials; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp index 087360b7a18..3cf94c520b5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2_permutation.cpp @@ -16,8 +16,8 @@ namespace bb::stdlib { */ template typename Poseidon2Permutation::State Poseidon2Permutation::permutation( - Builder* builder, - const typename Poseidon2Permutation::State& input) requires IsGoblinBuilder + Builder* builder, const typename Poseidon2Permutation::State& input) + requires IsGoblinBuilder { // deep copy State current_state(input); @@ -103,8 +103,8 @@ typename Poseidon2Permutation::State Poseidon2Permutation typename Poseidon2Permutation::State Poseidon2Permutation::permutation( - Builder* builder, - const typename Poseidon2Permutation::State& input) requires IsNotGoblinBuilder + Builder* builder, const typename Poseidon2Permutation::State& input) + requires IsNotGoblinBuilder { // deep copy State current_state(input); @@ -139,8 +139,8 @@ typename Poseidon2Permutation::State Poseidon2Permutation void Poseidon2Permutation::add_round_constants( - State& input, - const typename Poseidon2Permutation::RoundConstants& rc) requires IsNotGoblinBuilder + State& input, const typename Poseidon2Permutation::RoundConstants& rc) + requires IsNotGoblinBuilder { for (size_t i = 0; i < t; ++i) { @@ -149,7 +149,8 @@ void Poseidon2Permutation::add_round_constants( } template -void Poseidon2Permutation::apply_sbox(State& input) requires IsNotGoblinBuilder +void Poseidon2Permutation::apply_sbox(State& input) + requires IsNotGoblinBuilder { for (auto& in : input) { apply_single_sbox(in); @@ -157,8 +158,8 @@ void Poseidon2Permutation::apply_sbox(State& input) requires Is } template -void Poseidon2Permutation::apply_single_sbox(field_t& input) requires - IsNotGoblinBuilder +void Poseidon2Permutation::apply_single_sbox(field_t& input) + requires IsNotGoblinBuilder { // hardcoded assumption that d = 5. should fix this or not make d configurable auto xx = input.sqr(); @@ -167,8 +168,8 @@ void Poseidon2Permutation::apply_single_sbox(field_t& } template -void Poseidon2Permutation::matrix_multiplication_internal(State& input) requires - IsNotGoblinBuilder +void Poseidon2Permutation::matrix_multiplication_internal(State& input) + requires IsNotGoblinBuilder { // for t = 4 auto sum = input[0]; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp index 5f7671ee43e..c11f3ebb74a 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.hpp @@ -103,9 +103,11 @@ template class ProverInstance_ { void compute_sorted_list_accumulator(FF); - void compute_logderivative_inverse(FF, FF) requires IsGoblinFlavor; + void compute_logderivative_inverse(FF, FF) + requires IsGoblinFlavor; - void compute_databus_id() requires IsGoblinFlavor; + void compute_databus_id() + requires IsGoblinFlavor; void compute_grand_product_polynomials(FF, FF); @@ -117,7 +119,8 @@ template class ProverInstance_ { size_t compute_dyadic_size(Circuit&); - void construct_databus_polynomials(Circuit&) requires IsGoblinFlavor; + void construct_databus_polynomials(Circuit&) + requires IsGoblinFlavor; void construct_table_polynomials(Circuit&, size_t); From 35a1472f13dbfba125df3031ebb02f7e18917f15 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 4 Mar 2024 15:11:38 +0000 Subject: [PATCH 32/33] chore: revert more formatting changes --- .../execution_trace/execution_trace.cpp | 9 ++++----- .../execution_trace/execution_trace.hpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp index ac6a0c191e4..d654b382f0b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp @@ -50,9 +50,8 @@ void ExecutionTrace_::add_wires_and_selectors_to_proving_key( } template -void ExecutionTrace_::add_memory_records_to_proving_key(TraceData& trace_data, - Builder& builder, - const std::shared_ptr& proving_key) +void ExecutionTrace_::add_memory_records_to_proving_key( + TraceData& trace_data, Builder& builder, const std::shared_ptr& proving_key) requires IsUltraPlonkOrHonk { ASSERT(proving_key->memory_read_records.empty() && proving_key->memory_write_records.empty()); @@ -67,8 +66,8 @@ void ExecutionTrace_::add_memory_records_to_proving_key(TraceData& trace } template -typename ExecutionTrace_::TraceData ExecutionTrace_::construct_trace_data(Builder& builder, - size_t dyadic_circuit_size) +typename ExecutionTrace_::TraceData ExecutionTrace_::construct_trace_data( + Builder& builder, size_t dyadic_circuit_size) { TraceData trace_data{ dyadic_circuit_size, builder }; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.hpp b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.hpp index 9d438c2d1c4..f4d7cf5a655 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.hpp @@ -68,10 +68,10 @@ template class ExecutionTrace_ { * @param builder * @param proving_key */ - static void add_memory_records_to_proving_key( - TraceData& trace_data, - Builder& builder, - const std::shared_ptr& proving_key) requires IsUltraPlonkOrHonk; + static void add_memory_records_to_proving_key(TraceData& trace_data, + Builder& builder, + const std::shared_ptr& proving_key) + requires IsUltraPlonkOrHonk; /** * @brief Construct wire polynomials, selector polynomials and copy cycles from raw circuit data @@ -98,9 +98,9 @@ template class ExecutionTrace_ { * @param builder * @param proving_key */ - static void add_ecc_op_wires_to_proving_key( - Builder& builder, - const std::shared_ptr& proving_key) requires IsGoblinFlavor; + static void add_ecc_op_wires_to_proving_key(Builder& builder, + const std::shared_ptr& proving_key) + requires IsGoblinFlavor; }; -} // namespace bb \ No newline at end of file +} // namespace bb From 3a0796cd31b50b7ceb619dc843bf23e2520da97b Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 4 Mar 2024 15:13:10 +0000 Subject: [PATCH 33/33] chore: one more --- .../proof_system/execution_trace/execution_trace.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp index d654b382f0b..52f713286c1 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/execution_trace/execution_trace.cpp @@ -66,8 +66,8 @@ void ExecutionTrace_::add_memory_records_to_proving_key( } template -typename ExecutionTrace_::TraceData ExecutionTrace_::construct_trace_data( - Builder& builder, size_t dyadic_circuit_size) +typename ExecutionTrace_::TraceData ExecutionTrace_::construct_trace_data(Builder& builder, + size_t dyadic_circuit_size) { TraceData trace_data{ dyadic_circuit_size, builder }; @@ -130,8 +130,8 @@ template void ExecutionTrace_::populate_public_inputs_blo } template -void ExecutionTrace_::add_ecc_op_wires_to_proving_key(Builder& builder, - const std::shared_ptr& proving_key) +void ExecutionTrace_::add_ecc_op_wires_to_proving_key( + Builder& builder, const std::shared_ptr& proving_key) requires IsGoblinFlavor { // Initialize the ecc op wire polynomials to zero on the whole domain