Skip to content

Commit d4213a0

Browse files
AztecBotTomAFrench
andauthored
feat: Sync from aztec-packages (#4546)
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 <[email protected]>
1 parent d8710c4 commit d4213a0

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

.aztec-sync-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
58e15edf7fd3d32267b0aed883fc84f6cee327c9
1+
aa90f6ed7bfae06bdf6990816d154bbd24993689

aztec_macros/src/transforms/functions.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ pub fn transform_function(
4848
func.def.body.0.insert(0, init_check);
4949
}
5050

51+
// Add assertion for initialization arguments
52+
if is_initializer {
53+
let assert_init_args = create_assert_init_args();
54+
func.def.body.0.insert(0, assert_init_args);
55+
}
56+
5157
// Add access to the storage struct
5258
if storage_defined {
5359
let storage_def = abstract_storage(&ty.to_lowercase(), false);
@@ -205,6 +211,23 @@ fn create_internal_check(fname: &str) -> Statement {
205211
)))
206212
}
207213

214+
/// Creates a call to assert_initialization_args_match_address_preimage to ensure
215+
/// the initialization arguments used in the init call match the address preimage.
216+
///
217+
/// ```noir
218+
/// assert_initialization_args_match_address_preimage(context);
219+
/// ```
220+
fn create_assert_init_args() -> Statement {
221+
make_statement(StatementKind::Expression(call(
222+
variable_path(chained_dep!(
223+
"aztec",
224+
"initializer",
225+
"assert_initialization_args_match_address_preimage"
226+
)),
227+
vec![variable("context")],
228+
)))
229+
}
230+
208231
/// Creates the private context object to be accessed within the function, the parameters need to be extracted to be
209232
/// appended into the args hash object.
210233
///

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"plonkc",
141141
"PLONKish",
142142
"pprof",
143+
"preimage",
143144
"preprocess",
144145
"prettytable",
145146
"printstd",

0 commit comments

Comments
 (0)