Skip to content

refactor: restructuring function macros + migration notes#18289

Merged
benesjan merged 1 commit intonextfrom
11-08-refactor_restructuring_function_macros
Nov 18, 2025
Merged

refactor: restructuring function macros + migration notes#18289
benesjan merged 1 commit intonextfrom
11-08-refactor_restructuring_function_macros

Conversation

@benesjan
Copy link
Contributor

@benesjan benesjan commented Nov 8, 2025

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.

@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch from 6768d36 to 08e2889 Compare November 9, 2025 13:06
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 1b0eb6f to 50e1222 Compare November 9, 2025 13:06
@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch from 6b1c439 to 08e2889 Compare November 10, 2025 14:45
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 8bb0e31 to 4463791 Compare November 10, 2025 14:48
@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch from 08e2889 to 31d7349 Compare November 10, 2025 14:48

/// 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.
Copy link
Contributor Author

@benesjan benesjan Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to macros/internals_functions_generation/external/helpers.nr

attributes
}

pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to macros/internals_functions_generation/external/private.nr

}
}

pub(crate) comptime fn transform_public(f: FunctionDefinition) -> Quoted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to macros/internals_functions_generation/external/public.nr

}
}

pub(crate) comptime fn transform_utility(f: FunctionDefinition) -> Quoted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor Author

@benesjan benesjan Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Renamed this.

utils::module_has_storage,
};

pub(crate) comptime fn generate_utility_external(f: FunctionDefinition) -> Quoted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Renamed this.

@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch from 31d7349 to d7294cc Compare November 10, 2025 15:52
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 4463791 to 39a98d3 Compare November 10, 2025 15:52
@benesjan benesjan changed the title refactor: restructuring function macros refactor: restructuring function macros + migration notes Nov 10, 2025
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 39a98d3 to 26b8165 Compare November 10, 2025 18:12
@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch from d7294cc to 384c442 Compare November 10, 2025 18:12
@AztecBot AztecBot force-pushed the 11-07-feat_new_external_function_call_interface branch from 26b8165 to 7de49f6 Compare November 10, 2025 18:38
Base automatically changed from 11-07-feat_new_external_function_call_interface to next November 10, 2025 20:01
@benesjan benesjan force-pushed the 11-08-refactor_restructuring_function_macros branch 2 times, most recently from bc4c8d7 to 4989b0d Compare November 11, 2025 17:26
@benesjan benesjan marked this pull request as ready for review November 11, 2025 17:27
@benesjan benesjan requested a review from nventuro November 11, 2025 17:27
@AztecBot
Copy link
Collaborator

AztecBot commented Nov 11, 2025

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033[38;2;188;109;208mFLAKED\033[0m (\033[38;2;250;217;121m8;;http://ci.aztec-labs.com/d8f517a5d1896c07�d8f517a5d1896c078;;�\033[0m): yarn-project/scripts/run_test.sh ethereum/src/l1_tx_utils/l1_tx_utils.test.ts (67s) (code: 1) group:e2e-p2p-epoch-flakes (\033[38;2;188;109;208mJan Beneš\033[0m: refactor: restructuring function macros + migration notes (#18289))

Copy link
Contributor

@Thunkar Thunkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely

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.
@AztecBot AztecBot force-pushed the 11-08-refactor_restructuring_function_macros branch from 296e47c to ecd4088 Compare November 18, 2025 17:21
@benesjan benesjan added this pull request to the merge queue Nov 18, 2025
Merged via the queue into next with commit 16b5944 Nov 18, 2025
15 checks passed
@benesjan benesjan deleted the 11-08-refactor_restructuring_function_macros branch November 18, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants