From e0948c9ea6619109bcb34bb7d5103e43b15c59a7 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 09:18:30 +0000 Subject: [PATCH 01/12] refactor: cleanup of abi.nr --- noir/aztec_macros/src/lib.rs | 4 +-- yarn-project/aztec-nr/aztec/src/abi.nr | 25 ---------------- yarn-project/aztec-nr/aztec/src/hasher.nr | 30 +++++++++++++++++++ yarn-project/aztec-nr/aztec/src/lib.nr | 1 + .../contracts/card_game_contract/src/main.nr | 12 ++------ .../docs_example_contract/src/main.nr | 2 +- .../src/main.nr | 5 +--- 7 files changed, 38 insertions(+), 41 deletions(-) create mode 100644 yarn-project/aztec-nr/aztec/src/hasher.nr diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 138bcafb1d6..66982a15b7e 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -1088,8 +1088,8 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac let let_hasher = mutable_assignment( "hasher", // Assigned to call( - variable_path(chained_path!("aztec", "abi", "Hasher", "new")), // Path - vec![], // args + variable_path(chained_path!("aztec", "hasher", "Hasher", "new")), // Path + vec![], // args ), ); diff --git a/yarn-project/aztec-nr/aztec/src/abi.nr b/yarn-project/aztec-nr/aztec/src/abi.nr index d9de304de0c..dc60f1c6d87 100644 --- a/yarn-project/aztec-nr/aztec/src/abi.nr +++ b/yarn-project/aztec-nr/aztec/src/abi.nr @@ -68,28 +68,3 @@ struct PublicContextInputs { } // docs:end:public-context-inputs -struct Hasher { - fields: [Field], -} - -impl Hash for Hasher { - fn hash(self) -> Field { - hash_args(self.fields) - } -} - -impl Hasher { - pub fn new()-> Self { - Self { fields: [] } - } - - pub fn add(&mut self, field: Field) { - self.fields = self.fields.push_back(field); - } - - pub fn add_multiple(&mut self, fields: [Field; N]) { - for i in 0..N { - self.fields = self.fields.push_back(fields[i]); - } - } -} diff --git a/yarn-project/aztec-nr/aztec/src/hasher.nr b/yarn-project/aztec-nr/aztec/src/hasher.nr new file mode 100644 index 00000000000..fcfd27a74ac --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/hasher.nr @@ -0,0 +1,30 @@ +use dep::protocol_types::{ + hash::hash_args, + traits::Hash, +}; + +struct Hasher { + fields: [Field], +} + +impl Hash for Hasher { + fn hash(self) -> Field { + hash_args(self.fields) + } +} + +impl Hasher { + pub fn new()-> Self { + Self { fields: [] } + } + + pub fn add(&mut self, field: Field) { + self.fields = self.fields.push_back(field); + } + + pub fn add_multiple(&mut self, fields: [Field; N]) { + for i in 0..N { + self.fields = self.fields.push_back(fields[i]); + } + } +} diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index 88866fb2fbc..cf15736a3d5 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -2,6 +2,7 @@ mod abi; mod avm; mod context; mod hash; +mod hasher; mod history; mod key; mod log; 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..0b4424ac9b5 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 @@ -25,15 +25,9 @@ contract CardGame { }, }; - use dep::aztec::{ - abi, - abi::{ - Hasher, PrivateContextInputs, - }, - note::{ - note_header::NoteHeader, - utils as note_utils, - }, + use dep::aztec::note::{ + note_header::NoteHeader, + utils as note_utils, }; use crate::cards::{ 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..c80b7559a55 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 @@ -245,7 +245,7 @@ contract DocsExample { /// Macro equivalence section use dep::aztec::abi; - use dep::aztec::abi::Hasher; + use dep::aztec::hasher::Hasher; use dep::aztec::abi::PrivateContextInputs; use dep::aztec::abi::PrivateCircuitPublicInputs; 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..ce0c13a9844 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,7 @@ // 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::aztec::context::PrivateContext; use dep::authwit:: { entrypoint::{ EntrypointPayload, ENTRYPOINT_PAYLOAD_SIZE }, From 25c750ace3b39af16554ff271c0850459b3cc5a1 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 10:01:14 +0000 Subject: [PATCH 02/12] WIP --- noir/aztec_macros/src/lib.rs | 2 +- yarn-project/aztec-nr/aztec/src/abi.nr | 70 ------------------- yarn-project/aztec-nr/aztec/src/context.nr | 11 +-- .../aztec-nr/aztec/src/context/globals.nr | 2 + .../globals/private_global_variables.nr | 14 ++++ .../globals/public_global_variables.nr | 31 ++++++++ .../aztec-nr/aztec/src/context/inputs.nr | 2 + .../context/inputs/private_context_inputs.nr | 16 +++++ .../context/inputs/public_context_inputs.nr | 16 +++++ .../{private.nr => private_context.nr} | 2 +- .../context/{public.nr => public_context.nr} | 2 +- yarn-project/aztec-nr/aztec/src/lib.nr | 1 - 12 files changed, 91 insertions(+), 78 deletions(-) delete mode 100644 yarn-project/aztec-nr/aztec/src/abi.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/globals.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/inputs.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr create mode 100644 yarn-project/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr rename yarn-project/aztec-nr/aztec/src/context/{private.nr => private_context.nr} (99%) rename yarn-project/aztec-nr/aztec/src/context/{public.nr => public_context.nr} (99%) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 66982a15b7e..7a9050ae3d7 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -1049,7 +1049,7 @@ fn generate_selector_impl(structure: &NoirStruct) -> TypeImpl { fn create_inputs(ty: &str) -> Param { let context_ident = ident("inputs"); let context_pattern = Pattern::Identifier(context_ident); - let type_path = chained_path!("aztec", "abi", ty); + let type_path = chained_path!("aztec", "context", "inputs", "private_context_inputs", ty); let context_type = make_type(UnresolvedTypeData::Named(type_path, vec![])); let visibility = Visibility::Private; diff --git a/yarn-project/aztec-nr/aztec/src/abi.nr b/yarn-project/aztec-nr/aztec/src/abi.nr deleted file mode 100644 index dc60f1c6d87..00000000000 --- a/yarn-project/aztec-nr/aztec/src/abi.nr +++ /dev/null @@ -1,70 +0,0 @@ -use dep::protocol_types::{ - abis::{ - call_context::CallContext, - private_circuit_public_inputs::PrivateCircuitPublicInputs, - public_circuit_public_inputs::PublicCircuitPublicInputs, - }, - address::{AztecAddress, EthAddress}, - contrakt::deployment_data::ContractDeploymentData, - hash::hash_args, - traits::{Hash, Serialize}, - header::Header, -}; - -// docs:start:private-global-variables -struct PrivateGlobalVariables { - chain_id: Field, - version: Field, -} -// docs:end:private-global-variables - -impl Serialize<2> for PrivateGlobalVariables { - fn serialize(self) -> [Field; 2] { - [self.chain_id, self.version] - } -} - -// docs:start:public-global-variables -struct PublicGlobalVariables { - chain_id: Field, - version: Field, - block_number: Field, - timestamp: Field, - coinbase: EthAddress, - fee_recipient: AztecAddress, -} -// docs:end:public-global-variables - -impl Serialize<6> for PublicGlobalVariables { - fn serialize(self) -> [Field; 6] { - [ - self.chain_id, - self.version, - self.block_number, - self.timestamp, - self.coinbase.to_field(), - self.fee_recipient.to_field(), - ] - } -} - -// PrivateContextInputs are expected to be provided to each private function -// docs:start:private-context-inputs -struct PrivateContextInputs { - call_context : CallContext, - historical_header: Header, - contract_deployment_data: ContractDeploymentData, - private_global_variables: PrivateGlobalVariables, -} -// docs:end:private-context-inputs - -// PublicContextInputs are expected to be provided to each public function -// docs:start:public-context-inputs -struct PublicContextInputs { - call_context: CallContext, - historical_header: Header, - - public_global_variables: PublicGlobalVariables, -} -// docs:end:public-context-inputs - diff --git a/yarn-project/aztec-nr/aztec/src/context.nr b/yarn-project/aztec-nr/aztec/src/context.nr index 911ee98f17c..8cc2c2a22c2 100644 --- a/yarn-project/aztec-nr/aztec/src/context.nr +++ b/yarn-project/aztec-nr/aztec/src/context.nr @@ -1,9 +1,12 @@ -mod private; -mod public; +mod globals; +mod inputs; + +mod private_context; +mod public_context; mod avm; -use public::PublicContext; -use private::PrivateContext; +use private_context::PrivateContext; +use public_context::PublicContext; use avm::AVMContext; struct Context { diff --git a/yarn-project/aztec-nr/aztec/src/context/globals.nr b/yarn-project/aztec-nr/aztec/src/context/globals.nr new file mode 100644 index 00000000000..8b50aa87a59 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/globals.nr @@ -0,0 +1,2 @@ +mod private_global_variables; +mod public_global_variables; diff --git a/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr b/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr new file mode 100644 index 00000000000..63bf5fe95d1 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr @@ -0,0 +1,14 @@ +use dep::protocol_types::traits::Serialize; + +// docs:start:private-global-variables +struct PrivateGlobalVariables { + chain_id: Field, + version: Field, +} +// docs:end:private-global-variables + +impl Serialize<2> for PrivateGlobalVariables { + fn serialize(self) -> [Field; 2] { + [self.chain_id, self.version] + } +} diff --git a/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr b/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr new file mode 100644 index 00000000000..586769a429f --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr @@ -0,0 +1,31 @@ +use dep::protocol_types::{ + address::{ + AztecAddress, + EthAddress, + }, + traits::Serialize, +}; + +// docs:start:public-global-variables +struct PublicGlobalVariables { + chain_id: Field, + version: Field, + block_number: Field, + timestamp: Field, + coinbase: EthAddress, + fee_recipient: AztecAddress, +} +// docs:end:public-global-variables + +impl Serialize<6> for PublicGlobalVariables { + fn serialize(self) -> [Field; 6] { + [ + self.chain_id, + self.version, + self.block_number, + self.timestamp, + self.coinbase.to_field(), + self.fee_recipient.to_field(), + ] + } +} diff --git a/yarn-project/aztec-nr/aztec/src/context/inputs.nr b/yarn-project/aztec-nr/aztec/src/context/inputs.nr new file mode 100644 index 00000000000..2a95cd3bb78 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/inputs.nr @@ -0,0 +1,2 @@ +mod private_context_inputs; +mod public_context_inputs; diff --git a/yarn-project/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr b/yarn-project/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr new file mode 100644 index 00000000000..b96f62e6e50 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr @@ -0,0 +1,16 @@ +use dep::protocol_types::{ + abis::call_context::CallContext, + contrakt::deployment_data::ContractDeploymentData, + header::Header, +}; +use crate::context::globals::private_global_variables::PrivateGlobalVariables; + +// PrivateContextInputs are expected to be provided to each private function +// docs:start:private-context-inputs +struct PrivateContextInputs { + call_context : CallContext, + historical_header: Header, + contract_deployment_data: ContractDeploymentData, + private_global_variables: PrivateGlobalVariables, +} +// docs:end:private-context-inputs \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr b/yarn-project/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr new file mode 100644 index 00000000000..6fefcfed3b7 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr @@ -0,0 +1,16 @@ +use crate::context::globals::public_global_variables::PublicGlobalVariables; + +use dep::protocol_types::{ + abis::call_context::CallContext, + header::Header, +}; + +// PublicContextInputs are expected to be provided to each public function +// docs:start:public-context-inputs +struct PublicContextInputs { + call_context: CallContext, + historical_header: Header, + + public_global_variables: PublicGlobalVariables, +} +// docs:end:public-context-inputs diff --git a/yarn-project/aztec-nr/aztec/src/context/private.nr b/yarn-project/aztec-nr/aztec/src/context/private_context.nr similarity index 99% rename from yarn-project/aztec-nr/aztec/src/context/private.nr rename to yarn-project/aztec-nr/aztec/src/context/private_context.nr index 1692808fbdb..3c64a0c619e 100644 --- a/yarn-project/aztec-nr/aztec/src/context/private.nr +++ b/yarn-project/aztec-nr/aztec/src/context/private_context.nr @@ -1,5 +1,5 @@ use crate::{ - abi::PrivateContextInputs, + context::inputs::private_context_inputs::PrivateContextInputs, key::nullifier_key::validate_nullifier_key_against_address, messaging::process_l1_to_l2_message, oracle::{ diff --git a/yarn-project/aztec-nr/aztec/src/context/public.nr b/yarn-project/aztec-nr/aztec/src/context/public_context.nr similarity index 99% rename from yarn-project/aztec-nr/aztec/src/context/public.nr rename to yarn-project/aztec-nr/aztec/src/context/public_context.nr index 19bb51c6bb9..3ebad5e1d18 100644 --- a/yarn-project/aztec-nr/aztec/src/context/public.nr +++ b/yarn-project/aztec-nr/aztec/src/context/public_context.nr @@ -1,5 +1,5 @@ use crate::{ - abi::PublicContextInputs, + context::inputs::public_context_inputs::PublicContextInputs, messaging::process_l1_to_l2_message, oracle::{ arguments, diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index cf15736a3d5..4b02952d76a 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -1,4 +1,3 @@ -mod abi; mod avm; mod context; mod hash; From 41a5702d3f924a715645822a2f2435088ea379f5 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 13:12:01 +0000 Subject: [PATCH 03/12] fixed macros --- avm-transpiler/Cargo.lock | 16 ++++++++++++++++ noir/Cargo.lock | 12 +++++++++++- noir/aztec_macros/Cargo.toml | 1 + noir/aztec_macros/src/lib.rs | 27 +++++++++++++++++---------- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/avm-transpiler/Cargo.lock b/avm-transpiler/Cargo.lock index 718f61220a5..b571e5ffbd4 100644 --- a/avm-transpiler/Cargo.lock +++ b/avm-transpiler/Cargo.lock @@ -317,6 +317,7 @@ dependencies = [ name = "aztec_macros" version = "0.23.0" dependencies = [ + "convert_case", "iter-extended", "noirc_frontend", ] @@ -550,6 +551,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -1775,6 +1785,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.11" diff --git a/noir/Cargo.lock b/noir/Cargo.lock index 93f1d25fc76..291ac30336c 100644 --- a/noir/Cargo.lock +++ b/noir/Cargo.lock @@ -418,6 +418,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" name = "aztec_macros" version = "0.23.0" dependencies = [ + "convert_case 0.6.0", "iter-extended", "noirc_frontend", ] @@ -1003,6 +1004,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -1368,7 +1378,7 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", diff --git a/noir/aztec_macros/Cargo.toml b/noir/aztec_macros/Cargo.toml index 04f74d3b022..5e908b2e672 100644 --- a/noir/aztec_macros/Cargo.toml +++ b/noir/aztec_macros/Cargo.toml @@ -12,3 +12,4 @@ repository.workspace = true [dependencies] noirc_frontend.workspace = true iter-extended.workspace = true +convert_case = "0.6.0" diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 7a9050ae3d7..316b1015490 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -17,6 +17,7 @@ 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; +use convert_case::{Case, Casing}; pub struct AztecMacro; @@ -1049,7 +1050,10 @@ fn generate_selector_impl(structure: &NoirStruct) -> TypeImpl { fn create_inputs(ty: &str) -> Param { let context_ident = ident("inputs"); let context_pattern = Pattern::Identifier(context_ident); - let type_path = chained_path!("aztec", "context", "inputs", "private_context_inputs", ty); + + let path_snippet = ty.to_case(Case::Snake); // e.g. private_context_inputs + let type_path = chained_path!("aztec", "context", "inputs", &path_snippet, ty); + let context_type = make_type(UnresolvedTypeData::Named(type_path, vec![])); let visibility = Visibility::Private; @@ -1145,15 +1149,17 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac let hash_call = method_call( variable("hasher"), // variable "hash", // method name - vec![], // args + vec![], // args ); + let path_snippet = ty.to_case(Case::Snake); // e.g. private_context + // let mut context = {ty}::new(inputs, hash); let let_context = mutable_assignment( "context", // Assigned to call( - variable_path(chained_path!("aztec", "context", ty, "new")), // Path - vec![inputs_expression, hash_call], // args + variable_path(chained_path!("aztec", "context", &path_snippet, ty, "new")), // Path + vec![inputs_expression, hash_call], // args ), ); injected_expressions.push(let_context); @@ -1200,7 +1206,7 @@ fn create_avm_context() -> Result { /// ```noir /// /// Before /// #[aztec(private)] -/// fn foo() -> abi::PrivateCircuitPublicInputs { +/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { /// // ... /// let my_return_value: Field = 10; /// context.return_values.push(my_return_value); @@ -1376,8 +1382,8 @@ fn make_castable_return_type(expression: Expression) -> Statement { /// Create Return Type /// -/// Public functions return abi::PublicCircuitPublicInputs while -/// private functions return abi::PrivateCircuitPublicInputs +/// Public functions return protocol_types::abis::public_circuit_public_inputs::PublicCircuitPublicInputs while +/// private functions return protocol_types::abis::private_circuit_public_inputs::::PrivateCircuitPublicInputs /// /// This call constructs an ast token referencing the above types /// The name is set in the function above `transform`, hence the @@ -1387,7 +1393,7 @@ fn make_castable_return_type(expression: Expression) -> Statement { /// ```noir /// /// /// Before -/// fn foo() -> abi::PrivateCircuitPublicInputs { +/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { /// // ... /// } /// @@ -1397,7 +1403,8 @@ fn make_castable_return_type(expression: Expression) -> Statement { /// // ... /// } fn create_return_type(ty: &str) -> FunctionReturnType { - let return_path = chained_path!("aztec", "abi", ty); + let path_snippet = ty.to_case(Case::Snake); // e.g. private_circuit_public_inputs or public_circuit_public_inputs + let return_path = chained_path!("aztec", "protocol_types", "abis", &path_snippet, ty); return_type(return_path) } @@ -1409,7 +1416,7 @@ fn create_return_type(ty: &str) -> FunctionReturnType { /// The replaced code: /// ```noir /// /// Before -/// fn foo() -> abi::PrivateCircuitPublicInputs { +/// fn foo() -> protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs { /// // ... /// context.finish() /// } From 4c25a1e63829f05cbd3bcc0bab511f430ca74cdd Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 13:28:58 +0000 Subject: [PATCH 04/12] fixing imports --- .../contracts/child_contract/src/main.nr | 6 ++++-- .../contracts/docs_example_contract/src/main.nr | 8 ++++---- .../contracts/ecdsa_account_contract/src/main.nr | 6 ++++-- .../contracts/test_contract/src/main.nr | 15 +++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) 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..a830f36be2b 100644 --- a/yarn-project/noir-contracts/contracts/child_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/child_contract/src/main.nr @@ -3,13 +3,15 @@ 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, + abis::{ + call_context::CallContext, + function_selector::FunctionSelector, + }, address::AztecAddress, }; 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 c80b7559a55..972632f2991 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 @@ -244,10 +244,10 @@ contract DocsExample { } /// Macro equivalence section - use dep::aztec::abi; use dep::aztec::hasher::Hasher; - use dep::aztec::abi::PrivateContextInputs; - use dep::aztec::abi::PrivateCircuitPublicInputs; + + use dep::aztec::protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; + use dep::aztec::context::inputs::private_context_inputs::PrivateContextInputs; // docs:start:simple_macro_example #[aztec(private)] @@ -270,7 +270,7 @@ contract DocsExample { b: Field // The actual return type of our circuit is the PrivateCircuitPublicInputs struct, this will be the // input to our kernel! // docs:start:context-example-return - ) -> distinct pub abi::PrivateCircuitPublicInputs { + ) -> distinct pub PrivateCircuitPublicInputs { // docs:end:context-example-return // ************************************************************ // The hasher is a structure used to generate a hash of the circuits inputs. 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..b94b576b364 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,11 +3,13 @@ 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::{ + abis::call_context::CallContext, + address::AztecAddress, + }; use dep::std; use dep::std::option::Option; use dep::aztec::{ - abi::CallContext, context::{PrivateContext, PublicContext, Context}, note::{ note_header::NoteHeader, 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 f2eaa8511c6..564221b2e8b 100644 --- a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr @@ -2,6 +2,7 @@ contract Test { use dep::std::option::Option; use dep::aztec::protocol_types::{ + abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, address::{ AztecAddress, EthAddress, @@ -9,7 +10,8 @@ contract Test { constants::{ MAX_READ_REQUESTS_PER_CALL, MAX_NOTES_PER_PAGE - } + }, + hash::hash_args, }; // 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 @@ -21,9 +23,10 @@ contract Test { // docs:end:unencrypted_import use dep::aztec::{ - context::Context, - abi, - abi::PrivateContextInputs, + context::{ + Context, + inputs::private_context_inputs::PrivateContextInputs, + }, hash::pedersen_hash, context::PrivateContext, note::{ @@ -191,7 +194,7 @@ contract Test { an_array: [Field; 2], a_struct: DummyNote, a_deep_struct: DeepStruct - ) -> distinct pub abi::PrivateCircuitPublicInputs { + ) -> distinct pub PrivateCircuitPublicInputs { let mut args: BoundedVec = BoundedVec::new(0); args.push(a_field); args.push(a_bool as Field); @@ -207,7 +210,7 @@ contract Test { args.push(note.amount); args.push(note.secret_hash); } - let args_hash = abi::hash_args(args.storage); + let args_hash = hash_args(args.storage); let mut context = PrivateContext::new(inputs, args_hash); context.return_values.push(args_hash); context.finish() From 82d3fa7674b470f5a91e6bb2872cf57e1a9357a6 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 13:35:50 +0000 Subject: [PATCH 05/12] nuking redundant implementation of PublicGlobalVariables --- .../globals/public_global_variables.nr | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr b/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr index 586769a429f..de68887afa8 100644 --- a/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr +++ b/yarn-project/aztec-nr/aztec/src/context/globals/public_global_variables.nr @@ -1,31 +1,2 @@ -use dep::protocol_types::{ - address::{ - AztecAddress, - EthAddress, - }, - traits::Serialize, -}; - -// docs:start:public-global-variables -struct PublicGlobalVariables { - chain_id: Field, - version: Field, - block_number: Field, - timestamp: Field, - coinbase: EthAddress, - fee_recipient: AztecAddress, -} -// docs:end:public-global-variables - -impl Serialize<6> for PublicGlobalVariables { - fn serialize(self) -> [Field; 6] { - [ - self.chain_id, - self.version, - self.block_number, - self.timestamp, - self.coinbase.to_field(), - self.fee_recipient.to_field(), - ] - } -} +// protocl global vars are equal to the private ones so we just re-export them here under a different name +use dep::protocol_types::abis::global_variables::GlobalVariables as PublicGlobalVariables; From 901da3d5e0362c4c6b25aeb995ce25650cf5bf4b Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 7 Feb 2024 14:12:02 +0000 Subject: [PATCH 06/12] removing redundant dependency from boxes --- boxes/blank-react/src/contracts/src/main.nr | 3 +-- boxes/blank/src/contracts/src/main.nr | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/boxes/blank-react/src/contracts/src/main.nr b/boxes/blank-react/src/contracts/src/main.nr index 84750a2da70..89c80306529 100644 --- a/boxes/blank-react/src/contracts/src/main.nr +++ b/boxes/blank-react/src/contracts/src/main.nr @@ -1,12 +1,11 @@ contract Blank { use dep::aztec::{ - abi, oracle::{ get_public_key::get_public_key, }, protocol_types::address::AztecAddress }; - + #[aztec(private)] fn constructor() {} diff --git a/boxes/blank/src/contracts/src/main.nr b/boxes/blank/src/contracts/src/main.nr index 28647415a6b..c5ccfa0ff44 100644 --- a/boxes/blank/src/contracts/src/main.nr +++ b/boxes/blank/src/contracts/src/main.nr @@ -1,12 +1,11 @@ contract Blank { use dep::aztec::{ - abi, oracle::{ get_public_key::get_public_key, }, protocol_types::address::AztecAddress }; - + #[aztec(private)] fn constructor() {} From 413f9fa1152f34c530136bcedbdd4eddd5243a86 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 09:37:50 +0000 Subject: [PATCH 07/12] fmt --- noir/aztec_macros/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 316b1015490..2143fbf6e3d 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -1,6 +1,7 @@ use std::borrow::{Borrow, BorrowMut}; use std::vec; +use convert_case::{Case, Casing}; use iter_extended::vecmap; use noirc_frontend::macros_api::FieldElement; use noirc_frontend::macros_api::{ @@ -17,7 +18,6 @@ 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; -use convert_case::{Case, Casing}; pub struct AztecMacro; @@ -1093,7 +1093,7 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac "hasher", // Assigned to call( variable_path(chained_path!("aztec", "hasher", "Hasher", "new")), // Path - vec![], // args + vec![], // args ), ); @@ -1149,7 +1149,7 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac let hash_call = method_call( variable("hasher"), // variable "hash", // method name - vec![], // args + vec![], // args ); let path_snippet = ty.to_case(Case::Snake); // e.g. private_context @@ -1159,7 +1159,7 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac "context", // Assigned to call( variable_path(chained_path!("aztec", "context", &path_snippet, ty, "new")), // Path - vec![inputs_expression, hash_call], // args + vec![inputs_expression, hash_call], // args ), ); injected_expressions.push(let_context); From b57d8b23ce23c4a3a9c949998f8892af55468acc Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 09:40:18 +0000 Subject: [PATCH 08/12] constant --- .../aztec/src/context/globals/private_global_variables.nr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr b/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr index 63bf5fe95d1..012db96d33c 100644 --- a/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr +++ b/yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr @@ -1,5 +1,7 @@ use dep::protocol_types::traits::Serialize; +global PRIVATE_GLOBAL_VARIABLES_LENGTH: Field = 2; + // docs:start:private-global-variables struct PrivateGlobalVariables { chain_id: Field, @@ -7,8 +9,8 @@ struct PrivateGlobalVariables { } // docs:end:private-global-variables -impl Serialize<2> for PrivateGlobalVariables { - fn serialize(self) -> [Field; 2] { +impl Serialize for PrivateGlobalVariables { + fn serialize(self) -> [Field; PRIVATE_GLOBAL_VARIABLES_LENGTH] { [self.chain_id, self.version] } } From 13425da30aff458cff421fc5f31ba2ecd2e85e86 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 09:52:27 +0000 Subject: [PATCH 09/12] re-exports --- yarn-project/aztec-nr/aztec/src/context/inputs.nr | 3 +++ yarn-project/aztec-nr/aztec/src/context/private_context.nr | 2 +- yarn-project/aztec-nr/aztec/src/context/public_context.nr | 2 +- .../noir-contracts/contracts/docs_example_contract/src/main.nr | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/yarn-project/aztec-nr/aztec/src/context/inputs.nr b/yarn-project/aztec-nr/aztec/src/context/inputs.nr index 2a95cd3bb78..0d7c56574d5 100644 --- a/yarn-project/aztec-nr/aztec/src/context/inputs.nr +++ b/yarn-project/aztec-nr/aztec/src/context/inputs.nr @@ -1,2 +1,5 @@ mod private_context_inputs; mod public_context_inputs; + +use crate::context::inputs::private_context_inputs::PrivateContextInputs; +use crate::context::inputs::public_context_inputs::PublicContextInputs; diff --git a/yarn-project/aztec-nr/aztec/src/context/private_context.nr b/yarn-project/aztec-nr/aztec/src/context/private_context.nr index 3c64a0c619e..0dc221e0034 100644 --- a/yarn-project/aztec-nr/aztec/src/context/private_context.nr +++ b/yarn-project/aztec-nr/aztec/src/context/private_context.nr @@ -1,5 +1,5 @@ use crate::{ - context::inputs::private_context_inputs::PrivateContextInputs, + context::inputs::PrivateContextInputs, key::nullifier_key::validate_nullifier_key_against_address, messaging::process_l1_to_l2_message, oracle::{ diff --git a/yarn-project/aztec-nr/aztec/src/context/public_context.nr b/yarn-project/aztec-nr/aztec/src/context/public_context.nr index 3ebad5e1d18..2309a906d22 100644 --- a/yarn-project/aztec-nr/aztec/src/context/public_context.nr +++ b/yarn-project/aztec-nr/aztec/src/context/public_context.nr @@ -1,5 +1,5 @@ use crate::{ - context::inputs::public_context_inputs::PublicContextInputs, + context::inputs::PublicContextInputs, messaging::process_l1_to_l2_message, oracle::{ arguments, 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 972632f2991..d884a56a40f 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 @@ -247,7 +247,7 @@ contract DocsExample { use dep::aztec::hasher::Hasher; use dep::aztec::protocol_types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; - use dep::aztec::context::inputs::private_context_inputs::PrivateContextInputs; + use dep::aztec::context::inputs::PrivateContextInputs; // docs:start:simple_macro_example #[aztec(private)] From 3acf03a5688a36ef9f7cf4c21a6e79e83d17d0fa Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 09:57:22 +0000 Subject: [PATCH 10/12] import cleanup --- boxes/token/src/contracts/src/main.nr | 7 +++++-- boxes/token/src/contracts/src/types/balances_map.nr | 2 +- yarn-project/aztec-nr/aztec/src/context/private_context.nr | 2 -- .../noir-contracts/contracts/token_contract/src/main.nr | 1 - .../contracts/token_contract/src/types/balances_map.nr | 3 +-- .../contracts/uniswap_contract/src/interfaces.nr | 2 +- .../noir-contracts/contracts/uniswap_contract/src/main.nr | 1 - 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/boxes/token/src/contracts/src/main.nr b/boxes/token/src/contracts/src/main.nr index a6c67b253ed..6bef8316bea 100644 --- a/boxes/token/src/contracts/src/main.nr +++ b/boxes/token/src/contracts/src/main.nr @@ -21,7 +21,6 @@ contract Token { note_header::NoteHeader, utils as note_utils, }, - context::{PrivateContext, PublicContext, Context}, hash::{compute_secret_hash}, state_vars::{map::Map, public_state::PublicState, set::Set}, protocol_types::{ @@ -328,7 +327,11 @@ contract Token { ) -> pub [Field; 4] { let note_header = NoteHeader::new(contract_address, nonce, storage_slot); if (storage_slot == storage.pending_shields.get_storage_slot()) { - note_utils::compute_note_hash_and_nullifier(TransparentNote::deserialize_content, note_header, serialized_note) + note_utils::compute_note_hash_and_nullifier( + TransparentNote::deserialize_content, + note_header, + serialized_note + ) } else { note_utils::compute_note_hash_and_nullifier(TokenNote::deserialize_content, note_header, serialized_note) } diff --git a/boxes/token/src/contracts/src/types/balances_map.nr b/boxes/token/src/contracts/src/types/balances_map.nr index 3b4c0607528..286a7825645 100644 --- a/boxes/token/src/contracts/src/types/balances_map.nr +++ b/boxes/token/src/contracts/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}, + context::Context, hash::pedersen_hash, protocol_types::{ address::AztecAddress, diff --git a/yarn-project/aztec-nr/aztec/src/context/private_context.nr b/yarn-project/aztec-nr/aztec/src/context/private_context.nr index 0dc221e0034..1fdad5a141a 100644 --- a/yarn-project/aztec-nr/aztec/src/context/private_context.nr +++ b/yarn-project/aztec-nr/aztec/src/context/private_context.nr @@ -40,9 +40,7 @@ use dep::protocol_types::{ NUM_FIELDS_PER_SHA256, RETURN_VALUES_LENGTH, }, - contract_class::ContractClassId, contrakt::{ - deployment_data::ContractDeploymentData, storage_read::StorageRead, storage_update_request::StorageUpdateRequest, }, 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..1c21fd1f95a 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/main.nr @@ -22,7 +22,6 @@ contract Token { 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::{ 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..8452ba327a7 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,8 +1,7 @@ use dep::std::option::Option; use dep::safe_math::SafeU120; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - hash::pedersen_hash, + context::Context, protocol_types::{ address::AztecAddress, constants::MAX_READ_REQUESTS_PER_CALL, 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..3db1354766b 100644 --- a/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr +++ b/yarn-project/noir-contracts/contracts/uniswap_contract/src/interfaces.nr @@ -7,7 +7,7 @@ use dep::aztec::protocol_types::{ }, }; use dep::aztec::{ - context::{ PrivateContext, PublicContext, Context }, + context::{ PrivateContext, PublicContext }, }; struct Token { 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..b389f1b3413 100644 --- a/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -14,7 +14,6 @@ contract Uniswap { }, }; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, oracle::{context::get_portal_address}, state_vars::{map::Map, public_state::PublicState}, }; From c8dddc550330141250571cc9e25ee9e6fd57d878 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 10:06:54 +0000 Subject: [PATCH 11/12] fixed docs imports --- docs/docs/developers/contracts/portals/main.md | 4 ++-- docs/docs/developers/contracts/syntax/context.md | 10 +++++----- docs/docs/developers/contracts/syntax/globals.md | 4 ++-- .../src/crates/types/src/abis/global_variables.nr | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/docs/developers/contracts/portals/main.md b/docs/docs/developers/contracts/portals/main.md index 71e5bd40751..69142288e6d 100644 --- a/docs/docs/developers/contracts/portals/main.md +++ b/docs/docs/developers/contracts/portals/main.md @@ -42,7 +42,7 @@ To consume the message, we can use the `consume_l1_to_l2_message` function withi Note that while the `secret` and the `content` are both hashed, they are actually hashed with different hash functions! ::: -#include_code context_consume_l1_to_l2_message /yarn-project/aztec-nr/aztec/src/context/private.nr rust +#include_code context_consume_l1_to_l2_message /yarn-project/aztec-nr/aztec/src/context/private_context.nr rust Computing the `content` must be done manually in its current form, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/contracts/token_bridge_contract/src/util.nr). @@ -78,7 +78,7 @@ The portal must ensure that the sender is as expected. One way to do this is to To send a message to L1 from your Aztec contract, you must use the `message_portal` function on the `context`. When messaging to L1, only the `content` is required (as a `Field`). -#include_code context_message_portal /yarn-project/aztec-nr/aztec/src/context/private.nr rust +#include_code context_message_portal /yarn-project/aztec-nr/aztec/src/context/private_context.nr rust When sending a message from L2 to L1 we don't need to pass recipient, deadline, secret nor fees. Recipient is populated with the attached portal and the remaining values are not needed as the message is inserted into the outbox at the same time as it was included in a block (for the inbox it could be inserted and then only included in rollup block later). diff --git a/docs/docs/developers/contracts/syntax/context.md b/docs/docs/developers/contracts/syntax/context.md index 29194058641..eea03e8eb0f 100644 --- a/docs/docs/developers/contracts/syntax/context.md +++ b/docs/docs/developers/contracts/syntax/context.md @@ -34,7 +34,7 @@ The following section will cover both contexts. ## The Private Context The code snippet below shows what is contained within the private context. -#include_code private-context /yarn-project/aztec-nr/aztec/src/context/private.nr rust +#include_code private-context /yarn-project/aztec-nr/aztec/src/context/private_context.nr rust ### Private Context Broken Down @@ -42,7 +42,7 @@ The code snippet below shows what is contained within the private context. The context inputs includes all of the information that is passed from the kernel circuit into the application circuit. It contains the following values. -#include_code private-context-inputs /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code private-context-inputs /yarn-project/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr rust As shown in the snippet, the application context is made up of 4 main structures. The call context, the block header, the contract deployment data and the private global variables. @@ -89,7 +89,7 @@ Just like with the `is_contract_deployment` flag mentioned earlier. This data wi In the private execution context, we only have access to a subset of the total global variables, we are restricted to those which can be reliably proven by the kernel circuits. -#include_code private-global-variables /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code private-global-variables /yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr rust ### Args Hash @@ -141,10 +141,10 @@ The Public Context includes all of the information passed from the `Public VM` i In the current version of the system, the public context is almost a clone of the private execution context. It contains the same call context data, access to the same historical tree roots, however it does NOT have access to contract deployment data, this is due to traditional contract deployments only currently being possible from private transactions. -#include_code public-context-inputs /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code public-context-inputs /yarn-project/aztec-nr/aztec/src/context/inputs/public_context_inputs.nr rust ### Public Global Variables The public global variables are provided by the rollup sequencer and consequently contain some more values than the private global variables. -#include_code public-global-variables /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code global-variables /yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr rust diff --git a/docs/docs/developers/contracts/syntax/globals.md b/docs/docs/developers/contracts/syntax/globals.md index 1778c75e56d..4f66ff577a6 100644 --- a/docs/docs/developers/contracts/syntax/globals.md +++ b/docs/docs/developers/contracts/syntax/globals.md @@ -9,7 +9,7 @@ For developers coming from solidity, this concept will be similar to how the glo `Aztec` has two execution environments, Private and Public. Each execution environment contains a different global variables object. ## Private Global Variables -#include_code private-global-variables /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code private-global-variables /yarn-project/aztec-nr/aztec/src/context/globals/private_global_variables.nr rust The private global variables contain: ### Chain Id @@ -27,7 +27,7 @@ context.version(); ## Public Global Variables -#include_code public-global-variables /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code global-variables /yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr rust The public global variables contain the values present in the `private global variables` described above, with the addition of: diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr index c7d9ef97d10..81c040a246b 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/global_variables.nr @@ -16,6 +16,7 @@ use crate::{ }, }; +// docs:start:global-variables struct GlobalVariables { chain_id : Field, version : Field, @@ -24,6 +25,7 @@ struct GlobalVariables { coinbase : EthAddress, fee_recipient : AztecAddress, } +// docs:end:global-variables impl Serialize for GlobalVariables { fn serialize(self) -> [Field; GLOBAL_VARIABLES_LENGTH] { From dd7575528deb58ee607d64a3ae3d9af16ca23bf9 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 8 Feb 2024 12:40:40 +0000 Subject: [PATCH 12/12] change to try to re-trigger full CI build --- l1-contracts/src/core/libraries/DataStructures.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/src/core/libraries/DataStructures.sol b/l1-contracts/src/core/libraries/DataStructures.sol index f588c7c1d4d..14be2064f07 100644 --- a/l1-contracts/src/core/libraries/DataStructures.sol +++ b/l1-contracts/src/core/libraries/DataStructures.sol @@ -54,7 +54,7 @@ library DataStructures { * @param sender - The sender of the message * @param recipient - The recipient of the message * @param content - The content of the message (application specific) padded to bytes32 or hashed if larger. - * @param secretHash - The secret hash of the message (make it possible to hide when a specific message is consumed on L2) + * @param secretHash - The secret hash of the message (make it possible to hide when a specific message is consumed on L2). * @param deadline - The deadline to consume a message. Only after it, can a message be cancelled. * @param fee - The fee provided to sequencer for including the entry */