Skip to content

Commit 7332e70

Browse files
feat!: demote auth registry to non-protocol contract (#23106)
Demotes auth_registry from protocol contract. Introduces generated `standard_addresses.nr` Noir file in aztec-nr and yarn-project/standard-contracts TS package that includes "drift" checks at build time and compile time to prevent someone from proceeding when they should actually go back and rebuild noir-contracts. Deploy `AuthRegistry` once per fresh rollup: `aztec-wallet deploy auth_registry_contract@AuthRegistry --salt 1 --universal -f <fee-paying-account>`. **CLI change**: Removed `--deployer <address>` flag from `aztec-wallet deploy`; `--universal` now works alongside `-f` to set deployer=0x0 while paying fees from the specified account. Stacked on #23216. --------- Co-authored-by: dbanks12 <davidjbanks920@gmail.com>
1 parent 6542ea5 commit 7332e70

84 files changed

Lines changed: 1277 additions & 129 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

barretenberg/cpp/pil/vm2/constants_gen.pil

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace constants;
1515
pol MAX_L2_TO_L1_MSGS_PER_TX = 8;
1616
pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
1717
pol MAX_PROTOCOL_CONTRACTS = 11;
18-
pol CANONICAL_AUTH_REGISTRY_ADDRESS = 1;
1918
pol CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 2;
2019
pol CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 3;
2120
pol MULTI_CALL_ENTRYPOINT_ADDRESS = 4;

barretenberg/cpp/src/barretenberg/aztec/aztec_constants.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define GENESIS_ARCHIVE_ROOT "0x177a4955b31ecaafad999753938a44e526b54c5ba5d536688227f85f15cfbdf5"
2222
#define MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS 3000
2323
#define MAX_PROTOCOL_CONTRACTS 11
24-
#define CANONICAL_AUTH_REGISTRY_ADDRESS 1
2524
#define CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS 2
2625
#define CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS 3
2726
#define MULTI_CALL_ENTRYPOINT_ADDRESS 4

docs/docs-developers/docs/foundational-topics/transactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ The setup phase runs before the user's application logic. Fee-related bookkeepin
120120
- The fee payer is nominated via a call to the protocol's `set_as_fee_payer()` function. An FPC typically calls this in its entrypoint; a user paying directly with Fee Juice does it implicitly via the default entrypoint.
121121
- `end_setup()` is called to mark the boundary between the non-revertible and revertible phases. Everything committed before `end_setup()` stands regardless of whether later phases revert.
122122

123-
Because the setup phase is non-revertible, the protocol restricts which public function calls are allowed during it. The default allowlist permits only protocol-contract setup functions (for example those on `AuthRegistry` and `FeeJuice`); in v4.2.0, public token functions such as `transfer_in_public` and `_increase_public_balance` were removed from it. See the [migration note](../resources/migration_notes.md#custom-token-fpcs-removed-from-default-public-setup-allowlist) for details.
123+
Because the setup phase is non-revertible, the protocol restricts which public function calls are allowed during it. The default allowlist permits a small set of trusted setup functions (for example those on `AuthRegistry` and `FeeJuice`); in v4.2.0, public token functions such as `transfer_in_public` and `_increase_public_balance` were removed from it. See the [migration note](../resources/migration_notes.md#custom-token-fpcs-removed-from-default-public-setup-allowlist) for details.
124124

125125
Practical consequences:
126126

docs/docs-developers/docs/resources/migration_notes.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ Aztec is in active development. Each version may introduce breaking changes that
3939
```
4040

4141
**Impact**: Code importing or referencing `ExtendedDirectionalAppTaggingSecret` should update to `AppTaggingSecret`.
42+
43+
### [Aztec.nr] `auth_registry` demoted from protocol contract
44+
45+
`auth_registry` is no longer a protocol contract. Its address is now derived from its artifact rather than hardcoded at `1`. The aztec-nr constant has moved and been renamed:
46+
47+
```diff
48+
- use protocol_types::constants::CANONICAL_AUTH_REGISTRY_ADDRESS;
49+
+ use crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS;
50+
```
51+
52+
PXE no longer auto-registers `AuthRegistry` on startup. If your wallet needs it, register it explicitly (as the `EmbeddedWallet` entrypoints do):
53+
54+
```ts
55+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
56+
57+
const { instance, artifact } = await getStandardAuthRegistry();
58+
await pxe.registerContract({ instance, artifact });
59+
```
60+
61+
For browser bundles, import from `@aztec/standard-contracts/auth-registry/lazy` instead.
62+
63+
Deploy `AuthRegistry` once per fresh rollup: `aztec-wallet deploy auth_registry_contract@AuthRegistry --salt 1 --universal -f <fee-paying-account>`.
64+
4265
### [Aztec.nr] `public_checks` helpers moved to `aztec-nr`
4366

4467
The `privately_check_timestamp`, `privately_check_block_number`, and related caller helpers previously in `noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr` are now in `aztec-nr/aztec/src/public_checks.nr`. Consumer contracts should update their imports:

noir-projects/aztec-nr/aztec/src/authwit/auth.nr

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ use crate::{
88
use crate::protocol::{
99
abis::function_selector::FunctionSelector,
1010
address::AztecAddress,
11-
constants::{
12-
CANONICAL_AUTH_REGISTRY_ADDRESS, DOM_SEP__AUTHWIT_INNER, DOM_SEP__AUTHWIT_NULLIFIER, DOM_SEP__AUTHWIT_OUTER,
13-
},
11+
constants::{DOM_SEP__AUTHWIT_INNER, DOM_SEP__AUTHWIT_NULLIFIER, DOM_SEP__AUTHWIT_OUTER},
1412
hash::poseidon2_hash_with_separator,
1513
traits::{Serialize, ToField},
1614
};
15+
use crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS;
1716

1817
/// Authentication witness helper library
1918
///
@@ -318,7 +317,7 @@ pub unconstrained fn assert_inner_hash_valid_authwit_public(
318317
inner_hash: Field,
319318
) {
320319
let results: [Field] = context.call_public_function(
321-
CANONICAL_AUTH_REGISTRY_ADDRESS,
320+
STANDARD_AUTH_REGISTRY_ADDRESS,
322321
comptime { FunctionSelector::from_signature("consume((Field),Field)") },
323322
[on_behalf_of.to_field(), inner_hash],
324323
GasOpts::default(),
@@ -399,7 +398,7 @@ pub fn compute_authwit_message_hash(
399398
/// false if it should be revoked
400399
pub unconstrained fn set_authorized(context: PublicContext, message_hash: Field, authorize: bool) {
401400
let res = context.call_public_function(
402-
CANONICAL_AUTH_REGISTRY_ADDRESS,
401+
STANDARD_AUTH_REGISTRY_ADDRESS,
403402
comptime { FunctionSelector::from_signature("set_authorized(Field,bool)") },
404403
[message_hash, authorize as Field],
405404
GasOpts::default(),
@@ -414,7 +413,7 @@ pub unconstrained fn set_authorized(context: PublicContext, message_hash: Field,
414413
/// @param reject True if all authwits should be rejected, false otherwise
415414
pub unconstrained fn set_reject_all(context: PublicContext, reject: bool) {
416415
let res = context.call_public_function(
417-
CANONICAL_AUTH_REGISTRY_ADDRESS,
416+
STANDARD_AUTH_REGISTRY_ADDRESS,
418417
comptime { FunctionSelector::from_signature("set_reject_all(bool)") },
419418
[reject as Field],
420419
GasOpts::default(),

noir-projects/aztec-nr/aztec/src/lib.nr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ pub mod utils;
4848
pub mod authwit;
4949
pub mod public_checks;
5050
pub mod macros;
51+
pub mod standard_addresses;
5152

5253
pub mod test;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// GENERATED FILE - DO NOT EDIT. RUN `yarn workspace @aztec/standard-contracts run generate`.
2+
use protocol_types::{address::AztecAddress, traits::FromField};
3+
4+
pub global STANDARD_AUTH_REGISTRY_ADDRESS: AztecAddress = AztecAddress::from_field(
5+
0x10ee94aaade35b40c82ec78d87269e55c39aa874ce585866ae43207da8c09c0e,
6+
);

noir-projects/aztec-nr/aztec/src/test/helpers/authwit.nr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ use crate::{
55
test::helpers::{test_environment::TestEnvironment, txe_oracles},
66
};
77

8-
use crate::protocol::{
9-
abis::function_selector::FunctionSelector, address::AztecAddress, constants::CANONICAL_AUTH_REGISTRY_ADDRESS,
10-
traits::ToField,
11-
};
8+
use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::ToField};
9+
use crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS;
1210

1311
pub unconstrained fn add_private_authwit_from_call<let M: u32, let N: u32, T>(
1412
env: TestEnvironment,
@@ -48,7 +46,7 @@ pub unconstrained fn add_public_authwit_from_call<let M: u32, let N: u32, T>(
4846
env.call_public(
4947
on_behalf_of,
5048
PublicCall::<_, _, ()>::new(
51-
CANONICAL_AUTH_REGISTRY_ADDRESS,
49+
STANDARD_AUTH_REGISTRY_ADDRESS,
5250
comptime { FunctionSelector::from_signature("set_authorized(Field,bool)") },
5351
"set_authorized",
5452
[message_hash, true as Field],

noir-projects/noir-contracts/Nargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ members = [
2727
"contracts/fees/fpc_contract",
2828
"contracts/fees/sponsored_fpc_contract",
2929
"contracts/message_discovery/handshake_registry_contract",
30-
"contracts/protocol/auth_registry_contract",
30+
"contracts/standard/auth_registry_contract",
3131
"contracts/protocol/contract_class_registry_contract",
3232
"contracts/protocol/contract_instance_registry_contract",
3333
"contracts/protocol/fee_juice_contract",

noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/authwit/auth.nr

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ use crate::context::{gas::GasOpts, PrivateContext, PublicContext};
22
use crate::protocol::{
33
abis::function_selector::FunctionSelector,
44
address::AztecAddress,
5-
constants::{
6-
CANONICAL_AUTH_REGISTRY_ADDRESS, DOM_SEP__AUTHWIT_INNER, DOM_SEP__AUTHWIT_NULLIFIER,
7-
DOM_SEP__AUTHWIT_OUTER,
8-
},
5+
constants::{DOM_SEP__AUTHWIT_INNER, DOM_SEP__AUTHWIT_NULLIFIER, DOM_SEP__AUTHWIT_OUTER},
96
hash::poseidon2_hash_with_separator,
107
traits::ToField,
118
};
9+
use crate::standard_addresses::STANDARD_AUTH_REGISTRY_ADDRESS;
1210

1311
/// Success indicator for authwit - 4 last bytes of poseidon2_hash_bytes("IS_VALID()")
1412
pub global IS_VALID_SELECTOR: Field = 0x47dacd73;
@@ -78,7 +76,7 @@ pub unconstrained fn assert_inner_hash_valid_authwit_public(
7876
inner_hash: Field,
7977
) {
8078
let results: [Field] = context.call_public_function(
81-
CANONICAL_AUTH_REGISTRY_ADDRESS,
79+
STANDARD_AUTH_REGISTRY_ADDRESS,
8280
comptime { FunctionSelector::from_signature("consume((Field),Field)") },
8381
[on_behalf_of.to_field(), inner_hash],
8482
GasOpts::default(),
@@ -129,7 +127,7 @@ pub fn compute_authwit_message_hash(
129127
/// @param authorize True if the message should be authorized, false if it should be revoked
130128
pub unconstrained fn set_authorized(context: PublicContext, message_hash: Field, authorize: bool) {
131129
let res = context.call_public_function(
132-
CANONICAL_AUTH_REGISTRY_ADDRESS,
130+
STANDARD_AUTH_REGISTRY_ADDRESS,
133131
comptime { FunctionSelector::from_signature("set_authorized(Field,bool)") },
134132
[message_hash, authorize as Field],
135133
GasOpts::default(),
@@ -142,7 +140,7 @@ pub unconstrained fn set_authorized(context: PublicContext, message_hash: Field,
142140
/// @param reject True if all authwits should be rejected, false otherwise
143141
pub unconstrained fn set_reject_all(context: PublicContext, reject: bool) {
144142
let res = context.call_public_function(
145-
CANONICAL_AUTH_REGISTRY_ADDRESS,
143+
STANDARD_AUTH_REGISTRY_ADDRESS,
146144
comptime { FunctionSelector::from_signature("set_reject_all(bool)") },
147145
[reject as Field],
148146
GasOpts::default(),

0 commit comments

Comments
 (0)