Skip to content

Commit

Permalink
feat: Sync from aztec-packages (#4546)
Browse files Browse the repository at this point in the history
Automated pull of Noir development from
[aztec-packages](https://github.com/AztecProtocol/aztec-packages).
BEGIN_COMMIT_OVERRIDE
chore: Pull noir
(AztecProtocol/aztec-packages#5193)
feat: Check initialization arguments in constructors
(AztecProtocol/aztec-packages#5144)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <tom@tomfren.ch>
  • Loading branch information
AztecBot and TomAFrench authored Mar 14, 2024
1 parent d8710c4 commit d4213a0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58e15edf7fd3d32267b0aed883fc84f6cee327c9
aa90f6ed7bfae06bdf6990816d154bbd24993689
23 changes: 23 additions & 0 deletions aztec_macros/src/transforms/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub fn transform_function(
func.def.body.0.insert(0, init_check);
}

// Add assertion for initialization arguments
if is_initializer {
let assert_init_args = create_assert_init_args();
func.def.body.0.insert(0, assert_init_args);
}

// Add access to the storage struct
if storage_defined {
let storage_def = abstract_storage(&ty.to_lowercase(), false);
Expand Down Expand Up @@ -205,6 +211,23 @@ fn create_internal_check(fname: &str) -> Statement {
)))
}

/// Creates a call to assert_initialization_args_match_address_preimage to ensure
/// the initialization arguments used in the init call match the address preimage.
///
/// ```noir
/// assert_initialization_args_match_address_preimage(context);
/// ```
fn create_assert_init_args() -> Statement {
make_statement(StatementKind::Expression(call(
variable_path(chained_dep!(
"aztec",
"initializer",
"assert_initialization_args_match_address_preimage"
)),
vec![variable("context")],
)))
}

/// Creates the private context object to be accessed within the function, the parameters need to be extracted to be
/// appended into the args hash object.
///
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"plonkc",
"PLONKish",
"pprof",
"preimage",
"preprocess",
"prettytable",
"printstd",
Expand Down

0 comments on commit d4213a0

Please sign in to comment.