refactor: restructuring function macros + migration notes#18289
refactor: restructuring function macros + migration notes#18289
Conversation
6768d36 to
08e2889
Compare
1b0eb6f to
50e1222
Compare
6b1c439 to
08e2889
Compare
8bb0e31 to
4463791
Compare
08e2889 to
31d7349
Compare
|
|
||
| /// Checks if each function in the module is marked with either #[external(...)], #[contract_library_method], or #[test]. | ||
| /// Non-macroified functions are not allowed in contracts. | ||
| comptime fn check_each_fn_macroified(m: Module) { |
There was a problem hiding this comment.
Move here from noir-projects/aztec-nr/aztec/src/macros/functions/utils.nr
| @@ -1,527 +0,0 @@ | |||
| // TODO(benesjan): Move this whole file to `noir-projects/aztec-nr/aztec/src/macros/internals_functions_generation`. | |||
There was a problem hiding this comment.
Having this here no longer made any sense. Also having all this functionality in the same file was too messy as these functions are quite complex. All the functionality here has been moved over to macros/internals_functions_generation/external directory.
| /// Gathers all attributes relevant to the function's ABI and returns a quote that can be applied to the newly generated | ||
| /// function. We apply the abi marker attributes instead of the original ones (e.g. abi_view instead of view) to avoid | ||
| /// the relevant attribute's functionality from getting triggered. | ||
| comptime fn get_abi_relevant_attributes(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/helpers.nr
| attributes | ||
| } | ||
|
|
||
| pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/private.nr
| } | ||
| } | ||
|
|
||
| pub(crate) comptime fn transform_public(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/public.nr
| } | ||
| } | ||
|
|
||
| pub(crate) comptime fn transform_utility(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/utility.nr
|
|
||
| /// Injects a call to `aztec::messages::discovery::discover_new_messages`, causing for new notes to be added to PXE and made | ||
| /// available for the current execution. | ||
| pub(crate) comptime fn create_message_discovery_call() -> Quoted { |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/helpers.nr
| /// * `is_private` - Whether the function is a private function (`true`) or a public function (`false`). This determines | ||
| /// which authwit verification method to use: `assert_current_call_valid_authwit` for private functions | ||
| /// or `assert_current_call_valid_authwit_public` for public functions. | ||
| pub(crate) comptime fn create_authorize_once_check( |
There was a problem hiding this comment.
Moved to macros/internals_functions_generation/external/helpers.nr
|
|
||
| /// Checks if each function in the module is marked with either #[external(...)], #[contract_library_method], or #[test]. | ||
| /// Non-macroified functions are not allowed in contracts. | ||
| pub(crate) comptime fn check_each_fn_macroified(m: Module) { |
There was a problem hiding this comment.
Moved to macros/aztec.nr - it was the only place where it was used
| use protocol_types::meta::utils::derive_serialization_quotes; | ||
| use std::meta::{ctstring::AsCtString, type_of}; | ||
|
|
||
| pub(crate) comptime fn generate_private_external(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Renamed the transform_private function to this to follow the naming of the internal functions (there it's called generate_private_internal.
| }; | ||
| use std::meta::ctstring::AsCtString; | ||
|
|
||
| pub(crate) comptime fn generate_public_external(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Same here. Renamed this.
| utils::module_has_storage, | ||
| }; | ||
|
|
||
| pub(crate) comptime fn generate_utility_external(f: FunctionDefinition) -> Quoted { |
There was a problem hiding this comment.
Same here. Renamed this.
31d7349 to
d7294cc
Compare
4463791 to
39a98d3
Compare
39a98d3 to
26b8165
Compare
d7294cc to
384c442
Compare
26b8165 to
7de49f6
Compare
bc4c8d7 to
4989b0d
Compare
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
4989b0d to
48cdb09
Compare
38b4974 to
296e47c
Compare
In the past core of the macro logic was handled by the external macro code. This has changed and now it's all done by Aztec macro. This resulted in a lot of the macro functionality now being placed in a way that made no sense. In the PR diff I comment on where each function was moved to. I also update migration notes and I describe there all the new contract API.
296e47c to
ecd4088
Compare

In the past core of the macro logic was handled by the external macro code. This has changed and now it's all done by Aztec macro.
This resulted in a lot of the macro functionality now being placed in a way that made no sense. In the PR diff I comment on where each function was moved to.
I also update migration notes and I describe there all the new contract API.