diff --git a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr index 0eaf0adea0ea..cd67cabb8c1c 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr @@ -6,9 +6,52 @@ use crate::macros::{ }, }; +/// Generates the per-contract helper that builds public `self`. +/// +/// Each public external function calls this helper instead of inlining the construction, so the same preamble does not +/// appear duplicated in every public function body. We let Noir's inliner decide whether to inline the helper at each +/// call site rather than forcing it via macro expansion. +/// +/// The helper is generic over the calldata length `N` because `PublicContext::new` takes a closure that reads `N` +/// fields from calldata. Noir monomorphizes one copy per distinct `N`, so public functions with the same number of +/// serialized args reuse the same compiled code. +pub(crate) comptime fn generate_public_self_creator(m: Module) -> Quoted { + let (storage_type, storage_init) = if module_has_storage(m) { + (quote { Storage }, quote { let storage = Storage::init(context); }) + } else { + // Contract does not have Storage defined, so we set storage to the unit type `()`. ContractSelfPublic requires + // a storage struct in its constructor. Using an Option type would lead to worse developer experience and + // higher constraint counts so we use the unit type `()` instead. + (quote { () }, quote { let storage = (); }) + }; + + quote { + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::ContractSelfPublic< + $storage_type, + CallSelf, + CallSelfStatic, + CallInternal, + > { + // Unlike in the private case, in public the `context` does not need to receive the hash of the original + // params. + let context = aztec::context::PublicContext::new(|| { + // We start from 1 because we skip the selector for the dispatch function. + let serialized_args : [Field; N] = aztec::oracle::avm::calldata_copy(1, N); + aztec::hash::hash_args(serialized_args) + }); + $storage_init + let self_address = context.this_address(); + let call_self: CallSelf = CallSelf { address: self_address, context }; + let call_self_static: CallSelfStatic = CallSelfStatic { address: self_address, context }; + let internal: CallInternal = CallInternal { context }; + aztec::contract_self::ContractSelfPublic::new(context, storage, call_self, call_self_static, internal) + } + } +} + pub(crate) comptime fn generate_public_external(f: FunctionDefinition) -> Quoted { let module_has_initializer = module_has_initializer(f.module()); - let module_has_storage = module_has_storage(f.module()); // Public functions undergo a lot of transformations from their Aztec.nr form. let original_params = f.parameters(); @@ -28,35 +71,9 @@ pub(crate) comptime fn generate_public_external(f: FunctionDefinition) -> Quoted .join(quote {+}) }; - let storage_init = if module_has_storage { - quote { - let storage = Storage::init(context); - } - } else { - // Contract does not have Storage defined, so we set storage to the unit type `()`. ContractSelfPublic requires - // a storage struct in its constructor. Using an Option type would lead to worse developer experience and - // higher constraint counts so we use the unit type `()` instead. - quote { - let storage = (); - } - }; - - // Unlike in the private case, in public the `context` does not need to receive the hash of the original params. let contract_self_creation = quote { #[allow(unused_variables)] - let mut self = { - let context = aztec::context::PublicContext::new(|| { - // We start from 1 because we skip the selector for the dispatch function. - let serialized_args : [Field; $args_len_quote] = aztec::oracle::avm::calldata_copy(1, $args_len_quote); - aztec::hash::hash_args(serialized_args) - }); - $storage_init - let self_address = context.this_address(); - let call_self: CallSelf = CallSelf { address: self_address, context }; - let call_self_static: CallSelfStatic = CallSelfStatic { address: self_address, context }; - let internal: CallInternal = CallInternal { context }; - aztec::contract_self::ContractSelfPublic::new(context, storage, call_self, call_self_static, internal) - }; + let mut self = __aztec_nr_internals__create_public_self::<$args_len_quote>(); }; let original_function_name = f.name(); diff --git a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr index 58f0290c4e8e..030fc37c36ee 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr @@ -12,7 +12,9 @@ pub(crate) mod internal; use abi_export::create_fn_abi_export; use external::{ - private::generate_private_external, public::generate_public_external, utility::generate_utility_external, + private::generate_private_external, + public::{generate_public_external, generate_public_self_creator}, + utility::generate_utility_external, }; use internal::{generate_private_internal, generate_public_internal}; @@ -47,6 +49,15 @@ pub(crate) comptime fn process_functions(m: Module) -> Quoted { let transformed_utility_functions = utility_functions.map(|function| generate_utility_external(function)).join(quote {}); + // Emit a contract-level helper that constructs `self` for public functions. Each transformed public function calls + // this helper rather than inlining the preamble. The helper is only useful for public external functions, so we + // skip emitting it when the contract has none. + let public_self_creator = if public_functions.len() > 0 { + generate_public_self_creator(m) + } else { + quote {} + }; + // Now that we have generated quotes of the new functions based on the original function definitions, we replace // the original functions' bodies with `static_assert(false, ...)` to prevent them from being called directly from // within the contract. We also need to set the return type to `()` to avoid compilation errors. @@ -84,6 +95,7 @@ pub(crate) comptime fn process_functions(m: Module) -> Quoted { // We return the new functions' quotes to be injected into the contract. quote { + $public_self_creator $transformed_private_functions $transformed_public_functions $transformed_utility_functions diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr index c5165f594d43..d4f2cb93b1da 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr @@ -159,10 +159,7 @@ impl CallPrivateOptions { self, additional_scopes: [AztecAddress; N_2], ) -> CallPrivateOptions { - CallPrivateOptions { - additional_scopes, - authorized_utility_call_targets: self.authorized_utility_call_targets, - } + CallPrivateOptions { additional_scopes, authorized_utility_call_targets: self.authorized_utility_call_targets } } /// Authorizes cross-contract utility calls to the given target contracts during this call. @@ -173,10 +170,7 @@ impl CallPrivateOptions { self, targets: [AztecAddress; T_2], ) -> CallPrivateOptions { - CallPrivateOptions { - additional_scopes: self.additional_scopes, - authorized_utility_call_targets: targets, - } + CallPrivateOptions { additional_scopes: self.additional_scopes, authorized_utility_call_targets: targets } } } @@ -214,10 +208,7 @@ impl ViewPrivateOptions { self, additional_scopes: [AztecAddress; S2], ) -> ViewPrivateOptions { - ViewPrivateOptions { - additional_scopes, - authorized_utility_call_targets: self.authorized_utility_call_targets, - } + ViewPrivateOptions { additional_scopes, authorized_utility_call_targets: self.authorized_utility_call_targets } } /// Authorizes cross-contract utility calls to the given target contracts during this call. @@ -228,10 +219,7 @@ impl ViewPrivateOptions { self, targets: [AztecAddress; T_2], ) -> ViewPrivateOptions { - ViewPrivateOptions { - additional_scopes: self.additional_scopes, - authorized_utility_call_targets: targets, - } + ViewPrivateOptions { additional_scopes: self.additional_scopes, authorized_utility_call_targets: targets } } } @@ -773,10 +761,7 @@ impl TestEnvironment { /// let contract_addr = env.deploy("SampleContract").without_initializer(); /// let return_value = env.execute_utility(SampleContract::at(contract_addr).sample_utility_function()); /// ``` - pub unconstrained fn execute_utility( - self: Self, - call: UtilityCall, - ) -> T + pub unconstrained fn execute_utility(self: Self, call: UtilityCall) -> T where T: Deserialize, { diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap index d41d90c9c38b..16b1da78250d 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_from_wrong_type/snapshots__stderr.snap @@ -14,13 +14,13 @@ error: Argument from in function foo must be of type AztecAddress, but is of typ 2: aztec at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 3: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:9 4: [T]::map at std/vector.nr:67:33 5: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:41 6: generate_public_external - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:114:9 7: create_authorize_once_check at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:72:9 diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap index 83939084f7a4..e91d74670519 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_from_param/snapshots__stderr.snap @@ -14,13 +14,13 @@ error: Function foo does not have a from parameter. Please specify which one to 2: aztec at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 3: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:9 4: [T]::map at std/vector.nr:67:33 5: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:41 6: generate_public_external - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:114:9 7: create_authorize_once_check at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:67:9 diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap index b0a19e34e8cc..550d3fd5e887 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_missing_nonce_param/snapshots__stderr.snap @@ -14,13 +14,13 @@ error: Function foo does not have a authwit_nonce. Please specify which one to u 2: aztec at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 3: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:9 4: [T]::map at std/vector.nr:67:33 5: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:41 6: generate_public_external - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:114:9 7: create_authorize_once_check at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:81:9 diff --git a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap index d2e4063624a2..cc49e0eac228 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/compile_failure/authorize_once_nonce_wrong_type/snapshots__stderr.snap @@ -14,13 +14,13 @@ error: Argument authwit_nonce in function foo must be of type Field, but is of t 2: aztec at /noir-projects/aztec-nr/aztec/src/macros/aztec.nr:97:21 3: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:9 4: [T]::map at std/vector.nr:67:33 5: process_functions - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:46:41 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/mod.nr:48:41 6: generate_public_external - at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:97:9 + at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr:114:9 7: create_authorize_once_check at /noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/helpers.nr:86:9 diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap index 1253e48c4746..9257c7534bb1 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/amm_contract/snapshots__expanded.snap @@ -2437,19 +2437,22 @@ pub contract AMM { self.context.finish() } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals___add_liquidity(config: Config, refund_token0_partial_note: PartialUintNote, refund_token1_partial_note: PartialUintNote, liquidity_partial_note: PartialUintNote, amount0_max: u128, amount1_max: u128, amount0_min: u128, amount1_min: u128) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10] = aztec::oracle::avm::calldata_copy(1_u32, ((((((>::N + ::N) + ::N) + ::N) + ::N) + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10>(); assert(self.msg_sender() == self.address, "Function _add_liquidity can only be called by the same contract"); { let token0: Token::Token = Token::at(config.token0); @@ -2481,18 +2484,7 @@ pub contract AMM { } unconstrained fn __aztec_nr_internals___remove_liquidity(config: Config, liquidity: u128, token0_partial_note: PartialUintNote, token1_partial_note: PartialUintNote, amount0_min: u128, amount1_min: u128) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 8] = aztec::oracle::avm::calldata_copy(1_u32, ((((>::N + ::N) + ::N) + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<8>(); assert(self.msg_sender() == self.address, "Function _remove_liquidity can only be called by the same contract"); { let token0: Token::Token = Token::at(config.token0); @@ -2511,18 +2503,7 @@ pub contract AMM { } unconstrained fn __aztec_nr_internals___swap_exact_tokens_for_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in: u128, amount_out_min: u128, token_out_partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 5] = aztec::oracle::avm::calldata_copy(1_u32, (((::N + ::N) + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<5>(); assert(self.msg_sender() == self.address, "Function _swap_exact_tokens_for_tokens can only be called by the same contract"); { let balance_in_plus_amount_in: u128 = self.view(Token::at(token_in).balance_of_public(self.address)); @@ -2535,18 +2516,7 @@ pub contract AMM { } unconstrained fn __aztec_nr_internals___swap_tokens_for_exact_tokens(token_in: AztecAddress, token_out: AztecAddress, amount_in_max: u128, amount_out: u128, change_token_in_partial_note: PartialUintNote, token_out_partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ((((::N + ::N) + ::N) + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<6>(); assert(self.msg_sender() == self.address, "Function _swap_tokens_for_exact_tokens can only be called by the same contract"); { let balance_in_plus_amount_in_max: u128 = self.view(Token::at(token_in).balance_of_public(self.address)); @@ -2563,18 +2533,7 @@ pub contract AMM { } unconstrained fn __aztec_nr_internals__constructor(token0: AztecAddress, token1: AztecAddress, liquidity_token: AztecAddress) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<3>(); aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_public(self.context); { self.storage.config.initialize(Config { token0: token0, token1: token1, liquidity_token: liquidity_token}); diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap index 2f36a53d539e..ffa8956a4747 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_gadgets_test_contract/snapshots__expanded.snap @@ -1219,433 +1219,183 @@ contract AvmGadgetsTest { return_type: [u8; 32], } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals__keccak_f1600(data: [u64; 25]) -> pub [u64; 25] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 25 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u64; 25] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<25 * 1>(); { std::hash::keccakf1600(data) } } unconstrained fn __aztec_nr_internals__keccak_hash(data: [u8; 10]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10 * 1>(); { keccak256::keccak256(data, data.len()) } } unconstrained fn __aztec_nr_internals__keccak_hash_1400(data: [u8; 1400]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1400 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1400] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1400 * 1>(); { keccak256::keccak256(data, data.len()) } } unconstrained fn __aztec_nr_internals__keccak_hash_300(data: [u8; 300]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 300] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<300 * 1>(); { keccak256::keccak256(data, data.len()) } } unconstrained fn __aztec_nr_internals__pedersen_hash(data: [Field; 10]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10 * 1>(); { std::hash::pedersen_hash(data) } } unconstrained fn __aztec_nr_internals__pedersen_hash_with_index(data: [Field; 10]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10 * 1>(); { std::hash::pedersen_hash_with_separator(data, 20_u32) } } unconstrained fn __aztec_nr_internals__poseidon2_hash(data: [Field; 10]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 10] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10 * 1>(); { poseidon::poseidon2::Poseidon2::hash(data, data.len()) } } unconstrained fn __aztec_nr_internals__poseidon2_hash_1000fields(data: [Field; 1000]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1000 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 1000] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1000 * 1>(); { poseidon::poseidon2::Poseidon2::hash(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_10(data: [u8; 10]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 10 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 10] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<10 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_100(data: [u8; 100]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 100 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 100] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<100 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_1024(data: [u8; 1024]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1024 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1024] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1024 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_1536(data: [u8; 1536]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1536 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 1536] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1536 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_20(data: [u8; 20]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 20 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 20] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<20 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_255(data: [u8; 255]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 255 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 255] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<255 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_256(data: [u8; 256]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 256 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 256] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<256 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_30(data: [u8; 30]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 30 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 30] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<30 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_40(data: [u8; 40]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 40 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 40] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<40 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_50(data: [u8; 50]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 50 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 50] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<50 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_511(data: [u8; 511]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 511 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 511] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<511 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_512(data: [u8; 512]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 512 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 512] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<512 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_60(data: [u8; 60]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 60 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 60] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<60 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_70(data: [u8; 70]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 70 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 70] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<70 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_80(data: [u8; 80]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 80 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 80] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<80 * 1>(); { sha256::sha256_var(data, data.len()) } } unconstrained fn __aztec_nr_internals__sha256_hash_90(data: [u8; 90]) -> pub [u8; 32] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 90 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[u8; 90] as aztec::protocol::traits::Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<90 * 1>(); { sha256::sha256_var(data, data.len()) } diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap index 7b88b9531a0c..26297d6007ad 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/avm_test_contract/snapshots__expanded.snap @@ -5999,73 +5999,43 @@ pub contract AvmTest { self.context.finish() } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> { + let context: PublicContext = PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals__add_args_return(arg_a: Field, arg_b: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { add(arg_a, arg_b) } } unconstrained fn __aztec_nr_internals__add_storage_map(to: AztecAddress, amount: u32) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _add_storage_map(self.storage, to, amount) } } unconstrained fn __aztec_nr_internals__add_u128(a: u128, b: u128) -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { a + b } } unconstrained fn __aztec_nr_internals__assert_calldata_copy(args: [Field; 3], with_selector: bool) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 3] as Serialize>::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); { let offset: u32 = with_selector as u32; let cd: [Field; 3] = aztec::oracle::avm::calldata_copy(offset, 3_u32); @@ -6074,18 +6044,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__assert_calldata_copy_large(args: [Field; 300], with_selector: bool) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 301] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<301>(); { let offset: u32 = with_selector as u32; let cd: [Field; 300] = aztec::oracle::avm::calldata_copy(offset, 300_u32); @@ -6094,36 +6053,14 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__assert_nullifier_exists(nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { assert(self.context.nullifier_exists_unsafe(nullifier, self.address), "Nullifier doesn't exist!"); } } unconstrained fn __aztec_nr_internals__assert_same(arg_a: Field, arg_b: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { assert(arg_a == arg_b, "Values are not equal"); 1_Field @@ -6131,36 +6068,14 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__assertion_failure() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { helper_with_failed_assertion() } } unconstrained fn __aztec_nr_internals__bulk_testing(args_field: [Field; 10], args_u8: [u8; 10], get_instance_for_address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field, skip_strictly_limited_side_effects: bool) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 25] = aztec::oracle::avm::calldata_copy(1_u32, (((((<[Field; 10] as Serialize>::N + <[u8; 10] as Serialize>::N) + ::N) + ::N) + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<25>(); { aztec::oracle::logging::debug_log("biwise_ops"); let num: u32 = self.context.block_number(); @@ -6249,72 +6164,28 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__call_auth_registry() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let _: bool = AuthRegistry::at(CANONICAL_AUTH_REGISTRY_ADDRESS).is_reject_all(self.address).view(self.context); } } unconstrained fn __aztec_nr_internals__call_fee_juice() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _call_fee_juice(self.context, self.address); } } unconstrained fn __aztec_nr_internals__call_instance_registry() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let _: u64 = self.view(ContractInstanceRegistry::at(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS).get_update_delay()); } } unconstrained fn __aztec_nr_internals__conditional_move(x: [Field; 1], y: [Field; 1], b: bool) -> pub [Field; 1] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (<[Field; 1] as Serialize>::N + <[Field; 1] as Serialize>::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<3>(); { if b { x @@ -6325,18 +6196,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { self.context.push_nullifier(nullifier); self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier + 1_Field)); @@ -6344,18 +6204,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { self.context.push_nullifier(nullifier); self.call(AvmTest::at(nestedAddress).new_nullifier(nullifier)); @@ -6363,18 +6212,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__debug_logging() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { aztec::oracle::logging::debug_log("just text"); aztec::oracle::logging::debug_log_format("second: {1}", [1_Field, 2_Field, 3_Field, 4_Field]); @@ -6386,54 +6224,21 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__divide_by_zero(denominator: u8) -> pub u8 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { 1_u8 / denominator } } unconstrained fn __aztec_nr_internals__elliptic_curve_add(lhs: Point, rhs: Point) -> pub Point { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 6] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<6>(); { lhs + rhs } } unconstrained fn __aztec_nr_internals__elliptic_curve_add_and_double() -> pub Point { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let g: Point = Point { x: GRUMPKIN_ONE_X, y: GRUMPKIN_ONE_Y, is_infinite: false}; let doubled: Point = g + g; @@ -6443,18 +6248,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__emit_nullifier_and_check(nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { self.context.push_nullifier(nullifier); let exists: bool = self.context.nullifier_exists_unsafe(nullifier, self.address); @@ -6463,72 +6257,28 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__emit_public_log() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _emit_public_log(self.context); } } unconstrained fn __aztec_nr_internals__external_call_to_assertion_failure() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { self.call_self.assertion_failure(); } } unconstrained fn __aztec_nr_internals__external_call_to_divide_by_zero() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let _: u8 = self.call_self.divide_by_zero(0_u8); } } unconstrained fn __aztec_nr_internals__external_call_to_divide_by_zero_recovers() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let l2_gas_left: u32 = self.context.l2_gas_left(); let da_gas_left: u32 = self.context.da_gas_left(); @@ -6541,288 +6291,112 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__fn_w_large_calldata(_arr: [Field; 300]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<300 * 1>(); { 5_Field } } unconstrained fn __aztec_nr_internals__get_address() -> pub AztecAddress { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_address(self.address) } } unconstrained fn __aztec_nr_internals__get_args_hash(_a: u8, _fields: [Field; 3]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ::N + <[Field; 3] as Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); { self.context.get_args_hash() } } unconstrained fn __aztec_nr_internals__get_block_number() -> pub u32 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_block_number(self.context) } } unconstrained fn __aztec_nr_internals__get_chain_id() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_chain_id(self.context) } } unconstrained fn __aztec_nr_internals__get_da_gas_left() -> pub u32 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_da_gas_left(self.context) } } unconstrained fn __aztec_nr_internals__get_fee_per_da_gas() -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_fee_per_da_gas(self.context) } } unconstrained fn __aztec_nr_internals__get_fee_per_l2_gas() -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_fee_per_l2_gas(self.context) } } unconstrained fn __aztec_nr_internals__get_l2_gas_left() -> pub u32 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_l2_gas_left(self.context) } } unconstrained fn __aztec_nr_internals__get_sender() -> pub AztecAddress { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_sender(self.context) } } unconstrained fn __aztec_nr_internals__get_timestamp() -> pub u64 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_timestamp(self.context) } } unconstrained fn __aztec_nr_internals__get_transaction_fee() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_transaction_fee(self.context) } } unconstrained fn __aztec_nr_internals__get_version() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _get_version(self.context) } } unconstrained fn __aztec_nr_internals__l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> pub bool { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _l1_to_l2_msg_exists(self.context, msg_hash, msg_leaf_index) } } unconstrained fn __aztec_nr_internals__modulo2(a: u64) -> pub u64 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { a % 2_u64 } } unconstrained fn __aztec_nr_internals__n_new_l2_to_l1_msgs(num: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { for i in 0_u32..num { self.context.message_portal(EthAddress::from_field(i as Field), i as Field) @@ -6831,18 +6405,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__n_new_note_hashes(num: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { for i in 0_u32..num { self.context.push_note_hash(i as Field); @@ -6851,18 +6414,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__n_new_nullifiers(num: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { for i in 0_u32..num { self.context.push_nullifier(i as Field); @@ -6871,18 +6423,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__n_new_public_logs(num: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { for i in 0_u32..num { self.context.emit_public_log_unsafe(0_Field, [i as Field]); @@ -6891,18 +6432,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__n_storage_writes(num: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { for i in 0_u32..num { self.storage.map.at(AztecAddress::from_field(i as Field)).write(i); @@ -6911,54 +6441,21 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__nested_call_large_calldata(arr: [Field; 300]) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 300 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[Field; 300] as Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<300 * 1>(); { self.call_self.fn_w_large_calldata(arr) } } unconstrained fn __aztec_nr_internals__nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _nested_call_to_add(self.context, self.address, arg_a, arg_b) } } unconstrained fn __aztec_nr_internals__nested_call_to_add_n_times_different_addresses(addrs: [AztecAddress; 23]) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 23 * 1] = aztec::oracle::avm::calldata_copy(1_u32, <[AztecAddress; 23] as Serialize>::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<23 * 1>(); { for i in 0_u32..MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS + 2_u32 { let addr: AztecAddress = addrs[i]; @@ -6970,54 +6467,21 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__nested_call_to_add_with_gas(arg_a: Field, arg_b: Field, l2_gas: u32, da_gas: u32) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); { self.call(AvmTest::at(self.address).add_args_return(arg_a, arg_b).with_gas(GasOpts::new(l2_gas, da_gas))) } } unconstrained fn __aztec_nr_internals__nested_call_to_assert_same(arg_a: Field, arg_b: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { self.call_self.assert_same(arg_a, arg_b) } } unconstrained fn __aztec_nr_internals__nested_call_to_nothing() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let garbageAddress: AztecAddress = AztecAddress::from_field(42_Field); self.call(AvmTest::at(garbageAddress).nested_call_to_nothing()) @@ -7025,18 +6489,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__nested_call_to_nothing_recovers() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let garbageAddress: AztecAddress = AztecAddress::from_field(42_Field); call(1_u32, 1_u32, garbageAddress, []); @@ -7046,36 +6499,14 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _nested_static_call_to_add(self.context, self.address, arg_a, arg_b) } } unconstrained fn __aztec_nr_internals__nested_static_call_to_set_storage() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let selector: FunctionSelector = FunctionSelector { inner: 2230419055_u32}; let args: [Field; 1] = [20_Field as Field]; @@ -7084,72 +6515,28 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__new_note_hash(note_hash: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _new_note_hash(self.context, note_hash); } } unconstrained fn __aztec_nr_internals__new_nullifier(nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _new_nullifier(self.context, nullifier); } } unconstrained fn __aztec_nr_internals__note_hash_exists(note_hash: Field, leaf_index: u64) -> pub bool { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _note_hash_exists(self.context, note_hash, leaf_index) } } unconstrained fn __aztec_nr_internals__nullifier_collision(nullifier: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { self.context.push_nullifier(nullifier); self.context.push_nullifier(nullifier); @@ -7157,36 +6544,14 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__nullifier_exists(nullifier: Field) -> pub bool { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _nullifier_exists(self.context, self.address, nullifier) } } unconstrained fn __aztec_nr_internals__pedersen_commit(x: Field, y: Field) -> pub Point { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { let commitment: std::embedded_curve_ops::EmbeddedCurvePoint = std::hash::pedersen_commitment_with_separator([x, y], 20_u32); commitment.into() @@ -7194,108 +6559,42 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__raw_l2_to_l1_msg(recipient: EthAddress, content: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { self.context.message_portal(recipient, content) } } unconstrained fn __aztec_nr_internals__read_assert_storage_single(a: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { assert(a == self.storage.single.read(), "Storage value does not match input"); } } unconstrained fn __aztec_nr_internals__read_storage_list() -> pub [Field; 2] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _read_storage_list(self.storage) } } unconstrained fn __aztec_nr_internals__read_storage_map(address: AztecAddress) -> pub u32 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _read_storage_map(self.storage, address) } } unconstrained fn __aztec_nr_internals__read_storage_single() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { _read_storage_single(self.storage) } } unconstrained fn __aztec_nr_internals__return_oracle() -> pub [Field; 3] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { avm_return([1_Field, 2_Field, 3_Field].as_slice()); [4_Field, 5_Field, 6_Field] @@ -7303,18 +6602,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__returndata_copy_oracle() { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let _: [Field; 3] = self.call_self.return_oracle(); let returndatasize: u32 = returndata_size(); @@ -7324,18 +6612,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__revert_oracle() -> pub [Field; 3] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { revert([1_Field, 2_Field, 3_Field].as_slice()); [4_Field, 5_Field, 6_Field] @@ -7343,144 +6620,56 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__send_l2_to_l1_msg(recipient: EthAddress, content: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _send_l2_to_l1_msg(self.context, recipient, content); } } unconstrained fn __aztec_nr_internals__set_opcode_big_field() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { big_field_136_bits } } unconstrained fn __aztec_nr_internals__set_opcode_really_big_field() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { big_field_254_bits } } unconstrained fn __aztec_nr_internals__set_opcode_small_field() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { big_field_128_bits } } unconstrained fn __aztec_nr_internals__set_opcode_u32() -> pub u32 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { 1_u32 << 30_u32 } } unconstrained fn __aztec_nr_internals__set_opcode_u64() -> pub u64 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { 1_u64 << 60_u64 } } unconstrained fn __aztec_nr_internals__set_opcode_u8() -> pub u8 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { 8_u8 } } unconstrained fn __aztec_nr_internals__set_opcode_u8_view() -> pub u8 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); assert(self.context.is_static_call(), "Function set_opcode_u8_view can only be called statically"); { 8_u8 @@ -7488,18 +6677,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__set_read_storage_single(a: Field) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { self.storage.single.write(a); self.storage.single.read() @@ -7507,72 +6685,28 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__set_storage_list(a: Field, b: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _set_storage_list(self.storage, a, b); } } unconstrained fn __aztec_nr_internals__set_storage_map(to: AztecAddress, amount: u32) -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); { _set_storage_map(self.storage, to, amount) } } unconstrained fn __aztec_nr_internals__set_storage_single(a: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _set_storage_single(self.storage, a); } } unconstrained fn __aztec_nr_internals__test_get_contract_instance(address: AztecAddress) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let deployer: Option = get_contract_instance_deployer_avm(address); let class_id: Option = get_contract_instance_class_id_avm(address); @@ -7587,72 +6721,28 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__test_get_contract_instance_matches(address: AztecAddress, expected_deployer: AztecAddress, expected_class_id: ContractClassId, expected_initialization_hash: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); { _test_get_contract_instance_matches(address, expected_deployer, expected_class_id, expected_initialization_hash); } } unconstrained fn __aztec_nr_internals__to_le_bits(input: Field) -> pub [bool; 16] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _to_le_bits(input) } } unconstrained fn __aztec_nr_internals__to_le_bytes(input: Field) -> pub [u8; 10] { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { _to_le_bytes(input) } } unconstrained fn __aztec_nr_internals__u128_addition_overflow() -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); { let max_u128: u128 = 340282366920938463463374607431768211455_u128; let one: u128 = 1_u128; @@ -7661,18 +6751,7 @@ pub contract AvmTest { } unconstrained fn __aztec_nr_internals__variable_base_msm(scalar_lo: Field, scalar_hi: Field, scalar2_lo: Field, scalar2_hi: Field) -> pub Point { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: PublicContext = PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); { let g: Point = Point { x: GRUMPKIN_ONE_X, y: GRUMPKIN_ONE_Y, is_infinite: false}; let triple_g: std::embedded_curve_ops::EmbeddedCurvePoint = multi_scalar_mul([g.to_embedded(), g.to_embedded()], [Scalar { lo: scalar_lo, hi: scalar_hi}, Scalar { lo: scalar2_lo, hi: scalar2_hi}]); diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/public_fns_with_emit_repro_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/public_fns_with_emit_repro_contract/snapshots__expanded.snap index 81841dad48de..cb3e8a11e0a6 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/public_fns_with_emit_repro_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/public_fns_with_emit_repro_contract/snapshots__expanded.snap @@ -2,7 +2,6 @@ source: tests/snapshots.rs expression: stdout --- - use aztec::macros::aztec; use aztec::macros::aztec; @@ -866,19 +865,22 @@ pub contract PublicFnsWithEmitRepro { parameters: fn_15_parameters, } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: aztec::protocol::address::AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals__fn_01(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 1_u64); @@ -887,18 +889,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_02(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 2_u64); @@ -907,18 +898,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_03(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 3_u64); @@ -927,18 +907,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_04(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 4_u64); @@ -947,18 +916,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_05(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 5_u64); @@ -967,18 +925,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_06(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 6_u64); @@ -987,18 +934,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_07(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 7_u64); @@ -1007,18 +943,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_08(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 8_u64); @@ -1027,18 +952,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_09(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 9_u64); @@ -1047,18 +961,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_10(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 10_u64); @@ -1067,18 +970,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_11(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 11_u64); @@ -1087,18 +979,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_12(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 12_u64); @@ -1107,18 +988,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_13(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 13_u64); @@ -1127,18 +997,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_14(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 14_u64); @@ -1147,18 +1006,7 @@ pub contract PublicFnsWithEmitRepro { } unconstrained fn __aztec_nr_internals__fn_15(v: u64) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: aztec::protocol::address::AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); { let old: u64 = self.storage.value.read(); self.storage.value.write((old + v) + 15_u64); diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap index 0bb78f0095c8..223210d26ec9 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/storage_proof_test_contract/snapshots__expanded.snap @@ -792,19 +792,22 @@ contract StorageProofTest { self.context.finish() } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: () = (); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals__account_proof(account: Account, root: [u64; 4], nodes: [Node; 15], node_length: u32) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1290] = aztec::oracle::avm::calldata_copy(1_u32, ((>::N + <[u64; 4] as Serialize>::N) + <[Node; 15] as Serialize>::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: () = (); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::<(), CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic<(), CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1290>(); assert(self.context.is_static_call(), "Function account_proof can only be called statically"); { let trie_key: [u8; 32] = KeccakHasher::hash_bytes(account.address, 20_u32); diff --git a/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap b/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap index ca20d6e6efd9..199838d29bba 100644 --- a/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap +++ b/noir-projects/contract-snapshots/tests/snapshots/expand/token_contract/snapshots__expanded.snap @@ -3773,19 +3773,22 @@ pub contract Token { self.context.finish() } + #[contract_library_method] + unconstrained fn __aztec_nr_internals__create_public_self() -> aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> { + let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { + let serialized_args: [Field; N] = aztec::oracle::avm::calldata_copy(1_u32, N); + aztec::hash::hash_args(serialized_args) + }); + let storage: Storage = Storage::::init(context); + let self_address: AztecAddress = context.this_address(); + let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; + let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; + let internal: CallInternal = CallInternal:: { context: context}; + aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) + } + unconstrained fn __aztec_nr_internals___finalize_mint_to_private_unsafe(minter_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<3>(); assert(self.msg_sender() == self.address, "Function _finalize_mint_to_private_unsafe can only be called by the same contract"); { assert(self.storage.minters.at(minter_and_completer).read(), "caller is not minter"); @@ -3794,18 +3797,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals___finalize_transfer_to_private_unsafe(from_and_completer: AztecAddress, amount: u128, partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<3>(); assert(self.msg_sender() == self.address, "Function _finalize_transfer_to_private_unsafe can only be called by the same contract"); { self.internal._finalize_transfer_to_private(from_and_completer, amount, partial_note); @@ -3813,18 +3805,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals___increase_public_balance(to: AztecAddress, amount: u128) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); assert(self.msg_sender() == self.address, "Function _increase_public_balance can only be called by the same contract"); { let to_balance: PublicMutable = self.storage.public_balances.at(to); @@ -3834,18 +3815,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals___reduce_total_supply(amount: u128) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); assert(self.msg_sender() == self.address, "Function _reduce_total_supply can only be called by the same contract"); { let new_supply: u128 = self.storage.total_supply.read().sub(amount); @@ -3854,18 +3824,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__balance_of_public(owner: AztecAddress) -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function balance_of_public can only be called statically"); { @@ -3874,18 +3833,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__burn_public(from: AztecAddress, amount: u128, authwit_nonce: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 3] = aztec::oracle::avm::calldata_copy(1_u32, (::N + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<3>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); if !from.eq(self.msg_sender()) { aztec::authwit::auth::assert_current_call_valid_authwit_public(self.context, from); @@ -3901,18 +3849,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__constructor(admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 64] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + as aztec::protocol::traits::Serialize>::N) + as aztec::protocol::traits::Serialize>::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<64>(); aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_public(self.context); { assert(!admin.is_zero(), "invalid admin"); @@ -3926,18 +3863,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__finalize_mint_to_private(amount: u128, partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); { let minter_and_completer: AztecAddress = self.msg_sender(); @@ -3947,18 +3873,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__finalize_transfer_to_private(amount: u128, partial_note: PartialUintNote) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); { let from_and_completer: AztecAddress = self.msg_sender(); @@ -3967,18 +3882,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__get_admin() -> pub Field { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function get_admin can only be called statically"); { @@ -3987,18 +3891,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__is_minter(minter: AztecAddress) -> pub bool { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function is_minter can only be called statically"); { @@ -4007,18 +3900,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__mint_to_public(to: AztecAddress, amount: u128) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); { assert(self.storage.minters.at(self.msg_sender()).read(), "caller is not minter"); @@ -4030,18 +3912,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__public_get_decimals() -> pub u8 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function public_get_decimals can only be called statically"); { @@ -4050,18 +3921,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__public_get_name() -> pub FieldCompressedString { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function public_get_name can only be called statically"); { @@ -4070,18 +3930,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__public_get_symbol() -> pub FieldCompressedString { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function public_get_symbol can only be called statically"); { @@ -4090,18 +3939,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__set_admin(new_admin: AztecAddress) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 1] = aztec::oracle::avm::calldata_copy(1_u32, ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<1>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); { assert(self.storage.admin.read().eq(self.msg_sender()), "caller is not admin"); @@ -4110,18 +3948,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__set_minter(minter: AztecAddress, approve: bool) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 2] = aztec::oracle::avm::calldata_copy(1_u32, ::N + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<2>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); { assert(self.storage.admin.read().eq(self.msg_sender()), "caller is not admin"); @@ -4130,18 +3957,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__total_supply() -> pub u128 { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 0] = aztec::oracle::avm::calldata_copy(1_u32, 0_u32); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<0>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); assert(self.context.is_static_call(), "Function total_supply can only be called statically"); { @@ -4150,18 +3966,7 @@ pub contract Token { } unconstrained fn __aztec_nr_internals__transfer_in_public(from: AztecAddress, to: AztecAddress, amount: u128, authwit_nonce: Field) { - let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = { - let context: aztec::context::PublicContext = aztec::context::PublicContext::new(|| -> Field { - let serialized_args: [Field; 4] = aztec::oracle::avm::calldata_copy(1_u32, ((::N + ::N) + ::N) + ::N); - aztec::hash::hash_args(serialized_args) - }); - let storage: Storage = Storage::::init(context); - let self_address: AztecAddress = context.this_address(); - let call_self: CallSelf = CallSelf:: { address: self_address, context: context}; - let call_self_static: CallSelfStatic = CallSelfStatic:: { address: self_address, context: context}; - let internal: CallInternal = CallInternal:: { context: context}; - aztec::contract_self::contract_self_public::ContractSelfPublic::, CallSelf, CallSelfStatic, CallInternal>::new(context, storage, call_self, call_self_static, internal) - }; + let mut self: aztec::contract_self::contract_self_public::ContractSelfPublic, CallSelf, CallSelfStatic, CallInternal> = __aztec_nr_internals__create_public_self::<4>(); aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); if !from.eq(self.msg_sender()) { aztec::authwit::auth::assert_current_call_valid_authwit_public(self.context, from); diff --git a/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts b/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts index 9870c7cd3895..bc3567df0c7b 100644 --- a/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts +++ b/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts @@ -15,6 +15,7 @@ import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy import { PendingNoteHashesContract } from '@aztec/noir-test-contracts.js/PendingNoteHashes'; import { type AbiDecoded, decodeFromAbi, getFunctionArtifact } from '@aztec/stdlib/abi'; import { computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness'; +import { MerkleTreeId } from '@aztec/stdlib/trees'; import { jest } from '@jest/globals'; @@ -412,7 +413,7 @@ describe('Kernelless simulation', () => { }); // Spy on the node API that generateSimulatedProvingResult uses to verify settled read requests - const noteHashMembershipWitnessSpy = jest.spyOn(aztecNode, 'getNoteHashMembershipWitness'); + const findLeavesIndexesSpy = jest.spyOn(aztecNode, 'findLeavesIndexes'); wallet.setSimulationMode('kernelless-override'); await expect( @@ -421,8 +422,12 @@ describe('Kernelless simulation', () => { }), ).resolves.toBeDefined(); - expect(noteHashMembershipWitnessSpy).toHaveBeenCalled(); - noteHashMembershipWitnessSpy.mockRestore(); + expect(findLeavesIndexesSpy).toHaveBeenCalledWith( + expect.anything(), + MerkleTreeId.NOTE_HASH_TREE, + expect.anything(), + ); + findLeavesIndexesSpy.mockRestore(); }); }); diff --git a/yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts b/yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts index 407ec00c5d30..281eb88a553f 100644 --- a/yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts +++ b/yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts @@ -76,6 +76,7 @@ import { import { PrivateLog } from '@aztec/stdlib/logs'; import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging'; import { ChonkProof } from '@aztec/stdlib/proofs'; +import { MerkleTreeId } from '@aztec/stdlib/trees'; import { BlockHeader, CallContext, @@ -758,7 +759,7 @@ function squashTransientSideEffects( * at the tx's anchor block, mimicking the behavior of the kernels */ async function verifyReadRequests( - node: Pick, + node: Pick, anchorBlockHash: BlockParameter, noteHashReadRequests: ScopedReadRequest[], nullifierReadRequests: ScopedReadRequest[], @@ -791,13 +792,25 @@ async function verifyReadRequests( } } - const [noteHashWitnesses, nullifierWitnesses] = await Promise.all([ - Promise.all(settledNoteHashReads.map(({ value }) => node.getNoteHashMembershipWitness(anchorBlockHash, value))), - Promise.all(settledNullifierReads.map(({ value }) => node.getNullifierMembershipWitness(anchorBlockHash, value))), + const [noteHashResults, nullifierResults] = await Promise.all([ + settledNoteHashReads.length > 0 + ? node.findLeavesIndexes( + anchorBlockHash, + MerkleTreeId.NOTE_HASH_TREE, + settledNoteHashReads.map(({ value }) => value), + ) + : [], + settledNullifierReads.length > 0 + ? node.findLeavesIndexes( + anchorBlockHash, + MerkleTreeId.NULLIFIER_TREE, + settledNullifierReads.map(({ value }) => value), + ) + : [], ]); for (let i = 0; i < settledNoteHashReads.length; i++) { - if (!noteHashWitnesses[i]) { + if (!noteHashResults[i]) { throw new Error( `Note hash read request at index ${settledNoteHashReads[i].index} is reading an unknown note hash: ${settledNoteHashReads[i].value}`, ); @@ -805,7 +818,7 @@ async function verifyReadRequests( } for (let i = 0; i < settledNullifierReads.length; i++) { - if (!nullifierWitnesses[i]) { + if (!nullifierResults[i]) { throw new Error( `Nullifier read request at index ${settledNullifierReads[i].index} is reading an unknown nullifier: ${settledNullifierReads[i].value}`, ); diff --git a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts index 4e27a371937c..91614bdc40bc 100644 --- a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts +++ b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.test.ts @@ -55,16 +55,20 @@ describe('Private Kernel Sequencer', () => { { publicInputs, childPublicInputs = [], + address = contractAddress, + nestedResults, }: { publicInputs?: PrivateCircuitPublicInputs; childPublicInputs?: PrivateCircuitPublicInputs[]; + address?: AztecAddress; + nestedResults?: PrivateCallExecutionResult[]; } = {}, ): PrivateCallExecutionResult => { if (!publicInputs) { publicInputs = PrivateCircuitPublicInputs.empty(); } publicInputs.callContext.functionSelector = new FunctionSelector(fnName.charCodeAt(0)); - publicInputs.callContext.contractAddress = contractAddress; + publicInputs.callContext.contractAddress = address; return new PrivateCallExecutionResult( Buffer.alloc(0), @@ -76,9 +80,10 @@ describe('Private Kernel Sequencer', () => { [], [], [], - (dependencies[fnName] || []).map((name, i) => - createCallExecutionResult(name, { publicInputs: childPublicInputs[i] }), - ), + nestedResults ?? + (dependencies[fnName] || []).map((name, i) => + createCallExecutionResult(name, { publicInputs: childPublicInputs[i] }), + ), [], ); }; @@ -361,4 +366,22 @@ describe('Private Kernel Sequencer', () => { expect(proofCreator.simulateReset).toHaveBeenCalledTimes(3); expect(proofCreator.simulateTail).toHaveBeenCalledTimes(1); }); + + it('fetches updated class id hints once per unique contract address', async () => { + const contractAddressB = AztecAddress.fromBigInt(111111n); + + // a { b {} c {} } + // a and c use contractAddress, b uses contractAddressB → 2 unique contracts, 3 executions. + dependencies = {}; + const bExec = createCallExecutionResult('b', { address: contractAddressB }); + const cExec = createCallExecutionResult('c'); + const aExec = createCallExecutionResult('a', { nestedResults: [bExec, cExec] }); + + const executionResult = new PrivateExecutionResult(aExec, Fr.zero(), []); + await prove(executionResult); + + expect(oracle.getUpdatedClassIdHints).toHaveBeenCalledTimes(2); + expect(oracle.getUpdatedClassIdHints).toHaveBeenCalledWith(contractAddress); + expect(oracle.getUpdatedClassIdHints).toHaveBeenCalledWith(contractAddressB); + }); }); diff --git a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.ts b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.ts index 295f29752a17..eeeefcb67750 100644 --- a/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.ts +++ b/yarn-project/pxe/src/private_kernel/private_kernel_execution_prover.ts @@ -1,3 +1,4 @@ +import { uniqueBy } from '@aztec/foundation/collection'; import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys'; import { Fr } from '@aztec/foundation/curves/bn254'; import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log'; @@ -22,12 +23,14 @@ import { PrivateKernelTailCircuitPrivateInputs, type PrivateKernelTailCircuitPublicInputs, PrivateVerificationKeyHints, + type UpdatedClassIdHints, } from '@aztec/stdlib/kernel'; import { ChonkProof, ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs'; import { type PrivateCallExecutionResult, type PrivateExecutionResult, TxRequest, + collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter, } from '@aztec/stdlib/tx'; @@ -108,6 +111,8 @@ export class PrivateKernelExecutionProver { const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult); const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter; + const updatedClassIdHintsMap = await this.prefetchUpdatedClassIdHints(executionResult); + while (executionStack.length) { if (!firstIteration) { let resetBuilder = new PrivateKernelResetPrivateInputsBuilder( @@ -161,7 +166,7 @@ export class PrivateKernelExecutionProver { }, }); - const privateCallData = await this.createPrivateCallData(currentExecution); + const privateCallData = await this.createPrivateCallData(currentExecution, updatedClassIdHintsMap); if (firstIteration) { const witgenTimer = new Timer(); @@ -401,7 +406,28 @@ export class PrivateKernelExecutionProver { ); } - private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult) { + /** Prefetches updated class id hints for all unique contracts in the execution tree in parallel. */ + private async prefetchUpdatedClassIdHints( + executionResult: PrivateExecutionResult, + ): Promise> { + const allAddresses = collectNested([executionResult.entrypoint], exec => [ + exec.publicInputs.callContext.contractAddress, + ]); + const uniqueAddresses = uniqueBy(allAddresses, a => a.toString()); + return new Map( + await Promise.all( + uniqueAddresses.map( + async addr => + [addr.toString(), await this.oracle.getUpdatedClassIdHints(addr)] as [string, UpdatedClassIdHints], + ), + ), + ); + } + + private async createPrivateCallData( + { publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult, + updatedClassIdHintsMap: Map, + ) { const { contractAddress, functionSelector } = publicInputs.callContext; const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer); @@ -417,7 +443,7 @@ export class PrivateKernelExecutionProver { const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } = await this.oracle.getContractClassIdPreimage(currentContractClassId); - const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress); + const updatedClassIdHints = updatedClassIdHintsMap.get(contractAddress.toString())!; return PrivateCallData.from({ publicInputs, diff --git a/yarn-project/pxe/src/private_kernel/private_kernel_oracle.test.ts b/yarn-project/pxe/src/private_kernel/private_kernel_oracle.test.ts new file mode 100644 index 000000000000..5ebbbe505cb7 --- /dev/null +++ b/yarn-project/pxe/src/private_kernel/private_kernel_oracle.test.ts @@ -0,0 +1,73 @@ +import { PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants'; +import { Fr } from '@aztec/foundation/curves/bn254'; +import { SiblingPath } from '@aztec/foundation/trees'; +import type { KeyStore } from '@aztec/key-store'; +import { ProtocolContractAddress } from '@aztec/protocol-contracts'; +import { AztecAddress } from '@aztec/stdlib/aztec-address'; +import { DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable'; +import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash'; +import type { AztecNode } from '@aztec/stdlib/interfaces/client'; +import { PublicDataTreeLeaf, PublicDataTreeLeafPreimage, PublicDataWitness } from '@aztec/stdlib/trees'; +import { BlockHeader } from '@aztec/stdlib/tx'; + +import { mock } from 'jest-mock-extended'; + +import type { ContractStore } from '../storage/contract_store/contract_store.js'; +import { PrivateKernelOracle } from './private_kernel_oracle.js'; + +describe('PrivateKernelOracle', () => { + let oracle: PrivateKernelOracle; + let node: ReturnType>; + + beforeEach(() => { + node = mock(); + oracle = new PrivateKernelOracle(mock(), mock(), node, BlockHeader.empty()); + }); + + describe('getUpdatedClassIdHints', () => { + it('skips storage reads when contract class was never updated', async () => { + const contractAddress = await AztecAddress.random(); + const hashLeafSlot = await getHashLeafSlot(contractAddress); + + // Non-matching slot simulates a low-leaf witness (slot was never written) + const unrelatedSlot = new Fr(hashLeafSlot.toBigInt() - 1n); + node.getPublicDataWitness.mockResolvedValue(makeWitness(unrelatedSlot)); + + const result = await oracle.getUpdatedClassIdHints(contractAddress); + + expect(result.updatedClassIdValues.isEmpty()).toBe(true); + expect(node.getPublicStorageAt).not.toHaveBeenCalled(); + }); + + it('reads storage when contract class was updated', async () => { + const contractAddress = await AztecAddress.random(); + const hashLeafSlot = await getHashLeafSlot(contractAddress); + + // Matching slot means the contract class was updated + node.getPublicDataWitness.mockResolvedValue(makeWitness(hashLeafSlot, Fr.random())); + node.getPublicStorageAt.mockResolvedValue(new Fr(42)); + + const result = await oracle.getUpdatedClassIdHints(contractAddress); + + expect(result.updatedClassIdValues.isEmpty()).toBe(false); + expect(node.getPublicStorageAt).toHaveBeenCalled(); + }); + }); + + async function getHashLeafSlot(contractAddress: AztecAddress) { + const { delayedPublicMutableHashSlot } = + await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress); + return computePublicDataTreeLeafSlot( + ProtocolContractAddress.ContractInstanceRegistry, + delayedPublicMutableHashSlot, + ); + } + + function makeWitness(slot: Fr, value: Fr = Fr.ZERO) { + return new PublicDataWitness( + 0n, + new PublicDataTreeLeafPreimage(new PublicDataTreeLeaf(slot, value), Fr.ZERO, 0n), + SiblingPath.random(PUBLIC_DATA_TREE_HEIGHT), + ); + } +}); diff --git a/yarn-project/pxe/src/private_kernel/private_kernel_oracle.ts b/yarn-project/pxe/src/private_kernel/private_kernel_oracle.ts index 52e3ceb10327..e04720182409 100644 --- a/yarn-project/pxe/src/private_kernel/private_kernel_oracle.ts +++ b/yarn-project/pxe/src/private_kernel/private_kernel_oracle.ts @@ -1,4 +1,10 @@ -import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants'; +import { + FUNCTION_TREE_HEIGHT, + NOTE_HASH_TREE_HEIGHT, + PUBLIC_DATA_TREE_HEIGHT, + UPDATES_VALUE_SIZE, + VK_TREE_HEIGHT, +} from '@aztec/constants'; import type { Fr } from '@aztec/foundation/curves/bn254'; import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin'; import { MembershipWitness } from '@aztec/foundation/trees'; @@ -132,12 +138,16 @@ export class PrivateKernelOracle { throw new Error(`No public data tree witness found for ${hashLeafSlot}`); } + // In an indexed merkle tree, getPublicDataWitness returns a leaf whose slot matches our query + // only if the slot has been written to. Otherwise, it returns the "low leaf" predecessor, whose + // slot will differ. Most contracts are never updated, so we can skip the readFromTree call + // (which triggers multiple RPC calls) and return empty values directly. const readStorage = (storageSlot: Fr) => this.node.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot); - const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree( - delayedPublicMutableSlot, - readStorage, - ); + const slotExists = updatedClassIdWitness.leafPreimage.leaf.slot.equals(hashLeafSlot); + const delayedPublicMutableValues = slotExists + ? await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage) + : DelayedPublicMutableValues.empty(UPDATES_VALUE_SIZE); return new UpdatedClassIdHints( new MembershipWitness( diff --git a/yarn-project/pxe/src/pxe.test.ts b/yarn-project/pxe/src/pxe.test.ts index 311716cd32e2..68c963629bc5 100644 --- a/yarn-project/pxe/src/pxe.test.ts +++ b/yarn-project/pxe/src/pxe.test.ts @@ -7,7 +7,7 @@ import { AztecLMDBStoreV2, openTmpStore } from '@aztec/kv-store/lmdb-v2'; import { TestContractArtifact } from '@aztec/noir-test-contracts.js/Test'; import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle'; import { WASMSimulator } from '@aztec/simulator/client'; -import { EventSelector } from '@aztec/stdlib/abi'; +import { EventSelector, FunctionType } from '@aztec/stdlib/abi'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { BlockHash, GENESIS_BLOCK_HEADER_HASH, GENESIS_CHECKPOINT_HEADER_HASH } from '@aztec/stdlib/block'; import { getContractClassFromArtifact } from '@aztec/stdlib/contract'; @@ -161,6 +161,40 @@ describe('PXE', () => { await expect(pxe.registerContract({ instance, artifact })).rejects.toThrow(/Artifact does not match/i); }); + it('does not call registerContractFunctionSignatures for contracts without public functions', async () => { + const { artifact, instance } = await randomDeployedContract(); + node.registerContractFunctionSignatures.mockClear(); + + await pxe.registerContract({ artifact, instance }); + + expect(node.registerContractFunctionSignatures).not.toHaveBeenCalled(); + }); + + it('calls registerContractFunctionSignatures for contracts with public functions', async () => { + const artifact = randomContractArtifact(); + artifact.functions = [ + { + name: 'my_public_fn', + functionType: FunctionType.PUBLIC, + isOnlySelf: false, + isStatic: false, + isInitializer: false, + parameters: [], + returnTypes: [], + errorTypes: {}, + bytecode: Buffer.from(''), + debugSymbols: '', + }, + ]; + const contractClass = await getContractClassFromArtifact(artifact); + const instance = await randomContractInstanceWithAddress({ contractClassId: contractClass.id }); + node.registerContractFunctionSignatures.mockClear(); + + await pxe.registerContract({ artifact, instance }); + + expect(node.registerContractFunctionSignatures).toHaveBeenCalledWith(['my_public_fn()']); + }); + // These tests are meant to quickly exercise PXE as a // frontier API so we don't need to rely on slower E2E // tests (which in turn are more meaningful for acceptance). diff --git a/yarn-project/pxe/src/pxe.ts b/yarn-project/pxe/src/pxe.ts index 71a08d0a83f3..24a01c341832 100644 --- a/yarn-project/pxe/src/pxe.ts +++ b/yarn-project/pxe/src/pxe.ts @@ -706,7 +706,9 @@ export class PXE { const publicFunctionSignatures = artifact.functions .filter(fn => fn.functionType === FunctionType.PUBLIC) .map(fn => decodeFunctionSignature(fn.name, fn.parameters)); - await this.node.registerContractFunctionSignatures(publicFunctionSignatures); + if (publicFunctionSignatures.length > 0) { + await this.node.registerContractFunctionSignatures(publicFunctionSignatures); + } } else { // Otherwise, make sure there is an artifact already registered for that class id artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId); @@ -753,7 +755,9 @@ export class PXE { const publicFunctionSignatures = artifact.functions .filter(fn => fn.functionType === FunctionType.PUBLIC) .map(fn => decodeFunctionSignature(fn.name, fn.parameters)); - await this.node.registerContractFunctionSignatures(publicFunctionSignatures); + if (publicFunctionSignatures.length > 0) { + await this.node.registerContractFunctionSignatures(publicFunctionSignatures); + } currentInstance.currentContractClassId = contractClass.id; await Promise.all([ @@ -845,8 +849,7 @@ export class PXE { // storing the tags here prevents linkage of txs sent from the same PXE. const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges; if (taggingIndexRangesUsedInTheTx.length > 0) { - // TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it. - const txHash = (await txProvingResult.toTx()).txHash; + const txHash = await txProvingResult.getTxHash(); await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId); this.log.debug(`Stored used tagging index ranges as sender for the tx`, { diff --git a/yarn-project/stdlib/src/tx/proven_tx.ts b/yarn-project/stdlib/src/tx/proven_tx.ts index b0957686dd64..df04eef960e5 100644 --- a/yarn-project/stdlib/src/tx/proven_tx.ts +++ b/yarn-project/stdlib/src/tx/proven_tx.ts @@ -13,6 +13,7 @@ import { } from './private_execution_result.js'; import { type ProvingStats, ProvingTimingsSchema } from './profiling.js'; import { Tx } from './tx.js'; +import type { TxHash } from './tx_hash.js'; export class TxProvingResult { constructor( @@ -22,6 +23,11 @@ export class TxProvingResult { public stats?: ProvingStats, ) {} + getTxHash(): Promise { + // Equivalent to `(await this.toTx()).txHash` but skips walking the execution result tree to collect logs. + return Tx.computeTxHash({ data: this.publicInputs }); + } + async toTx(): Promise { const contractClassLogs = collectSortedContractClassLogs(this.privateExecutionResult);