diff --git a/noir-projects/aztec-nr/authwit/src/auth.nr b/noir-projects/aztec-nr/authwit/src/auth.nr index 0a3c991987a..aff8007f83f 100644 --- a/noir-projects/aztec-nr/authwit/src/auth.nr +++ b/noir-projects/aztec-nr/authwit/src/auth.nr @@ -262,7 +262,7 @@ pub fn assert_current_call_valid_authwit_public(context: &mut PublicContext, on_ */ pub fn assert_inner_hash_valid_authwit_public(context: &mut PublicContext, on_behalf_of: AztecAddress, inner_hash: Field) { let result: Field = context.call_public_function( - AztecAddress::from_field(CANONICAL_AUTH_REGISTRY_ADDRESS), + CANONICAL_AUTH_REGISTRY_ADDRESS, FunctionSelector::from_signature("consume((Field),Field)"), [on_behalf_of.to_field(), inner_hash].as_slice(), GasOpts::default() @@ -356,7 +356,7 @@ pub fn compute_authwit_message_hash(consumer: AztecAddress, chain_id: Field, ver */ pub fn set_authorized(context: &mut PublicContext, message_hash: Field, authorize: bool) { context.call_public_function( - AztecAddress::from_field(CANONICAL_AUTH_REGISTRY_ADDRESS), + CANONICAL_AUTH_REGISTRY_ADDRESS, FunctionSelector::from_signature("set_authorized(Field,bool)"), [message_hash, authorize as Field].as_slice(), GasOpts::default() @@ -372,7 +372,7 @@ pub fn set_authorized(context: &mut PublicContext, message_hash: Field, authoriz */ pub fn set_reject_all(context: &mut PublicContext, reject: bool) { context.call_public_function( - AztecAddress::from_field(CANONICAL_AUTH_REGISTRY_ADDRESS), + CANONICAL_AUTH_REGISTRY_ADDRESS, FunctionSelector::from_signature("set_reject_all(bool)"), [context.this_address().to_field(), reject as Field].as_slice(), GasOpts::default() diff --git a/noir-projects/aztec-nr/aztec/src/deploy.nr b/noir-projects/aztec-nr/aztec/src/deploy.nr index 9b138875d5b..947a0eb85d8 100644 --- a/noir-projects/aztec-nr/aztec/src/deploy.nr +++ b/noir-projects/aztec-nr/aztec/src/deploy.nr @@ -24,7 +24,7 @@ pub fn deploy_contract(context: &mut PrivateContext, target: AztecAddress) { serialized_args[4] = universal_deploy as Field; let _call_result = context.call_private_function( - AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), + DEPLOYER_CONTRACT_ADDRESS, FunctionSelector::from_field(0x7ebd3690), serialized_args ); diff --git a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr index 78ce23575e4..942de054bd9 100644 --- a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr @@ -11,7 +11,7 @@ impl ProveContractDeployment for Header { fn prove_contract_deployment(self, contract_address: AztecAddress) { // Compute deployment nullifier let nullifier = compute_siloed_nullifier( - AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), + DEPLOYER_CONTRACT_ADDRESS, contract_address.to_field() ); @@ -27,7 +27,7 @@ impl ProveContractNonDeployment for Header { fn prove_contract_non_deployment(self, contract_address: AztecAddress) { // Compute deployment nullifier let nullifier = compute_siloed_nullifier( - AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), + DEPLOYER_CONTRACT_ADDRESS, contract_address.to_field() ); diff --git a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr index bf67e1e9e8b..dc1af573af1 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr @@ -92,10 +92,7 @@ fn key_registry_hash_public_historical_read(historical_header: Header, account: // (prior to siloing!), we simply add the length to the base slot to get the last element. let hash_storage_slot = keys_storage_slot + PUBLIC_KEYS_LENGTH as Field; - historical_header.public_storage_historical_read( - hash_storage_slot, - AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS) - ) + historical_header.public_storage_historical_read(hash_storage_slot, CANONICAL_KEY_REGISTRY_ADDRESS) } unconstrained fn key_registry_get_stored_keys_hint(account: AztecAddress, block_number: u32) -> PublicKeys { @@ -105,10 +102,7 @@ unconstrained fn key_registry_get_stored_keys_hint(account: AztecAddress, block_ // TODO (#7524): call the unconstrained KeyRegistry.get_current_keys() function instead - let context = UnconstrainedContext::at_historical( - AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS), - block_number - ); + let context = UnconstrainedContext::at_historical(CANONICAL_KEY_REGISTRY_ADDRESS, block_number); let keys_storage = Map::new( context, KEY_REGISTRY_STORAGE_SLOT, diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr index dcdc9efda7c..a3666c8facc 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr @@ -11,8 +11,14 @@ pub fn store_master_key(key_index: Field, address: AztecAddress, key: Point) { let x_coordinate_derived_slot = derive_storage_slot_in_map(x_coordinate_map_slot, address); let y_coordinate_derived_slot = derive_storage_slot_in_map(y_coordinate_map_slot, address); - let canonical_registry_address = AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS); - - cheatcodes::direct_storage_write(canonical_registry_address, x_coordinate_derived_slot, [key.x]); - cheatcodes::direct_storage_write(canonical_registry_address, y_coordinate_derived_slot, [key.y]); + cheatcodes::direct_storage_write( + CANONICAL_KEY_REGISTRY_ADDRESS, + x_coordinate_derived_slot, + [key.x] + ); + cheatcodes::direct_storage_write( + CANONICAL_KEY_REGISTRY_ADDRESS, + y_coordinate_derived_slot, + [key.y] + ); } diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr index b753fa9cecd..632516b985e 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr @@ -52,12 +52,12 @@ contract FeeJuice { context.end_setup(); // Register class and publicly deploy contract - let _register = ContractClassRegisterer::at(AztecAddress::from_field(REGISTERER_CONTRACT_ADDRESS)).register( + let _register = ContractClassRegisterer::at(REGISTERER_CONTRACT_ADDRESS).register( artifact_hash, private_functions_root, public_bytecode_commitment ).call(&mut context); - let _deploy = ContractInstanceDeployer::at(AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS)).deploy( + let _deploy = ContractInstanceDeployer::at(DEPLOYER_CONTRACT_ADDRESS).deploy( instance.salt, instance.contract_class_id, instance.initialization_hash, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr index 005df73f7d0..8a48c330da0 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -420,9 +420,11 @@ fn insert_public_data_update_requests( fn compute_fee_payer_fee_juice_balance_leaf_slot(fee_payer: AztecAddress) -> Field { let balances_slot_in_fee_juice_contract = 1; - let fee_juice = AztecAddress::from_field(FEE_JUICE_ADDRESS); let fee_payer_balance_slot_in_fee_juice_contract = derive_storage_slot_in_map(balances_slot_in_fee_juice_contract, fee_payer); - compute_public_data_tree_index(fee_juice, fee_payer_balance_slot_in_fee_juice_contract) + compute_public_data_tree_index( + FEE_JUICE_ADDRESS, + fee_payer_balance_slot_in_fee_juice_contract + ) } #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 48fe455905e..f6f94f77777 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -1,3 +1,5 @@ +use crate::address::AztecAddress; + global MAX_FIELD_VALUE: Field = 21888242871839275222246405745257275088548364400416034343698204186575808495616; global ARGS_LENGTH: u32 = 16; @@ -178,11 +180,11 @@ global L2_GAS_PER_NOTE_HASH: u32 = 32; global L2_GAS_PER_NULLIFIER: u32 = 64; // CANONICAL CONTRACT ADDRESSES -global CANONICAL_KEY_REGISTRY_ADDRESS = 0x2ee3f8c67efa88f9e6fb44242f1e9dcc0f9a6752ded07af0d9fac3875a61d421; -global CANONICAL_AUTH_REGISTRY_ADDRESS = 0x24877c50868f86712240eb535d90d1c97403d074805dd3758c3aecb02958f8d4; -global DEPLOYER_CONTRACT_ADDRESS = 0x2ab1a2bd6d07d8d61ea56d85861446349e52c6b7c0612b702cb1e6db6ad0b089; -global REGISTERER_CONTRACT_ADDRESS = 0x05d15342d76e46e5be07d3cda0d753158431cdc5e39d29ce4e8fe1f5c070564a; -global FEE_JUICE_ADDRESS = 0x16a83e3395bc921a2441db55dce24f0e0932636901a2e676fa68b9b2b9a644c1; +global CANONICAL_KEY_REGISTRY_ADDRESS = AztecAddress::from_field(0x2ee3f8c67efa88f9e6fb44242f1e9dcc0f9a6752ded07af0d9fac3875a61d421); +global CANONICAL_AUTH_REGISTRY_ADDRESS = AztecAddress::from_field(0x24877c50868f86712240eb535d90d1c97403d074805dd3758c3aecb02958f8d4); +global DEPLOYER_CONTRACT_ADDRESS = AztecAddress::from_field(0x2ab1a2bd6d07d8d61ea56d85861446349e52c6b7c0612b702cb1e6db6ad0b089); +global REGISTERER_CONTRACT_ADDRESS = AztecAddress::from_field(0x05d15342d76e46e5be07d3cda0d753158431cdc5e39d29ce4e8fe1f5c070564a); +global FEE_JUICE_ADDRESS = AztecAddress::from_field(0x16a83e3395bc921a2441db55dce24f0e0932636901a2e676fa68b9b2b9a644c1); // LENGTH OF STRUCTS SERIALIZED TO FIELDS global AZTEC_ADDRESS_LENGTH = 1; diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index a74a37a8f7c..d2e7f347643 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -289,8 +289,10 @@ function parseNoirFile(fileContent: string): ParsedContent { const [, name, _type, value] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*(.+?);/) || []; if (!name || !value) { - // eslint-disable-next-line no-console - console.warn(`Unknown content: ${line}`); + if (!line.includes('use crate')) { + // eslint-disable-next-line no-console + console.warn(`Unknown content: ${line}`); + } return; } @@ -327,6 +329,8 @@ function evaluateExpressions(expressions: [string, string][]): { [key: string]: // Remove 'as u8' and 'as u32' castings .replaceAll(' as u8', '') .replaceAll(' as u32', '') + // Remove the 'AztecAddress::from_field(...)' pattern + .replace(/AztecAddress::from_field\((0x[a-fA-F0-9]+)\)/g, '$1') // We make some space around the parentheses, so that constant numbers are still split. .replace(/\(/g, '( ') .replace(/\)/g, ' )')