Skip to content

Commit 3b4ba4a

Browse files
authored
refactor(aztec-nr): shared no-op sync handler for stateless contracts (#24844)
## Summary - AuthRegistry, MultiCallEntrypoint and PublicChecks hold no private state, but used the default `sync_state`, which performs pointless discovery RPC calls and embeds the HandshakeRegistry address in their bytecode. - Adds a shared `do_sync_state_no_op` handler to aztec-nr and wires it into those three contracts, plus SchnorrInitializerlessAccount, which previously carried its own local copy of the same no-op. - The pinned standard-contract artifacts are untouched, so shipped artifacts and addresses only change at the next intentional re-pin.
1 parent 1879ac1 commit 3b4ba4a

5 files changed

Lines changed: 22 additions & 27 deletions

File tree

  • noir-projects
    • aztec-nr/aztec/src/messages/discovery
    • noir-contracts/contracts
      • account/schnorr_initializerless_account_contract/src
      • standard
        • auth_registry_contract/src
        • multi_call_entrypoint_contract/src
        • public_checks_contract/src

noir-projects/aztec-nr/aztec/src/messages/discovery/mod.nr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ pub unconstrained fn do_sync_state_without_handshake_discovery(
174174
);
175175
}
176176

177+
/// A [`CustomSyncHandler`] that skips state synchronization entirely.
178+
///
179+
/// For contracts that hold no private state and emit no messages, there is nothing to discover: syncing would only
180+
/// perform unnecessary RPC calls.
181+
pub unconstrained fn do_sync_state_no_op(
182+
_contract_address: AztecAddress,
183+
_compute_note_hash: ComputeNoteHash,
184+
_compute_note_nullifier: ComputeNoteNullifier,
185+
_process_custom_message: Option<CustomMessageHandler>,
186+
_offchain_inbox_sync: Option<OffchainInboxSync>,
187+
_scope: AztecAddress,
188+
) {}
189+
177190
unconstrained fn sync_state_with_secrets(
178191
contract_address: AztecAddress,
179192
compute_note_hash: ComputeNoteHash,

noir-projects/noir-contracts/contracts/account/schnorr_initializerless_account_contract/src/main.nr

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
use aztec::{
2-
macros::{aztec, AztecConfig},
3-
messages::{
4-
discovery::{ComputeNoteHash, ComputeNoteNullifier, CustomMessageHandler},
5-
processing::offchain::OffchainInboxSync,
6-
},
7-
protocol::address::AztecAddress,
8-
};
9-
10-
/// Empty override to opt-out of state syncing. This contract does not hold private state,
11-
/// so runnning the sync process just results in unnecessary RPC calls
12-
unconstrained fn no_sync(
13-
_contract_address: AztecAddress,
14-
_compute_note_hash: ComputeNoteHash,
15-
_compute_note_nullifier: ComputeNoteNullifier,
16-
_process_custom_message: Option<CustomMessageHandler>,
17-
_offchain_inbox_sync: Option<OffchainInboxSync>,
18-
_scope: AztecAddress,
19-
) {}
20-
21-
#[aztec(AztecConfig::new().custom_sync_state(crate::no_sync))]
1+
use aztec::{macros::{aztec, AztecConfig}, messages::discovery::do_sync_state_no_op};
2+
3+
#[aztec(AztecConfig::new().custom_sync_state(do_sync_state_no_op))]
224
pub contract SchnorrInitializerlessAccount {
235
use aztec::{
246
authwit::{

noir-projects/noir-contracts/contracts/standard/auth_registry_contract/src/main.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use aztec::macros::aztec;
1+
use aztec::{macros::{aztec, AztecConfig}, messages::discovery::do_sync_state_no_op};
22

33
/// A contract that manages public authentication witnesses (authwits) on the Aztec network.
44
///
@@ -14,7 +14,7 @@ use aztec::macros::aztec;
1414
/// Note that there is no expiration time enforced on the approved actions in this contract as this can be achieved by
1515
/// including an expiration timestamp in the `message` (`message_hash` preimage) and having the consumer contract
1616
/// constrain that value.
17-
#[aztec]
17+
#[aztec(AztecConfig::new().custom_sync_state(do_sync_state_no_op))]
1818
pub contract AuthRegistry {
1919
use aztec::{
2020
authwit::auth::{assert_current_call_valid_authwit, compute_authwit_message_hash, IS_VALID_SELECTOR},

noir-projects/noir-contracts/contracts/standard/multi_call_entrypoint_contract/src/main.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
//
99
// Note that this contract should not be grouped with protocol contracts as it is not part of the protocol. We keep
1010
// it here for now as it allows us to use hardcoded address.
11-
use aztec::macros::aztec;
11+
use aztec::{macros::{aztec, AztecConfig}, messages::discovery::do_sync_state_no_op};
1212

13-
#[aztec]
13+
#[aztec(AztecConfig::new().custom_sync_state(do_sync_state_no_op))]
1414
pub contract MultiCallEntrypoint {
1515
use aztec::{authwit::entrypoint::app::AppPayload, macros::functions::{allow_phase_change, external}};
1616

noir-projects/noir-contracts/contracts/standard/public_checks_contract/src/main.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
mod test;
22

3-
use aztec::macros::aztec;
3+
use aztec::{macros::{aztec, AztecConfig}, messages::discovery::do_sync_state_no_op};
44

55
/// The purpose of this contract is to perform a check in public without revealing what contract enqueued the public
66
/// call. This can be achieved by enqueueing an `incognito` public call.
77
///
88
/// Note that this contract should not be grouped with protocol contracts as it is not part of the protocol. We keep
99
/// it here for now as it allows us to use hardcoded address.
10-
#[aztec]
10+
#[aztec(AztecConfig::new().custom_sync_state(do_sync_state_no_op))]
1111
pub contract PublicChecks {
1212
use aztec::{macros::functions::{external, view}, utils::comparison::compare};
1313

0 commit comments

Comments
 (0)