Skip to content

feat(aztec-nr)!: add explicit custom_sync_state hook to AztecConfig#23446

Merged
nchamo merged 3 commits into
merge-train/fairiesfrom
nchamo/f-655-add-explicit-custom-sync_state-hook-to-aztecconfig
May 22, 2026
Merged

feat(aztec-nr)!: add explicit custom_sync_state hook to AztecConfig#23446
nchamo merged 3 commits into
merge-train/fairiesfrom
nchamo/f-655-add-explicit-custom-sync_state-hook-to-aztecconfig

Conversation

@nchamo

@nchamo nchamo commented May 20, 2026

Copy link
Copy Markdown
Contributor

Why we are doing this

Contracts that wanted to customize state sync had to override the macro-generated sync_state utility by defining a function with that name. The override happened silently — the macro had no way to surface that the default was being replaced, and there was no compile-time signal when the override accidentally shadowed the generated function.

Our fix

Adds an explicit AztecConfig::custom_sync_state() builder that registers a CustomSyncHandler. The handler receives the same parameters as the default do_sync_state and can wrap, delegate to, or skip it. Defining a function named sync_state directly now errors with a message pointing users at the new builder.

The naming follows the existing CustomMessageHandler pattern for sibling consistency. A custom_sync_state_contract exercises the full flow (deploy + execute_utility) and verifies the handler is invoked in the right scope.

Migration

See migration_notes.md. Only contracts that previously defined their own sync_state function are affected; users of the default macro-generated sync need no changes.

Fixes F-655

@nchamo nchamo requested a review from nventuro as a code owner May 20, 2026 22:19
@nchamo nchamo self-assigned this May 20, 2026

### [Aztec.nr] Defining a custom `sync_state` function now requires `AztecConfig`

Contracts that previously overrode the default `sync_state` by defining their own function with that name will now get a compile error. Use `AztecConfig::custom_sync_state()` instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if we should call this custom_sync_state() or custom_sync_handler(). What do you think?

@nchamo nchamo requested a review from mverzilli May 20, 2026 22:42
Comment on lines +70 to +71
pub comptime fn custom_sync_state(self, handler: CustomSyncHandler<()>) -> Self {
Self { custom_message_handler: self.custom_message_handler, custom_sync_state: Option::some(handler) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: we should interact with mutable AztecConfig references, so instead of rebuilding a new object on each of these extension point calls we can just mutate the corresponding one. The convenience is not related to performance, it's to avoid having to edit each of these functions each time we add a new one.

This is something I had intended to do when introducing custom_message_handler but I lost it through the cracks

@mverzilli mverzilli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, loved the "sync counter" example to showcase the feature

nchamo added 2 commits May 22, 2026 13:28
…/f-655-add-explicit-custom-sync_state-hook-to-aztecconfig

# Conflicts:
#	docs/docs-developers/docs/resources/migration_notes.md
@nchamo nchamo enabled auto-merge (squash) May 22, 2026 13:37
@AztecBot

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/9b9349a2295c8021�9b9349a2295c80218;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_mbps.parallel.test.ts "builds multiple blocks per slot with L2 to L1 messages" (380s) (code: 0) group:e2e-p2p-epoch-flakes

@nchamo nchamo merged commit a15c6ef into merge-train/fairies May 22, 2026
14 checks passed
@nchamo nchamo deleted the nchamo/f-655-add-explicit-custom-sync_state-hook-to-aztecconfig branch May 22, 2026 13:58
github-merge-queue Bot pushed a commit that referenced this pull request May 25, 2026
BEGIN_COMMIT_OVERRIDE
feat(txe): add TXE oracle version check to bootstrap (#23324)
fix(txe): correct TXE_ORACLE_INTERFACE_HASH to match current oracle
interface (#23460)
feat(aztec-nr): add Serialize/Deserialize for EphemeralArray (#23417)
refactor: move validation and error handling out of transport layer
(#23422)
feat(pxe)!: add source and block-range filtering to get_logs_by_tag
(#23326)
fix(txe): update TXE oracle interface hash for new AVM oracle methods
(#23492)
chore(ci): capture sandbox diagnostics on acceptance test failure
(#23495)
feat(aztec-nr)!: rename push_nullifier to push_nullifier_unsafe (#23488)
feat(aztec-nr)!: add explicit custom_sync_state hook to AztecConfig
(#23446)
fix(ci): skip aztec-cli notify job when acceptance test is skipped
(#23534)
fix: released contract artifact aztec version (forward port of #23470)
(#23500)
fix: merge train conflicts (#23548)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants