feat(aztec-nr)!: add explicit custom_sync_state hook to AztecConfig#23446
Conversation
|
|
||
| ### [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. |
There was a problem hiding this comment.
I wasn't sure if we should call this custom_sync_state() or custom_sync_handler(). What do you think?
| pub comptime fn custom_sync_state(self, handler: CustomSyncHandler<()>) -> Self { | ||
| Self { custom_message_handler: self.custom_message_handler, custom_sync_state: Option::some(handler) } |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Very cool, loved the "sync counter" example to showcase the feature
…/f-655-add-explicit-custom-sync_state-hook-to-aztecconfig # Conflicts: # docs/docs-developers/docs/resources/migration_notes.md
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
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
Why we are doing this
Contracts that wanted to customize state sync had to override the macro-generated
sync_stateutility 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 aCustomSyncHandler. The handler receives the same parameters as the defaultdo_sync_stateand can wrap, delegate to, or skip it. Defining a function namedsync_statedirectly now errors with a message pointing users at the new builder.The naming follows the existing
CustomMessageHandlerpattern for sibling consistency. Acustom_sync_state_contractexercises 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_statefunction are affected; users of the default macro-generated sync need no changes.Fixes F-655