@aztec-labs/standard-contracts 6.0.0-rc.1 → 6.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/AuthRegistry.json +151 -147
- package/artifacts/HandshakeRegistry.json +298 -294
- package/artifacts/MultiCallEntrypoint.json +102 -102
- package/artifacts/PublicChecks.json +99 -99
- package/dest/standard_contract_data.js +9 -9
- package/package.json +3 -3
- package/src/standard_contract_data.ts +9 -9
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"start": 12880
|
|
54
54
|
}
|
|
55
55
|
],
|
|
56
|
-
"path": "/
|
|
56
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/aztec.nr",
|
|
57
57
|
"source": "mod compute_note_hash_and_nullifier;\n\nuse crate::{\n macros::{\n calls_generation::{\n external_functions::{generate_external_function_calls, generate_external_function_self_calls_structs},\n internal_functions::generate_call_internal_struct,\n },\n dispatch::generate_public_dispatch,\n emit_public_init_nullifier::generate_emit_public_init_nullifier,\n internals_functions_generation::{create_fn_abi_exports, process_functions},\n offchain_receive::{\n OFFCHAIN_RECEIVE_FN_NAME, OFFCHAIN_RECEIVE_PARAM_NAME, offchain_receive_param_type,\n OFFCHAIN_RECEIVE_RETURN_TYPE,\n },\n storage::STORAGE_LAYOUT_NAME,\n utils::{is_fn_contract_library_method, is_fn_external, is_fn_internal, is_fn_test, module_has_storage},\n },\n messages::discovery::{CustomMessageHandler, CustomSyncHandler},\n};\n\nuse compute_note_hash_and_nullifier::generate_contract_library_methods_compute_note_hash_and_nullifier;\n\n/// Configuration for the [`aztec`] macro.\n///\n/// This type lets users override different parts of the default aztec-nr contract behavior, such\n/// as message handling and state synchronization. These are advanced features that require careful\n/// understanding of the behavior of these systems.\n///\n/// ## Examples\n///\n/// ```noir\n/// #[aztec(aztec::macros::AztecConfig::new().custom_message_handler(my_handler))]\n/// contract MyContract { ... }\n/// ```\npub struct AztecConfig {\n custom_message_handler: Option<CustomMessageHandler>,\n custom_sync_state: Option<CustomSyncHandler>,\n}\n\nimpl AztecConfig {\n /// Creates a new `AztecConfig` with default values.\n ///\n /// Calling `new` is equivalent to invoking the [`aztec`] macro with no parameters. The different methods\n /// (e.g. [`AztecConfig::custom_message_handler`]) can then be used to change the default behavior.\n pub comptime fn new() -> Self {\n Self { custom_message_handler: Option::none(), custom_sync_state: Option::none() }\n }\n\n /// Sets a handler for custom messages.\n ///\n /// This enables contracts to process non-standard messages (i.e. any with a message type that is not in\n /// [`crate::messages::msg_type`]).\n ///\n /// `handler` must be a function that conforms to the\n /// [`crate::messages::discovery::CustomMessageHandler`] type signature.\n pub comptime fn custom_message_handler(&mut self, handler: CustomMessageHandler) -> Self {\n self.custom_message_handler = Option::some(handler);\n *self\n }\n\n /// Overrides the default state synchronization logic.\n ///\n /// The generated `sync_state` function will call `handler` instead of\n /// [`crate::messages::discovery::do_sync_state`]. The handler receives all of the same parameters, so it can\n /// run custom logic (e.g. fetching and decrypting custom logs) before, after, or instead of calling\n /// `do_sync_state`.\n ///\n /// `handler` must be a function that conforms to the\n /// [`crate::messages::discovery::CustomSyncHandler`] type signature.\n pub comptime fn custom_sync_state(&mut self, handler: CustomSyncHandler) -> Self {\n self.custom_sync_state = Option::some(handler);\n *self\n }\n}\n\n/// Enables aztec-nr features on a `contract`.\n///\n/// All aztec-nr contracts should have this macro invoked on them, as it is the one that processes all contract\n/// functions, notes, storage, generates interfaces for external calls, and creates the message processing\n/// boilerplate.\n///\n/// ## Examples\n///\n/// Most contracts can simply invoke the macro with no parameters, resulting in default aztec-nr behavior:\n/// ```noir\n/// #[aztec]\n/// contract MyContract { ... }\n/// ```\n///\n/// Advanced contracts can use [`AztecConfig`] to customize parts of its behavior, such as message\n/// processing.\n/// ```noir\n/// #[aztec(aztec::macros::AztecConfig::new().custom_message_handler(my_handler))]\n/// contract MyAdvancedContract { ... }\n/// ```\n#[varargs]\npub comptime fn aztec(m: Module, args: [AztecConfig]) -> Quoted {\n let num_args = args.len();\n let config = if num_args == 0 {\n AztecConfig::new()\n } else if num_args == 1 {\n args[0]\n } else {\n panic(f\"#[aztec] expects 0 or 1 arguments, got {num_args}\")\n };\n\n // Functions that don't have #[external(...)], #[contract_library_method], or #[test] are not allowed in contracts.\n check_each_fn_macroified(m);\n\n // We generate new functions prefixed with `__aztec_nr_internals__` and we replace the original functions' bodies\n // with `static_assert(false, ...)` to prevent them from being called directly from within the contract.\n let functions = process_functions(m);\n\n // We generate structs and their implementations necessary for convenient functions calls.\n let interface = generate_contract_interface(m);\n let self_call_structs = generate_external_function_self_calls_structs(m);\n let call_internal_struct = generate_call_internal_struct(m);\n\n // We generate ABI exports for all the external functions in the contract.\n let fn_abi_exports = create_fn_abi_exports(m);\n\n // We generate `_compute_note_hash`, `_compute_note_nullifier` (and the deprecated\n // `_compute_note_hash_and_nullifier` wrapper) only if they are not already implemented.\n // If they are implemented we just insert empty quotes.\n let contract_library_method_compute_note_hash_and_nullifier = if !m.functions().any(|f| {\n // Note that we don't test for `_compute_note_hash` or `_compute_note_nullifier` in order to make this simpler\n // - users must either implement all three or none.\n // Down the line we'll remove this check and use `AztecConfig`.\n f.name() == quote { _compute_note_hash_and_nullifier }\n }) {\n generate_contract_library_methods_compute_note_hash_and_nullifier()\n } else {\n quote {}\n };\n let process_custom_message_option = if config.custom_message_handler.is_some() {\n let handler = config.custom_message_handler.unwrap();\n quote { Option::some($handler) }\n } else {\n quote { Option::<aztec::messages::discovery::CustomMessageHandler>::none() }\n };\n\n let offchain_inbox_sync_option = quote {\n Option::some(aztec::messages::processing::offchain::sync_inbox)\n };\n\n if m.functions().any(|f| f.name() == quote { sync_state }) {\n panic(\n \"User-defined 'sync_state' is not allowed. Use AztecConfig::custom_sync_state() to customize sync behavior.\",\n );\n }\n\n let custom_sync_handler = if config.custom_sync_state.is_some() {\n let handler = config.custom_sync_state.unwrap();\n Option::some(quote { $handler })\n } else {\n Option::none()\n };\n\n let sync_state_fn_and_abi_export = generate_sync_state(\n process_custom_message_option,\n offchain_inbox_sync_option,\n custom_sync_handler,\n );\n\n if m.functions().any(|f| f.name() == quote { offchain_receive }) {\n panic(\n \"User-defined 'offchain_receive' is not allowed. The function is auto-injected by the #[aztec] macro. See https://docs.aztec.network/errors/7\",\n );\n }\n let offchain_receive_fn_and_abi_export = generate_offchain_receive();\n\n let (has_public_init_nullifier_fn, emit_public_init_nullifier_fn_body) = generate_emit_public_init_nullifier(m);\n let public_dispatch = generate_public_dispatch(m, has_public_init_nullifier_fn);\n\n quote {\n $interface\n $self_call_structs\n $call_internal_struct\n $functions\n $fn_abi_exports\n $contract_library_method_compute_note_hash_and_nullifier\n $public_dispatch\n $sync_state_fn_and_abi_export\n $emit_public_init_nullifier_fn_body\n $offchain_receive_fn_and_abi_export\n }\n}\n\ncomptime fn generate_contract_interface(m: Module) -> Quoted {\n let calls = generate_external_function_calls(m);\n\n let module_name = m.name();\n\n let has_storage_layout = module_has_storage(m) & STORAGE_LAYOUT_NAME.get(m).is_some();\n let storage_layout_getter = if has_storage_layout {\n let storage_layout_name = STORAGE_LAYOUT_NAME.get(m).unwrap();\n quote {\n pub fn storage_layout() -> StorageLayoutFields {\n $storage_layout_name.fields\n }\n }\n } else {\n quote {}\n };\n\n let library_storage_layout_getter = if has_storage_layout {\n quote {\n #[contract_library_method]\n $storage_layout_getter\n }\n } else {\n quote {}\n };\n\n quote {\n pub struct $module_name {\n pub target_contract: aztec::protocol::address::AztecAddress\n }\n\n impl $module_name {\n $calls\n\n pub fn at(\n addr: aztec::protocol::address::AztecAddress\n ) -> Self {\n Self { target_contract: addr }\n }\n\n pub fn interface() -> Self {\n Self { target_contract: aztec::protocol::address::AztecAddress::zero() }\n }\n\n $storage_layout_getter\n }\n\n #[contract_library_method]\n pub fn at(\n addr: aztec::protocol::address::AztecAddress\n ) -> $module_name {\n $module_name { target_contract: addr }\n }\n\n #[contract_library_method]\n pub fn interface() -> $module_name {\n $module_name { target_contract: aztec::protocol::address::AztecAddress::zero() }\n }\n\n $library_storage_layout_getter\n\n }\n}\n\n/// Generates the `sync_state` utility function that performs message discovery.\ncomptime fn generate_sync_state(\n process_custom_message_option: Quoted,\n offchain_inbox_sync_option: Quoted,\n custom_sync_handler: Option<Quoted>,\n) -> Quoted {\n let body = if custom_sync_handler.is_some() {\n let handler = custom_sync_handler.unwrap();\n quote {\n $handler(\n address,\n _compute_note_hash,\n _compute_note_nullifier,\n $process_custom_message_option,\n $offchain_inbox_sync_option,\n scope,\n );\n }\n } else {\n quote {\n aztec::messages::discovery::do_sync_state(\n address,\n _compute_note_hash,\n _compute_note_nullifier,\n $process_custom_message_option,\n $offchain_inbox_sync_option,\n scope,\n );\n }\n };\n\n quote {\n pub struct sync_state_parameters {\n pub scope: aztec::protocol::address::AztecAddress,\n }\n\n #[abi(functions)]\n pub struct sync_state_abi {\n parameters: sync_state_parameters,\n }\n\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_utility]\n unconstrained fn sync_state(scope: aztec::protocol::address::AztecAddress) {\n let address = aztec::context::UtilityContext::new().this_address();\n $body\n }\n }\n}\n\n/// Generates an `offchain_receive` utility function that lets callers add messages to the offchain message inbox.\n///\n/// For more details, see `aztec::messages::processing::offchain::receive`.\ncomptime fn generate_offchain_receive() -> Quoted {\n let param_type = offchain_receive_param_type(quote { aztec });\n let parameters_struct_name = f\"{OFFCHAIN_RECEIVE_FN_NAME}_parameters\".quoted_contents();\n let abi_struct_name = f\"{OFFCHAIN_RECEIVE_FN_NAME}_abi\".quoted_contents();\n\n quote {\n pub struct $parameters_struct_name {\n pub $OFFCHAIN_RECEIVE_PARAM_NAME: $param_type,\n }\n\n #[abi(functions)]\n pub struct $abi_struct_name {\n parameters: $parameters_struct_name,\n }\n\n /// Receives offchain messages into this contract's offchain inbox for subsequent processing.\n ///\n /// Each message is routed to the inbox scoped to its `recipient` field.\n ///\n /// For more details, see `aztec::messages::processing::offchain::receive`.\n ///\n /// This function is automatically injected by the `#[aztec]` macro.\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_utility]\n unconstrained fn $OFFCHAIN_RECEIVE_FN_NAME($OFFCHAIN_RECEIVE_PARAM_NAME: $param_type) -> $OFFCHAIN_RECEIVE_RETURN_TYPE {\n let address = aztec::context::UtilityContext::new().this_address();\n aztec::messages::processing::offchain::receive(address, $OFFCHAIN_RECEIVE_PARAM_NAME);\n }\n }\n}\n\n/// Checks that all functions in the module have a context macro applied.\n///\n/// Non-macroified functions are not allowed in contracts. They must all be one of\n/// [`crate::macros::functions::external`], [`crate::macros::functions::internal`] or `test`.\ncomptime fn check_each_fn_macroified(m: Module) {\n for f in m.functions() {\n let name = f.name();\n if !is_fn_external(f) & !is_fn_contract_library_method(f) & !is_fn_internal(f) & !is_fn_test(f) {\n // We don't suggest that #[contract_library_method] is allowed because we don't want to introduce another\n // concept\n panic(\n f\"Function {name} must be marked as either #[external(...)], #[internal(...)], or #[test]\",\n );\n }\n }\n}\n"
|
|
58
58
|
},
|
|
59
59
|
"107": {
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"start": 13746
|
|
116
116
|
}
|
|
117
117
|
],
|
|
118
|
-
"path": "/
|
|
118
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/calls_generation/external_functions_stubs.nr",
|
|
119
119
|
"source": "//! Stubs are auto-generated wrapper functions that provide an ergonomic interface for cross-contract calls. ! Instead\n// of manually serializing arguments and creating call interfaces, stubs allow natural syntax, e.g. for ! enqueuing\n// calls to public functions: ! ! ExternalContract.at(address).some_method(arg1, arg2).enqueue()\n\nuse crate::macros::utils::compute_fn_selector;\nuse crate::protocol::meta::utils::derive_serialization_quotes;\nuse std::meta::unquote;\n\ncomptime global FROM_FIELD: TypedExpr = {\n let from_field_trait = quote { crate::protocol::traits::FromField }.as_trait_constraint();\n let function_selector_typ = quote { crate::protocol::abis::function_selector::FunctionSelector }.as_type();\n function_selector_typ.get_trait_impl(from_field_trait).unwrap().methods().filter(|m| {\n m.name() == quote { from_field }\n })[0]\n .as_typed_expr()\n};\n\n/// Utility function creating stubs used by all the stub functions in this file.\ncomptime fn create_stub_base(f: FunctionDefinition) -> (Quoted, Quoted, Quoted, Quoted, u32, Quoted, u32, Field) {\n // Dear privacy adventurer, chances are, you've command+clicked on the name of an external function call -- seeking\n // to view that function -- only to end up here. Here's an explanation: The external contract that you're calling\n // was likely annotated with the `#[aztec]` annotation -- as all good aztec contracts are. This triggers a macro\n // which generates a \"contract interface\" for that contract, which is effectively a pretty interface that gives\n // natural contract calling semantics:\n //\n // `MyImportedContract.at(some_address).my_method(arg1, arg2).enqueue();\n //\n // Unfortunately, the usage of macros makes it a bit of a black box. To actually view the target function, you\n // could instead command+click on `MyImportedContract`, or you can just manually search it. If you want to view the\n // noir code that gets generated by this macro, you can use `nargo expand` on your contract.\n create_stub_base_from_parts(\n f.name(),\n f.parameters().map(|param| (param.name(), param.typ())),\n )\n}\n\n/// Variant of `create_stub_base` that takes raw `(name, parameters)` instead of a `FunctionDefinition`.\n///\n/// This lets macro-injected functions (e.g. `offchain_receive`) reuse the stub-generation machinery without needing a\n/// `FunctionDefinition`.\npub(crate) comptime fn create_stub_base_from_parts(\n fn_name: Quoted,\n fn_parameters: [(Quoted, Type)],\n) -> (Quoted, Quoted, Quoted, Quoted, u32, Quoted, u32, Field) {\n let fn_parameters_list = fn_parameters.map(|(name, typ): (Quoted, Type)| quote { $name: $typ }).join(quote {,});\n\n let (serialized_args_array_construction, serialized_args_array_len_quote, serialized_args_array_name) =\n derive_serialization_quotes(fn_parameters, false);\n let serialized_args_array_len: u32 = unquote!(quote { ($serialized_args_array_len_quote) as u32 });\n\n let fn_name_str = f\"\\\"{fn_name}\\\"\".quoted_contents();\n let fn_name_len: u32 = unquote!(quote { $fn_name_str.as_bytes().len() });\n let fn_selector: Field = compute_fn_selector(fn_name, fn_parameters);\n\n (\n fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name,\n serialized_args_array_len, fn_name_str, fn_name_len, fn_selector,\n )\n}\n\npub(crate) comptime fn create_private_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, serialized_args_array_len, fn_name_str, fn_name_len, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> aztec::context::calls::PrivateCall<$fn_name_len, $serialized_args_array_len, $fn_return_type> {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n aztec::context::calls::PrivateCall::new(\n self.target_contract,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n )\n }\n }\n}\n\npub(crate) comptime fn create_private_static_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, serialized_args_array_len, fn_name_str, fn_name_len, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> aztec::context::calls::PrivateStaticCall<$fn_name_len, $serialized_args_array_len, $fn_return_type> {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n aztec::context::calls::PrivateStaticCall::new(\n self.target_contract,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n )\n }\n }\n}\n\npub(crate) comptime fn create_public_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, serialized_args_array_len, fn_name_str, fn_name_len, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> aztec::context::calls::PublicCall<$fn_name_len, $serialized_args_array_len, $fn_return_type> {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n aztec::context::calls::PublicCall::new(\n self.target_contract,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n )\n }\n }\n}\n\npub(crate) comptime fn create_public_static_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, serialized_args_array_len, fn_name_str, fn_name_len, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> aztec::context::calls::PublicStaticCall<$fn_name_len, $serialized_args_array_len, $fn_return_type> {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n aztec::context::calls::PublicStaticCall::new(\n self.target_contract,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n )\n }\n }\n}\n\npub(crate) comptime fn create_utility_stub(f: FunctionDefinition) -> Quoted {\n create_utility_stub_from_parts(\n f.name(),\n f.parameters().map(|param| (param.name(), param.typ())),\n f.return_type(),\n )\n}\n\n/// Variant of `create_utility_stub` that takes raw `(name, parameters, return_type)` instead of `FunctionDefinition`.\npub(crate) comptime fn create_utility_stub_from_parts(\n fn_name: Quoted,\n fn_parameters: [(Quoted, Type)],\n fn_return_type: Type,\n) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, serialized_args_array_len, fn_name_str, fn_name_len, fn_selector) =\n create_stub_base_from_parts(fn_name, fn_parameters);\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> aztec::context::calls::UtilityCall<$fn_name_len, $serialized_args_array_len, $fn_return_type> {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n aztec::context::calls::UtilityCall::new(\n self.target_contract,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n )\n }\n }\n}\n\n// Self-call stub generation functions for CallSelf, CallSelfStatic, EnqueueSelf, and EnqueueSelfStatic structs. Unlike\n// the stubs above, the self-call stubs directly perform the call instead of returning a struct that can be later used\n// to perform the call.\n\n/// Creates a stub for calling a private function (or static private function if `is_static` is true) from private\n/// context (for CallSelf<&mut PrivateContext> and CallSelfStatic<&mut PrivateContext>).\npub comptime fn create_private_self_call_stub(f: FunctionDefinition, is_static: bool) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _, _, _, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> $fn_return_type {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n let args_hash = aztec::hash::hash_args($serialized_args_array_name);\n aztec::oracle::execution_cache::store($serialized_args_array_name, args_hash);\n let returns_hash = self.context.call_private_function_with_args_hash(\n self.address,\n selector,\n args_hash,\n $is_static\n );\n returns_hash.get_preimage()\n }\n }\n}\n\n/// Creates a stub for calling a public function from public context (for CallSelf<PublicContext>)\npub comptime fn create_public_self_call_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _, fn_name_str, _, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n // TODO: It makes sense to drop the use of PublicStaticCall struct here and just perform the call directly but\n // before doing that we need to drop the use of slices from return values because we cannot return slices from an\n // unconstrained function. This is not a priority right now.\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> $fn_return_type {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n unsafe {\n aztec::context::calls::PublicCall::new(\n self.address,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n ).call(self.context)\n }\n }\n }\n}\n\n/// Creates a static stub for calling a public view function from public context (for CallSelfStatic<PublicContext>)\npub comptime fn create_public_self_call_static_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _, fn_name_str, _, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n // TODO: It makes sense to drop the use of PublicStaticCall struct here and just perform the call directly but\n // before doing that we need to drop the use of slices from return values because we cannot return slices from an\n // unconstrained function. This is not a priority right now.\n quote {\n pub fn $fn_name(self, $fn_parameters_list) -> $fn_return_type {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n unsafe {\n aztec::context::calls::PublicStaticCall::new(\n self.address,\n selector,\n $fn_name_str,\n $serialized_args_array_name,\n ).view(self.context)\n }\n }\n }\n}\n\n/// Creates a static stub for enqueuing a public view function from private context (for EnqueueSelfStatic<&mut\n/// PrivateContext>)\npub comptime fn create_public_self_enqueue_static_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _serialized_args_array_len, _fn_name_str, _fn_name_len, fn_selector) =\n create_stub_base(f);\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n let calldata = [aztec::protocol::traits::ToField::to_field(selector)].concat($serialized_args_array_name);\n let calldata_hash = aztec::hash::hash_calldata_array(calldata);\n aztec::oracle::execution_cache::store(calldata, calldata_hash);\n self.context.call_public_function_with_calldata_hash(\n self.address,\n calldata_hash,\n /*is_static_call=*/ true,\n /*hide_msg_sender=*/ false,\n );\n }\n }\n}\n\n/// Creates a stub for calling a utility function on the same contract (for CallSelfUtility).\npub comptime fn create_utility_self_call_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _, _, _, fn_selector) =\n create_stub_base(f);\n let fn_return_type = f.return_type();\n\n quote {\n pub unconstrained fn $fn_name(self, $fn_parameters_list) -> $fn_return_type {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n let returns = aztec::oracle::call_utility_function::call_utility_function(\n self.address, selector, $serialized_args_array_name,\n );\n aztec::protocol::traits::Deserialize::deserialize(returns)\n }\n }\n}\n\n/// Creates a stub for enqueuing a public function from private context (for EnqueueSelf<&mut PrivateContext>)\npub comptime fn create_public_self_enqueue_stub(f: FunctionDefinition) -> Quoted {\n let (fn_name, fn_parameters_list, serialized_args_array_construction, serialized_args_array_name, _serialized_args_array_len, _fn_name_str, _fn_name_len, fn_selector) =\n create_stub_base(f);\n\n quote {\n pub fn $fn_name(self, $fn_parameters_list) {\n $serialized_args_array_construction\n let selector = $FROM_FIELD($fn_selector);\n let calldata = [aztec::protocol::traits::ToField::to_field(selector)].concat($serialized_args_array_name);\n let calldata_hash = aztec::hash::hash_calldata_array(calldata);\n aztec::oracle::execution_cache::store(calldata, calldata_hash);\n self.context.call_public_function_with_calldata_hash(\n self.address,\n calldata_hash,\n /*is_static_call=*/ false,\n /*hide_msg_sender=*/ false,\n );\n }\n }\n}\n"
|
|
120
120
|
},
|
|
121
121
|
"110": {
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"start": 12320
|
|
146
146
|
}
|
|
147
147
|
],
|
|
148
|
-
"path": "/
|
|
148
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/dispatch.nr",
|
|
149
149
|
"source": "use crate::macros::internals_functions_generation::external_functions_registry::get_public_functions;\nuse crate::protocol::meta::utils::get_params_len_quote;\nuse crate::utils::cmap::CHashMap;\nuse super::functions::initialization_utils::EMIT_PUBLIC_INIT_NULLIFIER_FN_NAME;\nuse super::utils::compute_fn_selector;\n\n/// Minimum number of public functions that must share a parameter-type signature before we extract a shared\n/// unpack helper. See [compute_unpack_prelude] for the rationale behind the chosen value.\nglobal EXTRACTION_THRESHOLD: u32 = 4;\n\n/// Generates a `public_dispatch` function for an Aztec contract module `m`.\n///\n/// The generated function dispatches public calls based on selector to the appropriate contract function. If\n/// `generate_emit_public_init_nullifier` is true, it also handles dispatch to the macro-generated\n/// `__emit_public_init_nullifier` function.\n///\n/// Alongside `public_dispatch`, this also emits one `__aztec_nr_internals__unpack_arguments_<N>` helper per\n/// parameter-type signature shared by enough public functions; see [compute_unpack_prelude] for the extraction\n/// criterion.\npub comptime fn generate_public_dispatch(m: Module, generate_emit_public_init_nullifier: bool) -> Quoted {\n let functions = get_public_functions(m);\n\n let unit = get_type::<()>();\n\n // Count how many public functions share each parameter-type signature, so we can decide which signatures are\n // worth extracting into helpers.\n let signature_counts = &mut CHashMap::<Quoted, u32>::new();\n for function in functions {\n let parameters = function.parameters().map(|param| (param.name(), param.typ()));\n if parameters.len() != 0 {\n let key = signature_key(parameters);\n let prior = signature_counts.get(key).unwrap_or(0);\n signature_counts.insert(key, prior + 1);\n }\n }\n\n let seen_selectors = &mut CHashMap::<Field, Quoted>::new();\n let signature_to_helper_idx = &mut CHashMap::<Quoted, u32>::new();\n // The helper function definitions, in the order they were created.\n let unpack_helpers: &mut [Quoted] = &mut @[];\n\n let mut ifs = functions.map(|function: FunctionDefinition| {\n let parameters = function.parameters().map(|param| (param.name(), param.typ()));\n let return_type = function.return_type();\n\n let fn_name = function.name();\n let selector: Field = compute_fn_selector(fn_name, parameters);\n\n // Since function selectors are computed as the first 4 bytes of the hash of the function signature, it's\n // possible to have collisions. With the following check, we ensure it doesn't happen within the same contract.\n let existing_fn = seen_selectors.get(selector);\n if existing_fn.is_some() {\n let existing_fn = existing_fn.unwrap();\n panic(\n f\"Public function selector collision detected between functions '{fn_name}' and '{existing_fn}'\",\n );\n }\n seen_selectors.insert(selector, fn_name);\n\n let (unpack_prelude, call_args) = compute_unpack_prelude(\n parameters,\n signature_counts,\n signature_to_helper_idx,\n unpack_helpers,\n );\n\n // We call a function whose name is prefixed with `__aztec_nr_internals__`. This is necessary because the\n // original function is intentionally made uncallable, preventing direct invocation within the contract.\n // Instead, a new function with the same name, but prefixed by `__aztec_nr_internals__`, has been generated to\n // be called here. For more details see the `process_functions` function.\n let name = f\"__aztec_nr_internals__{fn_name}\".quoted_contents();\n let call = quote { $name($call_args) };\n\n let return_code = if return_type == unit {\n quote {\n $call;\n // Force early return.\n aztec::oracle::avm::avm_return([]);\n }\n } else {\n quote {\n let return_value = aztec::protocol::traits::Serialize::serialize($call);\n aztec::oracle::avm::avm_return(return_value.as_vector());\n }\n };\n\n let if_ = quote {\n if selector == $selector {\n $unpack_prelude\n $return_code\n }\n };\n if_\n });\n\n // If we injected the auto-generated public function to emit the public initialization nullifier, then\n // we'll also need to handle its dispatch.\n if generate_emit_public_init_nullifier {\n let name = EMIT_PUBLIC_INIT_NULLIFIER_FN_NAME;\n let init_nullifier_selector: Field = compute_fn_selector(name, @[]);\n\n ifs = ifs.push_back(\n quote {\n if selector == $init_nullifier_selector {\n $name();\n aztec::oracle::avm::avm_return([]);\n }\n },\n );\n }\n\n if ifs.len() == 0 {\n // No dispatch function if there are no public functions\n quote {}\n } else {\n let ifs = ifs.push_back(quote { panic(f\"Unknown selector {selector}\") });\n let dispatch = ifs.join(quote { });\n\n let helpers = (*unpack_helpers).join(quote { });\n\n let body = quote {\n $helpers\n\n // We mark this as public because our whole system depends on public functions having this attribute.\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_public]\n pub unconstrained fn public_dispatch(selector: Field) {\n $dispatch\n }\n };\n\n body\n }\n}\n\n/// Canonical Quoted representation of a parameter list's types, used as the deduplication key for unpack helpers.\ncomptime fn signature_key(parameters: [(Quoted, Type)]) -> Quoted {\n parameters\n .map(|param: (Quoted, Type)| {\n let param_type = param.1;\n quote { $param_type }\n })\n .join(quote { , })\n}\n\n/// Builds the dispatch-arm prelude for a public function and the comma-separated arg list to pass through to the call.\n///\n/// If the function's signature reaches `EXTRACTION_THRESHOLD`, the prelude reuses (or creates) a shared\n/// `__aztec_nr_internals__unpack_arguments_<N>` helper. Otherwise the calldata read is inlined, matching the\n/// pre-extraction shape; this avoids paying the helper-call overhead on signatures that would not benefit from the\n/// shared body.\n///\n/// The real break-even depends on the size of the inlined boilerplate at each call site (which scales with the\n/// parameter types' `stream_deserialize` cost), not just the share count: a signature with one `Field` arg inlines\n/// to a few opcodes per site, while a signature like `(AztecAddress, U128, PartialUintNote)` inlines into many. For\n/// now we approximate that with a single share-count threshold, which is the simplest knob that keeps the macro\n/// readable. If we ever want to be more precise we can size each helper against its per-site savings.\ncomptime fn compute_unpack_prelude(\n parameters: [(Quoted, Type)],\n signature_counts: &mut CHashMap<Quoted, u32>,\n signature_to_helper_idx: &mut CHashMap<Quoted, u32>,\n unpack_helpers: &mut [Quoted],\n) -> (Quoted, Quoted) {\n if parameters.len() == 0 {\n (quote {}, quote {})\n } else {\n let sig_key = signature_key(parameters);\n let count = signature_counts.get(sig_key).unwrap_or(0);\n let shared = count >= EXTRACTION_THRESHOLD;\n\n let mut arg_names: [Quoted] = @[];\n for parameter_index in 0..parameters.len() {\n let arg_name = f\"arg{parameter_index}\".quoted_contents();\n arg_names = arg_names.push_back(arg_name);\n }\n let args = arg_names.join(quote { , });\n\n let prelude = if shared {\n let existing_idx = signature_to_helper_idx.get(sig_key);\n let helper_idx = if existing_idx.is_some() {\n existing_idx.unwrap()\n } else {\n let new_idx = (*unpack_helpers).len();\n signature_to_helper_idx.insert(sig_key, new_idx);\n let helper_def = build_unpack_helper(new_idx, parameters);\n *unpack_helpers = (*unpack_helpers).push_back(helper_def);\n new_idx\n };\n let helper_name = f\"__aztec_nr_internals__unpack_arguments_{helper_idx}\".quoted_contents();\n if parameters.len() == 1 {\n quote { let arg0 = $helper_name(); }\n } else {\n quote { let ($args) = $helper_name(); }\n }\n } else {\n inline_unpack(parameters)\n };\n\n (prelude, args)\n }\n}\n\n/// Inlined calldata read + per-parameter `stream_deserialize` for signatures that are not worth extracting.\ncomptime fn inline_unpack(parameters: [(Quoted, Type)]) -> Quoted {\n let params_len_quote = get_params_len_quote(parameters);\n let initial_read = quote {\n let input_calldata: [Field; $params_len_quote] = aztec::oracle::avm::calldata_copy(1, $params_len_quote);\n let mut reader = aztec::protocol::utils::reader::Reader::new(input_calldata);\n };\n\n let mut read_quotes: [Quoted] = @[];\n for parameter_index in 0..parameters.len() {\n let arg_name = f\"arg{parameter_index}\".quoted_contents();\n let param_type = parameters[parameter_index].1;\n read_quotes = read_quotes.push_back(\n quote {\n let $arg_name: $param_type = aztec::protocol::traits::Deserialize::stream_deserialize(&mut reader);\n },\n );\n }\n let reads = read_quotes.join(quote { });\n\n quote {\n $initial_read\n $reads\n }\n}\n\n/// Emits the `#[inline_never]` helper that reads calldata for one specific parameter-type signature.\n///\n/// Returns a single value when there is only one parameter, and a tuple when there are several. Marked\n/// `#[inline_never]` (and therefore `unconstrained`) so each entry point can call into the same compiled body.\ncomptime fn build_unpack_helper(idx: u32, parameters: [(Quoted, Type)]) -> Quoted {\n let helper_name = f\"__aztec_nr_internals__unpack_arguments_{idx}\".quoted_contents();\n let params_len_quote = get_params_len_quote(parameters);\n\n // The initial calldata_copy offset is 1 to skip the Field selector. The expected calldata is the serialization\n // of:\n // - FunctionSelector: the selector of the function intended to dispatch\n // - Parameters: the parameters of the function intended to dispatch\n // That is, exactly what is expected for a call to the target function, but with a selector added at the\n // beginning.\n let initial_read = quote {\n let input_calldata: [Field; $params_len_quote] = aztec::oracle::avm::calldata_copy(1, $params_len_quote);\n let mut reader = aztec::protocol::utils::reader::Reader::new(input_calldata);\n };\n\n let mut read_quotes: [Quoted] = @[];\n let mut arg_quotes: [Quoted] = @[];\n let mut type_quotes: [Quoted] = @[];\n for parameter_index in 0..parameters.len() {\n let arg_name = f\"arg{parameter_index}\".quoted_contents();\n let param_type = parameters[parameter_index].1;\n read_quotes = read_quotes.push_back(\n quote {\n let $arg_name: $param_type = aztec::protocol::traits::Deserialize::stream_deserialize(&mut reader);\n },\n );\n arg_quotes = arg_quotes.push_back(arg_name);\n type_quotes = type_quotes.push_back(quote { $param_type });\n }\n let reads = read_quotes.join(quote { });\n let return_args = arg_quotes.join(quote { , });\n\n if parameters.len() == 1 {\n let only_type = parameters[0].1;\n quote {\n #[inline_never]\n #[contract_library_method]\n unconstrained fn $helper_name() -> $only_type {\n $initial_read\n $reads\n arg0\n }\n }\n } else {\n let return_types = type_quotes.join(quote { , });\n quote {\n #[inline_never]\n #[contract_library_method]\n unconstrained fn $helper_name() -> ($return_types) {\n $initial_read\n $reads\n ($return_args)\n }\n }\n }\n}\n\ncomptime fn get_type<T>() -> Type {\n let t: T = std::mem::zeroed();\n std::meta::type_of(t)\n}\n"
|
|
150
150
|
},
|
|
151
151
|
"120": {
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
"start": 579
|
|
156
156
|
}
|
|
157
157
|
],
|
|
158
|
-
"path": "/
|
|
158
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/private.nr",
|
|
159
159
|
"source": "use crate::macros::{\n functions::initialization_utils::has_public_init_checked_functions,\n internals_functions_generation::external::helpers::{create_authorize_once_check, get_abi_relevant_attributes},\n utils::{\n fn_has_allow_phase_change, fn_has_authorize_once, fn_has_noinitcheck, is_fn_initializer, is_fn_only_self,\n is_fn_view, module_has_initializer, module_has_storage,\n },\n};\nuse crate::protocol::meta::utils::derive_serialization_quotes;\nuse std::meta::type_of;\n\npub(crate) comptime fn generate_private_external(f: FunctionDefinition) -> Quoted {\n let module_has_initializer = module_has_initializer(f.module());\n let module_has_storage = module_has_storage(f.module());\n\n // Private functions undergo a lot of transformations from their Aztec.nr form into a circuit that can be fed to\n // the Private Kernel Circuit. First we change the function signature so that it also receives\n // `PrivateContextInputs`, which contain information about the execution context (e.g. the caller).\n let original_params = f.parameters().map(|param| (param.name(), param.typ()));\n\n let original_params_quotes =\n original_params.map(|(param_name, param_type)| quote { $param_name: $param_type }).join(quote {, });\n\n let params = quote { inputs: aztec::context::inputs::PrivateContextInputs, $original_params_quotes };\n\n let mut body = f.body().as_block().unwrap();\n\n // The original params are hashed and passed to the `context` object, so that the kernel can verify we've received\n // the correct values.\n let (args_serialization, _, serialized_args_name) = derive_serialization_quotes(original_params, false);\n\n let storage_init = if module_has_storage {\n // Contract has Storage defined so we initialize it.\n quote {\n let storage = Storage::init(&mut context);\n }\n } else {\n // Contract does not have Storage defined, so we set storage to the unit type `()`. ContractSelfPrivate\n // requires a storage struct in its constructor. Using an Option type would lead to worse developer experience\n // and higher constraint counts so we use the unit type `()` instead.\n quote {\n let storage = ();\n }\n };\n\n let contract_self_creation = quote {\n #[allow(unused_variables)]\n let mut self = {\n $args_serialization\n let args_hash = aztec::hash::hash_args($serialized_args_name);\n let mut context = aztec::context::PrivateContext::new(inputs, args_hash);\n $storage_init\n let self_address = context.this_address();\n let call_self: CallSelf<&mut aztec::context::PrivateContext> = CallSelf { address: self_address, context: &mut context };\n let enqueue_self: EnqueueSelf<&mut aztec::context::PrivateContext> = EnqueueSelf { address: self_address, context: &mut context };\n let call_self_static: CallSelfStatic<&mut aztec::context::PrivateContext> = CallSelfStatic { address: self_address, context: &mut context };\n let enqueue_self_static: EnqueueSelfStatic<&mut aztec::context::PrivateContext> = EnqueueSelfStatic { address: self_address, context: &mut context };\n let internal: CallInternal<&mut aztec::context::PrivateContext> = CallInternal { context: &mut context };\n let call_self_utility = CallSelfUtility { address: self_address };\n let utility: aztec::contract_self::PrivateUtilityCalls<CallSelfUtility> = aztec::contract_self::PrivateUtilityCalls { call_self: call_self_utility };\n aztec::contract_self::ContractSelfPrivate::new(&mut context, storage, call_self, enqueue_self, call_self_static, enqueue_self_static, internal, utility)\n };\n };\n\n let original_function_name = f.name();\n\n // Modifications introduced by the different marker attributes.\n let internal_check = if is_fn_only_self(f) {\n let assertion_message = f\"Function {original_function_name} can only be called by the same contract\";\n quote { assert(self.msg_sender() == self.address, $assertion_message); }\n } else {\n quote {}\n };\n\n let view_check = if is_fn_view(f) {\n let assertion_message = f\"Function {original_function_name} can only be called statically\".as_quoted_str();\n quote { assert(self.context.is_static_call(), $assertion_message); }\n } else {\n quote {}\n };\n\n let (assert_initializer, mark_as_initialized) = if is_fn_initializer(f) {\n let has_public_fns_with_init_check = has_public_init_checked_functions(f.module());\n (\n quote {\n aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_private(*self.context);\n },\n quote { aztec::macros::functions::initialization_utils::mark_as_initialized_from_private_initializer(self.context, $has_public_fns_with_init_check); },\n )\n } else {\n (quote {}, quote {})\n };\n\n // Initialization checks are not included in contracts that don't have initializers.\n let init_check = if module_has_initializer & !is_fn_initializer(f) & !fn_has_noinitcheck(f) {\n quote { aztec::macros::functions::initialization_utils::assert_is_initialized_private(self.context); }\n } else {\n quote {}\n };\n\n // Phase checks are skipped in functions that request to manually handle phases\n let initial_phase_store = if fn_has_allow_phase_change(f) {\n quote {}\n } else {\n quote { let within_revertible_phase: bool = self.context.in_revertible_phase(); }\n };\n\n let no_phase_change_check = if fn_has_allow_phase_change(f) {\n quote {}\n } else {\n quote {\n assert_eq(\n within_revertible_phase,\n self.context.in_revertible_phase(),\n f\"Phase change detected on function with phase check. If this is expected, use #[allow_phase_change]\",\n );\n }\n };\n\n // Inject the authwit check if the function is marked with #[authorize_once].\n let authorize_once_check = if fn_has_authorize_once(f) {\n create_authorize_once_check(f, true)\n } else {\n quote {}\n };\n\n // Finally, we need to change the return type to be `PrivateCircuitPublicInputs`, which is what the Private Kernel\n // circuit expects.\n let return_value_var_name = quote { macro__returned__values };\n\n let return_value_type = f.return_type();\n let return_value = if body.len() == 0 {\n quote {}\n } else if return_value_type != type_of(()) {\n // The original return value is serialized and hashed before being passed to the context.\n let (body_without_return, last_body_expr) = body.pop_back();\n let return_value = last_body_expr.quoted();\n let return_value_assignment = quote { let $return_value_var_name: $return_value_type = $return_value; };\n\n let (return_serialization, _, serialized_return_name) =\n derive_serialization_quotes([(return_value_var_name, return_value_type)], false);\n\n body = body_without_return;\n\n quote {\n $return_value_assignment\n $return_serialization\n self.context.set_return_hash($serialized_return_name);\n }\n } else {\n let (body_without_return, last_body_expr) = body.pop_back();\n if !last_body_expr.has_semicolon()\n & last_body_expr.as_for().is_none()\n & last_body_expr.as_assert().is_none()\n & last_body_expr.as_for_range().is_none()\n & last_body_expr.as_assert_eq().is_none()\n & last_body_expr.as_let().is_none() {\n let unused_return_value_name = f\"_{return_value_var_name}\".quoted_contents();\n body = body_without_return.push_back(quote { let $unused_return_value_name = $last_body_expr; }\n .as_expr()\n .unwrap());\n }\n quote {}\n };\n\n let context_finish = quote { self.context.finish() };\n\n // Preserve all attributes that are relevant to the function's ABI.\n let abi_relevant_attributes = get_abi_relevant_attributes(f);\n\n let fn_name = f\"__aztec_nr_internals__{original_function_name}\".quoted_contents();\n\n let to_prepend = quote {\n aztec::oracle::version::assert_compatible_oracle_version();\n $contract_self_creation\n $initial_phase_store\n $assert_initializer\n $init_check\n $internal_check\n $view_check\n $authorize_once_check\n };\n\n let body_quote = body.map(|expr| expr.quoted()).join(quote { });\n\n // `mark_as_initialized` is placed after the user's function body. If it ran at the beginning, the contract\n // would appear initialized while the initializer is still running, allowing contracts called by the initializer\n // to re-enter into a half-initialized contract.\n let to_append = quote {\n $return_value\n $mark_as_initialized\n $no_phase_change_check\n $context_finish\n };\n\n // `PrivateCircuitPublicInputs` is a fixed protocol ABI: some of its fields are constant for a given function (e.g.\n // the `is_static_call` flag of a non-static function), and the compiler flags those as constants that could be\n // dropped from the return value. They cannot be dropped without changing the ABI, so silence the lint here rather\n // than letting it defeat `--deny-warnings` for every contract.\n quote {\n #[allow(constant_return)]\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_private]\n $abi_relevant_attributes\n fn $fn_name($params) -> return_data aztec::protocol::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs {\n $to_prepend\n $body_quote\n $to_append\n }\n }\n}\n"
|
|
160
160
|
},
|
|
161
161
|
"121": {
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"start": 4225
|
|
174
174
|
}
|
|
175
175
|
],
|
|
176
|
-
"path": "/
|
|
176
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/public.nr",
|
|
177
177
|
"source": "use crate::macros::{\n internals_functions_generation::external::helpers::{create_authorize_once_check, get_abi_relevant_attributes},\n utils::{\n fn_has_authorize_once, fn_has_noinitcheck, is_fn_initializer, is_fn_only_self, is_fn_view,\n module_has_initializer, module_has_storage,\n },\n};\n\n/// Emits a per-contract helper that creates the `self` value from a `PublicContext` already in scope.\n///\n/// This is the shared helper used by both:\n/// - public external functions, via [`generate_public_self_creator`], which constructs a fresh `PublicContext` from\n/// `calldata_copy` and then delegates to this helper; and\n/// - public internal functions and `#[contract_library_method]` bodies, which already receive `context` as a\n/// parameter and call this helper directly to skip the `calldata_copy` step.\npub(crate) comptime fn generate_public_self_creator_from_context(m: Module) -> Quoted {\n let (storage_type, storage_init) = if module_has_storage(m) {\n (quote { Storage<aztec::context::PublicContext> }, quote { let storage = Storage::init(context); })\n } else {\n // Contract does not have Storage defined, so we set storage to the unit type `()`. ContractSelfPublic requires\n // a storage struct in its constructor. Using an Option type would lead to worse developer experience and\n // higher constraint counts so we use the unit type `()` instead.\n (quote { () }, quote { let storage = (); })\n };\n\n quote {\n #[contract_library_method]\n unconstrained fn __aztec_nr_internals__create_public_self_from_context(context: aztec::context::PublicContext) -> aztec::contract_self::ContractSelfPublic<$storage_type, CallSelf<aztec::context::PublicContext>, CallSelfStatic<aztec::context::PublicContext>, CallInternal<aztec::context::PublicContext>> {\n $storage_init\n let self_address = context.this_address();\n let call_self: CallSelf<aztec::context::PublicContext> = CallSelf { address: self_address, context };\n let call_self_static: CallSelfStatic<aztec::context::PublicContext> = CallSelfStatic { address: self_address, context };\n let internal: CallInternal<aztec::context::PublicContext> = CallInternal { context };\n aztec::contract_self::ContractSelfPublic::new(context, storage, call_self, call_self_static, internal)\n }\n }\n}\n\n/// Generates the per-contract helper that builds public `self`.\n///\n/// Each public external function calls this helper instead of inlining the construction, so the same preamble does not\n/// appear duplicated in every public function body. We let Noir's inliner decide whether to inline the helper at each\n/// call site rather than forcing it via macro expansion.\n///\n/// The helper is generic over the calldata length `N` because `PublicContext::new` takes a closure that reads `N`\n/// fields from calldata. Noir monomorphizes one copy per distinct `N`, so public functions with the same number of\n/// serialized args reuse the same compiled code.\npub(crate) comptime fn generate_public_self_creator(m: Module) -> Quoted {\n let storage_type = if module_has_storage(m) {\n quote { Storage<aztec::context::PublicContext> }\n } else {\n quote { () }\n };\n\n quote {\n #[contract_library_method]\n unconstrained fn __aztec_nr_internals__create_public_self<let N: u32>() -> aztec::contract_self::ContractSelfPublic<$storage_type, CallSelf<aztec::context::PublicContext>, CallSelfStatic<aztec::context::PublicContext>, CallInternal<aztec::context::PublicContext>> {\n // Unlike in the private case, in public the `context` does not need to receive the hash of the original\n // params.\n let context = aztec::context::PublicContext::new(|| {\n // We start from 1 because we skip the selector for the dispatch function.\n let serialized_args : [Field; N] = aztec::oracle::avm::calldata_copy(1, N);\n aztec::hash::hash_args(serialized_args)\n });\n __aztec_nr_internals__create_public_self_from_context(context)\n }\n }\n}\n\npub(crate) comptime fn generate_public_external(f: FunctionDefinition) -> Quoted {\n let module_has_initializer = module_has_initializer(f.module());\n\n // Public functions undergo a lot of transformations from their Aztec.nr form.\n let original_params = f.parameters().map(|param| (param.name(), param.typ()));\n\n let args_len_quote = if original_params.len() == 0 {\n // If the function has no parameters, we set the args_len to 0.\n quote { 0 }\n } else {\n // The following will give us <type_of_struct_member_1 as Serialize>::N + <type_of_struct_member_2 as\n // Serialize>::N + ...\n original_params\n .map(|(_, param_type): (Quoted, Type)| {\n quote {\n <$param_type as $crate::protocol::traits::Serialize>::N\n }\n })\n .join(quote {+})\n };\n\n let contract_self_creation = quote {\n #[allow(unused_variables)]\n let mut self = __aztec_nr_internals__create_public_self::<$args_len_quote>();\n };\n\n let original_function_name = f.name();\n\n // Modifications introduced by the different marker attributes.\n let internal_check = if is_fn_only_self(f) {\n let assertion_message = f\"Function {original_function_name} can only be called by the same contract\";\n quote { assert(self.msg_sender() == self.address, $assertion_message); }\n } else {\n quote {}\n };\n\n let view_check = if is_fn_view(f) {\n let assertion_message = f\"Function {original_function_name} can only be called statically\".as_quoted_str();\n quote { assert(self.context.is_static_call(), $assertion_message); }\n } else {\n quote {}\n };\n\n let (assert_initializer, mark_as_initialized) = if is_fn_initializer(f) {\n (\n quote {\n aztec::macros::functions::initialization_utils::assert_initialization_matches_address_preimage_public(self.context);\n },\n quote {\n aztec::macros::functions::initialization_utils::mark_as_initialized_from_public_initializer(self.context);\n },\n )\n } else {\n (quote {}, quote {})\n };\n\n // Initialization checks are not included in contracts that don't have initializers.\n let init_check = if module_has_initializer & !fn_has_noinitcheck(f) & !is_fn_initializer(f) {\n quote { aztec::macros::functions::initialization_utils::assert_is_initialized_public(self.context); }\n } else {\n quote {}\n };\n\n // Inject the authwit check if the function is marked with #[authorize_once].\n let authorize_once_check = if fn_has_authorize_once(f) {\n create_authorize_once_check(f, false)\n } else {\n quote {}\n };\n\n let to_prepend = quote {\n $contract_self_creation\n $assert_initializer\n $init_check\n $internal_check\n $view_check\n $authorize_once_check\n };\n\n // `mark_as_initialized` is placed after the user's function body. If it ran at the beginning, the contract\n // would appear initialized while the initializer is still running, allowing contracts called by the initializer\n // to re-enter into a half-initialized contract.\n let to_append = quote {\n $mark_as_initialized\n };\n\n let fn_name = f\"__aztec_nr_internals__{original_function_name}\".quoted_contents();\n let body = f.body();\n let return_type = f.return_type();\n\n // New function parameters are the same as the original function's ones.\n let params = original_params.map(|(param_name, param_type)| quote { $param_name: $param_type }).join(quote {, });\n\n // Preserve all attributes that are relevant to the function's ABI.\n let abi_relevant_attributes = get_abi_relevant_attributes(f);\n\n // All public functions are automatically made unconstrained, even if they were not marked as such. This is because\n // instead of compiling into a circuit, they will compile to bytecode that will be later transpiled into AVM\n // bytecode.\n quote {\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_public]\n $abi_relevant_attributes\n unconstrained fn $fn_name($params) -> pub $return_type {\n $to_prepend\n $body\n $to_append\n }\n }\n}\n"
|
|
178
178
|
},
|
|
179
179
|
"122": {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"start": 1935
|
|
188
188
|
}
|
|
189
189
|
],
|
|
190
|
-
"path": "/
|
|
190
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation/external/utility.nr",
|
|
191
191
|
"source": "use crate::macros::utils::{fn_has_noinitcheck, module_has_initializer, module_has_storage};\n\n/// Emits a per-contract helper that builds the `self` value used by every utility external function.\n///\n/// Each utility external function calls this helper instead of inlining the construction, so the\n/// `UtilityContext::new`/`Storage::init`/`CallSelfUtility`/`ContractSelfUtility::new` chain does not appear duplicated\n/// in every utility function body. We let Noir's inliner decide whether to inline the helper at each call site rather\n/// than forcing it via macro expansion.\n///\n/// Unlike the public counterpart, this helper takes no arguments because `UtilityContext::new` does not need calldata.\npub(crate) comptime fn generate_utility_self_creator(m: Module) -> Quoted {\n let (storage_type, storage_init) = if module_has_storage(m) {\n (quote { Storage<aztec::context::UtilityContext> }, quote { let storage = Storage::init(context); })\n } else {\n // Contract does not have Storage defined, so we set storage to the unit type `()`. ContractSelfUtility requires\n // a storage struct in its constructor. Using an Option type would lead to worse developer experience and higher\n // constraint counts so we use the unit type `()` instead.\n (quote { () }, quote { let storage = (); })\n };\n\n quote {\n #[contract_library_method]\n unconstrained fn __aztec_nr_internals__create_utility_self() -> aztec::contract_self::ContractSelfUtility<$storage_type, CallSelfUtility> {\n let context = aztec::context::UtilityContext::new();\n $storage_init\n let self_address = context.this_address();\n let call_self = CallSelfUtility { address: self_address };\n aztec::contract_self::ContractSelfUtility::new(context, storage, call_self)\n }\n }\n}\n\npub(crate) comptime fn generate_utility_external(f: FunctionDefinition) -> Quoted {\n let module_has_initializer = module_has_initializer(f.module());\n\n let contract_self_creation = quote {\n #[allow(unused_variables)]\n let mut self = __aztec_nr_internals__create_utility_self();\n };\n\n // Initialization checks are not included in contracts that don't have initializers.\n let init_check = if module_has_initializer & !fn_has_noinitcheck(f) {\n quote {\n aztec::macros::functions::initialization_utils::assert_is_initialized_utility(\n self.context,\n );\n }\n } else {\n quote {}\n };\n\n // A quote to be injected at the beginning of the function body.\n let to_prepend = quote {\n aztec::oracle::version::assert_compatible_oracle_version();\n $contract_self_creation\n $init_check\n };\n\n let original_function_name = f.name();\n let fn_name = f\"__aztec_nr_internals__{original_function_name}\".quoted_contents();\n let body = f.body();\n let params = f\n .parameters()\n .map(|param| {\n let param_name = param.name();\n let param_type = param.typ();\n quote { $param_name: $param_type }\n })\n .join(quote {, });\n let return_type = f.return_type();\n\n quote {\n #[aztec::macros::internals_functions_generation::abi_attributes::abi_utility]\n unconstrained fn $fn_name($params) -> pub $return_type {\n $to_prepend\n $body\n }\n }\n}\n"
|
|
192
192
|
},
|
|
193
193
|
"165": {
|
|
@@ -237,98 +237,98 @@
|
|
|
237
237
|
"start": 11760
|
|
238
238
|
}
|
|
239
239
|
],
|
|
240
|
-
"path": "/
|
|
240
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/messages/processing/offchain/mod.nr",
|
|
241
241
|
"source": "use crate::{\n context::UtilityContext,\n ephemeral::EphemeralArray,\n messages::{encoding::MESSAGE_CIPHERTEXT_LEN, processing::OffchainMessageWithTx},\n oracle::{contract_sync::set_contract_sync_cache_invalid, tx_resolution::get_resolved_txs},\n protocol::{address::AztecAddress, traits::{Deserialize, Serialize}},\n};\n\nmod reception;\nuse reception::{MAX_ANCHOR_FUTURE_SKEW, OffchainReception};\n\n/// Maximum number of offchain messages accepted by `offchain_receive` in a single call.\npub global MAX_OFFCHAIN_MESSAGES_PER_RECEIVE_CALL: u32 = 16;\n\n/// A function that manages offchain-delivered messages for processing during sync.\n///\n/// Offchain messages are messages that are not broadcasted via onchain logs. They are instead delivered to the\n/// recipient by calling the `offchain_receive` utility function (injected by the `#[aztec]` macro). Message transport\n/// is the app's responsibility. Typical examples of transport methods are: messaging apps, email, QR codes, etc.\n///\n/// Once offchain messages are delivered to the recipient's private environment via `offchain_receive`, messages are\n/// locally stored in a persistent inbox.\n///\n/// This function determines when each message in said inbox is ready for processing, when it can be safely disposed\n/// of, etc.\n///\n/// The only current implementation of an [`OffchainInboxSync`] is [`sync_inbox`], which manages an inbox with\n/// expiration and finality-based eviction and automatic transaction context resolution.\npub type OffchainInboxSync = unconstrained fn(\n/* contract_address */AztecAddress, /* scope */ AztecAddress) -> EphemeralArray<OffchainMessageWithTx>;\n\n/// Delivers offchain messages to the given contract's offchain inbox for subsequent processing.\n///\n/// Offchain messages are transaction effects that are not broadcasted via onchain logs. Instead, the sender shares the\n/// message to the recipient through an external channel (e.g. a URL accessible by the recipient). The recipient then\n/// calls this function to hand the messages to the contract so they can be processed through the same mechanisms as\n/// onchain messages.\n///\n/// Messages are processed when their originating transaction is found onchain (providing the context needed to\n/// validate resulting notes and events).\n///\n/// Messages are eventually removed from the inbox: an unprocessed message once its TTL (`anchor_block_timestamp +\n/// MAX_MSG_TTL`) elapses, and a processed message once the block its transaction was found in finalizes.\n///\n/// Processing order is not guaranteed.\npub unconstrained fn receive(\n contract_address: AztecAddress,\n messages: BoundedVec<OffchainMessage, MAX_OFFCHAIN_MESSAGES_PER_RECEIVE_CALL>,\n) {\n // Offchain reception facts are scoped to the recipient. Note that because offchain messages have no integrity or\n // authenticity checks it is not possible to verify that this is indeed the intended recipient. In this case we're\n // assuming a cooperative environment, which is on par with other offchain delivery expectations.\n //\n // The sender-supplied anchor timestamp is the one field we bound: a message claiming to originate implausibly far\n // in our future (see MAX_ANCHOR_FUTURE_SKEW) cannot be genuine, and accepting it would let a malicious anchor evade\n // the TTL-based inbox eviction. We reject such a batch by panicking instead of silently dropping the message, so\n // the calling wallet can react to it (e.g. surface the error or distrust the sender).\n let now = UtilityContext::new().timestamp();\n messages.for_each(|msg| {\n assert(\n msg.anchor_block_timestamp <= now + MAX_ANCHOR_FUTURE_SKEW,\n \"offchain message anchor timestamp is implausibly far in the future\",\n );\n });\n\n messages.for_each(|msg| OffchainReception::init(contract_address, msg));\n\n // Clear cache for message recipients so the next sync runs.\n set_contract_sync_cache_invalid(contract_address, messages.map(|msg| msg.recipient));\n}\n\n/// Returns offchain-delivered messages to process during sync.\npub unconstrained fn sync_inbox(\n contract_address: AztecAddress,\n scope: AztecAddress,\n) -> EphemeralArray<OffchainMessageWithTx> {\n let active_receptions = OffchainReception::load_all(contract_address, scope);\n\n // Ask PXE to resolve each message's originating tx. We pass the tx hashes in reception order, so the resolved txs\n // come back aligned with the reception indices and can be matched back positionally.\n let resolved_txs = get_resolved_txs(active_receptions.map(|reception: OffchainReception| {\n reception.read_message().tx_hash.unwrap_or(0)\n }));\n\n let processable_messages: EphemeralArray<OffchainMessageWithTx> = EphemeralArray::empty();\n let now = UtilityContext::new().timestamp();\n\n active_receptions.for_each(|i, reception| {\n let maybe_message = reception.step(resolved_txs.get(i), now);\n if maybe_message.is_some() {\n processable_messages.push(maybe_message.unwrap());\n }\n });\n\n processable_messages\n}\n\n/// A message delivered via the `offchain_receive` utility function.\n#[derive(Serialize, Deserialize)]\npub struct OffchainMessage {\n /// The encrypted message payload.\n pub ciphertext: BoundedVec<Field, MESSAGE_CIPHERTEXT_LEN>,\n /// The intended recipient of the message.\n pub recipient: AztecAddress,\n /// The hash of the transaction that produced this message. `Option::none` indicates a tx-less message.\n pub tx_hash: Option<Field>,\n /// Anchor block timestamp at message emission.\n pub anchor_block_timestamp: u64,\n}\n\nmod test {\n use crate::{\n oracle::random::random,\n protocol::{address::AztecAddress, constants::MAX_TX_LIFETIME},\n test::helpers::test_environment::TestEnvironment,\n };\n use super::{MAX_OFFCHAIN_MESSAGES_PER_RECEIVE_CALL, OffchainMessage, receive, sync_inbox};\n use super::reception::{MAX_ANCHOR_FUTURE_SKEW, MAX_MSG_TTL, OffchainReception};\n\n unconstrained fn setup() -> (TestEnvironment, AztecAddress) {\n let mut env = TestEnvironment::new();\n let scope = env.create_light_account();\n (env, scope)\n }\n\n /// Creates an `OffchainMessage` with dummy ciphertext and the given scope as recipient.\n fn make_msg(recipient: AztecAddress, tx_hash: Option<Field>, anchor_block_timestamp: u64) -> OffchainMessage {\n OffchainMessage { ciphertext: BoundedVec::new(), recipient, tx_hash, anchor_block_timestamp }\n }\n\n /// Advances the TXE block timestamp by `offset` seconds and returns the resulting timestamp.\n unconstrained fn advance_by(env: TestEnvironment, offset: u64) -> u64 {\n env.advance_next_block_timestamp_by(offset);\n env.mine_block();\n env.last_block_timestamp()\n }\n\n #[test]\n unconstrained fn empty_inbox_returns_empty_result() {\n let (env, scope) = setup();\n env.utility_context(|context| {\n let address = context.this_address();\n let result = sync_inbox(address, scope);\n\n assert_eq(result.len(), 0);\n assert_eq(OffchainReception::load_all(address, scope).len(), 0);\n });\n }\n\n #[test]\n unconstrained fn multiple_messages_mixed_expiration() {\n let (env, scope) = setup();\n let anchor_ts = advance_by(env, 10);\n\n let expired_a_tx_hash = random();\n let survivor_tx_hash = random();\n\n let expired_a = make_msg(scope, Option::some(expired_a_tx_hash), 0);\n let survivor = make_msg(scope, Option::some(survivor_tx_hash), anchor_ts);\n let expired_b = make_msg(scope, Option::none(), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n let mut msgs: BoundedVec<OffchainMessage, MAX_OFFCHAIN_MESSAGES_PER_RECEIVE_CALL> = BoundedVec::new();\n // Message 0: tx-bound, anchor=0 so it expires quickly.\n msgs.push(expired_a);\n // Message 1: tx-bound, anchor_ts is recent so it survives.\n msgs.push(survivor);\n // Message 2: tx-less, anchor=0 so it also expires.\n msgs.push(expired_b);\n receive(address, msgs);\n });\n\n // Advance past MAX_MSG_TTL for anchor=0, but not for anchor_ts.\n let _now = advance_by(env, MAX_MSG_TTL);\n\n env.utility_context(|context| {\n let address = context.this_address();\n let result = sync_inbox(address, scope);\n\n assert_eq(result.len(), 0); // all contexts are None\n assert(\n !OffchainReception::is_active(address, scope, expired_a),\n \"expired tx-bound reception should be terminated\",\n );\n assert(\n !OffchainReception::is_active(address, scope, expired_b),\n \"expired tx-less reception should be terminated\",\n );\n assert(OffchainReception::is_active(address, scope, survivor), \"survivor reception should stay active\");\n assert_eq(OffchainReception::load_all(address, scope).len(), 1);\n });\n }\n\n #[test]\n unconstrained fn accepts_messages_within_the_tolerated_future_skew() {\n let (env, scope) = setup();\n let now = advance_by(env, 10);\n\n // A present-dated anchor and a 24h-future one both fall within the tolerated skew. The latter models a genuine\n // message whose sender anchored ahead of our lagging PXE, and must still be accepted.\n let present = make_msg(scope, Option::some(random()), now);\n let lagged = make_msg(scope, Option::some(random()), now + MAX_TX_LIFETIME);\n\n env.utility_context(|context| {\n let address = context.this_address();\n receive(address, BoundedVec::from_array([present, lagged]));\n\n assert(OffchainReception::is_active(address, scope, present));\n assert(OffchainReception::is_active(address, scope, lagged));\n assert_eq(OffchainReception::load_all(address, scope).len(), 2);\n });\n }\n\n #[test(should_fail_with = \"offchain message anchor timestamp is implausibly far in the future\")]\n unconstrained fn rejects_batch_with_implausible_future_anchor() {\n let (env, scope) = setup();\n let now = advance_by(env, 10);\n\n // Beyond `now + MAX_ANCHOR_FUTURE_SKEW`: our view would trail the tip by more than a tx lifetime, so this\n // cannot be genuine. Reception panics so the wallet can react rather than accept it.\n let too_future = make_msg(\n scope,\n Option::some(random()),\n now + MAX_ANCHOR_FUTURE_SKEW + 7200,\n );\n\n env.utility_context(|context| { receive(context.this_address(), BoundedVec::from_array([too_future])); });\n }\n\n // -- Idempotent re-delivery (first-write-wins fact recording) ---------\n\n #[test]\n unconstrained fn redelivery_is_idempotent() {\n let (env, scope) = setup();\n let anchor_ts = advance_by(env, 10);\n let msg = make_msg(scope, Option::some(random()), anchor_ts);\n\n // First delivery, committed as its own job.\n env.utility_context(|context| { receive(context.this_address(), BoundedVec::from_array([msg])); });\n\n // Re-delivering the same content-addressed message must not panic and must not create a second reception.\n env.utility_context(|context| {\n let address = context.this_address();\n receive(address, BoundedVec::from_array([msg]));\n\n assert(OffchainReception::is_active(address, scope, msg), \"reception should be active\");\n assert_eq(OffchainReception::load_all(address, scope).len(), 1);\n });\n }\n\n #[test]\n unconstrained fn redelivery_after_processing_keeps_processed_guard() {\n let (env, scope) = setup();\n let known_tx_hash: Field = 1;\n let anchor_ts = advance_by(env, 10);\n let msg = make_msg(scope, Option::some(known_tx_hash), anchor_ts);\n\n env.utility_context(|context| { receive(context.this_address(), BoundedVec::from_array([msg])); });\n\n let _now = advance_by(env, 100);\n\n // First sync resolves the message and marks it as processed.\n env.utility_context(|context| {\n let address = context.this_address();\n assert_eq(sync_inbox(address, scope).len(), 1);\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n });\n\n // Re-deliver the same message. The next sync recognizes it as already processed and does not re-push it.\n env.utility_context(|context| {\n let address = context.this_address();\n receive(address, BoundedVec::from_array([msg]));\n\n assert(\n OffchainReception::is_processed(address, scope, msg),\n \"re-delivery must preserve the processed guard\",\n );\n assert_eq(sync_inbox(address, scope).len(), 0);\n });\n }\n}\n"
|
|
242
242
|
},
|
|
243
243
|
"166": {
|
|
244
244
|
"function_locations": [
|
|
245
245
|
{
|
|
246
246
|
"name": "OffchainReception::init",
|
|
247
|
-
"start":
|
|
247
|
+
"start": 9701
|
|
248
248
|
},
|
|
249
249
|
{
|
|
250
250
|
"name": "OffchainReception::load_all",
|
|
251
|
-
"start":
|
|
251
|
+
"start": 10219
|
|
252
252
|
},
|
|
253
253
|
{
|
|
254
254
|
"name": "OffchainReception::read_message",
|
|
255
|
-
"start":
|
|
255
|
+
"start": 10568
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
258
|
"name": "OffchainReception::id_for",
|
|
259
|
-
"start":
|
|
259
|
+
"start": 11269
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
262
|
"name": "OffchainReception::is_active",
|
|
263
|
-
"start":
|
|
263
|
+
"start": 11588
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
266
|
"name": "OffchainReception::step",
|
|
267
|
-
"start":
|
|
267
|
+
"start": 12243
|
|
268
268
|
},
|
|
269
269
|
{
|
|
270
270
|
"name": "OffchainReception::is_processed",
|
|
271
|
-
"start":
|
|
271
|
+
"start": 13848
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
274
|
"name": "OffchainReception::mark_processed",
|
|
275
|
-
"start":
|
|
275
|
+
"start": 14416
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
278
|
"name": "OffchainReception::terminate",
|
|
279
|
-
"start":
|
|
279
|
+
"start": 14987
|
|
280
280
|
},
|
|
281
281
|
{
|
|
282
282
|
"name": "to_payload",
|
|
283
|
-
"start":
|
|
283
|
+
"start": 15361
|
|
284
284
|
},
|
|
285
285
|
{
|
|
286
286
|
"name": "test::setup",
|
|
287
|
-
"start":
|
|
287
|
+
"start": 15784
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
"name": "test::make_msg",
|
|
291
|
-
"start":
|
|
291
|
+
"start": 16114
|
|
292
292
|
},
|
|
293
293
|
{
|
|
294
294
|
"name": "test::resolved_tx_at_block",
|
|
295
|
-
"start":
|
|
295
|
+
"start": 16398
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
"name": "test::resolved_tx",
|
|
299
|
-
"start":
|
|
299
|
+
"start": 16789
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
302
|
"name": "test::expired_reception_is_terminated",
|
|
303
|
-
"start":
|
|
303
|
+
"start": 16906
|
|
304
304
|
},
|
|
305
305
|
{
|
|
306
306
|
"name": "test::unresolved_reception_stays_active",
|
|
307
|
-
"start":
|
|
307
|
+
"start": 17588
|
|
308
308
|
},
|
|
309
309
|
{
|
|
310
310
|
"name": "test::resolved_reception_is_ready_to_process",
|
|
311
|
-
"start":
|
|
311
|
+
"start": 18383
|
|
312
312
|
},
|
|
313
313
|
{
|
|
314
314
|
"name": "test::already_processed_reception_is_not_re_pushed",
|
|
315
|
-
"start":
|
|
315
|
+
"start": 19429
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
318
|
"name": "test::processed_reception_terminates_once_its_origin_block_finalizes",
|
|
319
|
-
"start":
|
|
319
|
+
"start": 20803
|
|
320
320
|
},
|
|
321
321
|
{
|
|
322
322
|
"name": "test::unfinalized_processed_reception_survives_past_the_ttl",
|
|
323
|
-
"start":
|
|
323
|
+
"start": 22028
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
326
|
"name": "test::expired_reception_is_still_processed_when_its_tx_resolves",
|
|
327
|
-
"start":
|
|
327
|
+
"start": 23418
|
|
328
328
|
}
|
|
329
329
|
],
|
|
330
|
-
"path": "/
|
|
331
|
-
"source": "//! The state machine of a single offchain message reception process.\n//!\n//! Offchain processing needs to handle some complexity, including the possibility of reorgs reverting message effects,\n//! and the need to reprocess messages in that case. The state chart below summarizes the current behavior.\n//!\n//! ```text\n//! offchain_receive() (process starts)\n//! |\n//! v\n//! +-----------+ tx found onchain +-----------+\n//! ---- | | --------------------------> | |\n//! tx not found | | | | | discover notes,\n//! |--> | RECEIVED | | PROCESSED | ~~> events, etc\n//! | | <-------------------------- | |\n//! | | tx block re-orged | |\n//! +-----------+ +-----------+\n//! | |\n//! | TTL expired | tx block finalized\n//! v v\n//! +---------------------------------------------------------+\n//! | TERMINATED (process ends) |\n//! +---------------------------------------------------------+\n//! ```\n//!\n//! ## States\n//!\n//! - **Received**: the message is stored but its originating transaction has not been found onchain yet (or the\n//! message is tx-less; see below). While the reception process is in this state, it keeps looking for the\n// transaction onchain.\n//! - **Processed**: the message has been handed off for processing. If there weren't reorgs, reaching this state would\n//! be equivalent to terminating the reception process. Since reorgs are a possibility, this state is not terminal\n//! until the block the originating transaction was found in finalizes.\n//! - **Terminated**: nothing else can be done with the message, either because its originating transaction never\n//! appeared within the TTL, or because the block it was processed in has finalized. This is the terminal state of\n//! this process.\n//!\n//! ## Transitions (each evaluated by [`OffchainReception::step`])\n//!\n//! - **Received -> Processed**: the originating transaction is found onchain. The message (packaged with its\n//! transaction context) is queued to have its actual contents processed (which can lead for example to the discovery\n//! of notes and events).\n//! - **Processed -> Received**: the block where the message transaction was originally found is re-orged out.\n//! - **Received -> Terminated**: the message TTL has elapsed (see below), so the originating transaction can no longer\n//! appear and the message is no longer processable.\n//! - **Processed -> Terminated**: the block the originating transaction was found in has finalized, so the effects of\n//! its processing are permanent and reorg-proof.\n//!\n//! # Message reception lifecycle and the TTL\n//!\n//! A reception expires once `now > anchor_block_timestamp + MAX_MSG_TTL`, where `MAX_MSG_TTL = MAX_TX_LIFETIME + 2h`.\n//! A transaction anchored at a given block can only be mined within\n//! [`MAX_TX_LIFETIME`](crate::protocol::constants::MAX_TX_LIFETIME) of that block, so once that\n//! window (plus a safety margin of 2 hours) has elapsed the originating transaction can no longer appear, and it is\n//! safe to stop looking for it.\n//!\n//! The TTL only matters for unprocessed messages. Already-processed message receptions complete when the block that\n//! included the originating transaction finalizes, which is exactly when the processing becomes reorg-proof.\n//!\n//! # Current limitations, future plans\n//!\n//! - Tx-less messages never reach `Processed` and are only ever removed by expiry. This will be supported in the\n//! future.\n//!\n//! # Implementation\n//!\n//! [`OffchainReception::init`] creates a [fact collection](crate::facts::FactCollection) of type\n//! `OFFCHAIN_RECEPTION_TYPE_ID`. The fact collection is identified by a hash of the `OffchainMessage` it tracks, which\n//! makes duplicate calls to `init` idempotent.\n//!\n//! Upon reception, an `OFFCHAIN_MESSAGE_RECEIVED` [non-retractable fact](crate::facts::record_non_retractable_fact) is\n//! recorded. The fact's payload is the `OffchainMessage` itself, which persists it to be subsequently processed.\n//! A fact collection with just an `OFFCHAIN_MESSAGE_RECEIVED` fact represents an active reception process in the\n//! RECEIVED state from our state chart above.\n//!\n//! The message reception state machine is driven externally, advancing one step at a time each time\n//! [`OffchainReception::step`] is invoked. [`OffchainReception::step`] implements the rest of the reception state\n//! machine described above.\n//!\n//! When stepping, if the transaction to the message is found onchain, an `OFFCHAIN_MESSAGE_PROCESSED`\n//! [retractable fact](crate::facts::record_retractable_fact) associated to the block where the transaction was found is\n//! recorded.\n//! Note that since this fact is retractable, a reorg dropping said block would result in the fact being automatically\n//! removed by PXE, effectively pushing the reception process back to `RECEIVED` state.\n//!\n//! To determine in which state of the reception process we are we just analyze the recorded facts:\n//!\n//! - If there is an `OFFCHAIN_MESSAGE_PROCESSED` fact we are in PROCESSED state. Once that fact's origin block has\n//! finalized the processing is reorg-proof, so the [fact collection](crate::facts::FactCollection) can (and should)\n//! be deleted; until then there is nothing to do.\n//! - If there is only an `OFFCHAIN_MESSAGE_RECEIVED` fact we are in RECEIVED state, so we check if the message\n//! transaction is now available onchain, and if so, exercise the RECEIVED->PROCESSED transition. Otherwise, once the\n//! TTL has elapsed the originating transaction can no longer appear and the collection can (and should) be deleted.\n//!\n//! The PROCESSED->RECEIVED transition is transparently handled by PXE: if a re-org caused the message transaction to\n//! fall off the chain, the `OFFCHAIN_MESSAGE_PROCESSED` fact disappears, taking us back to the RECEIVED state.\n\nuse crate::{\n ephemeral::EphemeralArray,\n facts::{\n delete_fact_collection, Fact, FactCollection, get_fact_collection, get_fact_collections_by_type, OriginBlock,\n record_non_retractable_fact, record_retractable_fact,\n },\n messages::processing::OffchainMessageWithTx,\n oracle::tx_resolution::ResolvedTx,\n protocol::{\n address::AztecAddress,\n constants::MAX_TX_LIFETIME,\n hash::{poseidon2_hash, sha256_to_field},\n traits::{Deserialize, Serialize},\n },\n};\nuse super::OffchainMessage;\n\n/// Maximum time-to-live for a tx-bound offchain message.\n///\n/// After `anchor_block_timestamp + MAX_MSG_TTL`, the message is evicted from the inbox.\n/// (7200 == 2 hours)\npub(crate) global MAX_MSG_TTL: u64 = MAX_TX_LIFETIME + 7200;\n\n/// Maximum amount by which a received message's `anchor_block_timestamp` may exceed our current timestamp.\n///\n/// A message's anchor is the timestamp of the block the sender anchored its originating tx to, so for a genuine\n/// message it is at or before our own anchor timestamp. Our PXE may lag the chain tip though, which can make a\n/// legitimate anchor appear to be in our future, so we tolerate a forward skew of `MAX_TX_LIFETIME` (the longest a tx\n/// can wait to be mined after its anchor) plus a 2h margin. A larger skew would mean our view trails the tip by more\n/// than a tx lifetime -- so far behind that we could not even build a tx that wouldn't be immediately expired -- so\n/// such a message cannot be genuine and is rejected on reception. Bounding the anchor this way also keeps accepted\n/// values near the present, which prevents the `anchor_block_timestamp + MAX_MSG_TTL` eviction check from overflowing.\n/// (7200 == 2 hours)\npub(crate) global MAX_ANCHOR_FUTURE_SKEW: u64 = MAX_TX_LIFETIME + 7200;\n\n/// Fact type id of the fact that stores the offchain message body inside a reception collection.\nglobal OFFCHAIN_MESSAGE_RECEIVED: Field = sha256_to_field(\"AZTEC_NR::OFFCHAIN_MESSAGE_RECEIVED\".as_bytes());\n\n/// Fact type id to mark an offchain message as processed.\n///\n/// A reception is in \"processed state\" exactly when its collection carries a fact of this type.\npub(crate) global OFFCHAIN_MESSAGE_PROCESSED: Field =\n sha256_to_field(\"AZTEC_NR::OFFCHAIN_MESSAGE_PROCESSED\".as_bytes());\n\n/// Fact-collection type id shared by every offchain message reception in the [fact store](crate::facts).\npub(crate) global OFFCHAIN_RECEPTION_TYPE_ID: Field =\n sha256_to_field(\"AZTEC_NR::OFFCHAIN_RECEPTION_TYPE_ID\".as_bytes());\n\n/// A single offchain message reception machine, backed by a [`FactCollection`](crate::facts::FactCollection).\n///\n/// Wraps the fact collection that tracks one message's progress through the reception state machine (see the\n/// [module documentation](super)); the [`OffchainMessage`] it carries is decoded on demand.\n#[derive(Deserialize, Serialize)]\npub(crate) struct OffchainReception {\n collection: FactCollection,\n}\n\nimpl OffchainReception {\n /// Initializes a new reception for a freshly received message, in the `Received` state.\n ///\n /// Re-initializing the same message is a no-op, which makes redelivery idempotent.\n pub(crate) unconstrained fn init(contract_address: AztecAddress, message: OffchainMessage) {\n record_non_retractable_fact(\n contract_address,\n message.recipient,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n OFFCHAIN_MESSAGE_RECEIVED,\n to_payload(message),\n );\n }\n\n /// Loads every active reception for the given contract and scope, decoding each message body.\n pub(crate) unconstrained fn load_all(\n contract_address: AztecAddress,\n scope: AztecAddress,\n ) -> EphemeralArray<OffchainReception> {\n get_fact_collections_by_type(contract_address, scope, OFFCHAIN_RECEPTION_TYPE_ID)\n .map(|collection: FactCollection| OffchainReception { collection })\n }\n\n /// Reads and returns the message this reception carries, decoding it from its fact collection.\n pub(crate) unconstrained fn read_message(self) -> OffchainMessage {\n let message_fact = self.collection.facts.find(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_RECEIVED).unwrap();\n let n = <OffchainMessage as Deserialize>::N;\n let mut fields = [0; <OffchainMessage as Deserialize>::N];\n for i in 0..n {\n fields[i] = message_fact.payload.get(i);\n }\n Deserialize::deserialize(fields)\n }\n\n /// Computes the fact-collection id that identifies a message's reception machine in the [fact store](crate::facts).\n ///\n /// The id is a hash of the message, which makes duplicate receptions of the same message collapse onto a single\n /// reception.\n pub(crate) fn id_for(message: OffchainMessage) -> Field {\n poseidon2_hash(message.serialize())\n }\n\n /// Returns `true` if a reception for `message` is currently active for the given contract and scope.\n pub(crate) unconstrained fn is_active(\n contract_address: AztecAddress,\n scope: AztecAddress,\n message: OffchainMessage,\n ) -> bool {\n get_fact_collection(\n contract_address,\n scope,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n )\n .is_some()\n }\n\n /// Advances this reception by one step of its state machine. See the [module documentation](super) for the\n /// states, transitions, and expiry rules.\n ///\n /// Returns `Some` with the message and its resolved context when this step determines the message is ready to be\n /// processed.\n pub(crate) unconstrained fn step(\n self,\n maybe_resolved_tx: Option<ResolvedTx>,\n now: u64,\n ) -> Option<OffchainMessageWithTx> {\n let message = self.read_message();\n let processed_fact = self.collection.facts.find(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_PROCESSED);\n\n if processed_fact.is_none() & maybe_resolved_tx.is_some() {\n // Received -> Processed: the originating tx is onchain.\n let resolved = maybe_resolved_tx.unwrap();\n self.mark_processed(resolved.block_number, resolved.block_hash);\n Option::some(\n OffchainMessageWithTx { message_ciphertext: message.ciphertext, resolved_tx: resolved },\n )\n } else if processed_fact.is_some() {\n if processed_fact.unwrap().origin_block.unwrap().block_state.is_finalized() {\n // Processed -> Terminated: once the marker's origin block finalizes, the processing is reorg-proof and\n // the reception is complete. Until then we wait: a reorg dropping that block removes the retractable\n // marker and PXE pushes us back to Received.\n self.terminate();\n }\n Option::none()\n } else {\n // Received -> Terminated: the TTL caps how long we keep looking for the originating tx.\n if now > message.anchor_block_timestamp + MAX_MSG_TTL {\n self.terminate();\n }\n Option::none()\n }\n }\n\n /// Returns `true` if the reception for `message` has been marked processed.\n pub(crate) unconstrained fn is_processed(\n contract_address: AztecAddress,\n scope: AztecAddress,\n message: OffchainMessage,\n ) -> bool {\n let maybe_collection = get_fact_collection(\n contract_address,\n scope,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n );\n if maybe_collection.is_some() {\n maybe_collection.unwrap().facts.any(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_PROCESSED)\n } else {\n false\n }\n }\n\n /// Records the retractable processed marker for this reception, originated at the resolved block.\n unconstrained fn mark_processed(self, block_number: u32, block_hash: Field) {\n let empty_payload: EphemeralArray<Field> = EphemeralArray::empty();\n record_retractable_fact(\n self.collection.contract_address,\n self.collection.scope,\n self.collection.fact_collection_type_id,\n self.collection.fact_collection_id,\n OFFCHAIN_MESSAGE_PROCESSED,\n empty_payload,\n OriginBlock { block_number, block_hash },\n );\n }\n\n /// Terminates this reception by deleting its [fact collection](crate::facts::FactCollection).\n unconstrained fn terminate(self) {\n delete_fact_collection(\n self.collection.contract_address,\n self.collection.scope,\n self.collection.fact_collection_type_id,\n self.collection.fact_collection_id,\n );\n }\n}\n\n/// Serializes an [`OffchainMessage`] into a fact payload.\nunconstrained fn to_payload(message: OffchainMessage) -> EphemeralArray<Field> {\n let fields = message.serialize();\n let payload: EphemeralArray<Field> = EphemeralArray::empty();\n for i in 0..fields.len() {\n payload.push(fields[i]);\n }\n payload\n}\n\nmod test {\n use crate::{\n messages::processing::offchain::OffchainMessage,\n oracle::{random::random, tx_resolution::ResolvedTx},\n protocol::address::AztecAddress,\n test::helpers::test_environment::TestEnvironment,\n };\n use super::{MAX_MSG_TTL, OffchainReception};\n\n unconstrained fn setup() -> (TestEnvironment, AztecAddress) {\n let mut env = TestEnvironment::new();\n let scope = env.create_light_account();\n (env, scope)\n }\n\n /// Creates an `OffchainMessage` with dummy ciphertext and the given scope as recipient.\n fn make_msg(recipient: AztecAddress, tx_hash: Option<Field>, anchor_block_timestamp: u64) -> OffchainMessage {\n OffchainMessage { ciphertext: BoundedVec::new(), recipient, tx_hash, anchor_block_timestamp }\n }\n\n /// Builds the resolved-tx context PXE would return for `tx_hash`, found in `block_number`.\n fn resolved_tx_at_block(tx_hash: Field, block_number: u32) -> ResolvedTx {\n ResolvedTx {\n tx_hash,\n unique_note_hashes_in_tx: BoundedVec::new(),\n first_nullifier_in_tx: 0,\n block_number,\n block_hash: 0,\n }\n }\n\n /// Builds a resolved-tx context found in a low block, which TXE (proven == finalized == latest) reports as\n /// `Finalized`.\n fn resolved_tx(tx_hash: Field) -> ResolvedTx {\n resolved_tx_at_block(tx_hash, 1)\n }\n\n #[test]\n unconstrained fn expired_reception_is_terminated() {\n let (env, scope) = setup();\n let msg = make_msg(scope, Option::some(random()), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // Past the TTL with no resolved tx: the reception is terminated.\n assert(reception.step(Option::none(), MAX_MSG_TTL + 1).is_none());\n assert(!OffchainReception::is_active(address, scope, msg), \"expired reception should be terminated\");\n });\n }\n\n #[test]\n unconstrained fn unresolved_reception_stays_active() {\n let (env, scope) = setup();\n let msg = make_msg(scope, Option::some(random()), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // Within the TTL with no resolved tx: nothing to process, the reception stays.\n assert(reception.step(Option::none(), 100).is_none());\n assert(OffchainReception::is_active(address, scope, msg), \"unresolved reception should stay active\");\n assert(!OffchainReception::is_processed(address, scope, msg), \"should still be unprocessed\");\n });\n }\n\n #[test]\n unconstrained fn resolved_reception_is_ready_to_process() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // A resolved tx within the TTL: the message is handed off with its tx context attached.\n let processable = reception.step(Option::some(resolved_tx(tx_hash)), 100);\n assert(processable.is_some());\n assert_eq(processable.unwrap().resolved_tx.tx_hash, tx_hash);\n\n // It stays active for reorg safety and is now marked processed.\n assert(OffchainReception::is_active(address, scope, msg), \"processed reception should stay active\");\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n });\n }\n\n #[test]\n unconstrained fn already_processed_reception_is_not_re_pushed() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n // A future origin block stays unfinalized, so the reception lingers in Processed across steps.\n let future_block = env.last_block_number() + 100;\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // First step processes the message.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Second step (still resolved, not finalized) recognizes it as processed and does not re-push it.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(\n reloaded.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_none(),\n \"already processed\",\n );\n assert(OffchainReception::is_active(address, scope, msg), \"processed reception should still be active\");\n });\n }\n\n #[test]\n unconstrained fn processed_reception_terminates_once_its_origin_block_finalizes() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // Process the message against a finalized block.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx(tx_hash)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Next step, still well within the TTL: a finalized origin block makes the processing reorg-proof, so the\n // reception terminates regardless of the TTL.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(reloaded.step(Option::some(resolved_tx(tx_hash)), 100).is_none());\n assert(\n !OffchainReception::is_active(address, scope, msg),\n \"finalized processed reception should be terminated\",\n );\n });\n }\n\n #[test]\n unconstrained fn unfinalized_processed_reception_survives_past_the_ttl() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n // A future origin block never finalizes here, so the reception must not be terminated by the TTL.\n let future_block = env.last_block_number() + 100;\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Past the TTL, but the origin block has not finalized: the reception stays active. The TTL no longer\n // governs an already-processed reception.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(reloaded.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), MAX_MSG_TTL + 1).is_none());\n assert(\n OffchainReception::is_active(address, scope, msg),\n \"unfinalized processed reception should survive past the TTL\",\n );\n });\n }\n\n #[test]\n unconstrained fn expired_reception_is_still_processed_when_its_tx_resolves() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // Even past the TTL, a freshly resolved tx is still handed off: expiry only caps the search for the\n // originating tx, it does not pre-empt processing once that tx is found.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx(tx_hash)), MAX_MSG_TTL + 1).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n assert(OffchainReception::is_active(address, scope, msg), \"just-processed reception should stay active\");\n });\n }\n}\n"
|
|
330
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/messages/processing/offchain/reception.nr",
|
|
331
|
+
"source": "//! The state machine of a single offchain message reception process.\n//!\n//! Offchain processing needs to handle some complexity, including the possibility of reorgs reverting message effects,\n//! and the need to reprocess messages in that case. The state chart below summarizes the current behavior.\n//!\n//! ```text\n//! offchain_receive() (process starts)\n//! |\n//! v\n//! +-----------+ tx found onchain +-----------+\n//! ---- | | --------------------------> | |\n//! tx not found | | | | | discover notes,\n//! |--> | RECEIVED | | PROCESSED | ~~> events, etc\n//! | | <-------------------------- | |\n//! | | tx block re-orged | |\n//! +-----------+ +-----------+\n//! | |\n//! | TTL expired | tx block finalized\n//! v v\n//! +---------------------------------------------------------+\n//! | TERMINATED (process ends) |\n//! +---------------------------------------------------------+\n//! ```\n//!\n//! ## States\n//!\n//! - **Received**: the message is stored but its originating transaction has not been found onchain yet (or the\n//! message is tx-less; see below). While the reception process is in this state, it keeps looking for the\n// transaction onchain.\n//! - **Processed**: the message has been handed off for processing. If there weren't reorgs, reaching this state would\n//! be equivalent to terminating the reception process. Since reorgs are a possibility, this state is not terminal\n//! until the block the originating transaction was found in finalizes.\n//! - **Terminated**: nothing else can be done with the message, either because its originating transaction never\n//! appeared within the TTL, or because the block it was processed in has finalized. This is the terminal state of\n//! this process.\n//!\n//! ## Transitions (each evaluated by [`OffchainReception::step`])\n//!\n//! - **Received -> Processed**: the originating transaction is found onchain. The message (packaged with its\n//! transaction context) is queued to have its actual contents processed (which can lead for example to the discovery\n//! of notes and events).\n//! - **Processed -> Received**: the block where the message transaction was originally found is re-orged out.\n//! - **Received -> Terminated**: the message TTL has elapsed (see below), so the originating transaction can no longer\n//! appear and the message is no longer processable.\n//! - **Processed -> Terminated**: the block the originating transaction was found in has finalized, so the effects of\n//! its processing are permanent and reorg-proof.\n//!\n//! # Message reception lifecycle and the TTL\n//!\n//! A reception expires once `now > anchor_block_timestamp + MAX_MSG_TTL`, where `MAX_MSG_TTL = MAX_TX_LIFETIME + 2h`.\n//! A transaction anchored at a given block can only be mined within\n//! [`MAX_TX_LIFETIME`](crate::protocol::constants::MAX_TX_LIFETIME) of that block, so once that\n//! window (plus a safety margin of 2 hours) has elapsed the originating transaction can no longer appear, and it is\n//! safe to stop looking for it.\n//!\n//! The TTL only matters for unprocessed messages. Already-processed message receptions complete when the block that\n//! included the originating transaction finalizes, which is exactly when the processing becomes reorg-proof.\n//!\n//! # Current limitations, future plans\n//!\n//! - Tx-less messages never reach `Processed` and are only ever removed by expiry. This will be supported in the\n//! future.\n//!\n//! # Implementation\n//!\n//! [`OffchainReception::init`] creates a [fact collection](crate::facts::FactCollection) of type\n//! `OFFCHAIN_RECEPTION_TYPE_ID`. The fact collection is identified by a hash of the `OffchainMessage` it tracks, which\n//! makes duplicate calls to `init` idempotent.\n//!\n//! Upon reception, an `OFFCHAIN_MESSAGE_RECEIVED` [non-retractable fact](crate::facts::record_non_retractable_fact) is\n//! recorded. The fact's payload is the `OffchainMessage` itself, which persists it to be subsequently processed.\n//! A fact collection with just an `OFFCHAIN_MESSAGE_RECEIVED` fact represents an active reception process in the\n//! RECEIVED state from our state chart above.\n//!\n//! The message reception state machine is driven externally, advancing one step at a time each time\n//! [`OffchainReception::step`] is invoked. [`OffchainReception::step`] implements the rest of the reception state\n//! machine described above.\n//!\n//! When stepping, if the transaction to the message is found onchain, an `OFFCHAIN_MESSAGE_PROCESSED`\n//! [retractable fact](crate::facts::record_retractable_fact) associated to the block where the transaction was found is\n//! recorded.\n//! Note that since this fact is retractable, a reorg dropping said block would result in the fact being automatically\n//! removed by PXE, effectively pushing the reception process back to `RECEIVED` state.\n//!\n//! To determine in which state of the reception process we are we just analyze the recorded facts:\n//!\n//! - If there is an `OFFCHAIN_MESSAGE_PROCESSED` fact we are in PROCESSED state. Once that fact's origin block has\n//! finalized the processing is reorg-proof, so the [fact collection](crate::facts::FactCollection) can (and should)\n//! be deleted; until then there is nothing to do.\n//! - If there is only an `OFFCHAIN_MESSAGE_RECEIVED` fact we are in RECEIVED state, so we check if the message\n//! transaction is now available onchain, and if so, exercise the RECEIVED->PROCESSED transition. Otherwise, once the\n//! TTL has elapsed the originating transaction can no longer appear and the collection can (and should) be deleted.\n//!\n//! The PROCESSED->RECEIVED transition is transparently handled by PXE: if a re-org caused the message transaction to\n//! fall off the chain, the `OFFCHAIN_MESSAGE_PROCESSED` fact disappears, taking us back to the RECEIVED state.\n\nuse crate::{\n ephemeral::EphemeralArray,\n facts::{\n delete_fact_collection, Fact, FactCollection, get_fact_collection, get_fact_collections_by_type,\n record_non_retractable_fact, record_retractable_fact,\n },\n messages::processing::OffchainMessageWithTx,\n oracle::{block_reference::BlockReference, tx_resolution::ResolvedTx},\n protocol::{\n address::AztecAddress,\n constants::MAX_TX_LIFETIME,\n hash::{poseidon2_hash, sha256_to_field},\n traits::{Deserialize, Serialize},\n },\n};\nuse super::OffchainMessage;\n\n/// Maximum time-to-live for a tx-bound offchain message.\n///\n/// After `anchor_block_timestamp + MAX_MSG_TTL`, the message is evicted from the inbox.\n/// (7200 == 2 hours)\npub(crate) global MAX_MSG_TTL: u64 = MAX_TX_LIFETIME + 7200;\n\n/// Maximum amount by which a received message's `anchor_block_timestamp` may exceed our current timestamp.\n///\n/// A message's anchor is the timestamp of the block the sender anchored its originating tx to, so for a genuine\n/// message it is at or before our own anchor timestamp. Our PXE may lag the chain tip though, which can make a\n/// legitimate anchor appear to be in our future, so we tolerate a forward skew of `MAX_TX_LIFETIME` (the longest a tx\n/// can wait to be mined after its anchor) plus a 2h margin. A larger skew would mean our view trails the tip by more\n/// than a tx lifetime -- so far behind that we could not even build a tx that wouldn't be immediately expired -- so\n/// such a message cannot be genuine and is rejected on reception. Bounding the anchor this way also keeps accepted\n/// values near the present, which prevents the `anchor_block_timestamp + MAX_MSG_TTL` eviction check from overflowing.\n/// (7200 == 2 hours)\npub(crate) global MAX_ANCHOR_FUTURE_SKEW: u64 = MAX_TX_LIFETIME + 7200;\n\n/// Fact type id of the fact that stores the offchain message body inside a reception collection.\nglobal OFFCHAIN_MESSAGE_RECEIVED: Field = sha256_to_field(\"AZTEC_NR::OFFCHAIN_MESSAGE_RECEIVED\".as_bytes());\n\n/// Fact type id to mark an offchain message as processed.\n///\n/// A reception is in \"processed state\" exactly when its collection carries a fact of this type.\npub(crate) global OFFCHAIN_MESSAGE_PROCESSED: Field =\n sha256_to_field(\"AZTEC_NR::OFFCHAIN_MESSAGE_PROCESSED\".as_bytes());\n\n/// Fact-collection type id shared by every offchain message reception in the [fact store](crate::facts).\npub(crate) global OFFCHAIN_RECEPTION_TYPE_ID: Field =\n sha256_to_field(\"AZTEC_NR::OFFCHAIN_RECEPTION_TYPE_ID\".as_bytes());\n\n/// A single offchain message reception machine, backed by a [`FactCollection`](crate::facts::FactCollection).\n///\n/// Wraps the fact collection that tracks one message's progress through the reception state machine (see the\n/// [module documentation](super)); the [`OffchainMessage`] it carries is decoded on demand.\n#[derive(Deserialize, Serialize)]\npub(crate) struct OffchainReception {\n collection: FactCollection,\n}\n\nimpl OffchainReception {\n /// Initializes a new reception for a freshly received message, in the `Received` state.\n ///\n /// Re-initializing the same message is a no-op, which makes redelivery idempotent.\n pub(crate) unconstrained fn init(contract_address: AztecAddress, message: OffchainMessage) {\n record_non_retractable_fact(\n contract_address,\n message.recipient,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n OFFCHAIN_MESSAGE_RECEIVED,\n to_payload(message),\n );\n }\n\n /// Loads every active reception for the given contract and scope, decoding each message body.\n pub(crate) unconstrained fn load_all(\n contract_address: AztecAddress,\n scope: AztecAddress,\n ) -> EphemeralArray<OffchainReception> {\n get_fact_collections_by_type(contract_address, scope, OFFCHAIN_RECEPTION_TYPE_ID)\n .map(|collection: FactCollection| OffchainReception { collection })\n }\n\n /// Reads and returns the message this reception carries, decoding it from its fact collection.\n pub(crate) unconstrained fn read_message(self) -> OffchainMessage {\n let message_fact = self.collection.facts.find(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_RECEIVED).unwrap();\n let n = <OffchainMessage as Deserialize>::N;\n let mut fields = [0; <OffchainMessage as Deserialize>::N];\n for i in 0..n {\n fields[i] = message_fact.payload.get(i);\n }\n Deserialize::deserialize(fields)\n }\n\n /// Computes the fact-collection id that identifies a message's reception machine in the [fact store](crate::facts).\n ///\n /// The id is a hash of the message, which makes duplicate receptions of the same message collapse onto a single\n /// reception.\n pub(crate) fn id_for(message: OffchainMessage) -> Field {\n poseidon2_hash(message.serialize())\n }\n\n /// Returns `true` if a reception for `message` is currently active for the given contract and scope.\n pub(crate) unconstrained fn is_active(\n contract_address: AztecAddress,\n scope: AztecAddress,\n message: OffchainMessage,\n ) -> bool {\n get_fact_collection(\n contract_address,\n scope,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n )\n .is_some()\n }\n\n /// Advances this reception by one step of its state machine. See the [module documentation](super) for the\n /// states, transitions, and expiry rules.\n ///\n /// Returns `Some` with the message and its resolved context when this step determines the message is ready to be\n /// processed.\n pub(crate) unconstrained fn step(\n self,\n maybe_resolved_tx: Option<ResolvedTx>,\n now: u64,\n ) -> Option<OffchainMessageWithTx> {\n let message = self.read_message();\n let processed_fact = self.collection.facts.find(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_PROCESSED);\n\n if processed_fact.is_none() & maybe_resolved_tx.is_some() {\n // Received -> Processed: the originating tx is onchain.\n let resolved = maybe_resolved_tx.unwrap();\n self.mark_processed(resolved.block_number, resolved.block_hash);\n Option::some(\n OffchainMessageWithTx { message_ciphertext: message.ciphertext, resolved_tx: resolved },\n )\n } else if processed_fact.is_some() {\n if processed_fact.unwrap().origin_block.unwrap().block_state.is_finalized() {\n // Processed -> Terminated: once the marker's origin block finalizes, the processing is reorg-proof and\n // the reception is complete. Until then we wait: a reorg dropping that block removes the retractable\n // marker and PXE pushes us back to Received.\n self.terminate();\n }\n Option::none()\n } else {\n // Received -> Terminated: the TTL caps how long we keep looking for the originating tx.\n if now > message.anchor_block_timestamp + MAX_MSG_TTL {\n self.terminate();\n }\n Option::none()\n }\n }\n\n /// Returns `true` if the reception for `message` has been marked processed.\n pub(crate) unconstrained fn is_processed(\n contract_address: AztecAddress,\n scope: AztecAddress,\n message: OffchainMessage,\n ) -> bool {\n let maybe_collection = get_fact_collection(\n contract_address,\n scope,\n OFFCHAIN_RECEPTION_TYPE_ID,\n Self::id_for(message),\n );\n if maybe_collection.is_some() {\n maybe_collection.unwrap().facts.any(|f: Fact| f.fact_type_id == OFFCHAIN_MESSAGE_PROCESSED)\n } else {\n false\n }\n }\n\n /// Records the retractable processed marker for this reception, originated at the resolved block.\n unconstrained fn mark_processed(self, block_number: u32, block_hash: Field) {\n let empty_payload: EphemeralArray<Field> = EphemeralArray::empty();\n record_retractable_fact(\n self.collection.contract_address,\n self.collection.scope,\n self.collection.fact_collection_type_id,\n self.collection.fact_collection_id,\n OFFCHAIN_MESSAGE_PROCESSED,\n empty_payload,\n BlockReference { block_number, block_hash },\n );\n }\n\n /// Terminates this reception by deleting its [fact collection](crate::facts::FactCollection).\n unconstrained fn terminate(self) {\n delete_fact_collection(\n self.collection.contract_address,\n self.collection.scope,\n self.collection.fact_collection_type_id,\n self.collection.fact_collection_id,\n );\n }\n}\n\n/// Serializes an [`OffchainMessage`] into a fact payload.\nunconstrained fn to_payload(message: OffchainMessage) -> EphemeralArray<Field> {\n EphemeralArray::from_array(message.serialize())\n}\n\nmod test {\n use crate::{\n messages::processing::offchain::OffchainMessage,\n oracle::{random::random, tx_resolution::ResolvedTx},\n protocol::address::AztecAddress,\n test::helpers::test_environment::TestEnvironment,\n };\n use super::{MAX_MSG_TTL, OffchainReception};\n\n unconstrained fn setup() -> (TestEnvironment, AztecAddress) {\n let mut env = TestEnvironment::new();\n let scope = env.create_light_account();\n (env, scope)\n }\n\n /// Creates an `OffchainMessage` with dummy ciphertext and the given scope as recipient.\n fn make_msg(recipient: AztecAddress, tx_hash: Option<Field>, anchor_block_timestamp: u64) -> OffchainMessage {\n OffchainMessage { ciphertext: BoundedVec::new(), recipient, tx_hash, anchor_block_timestamp }\n }\n\n /// Builds the resolved-tx context PXE would return for `tx_hash`, found in `block_number`.\n fn resolved_tx_at_block(tx_hash: Field, block_number: u32) -> ResolvedTx {\n ResolvedTx {\n tx_hash,\n unique_note_hashes_in_tx: BoundedVec::new(),\n first_nullifier_in_tx: 0,\n block_number,\n block_hash: 0,\n }\n }\n\n /// Builds a resolved-tx context found in a low block, which TXE (proven == finalized == latest) reports as\n /// `Finalized`.\n fn resolved_tx(tx_hash: Field) -> ResolvedTx {\n resolved_tx_at_block(tx_hash, 1)\n }\n\n #[test]\n unconstrained fn expired_reception_is_terminated() {\n let (env, scope) = setup();\n let msg = make_msg(scope, Option::some(random()), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // Past the TTL with no resolved tx: the reception is terminated.\n assert(reception.step(Option::none(), MAX_MSG_TTL + 1).is_none());\n assert(!OffchainReception::is_active(address, scope, msg), \"expired reception should be terminated\");\n });\n }\n\n #[test]\n unconstrained fn unresolved_reception_stays_active() {\n let (env, scope) = setup();\n let msg = make_msg(scope, Option::some(random()), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // Within the TTL with no resolved tx: nothing to process, the reception stays.\n assert(reception.step(Option::none(), 100).is_none());\n assert(OffchainReception::is_active(address, scope, msg), \"unresolved reception should stay active\");\n assert(!OffchainReception::is_processed(address, scope, msg), \"should still be unprocessed\");\n });\n }\n\n #[test]\n unconstrained fn resolved_reception_is_ready_to_process() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n let reception = OffchainReception::load_all(address, scope).get(0);\n\n // A resolved tx within the TTL: the message is handed off with its tx context attached.\n let processable = reception.step(Option::some(resolved_tx(tx_hash)), 100);\n assert(processable.is_some());\n assert_eq(processable.unwrap().resolved_tx.tx_hash, tx_hash);\n\n // It stays active for reorg safety and is now marked processed.\n assert(OffchainReception::is_active(address, scope, msg), \"processed reception should stay active\");\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n });\n }\n\n #[test]\n unconstrained fn already_processed_reception_is_not_re_pushed() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n // A future origin block stays unfinalized, so the reception lingers in Processed across steps.\n let future_block = env.last_block_number() + 100;\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // First step processes the message.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Second step (still resolved, not finalized) recognizes it as processed and does not re-push it.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(\n reloaded.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_none(),\n \"already processed\",\n );\n assert(OffchainReception::is_active(address, scope, msg), \"processed reception should still be active\");\n });\n }\n\n #[test]\n unconstrained fn processed_reception_terminates_once_its_origin_block_finalizes() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // Process the message against a finalized block.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx(tx_hash)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Next step, still well within the TTL: a finalized origin block makes the processing reorg-proof, so the\n // reception terminates regardless of the TTL.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(reloaded.step(Option::some(resolved_tx(tx_hash)), 100).is_none());\n assert(\n !OffchainReception::is_active(address, scope, msg),\n \"finalized processed reception should be terminated\",\n );\n });\n }\n\n #[test]\n unconstrained fn unfinalized_processed_reception_survives_past_the_ttl() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n // A future origin block never finalizes here, so the reception must not be terminated by the TTL.\n let future_block = env.last_block_number() + 100;\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), 100).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n\n // Past the TTL, but the origin block has not finalized: the reception stays active. The TTL no longer\n // governs an already-processed reception.\n let reloaded = OffchainReception::load_all(address, scope).get(0);\n assert(reloaded.step(Option::some(resolved_tx_at_block(tx_hash, future_block)), MAX_MSG_TTL + 1).is_none());\n assert(\n OffchainReception::is_active(address, scope, msg),\n \"unfinalized processed reception should survive past the TTL\",\n );\n });\n }\n\n #[test]\n unconstrained fn expired_reception_is_still_processed_when_its_tx_resolves() {\n let (env, scope) = setup();\n let tx_hash = random();\n let msg = make_msg(scope, Option::some(tx_hash), 0);\n\n env.utility_context(|context| {\n let address = context.this_address();\n OffchainReception::init(address, msg);\n\n // Even past the TTL, a freshly resolved tx is still handed off: expiry only caps the search for the\n // originating tx, it does not pre-empt processing once that tx is found.\n let reception = OffchainReception::load_all(address, scope).get(0);\n assert(reception.step(Option::some(resolved_tx(tx_hash)), MAX_MSG_TTL + 1).is_some());\n assert(OffchainReception::is_processed(address, scope, msg), \"should be processed\");\n assert(OffchainReception::is_active(address, scope, msg), \"just-processed reception should stay active\");\n });\n }\n}\n"
|
|
332
332
|
},
|
|
333
333
|
"17": {
|
|
334
334
|
"function_locations": [
|
|
@@ -751,10 +751,10 @@
|
|
|
751
751
|
"start": 7247
|
|
752
752
|
}
|
|
753
753
|
],
|
|
754
|
-
"path": "/
|
|
754
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/avm.nr",
|
|
755
755
|
"source": "//! AVM oracles.\n//!\n//! There are only available during public execution. Calling any of them from a private or utility function will\n//! result in runtime errors.\n\nuse crate::protocol::address::{AztecAddress, EthAddress};\n\npub unconstrained fn address() -> AztecAddress {\n address_opcode()\n}\npub unconstrained fn sender() -> AztecAddress {\n sender_opcode()\n}\npub unconstrained fn transaction_fee() -> Field {\n transaction_fee_opcode()\n}\npub unconstrained fn chain_id() -> Field {\n chain_id_opcode()\n}\npub unconstrained fn version() -> Field {\n version_opcode()\n}\npub unconstrained fn block_number() -> u32 {\n block_number_opcode()\n}\npub unconstrained fn timestamp() -> u64 {\n timestamp_opcode()\n}\npub unconstrained fn min_fee_per_l2_gas() -> u128 {\n min_fee_per_l2_gas_opcode()\n}\npub unconstrained fn min_fee_per_da_gas() -> u128 {\n min_fee_per_da_gas_opcode()\n}\npub unconstrained fn l2_gas_left() -> u32 {\n l2_gas_left_opcode()\n}\npub unconstrained fn da_gas_left() -> u32 {\n da_gas_left_opcode()\n}\npub unconstrained fn is_static_call() -> bool {\n is_static_call_opcode()\n}\npub unconstrained fn note_hash_exists(note_hash: Field, leaf_index: u64) -> bool {\n note_hash_exists_opcode(note_hash, leaf_index)\n}\npub unconstrained fn emit_note_hash(note_hash: Field) {\n emit_note_hash_opcode(note_hash)\n}\npub unconstrained fn nullifier_exists(siloed_nullifier: Field) -> bool {\n nullifier_exists_opcode(siloed_nullifier)\n}\npub unconstrained fn emit_nullifier(nullifier: Field) {\n emit_nullifier_opcode(nullifier)\n}\npub unconstrained fn emit_public_log(message: [Field]) {\n emit_public_log_opcode(message)\n}\npub unconstrained fn l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: u64) -> bool {\n l1_to_l2_msg_exists_opcode(msg_hash, msg_leaf_index)\n}\npub unconstrained fn send_l2_to_l1_msg(recipient: EthAddress, content: Field) {\n send_l2_to_l1_msg_opcode(recipient, content)\n}\n\npub unconstrained fn call<let N: u32>(\n l2_gas_allocation: u32,\n da_gas_allocation: u32,\n address: AztecAddress,\n args: [Field; N],\n) {\n call_opcode(l2_gas_allocation, da_gas_allocation, address, N, args)\n}\n\npub unconstrained fn call_static<let N: u32>(\n l2_gas_allocation: u32,\n da_gas_allocation: u32,\n address: AztecAddress,\n args: [Field; N],\n) {\n call_static_opcode(l2_gas_allocation, da_gas_allocation, address, N, args)\n}\n\npub unconstrained fn calldata_copy<let N: u32>(cdoffset: u32, copy_size: u32) -> [Field; N] {\n calldata_copy_opcode(cdoffset, copy_size)\n}\n\n/// `success_copy` is placed immediately after the CALL opcode to get the success value\npub unconstrained fn success_copy() -> bool {\n success_copy_opcode()\n}\n\npub unconstrained fn returndata_size() -> u32 {\n returndata_size_opcode()\n}\n\npub unconstrained fn returndata_copy(rdoffset: u32, copy_size: u32) -> [Field] {\n returndata_copy_opcode(rdoffset, copy_size)\n}\n\n/// The additional prefix is to avoid clashing with the `return` Noir keyword.\npub unconstrained fn avm_return(returndata: [Field]) {\n return_opcode(returndata)\n}\n\n/// This opcode reverts using the exact data given. In general it should only be used to do rethrows, where the revert\n/// data is the same as the original revert data. For normal reverts, use Noir's `assert` which, on top of reverting,\n/// will also add an error selector to the revert data.\npub unconstrained fn revert(revertdata: [Field]) {\n revert_opcode(revertdata)\n}\n\npub unconstrained fn storage_read(storage_slot: Field, contract_address: Field) -> Field {\n storage_read_opcode(storage_slot, contract_address)\n}\n\npub unconstrained fn storage_write(storage_slot: Field, value: Field) {\n storage_write_opcode(storage_slot, value);\n}\n\n#[oracle(aztec_avm_address)]\nunconstrained fn address_opcode() -> AztecAddress {}\n\n#[oracle(aztec_avm_sender)]\nunconstrained fn sender_opcode() -> AztecAddress {}\n\n#[oracle(aztec_avm_transactionFee)]\nunconstrained fn transaction_fee_opcode() -> Field {}\n\n#[oracle(aztec_avm_chainId)]\nunconstrained fn chain_id_opcode() -> Field {}\n\n#[oracle(aztec_avm_version)]\nunconstrained fn version_opcode() -> Field {}\n\n#[oracle(aztec_avm_blockNumber)]\nunconstrained fn block_number_opcode() -> u32 {}\n\n#[oracle(aztec_avm_timestamp)]\nunconstrained fn timestamp_opcode() -> u64 {}\n\n#[oracle(aztec_avm_minFeePerL2Gas)]\nunconstrained fn min_fee_per_l2_gas_opcode() -> u128 {}\n\n#[oracle(aztec_avm_minFeePerDaGas)]\nunconstrained fn min_fee_per_da_gas_opcode() -> u128 {}\n\n#[oracle(aztec_avm_l2GasLeft)]\nunconstrained fn l2_gas_left_opcode() -> u32 {}\n\n#[oracle(aztec_avm_daGasLeft)]\nunconstrained fn da_gas_left_opcode() -> u32 {}\n\n#[oracle(aztec_avm_isStaticCall)]\nunconstrained fn is_static_call_opcode() -> bool {}\n\n#[oracle(aztec_avm_noteHashExists)]\nunconstrained fn note_hash_exists_opcode(note_hash: Field, leaf_index: u64) -> bool {}\n\n#[oracle(aztec_avm_emitNoteHash)]\nunconstrained fn emit_note_hash_opcode(note_hash: Field) {}\n\n#[oracle(aztec_avm_nullifierExists)]\nunconstrained fn nullifier_exists_opcode(siloed_nullifier: Field) -> bool {}\n\n#[oracle(aztec_avm_emitNullifier)]\nunconstrained fn emit_nullifier_opcode(nullifier: Field) {}\n\n#[oracle(aztec_avm_emitPublicLog)]\nunconstrained fn emit_public_log_opcode(message: [Field]) {}\n\n#[oracle(aztec_avm_l1ToL2MsgExists)]\nunconstrained fn l1_to_l2_msg_exists_opcode(msg_hash: Field, msg_leaf_index: u64) -> bool {}\n\n#[oracle(aztec_avm_sendL2ToL1Msg)]\nunconstrained fn send_l2_to_l1_msg_opcode(recipient: EthAddress, content: Field) {}\n\n#[oracle(aztec_avm_calldataCopy)]\nunconstrained fn calldata_copy_opcode<let N: u32>(cdoffset: u32, copy_size: u32) -> [Field; N] {}\n\n#[oracle(aztec_avm_returndataSize)]\nunconstrained fn returndata_size_opcode() -> u32 {}\n\n#[oracle(aztec_avm_returndataCopy)]\nunconstrained fn returndata_copy_opcode(rdoffset: u32, copy_size: u32) -> [Field] {}\n\n#[oracle(aztec_avm_return)]\nunconstrained fn return_opcode(returndata: [Field]) {}\n\n#[oracle(aztec_avm_revert)]\nunconstrained fn revert_opcode(revertdata: [Field]) {}\n\n// While the length parameter might seem unnecessary given that we have N we keep it around because at the AVM bytecode\n// level, we want to support non-comptime-known lengths for such opcodes, even if Noir code will not generally take\n// that route.\n#[oracle(aztec_avm_call)]\nunconstrained fn call_opcode<let N: u32>(\n l2_gas_allocation: u32,\n da_gas_allocation: u32,\n address: AztecAddress,\n length: u32,\n args: [Field; N],\n) {}\n\n// While the length parameter might seem unnecessary given that we have N we keep it around because at the AVM bytecode\n// level, we want to support non-comptime-known lengths for such opcodes, even if Noir code will not generally take\n// that route.\n#[oracle(aztec_avm_staticCall)]\nunconstrained fn call_static_opcode<let N: u32>(\n l2_gas_allocation: u32,\n da_gas_allocation: u32,\n address: AztecAddress,\n length: u32,\n args: [Field; N],\n) {}\n\n#[oracle(aztec_avm_successCopy)]\nunconstrained fn success_copy_opcode() -> bool {}\n\n#[oracle(aztec_avm_storageRead)]\nunconstrained fn storage_read_opcode(storage_slot: Field, contract_address: Field) -> Field {}\n\n#[oracle(aztec_avm_storageWrite)]\nunconstrained fn storage_write_opcode(storage_slot: Field, value: Field) {}\n"
|
|
756
756
|
},
|
|
757
|
-
"
|
|
757
|
+
"191": {
|
|
758
758
|
"function_locations": [
|
|
759
759
|
{
|
|
760
760
|
"name": "call_private_function_oracle",
|
|
@@ -765,10 +765,10 @@
|
|
|
765
765
|
"start": 598
|
|
766
766
|
}
|
|
767
767
|
],
|
|
768
|
-
"path": "/
|
|
768
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/call_private_function.nr",
|
|
769
769
|
"source": "use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress};\n\n#[oracle(aztec_prv_callPrivateFunction)]\nunconstrained fn call_private_function_oracle(\n _contract_address: AztecAddress,\n _function_selector: FunctionSelector,\n _args_hash: Field,\n _start_side_effect_counter: u32,\n _is_static_call: bool,\n) -> (u32, Field) {}\n\npub unconstrained fn call_private_function_internal(\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args_hash: Field,\n start_side_effect_counter: u32,\n is_static_call: bool,\n) -> (u32, Field) {\n call_private_function_oracle(\n contract_address,\n function_selector,\n args_hash,\n start_side_effect_counter,\n is_static_call,\n )\n}\n"
|
|
770
770
|
},
|
|
771
|
-
"
|
|
771
|
+
"194": {
|
|
772
772
|
"function_locations": [
|
|
773
773
|
{
|
|
774
774
|
"name": "set_contract_sync_cache_invalid_oracle",
|
|
@@ -779,10 +779,10 @@
|
|
|
779
779
|
"start": 700
|
|
780
780
|
}
|
|
781
781
|
],
|
|
782
|
-
"path": "/
|
|
782
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/contract_sync.nr",
|
|
783
783
|
"source": "use crate::protocol::address::AztecAddress;\n\n#[oracle(aztec_utl_setContractSyncCacheInvalid)]\nunconstrained fn set_contract_sync_cache_invalid_oracle<let N: u32>(\n contract_address: AztecAddress,\n scopes: BoundedVec<AztecAddress, N>,\n) {}\n\n/// Forces the PXE to re-sync the given contract for a set of scopes on the next query.\n///\n/// Call this after writing data (e.g. offchain messages) that the contract's `sync_state` function needs to discover.\n/// Without invalidation, the sync cache would skip re-running `sync_state` until the next block.\npub unconstrained fn set_contract_sync_cache_invalid<let N: u32>(\n contract_address: AztecAddress,\n scopes: BoundedVec<AztecAddress, N>,\n) {\n set_contract_sync_cache_invalid_oracle(contract_address, scopes);\n}\n"
|
|
784
784
|
},
|
|
785
|
-
"
|
|
785
|
+
"196": {
|
|
786
786
|
"function_locations": [
|
|
787
787
|
{
|
|
788
788
|
"name": "get_utility_context_oracle",
|
|
@@ -793,10 +793,10 @@
|
|
|
793
793
|
"start": 786
|
|
794
794
|
}
|
|
795
795
|
],
|
|
796
|
-
"path": "/
|
|
796
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/execution.nr",
|
|
797
797
|
"source": "use crate::context::UtilityContext;\nuse crate::protocol::{abis::block_header::BlockHeader, address::AztecAddress};\n\n/// Wire shape of [`get_utility_context_oracle`]'s response. [`UtilityContext`] is built from it rather than returned\n/// directly so its fields stay private to its module.\n#[derive(Eq)]\npub(crate) struct UtilityContextData {\n pub(crate) block_header: BlockHeader,\n pub(crate) contract_address: AztecAddress,\n pub(crate) msg_sender: AztecAddress,\n}\n\n#[oracle(aztec_utl_getUtilityContext)]\nunconstrained fn get_utility_context_oracle() -> UtilityContextData {}\n\n/// Returns a utility context built from the global variables of anchor block and the contract address of the function\n/// being executed.\npub unconstrained fn get_utility_context() -> UtilityContext {\n UtilityContext::from(get_utility_context_oracle())\n}\n"
|
|
798
798
|
},
|
|
799
|
-
"
|
|
799
|
+
"197": {
|
|
800
800
|
"function_locations": [
|
|
801
801
|
{
|
|
802
802
|
"name": "store",
|
|
@@ -819,40 +819,44 @@
|
|
|
819
819
|
"start": 1028
|
|
820
820
|
}
|
|
821
821
|
],
|
|
822
|
-
"path": "/
|
|
822
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/execution_cache.nr",
|
|
823
823
|
"source": "/// Stores values represented as slice in execution cache to be later obtained by its hash.\n// TODO(F-498): review naming consistency\npub fn store<let N: u32>(values: [Field; N], hash: Field) {\n // Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to\n // call. When loading the values, however, the caller must check that the values are indeed the preimage.\n unsafe { set_hash_preimage_oracle_wrapper(values, hash) };\n}\n\nunconstrained fn set_hash_preimage_oracle_wrapper<let N: u32>(values: [Field; N], hash: Field) {\n set_hash_preimage_oracle(values, hash);\n}\n\n// TODO(F-498): review naming consistency\npub unconstrained fn load<let N: u32>(hash: Field) -> [Field; N] {\n get_hash_preimage_oracle(hash)\n}\n\n#[oracle(aztec_prv_setHashPreimage)]\nunconstrained fn set_hash_preimage_oracle<let N: u32>(_values: [Field; N], _hash: Field) {}\n\n#[oracle(aztec_prv_getHashPreimage)]\nunconstrained fn get_hash_preimage_oracle<let N: u32>(_hash: Field) -> [Field; N] {}\n"
|
|
824
824
|
},
|
|
825
|
-
"
|
|
825
|
+
"210": {
|
|
826
826
|
"function_locations": [
|
|
827
827
|
{
|
|
828
828
|
"name": "notify_created_nullifier",
|
|
829
|
-
"start":
|
|
829
|
+
"start": 555
|
|
830
830
|
},
|
|
831
831
|
{
|
|
832
832
|
"name": "notify_created_nullifier_oracle",
|
|
833
|
-
"start":
|
|
833
|
+
"start": 874
|
|
834
834
|
},
|
|
835
835
|
{
|
|
836
836
|
"name": "is_nullifier_pending",
|
|
837
|
-
"start":
|
|
837
|
+
"start": 1595
|
|
838
838
|
},
|
|
839
839
|
{
|
|
840
840
|
"name": "is_nullifier_pending_oracle",
|
|
841
|
-
"start":
|
|
841
|
+
"start": 1818
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
"name": "get_nullifier_statuses",
|
|
845
|
+
"start": 2793
|
|
842
846
|
},
|
|
843
847
|
{
|
|
844
848
|
"name": "check_nullifier_exists",
|
|
845
|
-
"start":
|
|
849
|
+
"start": 3394
|
|
846
850
|
},
|
|
847
851
|
{
|
|
848
|
-
"name": "
|
|
849
|
-
"start":
|
|
852
|
+
"name": "get_nullifier_statuses_oracle",
|
|
853
|
+
"start": 3660
|
|
850
854
|
}
|
|
851
855
|
],
|
|
852
|
-
"path": "/
|
|
853
|
-
"source": "//! Nullifier creation, existence checks, etc.\n\nuse crate::protocol::address::aztec_address::AztecAddress;\n\n/// Notifies the simulator that a nullifier has been created, so that its correct status (pending or settled) can be\n/// determined when reading nullifiers in subsequent private function calls. The first non-revertible nullifier emitted\n/// is also used to compute note nonces.\npub fn notify_created_nullifier(inner_nullifier: Field) {\n // Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to\n // call.\n unsafe { notify_created_nullifier_oracle(inner_nullifier) };\n}\n\n#[oracle(aztec_prv_notifyCreatedNullifier)]\nunconstrained fn notify_created_nullifier_oracle(_inner_nullifier: Field) {}\n\n/// Returns `true` if the nullifier has been emitted in the same transaction, i.e. if [`notify_created_nullifier`] has\n/// been\n/// called for this inner nullifier from the contract with the specified address.\n///\n/// Note that despite sharing pending transaction information with the app, this is not a privacy leak: anyone in the\n/// network can always determine in which transaction a inner nullifier was emitted by a given contract by simply\n/// inspecting transaction effects. What _would_ constitute a leak would be to share the list of inner pending\n/// nullifiers, as that would reveal their preimages.\npub unconstrained fn is_nullifier_pending(inner_nullifier: Field, contract_address: AztecAddress) -> bool {\n is_nullifier_pending_oracle(inner_nullifier, contract_address)\n}\n\n#[oracle(aztec_prv_isNullifierPending)]\nunconstrained fn is_nullifier_pending_oracle(_inner_nullifier: Field, _contract_address: AztecAddress) -> bool {}\n\n/// Returns `true` if the nullifier exists
|
|
856
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/nullifiers.nr",
|
|
857
|
+
"source": "//! Nullifier creation, existence checks, etc.\n\nuse crate::ephemeral::EphemeralArray;\nuse crate::oracle::block_reference::BlockReference;\nuse crate::protocol::{address::aztec_address::AztecAddress, traits::Deserialize};\n\n/// Notifies the simulator that a nullifier has been created, so that its correct status (pending or settled) can be\n/// determined when reading nullifiers in subsequent private function calls. The first non-revertible nullifier emitted\n/// is also used to compute note nonces.\npub fn notify_created_nullifier(inner_nullifier: Field) {\n // Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to\n // call.\n unsafe { notify_created_nullifier_oracle(inner_nullifier) };\n}\n\n#[oracle(aztec_prv_notifyCreatedNullifier)]\nunconstrained fn notify_created_nullifier_oracle(_inner_nullifier: Field) {}\n\n/// Returns `true` if the nullifier has been emitted in the same transaction, i.e. if [`notify_created_nullifier`] has\n/// been\n/// called for this inner nullifier from the contract with the specified address.\n///\n/// Note that despite sharing pending transaction information with the app, this is not a privacy leak: anyone in the\n/// network can always determine in which transaction a inner nullifier was emitted by a given contract by simply\n/// inspecting transaction effects. What _would_ constitute a leak would be to share the list of inner pending\n/// nullifiers, as that would reveal their preimages.\npub unconstrained fn is_nullifier_pending(inner_nullifier: Field, contract_address: AztecAddress) -> bool {\n is_nullifier_pending_oracle(inner_nullifier, contract_address)\n}\n\n#[oracle(aztec_prv_isNullifierPending)]\nunconstrained fn is_nullifier_pending_oracle(_inner_nullifier: Field, _contract_address: AztecAddress) -> bool {}\n\n/// The existence status of a nullifier.\n#[derive(Deserialize, Eq)]\npub struct NullifierStatus {\n pub exists: bool,\n\n /// The block the nullifier was included in.\n ///\n /// `None` if the nullifier does not exist, or if it is pending (emitted earlier in the current transaction and not\n /// yet in any block).\n pub origin_block: Option<BlockReference>,\n}\n\n/// Returns the existence status of multiple nullifiers.\n///\n/// Same guarantees as [`check_nullifier_exists`]: an existing nullifier can be constrained by proving its inclusion,\n/// but a non-existent one cannot be relied upon. Proving the `origin_block` however is fairly involved, as it'd require\n/// proving existence of the transaction in which the nullifier was emitted, inclusion of the transaction in the block,\n/// and ancestry of the block in the anchor block.\npub unconstrained fn get_nullifier_statuses(\n inner_nullifiers: EphemeralArray<Field>,\n) -> EphemeralArray<NullifierStatus> {\n get_nullifier_statuses_oracle(inner_nullifiers)\n}\n\n/// Returns `true` if the nullifier exists.\n///\n/// Note that a `true` value can be constrained by proving existence of the nullifier, but a `false` value should not be\n/// relied upon since other transactions may emit this nullifier before the current transaction is included in a block.\n/// While this might seem of little use at first, certain design patterns benefit from this abstraction (see e.g.\n/// `PrivateMutable`).\n// TODO(F-498): review naming consistency\npub unconstrained fn check_nullifier_exists(inner_nullifier: Field) -> bool {\n get_nullifier_statuses(EphemeralArray::from_array([inner_nullifier])).get(0).exists\n}\n\n#[oracle(aztec_utl_getNullifierStatuses)]\nunconstrained fn get_nullifier_statuses_oracle(\n _inner_nullifiers: EphemeralArray<Field>,\n) -> EphemeralArray<NullifierStatus> {}\n"
|
|
854
858
|
},
|
|
855
|
-
"
|
|
859
|
+
"211": {
|
|
856
860
|
"function_locations": [
|
|
857
861
|
{
|
|
858
862
|
"name": "emit_offchain_effect",
|
|
@@ -863,10 +867,10 @@
|
|
|
863
867
|
"start": 488
|
|
864
868
|
}
|
|
865
869
|
],
|
|
866
|
-
"path": "/
|
|
870
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/offchain_effect.nr",
|
|
867
871
|
"source": "use crate::protocol::traits::Serialize;\n\n/// Emits data that will be delivered to PXE unaltered. This data can be interpreted freely by a downstream consumer\n/// (such as a wallet).\n///\n/// # Arguments\n///\n/// * `data` - The data to emit.\npub unconstrained fn emit_offchain_effect<T>(data: T)\nwhere\n T: Serialize,\n{\n emit_offchain_effect_oracle(data.serialize());\n}\n\n#[oracle(aztec_utl_emitOffchainEffect)]\nunconstrained fn emit_offchain_effect_oracle<let N: u32>(data: [Field; N]) {}\n"
|
|
868
872
|
},
|
|
869
|
-
"
|
|
873
|
+
"212": {
|
|
870
874
|
"function_locations": [
|
|
871
875
|
{
|
|
872
876
|
"name": "assert_valid_public_call_data",
|
|
@@ -881,10 +885,10 @@
|
|
|
881
885
|
"start": 835
|
|
882
886
|
}
|
|
883
887
|
],
|
|
884
|
-
"path": "/
|
|
888
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/public_call.nr",
|
|
885
889
|
"source": "/// Validates public calldata by checking that the preimage exists and the cumulative size is within limits.\n///\n/// The check is unconstrained and the only purpose of it is to fail early in case of calldata overflow or a bug in\n/// calldata hashing.\npub(crate) fn assert_valid_public_call_data(calldata_hash: Field) {\n // Safety: This oracle call returns nothing: we only call it for its side effects (validating the calldata).\n // It is therefore always safe to call.\n unsafe {\n assert_valid_public_call_data_oracle_wrapper(calldata_hash)\n }\n}\n\nunconstrained fn assert_valid_public_call_data_oracle_wrapper(calldata_hash: Field) {\n assert_valid_public_call_data_oracle(calldata_hash)\n}\n\n#[oracle(aztec_prv_assertValidPublicCalldata)]\nunconstrained fn assert_valid_public_call_data_oracle(_calldata_hash: Field) {}\n"
|
|
886
890
|
},
|
|
887
|
-
"
|
|
891
|
+
"213": {
|
|
888
892
|
"function_locations": [
|
|
889
893
|
{
|
|
890
894
|
"name": "random",
|
|
@@ -895,10 +899,10 @@
|
|
|
895
899
|
"start": 568
|
|
896
900
|
}
|
|
897
901
|
],
|
|
898
|
-
"path": "/
|
|
902
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/random.nr",
|
|
899
903
|
"source": "/// Returns an unconstrained random value. Note that it is not possible to constrain this value to prove that it is\n/// truly random: we assume that the oracle is cooperating and returning random values. In some applications this\n/// behavior might not be acceptable and other techniques might be more suitable, such as producing pseudo-random\n/// values by hashing values outside of user control (like block hashes) or secrets.\npub unconstrained fn random() -> Field {\n rand_oracle()\n}\n\n#[oracle(aztec_misc_getRandomField)]\nunconstrained fn rand_oracle() -> Field {}\n"
|
|
900
904
|
},
|
|
901
|
-
"
|
|
905
|
+
"217": {
|
|
902
906
|
"function_locations": [
|
|
903
907
|
{
|
|
904
908
|
"name": "get_from_public_storage_oracle",
|
|
@@ -913,10 +917,10 @@
|
|
|
913
917
|
"start": 807
|
|
914
918
|
}
|
|
915
919
|
],
|
|
916
|
-
"path": "/
|
|
920
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/storage.nr",
|
|
917
921
|
"source": "use crate::protocol::{abis::block_header::BlockHeader, address::AztecAddress, traits::{Hash, Packable, ToField}};\n\n#[oracle(aztec_utl_getFromPublicStorage)]\nunconstrained fn get_from_public_storage_oracle<let N: u32>(\n block_hash: Field,\n address: Field,\n storage_slot: Field,\n length: u32,\n) -> [Field; N] {}\n\n// TODO(F-498): review naming consistency\npub unconstrained fn raw_storage_read<let N: u32>(\n block_hash_to_read_from: Field,\n address: AztecAddress,\n storage_slot: Field,\n) -> [Field; N] {\n get_from_public_storage_oracle(block_hash_to_read_from, address.to_field(), storage_slot, N)\n}\n\n// TODO(F-498): review naming consistency\npub unconstrained fn storage_read<T>(header_to_read_from: BlockHeader, address: AztecAddress, storage_slot: Field) -> T\nwhere\n T: Packable,\n{\n let block_hash_to_read_from = header_to_read_from.hash();\n T::unpack(\n raw_storage_read(block_hash_to_read_from, address, storage_slot),\n )\n}\n"
|
|
918
922
|
},
|
|
919
|
-
"
|
|
923
|
+
"219": {
|
|
920
924
|
"function_locations": [
|
|
921
925
|
{
|
|
922
926
|
"name": "notify_revertible_phase_start",
|
|
@@ -939,10 +943,10 @@
|
|
|
939
943
|
"start": 1143
|
|
940
944
|
}
|
|
941
945
|
],
|
|
942
|
-
"path": "/
|
|
946
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/tx_phase.nr",
|
|
943
947
|
"source": "/// Notifies PXE of the side effect counter at which the revertible phase begins.\n///\n/// PXE uses it to classify notes and nullifiers as revertible or non-revertible in its note cache. This information is\n/// then fed to kernels as hints.\npub(crate) fn notify_revertible_phase_start(counter: u32) {\n // Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe to\n // call.\n unsafe { notify_revertible_phase_start_oracle_wrapper(counter) };\n}\n\n/// Returns whether a side effect counter falls in the revertible phase of the transaction.\npub(crate) unconstrained fn is_execution_in_revertible_phase(current_counter: u32) -> bool {\n is_execution_in_revertible_phase_oracle(current_counter)\n}\n\nunconstrained fn notify_revertible_phase_start_oracle_wrapper(counter: u32) {\n notify_revertible_phase_start_oracle(counter);\n}\n\n#[oracle(aztec_prv_notifyRevertiblePhaseStart)]\nunconstrained fn notify_revertible_phase_start_oracle(_counter: u32) {}\n\n#[oracle(aztec_prv_isExecutionInRevertiblePhase)]\nunconstrained fn is_execution_in_revertible_phase_oracle(current_counter: u32) -> bool {}\n"
|
|
944
948
|
},
|
|
945
|
-
"
|
|
949
|
+
"221": {
|
|
946
950
|
"function_locations": [
|
|
947
951
|
{
|
|
948
952
|
"name": "assert_compatible_oracle_version",
|
|
@@ -965,10 +969,10 @@
|
|
|
965
969
|
"start": 2136
|
|
966
970
|
}
|
|
967
971
|
],
|
|
968
|
-
"path": "/
|
|
969
|
-
"source": "/// The oracle version constants are used to check that the oracle interface is in sync between PXE and Aztec.nr.\n/// We version the oracle interface as `major.minor` where:\n/// - `major` = backward-breaking changes (must match exactly between PXE and Aztec.nr)\n/// - `minor` = oracle additions (non-breaking; PXE minor >= contract minor)\n///\n/// The TypeScript counterparts are in `oracle_version.ts`.\n///\n/// @dev Whenever a contract function or Noir test is run, the `aztec_misc_assertCompatibleOracleVersion` oracle is\n/// called. If the major version is incompatible, an error is thrown immediately. The minor version is recorded by\n/// the PXE and used to provide helpful error messages if a contract calls an oracle that doesn't exist. We don't throw\n/// immediately if AZTEC_NR_MINOR > PXE_MINOR because if a contract is updated to use a newer Aztec.nr dependency\n/// without actually using any of the new oracles then there is no reason to throw.\npub global ORACLE_VERSION_MAJOR: Field =
|
|
972
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/oracle/version.nr",
|
|
973
|
+
"source": "/// The oracle version constants are used to check that the oracle interface is in sync between PXE and Aztec.nr.\n/// We version the oracle interface as `major.minor` where:\n/// - `major` = backward-breaking changes (must match exactly between PXE and Aztec.nr)\n/// - `minor` = oracle additions (non-breaking; PXE minor >= contract minor)\n///\n/// The TypeScript counterparts are in `oracle_version.ts`.\n///\n/// @dev Whenever a contract function or Noir test is run, the `aztec_misc_assertCompatibleOracleVersion` oracle is\n/// called. If the major version is incompatible, an error is thrown immediately. The minor version is recorded by\n/// the PXE and used to provide helpful error messages if a contract calls an oracle that doesn't exist. We don't throw\n/// immediately if AZTEC_NR_MINOR > PXE_MINOR because if a contract is updated to use a newer Aztec.nr dependency\n/// without actually using any of the new oracles then there is no reason to throw.\npub global ORACLE_VERSION_MAJOR: Field = 32;\npub global ORACLE_VERSION_MINOR: Field = 0;\n\n/// Asserts that the version of the oracle is compatible with the version expected by the contract.\npub fn assert_compatible_oracle_version() {\n // Safety: This oracle call returns nothing: we only call it to check Aztec.nr and Oracle interface versions are\n // compatible. It is therefore always safe to call.\n unsafe {\n assert_compatible_oracle_version_wrapper();\n }\n}\n\nunconstrained fn assert_compatible_oracle_version_wrapper() {\n assert_compatible_oracle_version_oracle(ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR);\n}\n\n#[oracle(aztec_misc_assertCompatibleOracleVersion)]\nunconstrained fn assert_compatible_oracle_version_oracle(major: Field, minor: Field) {}\n\nmod test {\n use super::{assert_compatible_oracle_version_oracle, ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR};\n\n #[test]\n unconstrained fn compatible_oracle_version() {\n assert_compatible_oracle_version_oracle(ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR);\n }\n\n #[test(should_fail_with = \"Incompatible aztec cli version:\")]\n unconstrained fn incompatible_oracle_version_major() {\n let arbitrary_incorrect_major = 318183437;\n assert_compatible_oracle_version_oracle(arbitrary_incorrect_major, ORACLE_VERSION_MINOR);\n }\n}\n"
|
|
970
974
|
},
|
|
971
|
-
"
|
|
975
|
+
"229": {
|
|
972
976
|
"function_locations": [
|
|
973
977
|
{
|
|
974
978
|
"name": "<impl StateVariable<1, Context> for Map<K, V, Context>>::new",
|
|
@@ -983,10 +987,10 @@
|
|
|
983
987
|
"start": 4999
|
|
984
988
|
}
|
|
985
989
|
],
|
|
986
|
-
"path": "/
|
|
990
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/state_vars/map.nr",
|
|
987
991
|
"source": "use crate::protocol::{storage::map::derive_storage_slot_in_map, traits::ToField};\nuse crate::state_vars::StateVariable;\n\n/// A key-value container for state variables.\n///\n/// A `Map` wraps another state variable type (the 'value') and creates independent instances of it for each key,\n/// resulting in effectively as many state variables as there are key values. This behavior is similar to a Solidity\n/// `mapping (K => V)`.\n///\n/// ## Use Cases\n///\n/// Any scenario in which a fixed number of variables is insufficient to represent contract state requires `Map` e.g.\n/// per-election configuration in a voting contract, per-user state, etc. `Map` also composes naturally into more\n/// complex containers: an array could be implemented as a `Map` with indices as keys.\n///\n/// Note that some private state variables, such as [`PrivateMutable`](crate::state_vars::PrivateMutable) and\n/// [`PrivateSet`](crate::state_vars::PrivateSet) cannot be wrapped in a `Map`. These types implement the\n/// [`OwnedStateVariable`](crate::state_vars::OwnedStateVariable) trait, and as such should instead be wrapped using the\n/// [`Owned`](crate::state_vars::Owned) container, which can be thought of as a specialization of `Map` for private\n/// state 'owned' by a single account.\n///\n/// ## Examples\n///\n/// Since `Map` is also a [`StateVariable`], it is declared in the contract's\n/// [`#[storage]`](crate::macros::storage::storage) struct along with all others:\n///\n/// ```noir\n/// #[storage]\n/// struct Storage<C> {\n/// is_admin: Map<AztecAddress, PublicMutable<bool, C>, C>,\n/// vote_tallies: Map<ElectionId, PublicMutable<u128, C>, C>,\n/// }\n/// ```\n///\n/// ### Multiple `Map`s\n///\n/// There is no limit to how many `Map` containers a contract can have, and `Map`s can themselves wrap other `Map`s,\n/// resulting in nested layouts.\n///\n/// ```noir\n/// #[storage]\n/// struct Storage<C> {\n/// // A nested map where the first key is an address and the second a `Year` type, such that\n/// // self.storage.user_yearly_config.at(user).at(year) results in distinct `UserConfig` variables for each\n/// // `(user, year)` tuple.\n/// user_yearly_config: Map<AztecAddress, Map<Year, UserConfig<C>, C>, C>,\n/// }\n/// ```\n///\n/// ## Requirements\n///\n/// The value type `V` must implement the [`StateVariable`] trait. The key type `K` must implement the [`ToField`] trait\n/// in such a way that the `Field` representation is unique for each key.\n///\n/// For key types that cannot be converted into a `Field`, consider wrapping them in a type that implements `ToField` as\n/// the hash of the key.\n///\n/// ```noir\n/// struct MyKey {\n/// a: Field,\n/// b: Field,\n/// }\n///\n/// struct MyKeyWrapper {\n/// inner: MyKey,\n/// }\n///\n/// impl ToField for MyKeyWrapper {\n/// fn to_field(self) -> Field {\n/// poseidon2_hash([self.inner.a, self.inner.b])\n/// }\n/// }\n///\n/// #[storage]\n/// struct Storage<C> {\n/// a: Map<MyKeyWrapper, PublicMutable<bool, C>, C>,\n/// }\n/// ```\n///\n/// ## Implementation Details\n///\n/// Like all other state variables, `Map` gets assigned a unique storage slot. It uses this value to derive unique\n/// storage slots for each key, resulting in independent state variables. Nothing gets stored at `Map`'s storage slot.\n/// This is equivalent to Solidity's implementation of `mapping`.\n///\n/// Because the storage slot derivation is done using a hash function, it is not possible to compute the key (preimage)\n/// used to obtain a given derived state variable slot.\npub struct Map<K, V, Context> {\n pub context: Context,\n storage_slot: Field,\n}\n\n// Map reserves a single storage slot regardless of what it stores because nothing is stored at said slot: it is only\n// used to derive the storage slots of nested state variables, which is expected to never result in collisions or slots\n// being close to one another due to these being hashes. This mirrors the strategy adopted by Solidity mappings.\nimpl<K, V, Context> StateVariable<1, Context> for Map<K, V, Context> {\n fn new(context: Context, storage_slot: Field) -> Self {\n assert(storage_slot != 0, \"Storage slot 0 not allowed. Storage slots must start from 1.\");\n Map { context, storage_slot }\n }\n\n fn get_storage_slot(self) -> Field {\n self.storage_slot\n }\n}\n\nimpl<K, V, Context> Map<K, V, Context> {\n /// Returns the state variable for a key.\n ///\n /// This derives a unique storage slot for `key` and returns a state variable of type `V` at that slot. It is\n /// equivalent to accessing a `mapping` via the `[]` operator in Solidity (e.g. `balances[user]` would be\n /// `balances.at(user)`).\n ///\n /// ## Example\n ///\n /// ```noir\n /// #[external(\"utility\")]\n /// fn get_election_vote_tallies(election: ElectionId) -> u128 {\n /// self.storage.vote_tallies.at(election).read()\n /// }\n /// ```\n pub fn at<let N: u32>(self, key: K) -> V\n where\n K: ToField,\n V: StateVariable<N, Context>,\n {\n V::new(\n self.context,\n derive_storage_slot_in_map(self.storage_slot, key),\n )\n }\n}\n"
|
|
988
992
|
},
|
|
989
|
-
"
|
|
993
|
+
"242": {
|
|
990
994
|
"function_locations": [
|
|
991
995
|
{
|
|
992
996
|
"name": "<impl StateVariable<M, Context> for PublicMutable<T, Context>>::new",
|
|
@@ -1009,10 +1013,10 @@
|
|
|
1009
1013
|
"start": 8774
|
|
1010
1014
|
}
|
|
1011
1015
|
],
|
|
1012
|
-
"path": "/
|
|
1016
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr",
|
|
1013
1017
|
"source": "use crate::context::{PublicContext, UtilityContext};\nuse crate::protocol::traits::Packable;\nuse crate::state_vars::StateVariable;\n\nmod test;\n\n/// Mutable public values.\n///\n/// This is one of the most basic public state variables. It is equivalent to a non-`immutable` non-`constant` Solidity\n/// state variable.\n///\n/// It represents a public value of type `T` that can be written to repeatedly over the lifetime of the contract,\n/// allowing the last value that was written to be read.\n///\n/// ## Access Patterns\n///\n/// A value stored in a `PublicMutable` can be read and written from public contract functions.\n///\n/// It is not possible to read or write a `PublicMutable` from private contract functions. A common pattern is to have\n/// these functions [enqueue a public self\n/// calls](crate::contract_self::ContractSelfPrivate::enqueue) in which the\n/// required operation is performed.\n///\n/// For an immutable variant which can be read from private functions, see\n/// [`PublicImmutable`](crate::state_vars::PublicImmutable).\n///\n/// For a mutable (with restrictions) variant which can be read from private functions see\n/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable).\n///\n/// ## Privacy\n///\n/// `PublicMutable` provides zero privacy. All write and read operations are public: the entire network can see these\n/// accesses and the data involved.\n///\n/// ## Use Cases\n///\n/// This is suitable for any kind of global state that needs to be accessible by everyone. For example, a token may\n/// have a public total supply, or a voting contract may have public vote tallies.\n///\n/// Note that contracts having public values does not necessarily mean the actions that update these values must\n/// themselves be wholly public. For example, the token could allow for private minting and burning, and casting a vote\n/// could be kept private: these private functions would enqueue a public function that writes to the `PublicMutable`.\n///\n/// Similarly, private functions can enqueue a public call in which the `PublicMutable` is checked to meet some\n/// condition. For example, a private action might be executable only if the vote count has exceeded some threshold, in\n/// which case the private function would enqueue a public function that reads from the `PublicMutable`.\n///\n/// Such patterns preserve the privacy of the account that executed the action, as well as details related to the\n/// private execution itself, but they _do_ reveal that the transaction interacted with the `PublicMutable` value (and\n/// hence that the contract was called), as all accesses to it are public. The\n/// [`only_self`](crate::macros::functions::only_self) attribute is very useful when implementing this.\n///\n/// ## Examples\n///\n/// Declaring a `PublicMutable` in the contract's [`#[storage]`](crate::macros::storage::storage) struct requires\n/// specifying the type `T` that is stored in the variable:\n///\n/// ```noir\n/// #[storage]\n/// struct Storage<C> {\n/// total_supply: PublicMutable<u128, C>,\n/// public_balances: Map<AztecAddress, PublicMutable<u128, C>, C>,\n///\n/// vote_tallies: Map<ElectionId, PublicMutable<u128, C>, C>,\n/// }\n/// ```\n///\n/// ## Requirements\n///\n/// The type `T` stored in the `PublicMutable` must implement the [`Packable`](crate::protocol::traits::Packable)\n/// trait.\n///\n/// ## Implementation Details\n///\n/// Values are packed and stored directly in the public storage tree, with no overhead. A `PublicMutable` therefore\n/// takes up as many storage slots as the packing length of the stored type `T`.\n///\n/// Private reads are not possible because private functions do not have access to the current network state, only the\n/// _past_ state at the anchor block. They _can_ perform historical reads of `PublicMutable` values at past times, but\n/// they have no way to guarantee that the value has not changed since then.\n/// [`PublicImmutable`](crate::state_vars::PublicImmutable) and\n/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable) are examples of public state variables that _can_\n/// be read privately by restricting mutation.\npub struct PublicMutable<T, Context> {\n context: Context,\n storage_slot: Field,\n}\n\nimpl<T, Context, let M: u32> StateVariable<M, Context> for PublicMutable<T, Context>\nwhere\n T: Packable<N = M>,\n{\n fn new(context: Context, storage_slot: Field) -> Self {\n assert(storage_slot != 0, \"Storage slot 0 not allowed. Storage slots must start from 1.\");\n PublicMutable { context, storage_slot }\n }\n\n fn get_storage_slot(self) -> Field {\n self.storage_slot\n }\n}\n\nimpl<T> PublicMutable<T, PublicContext> {\n /// Returns the current value.\n ///\n /// If [`write`](PublicMutable::write) has never been called, then this returns the default empty public storage\n /// value, which is all zeroes - equivalent to `let t = T::unpack(std::mem::zeroed());`.\n ///\n /// It is not possible to detect if a `PublicMutable` has ever been initialized or not other than by testing for\n /// the zero sentinel value. For a more robust solution, store an `Option<T>` in the `PublicMutable`.\n ///\n /// ## Examples\n ///\n /// A public getter that returns the current value:\n /// ```noir\n /// #[external(\"public\")]\n /// fn get_total_supply() -> u128 {\n /// self.storage.total_supply.read()\n /// }\n /// ```\n ///\n /// An [`only_self`](crate::macros::functions::only_self) helper that asserts a condition a private function\n /// requires:\n /// ```noir\n /// #[external(\"private\")]\n /// fn execute_proposal(election_id: ElectionId) {\n /// self.enqueue_self._assert_vote_passed(election_id);\n ///\n /// // execute the proposal - this remains private\n /// }\n ///\n /// #[external(\"public\")]\n /// #[only_self]\n /// fn _assert_vote_passed(election_id: ElectionId) {\n /// assert(self.storage.vote_tallies.at(election_id).read() >= VOTE_PASSED_THRESHOLD);\n /// }\n /// ```\n ///\n /// ## Cost\n ///\n /// The `SLOAD` AVM opcode is invoked a number of times equal to `T`'s packed length.\n pub fn read(self) -> T\n where\n T: Packable,\n {\n self.context.storage_read(self.storage_slot)\n }\n\n /// Stores a new value.\n ///\n /// The old value is overridden and cannot be recovered. The new value can be immediately retrieved by\n /// [`read`](PublicMutable::read).\n ///\n /// ## Examples\n ///\n /// A public setter that updates the current value:\n /// ```noir\n /// #[external(\"public\")]\n /// fn mint_tokens(recipient: AztecAddress, amount: u128) {\n /// let current_recipient_balance = self.storage.public_balances.at(recipient).read();\n /// self.storage.public_balances.at(recipient).write(current_recipient_balance + amount);\n ///\n /// let current_supply = self.storage.total_supply.read();\n /// self.storage.total_supply.write(current_supply + amount);\n /// }\n /// ```\n ///\n /// An [`only_self`](crate::macros::functions::only_self) helper that updates public state triggered by a private\n /// function:\n /// ```noir\n /// #[external(\"private\")]\n /// fn vote_for_proposal(election_id: ElectionId, votes: u128) {\n /// // validate the sender can cast this many votes - this remains private\n ///\n /// self.enqueue_self._tally_vote(election_id, votes);\n /// }\n ///\n /// #[external(\"public\")]\n /// #[only_self]\n /// fn _tally_vote(election_id: ElectionId, votes: u128) {\n /// let current = self.storage.vote_tallies.at(election_id).read();\n /// self.storage.vote_tallies.at(election_id).write(current + votes);\n /// }\n /// ```\n ///\n /// ## Cost\n ///\n /// The `SSTORE` AVM opcode is invoked a number of times equal to `T`'s packed length.\n pub fn write(self, value: T)\n where\n T: Packable,\n {\n self.context.storage_write(self.storage_slot, value);\n }\n}\n\nimpl<T> PublicMutable<T, UtilityContext> {\n /// Returns the value at the anchor block.\n ///\n /// If [`write`](PublicMutable::write) has never been called, then this returns the default empty public storage\n /// value, which is all zeroes - equivalent to `let t = T::unpack(std::mem::zeroed());`.\n ///\n /// It is not possible to detect if a `PublicMutable` has ever been initialized or not other than by testing for\n /// the zero sentinel value. For a more robust solution, store an `Option<T>` in the `PublicMutable`.\n ///\n /// ## Examples\n ///\n /// ```noir\n /// #[external(\"utility\")]\n /// fn get_total_supply() -> u128 {\n /// self.storage.total_supply.read()\n /// }\n /// ```\n pub unconstrained fn read(self) -> T\n where\n T: Packable,\n {\n self.context.storage_read(self.storage_slot)\n }\n}\n"
|
|
1014
1018
|
},
|
|
1015
|
-
"
|
|
1019
|
+
"277": {
|
|
1016
1020
|
"function_locations": [
|
|
1017
1021
|
{
|
|
1018
1022
|
"name": "UnconstrainedArray<T, Oracle>::at",
|
|
@@ -1026,61 +1030,65 @@
|
|
|
1026
1030
|
"name": "UnconstrainedArray<T, Oracle>::empty",
|
|
1027
1031
|
"start": 3834
|
|
1028
1032
|
},
|
|
1033
|
+
{
|
|
1034
|
+
"name": "UnconstrainedArray<T, Oracle>::from_array",
|
|
1035
|
+
"start": 4066
|
|
1036
|
+
},
|
|
1029
1037
|
{
|
|
1030
1038
|
"name": "UnconstrainedArray<T, Oracle>::len",
|
|
1031
|
-
"start":
|
|
1039
|
+
"start": 4295
|
|
1032
1040
|
},
|
|
1033
1041
|
{
|
|
1034
1042
|
"name": "UnconstrainedArray<T, Oracle>::push",
|
|
1035
|
-
"start":
|
|
1043
|
+
"start": 4472
|
|
1036
1044
|
},
|
|
1037
1045
|
{
|
|
1038
1046
|
"name": "UnconstrainedArray<T, Oracle>::pop",
|
|
1039
|
-
"start":
|
|
1047
|
+
"start": 4767
|
|
1040
1048
|
},
|
|
1041
1049
|
{
|
|
1042
1050
|
"name": "UnconstrainedArray<T, Oracle>::get",
|
|
1043
|
-
"start":
|
|
1051
|
+
"start": 5080
|
|
1044
1052
|
},
|
|
1045
1053
|
{
|
|
1046
1054
|
"name": "UnconstrainedArray<T, Oracle>::set",
|
|
1047
|
-
"start":
|
|
1055
|
+
"start": 5404
|
|
1048
1056
|
},
|
|
1049
1057
|
{
|
|
1050
1058
|
"name": "UnconstrainedArray<T, Oracle>::remove",
|
|
1051
|
-
"start":
|
|
1059
|
+
"start": 5718
|
|
1052
1060
|
},
|
|
1053
1061
|
{
|
|
1054
1062
|
"name": "UnconstrainedArray<T, Oracle>::clear",
|
|
1055
|
-
"start":
|
|
1063
|
+
"start": 5896
|
|
1056
1064
|
},
|
|
1057
1065
|
{
|
|
1058
1066
|
"name": "UnconstrainedArray<T, Oracle>::for_each",
|
|
1059
|
-
"start":
|
|
1067
|
+
"start": 6524
|
|
1060
1068
|
},
|
|
1061
1069
|
{
|
|
1062
1070
|
"name": "UnconstrainedArray<T, Oracle>::map",
|
|
1063
|
-
"start":
|
|
1071
|
+
"start": 6878
|
|
1064
1072
|
},
|
|
1065
1073
|
{
|
|
1066
1074
|
"name": "UnconstrainedArray<T, Oracle>::filter",
|
|
1067
|
-
"start":
|
|
1075
|
+
"start": 7298
|
|
1068
1076
|
},
|
|
1069
1077
|
{
|
|
1070
1078
|
"name": "UnconstrainedArray<T, Oracle>::any",
|
|
1071
|
-
"start":
|
|
1079
|
+
"start": 7758
|
|
1072
1080
|
},
|
|
1073
1081
|
{
|
|
1074
1082
|
"name": "UnconstrainedArray<T, Oracle>::all",
|
|
1075
|
-
"start":
|
|
1083
|
+
"start": 8043
|
|
1076
1084
|
},
|
|
1077
1085
|
{
|
|
1078
1086
|
"name": "UnconstrainedArray<T, Oracle>::find",
|
|
1079
|
-
"start":
|
|
1087
|
+
"start": 8318
|
|
1080
1088
|
}
|
|
1081
1089
|
],
|
|
1082
|
-
"path": "/
|
|
1083
|
-
"source": "pub(crate) mod test_helpers;\npub(crate) mod test_suite;\n\nuse crate::oracle::random::random;\nuse crate::protocol::traits::{Deserialize, Serialize};\n\n/// Oracle backend for an [`UnconstrainedArray`]: the set of PXE-side operations that implement its storage.\n///\n/// Each implementor routes these operations to a distinct family of oracles, and the oracle family determines the\n/// array's lifetime and visibility (e.g. [`EphemeralArray`](crate::ephemeral::EphemeralArray) arrays live for one\n/// contract call frame, while [`TransientArray`](crate::transient::TransientArray) arrays are shared across all frames\n/// of the same contract within one top-level PXE call).\npub(crate) trait ArrayOracles {\n /// Returns the number of elements in the array at `slot`.\n unconstrained fn len_oracle(slot: Field) -> u32;\n\n /// Appends a serialized element to the array at `slot` and returns the new length.\n unconstrained fn push_oracle<let N: u32>(slot: Field, values: [Field; N]) -> u32;\n\n /// Removes and returns the last serialized element of the array at `slot`. Implementors must panic if the\n /// array is empty.\n unconstrained fn pop_oracle<let N: u32>(slot: Field) -> [Field; N];\n\n /// Returns the serialized element at the given index of the array at `slot`. Implementors must panic if `index`\n /// is out of bounds.\n unconstrained fn get_oracle<let N: u32>(slot: Field, index: u32) -> [Field; N];\n\n /// Overwrites the serialized element at the given index of the array at `slot`. Implementors must panic if\n /// `index` is out of bounds.\n unconstrained fn set_oracle<let N: u32>(slot: Field, index: u32, values: [Field; N]);\n\n /// Removes the element at the given index of the array at `slot`, shifting subsequent elements backward.\n /// Implementors must panic if `index` is out of bounds.\n unconstrained fn remove_oracle(slot: Field, index: u32);\n\n /// Removes all elements from the array at `slot`.\n unconstrained fn clear_oracle(slot: Field);\n}\n\n/// A dynamically sized array backed by PXE-side in-memory storage via an [`ArrayOracles`] backend.\n///\n/// Arrays are identified by a slot, and each logical operation (push, pop, get, etc.) is a single oracle call. The\n/// `Oracle` backend determines the array's lifetime and visibility; contracts should not use this type directly but\n/// rather one of its aliases: [`EphemeralArray`](crate::ephemeral::EphemeralArray) (scoped to a single contract call\n/// frame) or [`TransientArray`](crate::transient::TransientArray) (shared across all frames of the same contract\n/// within one top-level PXE call).\npub struct UnconstrainedArray<T, Oracle> {\n pub(crate) slot: Field,\n}\n\nimpl<T, Oracle> UnconstrainedArray<T, Oracle>\nwhere\n Oracle: ArrayOracles,\n{\n /// Returns a handle to the array at the given slot, which may already contain data (e.g. populated by an oracle\n /// or by an earlier frame, depending on the backend's visibility).\n pub unconstrained fn at(slot: Field) -> Self {\n Self { slot }\n }\n\n /// Returns an empty array at the given slot, clearing any pre-existing data.\n ///\n /// For backends whose arrays are visible beyond a single call frame (e.g. transient arrays), this wipes data\n /// other frames of the same contract may have written at the slot.\n pub unconstrained fn empty_at(slot: Field) -> Self {\n Self::at(slot).clear()\n }\n\n /// Returns an empty array at a fresh, randomly allocated slot.\n ///\n /// Use this when the caller does not need a specific slot: the random slot is isolated from every other array of\n /// the same backend with overwhelming probability. Prefer [`UnconstrainedArray::empty_at`] when the slot must be a\n /// known value (e.g. one shared with an oracle or another call frame).\n pub unconstrained fn empty() -> Self {\n Self::at(random())\n }\n\n /// Returns the number of elements stored in the array.\n pub unconstrained fn len(self) -> u32 {\n Oracle::len_oracle(self.slot)\n }\n\n /// Stores a value at the end of the array.\n pub unconstrained fn push(self, value: T)\n where\n T: Serialize,\n {\n let serialized = value.serialize();\n let _ = Oracle::push_oracle(self.slot, serialized);\n }\n\n /// Removes and returns the last element. Implementors are required to panic if the array is empty.\n pub unconstrained fn pop(self) -> T\n where\n T: Deserialize,\n {\n let serialized = Oracle::pop_oracle(self.slot);\n Deserialize::deserialize(serialized)\n }\n\n /// Retrieves the value stored at `index`. Implementors are required to panic if the index is out of bounds.\n pub unconstrained fn get(self, index: u32) -> T\n where\n T: Deserialize,\n {\n let serialized = Oracle::get_oracle(self.slot, index);\n Deserialize::deserialize(serialized)\n }\n\n /// Overwrites the value stored at `index`. Implementors are required to panic if the index is out of bounds.\n pub unconstrained fn set(self, index: u32, value: T)\n where\n T: Serialize,\n {\n let serialized = value.serialize();\n Oracle::set_oracle(self.slot, index, serialized);\n }\n\n /// Removes the element at `index`, shifting subsequent elements backward. Implementors are required to panic if\n /// the index is out of bounds.\n pub unconstrained fn remove(self, index: u32) {\n Oracle::remove_oracle(self.slot, index);\n }\n\n /// Removes all elements from the array and returns self for chaining.\n pub unconstrained fn clear(self) -> Self {\n Oracle::clear_oracle(self.slot);\n self\n }\n\n /// Calls a function on each element of the array.\n ///\n /// The function `f` is called once with each array value and its corresponding index, in order (from the first\n /// element to the last).\n ///\n /// Structurally mutating the array from inside the callback (e.g. via `push`, `pop`, `remove` or `clear`) is\n /// **not** supported: it can cause elements to be skipped, visited more than once, or read out of bounds.\n pub unconstrained fn for_each<Env>(self, f: unconstrained fn[Env](u32, T) -> ())\n where\n T: Deserialize,\n {\n let n = self.len();\n for i in 0..n {\n f(i, self.get(i));\n }\n }\n\n /// Applies `f` to every element and collects the results into a fresh array.\n pub unconstrained fn map<U, Env>(self, f: unconstrained fn[Env](T) -> U) -> UnconstrainedArray<U, Oracle>\n where\n T: Deserialize,\n U: Serialize,\n {\n let dest: UnconstrainedArray<U, Oracle> = UnconstrainedArray::empty();\n let n = self.len();\n for i in 0..n {\n dest.push(f(self.get(i)));\n }\n dest\n }\n\n /// Collects every element satisfying the predicate `f` into a fresh array.\n pub unconstrained fn filter<Env>(self, f: unconstrained fn[Env](T) -> bool) -> Self\n where\n T: Serialize + Deserialize,\n {\n let dest: Self = UnconstrainedArray::empty();\n let n = self.len();\n for i in 0..n {\n let value = self.get(i);\n if f(value) {\n dest.push(value);\n }\n }\n dest\n }\n\n /// Returns `true` if at least one element satisfies the predicate `f`.\n pub unconstrained fn any<Env>(self, f: unconstrained fn[Env](T) -> bool) -> bool\n where\n T: Serialize + Deserialize,\n {\n self.filter(f).len() != 0\n }\n\n /// Returns `true` if every element satisfies the predicate `f` (vacuously `true` for an empty array).\n pub unconstrained fn all<Env>(self, f: unconstrained fn[Env](T) -> bool) -> bool\n where\n T: Serialize + Deserialize,\n {\n self.filter(f).len() == self.len()\n }\n\n /// Returns the first element satisfying the predicate `f`, or `Option::none` if none do.\n pub unconstrained fn find<Env>(self, f: unconstrained fn[Env](T) -> bool) -> Option<T>\n where\n T: Deserialize,\n {\n let n = self.len();\n let mut result: Option<T> = Option::none();\n let mut i = 0;\n while (i < n) & result.is_none() {\n let value = self.get(i);\n if f(value) {\n result = Option::some(value);\n }\n i += 1;\n }\n result\n }\n}\n"
|
|
1090
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/unconstrained_array/mod.nr",
|
|
1091
|
+
"source": "pub(crate) mod test_helpers;\npub(crate) mod test_suite;\n\nuse crate::oracle::random::random;\nuse crate::protocol::traits::{Deserialize, Serialize};\n\n/// Oracle backend for an [`UnconstrainedArray`]: the set of PXE-side operations that implement its storage.\n///\n/// Each implementor routes these operations to a distinct family of oracles, and the oracle family determines the\n/// array's lifetime and visibility (e.g. [`EphemeralArray`](crate::ephemeral::EphemeralArray) arrays live for one\n/// contract call frame, while [`TransientArray`](crate::transient::TransientArray) arrays are shared across all frames\n/// of the same contract within one top-level PXE call).\npub(crate) trait ArrayOracles {\n /// Returns the number of elements in the array at `slot`.\n unconstrained fn len_oracle(slot: Field) -> u32;\n\n /// Appends a serialized element to the array at `slot` and returns the new length.\n unconstrained fn push_oracle<let N: u32>(slot: Field, values: [Field; N]) -> u32;\n\n /// Removes and returns the last serialized element of the array at `slot`. Implementors must panic if the\n /// array is empty.\n unconstrained fn pop_oracle<let N: u32>(slot: Field) -> [Field; N];\n\n /// Returns the serialized element at the given index of the array at `slot`. Implementors must panic if `index`\n /// is out of bounds.\n unconstrained fn get_oracle<let N: u32>(slot: Field, index: u32) -> [Field; N];\n\n /// Overwrites the serialized element at the given index of the array at `slot`. Implementors must panic if\n /// `index` is out of bounds.\n unconstrained fn set_oracle<let N: u32>(slot: Field, index: u32, values: [Field; N]);\n\n /// Removes the element at the given index of the array at `slot`, shifting subsequent elements backward.\n /// Implementors must panic if `index` is out of bounds.\n unconstrained fn remove_oracle(slot: Field, index: u32);\n\n /// Removes all elements from the array at `slot`.\n unconstrained fn clear_oracle(slot: Field);\n}\n\n/// A dynamically sized array backed by PXE-side in-memory storage via an [`ArrayOracles`] backend.\n///\n/// Arrays are identified by a slot, and each logical operation (push, pop, get, etc.) is a single oracle call. The\n/// `Oracle` backend determines the array's lifetime and visibility; contracts should not use this type directly but\n/// rather one of its aliases: [`EphemeralArray`](crate::ephemeral::EphemeralArray) (scoped to a single contract call\n/// frame) or [`TransientArray`](crate::transient::TransientArray) (shared across all frames of the same contract\n/// within one top-level PXE call).\npub struct UnconstrainedArray<T, Oracle> {\n pub(crate) slot: Field,\n}\n\nimpl<T, Oracle> UnconstrainedArray<T, Oracle>\nwhere\n Oracle: ArrayOracles,\n{\n /// Returns a handle to the array at the given slot, which may already contain data (e.g. populated by an oracle\n /// or by an earlier frame, depending on the backend's visibility).\n pub unconstrained fn at(slot: Field) -> Self {\n Self { slot }\n }\n\n /// Returns an empty array at the given slot, clearing any pre-existing data.\n ///\n /// For backends whose arrays are visible beyond a single call frame (e.g. transient arrays), this wipes data\n /// other frames of the same contract may have written at the slot.\n pub unconstrained fn empty_at(slot: Field) -> Self {\n Self::at(slot).clear()\n }\n\n /// Returns an empty array at a fresh, randomly allocated slot.\n ///\n /// Use this when the caller does not need a specific slot: the random slot is isolated from every other array of\n /// the same backend with overwhelming probability. Prefer [`UnconstrainedArray::empty_at`] when the slot must be a\n /// known value (e.g. one shared with an oracle or another call frame).\n pub unconstrained fn empty() -> Self {\n Self::at(random())\n }\n\n /// Returns an array at a fresh, randomly allocated slot holding `values` in order.\n pub unconstrained fn from_array<let N: u32>(values: [T; N]) -> Self\n where\n T: Serialize,\n {\n let array = Self::empty();\n for i in 0..N {\n array.push(values[i]);\n }\n array\n }\n\n /// Returns the number of elements stored in the array.\n pub unconstrained fn len(self) -> u32 {\n Oracle::len_oracle(self.slot)\n }\n\n /// Stores a value at the end of the array.\n pub unconstrained fn push(self, value: T)\n where\n T: Serialize,\n {\n let serialized = value.serialize();\n let _ = Oracle::push_oracle(self.slot, serialized);\n }\n\n /// Removes and returns the last element. Implementors are required to panic if the array is empty.\n pub unconstrained fn pop(self) -> T\n where\n T: Deserialize,\n {\n let serialized = Oracle::pop_oracle(self.slot);\n Deserialize::deserialize(serialized)\n }\n\n /// Retrieves the value stored at `index`. Implementors are required to panic if the index is out of bounds.\n pub unconstrained fn get(self, index: u32) -> T\n where\n T: Deserialize,\n {\n let serialized = Oracle::get_oracle(self.slot, index);\n Deserialize::deserialize(serialized)\n }\n\n /// Overwrites the value stored at `index`. Implementors are required to panic if the index is out of bounds.\n pub unconstrained fn set(self, index: u32, value: T)\n where\n T: Serialize,\n {\n let serialized = value.serialize();\n Oracle::set_oracle(self.slot, index, serialized);\n }\n\n /// Removes the element at `index`, shifting subsequent elements backward. Implementors are required to panic if\n /// the index is out of bounds.\n pub unconstrained fn remove(self, index: u32) {\n Oracle::remove_oracle(self.slot, index);\n }\n\n /// Removes all elements from the array and returns self for chaining.\n pub unconstrained fn clear(self) -> Self {\n Oracle::clear_oracle(self.slot);\n self\n }\n\n /// Calls a function on each element of the array.\n ///\n /// The function `f` is called once with each array value and its corresponding index, in order (from the first\n /// element to the last).\n ///\n /// Structurally mutating the array from inside the callback (e.g. via `push`, `pop`, `remove` or `clear`) is\n /// **not** supported: it can cause elements to be skipped, visited more than once, or read out of bounds.\n pub unconstrained fn for_each<Env>(self, f: unconstrained fn[Env](u32, T) -> ())\n where\n T: Deserialize,\n {\n let n = self.len();\n for i in 0..n {\n f(i, self.get(i));\n }\n }\n\n /// Applies `f` to every element and collects the results into a fresh array.\n pub unconstrained fn map<U, Env>(self, f: unconstrained fn[Env](T) -> U) -> UnconstrainedArray<U, Oracle>\n where\n T: Deserialize,\n U: Serialize,\n {\n let dest: UnconstrainedArray<U, Oracle> = UnconstrainedArray::empty();\n let n = self.len();\n for i in 0..n {\n dest.push(f(self.get(i)));\n }\n dest\n }\n\n /// Collects every element satisfying the predicate `f` into a fresh array.\n pub unconstrained fn filter<Env>(self, f: unconstrained fn[Env](T) -> bool) -> Self\n where\n T: Serialize + Deserialize,\n {\n let dest: Self = UnconstrainedArray::empty();\n let n = self.len();\n for i in 0..n {\n let value = self.get(i);\n if f(value) {\n dest.push(value);\n }\n }\n dest\n }\n\n /// Returns `true` if at least one element satisfies the predicate `f`.\n pub unconstrained fn any<Env>(self, f: unconstrained fn[Env](T) -> bool) -> bool\n where\n T: Serialize + Deserialize,\n {\n self.filter(f).len() != 0\n }\n\n /// Returns `true` if every element satisfies the predicate `f` (vacuously `true` for an empty array).\n pub unconstrained fn all<Env>(self, f: unconstrained fn[Env](T) -> bool) -> bool\n where\n T: Serialize + Deserialize,\n {\n self.filter(f).len() == self.len()\n }\n\n /// Returns the first element satisfying the predicate `f`, or `Option::none` if none do.\n pub unconstrained fn find<Env>(self, f: unconstrained fn[Env](T) -> bool) -> Option<T>\n where\n T: Deserialize,\n {\n let n = self.len();\n let mut result: Option<T> = Option::none();\n let mut i = 0;\n while (i < n) & result.is_none() {\n let value = self.get(i);\n if f(value) {\n result = Option::some(value);\n }\n i += 1;\n }\n result\n }\n}\n"
|
|
1084
1092
|
},
|
|
1085
1093
|
"3": {
|
|
1086
1094
|
"function_locations": [
|
|
@@ -1256,7 +1264,7 @@
|
|
|
1256
1264
|
"path": "std/array/mod.nr",
|
|
1257
1265
|
"source": "use crate::cmp::{Eq, Ord};\nuse crate::convert::From;\nuse crate::runtime::is_unconstrained;\n\nmod check_shuffle;\nmod quicksort;\n\nimpl<T, let N: u32> [T; N] {\n /// Returns the length of this array.\n ///\n /// ```noir\n /// fn len(self) -> Field\n /// ```\n ///\n /// example\n ///\n /// ```noir\n /// fn main() {\n /// let array = [42, 42];\n /// assert(array.len() == 2);\n /// }\n /// ```\n #[builtin(array_len)]\n pub fn len(self) -> u32 {}\n\n /// Returns this array as a vector.\n ///\n /// ```noir\n /// let array = [1, 2];\n /// let vector = array.as_vector();\n /// assert_eq(vector, [1, 2].as_vector());\n /// ```\n #[builtin(as_vector)]\n pub fn as_vector(self) -> [T] {}\n\n /// Applies a function to each element of this array, returning a new array containing the mapped elements.\n ///\n /// Example:\n ///\n /// ```rust\n /// let a = [1, 2, 3];\n /// let b = a.map(|a| a * 2);\n /// assert_eq(b, [2, 4, 6]);\n /// ```\n pub fn map<U, Env>(&self, f: fn[Env](T) -> U) -> [U; N] {\n let uninitialized = crate::mem::zeroed();\n let mut ret = [uninitialized; N];\n\n for i in 0..self.len() {\n ret[i] = f(self[i]);\n }\n\n ret\n }\n\n /// Applies a function to each element of this array along with its index,\n /// returning a new array containing the mapped elements.\n ///\n /// Example:\n ///\n /// ```rust\n /// let a = [1, 2, 3];\n /// let b = a.mapi(|i, a| i + a * 2);\n /// assert_eq(b, [2, 5, 8]);\n /// ```\n pub fn mapi<U, Env>(&self, f: fn[Env](u32, T) -> U) -> [U; N] {\n let uninitialized = crate::mem::zeroed();\n let mut ret = [uninitialized; N];\n\n for i in 0..self.len() {\n ret[i] = f(i, self[i]);\n }\n\n ret\n }\n\n /// Applies a function to each element of this array.\n ///\n /// Example:\n ///\n /// ```rust\n /// let a = [1, 2, 3];\n /// let mut b = [0; 3];\n /// let mut i = 0;\n /// a.for_each(|x| {\n /// b[i] = x;\n /// i += 1;\n /// });\n /// assert_eq(a, b);\n /// ```\n pub fn for_each<Env>(&self, f: fn[Env](T) -> ()) {\n for i in 0..self.len() {\n f(self[i]);\n }\n }\n\n /// Applies a function to each element of this array along with its index.\n ///\n /// Example:\n ///\n /// ```rust\n /// let a = [1, 2, 3];\n /// let mut b = [0; 3];\n /// a.for_eachi(|i, x| {\n /// b[i] = x;\n /// });\n /// assert_eq(a, b);\n /// ```\n pub fn for_eachi<Env>(&self, f: fn[Env](u32, T) -> ()) {\n for i in 0..self.len() {\n f(i, self[i]);\n }\n }\n\n /// Applies a function to each element of the array, returning the final accumulated value. The first\n /// parameter is the initial value.\n ///\n /// This is a left fold, so the given function will be applied to the accumulator and first element of\n /// the array, then the second, and so on. For a given call the expected result would be equivalent to:\n ///\n /// ```rust\n /// let a1 = [1];\n /// let a2 = [1, 2];\n /// let a3 = [1, 2, 3];\n ///\n /// let f = |a, b| a - b;\n /// a1.fold(10, f); //=> f(10, 1)\n /// a2.fold(10, f); //=> f(f(10, 1), 2)\n /// a3.fold(10, f); //=> f(f(f(10, 1), 2), 3)\n ///\n /// assert_eq(a3.fold(10, f), 10 - 1 - 2 - 3);\n /// ```\n pub fn fold<U, Env>(&self, mut accumulator: U, f: fn[Env](U, T) -> U) -> U {\n for elem in self {\n accumulator = f(accumulator, elem);\n }\n accumulator\n }\n\n /// Same as fold, but uses the first element as the starting element.\n ///\n /// Requires the input array to be non-empty.\n ///\n /// Example:\n ///\n /// ```noir\n /// fn main() {\n /// let arr = [1, 2, 3, 4];\n /// let reduced = arr.reduce(|a, b| a + b);\n /// assert(reduced == 10);\n /// }\n /// ```\n pub fn reduce<Env>(&self, f: fn[Env](T, T) -> T) -> T {\n let mut accumulator = self[0];\n for i in 1..self.len() {\n accumulator = f(accumulator, self[i]);\n }\n accumulator\n }\n\n /// Returns true if all the elements in this array satisfy the given predicate.\n ///\n /// Example:\n ///\n /// ```noir\n /// fn main() {\n /// let arr = [2, 2, 2, 2, 2];\n /// let all = arr.all(|a| a == 2);\n /// assert(all);\n /// }\n /// ```\n pub fn all<Env>(&self, predicate: fn[Env](T) -> bool) -> bool {\n let mut ret = true;\n for elem in self {\n ret &= predicate(elem);\n }\n ret\n }\n\n /// Returns true if any of the elements in this array satisfy the given predicate.\n ///\n /// Example:\n ///\n /// ```noir\n /// fn main() {\n /// let arr = [2, 2, 2, 2, 5];\n /// let any = arr.any(|a| a == 5);\n /// assert(any);\n /// }\n /// ```\n pub fn any<Env>(&self, predicate: fn[Env](T) -> bool) -> bool {\n let mut ret = false;\n for elem in self {\n ret |= predicate(elem);\n }\n ret\n }\n\n /// Concatenates this array with another array.\n ///\n /// Example:\n ///\n /// ```noir\n /// fn main() {\n /// let arr1 = [1, 2, 3, 4];\n /// let arr2 = [6, 7, 8, 9, 10, 11];\n /// let concatenated_arr = arr1.concat(arr2);\n /// assert(concatenated_arr == [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]);\n /// }\n /// ```\n pub fn concat<let M: u32>(&self, array2: [T; M]) -> [T; N + M] {\n let mut result = [crate::mem::zeroed(); N + M];\n for i in 0..N {\n result[i] = self[i];\n }\n for i in 0..M {\n result[i + N] = array2[i];\n }\n result\n }\n}\n\nimpl<T, let N: u32> [T; N]\nwhere\n T: Ord + Eq,\n{\n /// Returns a new sorted array. The original array remains untouched. Notice that this function will\n /// only work for arrays of fields or integers, not for any arbitrary type. This is because the sorting\n /// logic it uses internally is optimized specifically for these values. If you need a sort function to\n /// sort any type, you should use the [`Self::sort_via`] function.\n ///\n /// Example:\n ///\n /// ```rust\n /// fn main() {\n /// let arr = [42, 32];\n /// let sorted = arr.sort();\n /// assert(sorted == [32, 42]);\n /// }\n /// ```\n pub fn sort(&self) -> Self {\n self.sort_via(|a, b| a <= b)\n }\n}\n\nimpl<T, let N: u32> [T; N]\nwhere\n T: Eq,\n{\n /// Returns a new sorted array by sorting it with a custom comparison function.\n /// The original array remains untouched.\n /// The ordering function must return true if the first argument should be sorted to be before the second argument or is equal to the second argument.\n ///\n /// Using this method with an operator like `<` that does not return `true` for equal values will result in an assertion failure for arrays with equal elements.\n ///\n /// Example:\n ///\n /// ```rust\n /// fn main() {\n /// let arr = [42, 32]\n /// let sorted_ascending = arr.sort_via(|a, b| a <= b);\n /// assert(sorted_ascending == [32, 42]); // verifies\n ///\n /// let sorted_descending = arr.sort_via(|a, b| a >= b);\n /// assert(sorted_descending == [32, 42]); // does not verify\n /// }\n /// ```\n pub fn sort_via<Env>(&self, ordering: fn[Env](T, T) -> bool) -> Self {\n if N != 0 {\n // Safety: `sorted` array is checked to be:\n // a. a permutation of `input`'s elements\n // b. satisfying the predicate `ordering`\n let sorted = unsafe { quicksort::quicksort(self, ordering) };\n\n if !is_unconstrained() {\n for i in 0..N - 1 {\n assert(\n ordering(sorted[i], sorted[i + 1]),\n \"Array has not been sorted correctly according to `ordering`.\",\n );\n }\n check_shuffle::check_shuffle(self, &sorted);\n }\n sorted\n } else {\n *self\n }\n }\n}\n\nimpl<let N: u32> [u8; N] {\n /// Converts a byte array of type `[u8; N]` to a string. Note that this performs no UTF-8 validation -\n /// the given array is interpreted as-is as a string.\n ///\n /// Example:\n ///\n /// ```rust\n /// fn main() {\n /// let hi = [104, 105].as_str_unchecked();\n /// assert_eq(hi, \"hi\");\n /// }\n /// ```\n #[builtin(array_as_str_unchecked)]\n pub fn as_str_unchecked(self) -> str<N> {}\n}\n\nimpl<let N: u32> From<str<N>> for [u8; N] {\n /// Returns an array of the string bytes.\n fn from(s: str<N>) -> Self {\n s.as_bytes()\n }\n}\n\nmod test {\n #[test]\n fn map_empty() {\n assert_eq([].map(|x| x + 1), []);\n }\n\n global arr_with_100_values: [u32; 100] = [\n 42, 123, 87, 93, 48, 80, 50, 5, 104, 84, 70, 47, 119, 66, 71, 121, 3, 29, 42, 118, 2, 54,\n 89, 44, 81, 0, 26, 106, 68, 96, 84, 48, 95, 54, 45, 32, 89, 100, 109, 19, 37, 41, 19, 98,\n 53, 114, 107, 66, 6, 74, 13, 19, 105, 64, 123, 28, 44, 50, 89, 58, 123, 126, 21, 43, 86, 35,\n 21, 62, 82, 0, 108, 120, 72, 72, 62, 80, 12, 71, 70, 86, 116, 73, 38, 15, 127, 81, 30, 8,\n 125, 28, 26, 69, 114, 63, 27, 28, 61, 42, 13, 32,\n ];\n global expected_with_100_values: [u32; 100] = [\n 0, 0, 2, 3, 5, 6, 8, 12, 13, 13, 15, 19, 19, 19, 21, 21, 26, 26, 27, 28, 28, 28, 29, 30, 32,\n 32, 35, 37, 38, 41, 42, 42, 42, 43, 44, 44, 45, 47, 48, 48, 50, 50, 53, 54, 54, 58, 61, 62,\n 62, 63, 64, 66, 66, 68, 69, 70, 70, 71, 71, 72, 72, 73, 74, 80, 80, 81, 81, 82, 84, 84, 86,\n 86, 87, 89, 89, 89, 93, 95, 96, 98, 100, 104, 105, 106, 107, 108, 109, 114, 114, 116, 118,\n 119, 120, 121, 123, 123, 123, 125, 126, 127,\n ];\n fn sort_u32(a: u32, b: u32) -> bool {\n a <= b\n }\n\n #[test]\n fn test_sort() {\n let arr: [u32; 7] = [3, 6, 8, 10, 1, 2, 1];\n\n let sorted = arr.sort();\n\n let expected: [u32; 7] = [1, 1, 2, 3, 6, 8, 10];\n assert(sorted == expected);\n }\n\n #[test]\n fn test_sort_empty() {\n let arr: [u32; 0] = [];\n let sorted = arr.sort();\n assert(sorted == arr);\n }\n\n #[test]\n fn test_sort_via_empty() {\n let arr: [u32; 0] = [];\n let sorted = arr.sort_via(sort_u32);\n assert(sorted == arr);\n }\n\n #[test]\n fn test_sort_100_values() {\n let arr: [u32; 100] = [\n 42, 123, 87, 93, 48, 80, 50, 5, 104, 84, 70, 47, 119, 66, 71, 121, 3, 29, 42, 118, 2,\n 54, 89, 44, 81, 0, 26, 106, 68, 96, 84, 48, 95, 54, 45, 32, 89, 100, 109, 19, 37, 41,\n 19, 98, 53, 114, 107, 66, 6, 74, 13, 19, 105, 64, 123, 28, 44, 50, 89, 58, 123, 126, 21,\n 43, 86, 35, 21, 62, 82, 0, 108, 120, 72, 72, 62, 80, 12, 71, 70, 86, 116, 73, 38, 15,\n 127, 81, 30, 8, 125, 28, 26, 69, 114, 63, 27, 28, 61, 42, 13, 32,\n ];\n\n let sorted = arr.sort();\n\n let expected: [u32; 100] = [\n 0, 0, 2, 3, 5, 6, 8, 12, 13, 13, 15, 19, 19, 19, 21, 21, 26, 26, 27, 28, 28, 28, 29, 30,\n 32, 32, 35, 37, 38, 41, 42, 42, 42, 43, 44, 44, 45, 47, 48, 48, 50, 50, 53, 54, 54, 58,\n 61, 62, 62, 63, 64, 66, 66, 68, 69, 70, 70, 71, 71, 72, 72, 73, 74, 80, 80, 81, 81, 82,\n 84, 84, 86, 86, 87, 89, 89, 89, 93, 95, 96, 98, 100, 104, 105, 106, 107, 108, 109, 114,\n 114, 116, 118, 119, 120, 121, 123, 123, 123, 125, 126, 127,\n ];\n assert(sorted == expected);\n }\n\n #[test]\n fn test_sort_100_values_comptime() {\n let sorted = arr_with_100_values.sort();\n assert(sorted == expected_with_100_values);\n }\n\n #[test]\n fn test_sort_via() {\n let arr: [u32; 7] = [3, 6, 8, 10, 1, 2, 1];\n\n let sorted = arr.sort_via(sort_u32);\n\n let expected: [u32; 7] = [1, 1, 2, 3, 6, 8, 10];\n assert(sorted == expected);\n }\n\n #[test]\n fn test_sort_via_100_values() {\n let arr: [u32; 100] = [\n 42, 123, 87, 93, 48, 80, 50, 5, 104, 84, 70, 47, 119, 66, 71, 121, 3, 29, 42, 118, 2,\n 54, 89, 44, 81, 0, 26, 106, 68, 96, 84, 48, 95, 54, 45, 32, 89, 100, 109, 19, 37, 41,\n 19, 98, 53, 114, 107, 66, 6, 74, 13, 19, 105, 64, 123, 28, 44, 50, 89, 58, 123, 126, 21,\n 43, 86, 35, 21, 62, 82, 0, 108, 120, 72, 72, 62, 80, 12, 71, 70, 86, 116, 73, 38, 15,\n 127, 81, 30, 8, 125, 28, 26, 69, 114, 63, 27, 28, 61, 42, 13, 32,\n ];\n\n let sorted = arr.sort_via(sort_u32);\n\n let expected: [u32; 100] = [\n 0, 0, 2, 3, 5, 6, 8, 12, 13, 13, 15, 19, 19, 19, 21, 21, 26, 26, 27, 28, 28, 28, 29, 30,\n 32, 32, 35, 37, 38, 41, 42, 42, 42, 43, 44, 44, 45, 47, 48, 48, 50, 50, 53, 54, 54, 58,\n 61, 62, 62, 63, 64, 66, 66, 68, 69, 70, 70, 71, 71, 72, 72, 73, 74, 80, 80, 81, 81, 82,\n 84, 84, 86, 86, 87, 89, 89, 89, 93, 95, 96, 98, 100, 104, 105, 106, 107, 108, 109, 114,\n 114, 116, 118, 119, 120, 121, 123, 123, 123, 125, 126, 127,\n ];\n assert(sorted == expected);\n }\n\n #[test]\n fn mapi_empty() {\n assert_eq([].mapi(|i, x| i * x + 1), []);\n }\n\n #[test]\n fn for_each_empty() {\n let empty_array: [Field; 0] = [];\n empty_array.for_each(|_x| assert(false));\n }\n\n #[test]\n fn for_eachi_empty() {\n let empty_array: [Field; 0] = [];\n empty_array.for_eachi(|_i, _x| assert(false));\n }\n\n #[test]\n fn map_example() {\n let a = [1, 2, 3];\n let b = a.map(|a| a * 2);\n assert_eq(b, [2, 4, 6]);\n }\n\n #[test]\n fn mapi_example() {\n let a = [1, 2, 3];\n let b = a.mapi(|i, a| i + a * 2);\n assert_eq(b, [2, 5, 8]);\n }\n\n #[test]\n fn for_each_example() {\n let a = [1, 2, 3];\n let mut b = [0, 0, 0];\n let b_ref = &mut b;\n let mut i = 0;\n let i_ref = &mut i;\n a.for_each(|x| {\n b_ref[*i_ref] = x * 2;\n *i_ref += 1;\n });\n assert_eq(b, [2, 4, 6]);\n assert_eq(i, 3);\n }\n\n #[test]\n fn for_eachi_example() {\n let a = [1, 2, 3];\n let mut b = [0, 0, 0];\n let b_ref = &mut b;\n a.for_eachi(|i, a| { b_ref[i] = i + a * 2; });\n assert_eq(b, [2, 5, 8]);\n }\n\n #[test]\n fn concat() {\n let arr1 = [1, 2, 3, 4];\n let arr2 = [6, 7, 8, 9, 10, 11];\n let concatenated_arr = arr1.concat(arr2);\n assert_eq(concatenated_arr, [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]);\n }\n\n #[test]\n fn concat_zero_length_with_something() {\n let arr1 = [];\n let arr2 = [1];\n let concatenated_arr = arr1.concat(arr2);\n assert_eq(concatenated_arr, [1]);\n }\n\n #[test]\n fn concat_something_with_zero_length() {\n let arr1 = [1];\n let arr2 = [];\n let concatenated_arr = arr1.concat(arr2);\n assert_eq(concatenated_arr, [1]);\n }\n\n #[test]\n fn concat_zero_lengths() {\n let arr1: [Field; 0] = [];\n let arr2: [Field; 0] = [];\n let concatenated_arr = arr1.concat(arr2);\n assert_eq(concatenated_arr, []);\n }\n\n #[test]\n fn test_fold() {\n let array = [1, 2, 3];\n let sum_plus_10 = array.fold(10, |x, y| x + y);\n assert_eq(sum_plus_10, 16);\n }\n\n #[test]\n fn test_reduce() {\n let array = [1, 2, 3];\n let sum = array.reduce(|x, y| x + y);\n assert_eq(sum, 6);\n }\n\n #[test(should_fail_with = \"Index out of bounds\")]\n fn test_reduce_failure_on_empty_array() {\n let array: [Field; 0] = [];\n let sum = array.reduce(|x, y| x + y);\n assert_eq(sum, 6);\n }\n\n #[test]\n fn test_all() {\n let array = [1, 2, 3];\n assert(array.all(|x| x >= 1));\n assert(!array.all(|x| x >= 2));\n }\n\n #[test]\n fn test_any() {\n let array = [1, 2, 3];\n assert(array.any(|x| x >= 3));\n assert(!array.any(|x| x >= 4));\n }\n\n #[test]\n fn test_to_string() {\n let str = [78_u8, 111, 105, 114].as_str_unchecked();\n assert_eq(str, \"Noir\");\n }\n\n #[test]\n fn test_bytes_from_string() {\n let bytes: [u8; 4] = crate::convert::From::from(\"Noir\");\n assert_eq(bytes, [78_u8, 111, 105, 114]);\n }\n}\n"
|
|
1258
1266
|
},
|
|
1259
|
-
"
|
|
1267
|
+
"301": {
|
|
1260
1268
|
"function_locations": [
|
|
1261
1269
|
{
|
|
1262
1270
|
"name": "Poseidon2::hash",
|
|
@@ -1295,10 +1303,10 @@
|
|
|
1295
1303
|
"start": 4549
|
|
1296
1304
|
}
|
|
1297
1305
|
],
|
|
1298
|
-
"path": "/
|
|
1306
|
+
"path": "/home/nventuro/nargo/github.com/noir-lang/poseidon/v0.3.0/src/poseidon2.nr",
|
|
1299
1307
|
"source": "use std::default::Default;\nuse std::hash::Hasher;\n\nglobal RATE: u32 = 3;\n\npub struct Poseidon2 {\n cache: [Field; 3],\n state: [Field; 4],\n cache_size: u32,\n squeeze_mode: bool, // 0 => absorb, 1 => squeeze\n}\n\nimpl Poseidon2 {\n #[no_predicates]\n pub fn hash<let N: u32>(input: [Field; N], message_size: u32) -> Field {\n Poseidon2::hash_internal(input, message_size)\n }\n\n pub(crate) fn new(iv: Field) -> Poseidon2 {\n let mut result =\n Poseidon2 { cache: [0; 3], state: [0; 4], cache_size: 0, squeeze_mode: false };\n result.state[RATE] = iv;\n result\n }\n\n fn perform_duplex(&mut self) {\n // add the cache into sponge state\n self.state[0] += self.cache[0];\n self.state[1] += self.cache[1];\n self.state[2] += self.cache[2];\n self.state = crate::poseidon2_permutation(self.state);\n }\n\n fn absorb(&mut self, input: Field) {\n assert(!self.squeeze_mode);\n if self.cache_size == RATE {\n // If we're absorbing, and the cache is full, apply the sponge permutation to compress the cache\n self.perform_duplex();\n self.cache[0] = input;\n self.cache_size = 1;\n } else {\n // If we're absorbing, and the cache is not full, add the input into the cache\n self.cache[self.cache_size] = input;\n self.cache_size += 1;\n }\n }\n\n fn squeeze(&mut self) -> Field {\n assert(!self.squeeze_mode);\n // If we're in absorb mode, apply sponge permutation to compress the cache.\n self.perform_duplex();\n self.squeeze_mode = true;\n\n // Pop one item off the top of the permutation and return it.\n self.state[0]\n }\n\n fn hash_internal<let N: u32>(input: [Field; N], in_len: u32) -> Field {\n let two_pow_64 = 18446744073709551616;\n let iv: Field = (in_len as Field) * two_pow_64;\n let mut state = [0; 4];\n state[RATE] = iv;\n\n if std::runtime::is_unconstrained() {\n for i in 0..(in_len / RATE) {\n state[0] += input[i * RATE];\n state[1] += input[i * RATE + 1];\n state[2] += input[i * RATE + 2];\n state = crate::poseidon2_permutation(state);\n }\n\n // handle remaining elements after last full RATE-sized chunk\n let num_extra_fields = in_len % RATE;\n if num_extra_fields != 0 {\n let remainder_start = in_len - num_extra_fields;\n state[0] += input[remainder_start];\n if num_extra_fields > 1 {\n state[1] += input[remainder_start + 1];\n }\n }\n } else {\n let mut states: [[Field; 4]; N / RATE + 1] = [[0; 4]; N / RATE + 1];\n states[0] = state;\n\n // process all full RATE-sized chunks, storing state after each permutation\n for chunk_idx in 0..(N / RATE) {\n for i in 0..RATE {\n state[i] += input[chunk_idx * RATE + i];\n }\n state = crate::poseidon2_permutation(state);\n states[chunk_idx + 1] = state;\n }\n\n // get state at the last full block before in_len\n let first_partially_filled_chunk = in_len / RATE;\n state = states[first_partially_filled_chunk];\n\n // handle remaining elements after last full RATE-sized chunk\n let remainder_start = (in_len / RATE) * RATE;\n for j in 0..RATE {\n let idx = remainder_start + j;\n if idx < in_len {\n state[j] += input[idx];\n }\n }\n }\n\n // always run final permutation unless we just completed a full chunk\n // still need to permute once if in_len is 0\n if (in_len == 0) | (in_len % RATE != 0) {\n state = crate::poseidon2_permutation(state);\n };\n\n state[0]\n }\n}\n\npub struct Poseidon2Hasher {\n _state: [Field],\n}\n\nimpl Hasher for Poseidon2Hasher {\n fn finish(self) -> Field {\n let iv: Field = (self._state.len() as Field) * 18446744073709551616; // iv = (self._state.len() << 64)\n let mut sponge = Poseidon2::new(iv);\n for i in 0..self._state.len() {\n sponge.absorb(self._state[i]);\n }\n sponge.squeeze()\n }\n\n fn write(&mut self, input: Field) {\n self._state = self._state.push_back(input);\n }\n}\n\nimpl Default for Poseidon2Hasher {\n fn default() -> Self {\n Poseidon2Hasher { _state: @[] }\n }\n}\n"
|
|
1300
1308
|
},
|
|
1301
|
-
"
|
|
1309
|
+
"312": {
|
|
1302
1310
|
"function_locations": [
|
|
1303
1311
|
{
|
|
1304
1312
|
"name": "BlockHeader::chain_id",
|
|
@@ -1337,10 +1345,10 @@
|
|
|
1337
1345
|
"start": 4104
|
|
1338
1346
|
}
|
|
1339
1347
|
],
|
|
1340
|
-
"path": "/
|
|
1348
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/types/src/abis/block_header.nr",
|
|
1341
1349
|
"source": "use crate::{\n abis::{\n append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables,\n state_reference::StateReference,\n },\n constants::{\n BLOCK_HEADER_LENGTH, DOM_SEP__BLOCK_HEADER_HASH, GENESIS_BLOCK_HEADER_HASH,\n GENESIS_NULLIFIER_TREE_ROOT,\n },\n hash::poseidon2_hash_with_separator,\n traits::{Deserialize, Empty, Hash, Serialize},\n};\nuse std::meta::derive;\n\n// docs:start:block-header\n#[derive(Deserialize, Eq, Serialize)]\npub struct BlockHeader {\n pub last_archive: AppendOnlyTreeSnapshot,\n pub state: StateReference,\n\n // The hash of the sponge blob for this block, which commits to the tx effects added in this block.\n // Note: it may also include tx effects from previous blocks within the same checkpoint.\n // When proving tx effects from this block only, we must refer to the `sponge_blob_hash` in the previous block\n // header to show that the effect was added after the previous block.\n // The previous block header can be validated using a membership proof of the last leaf in `last_archive`.\n pub sponge_blob_hash: Field,\n\n // The root of a merkle tree with one leaf per tx in this block, where each leaf binds a tx hash to the full\n // contents of that tx's effects (see `compute_tx_effects_tree_leaf`). Unlike `sponge_blob_hash`, this commits\n // to the effects of this block only, and it allows proving \"tx X was included in this block and produced effects\n // E\" with a single membership proof rather than a replay of the whole checkpoint's effects.\n // The tree shape is unbalanced, but deterministic: it is a function of the number of txs in the block alone.\n // An empty block has a root of 0.\n pub tx_effects_tree_root: Field,\n\n pub global_variables: GlobalVariables,\n pub total_fees: Field,\n pub total_mana_used: Field,\n}\n// docs:end:block-header\n\nimpl BlockHeader {\n pub fn chain_id(self) -> Field {\n self.global_variables.chain_id\n }\n\n pub fn version(self) -> Field {\n self.global_variables.version\n }\n\n pub fn block_number(self) -> u32 {\n self.global_variables.block_number\n }\n\n pub fn timestamp(self) -> u64 {\n self.global_variables.timestamp\n }\n}\n\nimpl Empty for BlockHeader {\n fn empty() -> Self {\n Self {\n last_archive: AppendOnlyTreeSnapshot::empty(),\n state: StateReference::empty(),\n sponge_blob_hash: 0,\n tx_effects_tree_root: 0,\n global_variables: GlobalVariables::empty(),\n total_fees: 0,\n total_mana_used: 0,\n }\n }\n}\n\nimpl Hash for BlockHeader {\n fn hash(self) -> Field {\n poseidon2_hash_with_separator(self.serialize(), DOM_SEP__BLOCK_HEADER_HASH)\n }\n}\n\n#[test]\nfn serialization_of_empty() {\n let header = BlockHeader::empty();\n // We use the BLOCK_HEADER_LENGTH constant to ensure that there is a match\n // between the derived trait implementation and the constant.\n let serialized: [Field; BLOCK_HEADER_LENGTH] = header.serialize();\n let deserialized = BlockHeader::deserialize(serialized);\n assert(header.eq(deserialized));\n}\n\n#[test]\nfn hash_of_genesis_block_header() {\n let mut header = BlockHeader::empty();\n // The remaining tree roots are those of an empty world state; only the nullifier tree is seeded at genesis.\n header.state.l1_to_l2_message_tree.root =\n 0x0fef6d80d31109ddb56d6b3f607cbc9c0af0bff3ea0d43e8f278983c64c11f7a;\n header.state.partial.note_hash_tree.root =\n 0x2590f2aab19dd791700b4a43d3f52bb88ef2409a3731da8e848663559202e4c6;\n header.state.partial.nullifier_tree.root = GENESIS_NULLIFIER_TREE_ROOT;\n header.state.partial.nullifier_tree.next_available_leaf_index = 128;\n header.state.partial.public_data_tree.root =\n 0x1bef38b621017d3c7416663d0cd81369424560710526a3fbaaec13e356b9d084;\n header.state.partial.public_data_tree.next_available_leaf_index = 128;\n\n let hash = header.hash();\n assert_eq(hash, GENESIS_BLOCK_HEADER_HASH);\n}\n\n#[test]\nfn hash_of_empty_block_header_match_typescript() {\n let header = BlockHeader::empty();\n let hash = header.hash();\n\n // Value from block_header.test.ts \"computes empty hash\" test\n let test_data_empty_hash = 0x270629a7878b72709d3600bf6f84458849d70beb86506bbdfa05ba9fe0e130c9;\n assert_eq(hash, test_data_empty_hash);\n}\n"
|
|
1342
1350
|
},
|
|
1343
|
-
"
|
|
1351
|
+
"389": {
|
|
1344
1352
|
"function_locations": [
|
|
1345
1353
|
{
|
|
1346
1354
|
"name": "sha256_to_field",
|
|
@@ -1471,10 +1479,10 @@
|
|
|
1471
1479
|
"start": 18490
|
|
1472
1480
|
}
|
|
1473
1481
|
],
|
|
1474
|
-
"path": "/
|
|
1482
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/types/src/hash.nr",
|
|
1475
1483
|
"source": "mod poseidon2_chunks;\n\nuse crate::{\n abis::{\n contract_class_function_leaf_preimage::ContractClassFunctionLeafPreimage,\n function_selector::FunctionSelector, nullifier::Nullifier, private_log::PrivateLog,\n transaction::tx_request::TxRequest,\n },\n address::{AztecAddress, EthAddress},\n constants::{\n CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, DOM_SEP__NOTE_HASH_NONCE,\n DOM_SEP__PRIVATE_LOG_FIRST_FIELD, DOM_SEP__SILOED_NOTE_HASH, DOM_SEP__SILOED_NULLIFIER,\n DOM_SEP__UNIQUE_NOTE_HASH, FUNCTION_TREE_HEIGHT, NULL_MSG_SENDER_CONTRACT_ADDRESS,\n TWO_POW_64,\n },\n merkle_tree::root_from_sibling_path,\n messaging::l2_to_l1_message::L2ToL1Message,\n poseidon2::Poseidon2Sponge,\n side_effect::{Counted, Scoped},\n traits::{FromField, Hash, ToField},\n utils::field::{field_from_bytes, field_from_bytes_32_trunc},\n};\n\npub use poseidon2_chunks::poseidon2_absorb_in_chunks_existing_sponge;\nuse poseidon2_chunks::poseidon2_absorb_in_chunks;\nuse std::embedded_curve_ops::EmbeddedCurveScalar;\n\n// TODO: refactor these into their own files: sha256, poseidon2, some protocol-specific hash computations, some merkle computations.\n\npub fn sha256_to_field<let N: u32>(bytes_to_hash: [u8; N]) -> Field {\n let sha256_hashed = sha256::digest(bytes_to_hash);\n let hash_in_a_field = field_from_bytes_32_trunc(sha256_hashed);\n\n hash_in_a_field\n}\n\npub fn private_functions_root_from_siblings(\n selector: FunctionSelector,\n vk_hash: Field,\n function_leaf_index: Field,\n function_leaf_sibling_path: [Field; FUNCTION_TREE_HEIGHT],\n) -> Field {\n let function_leaf_preimage = ContractClassFunctionLeafPreimage { selector, vk_hash };\n let function_leaf = function_leaf_preimage.hash();\n root_from_sibling_path(\n function_leaf,\n function_leaf_index,\n function_leaf_sibling_path,\n )\n}\n\n/// Siloing in the context of Aztec refers to the process of hashing a note hash with a contract address (this way\n/// the note hash is scoped to a specific contract). This is used to prevent intermingling of notes between contracts.\npub fn compute_siloed_note_hash(contract_address: AztecAddress, note_hash: Field) -> Field {\n poseidon2_hash_with_separator(\n [contract_address.to_field(), note_hash],\n DOM_SEP__SILOED_NOTE_HASH,\n )\n}\n\n/// Computes unique, siloed note hashes from siloed note hashes.\n///\n/// The protocol injects uniqueness into every note_hash, so that every single note_hash in the\n/// tree is unique. This prevents faerie gold attacks, where a malicious sender could create\n/// two identical note_hashes for a recipient (meaning only one would be nullifiable in future).\n///\n/// Most privacy protocols will inject the note's leaf_index (its position in the Note Hashes Tree)\n/// into the note, but this requires the creator of a note to wait until their tx is included in\n/// a block to know the note's final note hash (the unique, siloed note hash), because inserting\n/// leaves into trees is the job of a block producer.\n///\n/// We took a different approach so that the creator of a note will know each note's unique, siloed\n/// note hash before broadcasting their tx to the network.\n/// (There was also a historical requirement relating to \"chained transactions\" -- a feature that\n/// Aztec Connect had to enable notes to be spent from distinct txs earlier in the same block,\n/// and hence before an archive block root had been established for that block -- but that feature\n/// was abandoned for the Aztec Network for having too many bad tradeoffs).\n///\n/// (\n/// Edit: it is no longer true that all final note_hashes will be known by the creator of a tx\n/// before they send it to the network. If a tx makes public function calls, then _revertible_\n/// note_hashes that are created in private will not be made unique in private by the Reset circuit,\n/// but will instead be made unique by the AVM, because the `note_index_in_tx` will not be known\n/// until the AVM has executed the public functions of the tx. (See an explanation in\n/// reset_output_composer.nr for why).\n/// For some such txs, the `note_index_in_tx` might still be predictable through simulation, but\n/// for txs whose public functions create a varying number of non-revertible notes (determined at\n/// runtime), the `note_index_in_tx` will not be deterministically derivable before submitting the\n/// tx to the network.\n/// )\n///\n/// We use the `first_nullifier` of a tx as a seed of uniqueness. We have a guarantee that there will\n/// always be at least one nullifier per tx, because the init circuit will create one if one isn't\n/// created naturally by any functions of the tx. (Search \"protocol_nullifier\").\n/// We combine the `first_nullifier` with the note's index (its position within this tx's new\n/// note_hashes array) (`note_index_in_tx`) to get a truly unique value to inject into a note, which\n/// we call a `note_nonce`.\npub fn compute_unique_note_hash(note_nonce: Field, siloed_note_hash: Field) -> Field {\n let inputs = [note_nonce, siloed_note_hash];\n poseidon2_hash_with_separator(inputs, DOM_SEP__UNIQUE_NOTE_HASH)\n}\n\npub fn compute_note_hash_nonce(first_nullifier_in_tx: Field, note_index_in_tx: u32) -> Field {\n // Hashing the first nullifier with note index in tx is guaranteed to be unique (because all nullifiers are also\n // unique).\n poseidon2_hash_with_separator(\n [first_nullifier_in_tx, note_index_in_tx as Field],\n DOM_SEP__NOTE_HASH_NONCE,\n )\n}\n\npub fn compute_note_nonce_and_unique_note_hash(\n siloed_note_hash: Field,\n first_nullifier: Field,\n note_index_in_tx: u32,\n) -> Field {\n let note_nonce = compute_note_hash_nonce(first_nullifier, note_index_in_tx);\n compute_unique_note_hash(note_nonce, siloed_note_hash)\n}\n\npub fn compute_siloed_nullifier(contract_address: AztecAddress, nullifier: Field) -> Field {\n poseidon2_hash_with_separator(\n [contract_address.to_field(), nullifier],\n DOM_SEP__SILOED_NULLIFIER,\n )\n}\n\npub fn create_protocol_nullifier(tx_request: TxRequest) -> Scoped<Counted<Nullifier>> {\n // The protocol nullifier is ascribed a special side-effect counter of 1. No other side-effect\n // can have counter 1 (see `validate_as_first_call` for that assertion). Its value is the\n // transaction's nonce commitment (origin, chain id, version, salt): see\n // `TxRequest::compute_protocol_nullifier_value`. The reset kernel siloes it under\n // `NULL_MSG_SENDER_CONTRACT_ADDRESS` like every other nullifier.\n Nullifier { value: tx_request.compute_protocol_nullifier_value(), note_hash: 0 }.count(1).scope(\n NULL_MSG_SENDER_CONTRACT_ADDRESS,\n )\n}\n\npub fn compute_log_tag(raw_tag: Field, dom_sep: u32) -> Field {\n poseidon2_hash_with_separator([raw_tag], dom_sep)\n}\n\npub fn compute_siloed_private_log_first_field(\n contract_address: AztecAddress,\n field: Field,\n) -> Field {\n poseidon2_hash_with_separator(\n [contract_address.to_field(), field],\n DOM_SEP__PRIVATE_LOG_FIRST_FIELD,\n )\n}\n\npub fn compute_siloed_private_log(contract_address: AztecAddress, log: PrivateLog) -> PrivateLog {\n let mut fields = log.fields;\n fields[0] = compute_siloed_private_log_first_field(contract_address, fields[0]);\n PrivateLog::new(fields, log.length)\n}\n\npub fn compute_contract_class_log_hash(log: [Field; CONTRACT_CLASS_LOG_SIZE_IN_FIELDS]) -> Field {\n poseidon2_hash(log)\n}\n\npub fn compute_app_siloed_secret_key(\n master_secret_key: EmbeddedCurveScalar,\n app_address: AztecAddress,\n key_type_domain_separator: Field,\n) -> Field {\n poseidon2_hash_with_separator(\n [master_secret_key.hi, master_secret_key.lo, app_address.to_field()],\n key_type_domain_separator,\n )\n}\n\npub fn compute_l2_to_l1_message_hash(\n message: Scoped<L2ToL1Message>,\n rollup_version_id: Field,\n chain_id: Field,\n) -> Field {\n let contract_address_bytes: [u8; 32] = message.contract_address.to_field().to_be_bytes();\n let recipient_bytes: [u8; 20] = message.inner.recipient.to_be_bytes();\n let content_bytes: [u8; 32] = message.inner.content.to_be_bytes();\n let rollup_version_id_bytes: [u8; 32] = rollup_version_id.to_be_bytes();\n let chain_id_bytes: [u8; 32] = chain_id.to_be_bytes();\n\n let mut bytes: [u8; 148] = std::mem::zeroed();\n for i in 0..32 {\n bytes[i] = contract_address_bytes[i];\n bytes[i + 32] = rollup_version_id_bytes[i];\n // 64 - 84 are for recipient.\n bytes[i + 84] = chain_id_bytes[i];\n bytes[i + 116] = content_bytes[i];\n }\n\n for i in 0..20 {\n bytes[64 + i] = recipient_bytes[i];\n }\n\n sha256_to_field(bytes)\n}\n\n/// Computes sha256 hash of 2 input fields.\n///\n/// @returns A truncated field (i.e., the first byte is always 0).\npub fn accumulate_sha256(v0: Field, v1: Field) -> Field {\n // Concatenate two fields into 32 x 2 = 64 bytes\n let v0_as_bytes: [u8; 32] = v0.to_be_bytes();\n let v1_as_bytes: [u8; 32] = v1.to_be_bytes();\n let hash_input_flattened = v0_as_bytes.concat(v1_as_bytes);\n\n sha256_to_field(hash_input_flattened)\n}\n\n/// Computes sha256 hash of 2 input fields, prefixed by a domain separator, so that the result cannot collide with an\n/// [`accumulate_sha256`] over the same two fields.\n///\n/// @returns A truncated field (i.e., the first byte is always 0).\npub fn accumulate_sha256_with_separator(separator: u32, v0: Field, v1: Field) -> Field {\n // Concatenate the separator and two fields into 4 + 32 x 2 = 68 bytes\n let separator_as_bytes: [u8; 4] = (separator as Field).to_be_bytes();\n let v0_as_bytes: [u8; 32] = v0.to_be_bytes();\n let v1_as_bytes: [u8; 32] = v1.to_be_bytes();\n let hash_input_flattened = separator_as_bytes.concat(v0_as_bytes).concat(v1_as_bytes);\n\n sha256_to_field(hash_input_flattened)\n}\n\npub fn poseidon2_hash<let N: u32>(inputs: [Field; N]) -> Field {\n poseidon::poseidon2::Poseidon2::hash(inputs, N)\n}\n\n#[no_predicates]\npub fn poseidon2_hash_with_separator<let N: u32, T>(inputs: [Field; N], separator: T) -> Field\nwhere\n T: ToField,\n{\n let inputs_with_separator = [separator.to_field()].concat(inputs);\n poseidon2_hash(inputs_with_separator)\n}\n\n/// Computes a Poseidon2 hash over a dynamic-length subarray of the given input.\n/// Only the first `in_len` fields of `input` are absorbed; any remaining fields are ignored.\n/// The caller is responsible for ensuring that the input is padded with zeros if required.\n#[no_predicates]\npub fn poseidon2_hash_subarray<let N: u32>(input: [Field; N], in_len: u32) -> Field {\n let mut sponge = poseidon2_absorb_in_chunks(input, in_len);\n sponge.squeeze()\n}\n\n/// Computes a Poseidon2 hash with a domain separator over a dynamic-length subarray of the given input.\n/// Only the first `in_len` fields of `input` are absorbed; any remaining fields are ignored.\n/// For `in_len == N` this is equivalent to [`poseidon2_hash_with_separator`].\n#[no_predicates]\npub fn poseidon2_hash_subarray_with_separator<let N: u32, T>(\n input: [Field; N],\n in_len: u32,\n separator: T,\n) -> Field\nwhere\n T: ToField,\n{\n let inputs_with_separator = [separator.to_field()].concat(input);\n poseidon::poseidon2::Poseidon2::hash(inputs_with_separator, in_len + 1)\n}\n\n// This function is unconstrained because it is intended to be used in unconstrained context only as\n// in constrained contexts it would be too inefficient.\npub unconstrained fn poseidon2_hash_with_separator_bounded_vec<let N: u32, T>(\n inputs: BoundedVec<Field, N>,\n separator: T,\n) -> Field\nwhere\n T: ToField,\n{\n let in_len = inputs.len() + 1;\n let iv: Field = (in_len as Field) * TWO_POW_64;\n let mut sponge = Poseidon2Sponge::new(iv);\n sponge.absorb(separator.to_field());\n\n for i in 0..inputs.len() {\n sponge.absorb(inputs.get(i));\n }\n\n sponge.squeeze()\n}\n\n#[no_predicates]\npub fn poseidon2_hash_bytes<let N: u32>(inputs: [u8; N]) -> Field {\n let mut fields = [0; (N + 30) / 31];\n let mut field_index = 0;\n let mut current_field = [0; 31];\n for i in 0..inputs.len() {\n let index = i % 31;\n current_field[index] = inputs[i];\n if index == 30 {\n fields[field_index] = field_from_bytes(current_field, false);\n current_field = [0; 31];\n field_index += 1;\n }\n }\n if field_index != fields.len() {\n fields[field_index] = field_from_bytes(current_field, false);\n }\n poseidon2_hash(fields)\n}\n\n#[test]\nfn subarray_hash_matches_fixed() {\n let values_to_hash = [3; 17];\n let padded = values_to_hash.concat([0; 11]);\n let subarray_hash = poseidon2_hash_subarray(padded, values_to_hash.len());\n\n // Hash the entire values_to_hash.\n let fixed_len_hash = poseidon::poseidon2::Poseidon2::hash(values_to_hash, values_to_hash.len());\n\n assert_eq(subarray_hash, fixed_len_hash);\n}\n\n#[test]\nfn subarray_hash_matches_variable() {\n let values_to_hash = [3; 17];\n let padded = values_to_hash.concat([0; 11]);\n let subarray_hash = poseidon2_hash_subarray(padded, values_to_hash.len());\n\n // Hash up to values_to_hash.len() fields of the padded array.\n let variable_len_hash = poseidon::poseidon2::Poseidon2::hash(padded, values_to_hash.len());\n\n assert_eq(subarray_hash, variable_len_hash);\n}\n\n#[test]\nfn subarray_hash_with_separator_matches_fixed_len_with_separator() {\n let values_to_hash = [3; 17];\n let padded = values_to_hash.concat([0; 11]);\n let separator = 42;\n\n assert_eq(\n poseidon2_hash_subarray_with_separator(padded, values_to_hash.len(), separator),\n poseidon2_hash_with_separator(values_to_hash, separator),\n );\n // Hashing the whole array must differ from hashing a prefix of it, even though the padding is zero.\n assert(\n poseidon2_hash_subarray_with_separator(padded, padded.len(), separator)\n != poseidon2_hash_subarray_with_separator(padded, values_to_hash.len(), separator),\n );\n}\n\n#[test]\nfn smoke_sha256_to_field() {\n let full_buffer = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\n 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,\n 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,\n 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,\n 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,\n 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,\n 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,\n ];\n let result = sha256_to_field(full_buffer);\n\n assert(result == 0x448ebbc9e1a31220a2f3830c18eef61b9bd070e5084b7fa2a359fe729184c7);\n\n // to show correctness of the current ver (truncate one byte) vs old ver (mod full bytes):\n let result_bytes = sha256::digest(full_buffer);\n let truncated_field = crate::utils::field::field_from_bytes_32_trunc(result_bytes);\n assert(truncated_field == result);\n let mod_res = result + (result_bytes[31] as Field);\n assert(mod_res == 0x448ebbc9e1a31220a2f3830c18eef61b9bd070e5084b7fa2a359fe729184e0);\n}\n\n#[test]\nfn unique_siloed_note_hash_matches_typescript() {\n let inner_note_hash = 1;\n let contract_address = AztecAddress::from_field(2);\n let first_nullifier = 3;\n let note_index_in_tx = 4;\n\n let siloed_note_hash = compute_siloed_note_hash(contract_address, inner_note_hash);\n let siloed_note_hash_from_ts =\n 0x1986a4bea3eddb1fff917d629a13e10f63f514f401bdd61838c6b475db949169;\n assert_eq(siloed_note_hash, siloed_note_hash_from_ts);\n\n let nonce: Field = compute_note_hash_nonce(first_nullifier, note_index_in_tx);\n let note_hash_nonce_from_ts =\n 0x28e7799791bf066a57bb51fdd0fbcaf3f0926414314c7db515ea343f44f5d58b;\n assert_eq(nonce, note_hash_nonce_from_ts);\n\n let unique_siloed_note_hash_from_nonce = compute_unique_note_hash(nonce, siloed_note_hash);\n let unique_siloed_note_hash = compute_note_nonce_and_unique_note_hash(\n siloed_note_hash,\n first_nullifier,\n note_index_in_tx,\n );\n assert_eq(unique_siloed_note_hash_from_nonce, unique_siloed_note_hash);\n\n let unique_siloed_note_hash_from_ts =\n 0x29949aef207b715303b24639737c17fbfeb375c1d965ecfa85c7e4f0febb7d16;\n assert_eq(unique_siloed_note_hash, unique_siloed_note_hash_from_ts);\n}\n\n#[test]\nfn siloed_nullifier_matches_typescript() {\n let contract_address = AztecAddress::from_field(123);\n let nullifier = 456;\n\n let res = compute_siloed_nullifier(contract_address, nullifier);\n\n let siloed_nullifier_from_ts =\n 0x169b50336c1f29afdb8a03d955a81e485f5ac7d5f0b8065673d1e407e5877813;\n\n assert_eq(res, siloed_nullifier_from_ts);\n}\n\n#[test]\nfn siloed_private_log_first_field_matches_typescript() {\n let contract_address = AztecAddress::from_field(123);\n let field = 456;\n let res = compute_siloed_private_log_first_field(contract_address, field);\n\n let siloed_private_log_first_field_from_ts =\n 0x29480984f7b9257fded523d50addbcfc8d1d33adcf2db73ef3390a8fd5cdffaa;\n\n assert_eq(res, siloed_private_log_first_field_from_ts);\n}\n\n#[test]\nfn empty_l2_to_l1_message_hash_matches_typescript() {\n // All zeroes\n let res = compute_l2_to_l1_message_hash(\n L2ToL1Message { recipient: EthAddress::zero(), content: 0 }.scope(AztecAddress::from_field(\n 0,\n )),\n 0,\n 0,\n );\n\n let empty_l2_to_l1_msg_hash_from_ts =\n 0x003b18c58c739716e76429634a61375c45b3b5cd470c22ab6d3e14cee23dd992;\n\n assert_eq(res, empty_l2_to_l1_msg_hash_from_ts);\n}\n\n#[test]\nfn l2_to_l1_message_hash_matches_typescript() {\n let message = L2ToL1Message { recipient: EthAddress::from_field(1), content: 2 }.scope(\n AztecAddress::from_field(3),\n );\n let version = 4;\n let chainId = 5;\n\n let hash = compute_l2_to_l1_message_hash(message, version, chainId);\n\n // The following value was generated by `yarn-project/stdlib/src/hash/hash.test.ts`\n let l2_to_l1_message_hash_from_ts =\n 0x0081edf209e087ad31b3fd24263698723d57190bd1d6e9fe056fc0c0a68ee661;\n\n assert_eq(hash, l2_to_l1_message_hash_from_ts);\n}\n\n#[test]\nunconstrained fn poseidon2_hash_with_separator_bounded_vec_matches_non_bounded_vec_version() {\n let inputs = BoundedVec::<Field, 4>::from_array([1, 2, 3]);\n let separator = 42;\n\n // Hash using bounded vec version\n let bounded_result = poseidon2_hash_with_separator_bounded_vec(inputs, separator);\n\n // Hash using regular version\n let regular_result = poseidon2_hash_with_separator([1, 2, 3], separator);\n\n // Results should match\n assert_eq(bounded_result, regular_result);\n}\n"
|
|
1476
1484
|
},
|
|
1477
|
-
"
|
|
1485
|
+
"421": {
|
|
1478
1486
|
"function_locations": [
|
|
1479
1487
|
{
|
|
1480
1488
|
"name": "derive_storage_slot_in_map",
|
|
@@ -1485,10 +1493,10 @@
|
|
|
1485
1493
|
"start": 587
|
|
1486
1494
|
}
|
|
1487
1495
|
],
|
|
1488
|
-
"path": "/
|
|
1496
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/types/src/storage/map.nr",
|
|
1489
1497
|
"source": "use crate::{\n constants::DOM_SEP__PUBLIC_STORAGE_MAP_SLOT, hash::poseidon2_hash_with_separator,\n traits::ToField,\n};\n\n// TODO: Move this to src/public_data/storage/map.nr\npub fn derive_storage_slot_in_map<K>(storage_slot: Field, key: K) -> Field\nwhere\n K: ToField,\n{\n poseidon2_hash_with_separator(\n [storage_slot, key.to_field()],\n DOM_SEP__PUBLIC_STORAGE_MAP_SLOT,\n )\n}\n\nmod test {\n use crate::{address::AztecAddress, storage::map::derive_storage_slot_in_map, traits::FromField};\n\n #[test]\n fn test_derive_storage_slot_in_map_matches_typescript() {\n let map_slot = 0x132258fb6962c4387ba659d9556521102d227549a386d39f0b22d1890d59c2b5;\n let key = AztecAddress::from_field(\n 0x302dbc2f9b50a73283d5fb2f35bc01eae8935615817a0b4219a057b2ba8a5a3f,\n );\n\n let slot = derive_storage_slot_in_map(map_slot, key);\n\n // The following value was generated by `map_slot.test.ts`\n let slot_from_typescript =\n 0x2d225f361108379adc2da91378b9702675c5546b57e78bafc1e74ec7fec55967;\n\n assert_eq(slot, slot_from_typescript);\n }\n}\n"
|
|
1490
1498
|
},
|
|
1491
|
-
"
|
|
1499
|
+
"429": {
|
|
1492
1500
|
"function_locations": [
|
|
1493
1501
|
{
|
|
1494
1502
|
"name": "<impl Packable for bool>::pack",
|
|
@@ -1635,7 +1643,7 @@
|
|
|
1635
1643
|
"start": 6145
|
|
1636
1644
|
}
|
|
1637
1645
|
],
|
|
1638
|
-
"path": "/
|
|
1646
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/types/src/type_packing.nr",
|
|
1639
1647
|
"source": "use crate::traits::{Deserialize, Packable, Serialize};\n\nglobal BOOL_PACKED_LEN: u32 = 1;\nglobal U8_PACKED_LEN: u32 = 1;\nglobal U16_PACKED_LEN: u32 = 1;\nglobal U32_PACKED_LEN: u32 = 1;\nglobal U64_PACKED_LEN: u32 = 1;\nglobal U128_PACKED_LEN: u32 = 1;\nglobal FIELD_PACKED_LEN: u32 = 1;\nglobal I8_PACKED_LEN: u32 = 1;\nglobal I16_PACKED_LEN: u32 = 1;\nglobal I32_PACKED_LEN: u32 = 1;\nglobal I64_PACKED_LEN: u32 = 1;\nglobal POINT_PACKED_LEN: u32 = 2;\n\nimpl Packable for bool {\n let N: u32 = BOOL_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n /// Unpacks a `bool`, constraining the field to be a canonical boolean. A field outside `{0, 1}` is\n /// rejected (rather than silently reinterpreted), so an arbitrary-origin field cannot be misread.\n /// `pack` always emits `0` or `1`, so round-tripping is unaffected.\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> bool {\n let v = fields[0];\n // v * v == v holds iff v is 0 or 1: a single degree-2 constraint that both validates the field\n // is a canonical bool and avoids the byte-range decomposition that a cast to u8 would require.\n assert(v * v == v, \"Packable::unpack: bool field must be 0 or 1\");\n v == 1\n }\n}\n\nimpl Packable for u8 {\n let N: u32 = U8_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u8\n }\n}\n\nimpl Packable for u16 {\n let N: u32 = U16_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u16\n }\n}\n\nimpl Packable for u32 {\n let N: u32 = U32_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u32\n }\n}\n\nimpl Packable for u64 {\n let N: u32 = U64_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u64\n }\n}\n\nimpl Packable for u128 {\n let N: u32 = U128_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u128\n }\n}\n\nimpl Packable for Field {\n let N: u32 = FIELD_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0]\n }\n}\n\nimpl Packable for i8 {\n let N: u32 = I8_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as u8 as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u8 as i8\n }\n}\n\nimpl Packable for i16 {\n let N: u32 = I16_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as u16 as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u16 as i16\n }\n}\n\nimpl Packable for i32 {\n let N: u32 = I32_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as u32 as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u32 as i32\n }\n}\n\nimpl Packable for i64 {\n let N: u32 = I64_PACKED_LEN;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n [self as u64 as Field]\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n fields[0] as u64 as i64\n }\n}\n\nimpl Packable for super::point::EmbeddedCurvePoint {\n let N: u32 = POINT_PACKED_LEN;\n fn pack(self) -> [Field; Self::N] {\n self.serialize()\n }\n\n fn unpack(packed: [Field; Self::N]) -> Self {\n Self::deserialize(packed)\n }\n}\n\nimpl<T, let M: u32> Packable for [T; M]\nwhere\n T: Packable,\n{\n let N: u32 = M * <T as Packable>::N;\n\n #[inline_always]\n fn pack(self) -> [Field; Self::N] {\n let mut result: [Field; Self::N] = std::mem::zeroed();\n for i in 0..M {\n let serialized = self[i].pack();\n for j in 0..<T as Packable>::N {\n result[i * <T as Packable>::N + j] = serialized[j];\n }\n }\n result\n }\n\n #[inline_always]\n fn unpack(fields: [Field; Self::N]) -> Self {\n let mut reader = crate::utils::reader::Reader::new(fields);\n let result: [T; M] = std::mem::zeroed();\n reader.read_struct_array::<T, <T as Packable>::N, M>(Packable::unpack, result)\n }\n}\n\n#[test]\nfn test_u16_packing() {\n let a: u16 = 10;\n assert_eq(a, u16::unpack(a.pack()));\n}\n\n#[test]\nfn test_i8_packing() {\n let a: i8 = -10;\n assert_eq(a, i8::unpack(a.pack()));\n}\n\n#[test]\nfn test_i16_packing() {\n let a: i16 = -10;\n assert_eq(a, i16::unpack(a.pack()));\n}\n\n#[test]\nfn test_i32_packing() {\n let a: i32 = -10;\n assert_eq(a, i32::unpack(a.pack()));\n}\n\n#[test]\nfn test_i64_packing() {\n let a: i64 = -10;\n assert_eq(a, i64::unpack(a.pack()));\n}\n\n#[test]\nfn test_bool_unpack_accepts_canonical_values() {\n assert_eq(bool::unpack([0]), false);\n assert_eq(bool::unpack([1]), true);\n}\n\n#[test(should_fail_with = \"bool field must be 0 or 1\")]\nfn test_bool_unpack_rejects_even_non_bool() {\n // 2 has LSB 0, so the previous LSB-based unpack silently returned false; now it is rejected.\n let _ = bool::unpack([2]);\n}\n\n#[test(should_fail_with = \"bool field must be 0 or 1\")]\nfn test_bool_unpack_rejects_odd_non_bool() {\n // 3 has LSB 1, so the previous LSB-based unpack silently returned true; now it is rejected.\n let _ = bool::unpack([3]);\n}\n\n#[test(should_fail_with = \"bool field must be 0 or 1\")]\nfn test_bool_unpack_rejects_large_field() {\n let _ = bool::unpack([1000000]);\n}\n\n#[test]\nfn test_bool_pack_unpack_roundtrip() {\n // `pack` always emits 0 or 1, so it round-trips through the canonical-bool check in `unpack`.\n assert_eq(true.pack(), [1]);\n assert_eq(false.pack(), [0]);\n assert_eq(bool::unpack(true.pack()), true);\n assert_eq(bool::unpack(false.pack()), false);\n}\n"
|
|
1640
1648
|
},
|
|
1641
1649
|
"44": {
|
|
@@ -1816,7 +1824,7 @@
|
|
|
1816
1824
|
"path": "std/option.nr",
|
|
1817
1825
|
"source": "use crate::cmp::{Eq, Ord, Ordering};\nuse crate::default::Default;\nuse crate::hash::{Hash, Hasher};\n\n/// Represents a value of type T or its absence.\n/// Use `Option::some(value)` to construct a value or `Option::none()` to record the absence of one.\npub struct Option<T> {\n _is_some: bool,\n _value: T,\n}\n\nimpl<T> Option<T> {\n /// Constructs a None value\n pub fn none() -> Self {\n Self { _is_some: false, _value: crate::mem::zeroed() }\n }\n\n /// Constructs a Some wrapper around the given value\n pub fn some(_value: T) -> Self {\n Self { _is_some: true, _value }\n }\n\n /// True if this Option is None\n pub fn is_none(&self) -> bool {\n !self._is_some\n }\n\n /// True if this Option is Some\n pub fn is_some(&self) -> bool {\n self._is_some\n }\n\n /// Asserts `self.is_some()` and returns the wrapped value.\n pub fn unwrap(self) -> T {\n assert(self._is_some);\n self._value\n }\n\n /// Returns the inner value without asserting `self.is_some()`\n /// Note that if `self` is `None`, there is no guarantee what value will be returned,\n /// only that it will be of type `T`.\n pub fn unwrap_unchecked(self) -> T {\n self._value\n }\n\n /// Returns the wrapped value if `self.is_some()`. Otherwise, returns the given default value.\n pub fn unwrap_or(self, default: T) -> T {\n if self._is_some {\n self._value\n } else {\n default\n }\n }\n\n /// Returns the wrapped value if `self.is_some()`. Otherwise, calls the given function to return\n /// a default value.\n pub fn unwrap_or_else<Env>(self, default: fn[Env]() -> T) -> T {\n if self._is_some {\n self._value\n } else {\n default()\n }\n }\n\n /// Asserts `self.is_some()` with a provided custom message and returns the contained `Some` value\n pub fn expect<let N: u32, MessageTypes>(self, message: fmtstr<N, MessageTypes>) -> T {\n assert(self.is_some(), message);\n self._value\n }\n\n /// If self is `Some(x)`, this returns `Some(f(x))`. Otherwise, this returns `None`.\n pub fn map<U, Env>(self, f: fn[Env](T) -> U) -> Option<U> {\n if self._is_some {\n Option::some(f(self._value))\n } else {\n Option::none()\n }\n }\n\n /// If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns the given default value.\n pub fn map_or<U, Env>(self, default: U, f: fn[Env](T) -> U) -> U {\n if self._is_some {\n f(self._value)\n } else {\n default\n }\n }\n\n /// If self is `Some(x)`, this returns `f(x)`. Otherwise, this returns `default()`.\n pub fn map_or_else<U, Env1, Env2>(self, default: fn[Env1]() -> U, f: fn[Env2](T) -> U) -> U {\n if self._is_some {\n f(self._value)\n } else {\n default()\n }\n }\n\n /// Returns None if self is None. Otherwise, this returns `other`.\n pub fn and(self, other: Self) -> Self {\n if self.is_none() {\n Option::none()\n } else {\n other\n }\n }\n\n /// If self is None, this returns None. Otherwise, this calls the given function\n /// with the Some value contained within self, and returns the result of that call.\n ///\n /// In some languages this function is called `flat_map` or `bind`.\n pub fn and_then<U, Env>(self, f: fn[Env](T) -> Option<U>) -> Option<U> {\n if self._is_some {\n f(self._value)\n } else {\n Option::none()\n }\n }\n\n /// If self is Some, return self. Otherwise, return `other`.\n pub fn or(self, other: Self) -> Self {\n if self._is_some {\n self\n } else {\n other\n }\n }\n\n /// If self is Some, return self. Otherwise, return `default()`.\n pub fn or_else<Env>(self, default: fn[Env]() -> Self) -> Self {\n if self._is_some {\n self\n } else {\n default()\n }\n }\n\n // If only one of the two Options is Some, return that option.\n // Otherwise, if both options are Some or both are None, None is returned.\n pub fn xor(self, other: Self) -> Self {\n if self._is_some {\n if other._is_some {\n Option::none()\n } else {\n self\n }\n } else if other._is_some {\n other\n } else {\n Option::none()\n }\n }\n\n /// Returns `Some(x)` if self is `Some(x)` and `predicate(x)` is true.\n /// Otherwise, this returns `None`\n pub fn filter<Env>(self, predicate: fn[Env](T) -> bool) -> Self {\n if self._is_some {\n if predicate(self._value) {\n self\n } else {\n Option::none()\n }\n } else {\n Option::none()\n }\n }\n\n /// Flattens an Option<Option<T>> into a Option<T>.\n /// This returns None if the outer Option is None. Otherwise, this returns the inner Option.\n pub fn flatten(option: Option<Option<T>>) -> Option<T> {\n if option._is_some {\n option._value\n } else {\n Option::none()\n }\n }\n}\n\nimpl<T> Default for Option<T> {\n fn default() -> Self {\n Option::none()\n }\n}\n\nimpl<T> Eq for Option<T>\nwhere\n T: Eq,\n{\n fn eq(self, other: Self) -> bool {\n if self._is_some == other._is_some {\n if self._is_some {\n self._value == other._value\n } else {\n true\n }\n } else {\n false\n }\n }\n}\n\nimpl<T> Hash for Option<T>\nwhere\n T: Hash,\n{\n fn hash<H>(self, state: &mut H)\n where\n H: Hasher,\n {\n self._is_some.hash(state);\n if self._is_some {\n self._value.hash(state);\n }\n }\n}\n\n// For this impl we're declaring Option::none < Option::some\nimpl<T> Ord for Option<T>\nwhere\n T: Ord,\n{\n fn cmp(self, other: Self) -> Ordering {\n if self._is_some {\n if other._is_some {\n self._value.cmp(other._value)\n } else {\n Ordering::greater()\n }\n } else if other._is_some {\n Ordering::less()\n } else {\n Ordering::equal()\n }\n }\n}\n\nmod tests {\n use crate::cmp::Ord;\n use crate::cmp::Ordering;\n use crate::default::Default as _;\n use super::Option;\n\n #[test]\n fn some_and_none() {\n assert(Option::<u8>::none().is_none());\n assert(!Option::<u8>::none().is_some());\n assert(Option::some(1).is_some());\n assert(!Option::some(1).is_none());\n }\n\n #[test]\n fn unwrap_succeeds() {\n assert_eq(Option::some(1).unwrap(), 1);\n }\n\n #[test(should_fail)]\n fn unwrap_fails() {\n let _ = Option::<u8>::none().unwrap();\n }\n\n #[test]\n fn unwrap_or() {\n assert_eq(Option::some(1).unwrap_or(2), 1);\n assert_eq(Option::none().unwrap_or(2), 2);\n }\n\n #[test]\n fn unwrap_or_else() {\n assert_eq(Option::some(1).unwrap_or_else(|| 2), 1);\n assert_eq(Option::none().unwrap_or_else(|| 2), 2);\n }\n\n #[test]\n fn expect_succeeds() {\n assert_eq(Option::some(1).expect(f\"Should be there\"), 1);\n }\n\n #[test(should_fail_with = \"Should be there\")]\n fn expect_fails() {\n let _ = Option::<u8>::none().expect(f\"Should be there\");\n }\n\n #[test]\n fn map() {\n assert(Option::<u8>::none().map(|x| x + 1).is_none());\n assert_eq(Option::some(1).map(|x| x + 1), Option::some(2));\n }\n\n #[test]\n fn map_or() {\n assert_eq(Option::<u8>::none().map_or(0, |x| x + 1), 0);\n assert_eq(Option::some(1).map_or(0, |x| x + 1), 2);\n }\n\n #[test]\n fn map_or_else() {\n assert_eq(Option::<u8>::none().map_or_else(|| 0, |x| x + 1), 0);\n assert_eq(Option::some(1).map_or_else(|| 0, |x| x + 1), 2);\n }\n\n #[test]\n fn and() {\n assert_eq(Option::<u8>::none().and(Option::none()), Option::none());\n assert_eq(Option::<u8>::none().and(Option::some(1)), Option::none());\n assert_eq(Option::some(1).and(Option::some(2)), Option::some(2));\n assert_eq(Option::some(1).and(Option::none()), Option::none());\n }\n\n #[test]\n fn and_then() {\n assert_eq(Option::<u8>::none().and_then(|_| Option::<u8>::none()), Option::none());\n assert_eq(Option::<u8>::none().and_then(|_| Option::some(1)), Option::none());\n assert_eq(Option::some(1).and_then(|x| Option::some(x + 1)), Option::some(2));\n assert_eq(Option::some(1).and_then(|_| Option::<u8>::none()), Option::none());\n }\n\n #[test]\n fn or() {\n assert_eq(Option::<u8>::none().or(Option::none()), Option::none());\n assert_eq(Option::<u8>::none().or(Option::some(1)), Option::some(1));\n assert_eq(Option::some(1).or(Option::some(2)), Option::some(1));\n assert_eq(Option::some(1).or(Option::none()), Option::some(1));\n }\n\n #[test]\n fn or_else() {\n assert_eq(Option::<u8>::none().or_else(|| Option::none()), Option::none());\n assert_eq(Option::<u8>::none().or_else(|| Option::some(1)), Option::some(1));\n assert_eq(Option::some(1).or_else(|| Option::some(2)), Option::some(1));\n assert_eq(Option::some(1).or_else(|| Option::none()), Option::some(1));\n }\n\n #[test]\n fn xor() {\n assert_eq(Option::<u8>::none().xor(Option::none()), Option::none());\n assert_eq(Option::<u8>::none().xor(Option::some(1)), Option::some(1));\n assert_eq(Option::some(1).xor(Option::some(2)), Option::none());\n assert_eq(Option::some(1).xor(Option::none()), Option::some(1));\n }\n\n #[test]\n fn filter() {\n assert_eq(Option::<u8>::none().filter(|_| true), Option::none());\n assert_eq(Option::some(1).filter(|x| x == 1), Option::some(1));\n assert_eq(Option::some(1).filter(|x| x == 2), Option::none());\n assert_eq(Option::some(1).filter(|x| x == 2), Option::none());\n }\n\n #[test]\n fn flatten() {\n assert_eq(Option::<Option<u8>>::none().flatten(), Option::none());\n assert_eq(Option::some(Option::<u8>::none()).flatten(), Option::none());\n assert_eq(Option::some(Option::some(1)).flatten(), Option::some(1));\n }\n\n #[test]\n fn default() {\n assert_eq(Option::<u8>::default(), Option::none());\n }\n\n #[test]\n fn eq() {\n assert(Option::<u8>::none() == Option::none());\n assert(Option::<u8>::some(1) != Option::none());\n assert(Option::<u8>::none() != Option::some(1));\n assert(Option::<u8>::some(1) == Option::some(1));\n assert(Option::<u8>::some(1) != Option::some(2));\n }\n\n #[test]\n fn cmp() {\n let none = Option::<u8>::none();\n let one = Option::<u8>::some(1);\n let two = Option::<u8>::some(2);\n assert_eq(none.cmp(none), Ordering::equal());\n assert_eq(none.cmp(one), Ordering::less());\n assert_eq(one.cmp(none), Ordering::greater());\n assert_eq(one.cmp(one), Ordering::equal());\n assert_eq(one.cmp(two), Ordering::less());\n assert_eq(two.cmp(one), Ordering::greater());\n }\n}\n"
|
|
1818
1826
|
},
|
|
1819
|
-
"
|
|
1827
|
+
"441": {
|
|
1820
1828
|
"function_locations": [
|
|
1821
1829
|
{
|
|
1822
1830
|
"name": "Reader<N>::new",
|
|
@@ -1863,10 +1871,10 @@
|
|
|
1863
1871
|
"start": 1426
|
|
1864
1872
|
}
|
|
1865
1873
|
],
|
|
1866
|
-
"path": "/
|
|
1874
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/serde/src/reader.nr",
|
|
1867
1875
|
"source": "pub struct Reader<let N: u32> {\n data: [Field; N],\n offset: u32,\n}\n\nimpl<let N: u32> Reader<N> {\n pub fn new(data: [Field; N]) -> Self {\n Self { data, offset: 0 }\n }\n\n pub fn read(&mut self) -> Field {\n let result = self.data[self.offset];\n self.offset += 1;\n result\n }\n\n pub fn read_u32(&mut self) -> u32 {\n self.read() as u32\n }\n\n pub fn read_u64(&mut self) -> u64 {\n self.read() as u64\n }\n\n pub fn read_bool(&mut self) -> bool {\n self.read() != 0\n }\n\n pub fn read_array<let K: u32>(&mut self) -> [Field; K] {\n let mut result = [0; K];\n for i in 0..K {\n result[i] = self.data[self.offset + i];\n }\n self.offset += K;\n result\n }\n\n pub fn read_struct<T, let K: u32>(&mut self, deserialise: fn([Field; K]) -> T) -> T {\n let result = deserialise(self.read_array());\n result\n }\n\n pub fn read_struct_array<T, let K: u32, let C: u32>(\n &mut self,\n deserialise: fn([Field; K]) -> T,\n mut result: [T; C],\n ) -> [T; C] {\n for i in 0..C {\n result[i] = self.read_struct(deserialise);\n }\n result\n }\n\n pub fn peek_offset(&mut self, offset: u32) -> Field {\n self.data[self.offset + offset]\n }\n\n pub fn advance_offset(&mut self, offset: u32) {\n self.offset += offset;\n }\n\n pub fn finish(self) {\n assert_eq(self.offset, self.data.len(), \"Reader did not read all data\");\n }\n}\n"
|
|
1868
1876
|
},
|
|
1869
|
-
"
|
|
1877
|
+
"442": {
|
|
1870
1878
|
"function_locations": [
|
|
1871
1879
|
{
|
|
1872
1880
|
"name": "derive_serialize",
|
|
@@ -1889,10 +1897,10 @@
|
|
|
1889
1897
|
"start": 12587
|
|
1890
1898
|
}
|
|
1891
1899
|
],
|
|
1892
|
-
"path": "/
|
|
1900
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/serde/src/serialization.nr",
|
|
1893
1901
|
"source": "use crate::{reader::Reader, writer::Writer};\nuse std::meta::type_def::StructField;\n\n/// Trait for serializing Noir types into arrays of Fields.\n///\n/// An implementation of the Serialize trait has to follow Noir's intrinsic serialization (each member of a struct\n/// converted directly into one or more Fields without any packing or compression). This trait (and Deserialize) are\n/// typically used to communicate between Noir and TypeScript (via oracles and function arguments).\n///\n/// # On Following Noir's Intrinsic Serialization\n/// When calling a Noir function from TypeScript (TS), first the function arguments are serialized into an array\n/// of fields. This array is then included in the initial witness. Noir's intrinsic serialization is then used\n/// to deserialize the arguments from the witness. When the same Noir function is called from Noir this Serialize trait\n/// is used instead of the serialization in TS. For this reason we need to have a match between TS serialization,\n/// Noir's intrinsic serialization and the implementation of this trait. If there is a mismatch, the function calls\n/// fail with an arguments hash mismatch error message.\n///\n/// # Associated Constants\n/// * `N` - The length of the output Field array, known at compile time\n///\n/// # Example\n/// ```\n/// impl<let N: u32> Serialize for str<N> {\n/// let N: u32 = N;\n///\n/// fn serialize(self) -> [Field; Self::N] {\n/// let mut writer: Writer<Self::N> = Writer::new();\n/// self.stream_serialize(&mut writer);\n/// writer.finish()\n/// }\n///\n/// fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n/// let bytes = self.as_bytes();\n/// for i in 0..bytes.len() {\n/// writer.write(bytes[i] as Field);\n/// }\n/// }\n/// }\n/// ```\n#[derive_via(derive_serialize)]\npub trait Serialize {\n let N: u32;\n\n fn serialize(self) -> [Field; Self::N];\n\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>);\n}\n\n/// Generates a `Serialize` trait implementation for a struct type.\n///\n/// # Parameters\n/// - `s`: The struct type definition to generate the implementation for\n///\n/// # Returns\n/// A quoted code block containing the trait implementation\n///\n/// # Example\n/// For a struct defined as:\n/// ```\n/// struct Log<N> {\n/// fields: [Field; N],\n/// length: u32\n/// }\n/// ```\n///\n/// This function generates code equivalent to:\n/// ```\n/// impl<let N: u32> Serialize for Log<N> {\n/// let N: u32 = <[Field; N] as Serialize>::N + <u32 as Serialize>::N;\n///\n/// fn serialize(self) -> [Field; Self::N] {\n/// let mut writer: Writer<Self::N> = Writer::new();\n/// self.stream_serialize(&mut writer);\n/// writer.finish()\n/// }\n///\n/// #[inline_always]\n/// fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n/// Serialize::stream_serialize(self.fields, writer);\n/// Serialize::stream_serialize(self.length, writer);\n/// }\n/// }\n/// ```\npub comptime fn derive_serialize(s: TypeDefinition) -> Quoted {\n let typ = s.as_type();\n let nested_struct = typ.as_data_type().unwrap();\n let params = nested_struct.definition().fields(nested_struct.generics());\n\n // Generates the generic parameter declarations (to be placed after the `impl` keyword) and the `where` clause\n // for the `Serialize` trait.\n let generics_declarations = get_generics_declarations(s);\n let where_serialize_clause = get_where_trait_clause(s, quote { Serialize });\n\n let params_len_quote = get_params_len_quote(params);\n\n let function_body = params\n .map(|field: StructField| {\n let name = field.name();\n quote {\n $crate::serialization::Serialize::stream_serialize(self.$name, writer);\n }\n })\n .join(quote {});\n\n quote {\n impl$generics_declarations $crate::serialization::Serialize for $typ\n $where_serialize_clause\n {\n let N: u32 = $params_len_quote;\n\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: $crate::writer::Writer<Self::N> = $crate::writer::Writer::new();\n $crate::serialization::Serialize::stream_serialize(self, &mut writer);\n writer.finish()\n }\n\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut $crate::writer::Writer<K>) {\n $function_body\n }\n }\n }\n}\n\n/// Trait for deserializing Noir types from arrays of Fields.\n///\n/// An implementation of the Deserialize trait has to follow Noir's intrinsic serialization (each member of a struct\n/// converted directly into one or more Fields without any packing or compression). This trait is typically used when\n/// deserializing return values from function calls in Noir. Since the same function could be called from TypeScript\n/// (TS), in which case the TS deserialization would get used, we need to have a match between the 2.\n///\n/// # Associated Constants\n/// * `N` - The length of the input Field array, known at compile time\n///\n/// # Example\n/// ```\n/// impl<let M: u32> Deserialize for str<M> {\n/// let N: u32 = M;\n///\n/// fn deserialize(fields: [Field; Self::N]) -> Self {\n/// let mut reader = Reader::new(fields);\n/// let result = Self::stream_deserialize(&mut reader);\n/// reader.finish();\n/// result\n/// }\n///\n/// fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n/// let mut bytes = [0 as u8; M];\n/// for i in 0..M {\n/// bytes[i] = reader.read() as u8;\n/// }\n/// str::<M>::from(bytes)\n/// }\n/// }\n/// ```\n#[derive_via(derive_deserialize)]\npub trait Deserialize {\n let N: u32;\n\n fn deserialize(fields: [Field; Self::N]) -> Self;\n\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self;\n}\n\n/// Generates a `Deserialize` trait implementation for a given struct `s`.\n///\n/// # Arguments\n/// * `s` - The struct type definition to generate the implementation for\n///\n/// # Returns\n/// A `Quoted` block containing the generated trait implementation\n///\n/// # Requirements\n/// Each struct member type must implement the `Deserialize` trait (it gets used in the generated code).\n///\n/// # Example\n/// For a struct like:\n/// ```\n/// struct MyStruct {\n/// x: AztecAddress,\n/// y: Field,\n/// }\n/// ```\n///\n/// This generates:\n/// ```\n/// impl Deserialize for MyStruct {\n/// let N: u32 = <AztecAddress as Deserialize>::N + <Field as Deserialize>::N;\n///\n/// fn deserialize(fields: [Field; Self::N]) -> Self {\n/// let mut reader = Reader::new(fields);\n/// let result = Self::stream_deserialize(&mut reader);\n/// reader.finish();\n/// result\n/// }\n///\n/// #[inline_always]\n/// fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n/// let x = <AztecAddress as Deserialize>::stream_deserialize(reader);\n/// let y = <Field as Deserialize>::stream_deserialize(reader);\n/// Self { x, y }\n/// }\n/// }\n/// ```\npub comptime fn derive_deserialize(s: TypeDefinition) -> Quoted {\n let typ = s.as_type();\n let nested_struct = typ.as_data_type().unwrap();\n let params = nested_struct.definition().fields(nested_struct.generics());\n\n // Generates the generic parameter declarations (to be placed after the `impl` keyword) and the `where` clause\n // for the `Deserialize` trait.\n let generics_declarations = get_generics_declarations(s);\n let where_deserialize_clause = get_where_trait_clause(s, quote { Deserialize });\n\n // The following will give us:\n // <type_of_struct_member_1 as Deserialize>::N + <type_of_struct_member_2 as Deserialize>::N + ...\n // (or 0 if the struct has no members)\n let right_hand_side_of_definition_of_n = if params.len() > 0 {\n params\n .map(|field: StructField| {\n let param_type = field.typ();\n quote {\n <$param_type as $crate::serialization::Deserialize>::N\n }\n })\n .join(quote {+})\n } else {\n quote { 0 }\n };\n\n // For structs containing a single member, we can enhance performance by directly deserializing the input array,\n // bypassing the need for loop-based array construction. While this optimization yields significant benefits in\n // Brillig where the loops are expected to not be optimized, it is not relevant in ACIR where the loops are\n // expected to be optimized away.\n let function_body = if params.len() > 1 {\n // This generates deserialization code for each struct member and concatenates them together.\n let deserialization_of_struct_members = params\n .map(|field: StructField| {\n let param_name = field.name();\n let param_type = field.typ();\n quote {\n let $param_name = <$param_type as Deserialize>::stream_deserialize(reader);\n }\n })\n .join(quote {});\n\n // We join the struct member names with a comma to be used in the `Self { ... }` syntax\n // This will give us e.g. `a, b, c` for a struct with three fields named `a`, `b`, and `c`.\n let struct_members = params\n .map(|field: StructField| {\n let param_name = field.name();\n quote { $param_name }\n })\n .join(quote {,});\n\n quote {\n $deserialization_of_struct_members\n\n Self { $struct_members }\n }\n } else if params.len() == 1 {\n let param_name = params[0].name();\n quote {\n Self { $param_name: $crate::serialization::Deserialize::stream_deserialize(reader) }\n }\n } else {\n quote {\n Self {}\n }\n };\n\n quote {\n impl$generics_declarations $crate::serialization::Deserialize for $typ\n $where_deserialize_clause\n {\n let N: u32 = $right_hand_side_of_definition_of_n;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = $crate::reader::Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut $crate::reader::Reader<K>) -> Self {\n $function_body\n }\n }\n }\n}\n\n/// Generates a quoted expression that computes the total serialized length of function parameters.\n///\n/// # Parameters\n/// * `params` - The struct fields to serialize. Each field's type needs to implement the Serialize trait.\n///\n/// # Returns\n/// A quoted expression that evaluates to:\n/// * `0` if there are no parameters\n/// * `(<type1 as Serialize>::N + <type2 as Serialize>::N + ...)` for one or more parameters\ncomptime fn get_params_len_quote(params: [StructField]) -> Quoted {\n if params.len() == 0 {\n quote { 0 }\n } else {\n let params_quote_without_parentheses = params\n .map(|field: StructField| {\n let param_type = field.typ();\n quote {\n <$param_type as $crate::serialization::Serialize>::N\n }\n })\n .join(quote {+});\n quote { ($params_quote_without_parentheses) }\n }\n}\n\ncomptime fn get_generics_declarations(s: TypeDefinition) -> Quoted {\n let generics = s.generics();\n\n if generics.len() > 0 {\n let generics_declarations_items = generics\n .map(|generic| {\n let name = generic.typ();\n let maybe_integer_typ = generic.numeric_type();\n // numeric_type is Some only when the generic is numeric.\n if maybe_integer_typ.is_some() {\n // The generic is numeric, so we return a quote defined as e.g. \"let N: u32\"\n let integer_type = maybe_integer_typ.unwrap();\n quote {let $name: $integer_type}\n } else {\n // The generic is not numeric, so we return a quote containing the name of the generic (e.g. \"T\")\n quote { $name }\n }\n })\n .join(quote {,});\n quote {<$generics_declarations_items>}\n } else {\n // The struct doesn't have any generics defined, so we just return an empty quote.\n quote {}\n }\n}\n\ncomptime fn get_where_trait_clause(s: TypeDefinition, trait_name: Quoted) -> Quoted {\n let generics = s.generics();\n\n // numeric_type is Some only when the generic is numeric.\n let non_numeric_generics = generics.filter(|generic| generic.numeric_type().is_none());\n\n if non_numeric_generics.len() > 0 {\n let non_numeric_generics_declarations = non_numeric_generics\n .map(|generic| {\n let name = generic.typ();\n quote {$name: $trait_name}\n })\n .join(quote {,});\n quote {where $non_numeric_generics_declarations}\n } else {\n // There are no non-numeric generics, so we return an empty quote.\n quote {}\n }\n}\n"
|
|
1894
1902
|
},
|
|
1895
|
-
"
|
|
1903
|
+
"444": {
|
|
1896
1904
|
"function_locations": [
|
|
1897
1905
|
{
|
|
1898
1906
|
"name": "<impl Serialize for bool>::serialize",
|
|
@@ -2203,10 +2211,10 @@
|
|
|
2203
2211
|
"start": 21246
|
|
2204
2212
|
}
|
|
2205
2213
|
],
|
|
2206
|
-
"path": "/
|
|
2214
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/serde/src/type_impls.nr",
|
|
2207
2215
|
"source": "use crate::{reader::Reader, serialization::{Deserialize, Serialize}, writer::Writer};\nuse std::embedded_curve_ops::EmbeddedCurvePoint;\nuse std::embedded_curve_ops::EmbeddedCurveScalar;\n\nglobal BOOL_SERIALIZED_LEN: u32 = 1;\nglobal U8_SERIALIZED_LEN: u32 = 1;\nglobal U16_SERIALIZED_LEN: u32 = 1;\nglobal U32_SERIALIZED_LEN: u32 = 1;\nglobal U64_SERIALIZED_LEN: u32 = 1;\nglobal U128_SERIALIZED_LEN: u32 = 1;\nglobal FIELD_SERIALIZED_LEN: u32 = 1;\nglobal I8_SERIALIZED_LEN: u32 = 1;\nglobal I16_SERIALIZED_LEN: u32 = 1;\nglobal I32_SERIALIZED_LEN: u32 = 1;\nglobal I64_SERIALIZED_LEN: u32 = 1;\n\nimpl Serialize for bool {\n let N: u32 = BOOL_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for bool {\n let N: u32 = BOOL_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> bool {\n reader.read() != 0\n }\n}\n\nimpl Serialize for u8 {\n let N: u32 = U8_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for u8 {\n let N: u32 = U8_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u8\n }\n}\n\nimpl Serialize for u16 {\n let N: u32 = U16_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for u16 {\n let N: u32 = U16_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u16\n }\n}\n\nimpl Serialize for u32 {\n let N: u32 = U32_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for u32 {\n let N: u32 = U32_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u32\n }\n}\n\nimpl Serialize for u64 {\n let N: u32 = U64_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for u64 {\n let N: u32 = U64_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u64\n }\n}\n\nimpl Serialize for u128 {\n let N: u32 = U128_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as Field);\n }\n}\n\nimpl Deserialize for u128 {\n let N: u32 = U128_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u128\n }\n}\n\nimpl Serialize for Field {\n let N: u32 = FIELD_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self);\n }\n}\n\nimpl Deserialize for Field {\n let N: u32 = FIELD_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read()\n }\n}\n\nimpl Serialize for i8 {\n let N: u32 = I8_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as u8 as Field);\n }\n}\n\nimpl Deserialize for i8 {\n let N: u32 = I8_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u8 as i8\n }\n}\n\nimpl Serialize for i16 {\n let N: u32 = I16_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as u16 as Field);\n }\n}\n\nimpl Deserialize for i16 {\n let N: u32 = I16_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u16 as i16\n }\n}\n\nimpl Serialize for i32 {\n let N: u32 = I32_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as u32 as Field);\n }\n}\n\nimpl Deserialize for i32 {\n let N: u32 = I32_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u32 as i32\n }\n}\n\nimpl Serialize for i64 {\n let N: u32 = I64_SERIALIZED_LEN;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self as u64 as Field);\n }\n}\n\nimpl Deserialize for i64 {\n let N: u32 = I64_SERIALIZED_LEN;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n reader.read() as u64 as i64\n }\n}\n\nimpl<T, let M: u32> Serialize for [T; M]\nwhere\n T: Serialize,\n{\n let N: u32 = <T as Serialize>::N * M;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n for i in 0..M {\n self[i].stream_serialize(writer);\n }\n }\n}\n\nimpl<T, let M: u32> Deserialize for [T; M]\nwhere\n T: Deserialize,\n{\n let N: u32 = <T as Deserialize>::N * M;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n let mut result: [T; M] = std::mem::zeroed();\n for i in 0..M {\n result[i] = T::stream_deserialize(reader);\n }\n result\n }\n}\n\nimpl<T> Serialize for Option<T>\nwhere\n T: Serialize,\n{\n let N: u32 = <T as Serialize>::N + 1;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write_bool(self.is_some());\n if self.is_some() {\n self.unwrap_unchecked().stream_serialize(writer);\n } else {\n writer.advance_offset(<T as Serialize>::N);\n }\n }\n}\n\nimpl<T> Deserialize for Option<T>\nwhere\n T: Deserialize,\n{\n let N: u32 = <T as Deserialize>::N + 1;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n if reader.read_bool() {\n Option::some(<T as Deserialize>::stream_deserialize(reader))\n } else {\n reader.advance_offset(<T as Deserialize>::N);\n Option::none()\n }\n }\n}\n\nglobal SCALAR_SIZE: u32 = 2;\n\nimpl Serialize for EmbeddedCurveScalar {\n\n let N: u32 = SCALAR_SIZE;\n\n fn serialize(self) -> [Field; SCALAR_SIZE] {\n [self.lo, self.hi]\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self.lo);\n writer.write(self.hi);\n }\n}\n\nimpl Deserialize for EmbeddedCurveScalar {\n let N: u32 = SCALAR_SIZE;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n Self { lo: fields[0], hi: fields[1] }\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n Self { lo: reader.read(), hi: reader.read() }\n }\n}\n\nglobal POINT_SIZE: u32 = 2;\n\nimpl Serialize for EmbeddedCurvePoint {\n let N: u32 = POINT_SIZE;\n\n fn serialize(self) -> [Field; Self::N] {\n [self.x, self.y]\n }\n\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self.x);\n writer.write(self.y);\n }\n}\n\nimpl Deserialize for EmbeddedCurvePoint {\n let N: u32 = POINT_SIZE;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n Self { x: fields[0], y: fields[1] }\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n Self { x: reader.read(), y: reader.read() }\n }\n}\n\nimpl<let M: u32> Deserialize for str<M> {\n let N: u32 = M;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n let u8_arr = <[u8; Self::N] as Deserialize>::stream_deserialize(reader);\n str::<Self::N>::from(u8_arr)\n }\n}\n\nimpl<let M: u32> Serialize for str<M> {\n let N: u32 = M;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n self.as_bytes().stream_serialize(writer);\n }\n}\n\n// Note: Not deriving this because it's not supported to call derive_serialize on a \"remote\" struct (and it will never\n// be supported).\nimpl<T, let M: u32> Deserialize for BoundedVec<T, M>\nwhere\n T: Deserialize,\n{\n let N: u32 = <T as Deserialize>::N * M + 1;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n let mut new_bounded_vec: BoundedVec<T, M> = BoundedVec::new();\n let payload_len = Self::N - 1;\n\n // Length is stored in the last field as we need to match intrinsic Noir serialization and the `len` struct\n // field is after `storage` struct field (see `bounded_vec.nr` in noir-stdlib)\n let len = reader.peek_offset(payload_len) as u32;\n\n for i in 0..M {\n if i < len {\n new_bounded_vec.push(<T as Deserialize>::stream_deserialize(reader));\n }\n }\n\n // +1 for the length of the BoundedVec\n reader.advance_offset((M - len) * <T as Deserialize>::N + 1);\n\n new_bounded_vec\n }\n}\n\n// This may cause issues if used as program input, because noir disallows empty arrays for program input.\n// I think this is okay because I don't foresee a unit type being used as input. But leaving this comment as a hint\n// if someone does run into this in the future.\nimpl Deserialize for () {\n let N: u32 = 0;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(_reader: &mut Reader<K>) -> Self {\n ()\n }\n}\n\n// Note: Not deriving this because it's not supported to call derive_serialize on a \"remote\" struct (and it will never\n// be supported).\nimpl<T, let M: u32> Serialize for BoundedVec<T, M>\nwhere\n T: Serialize,\n{\n let N: u32 = <T as Serialize>::N * M + 1; // +1 for the length of the BoundedVec\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: Writer<Self::N> = Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n self.storage().stream_serialize(writer);\n // Length is stored in the last field as we need to match intrinsic Noir serialization and the `len` struct\n // field is after `storage` struct field (see `bounded_vec.nr` in noir-stdlib)\n writer.write_u32(self.len() as u32);\n }\n}\n\n// Create a slice of the given length with each element made from `f(i)` where `i` is the current index\ncomptime fn make_slice<Env, T>(length: u32, f: fn[Env](u32) -> T) -> [T] {\n let mut slice = @[];\n for i in 0..length {\n slice = slice.push_back(f(i));\n }\n slice\n}\n\n// Implements Serialize and Deserialize for an arbitrary tuple type\ncomptime fn impl_serialize_for_tuple(_m: Module, length: u32) -> Quoted {\n // `T0`, `T1`, `T2`\n let type_names = make_slice(length, |i| f\"T{i}\".quoted_contents());\n\n // `result0`, `result1`, `result2`\n let result_names = make_slice(length, |i| f\"result{i}\".quoted_contents());\n\n // `T0, T1, T2`\n let field_generics = type_names.join(quote [,]);\n\n // `<T0 as Serialize>::N + <T1 as Serialize>::N + <T2 as Serialize>::N`\n let full_size_serialize = type_names\n .map(|type_name| quote {\n <$type_name as Serialize>::N\n })\n .join(quote [+]);\n\n // `<T0 as Deserialize>::N + <T1 as Deserialize>::N + <T2 as Deserialize>::N`\n let full_size_deserialize = type_names\n .map(|type_name| quote {\n <$type_name as Deserialize>::N\n })\n .join(quote [+]);\n\n // `T0: Serialize, T1: Serialize, T2: Serialize,`\n let serialize_constraints = type_names\n .map(|field_name| quote {\n $field_name: Serialize,\n })\n .join(quote []);\n\n // `T0: Deserialize, T1: Deserialize, T2: Deserialize,`\n let deserialize_constraints = type_names\n .map(|field_name| quote {\n $field_name: Deserialize,\n })\n .join(quote []);\n\n // Statements to serialize each field\n let serialized_fields = type_names\n .mapi(|i, _type_name| quote {\n $crate::serialization::Serialize::stream_serialize(self.$i, writer);\n })\n .join(quote []);\n\n // Statements to deserialize each field\n let deserialized_fields = type_names\n .mapi(|i, type_name| {\n let result_name = result_names[i];\n quote {\n let $result_name = <$type_name as $crate::serialization::Deserialize>::stream_deserialize(reader);\n }\n })\n .join(quote []);\n let deserialize_results = result_names.join(quote [,]);\n\n quote {\n impl<$field_generics> Serialize for ($field_generics) where $serialize_constraints {\n let N: u32 = $full_size_serialize;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: $crate::writer::Writer<Self::N> = $crate::writer::Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut $crate::writer::Writer<K>) {\n\n $serialized_fields\n }\n }\n\n impl<$field_generics> Deserialize for ($field_generics) where $deserialize_constraints {\n let N: u32 = $full_size_deserialize;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = $crate::reader::Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n \n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut $crate::reader::Reader<K>) -> Self {\n $deserialized_fields\n ($deserialize_results)\n }\n }\n }\n}\n\n// Keeping these manual impls. They are more efficient since they do not\n// require copying sub-arrays from any serialized arrays.\nimpl<T1> Serialize for (T1,)\nwhere\n T1: Serialize,\n{\n let N: u32 = <T1 as Serialize>::N;\n\n fn serialize(self) -> [Field; Self::N] {\n let mut writer: crate::writer::Writer<Self::N> = crate::writer::Writer::new();\n self.stream_serialize(&mut writer);\n writer.finish()\n }\n\n #[inline_always]\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n self.0.stream_serialize(writer);\n }\n}\n\nimpl<T1> Deserialize for (T1,)\nwhere\n T1: Deserialize,\n{\n let N: u32 = <T1 as Deserialize>::N;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n let mut reader = crate::reader::Reader::new(fields);\n let result = Self::stream_deserialize(&mut reader);\n reader.finish();\n result\n }\n\n #[inline_always]\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n (<T1 as Deserialize>::stream_deserialize(reader),)\n }\n}\n\n#[impl_serialize_for_tuple(2)]\n#[impl_serialize_for_tuple(3)]\n#[impl_serialize_for_tuple(4)]\n#[impl_serialize_for_tuple(5)]\n#[impl_serialize_for_tuple(6)]\nmod impls {\n use crate::serialization::{Deserialize, Serialize};\n}\n\n#[test]\nunconstrained fn bounded_vec_serialization() {\n // Test empty BoundedVec\n let empty_vec: BoundedVec<Field, 3> = BoundedVec::from_array([]);\n let serialized = empty_vec.serialize();\n let deserialized = BoundedVec::<Field, 3>::deserialize(serialized);\n assert_eq(empty_vec, deserialized);\n assert_eq(deserialized.len(), 0);\n\n // Test partially filled BoundedVec\n let partial_vec: BoundedVec<[u32; 2], 3> = BoundedVec::from_array([[1, 2]]);\n let serialized = partial_vec.serialize();\n let deserialized = BoundedVec::<[u32; 2], 3>::deserialize(serialized);\n assert_eq(partial_vec, deserialized);\n assert_eq(deserialized.len(), 1);\n assert_eq(deserialized.get(0), [1, 2]);\n\n // Test full BoundedVec\n let full_vec: BoundedVec<[u32; 2], 3> = BoundedVec::from_array([[1, 2], [3, 4], [5, 6]]);\n let serialized = full_vec.serialize();\n let deserialized = BoundedVec::<[u32; 2], 3>::deserialize(serialized);\n assert_eq(full_vec, deserialized);\n assert_eq(deserialized.len(), 3);\n assert_eq(deserialized.get(0), [1, 2]);\n assert_eq(deserialized.get(1), [3, 4]);\n assert_eq(deserialized.get(2), [5, 6]);\n}\n"
|
|
2208
2216
|
},
|
|
2209
|
-
"
|
|
2217
|
+
"445": {
|
|
2210
2218
|
"function_locations": [
|
|
2211
2219
|
{
|
|
2212
2220
|
"name": "Writer<N>::new",
|
|
@@ -2249,7 +2257,7 @@
|
|
|
2249
2257
|
"start": 1263
|
|
2250
2258
|
}
|
|
2251
2259
|
],
|
|
2252
|
-
"path": "/
|
|
2260
|
+
"path": "/home/nventuro/nargo/github.com/AztecProtocol/aztec-packages/v6.0.0-rc.1/noir-projects/fnd/noir-protocol-circuits/crates/serde/src/writer.nr",
|
|
2253
2261
|
"source": "pub struct Writer<let N: u32> {\n data: [Field; N],\n offset: u32,\n}\n\nimpl<let N: u32> Writer<N> {\n pub fn new() -> Self {\n Self { data: [0; N], offset: 0 }\n }\n\n pub fn write(&mut self, value: Field) {\n self.data[self.offset] = value;\n self.offset += 1;\n }\n\n pub fn write_u32(&mut self, value: u32) {\n self.write(value as Field);\n }\n\n pub fn write_u64(&mut self, value: u64) {\n self.write(value as Field);\n }\n\n pub fn write_bool(&mut self, value: bool) {\n self.write(value as Field);\n }\n\n pub fn write_array<let K: u32>(&mut self, value: [Field; K]) {\n for i in 0..K {\n self.data[i + self.offset] = value[i];\n }\n self.offset += K;\n }\n\n pub fn write_struct<T, let K: u32>(&mut self, value: T, serialize: fn(T) -> [Field; K]) {\n self.write_array(serialize(value));\n }\n\n pub fn write_struct_array<T, let K: u32, let C: u32>(\n &mut self,\n value: [T; C],\n serialize: fn(T) -> [Field; K],\n ) {\n for i in 0..C {\n self.write_struct(value[i], serialize);\n }\n }\n\n pub fn advance_offset(&mut self, offset: u32) {\n self.offset += offset;\n }\n\n pub fn finish(self) -> [Field; N] {\n assert_eq(self.offset, self.data.len(), \"Writer did not write all data\");\n self.data\n }\n}\n"
|
|
2254
2262
|
},
|
|
2255
2263
|
"45": {
|
|
@@ -2611,7 +2619,7 @@
|
|
|
2611
2619
|
"start": 6210
|
|
2612
2620
|
}
|
|
2613
2621
|
],
|
|
2614
|
-
"path": "/
|
|
2622
|
+
"path": "/home/nventuro/node/noir-projects/noir-contracts/contracts/standard/auth_registry_contract/src/main.nr",
|
|
2615
2623
|
"source": "use aztec::{macros::{aztec, AztecConfig}, messages::discovery::do_sync_state_no_op};\n\n/// A contract that manages public authentication witnesses (authwits) on the Aztec network.\n///\n/// In Aztec, private authwits are verified by account contracts directly (via oracles on the user's device). Public\n/// authwits, however, require this onchain registry because local oracles cannot be used for global execution. Users\n/// pre-approve actions by storing `message_hash -> true` mappings via `set_authorized`, and consumer contracts verify\n/// and atomically revoke these approvals via `consume`.\n///\n/// The `message_hash` includes the consumer address, chain ID, and protocol version, preventing cross-chain and\n/// cross-contract replay. Each approval can only be consumed once. Users can also enable `reject_all` as an emergency\n/// kill switch to invalidate all outstanding approvals at once.\n///\n/// Note that there is no expiration time enforced on the approved actions in this contract as this can be achieved by\n/// including an expiration timestamp in the `message` (`message_hash` preimage) and having the consumer contract\n/// constrain that value.\n#[aztec(AztecConfig::new().custom_sync_state(do_sync_state_no_op))]\npub contract AuthRegistry {\n use aztec::{\n authwit::auth::{assert_current_call_valid_authwit, compute_authwit_message_hash, IS_VALID_SELECTOR},\n macros::{functions::{external, only_self, view}, storage::storage},\n protocol::address::AztecAddress,\n state_vars::{Map, PublicMutable},\n };\n\n #[storage]\n struct Storage<Context> {\n /// Per-address flag that, when true, causes all `consume` calls for that address to revert. Provides an\n /// emergency \"mass revocation\" mechanism. Does not delete existing approvals - if later set back to false,\n /// unconsumed approvals become consumable again.\n reject_all: Map<AztecAddress, PublicMutable<bool, Context>, Context>,\n /// Per-user, per-message authorization status. `approved_actions[user][message_hash]` is set to true by\n /// `set_authorized` and atomically revoked by `consume` to prevent replay.\n approved_actions: Map<AztecAddress, Map<Field, PublicMutable<bool, Context>, Context>, Context>,\n }\n\n /// Approves or revokes a `message_hash` for the `msg_sender`.\n #[external(\"public\")]\n fn set_authorized(message_hash: Field, authorize: bool) {\n self.storage.approved_actions.at(self.msg_sender()).at(message_hash).write(authorize);\n }\n\n /// Enables or disables mass rejection of all authwits for `msg_sender`. When enabled, all `consume` calls for the\n /// `msg_sender` will revert regardless of individual approvals.\n #[external(\"public\")]\n fn set_reject_all(reject: bool) {\n self.storage.reject_all.at(self.msg_sender()).write(reject);\n }\n\n /// Consumes (verifies and atomically revokes) an authorization on behalf of `on_behalf_of`.\n ///\n /// Called by consumer contracts (e.g. Token) to verify a user has authorized an action. Reverts if `reject_all`\n /// is set for `msg_sender`.\n ///\n /// Returns `IS_VALID_SELECTOR` (0x47dacd73) on success instead of a boolean. This follows the EIP-1271 pattern:\n /// a failed or malformed call would return the default zero value, which is indistinguishable from `false`. By\n /// requiring a specific magic value, the caller can reliably distinguish a successful validation from a failed\n /// call. The function also reverts on failure as a first line of defense, making the magic return value a\n /// defense-in-depth measure against subtle integration bugs on the caller side.\n #[external(\"public\")]\n fn consume(on_behalf_of: AztecAddress, inner_hash: Field) -> Field {\n assert_eq(false, self.storage.reject_all.at(on_behalf_of).read(), \"rejecting all\");\n\n let message_hash = compute_authwit_message_hash(\n self.msg_sender(),\n self.context.chain_id(),\n self.context.version(),\n inner_hash,\n );\n\n let authorized = self.storage.approved_actions.at(on_behalf_of).at(message_hash).read();\n\n assert_eq(true, authorized, \"unauthorized\");\n\n self.storage.approved_actions.at(on_behalf_of).at(message_hash).write(false);\n\n IS_VALID_SELECTOR\n }\n\n /// Updates a public authwit for `approver` using a private authwit\n ///\n /// Useful for the case where you want someone else to insert a public authwit for you. For example, if Alice\n /// (`approver` in this scenario) wants Bob to insert an authwit in public, such that they can execute a trade,\n /// Alice can create a private authwit, and Bob can call this function with it.\n #[external(\"private\")]\n fn set_authorized_private(approver: AztecAddress, message_hash: Field, authorize: bool) {\n assert_current_call_valid_authwit::<3>(self.context, approver);\n self.enqueue_self._set_authorized(approver, message_hash, authorize);\n }\n\n /// A function that writes an authorization entry for an arbitrary `approver`. Only callable by this contract\n /// itself (`#[only_self]`), ensuring it is only reachable through the validated `set_authorized_private` flow.\n #[external(\"public\")]\n #[only_self]\n fn _set_authorized(approver: AztecAddress, message_hash: Field, authorize: bool) {\n self.storage.approved_actions.at(approver).at(message_hash).write(authorize);\n }\n\n /// Returns whether `on_behalf_of` has enabled the `reject_all` flag.\n #[external(\"public\")]\n #[view]\n fn is_reject_all(on_behalf_of: AztecAddress) -> bool {\n self.storage.reject_all.at(on_behalf_of).read()\n }\n\n /// Returns whether a specific `message_hash` is currently consumable for `on_behalf_of`.\n #[external(\"public\")]\n #[view]\n fn is_consumable(on_behalf_of: AztecAddress, message_hash: Field) -> bool {\n !self.storage.reject_all.at(on_behalf_of).read()\n & self.storage.approved_actions.at(on_behalf_of).at(message_hash).read()\n }\n\n /// Utility version of `is_consumable`\n #[external(\"utility\")]\n unconstrained fn utility_is_consumable(on_behalf_of: AztecAddress, message_hash: Field) -> bool {\n !self.storage.reject_all.at(on_behalf_of).read()\n & self.storage.approved_actions.at(on_behalf_of).at(message_hash).read()\n }\n}\n"
|
|
2616
2624
|
},
|
|
2617
2625
|
"55": {
|
|
@@ -2661,7 +2669,7 @@
|
|
|
2661
2669
|
"start": 24498
|
|
2662
2670
|
}
|
|
2663
2671
|
],
|
|
2664
|
-
"path": "/
|
|
2672
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/authwit/auth.nr",
|
|
2665
2673
|
"source": "use crate::{\n authwit::{authorization_interface::AuthorizationInterface, AuthorizationSelector},\n context::{gas::GasOpts, PrivateContext, PublicContext},\n hash::hash_args,\n macros::authorization::authorization,\n oracle::{execution_cache::load, offchain_effect::emit_offchain_effect},\n};\nuse crate::protocol::{\n abis::function_selector::FunctionSelector,\n address::AztecAddress,\n constants::{DOM_SEP__AUTHWIT_INNER, DOM_SEP__AUTHWIT_OUTER},\n hash::poseidon2_hash_with_separator,\n traits::{Serialize, ToField},\n};\nuse crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS;\n\n/// Domain separator for authentication witness nullifiers.\npub(crate) global DOM_SEP__AUTHWIT_NULLIFIER: u32 = 1239150694;\n\n/// Authentication witness helper library\n///\n/// Authentication Witness is a scheme for authenticating actions on Aztec, so users can allow third-parties (e.g.\n/// protocols or other users) to execute an action on their behalf.\n///\n/// This library provides helper functions to manage such witnesses. The authentication witness, is some \"witness\"\n/// (data) that authenticates a `message_hash`. The simplest example of an authentication witness, is a signature. The\n/// signature is the \"evidence\", that the signer has seen the message, agrees with it, and has allowed it. It does not\n/// need to be a signature. It could be any kind of \"proof\" that the message is allowed. Another proof could be knowing\n/// some kind of secret, or having some kind of \"token\" that allows the message.\n///\n/// The `message_hash` is a hash of the following structure: hash(consumer, chain_id, version, inner_hash)\n/// - consumer: the address of the contract that is \"consuming\" the message,\n/// - chain_id: the chain id of the chain that the message is being consumed on,\n/// - version: the version of the chain that the message is being consumed on,\n/// - inner_hash: the hash of the \"inner\" message that is being consumed, this is the \"actual\" message or action.\n///\n/// While the `inner_hash` could be anything, such as showing you signed a specific message, it will often be a hash of\n/// the \"action\" to approve, along with who made the call. As part of this library, we provide a few helper functions\n/// to deal with such messages.\n///\n/// For example, we provide helper function that is used for checking that the message is an encoding of the current\n/// call. This can be used to let some contract \"allow\" another contract to act on its behalf, as long as it can show\n/// that it is acting on behalf of the contract.\n///\n/// If we take a case of allowing a contract to transfer tokens on behalf of an account, the `inner_hash` can be\n/// derived as: inner_hash = hash(caller, \"transfer\", hash(to, amount))\n///\n/// Where the `caller` would be the address of the contract that is trying to transfer the tokens, and `to` and\n/// `amount` the arguments for the transfer.\n///\n/// Note that we have both a `caller` and a `consumer`, the `consumer` will be the contract that is consuming the\n/// message, in the case of the transfer, it would be the `Token` contract itself, while the caller, will be the actor\n/// that is allowed to transfer the tokens.\n///\n///\n/// The authentication mechanism works differently in public and private contexts. In private, we recall that\n/// everything is executed on the user's device, so we can use `oracles` to \"ask\" the user (not contract) for\n/// information. In public we cannot do this, since it is executed by the sequencer (someone else). Therefore we can\n/// instead use a \"registry\" to store the messages that we have approved.\n///\n/// A simple example would be a \"token\" that is being \"pulled\" from one account into another. We will first outline how\n/// this would look in private, and then in public later.\n///\n/// Say that a user `Alice` wants to deposit some tokens into a DeFi protocol (say a DEX). `Alice` would make a\n/// `deposit` transaction, that she is executing using her account contract. The account would call the `DeFi` contract\n/// to execute `deposit`, which would try to pull funds from the `Token` contract. Since the `DeFi` contract is trying\n/// to pull funds from an account that is not its own, it needs to convince the `Token` contract that it is allowed to\n/// do so.\n///\n/// This is where the authentication witness comes in The `Token` contract computes a `message_hash` from the\n/// `transfer` call, and then asks `Alice Account` contract to verify that the `DeFi` contract is allowed to execute\n/// that call.\n///\n/// `Alice Account` contract can then ask `Alice` if she wants to allow the `DeFi` contract to pull funds from her\n/// account. If she does, she will sign the `message_hash` and return the signature to the `Alice Account` which will\n/// validate it and return success to the `Token` contract which will then allow the `DeFi` contract to pull funds from\n/// `Alice`.\n///\n/// To ensure that the same \"approval\" cannot be used multiple times, we also compute a `nullifier` for the\n/// authentication witness, and emit it from the `Token` contract (consumer).\n///\n/// Note that we can do this flow as we are in private were we can do oracle calls out from contracts.\n///\n///\n/// Person Contract Contract Contract\n/// Alice Alice Account Token DeFi\n/// | | | |\n/// | Defi.deposit(Token, 1000) | |\n/// |----------------->| | |\n/// | | deposit(Token, 1000) |\n/// | |---------------------------------------->|\n/// | | | |\n/// | | | transfer(Alice, Defi, 1000)\n/// | | |<---------------------|\n/// | | | |\n/// | | Check if Defi may call transfer(Alice, Defi, 1000)\n/// | |<-----------------| |\n/// | | | |\n/// | Please give me AuthWit for DeFi | |\n/// | calling transfer(Alice, Defi, 1000) | |\n/// |<-----------------| | |\n/// | | | |\n/// | | | |\n/// | AuthWit for transfer(Alice, Defi, 1000) |\n/// |----------------->| | |\n/// | | AuthWit validity | |\n/// | |----------------->| |\n/// | | | |\n/// | | throw if invalid AuthWit |\n/// | | | |\n/// | | emit AuthWit nullifier |\n/// | | | |\n/// | | transfer(Alice, Defi, 1000) |\n/// | | | |\n/// | | | |\n/// | | | success |\n/// | | |--------------------->|\n/// | | | |\n/// | | | |\n/// | | | deposit(Token, 1000)\n/// | | | |\n/// | | | |\n///\n///\n/// If we instead were in public, we cannot do the same flow. Instead we would use an authentication registry to store\n/// the messages that we have approved.\n///\n/// To approve a message, `Alice Account` can make a `set_authorized` call to the registry, to set a `message_hash` as\n/// authorized. This is essentially a mapping from `message_hash` to `true` for `Alice Contract`. Every account has its\n/// own map in the registry, so `Alice` cannot approve a message for `Bob`.\n///\n/// The `Token` contract can then try to \"spend\" the approval by calling `consume` on the registry. If the message was\n/// approved, the value is updated to `false`, and we return the success flag. For more information on the registry,\n/// see `main.nr` in `auth_registry_contract`.\n///\n/// Person Contract Contract Contract Contract\n/// Alice Alice Account Registry Token DeFi\n/// | | | | |\n/// | Registry.set_authorized(..., true) | | |\n/// |----------------->| | | |\n/// | | set_authorized(..., true) | |\n/// | |------------------->| | |\n/// | | | | |\n/// | | set authorized to true | |\n/// | | | | |\n/// | | | | |\n/// | Defi.deposit(Token, 1000) | | |\n/// |----------------->| | | |\n/// | | deposit(Token, 1000) | |\n/// | |-------------------------------------------------------------->|\n/// | | | | |\n/// | | | transfer(Alice, Defi, 1000) |\n/// | | | |<---------------------|\n/// | | | | |\n/// | | | Check if Defi may call transfer(Alice, Defi, 1000)\n/// | | |<------------------| |\n/// | | | | |\n/// | | throw if invalid AuthWit | |\n/// | | | | |\n/// | | | | |\n/// | | set authorized to false | |\n/// | | | | |\n/// | | | | |\n/// | | | AuthWit validity | |\n/// | | |------------------>| |\n/// | | | | |\n/// | | | | transfer(Alice, Defi, 1000)\n/// | | | |<-------------------->|\n/// | | | | |\n/// | | | | success |\n/// | | | |--------------------->|\n/// | | | | |\n/// | | | | deposit(Token, 1000)\n/// | | | | |\n///\n///\n/// --- FAQ ---\n/// Q: Why are we using a success flag of `poseidon2_hash_bytes(\"IS_VALID()\")` instead of just returning a boolean?\n/// A: We want to make sure that we don't accidentally return `true` if there is a collision in the function\n/// selector. By returning a hash of `IS_VALID()`, it becomes very unlikely that there is both a collision and we\n/// return a success flag.\n///\n/// Q: Why are we using static calls?\n/// A: We are using static calls to ensure that the account contract cannot re-enter. If it was a normal call, it\n/// could make a new call and do a re-entry attack. Using a static ensures that it cannot update any state.\n///\n/// Q: Would it not be cheaper to use a nullifier instead of updating state in public?\n/// A: At a quick glance, a public state update + nullifier is 96 bytes, but two state updates are 128, so it would\n/// be cheaper to use a nullifier, if this is the way it would always be done. However, if both the approval and the\n/// consumption is done in the same transaction, then we will be able to squash the updates (only final tx state diff\n/// is posted to DA), and now it is cheaper.\n///\n/// Q: Why is the chain id and the version part of the message hash?\n/// A: The chain id and the version is part of the message hash to ensure that the message is only valid on a\n/// specific chain to avoid a case where the same message could be used across multiple chains.\n\npub global IS_VALID_SELECTOR: Field = 0x47dacd73; // 4 last bytes of\n// poseidon2_hash_bytes(\"IS_VALID()\")\n\n/// A struct that represents a contract call the user can authorize. It's associated identifier is generated by\n/// serializing and hashing it. The user is expected to sign this hash to signal the contract call can be performed on\n/// their behalf\n#[authorization]\nstruct CallAuthorization {\n msg_sender: AztecAddress,\n selector: FunctionSelector,\n args_hash: Field,\n}\n\n/// A struct that represents a request to authorize a call, which is used to emit an offchain effect so the user/wallet\n/// can understand what they are being asked to sign. It is generated from a CallAuthorization by adding metadata to\n/// it, such as the selector for the authorization, the inner hash, and the actual arguments that are being passed to\n/// the function call.\n#[derive(Serialize)]\nstruct CallAuthorizationRequest {\n selector: AuthorizationSelector,\n inner_hash: Field,\n on_behalf_of: AztecAddress,\n msg_sender: AztecAddress,\n fn_selector: FunctionSelector,\n args_hash: Field,\n}\n\nunconstrained fn emit_authorization_as_offchain_effect<let N: u32>(\n authorization: CallAuthorization,\n inner_hash: Field,\n on_behalf_of: AztecAddress,\n) {\n let args: [Field; N] = load(authorization.args_hash);\n let authorization_request = CallAuthorizationRequest {\n selector: authorization.get_authorization_selector(),\n inner_hash: inner_hash,\n on_behalf_of: on_behalf_of,\n msg_sender: authorization.msg_sender,\n fn_selector: authorization.selector,\n args_hash: authorization.args_hash,\n };\n emit_offchain_effect(authorization_request.serialize().concat(args))\n}\n\n/// Assert that `on_behalf_of` has authorized the current call with a valid authentication witness\n///\n/// Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the\n/// `on_behalf_of` contract to verify that the `inner_hash` is valid.\n///\n/// Additionally, this function emits the identifying information of the call as an offchain effect so PXE can rely the\n/// information to the user/wallet in a readable way. To that effect, it is generic over N, where N is the number of\n/// arguments the authorized functions takes. This is used to load the arguments from the execution cache. This\n/// function is intended to be called via a macro, which will use the turbofish operator to specify the number of\n/// arguments.\n///\n/// @param on_behalf_of The address that has allegedly authorized the current call\npub fn assert_current_call_valid_authwit<let N: u32>(context: &mut PrivateContext, on_behalf_of: AztecAddress) {\n let args_hash: Field = context.get_args_hash();\n\n let authorization =\n CallAuthorization { msg_sender: context.maybe_msg_sender().unwrap(), selector: context.selector(), args_hash };\n let inner_hash = compute_inner_authwit_hash(authorization.serialize());\n // Safety: Offchain effects are by definition unconstrained. They are emitted via an oracle which we don't use for\n // anything besides its side effects, therefore this is safe to call.\n unsafe { emit_authorization_as_offchain_effect::<N>(authorization, inner_hash, on_behalf_of) };\n\n assert_inner_hash_valid_authwit(context, on_behalf_of, inner_hash);\n}\n\n/// Assert that a specific `inner_hash` is valid for the `on_behalf_of` address\n///\n/// Used as an internal function for `assert_current_call_valid_authwit` and can be used as a standalone function when\n/// the `inner_hash` is from a different source, e.g., say a block of text etc.\n///\n/// @param on_behalf_of The address that has allegedly authorized the current call @param inner_hash The hash of the\n/// message to authorize\npub fn assert_inner_hash_valid_authwit(context: &mut PrivateContext, on_behalf_of: AztecAddress, inner_hash: Field) {\n // We perform a static call here and not a standard one to ensure that the account contract cannot re-enter.\n let result: Field = context\n .static_call_private_function(\n on_behalf_of,\n comptime { FunctionSelector::from_signature(\"verify_private_authwit(Field)\") },\n [inner_hash],\n )\n .get_preimage();\n assert(result == IS_VALID_SELECTOR, \"Message not authorized by account\");\n // Compute the nullifier, similar computation to the outer hash, but without the chain_id and version. Those should\n // already be handled in the verification, so we just need something to nullify, that allows the same inner_hash\n // for multiple actors.\n let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash);\n context.push_nullifier_unsafe(nullifier);\n}\n\n/// Assert that `on_behalf_of` has authorized the current call in the authentication registry\n///\n/// Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the\n/// `on_behalf_of` contract to verify that the `inner_hash` is valid.\n///\n/// Note that the authentication registry will take the `msg_sender` into account as the consumer, so this will only\n/// work if the `msg_sender` is the same as the `consumer` when the `message_hash` was inserted into the registry.\n///\n/// @param on_behalf_of The address that has allegedly authorized the current call\npub unconstrained fn assert_current_call_valid_authwit_public(context: PublicContext, on_behalf_of: AztecAddress) {\n let inner_hash = compute_inner_authwit_hash([\n context.maybe_msg_sender().unwrap().to_field(),\n context.selector().to_field(),\n context.get_args_hash(),\n ]);\n assert_inner_hash_valid_authwit_public(context, on_behalf_of, inner_hash);\n}\n\n/// Assert that `on_behalf_of` has authorized a specific `inner_hash` in the authentication registry\n///\n/// Compute the `inner_hash` using the `msg_sender`, `selector` and `args_hash` and then make a call out to the\n/// `on_behalf_of` contract to verify that the `inner_hash` is valid.\n///\n/// Note that the authentication registry will take the `msg_sender` into account as the consumer, so this will only\n/// work if the `msg_sender` is the same as the `consumer` when the `message_hash` was inserted into the registry.\n///\n/// @param on_behalf_of The address that has allegedly authorized the `inner_hash`\npub unconstrained fn assert_inner_hash_valid_authwit_public(\n context: PublicContext,\n on_behalf_of: AztecAddress,\n inner_hash: Field,\n) {\n let results: [Field] = context.call_public_function(\n STANDARD_AUTH_REGISTRY_ADDRESS,\n comptime { FunctionSelector::from_signature(\"consume((Field),Field)\") },\n [on_behalf_of.to_field(), inner_hash],\n GasOpts::default(),\n );\n assert(results.len() == 1, \"Invalid response from registry\");\n assert(results[0] == IS_VALID_SELECTOR, \"Message not authorized by account\");\n}\n\n/// Compute the `message_hash` from a function call to be used by an authentication witness\n///\n/// Useful for when you need a non-account contract to approve during execution. For example if you need a contract to\n/// make a call to nested contract, e.g., contract A wants to exit token T to L1 using bridge B, so it needs to allow B\n/// to transfer T on its behalf.\n///\n/// @param caller The address of the contract that is calling the function, in the example above, this would be B\n/// @param consumer The address of the contract that is consuming the message, in the example above, this would be T\n/// @param chain_id The chain id of the chain that the message is being consumed on @param version The version of the\n/// chain that the message is being consumed on @param selector The function selector of the function that is being\n/// called @param args The arguments of the function that is being called\npub fn compute_authwit_message_hash_from_call<let N: u32>(\n caller: AztecAddress,\n consumer: AztecAddress,\n chain_id: Field,\n version: Field,\n selector: FunctionSelector,\n args: [Field; N],\n) -> Field {\n let args_hash = hash_args(args);\n let inner_hash = compute_inner_authwit_hash([caller.to_field(), selector.to_field(), args_hash]);\n compute_authwit_message_hash(consumer, chain_id, version, inner_hash)\n}\n\n/// Computes the `inner_hash` of the authentication witness\n///\n/// This is used internally, but also useful in cases where you want to compute the `inner_hash` for a specific message\n/// that is not necessarily a call, but just some \"bytes\" or text.\n///\n/// @param args The arguments to hash\npub fn compute_inner_authwit_hash<let N: u32>(args: [Field; N]) -> Field {\n poseidon2_hash_with_separator(args, DOM_SEP__AUTHWIT_INNER)\n}\n\n/// Computes the `authwit_nullifier` for a specific `on_behalf_of` and `inner_hash`\n///\n/// Using the `on_behalf_of` and the `inner_hash` to ensure that the nullifier is siloed for a specific `on_behalf_of`.\n///\n/// @param on_behalf_of The address that has authorized the `inner_hash` @param inner_hash The hash of the message to\n/// authorize\npub fn compute_authwit_nullifier(on_behalf_of: AztecAddress, inner_hash: Field) -> Field {\n poseidon2_hash_with_separator(\n [on_behalf_of.to_field(), inner_hash],\n DOM_SEP__AUTHWIT_NULLIFIER,\n )\n}\n\n/// Computes the `message_hash` for the authentication witness\n///\n/// @param consumer The address of the contract that is consuming the message @param chain_id The chain id of the chain\n/// that the message is being consumed on @param version The version of the chain that the message is being consumed on\n/// @param inner_hash The hash of the \"inner\" message that is being consumed\npub fn compute_authwit_message_hash(\n consumer: AztecAddress,\n chain_id: Field,\n version: Field,\n inner_hash: Field,\n) -> Field {\n poseidon2_hash_with_separator(\n [consumer.to_field(), chain_id, version, inner_hash],\n DOM_SEP__AUTHWIT_OUTER,\n )\n}\n\n/// Helper function to set the authorization status of a message hash\n///\n/// Wraps a public call to the authentication registry to set the authorization status of a `message_hash`\n///\n/// @param message_hash The hash of the message to authorize @param authorize True if the message should be authorized,\n/// false if it should be revoked\npub unconstrained fn set_authorized(context: PublicContext, message_hash: Field, authorize: bool) {\n let res = context.call_public_function(\n STANDARD_AUTH_REGISTRY_ADDRESS,\n comptime { FunctionSelector::from_signature(\"set_authorized(Field,bool)\") },\n [message_hash, authorize as Field],\n GasOpts::default(),\n );\n assert(res.len() == 0);\n}\n\n/// Helper function to reject all authwits\n///\n/// Wraps a public call to the authentication registry to set the `reject_all` flag\n///\n/// @param reject True if all authwits should be rejected, false otherwise\npub unconstrained fn set_reject_all(context: PublicContext, reject: bool) {\n let res = context.call_public_function(\n STANDARD_AUTH_REGISTRY_ADDRESS,\n comptime { FunctionSelector::from_signature(\"set_reject_all(bool)\") },\n [reject as Field],\n GasOpts::default(),\n );\n assert(res.len() == 0);\n}\n"
|
|
2666
2674
|
},
|
|
2667
2675
|
"6": {
|
|
@@ -3297,7 +3305,7 @@
|
|
|
3297
3305
|
"start": 86984
|
|
3298
3306
|
}
|
|
3299
3307
|
],
|
|
3300
|
-
"path": "/
|
|
3308
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/context/private_context.nr",
|
|
3301
3309
|
"source": "use crate::{\n context::{inputs::PrivateContextInputs, NoteExistenceRequest, NullifierExistenceRequest, ReturnsHash},\n hash::{hash_args, hash_calldata_array},\n keys::constants::{NULLIFIER_INDEX, NUM_KEY_TYPES, OUTGOING_INDEX, public_key_domain_separators},\n messaging::process_l1_to_l2_message,\n oracle::{\n block_header::get_block_header_at,\n call_private_function::call_private_function_internal,\n execution_cache,\n key_validation_request::get_key_validation_request,\n logs::notify_created_contract_class_log,\n notes::notify_nullified_note,\n nullifiers::notify_created_nullifier,\n public_call::assert_valid_public_call_data,\n tx_phase::{is_execution_in_revertible_phase, notify_revertible_phase_start},\n },\n};\nuse crate::logging::aztecnr_trace_log_format;\nuse crate::protocol::{\n abis::{\n block_header::BlockHeader,\n call_context::CallContext,\n function_selector::FunctionSelector,\n gas_settings::GasSettings,\n log_hash::LogHash,\n note_hash::NoteHash,\n nullifier::Nullifier,\n private_call_request::PrivateCallRequest,\n private_circuit_public_inputs::PrivateCircuitPublicInputs,\n private_log::{PrivateLog, PrivateLogData},\n public_call_request::PublicCallRequest,\n validation_requests::{KeyValidationRequest, KeyValidationRequestAndSeparator},\n },\n address::{AztecAddress, EthAddress},\n constants::{\n CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL,\n MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,\n MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL,\n MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL, MAX_TX_LIFETIME,\n NULL_MSG_SENDER_CONTRACT_ADDRESS, PRIVATE_LOG_CIPHERTEXT_LEN,\n },\n hash::compute_contract_class_log_hash,\n messaging::l2_to_l1_message::L2ToL1Message,\n side_effect::{Counted, scoped::Scoped},\n traits::{Empty, ToField},\n utils::arrays::{ClaimedLengthArray, trimmed_array_length_hint},\n};\n\n/// # PrivateContext\n///\n/// The **main interface** between an #[external(\"private\")] function and the Aztec blockchain.\n///\n/// An instance of the PrivateContext is initialized automatically at the outset of every private function, within the\n/// #[external(\"private\")] macro, so you'll never need to consciously instantiate this yourself.\n///\n/// The instance is always named `context`, and it is always be available within the body of every\n/// #[external(\"private\")] function in your smart contract.\n///\n/// > For those used to \"vanilla\" Noir, it might be jarring to have access to > `context` without seeing a declaration\n/// `let context = PrivateContext::new(...)` > within the body of your function. This is just a consequence of using >\n/// macros to tidy-up verbose boilerplate. You can use `nargo expand` to > expand all macros, if you dare.\n///\n/// Typical usage for a smart contract developer will be to call getter methods of the PrivateContext.\n///\n/// _Pushing_ data and requests to the context is mostly handled within aztec-nr's own functions, so typically a smart\n/// contract developer won't need to call any setter methods directly.\n///\n/// > Advanced users might occasionally wish to push data to the context > directly for lower-level control. If you\n/// find yourself doing this, please > open an issue on GitHub to describe your use case: it might be that > new\n/// functionality should be added to aztec-nr.\n///\n/// ## Responsibilities\n/// - Exposes contextual data to a private function:\n/// - Data relating to how this private function was called.\n/// - msg_sender\n/// - this_address - (the contract address of the private function being executed)\n/// - See `CallContext` for more data.\n/// - Data relating to the transaction in which this private function is being executed.\n/// - chain_id\n/// - version\n/// - gas_settings\n/// - Provides state access:\n/// - Access to the \"Anchor block\" header. Recall, a private function cannot read from the \"current\" block header, but\n/// must read from some historical block header, because as soon as private function execution begins (asynchronously,\n/// on a user's device), the public state of the chain (the \"current state\") will have progressed forward. We call this\n/// reference the \"Anchor block\". See `BlockHeader`.\n/// - Enables consumption of L1->L2 messages.\n/// - Enables calls to functions of other smart contracts:\n/// - Private function calls\n/// - Enqueueing of public function call requests (Since public functions are executed at a later time, by a block\n/// proposer, we say they are \"enqueued\").\n/// - Writes data to the blockchain:\n/// - New notes\n/// - New nullifiers\n/// - Private logs (for sending encrypted note contents or encrypted events)\n/// - New L2->L1 messages.\n/// - Provides args to the private function (handled by the #[external(\"private\")] macro).\n/// - Returns the return values of this private function (handled by the\n/// #[external(\"private\")] macro).\n/// - Makes Key Validation Requests.\n/// - Private functions are not allowed to see master secret keys, because we do not trust them. They are instead given\n/// \"app-siloed\" secret keys with a claim that they relate to a master public key. They can then request validation of\n/// this claim, by making a \"key validation request\" to the protocol's kernel circuits (which _are_ allowed to see\n/// certain master secret keys).\n///\n/// ## Advanced Responsibilities\n///\n/// - Ultimately, the PrivateContext is responsible for constructing the PrivateCircuitPublicInputs of the private\n/// function being executed. All private functions on Aztec must have public inputs which adhere to the rigid layout of\n/// the PrivateCircuitPublicInputs, in order to be compatible with the protocol's kernel circuits. A well-known\n/// misnomer:\n/// - \"public inputs\" contain both inputs and outputs of this function.\n/// - By \"outputs\" we mean a lot more side-effects than just the \"return values\" of the function.\n/// - Most of the so-called \"public inputs\" are kept _private_, and never leak to the outside world, because they are\n/// 'swallowed' by the protocol's kernel circuits before the tx is sent to the network. Only the following are exposed\n/// to the outside world:\n/// - New note_hashes\n/// - New nullifiers\n/// - New private logs\n/// - New L2->L1 messages\n/// - New enqueued public function call requests All the above-listed arrays of side-effects can be padded by the\n/// user's wallet (through instructions to the kernel circuits, via the PXE) to obscure their true lengths.\n///\n/// ## Syntax Justification\n///\n/// Both user-defined functions _and_ most functions in aztec-nr need access to the PrivateContext instance to\n/// read/write data. This is why you'll see the arguably-ugly pervasiveness of the \"context\" throughout your smart\n/// contract and the aztec-nr library. For example, `&mut context` is prevalent. In some languages, you can access and\n/// mutate a global variable (such as a PrivateContext instance) from a function without polluting the function's\n/// parameters. With Noir, a function must explicitly pass control of a mutable variable to another function, by\n/// reference. Since many functions in aztec-nr need to be able to push new data to the PrivateContext, they need to be\n/// handed a mutable reference _to_ the context as a parameter. For example, `Context` is prevalent as a generic\n/// parameter, to give better type safety at compile time. Many `aztec-nr` functions don't make sense if they're called\n/// in a particular runtime (private, public or utility), and so are intentionally only implemented over certain\n/// [Private|Public|Utility]Context structs. This gives smart contract developers a much faster feedback loop if\n/// they're making a mistake, as an error will be thrown by the LSP or when they compile their contract.\n///\n#[derive(Eq)]\npub struct PrivateContext {\n // docs:start:private-context\n inputs: PrivateContextInputs,\n side_effect_counter: u32,\n\n min_revertible_side_effect_counter: u32,\n is_fee_payer: bool,\n\n args_hash: Field,\n return_hash: Field,\n\n pub(crate) expiration_timestamp: u64,\n\n pub(crate) note_hash_read_requests: BoundedVec<Scoped<Counted<Field>>, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL>,\n pub(crate) nullifier_read_requests: BoundedVec<Scoped<Counted<Field>>, MAX_NULLIFIER_READ_REQUESTS_PER_CALL>,\n key_validation_requests_and_separators: BoundedVec<KeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL>,\n\n pub(crate) note_hashes: BoundedVec<Counted<NoteHash>, MAX_NOTE_HASHES_PER_CALL>,\n pub(crate) nullifiers: BoundedVec<Counted<Nullifier>, MAX_NULLIFIERS_PER_CALL>,\n\n pub(crate) private_call_requests: BoundedVec<PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,\n public_call_requests: BoundedVec<Counted<PublicCallRequest>, MAX_ENQUEUED_CALLS_PER_CALL>,\n public_teardown_call_request: PublicCallRequest,\n l2_to_l1_msgs: BoundedVec<Counted<L2ToL1Message>, MAX_L2_TO_L1_MSGS_PER_CALL>,\n // docs:end:private-context\n\n // Header of a block whose state is used during private execution (not the block the transaction is included in).\n pub(crate) anchor_block_header: BlockHeader,\n\n private_logs: BoundedVec<Counted<PrivateLogData>, MAX_PRIVATE_LOGS_PER_CALL>,\n contract_class_logs_hashes: BoundedVec<Counted<LogHash>, MAX_CONTRACT_CLASS_LOGS_PER_CALL>,\n\n // Contains the last key validation request for each key type. This is used to cache the last request and avoid\n // fetching the same request multiple times. The index of the array corresponds to the key type (0 nullifier, 1\n // incoming, 2 outgoing, 3 tagging).\n last_key_validation_requests: [Option<KeyValidationRequest>; NUM_KEY_TYPES],\n\n expected_non_revertible_side_effect_counter: u32,\n expected_revertible_side_effect_counter: u32,\n}\n\nimpl PrivateContext {\n pub fn new(inputs: PrivateContextInputs, args_hash: Field) -> PrivateContext {\n PrivateContext {\n inputs,\n side_effect_counter: inputs.start_side_effect_counter + 1,\n min_revertible_side_effect_counter: 0,\n is_fee_payer: false,\n args_hash,\n return_hash: 0,\n expiration_timestamp: inputs.anchor_block_header.timestamp() + MAX_TX_LIFETIME,\n note_hash_read_requests: BoundedVec::new(),\n nullifier_read_requests: BoundedVec::new(),\n key_validation_requests_and_separators: BoundedVec::new(),\n note_hashes: BoundedVec::new(),\n nullifiers: BoundedVec::new(),\n anchor_block_header: inputs.anchor_block_header,\n private_call_requests: BoundedVec::new(),\n public_call_requests: BoundedVec::new(),\n public_teardown_call_request: PublicCallRequest::empty(),\n l2_to_l1_msgs: BoundedVec::new(),\n private_logs: BoundedVec::new(),\n contract_class_logs_hashes: BoundedVec::new(),\n last_key_validation_requests: [Option::none(); NUM_KEY_TYPES],\n expected_non_revertible_side_effect_counter: 0,\n expected_revertible_side_effect_counter: 0,\n }\n }\n\n /// Returns the contract address that initiated this function call.\n ///\n /// This is similar to `msg.sender` in Solidity (hence the name).\n ///\n /// Important Note: Since Aztec doesn't have a concept of an EoA (Externally-owned Account), the msg_sender is\n /// \"none\" for the first function call of every transaction. The first function call of a tx is likely to be a call\n /// to the user's account contract, so this quirk will most often be handled by account contract developers.\n ///\n /// # Returns\n /// * `Option<AztecAddress>` - The address of the smart contract that called this function (be it an app contract\n /// or a user's account contract). Returns `Option<AztecAddress>::none` for the first function call of the tx. No\n /// other _private_ function calls in the tx will have a `none` msg_sender, but _public_ function calls might (see\n /// the PublicContext).\n pub fn maybe_msg_sender(self) -> Option<AztecAddress> {\n let maybe_msg_sender = self.inputs.call_context.msg_sender;\n if maybe_msg_sender == NULL_MSG_SENDER_CONTRACT_ADDRESS {\n Option::none()\n } else {\n Option::some(maybe_msg_sender)\n }\n }\n\n /// Returns the contract address of the current function being executed.\n ///\n /// This is equivalent to `address(this)` in Solidity (hence the name). Use this to identify the current contract's\n /// address, commonly needed for access control or when interacting with other contracts.\n ///\n /// # Returns\n /// * `AztecAddress` - The contract address of the current function being executed.\n ///\n pub fn this_address(self) -> AztecAddress {\n self.inputs.call_context.contract_address\n }\n\n /// Returns the chain ID of the current network.\n ///\n /// This is similar to `block.chainid` in Solidity. Returns the unique identifier for the blockchain network this\n /// transaction is executing on.\n ///\n /// Helps prevent cross-chain replay attacks. Useful if implementing multi-chain contract logic.\n ///\n /// # Returns\n /// * `Field` - The chain ID as a field element\n ///\n pub fn chain_id(self) -> Field {\n self.inputs.tx_context.chain_id\n }\n\n /// Returns the Aztec protocol version that this transaction is executing under. Different versions may have\n /// different rules, opcodes, or cryptographic primitives.\n ///\n /// This is similar to how Ethereum has different EVM versions.\n ///\n /// Useful for forward/backward compatibility checks\n ///\n /// Not to be confused with contract versions; this is the protocol version.\n ///\n /// # Returns\n /// * `Field` - The protocol version as a field element\n ///\n pub fn version(self) -> Field {\n self.inputs.tx_context.version\n }\n\n /// Returns the gas settings for the current transaction.\n ///\n /// This provides information about gas limits and pricing for the transaction, similar to `tx.gasprice` and gas\n /// limits in Ethereum. However, Aztec has a more sophisticated gas model with separate accounting for L2\n /// computation and data availability (DA) costs.\n ///\n /// # Returns\n /// * `GasSettings` - Struct containing gas limits and fee information\n ///\n pub fn gas_settings(self) -> GasSettings {\n self.inputs.tx_context.gas_settings\n }\n\n /// Returns the function selector of the currently executing function.\n ///\n /// Low-level function: Ordinarily, smart contract developers will not need to access this.\n ///\n /// This is similar to `msg.sig` in Solidity, which returns the first 4 bytes of the function signature. In Aztec,\n /// the selector uniquely identifies which function within the contract is being called.\n ///\n /// # Returns\n /// * `FunctionSelector` - The 4-byte function identifier\n ///\n /// # Advanced\n /// Only #[external(\"private\")] functions have a function selector as a protocol- enshrined concept. The function\n /// selectors of private functions are baked into the preimage of the contract address, and are used by the\n /// protocol's kernel circuits to identify each private function and ensure the correct one is being executed.\n ///\n /// Used internally for function dispatch and call verification.\n ///\n pub fn selector(self) -> FunctionSelector {\n self.inputs.call_context.function_selector\n }\n\n /// Returns whether this call is being executed as part of a static call.\n ///\n /// Similar to Solidity's `STATICCALL`, a static call is read-only: neither this function nor any of its nested\n /// calls may emit side-effects (new notes, nullifiers, logs, L2->L1 messages, etc.). A call is considered static\n /// if it was invoked as a static call or if any of its ancestor calls were.\n ///\n /// # Returns\n /// * `bool` - `true` if this call (or an ancestor call) is a static call.\n ///\n pub fn is_static_call(self) -> bool {\n self.inputs.call_context.is_static_call\n }\n\n /// Returns the hash of the arguments passed to the current function.\n ///\n /// Very low-level function: You shouldn't need to call this. The #[external(\"private\")] macro calls this, and it\n /// makes the arguments neatly available to the body of your private function.\n ///\n /// # Returns\n /// * `Field` - Hash of the function arguments\n ///\n /// # Advanced\n /// * Arguments are hashed to reduce proof size and verification time\n /// * Enables efficient argument passing in recursive function calls\n /// * The hash can be used to retrieve the original arguments from the PXE.\n ///\n pub fn get_args_hash(self) -> Field {\n self.args_hash\n }\n\n /// Returns the current value of the side-effect counter, i.e. the counter that will be assigned to the next\n /// side-effect emitted by this function.\n ///\n /// Low-level function: Ordinarily, smart contract developers will not need to access this. See `next_counter` for\n /// details on how side-effect counters are assigned and why they exist.\n ///\n /// # Returns\n /// * `u32` - The current side-effect counter.\n ///\n pub fn get_side_effect_counter(self) -> u32 {\n self.side_effect_counter\n }\n\n /// Pushes a new note_hash to the Aztec blockchain's global Note Hash Tree (a state tree).\n ///\n /// A note_hash is a commitment to a piece of private state.\n ///\n /// Low-level function: Ordinarily, smart contract developers will not need to manually call this. Aztec-nr's state\n /// variables (see `../state_vars/`) are designed to understand when to create and push new note hashes.\n ///\n /// # Arguments\n /// * `note_hash` - The new note_hash.\n ///\n /// # Advanced\n /// From here, the protocol's kernel circuits will take over and insert the note_hash into the protocol's \"note\n /// hash tree\" (in the Base Rollup circuit). Before insertion, the protocol will:\n /// - \"Silo\" the `note_hash` with the contract address of this function, to yield a `siloed_note_hash`. This\n /// prevents state collisions between different smart contracts.\n /// - Ensure uniqueness of the `siloed_note_hash`, to prevent Faerie-Gold attacks, by hashing the\n /// `siloed_note_hash` with a unique value, to yield a `unique_siloed_note_hash` (see the protocol spec for more).\n ///\n /// In addition to calling this function, aztec-nr provides the contents of the newly-created note to the PXE, via\n /// the `notify_created_note` oracle.\n ///\n /// > Advanced users might occasionally wish to push data to the context > directly for lower-level control. If you\n /// find yourself doing this, > please open an issue on GitHub to describe your use case: it might be > that new\n /// functionality should be added to aztec-nr.\n ///\n pub fn push_note_hash(&mut self, note_hash: Field) {\n self.note_hashes.push(Counted::new(note_hash, self.next_counter()));\n }\n\n /// Creates a new [nullifier](crate::nullifier).\n ///\n /// ## Safety\n ///\n /// This is a low-level function that must be used with great care to avoid subtle corruption of contract state.\n /// Instead of calling this function, consider using the higher-level [`crate::state_vars::SingleUseClaim`].\n ///\n /// In particular, callers must ensure all nullifiers created by a contract are properly domain-separated, so that\n /// unrelated components don't interfere with one another (e.g. a transaction nullifier accidentally marking a\n /// variable as initialized). Only [`PrivateContext::push_nullifier_for_note_hash`] should be used for note\n /// nullifiers, never this one.\n ///\n /// ## Advanced\n ///\n /// The raw `nullifier` is not what is inserted into the Aztec state tree: it will be first siloed by contract\n /// address via [`crate::protocol::hash::compute_siloed_nullifier`] in order to prevent accidental or malicious\n /// interference of nullifiers from different contracts.\n pub fn push_nullifier_unsafe(&mut self, nullifier: Field) {\n notify_created_nullifier(nullifier);\n self.nullifiers.push(Nullifier { value: nullifier, note_hash: 0 }.count(self.next_counter()));\n }\n\n /// Creates a new [nullifier](crate::nullifier) associated with a note.\n ///\n /// This is a variant of [`PrivateContext::push_nullifier_unsafe`] that is used for note nullifiers, i.e.\n /// nullifiers that correspond to a note. If a note and its nullifier are created in the same transaction, then\n /// the private kernels will 'squash' these values, deleting them both as if they never existed and reducing\n /// transaction fees.\n ///\n /// The `nullification_note_hash` must be the result of calling\n /// [`crate::note::utils::compute_confirmed_note_hash_for_nullification`] for pending notes, and `0` for settled\n /// notes (which cannot be squashed).\n ///\n /// ## Safety\n ///\n /// This is a low-level function that must be used with great care to avoid subtle corruption of contract state.\n /// Instead of calling this function, consider using the higher-level [`crate::note::lifecycle::destroy_note`].\n ///\n /// The precautions listed for [`PrivateContext::push_nullifier_unsafe`] apply here as well, and callers should\n /// additionally ensure `nullification_note_hash` corresponds to a note emitted by this contract, with its hash\n /// computed in the same transaction execution phase as the call to this function. Finally, only this function\n /// should be used for note nullifiers, never [`PrivateContext::push_nullifier_unsafe`].\n ///\n /// Failure to do these things can result in unprovable contexts, accidental deletion of notes, or double-spend\n /// attacks.\n pub fn push_nullifier_for_note_hash(&mut self, nullifier: Field, nullification_note_hash: Field) {\n let nullifier_counter = self.next_counter();\n notify_nullified_note(nullifier, nullification_note_hash, nullifier_counter);\n self.nullifiers.push(Nullifier { value: nullifier, note_hash: nullification_note_hash }.count(\n nullifier_counter,\n ));\n }\n\n /// Returns the anchor block header - the historical block header that this private function is reading from.\n ///\n /// A private function CANNOT read from the \"current\" block header, but must read from some older block header,\n /// because as soon as private function execution begins (asynchronously, on a user's device), the public state of\n /// the chain (the \"current state\") will have progressed forward.\n ///\n /// # Returns\n /// * `BlockHeader` - The anchor block header.\n ///\n /// # Advanced\n /// * All private functions of a tx read from the same anchor block header.\n /// * The protocol asserts that the `expiration_timestamp` of every tx is at most 24 hours beyond the timestamp of\n /// the tx's chosen anchor block header. This enables the network's nodes to safely prune old txs from the mempool.\n /// Therefore, the chosen block header _must_ be one from within the last 24 hours.\n ///\n pub fn get_anchor_block_header(self) -> BlockHeader {\n self.anchor_block_header\n }\n\n /// Returns the header of any historical block at or before the anchor block.\n ///\n /// This enables private contracts to access information from even older blocks than the anchor block header.\n ///\n /// Useful for time-based contract logic that needs to compare against multiple historical points.\n ///\n /// # Arguments\n /// * `block_number` - The block number to retrieve (must be <= anchor block number)\n ///\n /// # Returns\n /// * `BlockHeader` - The header of the requested historical block\n ///\n /// # Advanced\n /// This function uses an oracle to fetch block header data from the user's PXE. Depending on how much blockchain\n /// data the user's PXE has been set up to store, this might require a query from the PXE to another Aztec node to\n /// get the data. > This is generally true of all oracle getters (see `../oracle`).\n ///\n /// Each block header gets hashed and stored as a leaf in the protocol's Archive Tree. In fact, the i-th block\n /// header gets stored at the i-th leaf index of the Archive Tree. Behind the scenes, this `get_block_header_at`\n /// function will add Archive Tree merkle-membership constraints (~3k) to your smart contract function's circuit,\n /// to prove existence of the block header in the Archive Tree.\n ///\n /// Note: we don't do any caching, so avoid making duplicate calls for the same block header, because each call\n /// will add duplicate constraints.\n ///\n /// Calling this function is more expensive (constraint-wise) than getting the anchor block header (via\n /// `get_block_header`). This is because the anchor block's merkle membership proof is handled by Aztec's protocol\n /// circuits, and is only performed once for the entire tx because all private functions of a tx share a common\n /// anchor block header. Therefore, the cost (constraint-wise) of calling `get_block_header` is effectively free.\n ///\n pub fn get_block_header_at(self, block_number: u32) -> BlockHeader {\n get_block_header_at(block_number, self)\n }\n\n /// Sets the hash of the return values for this private function.\n ///\n /// Very low-level function: this is called by the #[external(\"private\")] macro.\n ///\n /// # Arguments\n /// * `serialized_return_values` - The serialized return values as a field array\n ///\n pub fn set_return_hash<let N: u32>(&mut self, serialized_return_values: [Field; N]) {\n let return_hash = hash_args(serialized_return_values);\n self.return_hash = return_hash;\n execution_cache::store(serialized_return_values, return_hash);\n }\n\n /// Builds the PrivateCircuitPublicInputs for this private function, to ensure compatibility with the protocol's\n /// kernel circuits.\n ///\n /// Very low-level function: This function is automatically called by the #[external(\"private\")] macro.\n pub fn finish(self) -> PrivateCircuitPublicInputs {\n PrivateCircuitPublicInputs {\n call_context: self.inputs.call_context,\n args_hash: self.args_hash,\n returns_hash: self.return_hash,\n min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,\n is_fee_payer: self.is_fee_payer,\n expiration_timestamp: self.expiration_timestamp,\n note_hash_read_requests: ClaimedLengthArray::from_bounded_vec(self.note_hash_read_requests),\n nullifier_read_requests: ClaimedLengthArray::from_bounded_vec(self.nullifier_read_requests),\n key_validation_requests_and_separators: ClaimedLengthArray::from_bounded_vec(\n self.key_validation_requests_and_separators,\n ),\n note_hashes: ClaimedLengthArray::from_bounded_vec(self.note_hashes),\n nullifiers: ClaimedLengthArray::from_bounded_vec(self.nullifiers),\n private_call_requests: ClaimedLengthArray::from_bounded_vec(self.private_call_requests),\n public_call_requests: ClaimedLengthArray::from_bounded_vec(self.public_call_requests),\n public_teardown_call_request: self.public_teardown_call_request,\n l2_to_l1_msgs: ClaimedLengthArray::from_bounded_vec(self.l2_to_l1_msgs),\n start_side_effect_counter: self.inputs.start_side_effect_counter,\n end_side_effect_counter: self.side_effect_counter,\n private_logs: ClaimedLengthArray::from_bounded_vec(self.private_logs),\n contract_class_logs_hashes: ClaimedLengthArray::from_bounded_vec(self.contract_class_logs_hashes),\n anchor_block_header: self.anchor_block_header,\n tx_context: self.inputs.tx_context,\n expected_non_revertible_side_effect_counter: self.expected_non_revertible_side_effect_counter,\n expected_revertible_side_effect_counter: self.expected_revertible_side_effect_counter,\n protocol_nullifier: self.inputs.protocol_nullifier,\n }\n }\n\n /// Designates this contract as the fee payer for the transaction.\n ///\n /// Unlike Ethereum, where the transaction sender always pays fees, Aztec allows any contract to voluntarily pay\n /// transaction fees. This enables patterns like sponsored transactions or fee abstraction where users don't need\n /// to hold fee-juice themselves. (Fee juice is a fee-paying asset for Aztec).\n ///\n /// Only one contract per transaction can declare itself as the fee payer, and it must have sufficient fee-juice\n /// balance (>= the gas limits specified in the TxContext) by the time we reach the public setup phase of the tx.\n ///\n /// The fee payer must be elected during the setup (non-revertible) phase, i.e. before\n /// [`end_setup`](PrivateContext::end_setup) is called - this function asserts so. This is because any compensation\n /// collected by the fee payer during the revertible phase can be discarded if a public call later reverts, while\n /// the protocol still debits the fee payer's fee-juice balance. Note that `end_setup` does not need to be called\n /// by the electing function itself: it can be called later in the transaction (e.g. by the fee-juice contract when\n /// claiming fee juice that pays for the very same transaction).\n pub fn set_as_fee_payer(&mut self) {\n assert(!self.in_revertible_phase(), \"fee payer must be elected during the setup phase\");\n aztecnr_trace_log_format!(\"Setting {0} as fee payer\")([self.this_address().to_field()]);\n self.is_fee_payer = true;\n }\n\n /// Returns whether execution is currently in the revertible (app) phase of the transaction.\n ///\n /// A transaction is in the revertible phase if [`end_setup`](PrivateContext::end_setup) has already been called -\n /// potentially by a different function of the same transaction.\n pub fn in_revertible_phase(&mut self) -> bool {\n let current_counter = self.side_effect_counter;\n\n // Safety: Kernel will validate that the claim is correct by validating the expected counters.\n let is_revertible = unsafe { is_execution_in_revertible_phase(current_counter) };\n\n if is_revertible {\n if (self.expected_revertible_side_effect_counter == 0)\n | (current_counter < self.expected_revertible_side_effect_counter) {\n self.expected_revertible_side_effect_counter = current_counter;\n }\n } else if current_counter > self.expected_non_revertible_side_effect_counter {\n self.expected_non_revertible_side_effect_counter = current_counter;\n }\n\n is_revertible\n }\n\n /// Declares the end of the \"setup phase\" of this tx.\n ///\n /// Only one function per tx can declare the end of the setup phase.\n ///\n /// Niche function: Only wallet developers and paymaster contract developers (aka Fee-payment contracts) will need\n /// to make use of this function.\n ///\n /// Aztec supports a three-phase execution model: setup, app logic, teardown. The phases exist to enable a fee\n /// payer to take on the risk of paying a transaction fee, safe in the knowledge that their payment (in whatever\n /// token or method the user chooses) will succeed, regardless of whether the app logic will succeed. The \"setup\"\n /// phase enables such a payment to be made, because the setup phase _cannot revert_: a reverting function within\n /// the setup phase would result in an invalid block which cannot be proven. Any side-effects generated during that\n /// phase are guaranteed to be inserted into Aztec's state trees (except for squashed notes & nullifiers, of\n /// course).\n ///\n /// Even though the end of the setup phase is declared within a private function, you might have noticed that\n /// _public_ functions can also execute within the setup phase. This is because any public function calls which\n /// were enqueued _within the setup phase_ by a private function are considered part of the setup phase.\n ///\n /// # Advanced\n /// * Sets the minimum revertible side effect counter of this tx to be the PrivateContext's _current_ side effect\n /// counter.\n ///\n pub fn end_setup(&mut self) {\n // We bump the counter twice: once so that `min_revertible_side_effect_counter` sits strictly above any\n // non-revertible side effect counter (including queries made via `in_revertible_phase` before this call), and\n // once more so that the next revertible side effect counter is strictly greater than\n // `min_revertible_side_effect_counter`. This ensures `min_revertible_side_effect_counter` occupies a gap that\n // no side effect takes, which the kernel relies on when validating the phase split.\n self.side_effect_counter += 1;\n self.min_revertible_side_effect_counter = self.side_effect_counter;\n self.side_effect_counter += 1;\n\n aztecnr_trace_log_format!(\n \"Ending setup, minimum revertible side effect counter is {0}\",\n )(\n [self.min_revertible_side_effect_counter as Field],\n );\n notify_revertible_phase_start(self.min_revertible_side_effect_counter);\n }\n\n /// Sets a deadline (an \"include-by timestamp\") for when this transaction must be included in a block.\n ///\n /// Other functions in this tx might call this setter with differing values for the include-by timestamp. To ensure\n /// that all functions' deadlines are met, the _minimum_ of all these include-by timestamps will be exposed when\n /// this tx is submitted to the network.\n ///\n /// If the transaction is not included in a block by its include-by timestamp, it becomes invalid and it will never\n /// be included.\n ///\n /// This expiry timestamp is publicly visible. See the \"Advanced\" section for privacy concerns.\n ///\n /// # Arguments\n /// * `expiration_timestamp` - Unix timestamp (seconds) deadline for inclusion. The include-by timestamp of this tx\n /// will be _at most_ the timestamp specified.\n ///\n /// # Advanced\n /// * If multiple functions set differing `expiration_timestamp`s, the kernel circuits will set it to be the\n /// _minimum_ of the two. This ensures the tx expiry requirements of all functions in the tx are met.\n /// * Rollup circuits will reject expired txs.\n /// * The protocol enforces that all transactions must be included within 24 hours of their chosen anchor block's\n /// timestamp, to enable safe mempool pruning.\n /// * The DelayedPublicMutable design makes heavy use of this functionality, to enable private functions to read\n /// public state.\n /// * A sophisticated Wallet should cleverly set an include-by timestamp to improve the privacy of the user and the\n /// network as a whole. For example, if a contract interaction sets include-by to some publicly-known value (e.g.\n /// the time when a contract upgrades), then the wallet might wish to set an even lower one to avoid revealing that\n /// this tx is interacting with said contract. Ideally, all wallets should standardize on an approach in order to\n /// provide users with a large privacy set -- although the exact approach\n /// will need to be discussed. Wallets that deviate from a standard might accidentally reveal which wallet each\n /// transaction originates from.\n ///\n // docs:start:expiration-timestamp\n pub fn set_expiration_timestamp(&mut self, expiration_timestamp: u64) {\n // docs:end:expiration-timestamp\n self.expiration_timestamp = std::cmp::min(self.expiration_timestamp, expiration_timestamp);\n }\n\n /// Asserts that a note has been created.\n ///\n /// This function will cause the transaction to fail unless the requested note exists. This is the preferred\n /// mechanism for performing this check, and the only one that works for pending notes.\n ///\n /// ## Pending Notes\n ///\n /// Both settled notes (created in prior transactions) and pending notes (created in the current transaction) will\n /// be considered by this function. Pending notes must have been created **before** this call is made for the check\n /// to pass.\n ///\n /// ## Historical Notes\n ///\n /// If you need to assert that a note existed _by some specific block in the past_, instead of simply proving that\n /// it exists by the current anchor block, use [`crate::history::note::assert_note_existed_by`] instead.\n ///\n /// ## Cost\n ///\n /// This uses up one of the call's kernel note hash read requests, which are limited. Like all kernel requests,\n /// proving time costs are only incurred when the total number of requests exceeds the kernel's capacity, requiring\n /// an additional invocation of the kernel reset circuit.\n pub fn assert_note_exists(&mut self, note_existence_request: NoteExistenceRequest) {\n // Note that the `note_hash_read_requests` array does not hold `NoteExistenceRequest` objects, but rather a\n // custom kernel type. We convert from the aztec-nr type into it.\n\n let note_hash = note_existence_request.note_hash();\n let contract_address = note_existence_request.maybe_contract_address().unwrap_or(AztecAddress::zero());\n\n let side_effect = Scoped::new(\n Counted::new(note_hash, self.next_counter()),\n contract_address,\n );\n\n self.note_hash_read_requests.push(side_effect);\n }\n\n /// Asserts that a nullifier has been emitted.\n ///\n /// This function will cause the transaction to fail unless the requested nullifier exists. This is the preferred\n /// mechanism for performing this check, and the only one that works for pending nullifiers.\n ///\n /// ## Pending Nullifiers\n ///\n /// Both settled nullifiers (emitted in prior transactions) and pending nullifiers (emitted in the current\n /// transaction) will be considered by this function. Pending nullifiers must have been emitted **before** this\n /// call is made for the check to pass.\n ///\n /// ## Historical Nullifiers\n ///\n /// If you need to assert that a nullifier existed _by some specific block in the past_, instead of simply proving\n /// that it exists by the current anchor block, use [`crate::history::nullifier::assert_nullifier_existed_by`]\n /// instead.\n ///\n /// ## Public vs Private\n ///\n /// In general, it is unsafe to check for nullifier non-existence in private, as that will not consider the\n /// possibility of the nullifier having been emitted in any transaction between the anchor block and the inclusion\n /// block. Private functions instead prove existence via this function and 'prove' non-existence by _emitting_ the\n /// nullifer, which would cause the transaction to fail if the nullifier existed.\n ///\n /// This is not the case in public functions, which do have access to the tip of the blockchain and so can reliably\n /// prove whether a nullifier exists or not via\n /// [`crate::context::public_context::PublicContext::nullifier_exists_unsafe`].\n ///\n /// ## Cost\n ///\n /// This uses up one of the call's kernel nullifier read requests, which are limited. Like all kernel requests,\n /// proving time costs are only incurred when the total number of requests exceeds the kernel's capacity, requiring\n /// an additional invocation of the kernel reset circuit.\n pub fn assert_nullifier_exists(&mut self, nullifier_existence_request: NullifierExistenceRequest) {\n let nullifier = nullifier_existence_request.nullifier();\n let contract_address = nullifier_existence_request.maybe_contract_address().unwrap_or(AztecAddress::zero());\n\n let request = Scoped::new(\n Counted::new(nullifier, self.next_counter()),\n contract_address,\n );\n\n self.nullifier_read_requests.push(request);\n }\n\n /// Requests the app-siloed nullifier hiding key (nhk_app) for the given (hashed) master nullifier public key\n /// (npk_m), from the user's PXE.\n ///\n /// Advanced function: Only needed if you're designing your own notes and/or nullifiers.\n ///\n /// Contracts are not allowed to compute nullifiers for other contracts, as that would let them read parts of their\n /// private state. Because of this, a contract is only given an \"app-siloed key\", which is constructed by\n /// hashing the user's master nullifier hiding key with the contract's address. However, because contracts cannot\n /// be trusted with a user's master nullifier hiding key (because we don't know which contracts are honest or\n /// malicious), the PXE refuses to provide any master secret keys to any app smart contract function. This means\n /// app functions are unable to prove that the derivation of an app-siloed nullifier hiding key has been computed\n /// correctly. Instead, an app function can request to the kernel (via `request_nhk_app`) that it validates the\n /// siloed derivation, since the kernel has been vetted to not leak any master secret keys.\n ///\n /// A common nullification scheme is to inject a nullifier hiding key into the preimage of a nullifier, to make the\n /// nullifier deterministic but random-looking. This function enables that flow.\n ///\n /// # Arguments\n /// * `npk_m_hash` - A hash of the master nullifier public key of the user whose PXE is executing this function.\n ///\n /// # Returns\n /// * The app-siloed nullifier hiding key that corresponds to the given `npk_m_hash`.\n ///\n pub fn request_nhk_app(&mut self, npk_m_hash: Field) -> Field {\n self.request_sk_app(npk_m_hash, NULLIFIER_INDEX)\n }\n\n /// Requests the app-siloed outgoing viewing secret key (ovsk_app) for the given (hashed) master outgoing\n /// viewing public key (ovpk_m), from the user's PXE.\n ///\n /// See `request_nhk_app` and `request_sk_app` for more info.\n ///\n /// The intention of the \"outgoing\" keypair is to provide a second secret key for all of a user's outgoing activity\n /// (i.e. for notes that a user creates, as opposed to notes that a user receives from others). The separation of\n /// incoming and outgoing data was a distinction made by zcash, with the intention of enabling a user to optionally\n /// share with a 3rd party a controlled view of only incoming or outgoing notes. Similar functionality of sharing\n /// select data can be achieved with offchain zero-knowledge proofs. It is up to an app developer whether they\n /// choose to make use of a user's outgoing keypair within their application logic, or instead simply use the same\n /// keypair (the address keypair (which is effectively the same as the \"incoming\" keypair)) for all incoming &\n /// outgoing messages to a user.\n ///\n /// Currently, all of the exposed encryption functions in aztec-nr ignore the outgoing viewing keys, and instead\n /// encrypt all note logs and event logs to a user's address public key.\n ///\n /// # Arguments\n /// * `ovpk_m_hash` - Hash of the outgoing viewing public key master\n ///\n /// # Returns\n /// * The application-specific outgoing viewing secret key\n ///\n pub fn request_ovsk_app(&mut self, ovpk_m_hash: Field) -> Field {\n self.request_sk_app(ovpk_m_hash, OUTGOING_INDEX)\n }\n\n /// Pushes a Key Validation Request to the kernel.\n ///\n /// Private functions are not allowed to see a user's master secret keys, because we do not trust them. They are\n /// instead given \"app-siloed\" secret keys with a claim that they relate to a master public key. They can then\n /// request validation of this claim, by making a \"key validation request\" to the protocol's kernel circuits (which\n /// _are_ allowed to see certain master secret keys).\n ///\n /// The app circuit only sees `pk_m_hash` (not the raw point). The kernel derives the\n /// point from `sk_m`, hashes it, and asserts equality. When a Key Validation Request tuple of\n /// (sk_app, pk_m_hash, app_address) is submitted to the kernel, it performs the following\n /// derivations to validate the relationship between the claimed sk_app and the user's pk_m_hash:\n ///\n /// (sk_m) ----> * G ----> pk_m ----> hash_public_key(pk_m)\n /// | |\n /// v | We use the kernel to prove this\n /// h(sk_m, app_address) | sk_app-pk_m_hash relationship, because app\n /// | | circuits must not be trusted to see sk_m.\n /// v |\n /// sk_app - - - - - - - - - - - - - - - - - -\n ///\n /// The function is named \"request_\" instead of \"get_\" to remind the user that a Key Validation Request will be\n /// emitted to the kernel.\n ///\n fn request_sk_app(&mut self, pk_m_hash: Field, key_index: Field) -> Field {\n // Match against the cache only when a request is actually present in the slot.\n let cached_slot = self.last_key_validation_requests[key_index as u32];\n let cache_hit = cached_slot.is_some() & (cached_slot.unwrap_unchecked().pk_m_hash == pk_m_hash);\n\n if cache_hit {\n // We get a match so the cached request is the latest one\n cached_slot.unwrap_unchecked().sk_app\n } else {\n // We didn't get a match meaning the cached result is stale. Typically we'd validate keys by showing that\n // the master secret key derives to a public key matching `pk_m_hash`, but that'd require the oracle\n // returning the master secret keys, which could cause malicious contracts to leak it or learn about\n // secrets from other contracts. We therefore silo secret keys, and rely on the private kernel to validate\n // that the siloed secret key corresponds to correct siloing of the master secret key that hashes to\n // `pk_m_hash`.\n\n // Safety: Kernels verify that the key validation request is valid and below we verify that a request for\n // the correct public key has been received.\n let request = unsafe { get_key_validation_request(pk_m_hash, key_index) };\n assert_eq(request.pk_m_hash, pk_m_hash, \"Obtained key validation request for wrong pk_m_hash\");\n\n self.key_validation_requests_and_separators.push(\n KeyValidationRequestAndSeparator {\n request,\n key_type_domain_separator: public_key_domain_separators[key_index as u32],\n },\n );\n self.last_key_validation_requests[key_index as u32] = Option::some(request);\n request.sk_app\n }\n }\n\n /// Sends an \"L2 -> L1 message\" from this function (Aztec, L2) to a smart contract on Ethereum (L1). L1 contracts\n /// which are designed to send/receive messages to/from Aztec are called \"Portal Contracts\".\n ///\n /// Common use cases include withdrawals, cross-chain asset transfers, and triggering L1 actions based on L2 state\n /// changes.\n ///\n /// The message will be inserted into an Aztec \"Outbox\" contract on L1, when this transaction's block is proposed\n /// to L1. Sending the message will not result in any immediate state changes in the target portal contract. The\n /// message will need to be manually consumed from the Outbox through a separate Ethereum transaction: a user will\n /// need to call a function of the portal contract -- a function specifically designed to make a call to the Outbox\n /// to consume the message. The message will only be available for consumption once the _epoch_ proof has been\n /// submitted. Given that there are multiple Aztec blocks within an epoch, it might take some time for this epoch\n /// proof to be submitted -- especially if the block was near the start of an epoch.\n ///\n /// # Arguments\n /// * `recipient` - Ethereum address that will receive the message\n /// * `content` - Message content (32 bytes as a Field element). This content has a very\n /// specific layout. docs:start:context_message_portal\n pub fn message_portal(&mut self, recipient: EthAddress, content: Field) {\n let message = L2ToL1Message { recipient, content };\n self.l2_to_l1_msgs.push(message.count(self.next_counter()));\n }\n\n /// Consumes a message sent from Ethereum (L1) to Aztec (L2).\n ///\n /// Common use cases include token bridging, cross-chain governance, and triggering L2 actions based on L1 events.\n ///\n /// Use this function if you only want the message to ever be \"referred to\" once. Once consumed using this method,\n /// the message cannot be consumed again, because a nullifier is emitted. If your use case wants for the message to\n /// be read unlimited times, then you can always read any historic message from the L1-to-L2 messages tree;\n /// messages never technically get deleted from that tree.\n ///\n /// The message will first be inserted into an Aztec \"Inbox\" smart contract on L1. Sending the message will not\n /// result in any immediate state changes in the target L2 contract. The message will need to be manually consumed\n /// by the target contract through a separate Aztec transaction. The message will not be available for consumption\n /// immediately. Messages get copied over from the L1 Inbox to L2 by the next Proposer in batches. So you will need\n /// to wait until the messages are copied before you can consume them.\n ///\n /// # Arguments\n /// * `content` - The message content that was sent from L1\n /// * `secret` - Secret fields used for message privacy (if needed)\n /// * `sender` - Ethereum address that sent the message\n /// * `leaf_index` - Index of the message in the L1-to-L2 message tree\n ///\n /// # Advanced\n /// Validates message existence in the L1-to-L2 message tree and nullifies the message to prevent\n /// double-consumption.\n pub fn consume_l1_to_l2_message<let N: u32>(\n &mut self,\n content: Field,\n secret: [Field; N],\n sender: EthAddress,\n leaf_index: Field,\n ) {\n let nullifier = process_l1_to_l2_message(\n self.anchor_block_header.state.l1_to_l2_message_tree.root,\n self.this_address(),\n sender,\n self.chain_id(),\n self.version(),\n content,\n secret,\n leaf_index,\n );\n\n // Push nullifier (and the \"commitment\" corresponding to this can be \"empty\")\n self.push_nullifier_unsafe(nullifier)\n }\n\n /// Emits a private log (an array of Fields) that will be published to an Ethereum blob.\n ///\n /// Private logs are intended for the broadcasting of ciphertexts: that is, encrypted events or encrypted note\n /// contents. Since the data in the logs is meant to be _encrypted_, private_logs are broadcast to publicly-visible\n /// Ethereum blobs. The intended recipients of such encrypted messages can then discover and decrypt these\n /// encrypted logs using their viewing secret key. (See `../messages/discovery` for more details).\n ///\n /// Important note: This function DOES NOT _do_ any encryption of the input `log` fields. This function blindly\n /// publishes whatever input `log` data is fed into it, so the caller of this function should have already\n /// performed the encryption, and the `log` should be the result of that encryption.\n ///\n /// The protocol does not dictate what encryption scheme should be used: a smart contract developer can choose\n /// whatever encryption scheme they like. Aztec-nr includes some off-the-shelf encryption libraries that developers\n /// might wish to use, for convenience. These libraries not only encrypt a plaintext (to produce a ciphertext);\n /// they also prepend the ciphertext with a `tag` and `ephemeral public key` for easier message discovery. This is\n /// a very dense topic, and we will be writing more libraries and docs soon.\n ///\n /// > Currently, AES128 CBC encryption is the main scheme included in > aztec.nr. > We are currently making\n /// significant changes to the interfaces of the > encryption library.\n ///\n /// In some niche use cases, an app might be tempted to publish _un-encrypted_ data via a private log, because\n /// _public logs_ are not available to private functions. Be warned that emitting public data via private logs is\n /// strongly discouraged, and is considered a \"privacy anti-pattern\", because it reveals identifiable information\n /// about _which_ function has been executed. A tx which leaks such information does not contribute to the privacy\n /// set of the network.\n ///\n /// * Unlike `emit_raw_note_log_unsafe`, this log is not tied to any specific note\n ///\n /// # Arguments\n /// * `tag` - A tag placed at `fields[0]` of the emitted log. Used by recipients and nodes to identify and\n /// filter for relevant logs without scanning all of them.\n /// * `log` - The log data that will be publicly broadcast (so make sure it's already been encrypted before you\n /// call this function). Private logs are bounded in size (`PRIVATE_LOG_CIPHERTEXT_LEN`), to encourage all logs\n /// from all smart contracts look identical. The protocol's kernel circuits can then append random fields as\n /// \"padding\" after the log's length, so that the logs of this smart contract look indistinguishable from (the\n /// same length as) the logs of all other applications. It's up to wallets how much padding to apply, so\n /// ideally all wallets should agree on standards for this.\n ///\n /// ## Safety\n ///\n /// The `tag` should be domain-separated (e.g. via [`crate::protocol::hash::compute_log_tag`]) to prevent\n /// collisions between logs from different sources. Without domain separation, two unrelated log types that\n /// happen to share a raw tag value become indistinguishable. Prefer the higher-level APIs\n /// ([`crate::messages::delivery::MessageDelivery`] for messages, `self.emit(event)` for events) which\n /// handle tagging automatically.\n pub fn emit_private_log_unsafe(&mut self, tag: Field, log: BoundedVec<Field, PRIVATE_LOG_CIPHERTEXT_LEN>) {\n self.emit_raw_note_log_unsafe(tag, log, 0);\n }\n\n /// Emits a private log that is explicitly tied to a newly-emitted note_hash, to convey to the kernel: \"this log\n /// relates to this note\".\n ///\n /// This linkage is important in case the note gets squashed (due to being read later in this same tx), since we\n /// can then squash the log as well.\n ///\n /// See [`emit_private_log_unsafe`](PrivateContext::emit_private_log_unsafe) for more info about private log\n /// emission.\n ///\n /// # Arguments\n /// * `tag` - A tag placed at `fields[0]`. See\n /// [`emit_private_log_unsafe`](PrivateContext::emit_private_log_unsafe).\n /// * `log` - The log data as a `BoundedVec` of Field elements.\n /// * `note_hash_counter` - The side-effect counter that was assigned to the new note_hash when it was pushed to\n /// this `PrivateContext`.\n ///\n /// Important: If your application logic requires the log to always be emitted regardless of note squashing,\n /// consider using [`emit_private_log_unsafe`](PrivateContext::emit_private_log_unsafe) instead, or emitting\n /// additional events.\n ///\n /// ## Safety\n ///\n /// Same as [`PrivateContext::emit_private_log_unsafe`]: the `tag` should be domain-separated.\n pub fn emit_raw_note_log_unsafe(\n &mut self,\n tag: Field,\n log: BoundedVec<Field, PRIVATE_LOG_CIPHERTEXT_LEN>,\n note_hash_counter: u32,\n ) {\n // Safety: the base rollup constrains every field of a private log beyond its length to be zero, so a log that\n // fails this check can never be included in a block. Nothing here relies on the check; it only surfaces the\n // mistake to the developer at simulation time, with a clear message, instead of at block building.\n unsafe { assert_private_log_zero_padded(log) };\n let counter = self.next_counter();\n let full_log = [tag].concat(log.storage());\n let private_log = PrivateLogData { log: PrivateLog::new(full_log, log.len() + 1), note_hash_counter };\n self.private_logs.push(private_log.count(counter));\n }\n\n /// Emits large data blobs.\n ///\n /// This reuses the Contract Class Log channel to emit blobs of up to [`CONTRACT_CLASS_LOG_SIZE_IN_FIELDS`].\n ///\n /// ## Privacy\n ///\n /// The address of the contract emitting these blobs is revelead.\n pub fn emit_contract_class_log<let N: u32>(&mut self, log: [Field; N]) {\n let contract_address = self.this_address();\n let counter = self.next_counter();\n\n let log_to_emit: [Field; CONTRACT_CLASS_LOG_SIZE_IN_FIELDS] =\n log.concat([0; CONTRACT_CLASS_LOG_SIZE_IN_FIELDS - N]);\n // Note: the length is not always N, it is the number of fields we want to broadcast, omitting trailing zeros\n // to save blob space.\n // Safety: The below length is constrained in the base rollup, which will make sure that all the fields beyond\n // length are zero. However, it won't be able to check that we didn't add extra padding (trailing zeroes) or\n // that we cut trailing zeroes from the end.\n let length = unsafe { trimmed_array_length_hint(log) };\n // We hash the entire padded log to ensure a user cannot pass a shorter length and so emit incorrect shorter\n // bytecode.\n let log_hash = compute_contract_class_log_hash(log_to_emit);\n // Safety: the below only exists to broadcast the raw log, so we can provide it to the base rollup later to be\n // constrained.\n unsafe {\n notify_created_contract_class_log(contract_address, log_to_emit, length, counter);\n }\n\n self.contract_class_logs_hashes.push(LogHash { value: log_hash, length: length }.count(counter));\n }\n\n /// Calls a private function on another contract (or the same contract).\n ///\n /// Very low-level function.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args` - Array of arguments to pass to the called function\n ///\n /// # Returns\n /// * `ReturnsHash` - Hash of the called function's return values. Use `.get_preimage()` to extract the actual\n /// return values.\n ///\n /// This enables contracts to interact with each other while maintaining privacy. This \"composability\" of private\n /// contract functions is a key feature of the Aztec network.\n ///\n /// If a user's transaction includes multiple private function calls, then by the design of Aztec, the following\n /// information will remain private[1]:\n /// - The function selectors and contract addresses of all private function calls will remain private, so an\n /// observer of the public mempool will not be able to look at a tx and deduce which private functions have been\n /// executed.\n /// - The arguments and return values of all private function calls will remain private.\n /// - The person who initiated the tx will remain private.\n /// - The notes and nullifiers and private logs that are emitted by all private function calls will (if designed\n /// well) not leak any user secrets, nor leak which functions have been executed.\n ///\n /// [1] Caveats: Some of these privacy guarantees depend on how app developers design their smart contracts. Some\n /// actions _can_ leak information, such as:\n /// - Calling an internal public function.\n /// - Calling a public function and not setting msg_sender to Option::none (feature not built yet - see github).\n /// - Calling any public function will always leak details about the nature of the transaction, so devs should be\n /// careful in their contract designs. If it can be done in a private function, then that will give the best\n /// privacy.\n /// - Not padding the side-effects of a tx to some standardized, uniform size. The kernel circuits can take hints\n /// to pad side-effects, so a wallet should be able to request for a particular amount of padding. Wallets should\n /// ideally agree on some standard.\n /// - Padding should include:\n /// - Padding the lengths of note & nullifier arrays\n /// - Padding private logs with random fields, up to some standardized size. See also:\n /// https://docs.aztec.network/developers/resources/considerations/privacy_considerations\n ///\n /// # Advanced\n /// * The call is added to the private call stack and executed by kernel circuits after this function completes\n /// * The called function can modify its own contract's private state\n /// * Side effects from the called function are included in this transaction\n /// * The call inherits the current transaction's context and gas limits\n ///\n pub fn call_private_function<let ArgsCount: u32>(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; ArgsCount],\n ) -> ReturnsHash {\n let args_hash = hash_args(args);\n execution_cache::store(args, args_hash);\n self.call_private_function_with_args_hash(contract_address, function_selector, args_hash, false)\n }\n\n /// Makes a read-only call to a private function on another contract.\n ///\n /// This is similar to Solidity's `staticcall`. The called function cannot modify state, emit L2->L2 messages, nor\n /// emit events. Any nested calls are constrained to also be staticcalls.\n ///\n /// See `call_private_function` for more general info on private function calls.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract to call\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args` - Array of arguments to pass to the called function\n ///\n /// # Returns\n /// * `ReturnsHash` - Hash of the called function's return values. Use `.get_preimage()` to extract the actual\n /// return values.\n ///\n pub fn static_call_private_function<let ArgsCount: u32>(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; ArgsCount],\n ) -> ReturnsHash {\n let args_hash = hash_args(args);\n execution_cache::store(args, args_hash);\n self.call_private_function_with_args_hash(contract_address, function_selector, args_hash, true)\n }\n\n /// Calls a private function that takes no arguments.\n ///\n /// This is a convenience function for calling private functions that don't require any input parameters. It's\n /// equivalent to `call_private_function` but slightly more efficient to use when no arguments are needed.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n ///\n /// # Returns\n /// * `ReturnsHash` - Hash of the called function's return values. Use `.get_preimage()` to extract the actual\n /// return values.\n ///\n pub fn call_private_function_no_args(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n ) -> ReturnsHash {\n self.call_private_function_with_args_hash(contract_address, function_selector, 0, false)\n }\n\n /// Makes a read-only call to a private function which takes no arguments.\n ///\n /// This combines the optimisation of `call_private_function_no_args` with the safety of\n /// `static_call_private_function`.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n ///\n /// # Returns\n /// * `ReturnsHash` - Hash of the called function's return values. Use `.get_preimage()` to extract the actual\n /// return values.\n ///\n pub fn static_call_private_function_no_args(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n ) -> ReturnsHash {\n self.call_private_function_with_args_hash(contract_address, function_selector, 0, true)\n }\n\n /// Low-level private function call.\n ///\n /// This is the underlying implementation used by all other private function call methods. Instead of taking raw\n /// arguments, it accepts a hash of the arguments.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args_hash` - Pre-computed hash of the function arguments\n /// * `is_static_call` - Whether this should be a read-only call\n ///\n /// # Returns\n /// * `ReturnsHash` - Hash of the called function's return values\n ///\n pub fn call_private_function_with_args_hash(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args_hash: Field,\n is_static_call: bool,\n ) -> ReturnsHash {\n let is_static_call = is_static_call | self.inputs.call_context.is_static_call;\n let start_side_effect_counter = self.side_effect_counter;\n\n // Safety: The oracle simulates the private call and returns the value of the side effects counter after\n // execution of the call (which means that end_side_effect_counter - start_side_effect_counter is the number of\n // side effects that took place), along with the hash of the return values. We validate these by requesting a\n // private kernel iteration in which the return values are constrained to hash to `returns_hash` and the side\n // effects counter to increment from start to end.\n let (end_side_effect_counter, returns_hash) = unsafe {\n call_private_function_internal(\n contract_address,\n function_selector,\n args_hash,\n start_side_effect_counter,\n is_static_call,\n )\n };\n\n self.private_call_requests.push(\n PrivateCallRequest {\n call_context: CallContext {\n msg_sender: self.this_address(),\n contract_address,\n function_selector,\n is_static_call,\n },\n args_hash,\n returns_hash,\n start_side_effect_counter,\n end_side_effect_counter,\n },\n );\n\n // The kernel circuits ensure that end_side_effect_counter is greater than start_side_effect_counter, and that\n // all side effects emitted in the child call have counters within the range [start_side_effect_counter,\n // end_side_effect_counter]. Therefore, we only need to ensure that the next side effect from the current call\n // starts after the end side effect from the child call.\n self.side_effect_counter = end_side_effect_counter + 1;\n\n ReturnsHash::new(returns_hash)\n }\n\n /// Enqueues a call to a public function to be executed later.\n ///\n /// Unlike private functions which execute immediately on the user's device, public function calls are \"enqueued\"\n /// and executed some time later by a block proposer.\n ///\n /// This means a public function cannot return any values back to a private function, because by the time the\n /// public function is being executed, the private function which called it has already completed execution. (In\n /// fact, the private function has been executed and proven, along with all other private function calls of the\n /// user's tx. A single proof of the tx has been submitted to the Aztec network, and some time later a proposer has\n /// picked the tx up from the mempool and begun executing all of the enqueued public functions).\n ///\n /// # Privacy warning Enqueueing a public function call is an inherently leaky action. Many interesting applications\n /// will require some interaction with public state, but smart contract developers should try to use public function\n /// calls sparingly, and carefully. _Internal_ public function calls are especially leaky, because they completely\n /// leak which private contract made the call. See also:\n /// https://docs.aztec.network/developers/resources/considerations/privacy_considerations\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args` - Array of arguments to pass to the public function\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn call_public_function<let ArgsCount: u32>(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; ArgsCount],\n hide_msg_sender: bool,\n ) {\n let calldata = [function_selector.to_field()].concat(args);\n let calldata_hash = hash_calldata_array(calldata);\n execution_cache::store(calldata, calldata_hash);\n self.call_public_function_with_calldata_hash(contract_address, calldata_hash, false, hide_msg_sender)\n }\n\n /// Enqueues a read-only call to a public function.\n ///\n /// This is similar to Solidity's `staticcall`. The called function cannot modify state or emit events. Any nested\n /// calls are constrained to also be staticcalls.\n ///\n /// See also `call_public_function` for more important information about making private -> public function calls.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args` - Array of arguments to pass to the public function\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn static_call_public_function<let ArgsCount: u32>(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; ArgsCount],\n hide_msg_sender: bool,\n ) {\n let calldata = [function_selector.to_field()].concat(args);\n let calldata_hash = hash_calldata_array(calldata);\n execution_cache::store(calldata, calldata_hash);\n self.call_public_function_with_calldata_hash(contract_address, calldata_hash, true, hide_msg_sender)\n }\n\n /// Enqueues a call to a public function that takes no arguments.\n ///\n /// This is an optimisation for calling public functions that don't take any input parameters. It's otherwise\n /// equivalent to `call_public_function`.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn call_public_function_no_args(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n hide_msg_sender: bool,\n ) {\n let calldata_hash = hash_calldata_array([function_selector.to_field()]);\n self.call_public_function_with_calldata_hash(contract_address, calldata_hash, false, hide_msg_sender)\n }\n\n /// Enqueues a read-only call to a public function with no arguments.\n ///\n /// This combines the optimisation of `call_public_function_no_args` with the safety of\n /// `static_call_public_function`.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn static_call_public_function_no_args(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n hide_msg_sender: bool,\n ) {\n let calldata_hash = hash_calldata_array([function_selector.to_field()]);\n self.call_public_function_with_calldata_hash(contract_address, calldata_hash, true, hide_msg_sender)\n }\n\n /// Low-level public function call.\n ///\n /// This is the underlying implementation used by all other public function call methods. Instead of taking raw\n /// arguments, it accepts a hash of the arguments.\n ///\n /// Advanced function: Most developers should use `call_public_function` or `static_call_public_function` instead.\n /// This function is exposed for performance optimization and advanced use cases.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the function\n /// * `calldata_hash` - Hash of the function calldata\n /// * `is_static_call` - Whether this should be a read-only call\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn call_public_function_with_calldata_hash(\n &mut self,\n contract_address: AztecAddress,\n calldata_hash: Field,\n is_static_call: bool,\n hide_msg_sender: bool,\n ) {\n let counter = self.next_counter();\n\n let is_static_call = is_static_call | self.inputs.call_context.is_static_call;\n\n assert_valid_public_call_data(calldata_hash);\n\n let msg_sender = if hide_msg_sender {\n NULL_MSG_SENDER_CONTRACT_ADDRESS\n } else {\n self.this_address()\n };\n\n let call_request = PublicCallRequest { msg_sender, contract_address, is_static_call, calldata_hash };\n\n self.public_call_requests.push(Counted::new(call_request, counter));\n }\n\n /// Enqueues a public function call, and designates it to be the teardown function for this tx. Only one teardown\n /// function call can be made by a tx.\n ///\n /// Niche function: Only wallet developers and paymaster contract developers (aka Fee-payment contracts) will need\n /// to make use of this function.\n ///\n /// Aztec supports a three-phase execution model: setup, app logic, teardown. The phases exist to enable a fee\n /// payer to take on the risk of paying a transaction fee, safe in the knowledge that their payment (in whatever\n /// token or method the user chooses) will succeed, regardless of whether the app logic will succeed. The \"setup\"\n /// phase ensures the fee payer has sufficient balance to pay the proposer their fees. The teardown phase is\n /// primarily intended to: calculate exactly how much the user owes, based on gas consumption, and refund the user\n /// any change.\n ///\n /// Note: in some cases, the cost of refunding the user (i.e. DA costs of tx side-effects) might exceed the refund\n /// amount. For app logic with fairly stable and predictable gas consumption, a material refund amount is unlikely.\n /// For app logic with unpredictable gas consumption, a refund might be important to the user (e.g. if a hefty\n /// function reverts very early). Wallet/FPC/Paymaster developers should be mindful of this.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the teardown function\n /// * `function_selector` - 4-byte identifier of the function to call\n /// * `args` - An array of fields to pass to the function.\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n pub fn set_public_teardown_function<let ArgsCount: u32>(\n &mut self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; ArgsCount],\n hide_msg_sender: bool,\n ) {\n let calldata = [function_selector.to_field()].concat(args);\n let calldata_hash = hash_calldata_array(calldata);\n execution_cache::store(calldata, calldata_hash);\n self.set_public_teardown_function_with_calldata_hash(contract_address, calldata_hash, false, hide_msg_sender)\n }\n\n /// Low-level function to set the public teardown function.\n ///\n /// This is the underlying implementation for setting the teardown function call that will execute at the end of\n /// the transaction. Instead of taking raw arguments, it accepts a hash of the arguments.\n ///\n /// Advanced function: Most developers should use `set_public_teardown_function` instead.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract containing the teardown function\n /// * `calldata_hash` - Hash of the function calldata\n /// * `is_static_call` - Whether this should be a read-only call\n /// * `hide_msg_sender` - the called function will see a \"null\" value for `msg_sender` if set to `true`\n ///\n pub fn set_public_teardown_function_with_calldata_hash(\n &mut self,\n contract_address: AztecAddress,\n calldata_hash: Field,\n is_static_call: bool,\n hide_msg_sender: bool,\n ) {\n let is_static_call = is_static_call | self.inputs.call_context.is_static_call;\n\n assert_valid_public_call_data(calldata_hash);\n\n let msg_sender = if hide_msg_sender {\n NULL_MSG_SENDER_CONTRACT_ADDRESS\n } else {\n self.this_address()\n };\n\n self.public_teardown_call_request =\n PublicCallRequest { msg_sender, contract_address, is_static_call, calldata_hash };\n }\n\n /// Increments the side-effect counter.\n ///\n /// Very low-level function.\n ///\n /// # Advanced\n ///\n /// Every side-effect of a private function is given a \"side-effect counter\", based on when it is created. This\n /// PrivateContext is in charge of assigning the counters.\n ///\n /// The reason we have side-effect counters is complicated. Consider this illustrative pseudocode of inter-contract\n /// function calls:\n /// ```\n /// contract A {\n /// let x = 5; // pseudocode for storage var x.\n /// fn a1 {\n /// read x; // value: 5, counter: 1.\n /// x = x + 1;\n /// write x; // value: 6, counter: 2.\n ///\n /// B.b(); // start_counter: 2, end_counter: 4\n ///\n /// read x; // value: 36, counter: 5.\n /// x = x + 1;\n /// write x; // value: 37, counter: 6.\n /// }\n ///\n /// fn a2 {\n /// read x; // value: 6, counter: 3.\n /// x = x * x;\n /// write x; // value: 36, counter: 4.\n /// }\n /// }\n ///\n /// contract B {\n /// fn b() {\n /// A.a2();\n /// }\n /// }\n /// ```\n ///\n /// Suppose a1 is the first function called. The comments show the execution counter of each side-effect, and what\n /// the new value of `x` is.\n ///\n /// These (private) functions are processed by Aztec's kernel circuits in an order that is different from execution\n /// order: All of A.a1 is proven before B.b is proven, before A.a2 is proven. So when we're in the 2nd execution\n /// frame of A.a1 (after the call to B.b), the circuit needs to justify why x went from being `6` to `36`. But the\n /// circuit doesn't know why, and given the order of proving, the kernel hasn't _seen_ a value of 36 get written\n /// yet. The kernel needs to track big arrays of all side-effects of all private functions in a tx. Then, as it\n /// recurses and processes B.b(), it will eventually see a value of 36 get written.\n ///\n /// Suppose side-effect counters weren't exposed: The kernel would only see this ordering (in order of proof\n /// verification): [ A.a1.read, A.a1.write, A.a1.read, A.a1.write, A.a2.read, A.a2.write ]\n /// [ 5, 6, 36, 37, 6, 36 ]\n /// The kernel wouldn't know _when_ B.b() was called within A.a1(), because it can't see what's going on within an\n /// app circuit. So the kernel wouldn't know that the ordering of reads and writes should actually be: [ A.a1.read,\n /// A.a1.write, A.a2.read, A.a2.write, A.a1.read, A.a1.write ]\n /// [ 5, 6, 6, 36, 36, 37 ]\n ///\n /// And so, we introduced side-effect counters: every private function must assign side-effect counters alongside\n /// every side-effect that it emits, and also expose to the kernel the counters that it started and ended with.\n /// This gives the kernel enough information to arrange all side-effects in the correct order. It can then catch\n /// (for example) if a function tries to read state before it has been written (e.g. if A.a2() maliciously tried to\n /// read a value of x=37) (e.g. if A.a1() maliciously tried to read x=6).\n ///\n /// If a malicious app contract _lies_ and does not count correctly:\n /// - It cannot lie about its start and end counters because the kernel will catch this.\n /// - It _could_ lie about its intermediate counters:\n /// - 1. It could not increment its side-effects correctly\n /// - 2. It could label its side-effects with counters outside of its start and end counters' range. The kernel\n /// will catch 2. The kernel will not catch 1., but this would only cause corruption to the private state of the\n /// malicious contract, and not any other contracts (because a contract can only modify its own state). If a \"good\"\n /// contract is given _read access_ to a maliciously-counting contract (via an external getter function, or by\n /// reading historic state from the archive tree directly), and they then make state changes to their _own_ state\n /// accordingly, that could be dangerous. Developers should be mindful not to trust the claimed innards of external\n /// contracts unless they have audited/vetted the contracts including vetting the side-effect counter\n /// incrementation. This is a similar paradigm to Ethereum smart contract development: you must vet external\n /// contracts that your contract relies upon, and you must not make any presumptions about their claimed behaviour.\n /// (Hopefully if a contract imports a version of aztec-nr, we will get contract verification tooling that can\n /// validate the authenticity of the imported aztec-nr package, and hence infer that the side- effect counting will\n /// be correct, without having to re-audit such logic for every contract).\n ///\n fn next_counter(&mut self) -> u32 {\n let counter = self.side_effect_counter;\n self.side_effect_counter += 1;\n counter\n }\n}\n\nimpl Empty for PrivateContext {\n fn empty() -> Self {\n PrivateContext {\n inputs: PrivateContextInputs::empty(),\n side_effect_counter: 0 as u32,\n min_revertible_side_effect_counter: 0 as u32,\n is_fee_payer: false,\n args_hash: 0,\n return_hash: 0,\n expiration_timestamp: 0,\n note_hash_read_requests: BoundedVec::new(),\n nullifier_read_requests: BoundedVec::new(),\n key_validation_requests_and_separators: BoundedVec::new(),\n note_hashes: BoundedVec::new(),\n nullifiers: BoundedVec::new(),\n private_call_requests: BoundedVec::new(),\n public_call_requests: BoundedVec::new(),\n public_teardown_call_request: PublicCallRequest::empty(),\n l2_to_l1_msgs: BoundedVec::new(),\n anchor_block_header: BlockHeader::empty(),\n private_logs: BoundedVec::new(),\n contract_class_logs_hashes: BoundedVec::new(),\n last_key_validation_requests: [Option::none(); NUM_KEY_TYPES],\n expected_non_revertible_side_effect_counter: 0,\n expected_revertible_side_effect_counter: 0,\n }\n }\n}\n\n/// Checks that every entry of `log`'s storage past `log.len()` is zero, which the protocol requires of every private\n/// log. `BoundedVec::truncate` and `BoundedVec::pop` only move `len` and leave the vacated storage in place, so a\n/// vector that was shortened before being emitted carries stale values into the log's padding unless the caller\n/// zeroes them; `BoundedVec::from_array` always yields zeroed storage.\nunconstrained fn assert_private_log_zero_padded<let N: u32>(log: BoundedVec<Field, N>) {\n let storage = log.storage();\n let len = log.len();\n for i in len..N {\n assert(\n storage[i] == 0,\n f\"Private log has a non-zero field at index {i}, beyond its length {len}. Fields beyond the length must be zero: if the BoundedVec was shortened with truncate or pop, zero the vacated entries first, or build it with BoundedVec::from_array.\",\n );\n }\n}\n\nmod test {\n use crate::protocol::{constants::PRIVATE_LOG_CIPHERTEXT_LEN, traits::Empty};\n use super::PrivateContext;\n\n #[test]\n unconstrained fn emits_short_log_with_zero_padding() {\n let mut context = PrivateContext::empty();\n let log: BoundedVec<Field, PRIVATE_LOG_CIPHERTEXT_LEN> = BoundedVec::from_array([1, 2, 3]);\n context.emit_private_log_unsafe(7, log);\n\n assert_eq(context.private_logs.len(), 1);\n let emitted = context.private_logs.get(0).inner.log;\n assert_eq(emitted.length, 4);\n assert_eq(emitted.fields[0], 7);\n assert_eq(emitted.fields[1], 1);\n assert_eq(emitted.fields[2], 2);\n assert_eq(emitted.fields[3], 3);\n for i in 4..emitted.fields.len() {\n assert_eq(emitted.fields[i], 0);\n }\n }\n\n #[test(should_fail_with = \"beyond its length\")]\n unconstrained fn rejects_log_with_stale_storage_after_truncate() {\n let mut context = PrivateContext::empty();\n let mut log: BoundedVec<Field, PRIVATE_LOG_CIPHERTEXT_LEN> = BoundedVec::from_array([1, 2, 3, 4, 5]);\n log.truncate(3);\n context.emit_private_log_unsafe(7, log);\n }\n\n #[test(should_fail_with = \"beyond its length\")]\n unconstrained fn rejects_log_with_stale_storage_after_pop() {\n let mut context = PrivateContext::empty();\n let mut log: BoundedVec<Field, PRIVATE_LOG_CIPHERTEXT_LEN> = BoundedVec::from_array([1, 2, 3]);\n let _ = log.pop();\n context.emit_private_log_unsafe(7, log);\n }\n}\n"
|
|
3302
3310
|
},
|
|
3303
3311
|
"71": {
|
|
@@ -3427,7 +3435,7 @@
|
|
|
3427
3435
|
"start": 34250
|
|
3428
3436
|
}
|
|
3429
3437
|
],
|
|
3430
|
-
"path": "/
|
|
3438
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/context/public_context.nr",
|
|
3431
3439
|
"source": "use crate::{\n context::gas::GasOpts,\n hash::{\n compute_l1_to_l2_message_hash, compute_l1_to_l2_message_nullifier, compute_secret_hash,\n compute_siloed_nullifier,\n },\n oracle::avm,\n};\nuse crate::protocol::{\n abis::function_selector::FunctionSelector,\n address::{AztecAddress, EthAddress},\n constants::{MAX_U32_VALUE, NULL_MSG_SENDER_CONTRACT_ADDRESS},\n traits::{Empty, FromField, Packable, Serialize, ToField},\n utils::writer::Writer,\n};\n\n/// # PublicContext\n///\n/// The **main interface** between an #[external(\"public\")] function and the Aztec blockchain.\n///\n/// An instance of the PublicContext is initialized automatically at the outset of every public function, within the\n/// #[external(\"public\")] macro, so you'll never need to consciously instantiate this yourself.\n///\n/// The instance is always named `context`, and it will always be available within the body of every\n/// #[external(\"public\")] function in your smart contract.\n///\n/// Typical usage for a smart contract developer will be to call getter methods of the PublicContext.\n///\n/// _Pushing_ data and requests to the context is mostly handled within aztec-nr's own functions, so typically a smart\n/// contract developer won't need to call any setter methods directly.\n///\n/// ## Responsibilities\n/// - Exposes contextual data to a public function:\n/// - Data relating to how this public function was called:\n/// - msg_sender, this_address\n/// - Data relating to the current blockchain state:\n/// - timestamp, block_number, chain_id, version\n/// - Gas and fee information\n/// - Provides state access:\n/// - Read/write public storage (key-value mapping)\n/// - Check existence of notes and nullifiers (Some patterns use notes & nullifiers to store public (not private)\n/// information)\n/// - Enables consumption of L1->L2 messages.\n/// - Enables calls to other public smart contract functions:\n/// - Writes data to the blockchain:\n/// - Updates to public state variables\n/// - New public logs (for events)\n/// - New L2->L1 messages\n/// - New notes & nullifiers (E.g. pushing public info to notes/nullifiers, or for completing \"partial notes\")\n///\n/// ## Key Differences from Private Execution\n///\n/// Unlike private functions -- which are executed on the user's device and which can only reference historic state --\n/// public functions are executed by a block proposer and are executed \"live\" on the _current_ tip of the chain. This\n/// means public functions can:\n/// - Read and write _current_ public state\n/// - Immediately see the effects of earlier transactions in the same block\n///\n/// Also, public functions are executed within a zkVM (the \"AVM\"), so that they can _revert_ whilst still ensuring\n/// payment to the proposer and prover. (Private functions cannot revert: they either succeed, or they cannot be\n/// included).\n///\n/// ## Optimising Public Functions\n///\n/// Using the AVM to execute public functions means they compile down to \"AVM bytecode\" instead of the ACIR that\n/// private functions (standalone circuits) compile to. Therefore the approach to optimising a public function is\n/// fundamentally different from optimising a public function.\n///\npub struct PublicContext {\n args_hash: Option<Field>,\n compute_args_hash: fn() -> Field,\n}\n\nimpl Eq for PublicContext {\n fn eq(self, other: Self) -> bool {\n (self.args_hash == other.args_hash)\n // Can't compare the function compute_args_hash\n }\n}\n\nimpl PublicContext {\n /// Creates a new PublicContext instance.\n ///\n /// Low-level function: This is called automatically by the #[external(\"public\")] macro, so you shouldn't need to\n /// be called directly by smart contract developers.\n ///\n /// # Arguments\n /// * `compute_args_hash` - Function to compute the args_hash\n ///\n /// # Returns\n /// * A new PublicContext instance\n ///\n pub fn new(compute_args_hash: fn() -> Field) -> Self {\n PublicContext { args_hash: Option::none(), compute_args_hash }\n }\n\n /// Emits a _public_ log that will be visible onchain to everyone.\n ///\n /// # Arguments\n /// * `tag` - A tag placed at `fields[0]` of the emitted log. Nodes index logs by this value, allowing\n /// clients to efficiently query for matching logs without scanning all of them.\n /// * `log` - The data to log, must implement Serialize trait.\n ///\n /// ## Safety\n ///\n /// The `tag` should be domain-separated (e.g. via [`crate::protocol::hash::compute_log_tag`]) to prevent\n /// collisions between logs from different sources. Without domain separation, two unrelated log types that\n /// happen to share a raw tag value become indistinguishable. Prefer `self.emit(event)` for events, which\n /// handles tagging automatically.\n pub fn emit_public_log_unsafe<T>(_self: Self, tag: Field, log: T)\n where\n T: Serialize,\n {\n // We use a Writer to serialize the log directly after the tag, avoiding an extra O(n) copy that would\n // result from serializing first and then prepending the tag.\n let mut writer: Writer<1 + <T as Serialize>::N> = Writer::new();\n writer.write(tag);\n Serialize::stream_serialize(log, &mut writer);\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe { avm::emit_public_log(writer.finish().as_vector()) };\n }\n\n /// Checks if a given note hash exists in the note hash tree at a particular leaf_index.\n ///\n /// # Arguments\n /// * `note_hash` - The note hash to check for existence\n /// * `leaf_index` - The index where the note hash should be located\n ///\n /// # Returns\n /// * `bool` - True if the note hash exists at the specified index\n ///\n pub fn note_hash_exists(_self: Self, note_hash: Field, leaf_index: u64) -> bool {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::note_hash_exists(note_hash, leaf_index)\n }\n }\n\n /// Checks if a specific L1-to-L2 message exists in the L1-to-L2 message tree at a particular leaf index.\n ///\n /// Common use cases include token bridging, cross-chain governance, and triggering L2 actions based on L1 events.\n ///\n /// This function should be called before attempting to consume an L1-to-L2 message.\n ///\n /// # Arguments\n /// * `msg_hash` - Hash of the L1-to-L2 message to check\n /// * `msg_leaf_index` - The index where the message should be located\n ///\n /// # Returns\n /// * `bool` - True if the message exists at the specified index\n ///\n /// # Advanced\n /// * Uses the AVM l1_to_l2_msg_exists opcode for tree lookup\n /// * Messages are copied from L1 Inbox to L2 by block proposers\n ///\n pub fn l1_to_l2_msg_exists(_self: Self, msg_hash: Field, msg_leaf_index: Field) -> bool {\n // Safety: AVM opcodes are constrained by the AVM itself TODO(alvaro): Make l1l2msg leaf index a u64 upstream\n unsafe {\n avm::l1_to_l2_msg_exists(msg_hash, msg_leaf_index as u64)\n }\n }\n\n /// Returns `true` if an `unsiloed_nullifier` has been emitted by `contract_address`.\n ///\n /// Note that unsiloed nullifiers are not the actual values stored in the nullifier tree: they are first siloed via\n /// [`crate::hash::compute_siloed_nullifier`] with the emitting contract's address.\n ///\n /// ## Use Cases\n ///\n /// Nullifiers are typically used as a _privacy-preserving_ record of a one-time action, but they can also be used\n /// to efficiently record _public_ one-time actions as well. This is cheaper than using public storage, and has the\n /// added benefit of the nullifier being emittable from a private function.\n ///\n /// An example is to check whether a contract has been published: we emit a nullifier that is deterministic and\n /// which has a _public_ preimage.\n ///\n /// ## Public vs Private\n ///\n /// In general, one should not attempt to prove nullifier non-existence in private, as that will not consider the\n /// possibility of the nullifier having been emitted in any transaction between the anchor block and the inclusion\n /// block. Private functions instead prove existence via\n /// [`crate::context::PrivateContext::assert_nullifier_exists`]\n /// and 'prove' non-existence by _emitting_ the nullifer, which would cause the transaction to fail if the\n /// nullifier existed.\n ///\n /// This is not the case in public functions, which **do** have access to the tip of the blockchain and so can\n /// reliably prove whether a nullifier exists or not.\n ///\n /// ## Safety\n ///\n /// While it is safe to rely on this function's return value to determine if a nullifier exists or not, it is often\n /// **not** safe to infer additional information from that. In particular, it is **unsafe** to infer that the\n /// existence of a nullifier emitted from a private function implies that all other side-effects of said private\n /// execution have been completed, more concretely that any enqueued public calls have been executed.\n ///\n /// For example, if a function in contract `A` privately emits nullifier `X` and then enqueues public function `Y`,\n /// then it is **unsafe** for a contract `B` to infer that `Y` has alredy executed simply because `X` exists.\n ///\n /// This is because **all** private transaction effects are committed _before_ enqueued public functions are run\n /// (in\n /// order to not reveal detailed timing information about the transaction), so it is possible to observe a\n /// nullifier that was emitted alongside the enqueuing of a public call **before** said call has been completed.\n ///\n /// ## Cost\n ///\n /// This emits the `CHECKNULLIFIEREXISTS` opcode, which conceptually performs a merkle inclusion proof on the\n /// nullifier tree (both when the nullifier exists and when it doesn't).\n pub fn nullifier_exists_unsafe(_self: Self, unsiloed_nullifier: Field, contract_address: AztecAddress) -> bool {\n let siloed_nullifier = compute_siloed_nullifier(contract_address, unsiloed_nullifier);\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::nullifier_exists(siloed_nullifier)\n }\n }\n\n /// Consumes a message sent from Ethereum (L1) to Aztec (L2) -- effectively marking it as \"read\".\n ///\n /// Use this function if you only want the message to ever be \"referred to\" once. Once consumed using this method,\n /// the message cannot be consumed again, because a nullifier is emitted. If your use case wants for the message to\n /// be read unlimited times, then you can always read any historic message from the L1-to-L2 messages tree, using\n /// the `l1_to_l2_msg_exists` method. Messages never technically get deleted from that tree.\n ///\n /// The message will first be inserted into an Aztec \"Inbox\" smart contract on L1. It will not be available for\n /// consumption immediately. Messages get copied-over from the L1 Inbox to L2 by the next Proposer in batches. So\n /// you will need to wait until the messages are copied before you can consume them.\n ///\n /// # Arguments\n /// * `content` - The message content that was sent from L1\n /// * `secret` - Secret fields used for message privacy (if needed)\n /// * `sender` - Ethereum address that sent the message\n /// * `leaf_index` - Index of the message in the L1-to-L2 message tree\n ///\n /// # Advanced\n /// * Validates message existence in the L1-to-L2 message tree\n /// * Prevents double-consumption by emitting a nullifier\n /// * Message hash is computed from all parameters + chain context\n /// * Will revert if message doesn't exist or was already consumed\n ///\n pub fn consume_l1_to_l2_message<let N: u32>(\n self: Self,\n content: Field,\n secret: [Field; N],\n sender: EthAddress,\n leaf_index: Field,\n ) {\n let secret_hash = compute_secret_hash(secret);\n let message_hash = compute_l1_to_l2_message_hash(\n sender,\n self.chain_id(),\n /*recipient=*/\n self.this_address(),\n self.version(),\n content,\n secret_hash,\n leaf_index,\n );\n let nullifier = compute_l1_to_l2_message_nullifier(message_hash, secret);\n\n assert(!self.nullifier_exists_unsafe(nullifier, self.this_address()), \"L1-to-L2 message is already nullified\");\n assert(self.l1_to_l2_msg_exists(message_hash, leaf_index), \"Tried to consume nonexistent L1-to-L2 message\");\n\n self.push_nullifier_unsafe(nullifier);\n }\n\n /// Sends an \"L2 -> L1 message\" from this function (Aztec, L2) to a smart contract on Ethereum (L1). L1 contracts\n /// which are designed to send/receive messages to/from Aztec are called \"Portal Contracts\".\n ///\n /// Common use cases include withdrawals, cross-chain asset transfers, and triggering L1 actions based on L2 state\n /// changes.\n ///\n /// The message will be inserted into an Aztec \"Outbox\" contract on L1, when this transaction's block is proposed\n /// to L1. Sending the message will not result in any immediate state changes in the target portal contract. The\n /// message will need to be manually consumed from the Outbox through a separate Ethereum transaction: a user will\n /// need to call a function of the portal contract -- a function specifically designed to make a call to the Outbox\n /// to consume the message. The message will only be available for consumption once the _epoch_ proof has been\n /// submitted. Given that there are multiple Aztec blocks within an epoch, it might take some time for this epoch\n /// proof to be submitted -- especially if the block was near the start of an epoch.\n ///\n /// # Arguments\n /// * `recipient` - Ethereum address that will receive the message\n /// * `content` - Message content (32 bytes as a Field element)\n ///\n pub fn message_portal(_self: Self, recipient: EthAddress, content: Field) {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe { avm::send_l2_to_l1_msg(recipient, content) };\n }\n\n /// Calls a public function on another contract.\n ///\n /// Will revert if the called function reverts or runs out of gas.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract to call\n /// * `function_selector` - Function to call on the target contract\n /// * `args` - Arguments to pass to the function\n /// * `gas_opts` - An optional allocation of gas to the called function.\n ///\n /// # Returns\n /// * `[Field]` - Return data from the called function\n ///\n pub unconstrained fn call_public_function<let N: u32>(\n _self: Self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; N],\n gas_opts: GasOpts,\n ) -> [Field] {\n let calldata = [function_selector.to_field()].concat(args);\n\n avm::call(\n gas_opts.l2_gas.unwrap_or(MAX_U32_VALUE),\n gas_opts.da_gas.unwrap_or(MAX_U32_VALUE),\n contract_address,\n calldata,\n );\n // Use success_copy to determine whether the call succeeded\n let success = avm::success_copy();\n\n let result_data = avm::returndata_copy(0, avm::returndata_size());\n if !success {\n // Rethrow the revert data.\n avm::revert(result_data);\n }\n result_data\n }\n\n /// Makes a read-only call to a public function on another contract.\n ///\n /// This is similar to Solidity's `staticcall`. The called function cannot modify state or emit events. Any nested\n /// calls are constrained to also be staticcalls.\n ///\n /// Useful for querying data from other contracts safely.\n ///\n /// Will revert if the called function reverts or runs out of gas.\n ///\n /// # Arguments\n /// * `contract_address` - Address of the contract to call\n /// * `function_selector` - Function to call on the target contract\n /// * `args` - Array of arguments to pass to the called function\n /// * `gas_opts` - An optional allocation of gas to the called function.\n ///\n /// # Returns\n /// * `[Field]` - Return data from the called function\n ///\n pub unconstrained fn static_call_public_function<let N: u32>(\n _self: Self,\n contract_address: AztecAddress,\n function_selector: FunctionSelector,\n args: [Field; N],\n gas_opts: GasOpts,\n ) -> [Field] {\n let calldata = [function_selector.to_field()].concat(args);\n\n avm::call_static(\n gas_opts.l2_gas.unwrap_or(MAX_U32_VALUE),\n gas_opts.da_gas.unwrap_or(MAX_U32_VALUE),\n contract_address,\n calldata,\n );\n // Use success_copy to determine whether the call succeeded\n let success = avm::success_copy();\n\n let result_data = avm::returndata_copy(0, avm::returndata_size());\n if !success {\n // Rethrow the revert data.\n avm::revert(result_data);\n }\n result_data\n }\n\n /// Adds a new note hash to the Aztec blockchain's global Note Hash Tree.\n ///\n /// Notes are ordinarily constructed and emitted by _private_ functions, to ensure that both the content of the\n /// note, and the contract that emitted the note, stay private.\n ///\n /// There are however some useful patterns whereby a note needs to contain _public_ data. The ability to push a new\n /// note_hash from a _public_ function means that notes can be injected with public data immediately -- as soon as\n /// the public value is known. The slower alternative would be to submit a follow-up transaction so that a private\n /// function can inject the data. Both are possible on Aztec.\n ///\n /// Search \"Partial Note\" for a very common pattern which enables a note to be \"partially\" populated with some data\n /// in a _private_ function, and then later \"completed\" with some data in a public function.\n ///\n /// # Arguments\n /// * `note_hash` - The hash of the note to add to the tree\n ///\n /// # Advanced\n /// * The note hash will be siloed with the contract address by the protocol\n ///\n pub fn push_note_hash(_self: Self, note_hash: Field) {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe { avm::emit_note_hash(note_hash) };\n }\n\n /// Creates a new [nullifier](crate::nullifier).\n ///\n /// While nullifiers are primarily intended as a _privacy-preserving_ record of a one-time action, they can also\n /// be used to efficiently record _public_ one-time actions. This function allows creating nullifiers from public\n /// contract functions, which behave just like those created from private functions.\n ///\n /// ## Safety\n ///\n /// This is a low-level function that must be used with great care to avoid subtle corruption of contract state.\n ///\n /// In particular, callers must ensure all nullifiers created by a contract are properly domain-separated, so that\n /// unrelated components don't interfere with one another (e.g. a transaction nullifier accidentally marking a\n /// variable as initialized). Note nullifiers should only be created via\n /// [`crate::context::PrivateContext::push_nullifier_for_note_hash`].\n ///\n /// ## Advanced\n ///\n /// The raw `nullifier` is not what is inserted into the Aztec state tree: it will be first siloed by contract\n /// address via [`crate::protocol::hash::compute_siloed_nullifier`] in order to prevent accidental or malicious\n /// interference of nullifiers from different contracts.\n pub fn push_nullifier_unsafe(_self: Self, nullifier: Field) {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe { avm::emit_nullifier(nullifier) };\n }\n\n /// Returns the address of the current contract being executed.\n ///\n /// This is equivalent to `address(this)` in Solidity (hence the name). Use this to identify the current contract's\n /// address, commonly needed for access control or when interacting with other contracts.\n ///\n /// # Returns\n /// * `AztecAddress` - The contract address of the current function being executed.\n ///\n pub fn this_address(_self: Self) -> AztecAddress {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::address()\n }\n }\n\n /// Returns the contract address that initiated this function call.\n ///\n /// This is similar to `msg.sender` in Solidity (hence the name).\n ///\n /// Important Note: If the calling function is a _private_ function, then it had the option of hiding its address\n /// when enqueuing this public function call. In such cases, this method will return `Option<AztecAddress>::none`.\n /// If the calling function is a _public_ function, it will always return an `Option<AztecAddress>::some` (i.e. a\n /// non-null value).\n ///\n /// # Returns\n /// * `Option<AztecAddress>` - The address of the smart contract that called this function (be it an app contract\n /// or a user's account contract).\n ///\n /// # Advanced\n /// * Value is provided by the AVM sender opcode\n /// * In nested calls, this is the immediate caller, not the original transaction sender\n ///\n pub fn maybe_msg_sender(_self: Self) -> Option<AztecAddress> {\n // Safety: AVM opcodes are constrained by the AVM itself\n let maybe_msg_sender = unsafe { avm::sender() };\n if maybe_msg_sender == NULL_MSG_SENDER_CONTRACT_ADDRESS {\n Option::none()\n } else {\n Option::some(maybe_msg_sender)\n }\n }\n\n /// Returns the function selector of the currently-executing function.\n ///\n /// This is similar to `msg.sig` in Solidity, returning the first 4 bytes of the function signature.\n ///\n /// # Returns\n /// * `FunctionSelector` - The 4-byte function identifier\n ///\n /// # Advanced\n /// * Extracted from the first element of calldata\n /// * Used internally for function dispatch in the AVM\n ///\n pub fn selector(_self: Self) -> FunctionSelector {\n // The selector is the first element of the calldata when calling a public function through dispatch.\n // Safety: AVM opcodes are constrained by the AVM itself.\n let raw_selector: [Field; 1] = unsafe { avm::calldata_copy(0, 1) };\n FunctionSelector::from_field(raw_selector[0])\n }\n\n /// Returns the hash of the arguments passed to the current function.\n ///\n /// Very low-level function: The #[external(\"public\")] macro uses this internally. Smart contract developers\n /// typically won't need to access this directly as arguments are automatically made available.\n ///\n /// # Returns\n /// * `Field` - Hash of the function arguments\n ///\n pub fn get_args_hash(mut self) -> Field {\n if !self.args_hash.is_some() {\n self.args_hash = Option::some((self.compute_args_hash)());\n }\n\n self.args_hash.unwrap_unchecked()\n }\n\n /// Returns the \"transaction fee\" for the current transaction. This is the final tx fee that will be deducted from\n /// the fee_payer's \"fee-juice\" balance (in the protocol's Base Rollup circuit).\n ///\n /// # Returns\n /// * `Field` - The actual, final cost of the transaction, taking into account: the actual gas used during the\n /// setup and app-logic phases, and the fixed amount of gas that's been allocated by the user for the teardown\n /// phase. I.e. effectiveL2FeePerGas * l2GasUsed + effectiveDAFeePerGas * daGasUsed\n ///\n /// This will return `0` during the \"setup\" and \"app-logic\" phases of tx execution (because the final tx fee is not\n /// known at that time). This will only return a nonzero value during the \"teardown\" phase of execution, where the\n /// final tx fee can actually be computed.\n ///\n /// Regardless of _when_ this function is called during the teardown phase, it will always return the same final tx\n /// fee value. The teardown phase does not consume a variable amount of gas: it always consumes a pre-allocated\n /// amount of gas, as specified by the user when they generate their tx.\n ///\n pub fn transaction_fee(_self: Self) -> Field {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::transaction_fee()\n }\n }\n\n /// Returns the chain ID of the current network.\n ///\n /// This is similar to `block.chainid` in Solidity. Returns the unique identifier for the blockchain network this\n /// transaction is executing on.\n ///\n /// Helps prevent cross-chain replay attacks. Useful if implementing multi-chain contract logic.\n ///\n /// # Returns\n /// * `Field` - The chain ID as a field element\n ///\n pub fn chain_id(_self: Self) -> Field {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::chain_id()\n }\n }\n\n /// Returns the Aztec protocol version that this transaction is executing under. Different versions may have\n /// different rules, opcodes, or cryptographic primitives.\n ///\n /// This is similar to how Ethereum has different EVM versions.\n ///\n /// Useful for forward/backward compatibility checks\n ///\n /// Not to be confused with contract versions; this is the protocol version.\n ///\n /// # Returns\n /// * `Field` - The protocol version as a field element\n ///\n pub fn version(_self: Self) -> Field {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::version()\n }\n }\n /// Returns the current block number.\n ///\n /// This is similar to `block.number` in Solidity.\n ///\n /// Note: the current block number is only available within a public function (as opposed to a private function).\n ///\n /// Note: the time intervals between blocks should not be relied upon as being consistent:\n /// - Timestamps of blocks fall within a range, rather than at exact regular intervals.\n /// - Slots can be missed.\n /// - Protocol upgrades can completely change the intervals between blocks (and indeed the current roadmap plans to\n /// reduce the time between blocks, eventually). Use `context.timestamp()` for more-reliable time-based logic.\n ///\n /// # Returns\n /// * `u32` - The current block number\n ///\n pub fn block_number(_self: Self) -> u32 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::block_number()\n }\n }\n\n /// Returns the timestamp of the current block.\n ///\n /// This is similar to `block.timestamp` in Solidity.\n ///\n /// All functions of all transactions in a block share the exact same timestamp (even though technically each\n /// transaction is executed one-after-the-other).\n ///\n /// Important note: Timestamps of Aztec blocks are not at reliably-fixed intervals. The proposer of the block has\n /// some flexibility to choose a timestamp which is in a valid _range_: Obviously the timestamp of this block must\n /// be strictly greater than that of the previous block, and must must be less than the timestamp of whichever\n /// ethereum block the aztec block is proposed to. Furthermore, if the timestamp is not deemed close enough to the\n /// actual current time, the committee of validators will not attest to the block.\n ///\n /// # Returns\n /// * `u64` - Unix timestamp in seconds\n ///\n pub fn timestamp(_self: Self) -> u64 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::timestamp()\n }\n }\n\n /// Returns the fee per unit of L2 gas for this transaction (aka the \"L2 gas price\"), as chosen by the user.\n ///\n /// L2 gas covers the cost of executing public functions and handling side-effects within the AVM.\n ///\n /// # Returns\n /// * `u128` - Fee per unit of L2 gas\n ///\n /// Wallet developers should be mindful that the choice of gas price (which is publicly visible) can leak\n /// information about the user, e.g.:\n /// - which wallet software the user is using;\n /// - the amount of time which has elapsed from the time the user's wallet chose a gas price (at the going rate),\n /// to the time of tx submission. This can give clues about the proving time, and hence the nature of the tx.\n /// - the urgency of the transaction (which is kind of unavoidable, if the tx is indeed urgent).\n /// - the wealth of the user.\n /// - the exact user (if the gas price is explicitly chosen by the user to be some unique number like 0.123456789,\n /// or their favorite number). Wallet devs might wish to consider fuzzing the choice of gas price.\n ///\n pub fn min_fee_per_l2_gas(_self: Self) -> u128 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::min_fee_per_l2_gas()\n }\n }\n\n /// Returns the fee per unit of DA (Data Availability) gas (aka the \"DA gas price\").\n ///\n /// DA gas covers the cost of making transaction data available on L1.\n ///\n /// See the warning in `min_fee_per_l2_gas` for how gas prices can be leaky.\n ///\n /// # Returns\n /// * `u128` - Fee per unit of DA gas\n ///\n pub fn min_fee_per_da_gas(_self: Self) -> u128 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::min_fee_per_da_gas()\n }\n }\n\n /// Returns the remaining L2 gas available for this transaction.\n ///\n /// Different AVM opcodes consume different amounts of gas.\n ///\n /// # Returns\n /// * `u32` - Remaining L2 gas units\n ///\n pub fn l2_gas_left(_self: Self) -> u32 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::l2_gas_left()\n }\n }\n\n /// Returns the remaining DA (Data Availability) gas available for this transaction.\n ///\n /// DA gas is consumed when emitting data that needs to be made available on L1, such as public logs or state\n /// updates. All of the side-effects from the private part of the tx also consume DA gas before execution of any\n /// public functions even begins.\n ///\n /// # Returns\n /// * `u32` - Remaining DA gas units\n ///\n pub fn da_gas_left(_self: Self) -> u32 {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::da_gas_left()\n }\n }\n\n /// Checks if the current execution is within a staticcall context, where no state changes or logs are allowed to\n /// be emitted (by this function or any nested function calls).\n ///\n /// # Returns\n /// * `bool` - True if in staticcall context, false otherwise\n ///\n pub fn is_static_call(_self: Self) -> bool {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe {\n avm::is_static_call()\n }\n }\n\n /// Reads raw field values from public storage. Reads N consecutive storage slots starting from the given slot.\n ///\n /// Very low-level function. Users should typically use the public state variable abstractions to perform reads:\n /// PublicMutable & PublicImmutable.\n ///\n /// # Arguments\n /// * `storage_slot` - The starting storage slot to read from\n ///\n /// # Returns\n /// * `[Field; N]` - Array of N field values from consecutive storage slots\n ///\n /// # Generic Parameters\n /// * `N` - the number of consecutive slots to return, starting from the `storage_slot`.\n ///\n pub fn raw_storage_read<let N: u32>(self: Self, storage_slot: Field) -> [Field; N] {\n let mut out = [0; N];\n for i in 0..N {\n // Safety: AVM opcodes are constrained by the AVM itself\n out[i] = unsafe { avm::storage_read(storage_slot + i as Field, self.this_address().to_field()) };\n }\n out\n }\n\n /// Reads a typed value from public storage.\n ///\n /// Low-level function. Users should typically use the public state variable abstractions to perform reads:\n /// PublicMutable & PublicImmutable.\n ///\n /// # Arguments\n /// * `storage_slot` - The storage slot to read from\n ///\n /// # Returns\n /// * `T` - The deserialized value from storage\n ///\n /// # Generic Parameters\n /// * `T` - The type that the caller expects to read from the `storage_slot`.\n ///\n pub fn storage_read<T>(self, storage_slot: Field) -> T\n where\n T: Packable,\n {\n T::unpack(self.raw_storage_read(storage_slot))\n }\n\n /// Writes raw field values to public storage. Writes to N consecutive storage slots starting from the given slot.\n ///\n /// Very low-level function. Users should typically use the public state variable abstractions to perform writes:\n /// PublicMutable & PublicImmutable.\n ///\n /// Public storage writes take effect immediately.\n ///\n /// # Arguments\n /// * `storage_slot` - The starting storage slot to write to\n /// * `values` - Array of N Fields to write to storage\n ///\n pub fn raw_storage_write<let N: u32>(_self: Self, storage_slot: Field, values: [Field; N]) {\n for i in 0..N {\n // Safety: AVM opcodes are constrained by the AVM itself\n unsafe { avm::storage_write(storage_slot + i as Field, values[i]) };\n }\n }\n\n /// Writes a typed value to public storage.\n ///\n /// Low-level function. Users should typically use the public state variable abstractions to perform writes:\n /// PublicMutable & PublicImmutable.\n ///\n /// # Arguments\n /// * `storage_slot` - The storage slot to write to\n /// * `value` - The typed value to write to storage\n ///\n /// # Generic Parameters\n /// * `T` - The type to write to storage.\n ///\n pub fn storage_write<T>(self, storage_slot: Field, value: T)\n where\n T: Packable,\n {\n self.raw_storage_write(storage_slot, value.pack());\n }\n}\n\nimpl Empty for PublicContext {\n fn empty() -> Self {\n PublicContext::new(|| 0)\n }\n}\n"
|
|
3432
3440
|
},
|
|
3433
3441
|
"72": {
|
|
@@ -3453,7 +3461,7 @@
|
|
|
3453
3461
|
"start": 2669
|
|
3454
3462
|
}
|
|
3455
3463
|
],
|
|
3456
|
-
"path": "/
|
|
3464
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/context/returns_hash.nr",
|
|
3457
3465
|
"source": "use crate::{hash::hash_args, oracle::execution_cache};\nuse crate::protocol::traits::Deserialize;\n\n/// The hash of a private contract function call's return value.\n///\n/// Use [`ReturnsHash::get_preimage`] to get the underlying value.\n///\n/// The kernels don't process the actual return values but instead their hashes, so it is up to contracts to populate\n/// oracles with the preimages of these hashes on return to make them available to their callers.\n///\n/// Public calls don't utilize this mechanism since the AVM does process the full return values.\npub struct ReturnsHash {\n hash: Field,\n}\n\nimpl ReturnsHash {\n pub fn new(hash: Field) -> Self {\n ReturnsHash { hash }\n }\n\n /// Fetches the underlying return value from an oracle, constraining that it corresponds to the return data hash.\n pub fn get_preimage<T>(self) -> T\n where\n T: Deserialize,\n {\n // Safety: We verify that the value returned by `load` is the preimage of `hash`, fully constraining it. If `T`\n // is `()`, then `preimage` must be an array of length 0 (since that is `()`'s deserialization length).\n // `hash_args` handles empty arrays following the protocol rules (i.e. an empty args array is signaled with a\n // zero hash), correctly constraining `self.hash`.\n let preimage = unsafe { execution_cache::load(self.hash) };\n assert_eq(self.hash, hash_args(preimage), \"Preimage mismatch\");\n\n Deserialize::deserialize(preimage)\n }\n}\n\nmod test {\n use crate::{\n hash::hash_args,\n oracle::execution_cache,\n test::{helpers::test_environment::TestEnvironment, mocks::MockStruct},\n };\n use crate::protocol::traits::Serialize;\n use super::ReturnsHash;\n use std::test::OracleMock;\n\n #[test]\n unconstrained fn retrieves_preimage() {\n let env = TestEnvironment::new();\n env.private_context(|_| {\n let value = MockStruct::new(4, 7);\n let serialized = value.serialize();\n\n let hash = hash_args(serialized);\n execution_cache::store(serialized, hash);\n\n assert_eq(ReturnsHash::new(hash).get_preimage(), value);\n });\n }\n\n #[test]\n unconstrained fn retrieves_empty_preimage() {\n let env = TestEnvironment::new();\n env.private_context(|_| {\n let value = ();\n let serialized = [];\n\n let hash = hash_args(serialized);\n execution_cache::store(serialized, hash);\n\n assert_eq(ReturnsHash::new(hash).get_preimage(), value);\n });\n }\n\n #[test(should_fail_with = \"Preimage mismatch\")]\n unconstrained fn rejects_bad_preimage() {\n let value = MockStruct::new(4, 7);\n let serialized = value.serialize();\n\n let mut bad_serialized = serialized;\n bad_serialized[0] += 1;\n\n let hash = hash_args(serialized);\n\n let _ = OracleMock::mock(\"aztec_prv_getHashPreimage\").returns(bad_serialized);\n assert_eq(ReturnsHash::new(hash).get_preimage(), value);\n }\n}\n"
|
|
3458
3466
|
},
|
|
3459
3467
|
"73": {
|
|
@@ -3507,7 +3515,7 @@
|
|
|
3507
3515
|
"start": 2891
|
|
3508
3516
|
}
|
|
3509
3517
|
],
|
|
3510
|
-
"path": "/
|
|
3518
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/context/utility_context.nr",
|
|
3511
3519
|
"source": "use crate::oracle::{execution::{get_utility_context, UtilityContextData}, storage::storage_read};\nuse crate::protocol::{\n abis::block_header::BlockHeader, address::AztecAddress, constants::NULL_MSG_SENDER_CONTRACT_ADDRESS,\n traits::Packable,\n};\n\n// If you'll modify this struct don't forget to update utility_context.ts as well.\npub struct UtilityContext {\n block_header: BlockHeader,\n contract_address: AztecAddress,\n msg_sender: AztecAddress,\n}\n\nimpl From<UtilityContextData> for UtilityContext {\n fn from(data: UtilityContextData) -> Self {\n Self { block_header: data.block_header, contract_address: data.contract_address, msg_sender: data.msg_sender }\n }\n}\n\nimpl UtilityContext {\n pub unconstrained fn new() -> Self {\n get_utility_context()\n }\n\n pub unconstrained fn at(contract_address: AztecAddress) -> Self {\n // We get a context with default contract address, and then we construct the final context with the provided\n // contract address.\n let default_context = get_utility_context();\n\n Self { block_header: default_context.block_header, contract_address, msg_sender: default_context.msg_sender }\n }\n\n pub fn block_header(self) -> BlockHeader {\n self.block_header\n }\n\n pub fn block_number(self) -> u32 {\n self.block_header.block_number()\n }\n\n pub fn timestamp(self) -> u64 {\n self.block_header.timestamp()\n }\n\n pub fn this_address(self) -> AztecAddress {\n self.contract_address\n }\n\n /// Returns the address that initiated this utility call.\n ///\n /// This is similar to `msg.sender` in Solidity (hence the name). A utility function called by another contract\n /// (via a nested utility call) sees that contract's address. A utility function invoked directly (e.g. by a wallet\n /// or dApp) has no caller and sees `Option::none`.\n ///\n /// Important Note: utility functions are simulated client-side and never proven, so this value is whatever the\n /// simulator (PXE) set it to: nothing about it is verified onchain. It exists to assist simulation in a\n /// cooperative environment and must not be relied on as a security guarantee.\n pub unconstrained fn maybe_msg_sender(self) -> Option<AztecAddress> {\n if self.msg_sender == NULL_MSG_SENDER_CONTRACT_ADDRESS {\n Option::none()\n } else {\n Option::some(self.msg_sender)\n }\n }\n\n pub fn version(self) -> Field {\n self.block_header.version()\n }\n\n pub fn chain_id(self) -> Field {\n self.block_header.chain_id()\n }\n\n pub unconstrained fn raw_storage_read<let N: u32>(self: Self, storage_slot: Field) -> [Field; N] {\n storage_read(self.block_header, self.this_address(), storage_slot)\n }\n\n pub unconstrained fn storage_read<T>(self, storage_slot: Field) -> T\n where\n T: Packable,\n {\n T::unpack(self.raw_storage_read(storage_slot))\n }\n}\n"
|
|
3512
3520
|
},
|
|
3513
3521
|
"75": {
|
|
@@ -3533,7 +3541,7 @@
|
|
|
3533
3541
|
"start": 6480
|
|
3534
3542
|
}
|
|
3535
3543
|
],
|
|
3536
|
-
"path": "/
|
|
3544
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/contract_self/contract_self_public.nr",
|
|
3537
3545
|
"source": "//! The `self` contract value for public execution contexts.\n\nuse crate::{\n context::{calls::{PublicCall, PublicStaticCall}, PublicContext},\n event::{event_emission::emit_event_in_public, event_interface::EventInterface},\n};\nuse crate::protocol::{address::AztecAddress, traits::{Deserialize, Serialize}};\n\n/// Core interface for interacting with aztec-nr contract features in public execution contexts.\n///\n/// This struct is automatically injected into every [`external`](crate::macros::functions::external) and\n/// [`internal`](crate::macros::functions::internal) contract function marked with `\"public\"` by the Aztec macro\n/// system and is accessible through the `self` variable.\n///\n/// ## Type Parameters\n///\n/// - `Storage`: The contract's storage struct (defined with [`storage`](crate::macros::storage::storage), or `()` if\n/// the contract has no storage\n/// - `CallSelf`: Macro-generated type for calling contract's own non-view functions\n/// - `CallSelfStatic`: Macro-generated type for calling contract's own view functions\n/// - `CallInternal`: Macro-generated type for calling internal functions\npub struct ContractSelfPublic<Storage, CallSelf, CallSelfStatic, CallInternal> {\n /// The address of this contract\n pub address: AztecAddress,\n\n /// The contract's storage instance, representing the struct to which the\n /// [`storage`](crate::macros::storage::storage) macro was applied in your contract. If the contract has no\n /// storage, the type of this will be `()`.\n ///\n /// This storage instance is specialized for the current execution context (public) and\n /// provides access to the contract's state variables.\n ///\n /// ## Developer Note\n ///\n /// If you've arrived here while trying to access your contract's storage while the `Storage` generic type is set\n /// to unit type `()`, it means you haven't yet defined a Storage struct using the\n /// [`storage`](crate::macros::storage::storage) macro in your contract. For guidance on setting this up, please\n /// refer to our docs: https://docs.aztec.network/developers/docs/guides/smart_contracts/storage\n pub storage: Storage,\n\n /// The public execution context.\n pub context: PublicContext,\n\n /// Provides type-safe methods for calling this contract's own non-view functions.\n ///\n /// Example API:\n /// ```noir\n /// self.call_self.some_public_function(args)\n /// ```\n pub call_self: CallSelf,\n\n /// Provides type-safe methods for calling this contract's own view functions.\n ///\n /// Example API:\n /// ```noir\n /// self.call_self_static.some_view_function(args)\n /// ```\n pub call_self_static: CallSelfStatic,\n\n /// Provides type-safe methods for calling internal functions.\n ///\n /// Example API:\n /// ```noir\n /// self.internal.some_internal_function(args)\n /// ```\n pub internal: CallInternal,\n}\n\nimpl<Storage, CallSelf, CallSelfStatic, CallInternal> ContractSelfPublic<Storage, CallSelf, CallSelfStatic, CallInternal> {\n /// Creates a new `ContractSelfPublic` instance for a public function.\n ///\n /// This constructor is called automatically by the macro system and should not be called directly.\n pub fn new(\n context: PublicContext,\n storage: Storage,\n call_self: CallSelf,\n call_self_static: CallSelfStatic,\n internal: CallInternal,\n ) -> Self {\n Self { context, storage, address: context.this_address(), call_self, call_self_static, internal }\n }\n\n /// The address of the contract address that made this function call.\n ///\n /// This is similar to Solidity's `msg.sender` value.\n ///\n /// ## Incognito Calls\n ///\n /// Contracts can call public functions from private ones hiding their identity (see\n ///\n /// [`ContractSelfPrivate::enqueue_incognito`](crate::contract_self::ContractSelfPrivate::enqueue_incognito)).\n /// This function reverts when executed in such a context.\n ///\n /// If you need to handle these cases, use [`PublicContext::maybe_msg_sender`].\n pub fn msg_sender(self: Self) -> AztecAddress {\n self.context.maybe_msg_sender().unwrap()\n }\n\n /// Emits an event publicly.\n ///\n /// Public events are emitted as plaintext and are therefore visible to everyone. This is is the same as Solidity\n /// events on EVM chains.\n ///\n /// Unlike private events, they don't require delivery of an event message.\n ///\n /// # Example\n /// ```noir\n /// #[event]\n /// struct Update { value: Field }\n ///\n /// #[external(\"public\")]\n /// fn publish_update(value: Field) {\n /// self.emit(Update { value });\n /// }\n /// ```\n ///\n /// # Cost\n ///\n /// Public event emission is achieved by emitting public transaction logs. A total of `N+1` fields are emitted,\n /// where `N` is the serialization length of the event.\n pub unconstrained fn emit<Event>(&mut self, event: Event)\n where\n Event: EventInterface + Serialize,\n {\n emit_event_in_public(self.context, event);\n }\n\n /// Makes a public contract call.\n ///\n /// Will revert if the called function reverts or runs out of gas.\n ///\n /// # Arguments\n /// * `call` - The object representing the public function to invoke.\n ///\n /// # Returns\n /// * `T` - Whatever data the called function has returned.\n ///\n /// # Example\n /// ```noir\n /// self.call(Token::at(address).transfer_in_public(recipient, amount));\n /// ```\n ///\n pub unconstrained fn call<let M: u32, let N: u32, T>(self, call: PublicCall<M, N, T>) -> T\n where\n T: Deserialize,\n {\n call.call(self.context)\n }\n\n /// Makes a public read-only contract call.\n ///\n /// This is similar to Solidity's `staticcall`. The called function cannot modify state or emit events. Any nested\n /// calls are constrained to also be static calls.\n ///\n /// Will revert if the called function reverts or runs out of gas.\n ///\n /// # Arguments\n /// * `call` - The object representing the read-only public function to invoke.\n ///\n /// # Returns\n /// * `T` - Whatever data the called function has returned.\n ///\n /// # Example\n /// ```noir\n /// self.view(Token::at(address).balance_of_public(recipient));\n /// ```\n ///\n pub unconstrained fn view<let M: u32, let N: u32, T>(self, call: PublicStaticCall<M, N, T>) -> T\n where\n T: Deserialize,\n {\n call.view(self.context)\n }\n}\n"
|
|
3538
3546
|
},
|
|
3539
3547
|
"78": {
|
|
@@ -3583,90 +3591,86 @@
|
|
|
3583
3591
|
"start": 3259
|
|
3584
3592
|
}
|
|
3585
3593
|
],
|
|
3586
|
-
"path": "/
|
|
3594
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/ephemeral/mod.nr",
|
|
3587
3595
|
"source": "use crate::oracle::ephemeral_oracles;\nuse crate::protocol::traits::{Deserialize, Serialize};\nuse crate::protocol::utils::{reader::Reader, writer::Writer};\nuse crate::unconstrained_array::{ArrayOracles, UnconstrainedArray};\n\n/// A dynamically sized array that exists only during a single contract call frame.\n///\n/// Ephemeral arrays are backed by in-memory storage on the PXE side rather than a persistent database. Each contract\n/// call frame gets its own isolated slot space of ephemeral arrays. Child simulations cannot see the parent's\n/// ephemeral arrays, and vice versa.\n///\n/// Each logical array operation (push, pop, get, etc.) is a single oracle call, making ephemeral arrays significantly\n/// cheaper than capsule arrays.\n///\n/// ## Use Cases\n///\n/// Ephemeral arrays are designed for passing data between PXE (TypeScript) and contracts (Noir) during simulation,\n/// for example, note validation requests or event validation responses. This data type is appropriate for data that\n/// is not supposed to be persisted.\n///\n/// For data that needs to persist across simulations, contract calls, etc, use\n/// [`CapsuleArray`](crate::capsules::CapsuleArray) instead.\n///\n/// For data that must be shared across all frames of the same contract (private and utility) within one top-level PXE\n/// call (transaction simulation or utility call) but not persisted, use\n/// [`TransientArray`](crate::transient::TransientArray).\npub type EphemeralArray<T> = UnconstrainedArray<T, EphemeralOracles>;\n\npub struct EphemeralOracles {}\n\nimpl ArrayOracles for EphemeralOracles {\n unconstrained fn len_oracle(slot: Field) -> u32 {\n ephemeral_oracles::len_oracle(slot)\n }\n\n unconstrained fn push_oracle<let N: u32>(slot: Field, values: [Field; N]) -> u32 {\n ephemeral_oracles::push_oracle(slot, values)\n }\n\n unconstrained fn pop_oracle<let N: u32>(slot: Field) -> [Field; N] {\n ephemeral_oracles::pop_oracle(slot)\n }\n\n unconstrained fn get_oracle<let N: u32>(slot: Field, index: u32) -> [Field; N] {\n ephemeral_oracles::get_oracle(slot, index)\n }\n\n unconstrained fn set_oracle<let N: u32>(slot: Field, index: u32, values: [Field; N]) {\n ephemeral_oracles::set_oracle(slot, index, values)\n }\n\n unconstrained fn remove_oracle(slot: Field, index: u32) {\n ephemeral_oracles::remove_oracle(slot, index)\n }\n\n unconstrained fn clear_oracle(slot: Field) {\n ephemeral_oracles::clear_oracle(slot)\n }\n}\n\n/// Serializes an `EphemeralArray` as its slot, allowing oracle function signatures to use ephemeral array types\n/// instead of opaque `Field` slots.\nimpl<T> Serialize for UnconstrainedArray<T, EphemeralOracles> {\n let N: u32 = 1;\n\n fn serialize(self) -> [Field; Self::N] {\n [self.slot]\n }\n\n fn stream_serialize<let K: u32>(self, writer: &mut Writer<K>) {\n writer.write(self.slot);\n }\n}\n\n/// Deserializes a single Field into an `EphemeralArray` handle, treating the field value as the slot identifier.\nimpl<T> Deserialize for UnconstrainedArray<T, EphemeralOracles> {\n let N: u32 = 1;\n\n fn deserialize(fields: [Field; Self::N]) -> Self {\n Self { slot: fields[0] }\n }\n\n fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {\n Self { slot: reader.read() }\n }\n}\n\n#[crate::unconstrained_array::test_suite::unconstrained_array_tests(quote { crate::ephemeral::EphemeralOracles })]\nmod test {}\n"
|
|
3588
3596
|
},
|
|
3589
3597
|
"84": {
|
|
3590
3598
|
"function_locations": [
|
|
3591
3599
|
{
|
|
3592
3600
|
"name": "record_retractable_fact",
|
|
3593
|
-
"start":
|
|
3601
|
+
"start": 2643
|
|
3594
3602
|
},
|
|
3595
3603
|
{
|
|
3596
3604
|
"name": "record_non_retractable_fact",
|
|
3597
|
-
"start":
|
|
3605
|
+
"start": 3279
|
|
3598
3606
|
},
|
|
3599
3607
|
{
|
|
3600
3608
|
"name": "delete_fact_collection",
|
|
3601
|
-
"start":
|
|
3609
|
+
"start": 3916
|
|
3602
3610
|
},
|
|
3603
3611
|
{
|
|
3604
3612
|
"name": "get_fact_collection",
|
|
3605
|
-
"start":
|
|
3613
|
+
"start": 4294
|
|
3606
3614
|
},
|
|
3607
3615
|
{
|
|
3608
3616
|
"name": "get_fact_collections_by_type",
|
|
3609
|
-
"start":
|
|
3617
|
+
"start": 4687
|
|
3610
3618
|
},
|
|
3611
3619
|
{
|
|
3612
3620
|
"name": "test::setup",
|
|
3613
|
-
"start":
|
|
3614
|
-
},
|
|
3615
|
-
{
|
|
3616
|
-
"name": "test::make_payload",
|
|
3617
|
-
"start": 5744
|
|
3621
|
+
"start": 5457
|
|
3618
3622
|
},
|
|
3619
3623
|
{
|
|
3620
3624
|
"name": "test::assert_payload",
|
|
3621
|
-
"start":
|
|
3625
|
+
"start": 5649
|
|
3622
3626
|
},
|
|
3623
3627
|
{
|
|
3624
3628
|
"name": "test::record_fact",
|
|
3625
|
-
"start":
|
|
3629
|
+
"start": 5890
|
|
3626
3630
|
},
|
|
3627
3631
|
{
|
|
3628
3632
|
"name": "test::records_and_reads_a_fact",
|
|
3629
|
-
"start":
|
|
3633
|
+
"start": 6179
|
|
3630
3634
|
},
|
|
3631
3635
|
{
|
|
3632
3636
|
"name": "test::reads_collections_by_type",
|
|
3633
|
-
"start":
|
|
3637
|
+
"start": 7056
|
|
3634
3638
|
},
|
|
3635
3639
|
{
|
|
3636
3640
|
"name": "test::records_a_retractable_fact_finalized_at_latest_block",
|
|
3637
|
-
"start":
|
|
3641
|
+
"start": 7806
|
|
3638
3642
|
},
|
|
3639
3643
|
{
|
|
3640
3644
|
"name": "test::retractable_fact_above_proven_tip_is_pending",
|
|
3641
|
-
"start":
|
|
3645
|
+
"start": 9062
|
|
3642
3646
|
},
|
|
3643
3647
|
{
|
|
3644
3648
|
"name": "test::deletes_a_fact_collection",
|
|
3645
|
-
"start":
|
|
3649
|
+
"start": 9959
|
|
3646
3650
|
},
|
|
3647
3651
|
{
|
|
3648
3652
|
"name": "test::reading_unknown_collection_returns_none",
|
|
3649
|
-
"start":
|
|
3653
|
+
"start": 10465
|
|
3650
3654
|
},
|
|
3651
3655
|
{
|
|
3652
3656
|
"name": "test::cannot_record_for_other_contract",
|
|
3653
|
-
"start":
|
|
3657
|
+
"start": 10874
|
|
3654
3658
|
},
|
|
3655
3659
|
{
|
|
3656
3660
|
"name": "test::re_recording_an_identical_fact_is_a_no_op",
|
|
3657
|
-
"start":
|
|
3661
|
+
"start": 11176
|
|
3658
3662
|
},
|
|
3659
3663
|
{
|
|
3660
3664
|
"name": "test::deleting_a_non_existing_collection_is_a_no_op",
|
|
3661
|
-
"start":
|
|
3665
|
+
"start": 11672
|
|
3662
3666
|
},
|
|
3663
3667
|
{
|
|
3664
3668
|
"name": "test::recording_a_fact_after_delete_recreates_the_collection",
|
|
3665
|
-
"start":
|
|
3669
|
+
"start": 12104
|
|
3666
3670
|
}
|
|
3667
3671
|
],
|
|
3668
|
-
"path": "/
|
|
3669
|
-
"source": "//! Per-contract storage of immutable facts grouped into collections.\n//!\n//! A fact is a contract-defined, typed, immutable datum. Facts are grouped into collections identified by a\n//! `(collection type, collection id)` tuple.\n//!\n//! They are stored in PXE's FactStore, which automatically deals with reorgs by removing any facts\n//! associated with blocks that have been pruned.\nuse crate::ephemeral::EphemeralArray;\nuse crate::oracle::fact_store::{\n delete_fact_collection_oracle, get_fact_collection_oracle, get_fact_collections_by_type_oracle, record_fact_oracle,\n};\nuse crate::protocol::{address::AztecAddress, traits::{Deserialize, Serialize}};\n\nmod origin_state;\npub use origin_state::OriginBlockState;\n\n/// The block a retractable fact originates from.\n#[derive(Deserialize, Eq, Serialize)]\npub struct OriginBlock {\n pub block_number: u32,\n pub block_hash: Field,\n}\n\n/// A retractable fact's origin block.\n#[derive(Deserialize, Eq, Serialize)]\npub struct RetractableFactOrigin {\n pub block_number: u32,\n pub block_hash: Field,\n pub block_state: OriginBlockState,\n}\n\n/// A single immutable fact in a collection.\n#[derive(Deserialize, Serialize)]\npub struct Fact {\n /// A user-defined identifier for fact kinds. Typically used to determine how to deserialize `payload`.\n pub fact_type_id: Field,\n pub payload: EphemeralArray<Field>,\n /// The block the fact is associated to, if any. A fact with an origin block is said to be a 'retractable' fact,\n /// and will be automatically deleted if its origin block gets pruned in a reorg. Typically used by facts\n /// associated with a transaction (e.g. 'processed entry X using data from tx Y in block Z').\n pub origin_block: Option<RetractableFactOrigin>,\n}\n\n/// A fact collection as returned by the store.\n#[derive(Deserialize, Serialize)]\npub struct FactCollection {\n pub contract_address: AztecAddress,\n pub scope: AztecAddress,\n /// The collection's type. A single contract may have facts in collections of different types (e.g. one for the\n /// processing offchain messages, another for partial notes, etc.).\n pub fact_collection_type_id: Field,\n /// The collection's unique identifier among the other collections of this type in this contract and scope.\n pub fact_collection_id: Field,\n pub facts: EphemeralArray<Fact>,\n}\n\n/// Records a retractable fact into a collection: PXE prunes it if `origin_block` is reorg'd away. Re-recording an\n/// identical fact is a no-op.\npub unconstrained fn record_retractable_fact(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n fact_type_id: Field,\n payload: EphemeralArray<Field>,\n origin_block: OriginBlock,\n) {\n record_fact_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n fact_type_id,\n payload,\n Option::some(origin_block),\n );\n}\n\n/// Records a non-retractable fact into a collection: it survives reorgs and will persist until the fact collection\n/// itself is deleted. Re-recording an identical fact is a no-op.\npub unconstrained fn record_non_retractable_fact(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n fact_type_id: Field,\n payload: EphemeralArray<Field>,\n) {\n record_fact_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n fact_type_id,\n payload,\n Option::none(),\n );\n}\n\n/// Deletes a fact collection, removing all its facts from PXE storage.\n///\n/// Collections must be eventually deleted to reclaim storage and to stop reprocessing past the lifespan of the\n/// workflows they enable.\n///\n/// A no-op if no such collection exists.\npub unconstrained fn delete_fact_collection(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n) {\n delete_fact_collection_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n );\n}\n\n/// Fetches a fact collection.\npub unconstrained fn get_fact_collection(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n) -> Option<FactCollection> {\n get_fact_collection_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n )\n}\n\n/// Returns every fact collection of `fact_collection_type_id`.\npub unconstrained fn get_fact_collections_by_type(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n) -> EphemeralArray<FactCollection> {\n get_fact_collections_by_type_oracle(contract_address, scope, fact_collection_type_id)\n}\n\nmod test {\n use crate::ephemeral::EphemeralArray;\n use crate::facts::{\n delete_fact_collection, get_fact_collection, get_fact_collections_by_type, OriginBlock,\n record_non_retractable_fact, record_retractable_fact,\n };\n use crate::protocol::address::AztecAddress;\n use crate::protocol::traits::{FromField, ToField};\n use crate::test::helpers::test_environment::TestEnvironment;\n\n global TYPE_ID: Field = 42;\n global COLLECTION_ID: Field = 7;\n global FACT_TYPE_ID: Field = 99;\n global PAYLOAD: [Field; 3] = [123, 456, 789];\n\n unconstrained fn setup() -> (TestEnvironment, AztecAddress) {\n let mut env = TestEnvironment::new();\n let scope = env.create_light_account();\n (env, scope)\n }\n\n unconstrained fn make_payload<let N: u32>(values: [Field; N]) -> EphemeralArray<Field> {\n let payload: EphemeralArray<Field> = EphemeralArray::empty();\n for i in 0..N {\n payload.push(values[i]);\n }\n payload\n }\n\n unconstrained fn assert_payload(payload: EphemeralArray<Field>) {\n assert_eq(payload.len(), PAYLOAD.len());\n for i in 0..PAYLOAD.len() {\n assert_eq(payload.get(i), PAYLOAD[i]);\n }\n }\n\n unconstrained fn record_fact(contract_address: AztecAddress, scope: AztecAddress) {\n record_non_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n make_payload(PAYLOAD),\n );\n }\n\n #[test]\n unconstrained fn records_and_reads_a_fact() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.contract_address, contract_address);\n assert_eq(collection.scope, scope);\n assert_eq(collection.fact_collection_type_id, TYPE_ID);\n assert_eq(collection.fact_collection_id, COLLECTION_ID);\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n assert(fact.origin_block.is_none());\n });\n }\n\n #[test]\n unconstrained fn reads_collections_by_type() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n\n let collections = get_fact_collections_by_type(contract_address, scope, TYPE_ID);\n assert_eq(collections.len(), 1);\n\n let collection = collections.get(0);\n assert_eq(collection.fact_collection_id, COLLECTION_ID);\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n });\n }\n\n #[test]\n unconstrained fn records_a_retractable_fact_finalized_at_latest_block() {\n let (env, scope) = setup();\n let origin_block_number = env.last_block_number();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n make_payload(PAYLOAD),\n OriginBlock { block_number: origin_block_number, block_hash: 0xabc },\n );\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n\n let origin = fact.origin_block.unwrap();\n assert_eq(origin.block_number, origin_block_number);\n assert_eq(origin.block_hash, 0xabc);\n // TXE finalizes every mined block, so an origin at the latest block is Finalized.\n assert(origin.block_state.is_finalized());\n });\n }\n\n #[test]\n unconstrained fn retractable_fact_above_proven_tip_is_pending() {\n let (env, scope) = setup();\n let future_block_number = env.last_block_number() + 100;\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n make_payload(PAYLOAD),\n OriginBlock { block_number: future_block_number, block_hash: 0xabc },\n );\n\n let origin = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID)\n .unwrap()\n .facts\n .get(0)\n .origin_block\n .unwrap();\n assert(origin.block_state.is_pending());\n });\n }\n\n #[test]\n unconstrained fn deletes_a_fact_collection() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n\n let collections = get_fact_collections_by_type(contract_address, scope, TYPE_ID);\n assert_eq(collections.len(), 0);\n });\n }\n\n #[test]\n unconstrained fn reading_unknown_collection_returns_none() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n assert(collection.is_none());\n });\n }\n\n #[test(should_fail_with = \"not allowed to access\")]\n unconstrained fn cannot_record_for_other_contract() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let other = AztecAddress::from_field(context.this_address().to_field() + 1);\n record_fact(other, scope);\n });\n }\n\n #[test]\n unconstrained fn re_recording_an_identical_fact_is_a_no_op() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n record_fact(contract_address, scope);\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.facts.len(), 1);\n });\n }\n\n #[test]\n unconstrained fn deleting_a_non_existing_collection_is_a_no_op() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n\n assert(get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).is_none());\n });\n }\n\n #[test]\n unconstrained fn recording_a_fact_after_delete_recreates_the_collection() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n\n record_fact(contract_address, scope);\n let collection_before_delete =\n get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection_before_delete.facts.len(), 1);\n\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n assert(get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).is_none());\n\n record_fact(contract_address, scope);\n let collection_after_recreate =\n get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection_after_recreate.facts.len(), 1);\n });\n }\n}\n"
|
|
3672
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/facts/mod.nr",
|
|
3673
|
+
"source": "//! Per-contract storage of immutable facts grouped into collections.\n//!\n//! A fact is a contract-defined, typed, immutable datum. Facts are grouped into collections identified by a\n//! `(collection type, collection id)` tuple.\n//!\n//! They are stored in PXE's FactStore, which automatically deals with reorgs by removing any facts\n//! associated with blocks that have been pruned.\nuse crate::ephemeral::EphemeralArray;\nuse crate::oracle::block_reference::BlockReference;\nuse crate::oracle::fact_store::{\n delete_fact_collection_oracle, get_fact_collection_oracle, get_fact_collections_by_type_oracle, record_fact_oracle,\n};\nuse crate::protocol::{address::AztecAddress, traits::{Deserialize, Serialize}};\n\nmod origin_state;\npub use origin_state::OriginBlockState;\n\n/// A retractable fact's origin block.\n#[derive(Deserialize, Eq, Serialize)]\npub struct RetractableFactOrigin {\n pub block_number: u32,\n pub block_hash: Field,\n pub block_state: OriginBlockState,\n}\n\n/// A single immutable fact in a collection.\n#[derive(Deserialize, Serialize)]\npub struct Fact {\n /// A user-defined identifier for fact kinds. Typically used to determine how to deserialize `payload`.\n pub fact_type_id: Field,\n pub payload: EphemeralArray<Field>,\n /// The block the fact is associated to, if any. A fact with an origin block is said to be a 'retractable' fact,\n /// and will be automatically deleted if its origin block gets pruned in a reorg. Typically used by facts\n /// associated with a transaction (e.g. 'processed entry X using data from tx Y in block Z').\n pub origin_block: Option<RetractableFactOrigin>,\n}\n\n/// A fact collection as returned by the store.\n#[derive(Deserialize, Serialize)]\npub struct FactCollection {\n pub contract_address: AztecAddress,\n pub scope: AztecAddress,\n /// The collection's type. A single contract may have facts in collections of different types (e.g. one for the\n /// processing offchain messages, another for partial notes, etc.).\n pub fact_collection_type_id: Field,\n /// The collection's unique identifier among the other collections of this type in this contract and scope.\n pub fact_collection_id: Field,\n pub facts: EphemeralArray<Fact>,\n}\n\n/// Records a retractable fact into a collection: PXE prunes it if `origin_block` is reorg'd away. Re-recording an\n/// identical fact is a no-op.\npub unconstrained fn record_retractable_fact(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n fact_type_id: Field,\n payload: EphemeralArray<Field>,\n origin_block: BlockReference,\n) {\n record_fact_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n fact_type_id,\n payload,\n Option::some(origin_block),\n );\n}\n\n/// Records a non-retractable fact into a collection: it survives reorgs and will persist until the fact collection\n/// itself is deleted. Re-recording an identical fact is a no-op.\npub unconstrained fn record_non_retractable_fact(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n fact_type_id: Field,\n payload: EphemeralArray<Field>,\n) {\n record_fact_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n fact_type_id,\n payload,\n Option::none(),\n );\n}\n\n/// Deletes a fact collection, removing all its facts from PXE storage.\n///\n/// Collections must be eventually deleted to reclaim storage and to stop reprocessing past the lifespan of the\n/// workflows they enable.\n///\n/// A no-op if no such collection exists.\npub unconstrained fn delete_fact_collection(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n) {\n delete_fact_collection_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n );\n}\n\n/// Fetches a fact collection.\npub unconstrained fn get_fact_collection(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n fact_collection_id: Field,\n) -> Option<FactCollection> {\n get_fact_collection_oracle(\n contract_address,\n scope,\n fact_collection_type_id,\n fact_collection_id,\n )\n}\n\n/// Returns every fact collection of `fact_collection_type_id`.\npub unconstrained fn get_fact_collections_by_type(\n contract_address: AztecAddress,\n scope: AztecAddress,\n fact_collection_type_id: Field,\n) -> EphemeralArray<FactCollection> {\n get_fact_collections_by_type_oracle(contract_address, scope, fact_collection_type_id)\n}\n\nmod test {\n use crate::ephemeral::EphemeralArray;\n use crate::facts::{\n delete_fact_collection, get_fact_collection, get_fact_collections_by_type, record_non_retractable_fact,\n record_retractable_fact,\n };\n use crate::oracle::block_reference::BlockReference;\n use crate::protocol::address::AztecAddress;\n use crate::protocol::traits::{FromField, ToField};\n use crate::test::helpers::test_environment::TestEnvironment;\n\n global TYPE_ID: Field = 42;\n global COLLECTION_ID: Field = 7;\n global FACT_TYPE_ID: Field = 99;\n global PAYLOAD: [Field; 3] = [123, 456, 789];\n\n unconstrained fn setup() -> (TestEnvironment, AztecAddress) {\n let mut env = TestEnvironment::new();\n let scope = env.create_light_account();\n (env, scope)\n }\n\n unconstrained fn assert_payload(payload: EphemeralArray<Field>) {\n assert_eq(payload.len(), PAYLOAD.len());\n for i in 0..PAYLOAD.len() {\n assert_eq(payload.get(i), PAYLOAD[i]);\n }\n }\n\n unconstrained fn record_fact(contract_address: AztecAddress, scope: AztecAddress) {\n record_non_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n EphemeralArray::from_array(PAYLOAD),\n );\n }\n\n #[test]\n unconstrained fn records_and_reads_a_fact() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.contract_address, contract_address);\n assert_eq(collection.scope, scope);\n assert_eq(collection.fact_collection_type_id, TYPE_ID);\n assert_eq(collection.fact_collection_id, COLLECTION_ID);\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n assert(fact.origin_block.is_none());\n });\n }\n\n #[test]\n unconstrained fn reads_collections_by_type() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n\n let collections = get_fact_collections_by_type(contract_address, scope, TYPE_ID);\n assert_eq(collections.len(), 1);\n\n let collection = collections.get(0);\n assert_eq(collection.fact_collection_id, COLLECTION_ID);\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n });\n }\n\n #[test]\n unconstrained fn records_a_retractable_fact_finalized_at_latest_block() {\n let (env, scope) = setup();\n let origin_block_number = env.last_block_number();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n EphemeralArray::from_array(PAYLOAD),\n BlockReference { block_number: origin_block_number, block_hash: 0xabc },\n );\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.facts.len(), 1);\n\n let fact = collection.facts.get(0);\n assert_eq(fact.fact_type_id, FACT_TYPE_ID);\n assert_payload(fact.payload);\n\n let origin = fact.origin_block.unwrap();\n assert_eq(origin.block_number, origin_block_number);\n assert_eq(origin.block_hash, 0xabc);\n // TXE finalizes every mined block, so an origin at the latest block is Finalized.\n assert(origin.block_state.is_finalized());\n });\n }\n\n #[test]\n unconstrained fn retractable_fact_above_proven_tip_is_pending() {\n let (env, scope) = setup();\n let future_block_number = env.last_block_number() + 100;\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_retractable_fact(\n contract_address,\n scope,\n TYPE_ID,\n COLLECTION_ID,\n FACT_TYPE_ID,\n EphemeralArray::from_array(PAYLOAD),\n BlockReference { block_number: future_block_number, block_hash: 0xabc },\n );\n\n let origin = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID)\n .unwrap()\n .facts\n .get(0)\n .origin_block\n .unwrap();\n assert(origin.block_state.is_pending());\n });\n }\n\n #[test]\n unconstrained fn deletes_a_fact_collection() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n\n let collections = get_fact_collections_by_type(contract_address, scope, TYPE_ID);\n assert_eq(collections.len(), 0);\n });\n }\n\n #[test]\n unconstrained fn reading_unknown_collection_returns_none() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n assert(collection.is_none());\n });\n }\n\n #[test(should_fail_with = \"not allowed to access\")]\n unconstrained fn cannot_record_for_other_contract() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let other = AztecAddress::from_field(context.this_address().to_field() + 1);\n record_fact(other, scope);\n });\n }\n\n #[test]\n unconstrained fn re_recording_an_identical_fact_is_a_no_op() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n record_fact(contract_address, scope);\n record_fact(contract_address, scope);\n\n let collection = get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection.facts.len(), 1);\n });\n }\n\n #[test]\n unconstrained fn deleting_a_non_existing_collection_is_a_no_op() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n\n assert(get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).is_none());\n });\n }\n\n #[test]\n unconstrained fn recording_a_fact_after_delete_recreates_the_collection() {\n let (env, scope) = setup();\n env.private_context(|context| {\n let contract_address = context.this_address();\n\n record_fact(contract_address, scope);\n let collection_before_delete =\n get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection_before_delete.facts.len(), 1);\n\n delete_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID);\n assert(get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).is_none());\n\n record_fact(contract_address, scope);\n let collection_after_recreate =\n get_fact_collection(contract_address, scope, TYPE_ID, COLLECTION_ID).unwrap();\n assert_eq(collection_after_recreate.facts.len(), 1);\n });\n }\n}\n"
|
|
3670
3674
|
},
|
|
3671
3675
|
"86": {
|
|
3672
3676
|
"function_locations": [
|
|
@@ -3711,7 +3715,7 @@
|
|
|
3711
3715
|
"start": 5428
|
|
3712
3716
|
}
|
|
3713
3717
|
],
|
|
3714
|
-
"path": "/
|
|
3718
|
+
"path": "/home/nventuro/node/noir-projects/aztec-nr/aztec/src/hash.nr",
|
|
3715
3719
|
"source": "//! Aztec hash functions.\n\nuse crate::protocol::{\n address::{AztecAddress, EthAddress},\n constants::{\n DOM_SEP__FUNCTION_ARGS, DOM_SEP__MESSAGE_NULLIFIER, DOM_SEP__PUBLIC_BYTECODE, DOM_SEP__PUBLIC_CALLDATA,\n DOM_SEP__SECRET_HASH, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS,\n },\n hash::{poseidon2_hash_subarray, poseidon2_hash_with_separator, sha256_to_field},\n traits::ToField,\n};\n\npub use crate::protocol::hash::compute_siloed_nullifier;\n\npub fn compute_secret_hash<let N: u32>(secret: [Field; N]) -> Field {\n poseidon2_hash_with_separator(secret, DOM_SEP__SECRET_HASH)\n}\n\npub fn compute_l1_to_l2_message_hash(\n sender: EthAddress,\n chain_id: Field,\n recipient: AztecAddress,\n version: Field,\n content: Field,\n secret_hash: Field,\n leaf_index: Field,\n) -> Field {\n let mut hash_bytes = [0 as u8; 224];\n let sender_bytes: [u8; 32] = sender.to_field().to_be_bytes();\n let chain_id_bytes: [u8; 32] = chain_id.to_be_bytes();\n let recipient_bytes: [u8; 32] = recipient.to_field().to_be_bytes();\n let version_bytes: [u8; 32] = version.to_be_bytes();\n let content_bytes: [u8; 32] = content.to_be_bytes();\n let secret_hash_bytes: [u8; 32] = secret_hash.to_be_bytes();\n let leaf_index_bytes: [u8; 32] = leaf_index.to_be_bytes();\n\n for i in 0..32 {\n hash_bytes[i] = sender_bytes[i];\n hash_bytes[i + 32] = chain_id_bytes[i];\n hash_bytes[i + 64] = recipient_bytes[i];\n hash_bytes[i + 96] = version_bytes[i];\n hash_bytes[i + 128] = content_bytes[i];\n hash_bytes[i + 160] = secret_hash_bytes[i];\n hash_bytes[i + 192] = leaf_index_bytes[i];\n }\n\n sha256_to_field(hash_bytes)\n}\n\n// The nullifier of an l1 to l2 message is the hash of the message salted with the secret.\npub fn compute_l1_to_l2_message_nullifier<let N: u32>(message_hash: Field, secret: [Field; N]) -> Field {\n poseidon2_hash_with_separator([message_hash].concat(secret), DOM_SEP__MESSAGE_NULLIFIER)\n}\n\n// Computes the hash of input arguments or return values for private functions, or for authwit creation.\npub fn hash_args<let N: u32>(args: [Field; N]) -> Field {\n if args.len() == 0 {\n 0\n } else {\n poseidon2_hash_with_separator(args, DOM_SEP__FUNCTION_ARGS)\n }\n}\n\n// Computes the hash of calldata for public functions.\npub fn hash_calldata_array<let N: u32>(calldata: [Field; N]) -> Field {\n poseidon2_hash_with_separator(calldata, DOM_SEP__PUBLIC_CALLDATA)\n}\n\n/// Computes the public bytecode commitment for a contract class. The commitment is `hash([(length | separator),\n/// ...bytecode])`.\n///\n/// @param packed_bytecode - The packed bytecode of the contract class. 0th word is the length in bytes.\n/// packed_bytecode is mutable so that we can avoid copying the array to construct one starting with first_field\n/// instead of length. @returns The public bytecode commitment.\npub fn compute_public_bytecode_commitment(\n mut packed_public_bytecode: [Field; MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS],\n) -> Field {\n // First field element contains the length of the bytecode\n let bytecode_length_in_bytes: u32 = packed_public_bytecode[0] as u32;\n let bytecode_length_in_fields: u32 = (bytecode_length_in_bytes / 31) + (bytecode_length_in_bytes % 31 != 0) as u32;\n // Don't allow empty public bytecode. AVM doesn't handle execution of contracts that exist with empty bytecode.\n assert(bytecode_length_in_fields != 0);\n assert(bytecode_length_in_fields < MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);\n\n // Packed_bytecode's 0th entry is the length. Append it to the separator before hashing.\n let first_field = DOM_SEP__PUBLIC_BYTECODE.to_field() + (packed_public_bytecode[0] as u64 << 32) as Field;\n packed_public_bytecode[0] = first_field;\n\n // `fields_to_hash` is the number of fields from the start of `packed_public_bytecode` that should be included in\n // the hash. Fields after this length are ignored. +1 to account for the prepended field.\n let num_fields_to_hash = bytecode_length_in_fields + 1;\n\n poseidon2_hash_subarray(packed_public_bytecode, num_fields_to_hash)\n}\n\n#[test]\nunconstrained fn secret_hash_matches_typescript() {\n let secret = 8;\n let hash = compute_secret_hash([secret]);\n\n // The following value was generated by `yarn-project/stdlib/src/hash/hash.test.ts`\n let secret_hash_from_ts = 0x1848b066724ab0ffb50ecb0ee3398eb839f162823d262bad959721a9c13d1e96;\n\n assert_eq(hash, secret_hash_from_ts);\n}\n\n#[test]\nunconstrained fn var_args_hash_matches_typescript() {\n let mut input = [0; 100];\n for i in 0..100 {\n input[i] = i as Field;\n }\n let hash = hash_args(input);\n\n // The following value was generated by `yarn-project/stdlib/src/hash/hash.test.ts`\n let var_args_hash_from_ts = 0x262e5e121a8efc0382566ab42f0ae2a78bd85db88484f83018fe07fc2552ba0c;\n\n assert_eq(hash, var_args_hash_from_ts);\n}\n\n#[test]\nunconstrained fn compute_calldata_hash() {\n let mut input = [0; 100];\n for i in 0..input.len() {\n input[i] = i as Field;\n }\n let hash = hash_calldata_array(input);\n\n // The following value was generated by `yarn-project/stdlib/src/hash/hash.test.ts`\n let calldata_hash_from_ts = 0x14a1539bdb1d26e03097cf4d40c87e02ca03f0bb50a3e617ace5a7bfd3943944;\n\n // Used in cpp vm2 tests:\n assert_eq(hash, calldata_hash_from_ts);\n}\n\n#[test]\nunconstrained fn public_bytecode_commitment() {\n let mut input = [0; MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS];\n let len = 99;\n for i in 1..len + 1 {\n input[i] = i as Field;\n }\n input[0] = (len as Field) * 31;\n let hash = compute_public_bytecode_commitment(input);\n // Used in cpp vm2 tests:\n assert_eq(hash, 0x09348974e76c3602893d7a4b4bb52c2ec746f1ade5004ac471d0fbb4587a81a6);\n}\n"
|
|
3716
3720
|
}
|
|
3717
3721
|
},
|
|
@@ -3768,7 +3772,7 @@
|
|
|
3768
3772
|
"abi_public",
|
|
3769
3773
|
"abi_only_self"
|
|
3770
3774
|
],
|
|
3771
|
-
"debug_symbols": "
|
|
3775
|
+
"debug_symbols": "rZhhb+IwDIb/Sz/zIY7tJOavnE4TY92EhAAxOOk08d/PGXFbOCXXG/synrrtWzt5nWb96F765/Pb02b3un/vlj8+uufjZrvdvD1t9+vVabPfafSjc/kPQOiWvOjAQ7eU/KvHgAqoAchnMBQgV04RF+AciRm4QLBISAUiGkSFpJB8AXEGervXR3jnDKQAWgTJwE6RRcgibBFOBYI3iAUiGIQCyR6RLI2UBTVnL2iQroAODSwCFgGL+JxGyiAF0CKo16BTIDTIEVBgLBDAQDPEfFd0BlwgWSRZRCwiZJCuQDnnK8QC4A3KIyjP/xVUkFwGKZCTv4JFyCJkEbZINgBBBjbI16hbKOZrKIMUSLGAaD6Uny4aYbhcFp159el07Pts1Yl51dKH1bHfnbrl7rzdLrpfq+3586L3w2r3+XtaHfWsZtTvXvRXBV832z7TZTHe7eq3spNY7mbgNAhop9xIQF2CXPBFQkecqhK+LgFJrAYQcFUJrEt4xx6LhjLGQSTealBDIyZTkEkdKc2tw2vfmQJGrNYR6hJIxEUC1V1jFXyjEL9hJNKjI9HyFQ2mYIqx7quGhropDMbi6lBAw5segherBAL52liAb02JSWCoD8Y/0uA4pBGdVNNouJO89QiRH0eUvzaek0rux7PhTnHmC/FjEUTzbcHmbmYIVVu0JDDYODDKOKGMt1VIa9EbswA3GstrTTed3khD36dmChmXTbpf8xqmAAfRegScn5gC010eDXOKgCUiwrGugS2D23qBaawF3V0trZUTYhj8nehrGh6HZcuHRh6t1VOGhYscjDMLcXYaKgHDzEapptE2mJPBYBOb/2Uwab1WhzczAdBXNYY1Aya13GvMbDea9Mpdu6F/vN0QH203pO9oN+TH2w3Do+2G8fF2a2rMbDeUh9utlcbcdmsbbF67UUNDt/0wvF7dOBxe9wzzNRINGpPt373G3Hbz1XajhkWjODNHFPT1SpoWHZtFOVX3TdSYWo5D26dpz8r/pIHjbhi4vqlvmRTZ2UqqHLAmwo15wZCG8Ygeb3eBP/Vwtd4cb748XLLYcbN63vbl8PW8W0/Onn4f7Ix9uTgc9+v+5Xzss9L084X+Myi8kPjzkp/2Bw==",
|
|
3772
3776
|
"is_unconstrained": true,
|
|
3773
3777
|
"name": "_set_authorized"
|
|
3774
3778
|
},
|
|
@@ -3829,7 +3833,7 @@
|
|
|
3829
3833
|
"custom_attributes": [
|
|
3830
3834
|
"abi_public"
|
|
3831
3835
|
],
|
|
3832
|
-
"debug_symbols": "vZrRbhs5DEX/
|
|
3836
|
+
"debug_symbols": "vZrRbhs5DEX/xc95kEiREvsrRVGkqVsEMJzATRZYFPn3JT2iZtyFlInH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
|
@@ -3887,7 +3891,7 @@
|
|
|
3887
3891
|
"abi_public",
|
|
3888
3892
|
"abi_view"
|
|
3889
3893
|
],
|
|
3890
|
-
"debug_symbols": "rVlRbtswDL2Lv/MhUiIl5SrDUKRtOgQI0iJLBgxF7j6yFm0ngFQvzk/9TNvPJMUnMvVn97p9Pv962h3e3n936x+f3fNxt9/vfj3t3182p937QayfndM/nLo1rbrou3WWg5wBrrokp+DlmPpj5v4IDro1OgVcAFAB3izBGbBLZBYyC5uFg4FUgLrSg1hAQgP2imxuZCVEBbkH6IIBs4BZwCxoFq9ueAVUQDBL0HtIQS6A1MIKcgFslogGxGevzOqzDwKyEHq9pK76uOq8cwZSASAh+6RAk6AWlMcDKYgFeDDABQSzBLOQWTTPPcgFqKs9SAVonntgr0j2Us1zUDfU+R5QD4JzBswCZgGzoLqRFHABmmdyCuQeAgGa5x6kAkj8Ib2ZYgGMBswSzRLNksAAFaA+9yAYyD0g5w2kAkAI2SngAtT5HpjFm8WbJZgliBsszhOhAb1H6odY7wkKuIAYDIg/UR9PYolSLZTl8aiXshBGWQJ2WICmtwcSYJRCYlRLvFxWncn56XTcblXNE32L6j82x+3h1K0P5/1+1f3Z7M9fN/3+2By+jqfNUa6KI9vDqxyF8G233yq6rManXf1RcjmWpwkoDQSAcEUBdYrgGAtFAAxVCqxTQMoWg2wMrkrh6xToSEX/xSHYx4EkXnOEBkdMxpAncaQ0Nw7ECMYg6qzGwXUKH1S/XxSyK9AYBV0xxAdkIi3NRKuuoh/qKnK9KKDB4QEgWy5AmlItEGhUJ7jEVlrg8p2xuCGWFKuxtCiyGygy8kBB/
|
|
3894
|
+
"debug_symbols": "rVlRbtswDL2Lv/MhUiIl5SrDUKRtOgQI0iJLBgxF7j6yFm0ngFQvzk/9TNvPJMUnMvVn97p9Pv962h3e3n936x+f3fNxt9/vfj3t3182p937QayfndM/nLo1rbrou3WWg5wBrrokp+DlmPpj5v4IDro1OgVcAFAB3izBGbBLZBYyC5uFg4FUgLrSg1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OtjkeMA5O5OZdTW5My8dB5geMgxwfMA5yesA4yHnpOPhNLPPGwQjLx8FvVmbeOBj98nHwG45Z42CT4wHjYMp5FAxeCeannG1edserLxEX5TruNs/7bTl9Ox9eJldPfz/sin3J+Di+v2xfz8etMo2fM0D+6/pDgl+J8z8v+r5/",
|
|
3891
3895
|
"is_unconstrained": true,
|
|
3892
3896
|
"name": "is_consumable"
|
|
3893
3897
|
},
|
|
@@ -3938,7 +3942,7 @@
|
|
|
3938
3942
|
"abi_public",
|
|
3939
3943
|
"abi_view"
|
|
3940
3944
|
],
|
|
3941
|
-
"debug_symbols": "
|
|
3945
|
+
"debug_symbols": "rZfRbusgDIbfhetcYBsM9FWmacq6bIoUpVXWHulo6rsPtpgklUBdt5vmj2m++scGmg/10j2f35768fXwrnYPH+p56oehf3saDvv21B/GGP1QOn2wUTvbKA5qFxrl4h1gvMZboEZ5830NOF+d2qFuFGieBcAsCEXIkJEhIxErESsR1iKMiDALRyL8LLz8hJc0QgJiEvZboNYiJAISAYmgRDClEW0hgQiJmPQdm4SdhU0RTsLOgiXCfhYpZ0rklDOZKHwEUhpKqZJLgr8FaSMiWiZ/uTRK6vN0mroulWdVsFjGYzt140ntxvMwNOpfO5y/vvR+bMev66md4micmG58idcIfO2HLqlLszyty49aHdz8tAXrMwAQNggoI4xmnBEG0BQRWEaAD+IhVlgXEVRGxPKnMn4xoiaXIW7LMBWG80IIKx/e3+oD0YEQyFHRB5cRZIydEWTYLi7shuD+YCb8b2ei1leOcl85LjcFVBgU95ogcwFgdMkIVLoTtGdpLdDhTi86e/Gu6KWGYDSCYLsYsbQ1Ymor1dq8UvXSGIhhy7CVsnoxQmFZ6+a6JlybTnCy2kHjakLJX+VRadEQQBIJwboyw9cWijQ5+cUL6SsvoTIb4KQ1ELy5j4GU11o8FYoMrLQohbzajIalsuBuTiMiIFfWhbKVaoPpkBsMuNhgWGEYCpKHMXqZDjT4A4Y3mbHaRK8Zty43DqXlhpUW5fifY0YwApad1FoU3dKkuN4GrzYwrJUWNecTAbXHEoT0H5wJBL8+HuteUC9eAhfTqJz0ZG3uddZYTqReGVpVZrVirhOp7KbxdJIJAdS02k/DTxiQGZbvYyDnIw4dbhmP8bbd99PmTeCSYFPfPg/dfPt6Hver0dP/o4zIm8RxOuy7l/PUJdLyOpFeBx4YGqbHS/q1Tw==",
|
|
3942
3946
|
"is_unconstrained": true,
|
|
3943
3947
|
"name": "is_reject_all"
|
|
3944
3948
|
},
|
|
@@ -3973,7 +3977,7 @@
|
|
|
3973
3977
|
"custom_attributes": [
|
|
3974
3978
|
"abi_public"
|
|
3975
3979
|
],
|
|
3976
|
-
"debug_symbols": "
|
|
3980
|
+
"debug_symbols": "rVjbbuIwEP2XPPPgufjGr6xWFaVphYQApbDSquLfd1w8ToJkb1r6Qk7GycmZ8RnH5KN76Z8vb0+7w+vxvVv/+uieh91+v3t72h+3m/PueJDoR2fSDwB2a7uSo+/WUY4o50AJSADSCKECl4cYFKSIF2BBgUYcK4gZeOrWyAmEDIK/ATQ5gknNDegQagQ1QhpJej4BGwVWQczAsgJ9hCMFidAJ8KDAZRA0EjQSNRJzhEyS4RPwGYBGIF0jxSQEBRIhI4BAQcyARSGluzhkYEmBRpxGnEY8KnAZJM03YDOIRoE+IsYbYJMIYwI+gyT+BjSCGkGNkEZIZLCIZyYFcg2jACvXMCXgM3A2Ay96OD3dS8Sa63XVqSGfzkPfJz9OHCq+PW2G/nDu1ofLfr/q/mz2l8+L3k+bw+fxvBlkVJ7fH17kKISvu32f0HU13m3qt1oTfb7bgg2FABBmFFCnYOMwU0gRuUqBdQoIUXOACKZKQXUKNBYpcwgmX0j8nIMbHD4oQ5zkEcLSPKRHQRnIUzUPV6eQdrCZgsQ5YxZ2xuB/oBLh0Uo0fIVcTIHsRwmW5rZqUIiZXPGVrVYCGtZEcGn1ucmQFRlrpQBszYhSkKvX4j8yrC8yvIlVGQ1zMmqLsCxIY0G/V89JJvf1bJgzGrVFxDEJ5uWuGKeDHVRdEVoLlrVlwTKjK1AEzThiQ0bQUlIclzy+X68aiYABr/4Gg5MZpTDXgQ1fxAgqJEbr6xxNd2qvUxhzIXOXS2vlBO+KOQN/jwOpLDnoGjpsI5NYFh02MM4s+MUyhALKzPpYldE2mInFYOCqBsPQeiWWtyoD8Hc5SsPDJJd7jqXtFqjWbgSPtxvho+1G9BPtRvx4u5F9tN3IPd5uTY6F7Ubh4XZryVjabm2DLWs3bu1AKUJ5N5qxHOL/L3AELhyTrds9x8J2s6babtywqI9GzeEjYT2TpkXHZhEcqpsebkyt9aXtw7Rn41dk0LiTBVvfkLdMStboSirYUZWk8bqXP42lHh5pvoX7Laeb7W6YfRq4JrJht3ne9/n09XLYTkbPf086op8WTsNx279chj4xTb8vyB+5EFbR/L6mp/0D",
|
|
3977
3981
|
"is_unconstrained": true,
|
|
3978
3982
|
"name": "set_authorized"
|
|
3979
3983
|
},
|
|
@@ -5796,11 +5800,11 @@
|
|
|
5796
5800
|
"visibility": "databus"
|
|
5797
5801
|
}
|
|
5798
5802
|
},
|
|
5799
|
-
"bytecode": "H4sIAAAAAAAA/+2dZ2BURduG8zwTOlgQxU4EUbCLvQtJgFgAwd7WNVlgJSRxs6FZIDbEmiygYFd6ExSkKIK9zi12RbH3jr37fiek7KZsMpvs/errhz/0uDvneubMmT7LhYmU3rB2D5/PPyYcyPblhXzBvHAglOfPLfT5CgNhn78oPDQ/FBwTyPEVhIIj/OHAOjO7eFGvXH/2sF75o3oX5WWn+3Nzi2cM7NmvT2akeNYpwXBeoLBQ0xwSGXFI1N6F1OFoh0Qd7TiHVFs7pdrBJVc7uiTq5JIozSXRTk457+yUqotTqp2dUnV1yXx3KZ7XKxTMzQ0OKft+UkpJycSSksfSUur/R4rn9iwsDITCpwdC+RNLSiOPpe2T0y/03r53dF8+IHNpcfGpZ3Xb79O+o1cUlKa/9+PE9d4tMKH6sa/s+cGwxmAL42JTKy/qKIglA/ILA8Gc/LweAwKh4UVhfziYnxeZVFUwXnarrnetuuoW833hJJgwTBHMC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MO67znP9IPTM5EOzn/kYH/iYH/mYH/hYH/lYH/jYH/nYP/gYP/kYP/iYDkOYOU4gJXjAFaOA1g5DmDlOICV4wBWjgNYOQ5g5TiAleMAVo4DWDkOYOU4gJXjAFaOA1g5DmDlOICV4wDW9hwsxwGsHAewchzAynEAK8cBrBwHsHIcwMpxACvHAawcB7ByHMDKcQArxwGsHAewchzA2plyCqscB7ByHMDKcQArxwGsHAewchzAynEAK8cBrLtzsHtwsHtysHtxsHtzsPtwsByXrvbgYDkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49LVgRwsx6WrHJeucly6ynHpKselqxyXrnJcuspx6SrHpascl65yXLrKcekqx6WrHJeucly6ynHpKselqxyXrnJcuspx6SrHpascl65yXLrKcekqx6WrHJeucly6ynHpKselqxyXrnJcuhriYDkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49LVCAfLcekqx6WrHJeucly6ynHpKselq5w/Eqgcl65yXLrKcekqx6WrHJeucly6ynHpKueP5yrHpascl65yXLrKcekqx6WrHJeucly6ynHpKselqxyXrnJcuspx6SrHpascl65yXLrKcenqvRwsx6WrHJeucly6ynHpKselqxyXrnJcuspx6SrHpascl65yXLrKcekqx6WrHJeucly6ynHpKselqxyXrnJcuspx6SrHpascl65yXLrKcekqx6WrloPluHSV49JVjktXOS5d5bh09UUOluPSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1c5Ll3luHSV49JVjktXOS5d5bh0lePSVY5LVzkuXeW4dJXj0lWOS1e/5WC/42C/52B/4GA5/lvl+G+V479Vjv9WO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I3B/78jYUse/8Im9SHcgLT6mZvdaNPbSuuL9Nkl9j6yg4Tnno3IqAMcWSEi2fOHfJtOOLcmPeW4PJBxWdWwe92kAdUw9qvIyqn1y0/j8u92aRDZ8BAA==",
|
|
5800
5804
|
"custom_attributes": [
|
|
5801
5805
|
"abi_private"
|
|
5802
5806
|
],
|
|
5803
|
-
"debug_symbols": "
|
|
5807
|
+
"debug_symbols": "tVrbbhwtDH6Xvc4FNmDjvEr1q9qm2yrSKom2SaVfVd+9hgGG3RZ2sjO5WXtO3xrjA2D/2n09fHn7/vnx6dvzj939p1+7L6fH4/Hx++fj88P+9fH5Se/+2pn4A253j+733Q7SldUrq1eYrmR375Q3E4GJ4ETsRNxE/O5elNDuHkApZxoylYlakylkipnaTBUNUKnPlDLlTEOmMlFnMoVMMVObacZzGc9lPJfxXMZzGc9nPJ/xfMbzGc9nPJ/xfMbzGc9HvKBUJkom04in+qGIJ6peG9UbR5sHi3rPxXtR1wh65dMEKB7qK3EiIk1PcZqKRDHTOG0Rg9JX8anRK/7Hv4TyBvzWq2IPn19Ph0N80hiIms3L/nR4et3dP70dj3e7n/vjW3rpx8v+KdHX/Umfmrvd4emrUgX89ng8RO733fy16X9KnvLHbLh+joBLAXyQDEA4A4DwUgBwYgqE8jZUEO/PMGwfg50vo2B/kxAepSgCvG1GciGE72M44DIOh25GcO5cmdSHsFxVYZlDF4LXQ4QBBFKFwIANhLtRn5Z6+oSRaVGAjOFJZuO270AgXxEaZdh3jIP9PA5nu+MYWKf1ZRiWfONjcI7g+giitpUhxNnQnREYmKdQNQwha/sYNNKnwapPcH2MgYGiLeEKfWtb79An2qrP0NWn+Zh4aVyNNKaJNIv/e3WoIimjZyfN6GW5TRuuJt24FeLiQQSkYgfBYqMHPFckDuwRbAg17NubxNBXiy4QuTFHE87FGJgjU7EGDtA1aByES7HVN725JViiyluG4bztatMOVVG9G7HxikDnEDCYEANcZhWM4s3hMpwbl8WBNgSKQkU89zFGDu6qg4cmaJtzw7CDgKnv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t00iZ3s5T18UqLeoWqnlqp248N9vxMgyb5lc7XL5u+jy149f53E5hNXB34z6cA+GhH7qIbpv5aVV+1CjP6WkDxmUCQFhRQJlCK4uJQgPqIgWWKcB5iQE8qCIFlSlQGaTEEXDIrpDwmkNXONgJg1/E4dyzcSAyCAMxFeOwZQrS2iQK0tbMUZgVA/9AJtz/ZqKiK3QgFQ2dNYdhaC2rCkUQk826MsVMQEWaCDb25N0NsBpLqQCsVUQoyJZz8Rc3DGc3WPmiGxVxapSEao1zTc338rmI5DGfFXF6JbLwOAeh9dOqYJeV6RZpeFSFqw0sY/LAUrMqMDi04vA1cUoqyc8jTz/Oq0ogoIBl6IHCRSjk1n5gRRfe5ybx3nCZo6pOySi5ORZSD7HUJiewzeJ0+nscSLmwaCt+mEokPg8drWCuLPDTbgQKyJVlX3SjLjDls8DAFgWGFQ5NHnKzqjkdGCbQ8xxOZ47FXvLI8Wy7kS61G1Ukyl6JONgTFr2gqkTnZgnYFacwVUprOLe9W/as/xc3aN5awRT3RaqJlIySUR6wpSJJbY+3LueDkdZ7ymu4bHf9tPqCv0WyqW/fhy5dHi7jbrF6/n2SFfkDOE3HXbe/TF1kWvwGhA/nFwsbS6+3+LY/",
|
|
5833
5837
|
"is_unconstrained": true,
|
|
5834
5838
|
"name": "set_reject_all"
|
|
5835
5839
|
},
|
|
@@ -5886,11 +5890,11 @@
|
|
|
5886
5890
|
"visibility": "public"
|
|
5887
5891
|
}
|
|
5888
5892
|
},
|
|
5889
|
-
"bytecode": "H4sIAAAAAAAA/+1bzW8bRRT3rj92badf6UfcEsdJnEARJwpCXGmakEBDq5ZyQrKWZAkW/mJtA+GEuYKQnRb+APJBEBSBBEJqJU7AAWoEElJVqYciVeJLiAviwIl1/bFvZ/bN7qzHoNL0tPHb95s3b37z5s172+Ba4+1r92Uy2isVfSlTMDLZQkU3ClqunMlUK9lctrKayZYzS8VCuZrXnsnpjdr7x41sLpddmdFyuQuBtdrW2WxhJaefrzfWvhgPsP9JAddXAn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Q8X6OHVhXKeI3wdQxXXPYu+PO+n4zzunKxu0T/rh3deH53d/6PBmsueHuy+P9/7h99enr2efffn/T3wGfyjx8/nH1/tvr8/3Zlr/WkL/+Str/Cz9k/2KuH2ox3Lu9OnNov8L",
|
|
5894
5898
|
"is_unconstrained": true,
|
|
5895
5899
|
"name": "utility_is_consumable"
|
|
5896
5900
|
},
|
|
@@ -6025,7 +6029,7 @@
|
|
|
6025
6029
|
"custom_attributes": [
|
|
6026
6030
|
"abi_utility"
|
|
6027
6031
|
],
|
|
6028
|
-
"debug_symbols": "
|
|
6032
|
+
"debug_symbols": "tZzdblQ7FoTfpa9zYa/lX17l6AgFCEeRooByYKQRyruPl7fL1YHZptOb3JAvJF1ley9X+6eVH6dPdx++//P+/vHzl39P7/76cfrwdP/wcP/P+4cvH2+/3X95bP/74+Tsn6Ryeqc37aue3uX2NbSv1b6m0zvvDTKgAOqA6AAeIAAFBEAEQDlCOUI5QjmZsjUreYAAFGDKwcCUo0ECZIApS4Niyta/ajrWwaqAAIiABMiAAqgbZOcAHiAABQRABCRABhQAlD2UPZQ9lD2UPZQ9lD2UPZQ9lD2UBcoCZWnKIgYKCICmLMkgATKgAOoAdQAPEIACAgDKCmWFsppyMagDggM0ZXUGAlBAe7lam60gVQ08QAD2y2ZhBblBBCRABhRAHWAFuYEHCMCUs0EAREACmHKr1ZztVTbyub0qeIMAiIAEyIACqAOKA3iAAEzZRqMEQAQkgClbe0oB1AHVATxAAAoIgAhIAFOOBgVQNyg2ZTYw5WxgytVAAQEQAQmQAQVQB9iU2cADmnJ0BgoIgAhoOlEN6gCbIBt4gAAUEAARkAAZYMrBoA6wCbKBB5hgMgiACEgAe7kNlM2CaP2yWbCBABQQABGQABlQAHWATZlko2FTZgMBKKApJzGIgARoysmaalNmgzrApswGHiAABQRABCQAlBOUE5RtEiUbFpsyqRgkgL3K+mVTJlvjbcp0sCmzgQcIQAEBAOUCZZsyGxRAHWBTZgNT9gYCMGUbKJsyG0RAAjTlbGVj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tEvXKdsylRtOoV7ZD8tQ4S9LXaYQ5Xfx5dbxKQys1rhwPb5+gGholXKnBMW0FcqVGKdS4cjxkHnO0G6X98cir3U7NzGPPZ+vz5c3giqHd11zZlRj81Eh6nUZimaZryzSxxFK6TqMdS6A82jp/f8oVfdPH0iT8bEbeb8byjKLOIa01pN33hbI6s4lnu532mPfPKEo+fkZRytEzinUrLjujqO74O3Z1x88XqrytxuVnFDUcP6NYalx4RnGxxuKMoubjO4Z6eG1aD69N10/20jMK7/zRIwbvDu+f1hKXDYcef6zexeM9iW/6YC8+ZmhLzqOnBN7V48NR33g4Ljwn8Kubnovrwx8+hVpL/IEBufSowC9vai48K1g15dJ9vvfl+KAeTtPluuHCnb6XP7DV/81ijBdobTG2v9X3qxOD4Obupb01cEUnOf8kstrs8wJMS1qJLAIxzGINZ3eSbaf4is746GZnzt6lfm3HUmRuHNqorkQWhRZCnSLx7Nn8KlJXJ8DzsjeGF2+6P82aP3Go7ld3PhdOveWIRJ3PN+a0PyK6Ot/KnDjFs0raRLx4I5S9/3+HW7/MmtXNkTJINGRO4BIu/jRATcI93f4HCryuLkljmGcgjavuXcTrMla52daw+2mAdTti4YYsVrlOJM0qa7z/2YbgD38w4TftmBXSWOKOyPLhej7cuvioR1iIZIdHm89OP9uB1fPz3+3b24/3Ty/+fMGzST3d3354uBvffv7++PHsp9/++xU/wZ8/+Pr05ePdp+9Pd6bEv4HQ/vmrjVG9aVGY/745afs+tUmV1Lfv7LOU9uPUfpzL38/Wnv8B",
|
|
6029
6033
|
"is_unconstrained": true,
|
|
6030
6034
|
"name": "offchain_receive"
|
|
6031
6035
|
},
|
|
@@ -6086,7 +6090,7 @@
|
|
|
6086
6090
|
"custom_attributes": [
|
|
6087
6091
|
"abi_public"
|
|
6088
6092
|
],
|
|
6089
|
-
"debug_symbols": "vZ3djt02DoDfZa5zIZGifvIqRVGkbboIEKRFNllgUeTdV6Qk0jOFeTSxszc533A8lCyRokTaJ38//f7+16//+uXDpz/+/PfT25/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W2jnr+WC+yaWbvhKjYd0S3qhwssM6I6i0fnrPu4q0IJG8Qb5dBW4o4oF16tYcE8VC+6oYsH1KhbcUcWCO6pYcEMVy+3IdgT2LW0zAnt1rO0I7Cu5IQIffe/84WP0qli7ERjdN7J2IzAGvCECY7jji9UwXP5mtUe3sxeB0S1mbUbgR/OzF4HRq2XtRuBHSrYisK/khld2qFkpqrXTV6Ex3lAnwHi5ToDxljoBxhvqBBgv1wkw3lAn8JXsfrcXXK8TuB3ZDVwPLG3z673ghjrBIyXX6wTmeznE06cGEW6oEyBcrhMg3FInQLihToB4uU6AeEOdwFey63t4vU7gdmTb9+CGOgHiDXWCB0ru2DQefA9PU6boFbW2N41uUWt70+hWgrY3jd63ue1vGt0vDNzbND64nc1No/eNgdubxgfzs7lp9F7Q2t40PlCyt2l0ldyxaazNviAFTx8u8XLAMdh3WKfzbyVHcs1V3xc9fIV1PwF++7n/9O63D5+f/S/n31jT5w/vfv34fv74x9dPvx1+++W/f63frP8l/a/Pf/72/vevn9+zJvuv0vs/P9V+6qyx/vzmCfmnvv7WFPtP/D9t/FR7dalC/Pkb9+V/",
|
|
6090
6094
|
"is_unconstrained": true,
|
|
6091
6095
|
"name": "public_dispatch"
|
|
6092
6096
|
},
|
|
@@ -6118,7 +6122,7 @@
|
|
|
6118
6122
|
"custom_attributes": [
|
|
6119
6123
|
"abi_utility"
|
|
6120
6124
|
],
|
|
6121
|
-
"debug_symbols": "
|
|
6125
|
+
"debug_symbols": "dZFNDoMgEEbvMmsXUOvvVZrGoI6GhABBaNIY7l4wWHXhBmb45r0QWGHE3s0dl5NaoH2t0BsuBJ87oQZmuZLhdAUSF0qhzb3PYI86axBjcpoNBs0MSgutdEJk8GHCbUOLZnLbLTMhJRmgHMMehBMXGCufHTS5RylpiiLhoW4efwUlxUVC7yVVSZOiqg9BlV/4xz1f0zzx9ZMeF2hK79+hZQM3lzf0UWU46wWmdnJyOKX2q/dk/wNt1ICjMxhNWxbcPw==",
|
|
6122
6126
|
"is_unconstrained": true,
|
|
6123
6127
|
"name": "sync_state"
|
|
6124
6128
|
}
|
|
@@ -6631,5 +6635,5 @@
|
|
|
6631
6635
|
}
|
|
6632
6636
|
},
|
|
6633
6637
|
"transpiled": true,
|
|
6634
|
-
"aztec_version": "6.0.0-rc.
|
|
6638
|
+
"aztec_version": "6.0.0-rc.2"
|
|
6635
6639
|
}
|