@aztec/pxe 3.0.0-rc.5 → 4.0.0-nightly.20260107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +22 -22
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +4 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +40 -11
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +47 -17
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -4
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +3 -3
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +7 -9
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +11 -11
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -8
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +24 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +47 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +143 -37
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +47 -0
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +4 -4
- package/dest/logs/log_service.d.ts +26 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +120 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +4 -4
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +7 -7
- package/dest/public_storage/public_storage_service.d.ts +24 -0
- package/dest/public_storage/public_storage_service.d.ts.map +1 -0
- package/dest/public_storage/public_storage_service.js +26 -0
- package/dest/pxe.d.ts +25 -33
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +125 -136
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.d.ts → anchor_block_store/anchor_block_store.d.ts} +2 -4
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +33 -5
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +7 -4
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -3
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +7 -7
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +6 -6
- package/dest/storage/{private_event_data_provider/private_event_data_provider.d.ts → private_event_store/private_event_store.d.ts} +9 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/{private_event_data_provider/private_event_data_provider.js → private_event_store/private_event_store.js} +57 -15
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
- package/dest/tagging/index.d.ts +15 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +23 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +20 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +32 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +55 -0
- package/dest/tree_membership/tree_membership_service.d.ts +52 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +84 -0
- package/package.json +16 -16
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +21 -22
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +3 -3
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +84 -15
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +5 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +2 -3
- package/src/contract_function_simulator/oracle/oracle.ts +3 -3
- package/src/contract_function_simulator/oracle/private_execution.ts +14 -13
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +89 -19
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +208 -45
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/debug/pxe_debug_utils.ts +48 -0
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +77 -0
- package/src/events/private_event_filter_validator.ts +5 -4
- package/src/logs/log_service.ts +202 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/private_kernel/private_kernel_oracle_impl.ts +6 -6
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +153 -162
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -12
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +33 -1
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +64 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +7 -7
- package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +69 -18
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
- package/src/tagging/index.ts +27 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +96 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
- package/src/tree_membership/tree_membership_service.ts +112 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -268
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -124
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -713
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -36
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/tagging/constants.d.ts +0 -2
- package/dest/tagging/constants.d.ts.map +0 -1
- package/dest/tagging/constants.js +0 -2
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -343
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1040
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/tagging/constants.ts +0 -2
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
5
|
+
/**
|
|
6
|
+
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
|
|
7
|
+
* `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
|
|
8
|
+
* exclusive.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadLogsForRange(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, start: number, end: number, anchorBlockNumber: BlockNumber): Promise<Array<{
|
|
11
|
+
log: TxScopedL2Log;
|
|
12
|
+
taggingIndex: number;
|
|
13
|
+
}>>;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9sb2dzX2Zvcl9yYW5nZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvdXRpbHMvbG9hZF9sb2dzX2Zvcl9yYW5nZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUc3Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsMkJBQTJCLEVBQ25DLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxpQkFBaUIsRUFBRSxXQUFXLEdBQzdCLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FBQyxDQXdCOUQifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG7F;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,WAAW,GAC7B,OAAO,CAAC,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAwB9D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
2
|
+
/**
|
|
3
|
+
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
|
|
4
|
+
* `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
|
|
5
|
+
* exclusive.
|
|
6
|
+
*/ export async function loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber) {
|
|
7
|
+
// Derive tags for the window
|
|
8
|
+
const preTags = Array(end - start).fill(0).map((_, i)=>({
|
|
9
|
+
secret,
|
|
10
|
+
index: start + i
|
|
11
|
+
}));
|
|
12
|
+
const siloedTags = await Promise.all(preTags.map((preTag)=>Tag.compute(preTag))).then((tags)=>Promise.all(tags.map((tag)=>SiloedTag.compute(tag, app))));
|
|
13
|
+
const logs = await aztecNode.getPrivateLogsByTags(siloedTags);
|
|
14
|
+
// Pair logs with their corresponding tagging indexes
|
|
15
|
+
const logsWithIndexes = [];
|
|
16
|
+
for(let i = 0; i < logs.length; i++){
|
|
17
|
+
const logsForTag = logs[i];
|
|
18
|
+
const taggingIndex = preTags[i].index;
|
|
19
|
+
for (const log of logsForTag){
|
|
20
|
+
if (log.blockNumber <= anchorBlockNumber) {
|
|
21
|
+
logsWithIndexes.push({
|
|
22
|
+
log,
|
|
23
|
+
taggingIndex
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return logsWithIndexes;
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
4
|
+
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
5
|
+
/**
|
|
6
|
+
* Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
|
|
7
|
+
*
|
|
8
|
+
* @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
|
|
9
|
+
* sender -> recipient matters.
|
|
10
|
+
* @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
|
|
11
|
+
* second round of siloing in this function which is necessary because kernels do it as well (they silo first field
|
|
12
|
+
* of the private log which corresponds to the tag).
|
|
13
|
+
* @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
|
|
14
|
+
* pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
|
|
15
|
+
* is simply the highest pending index plus one (or finalized if pending is undefined).
|
|
16
|
+
* @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
|
|
17
|
+
* updates its status accordingly.
|
|
18
|
+
*/
|
|
19
|
+
export declare function syncSenderTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, taggingStore: SenderTaggingStore): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSwyQkFBMkIsRUFDbkMsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixHQUMvQixPQUFPLENBQUMsSUFBSSxDQUFDLENBbUVmIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAmEf"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../index.js';
|
|
2
|
+
import { getStatusChangeOfPending } from './utils/get_status_change_of_pending.js';
|
|
3
|
+
import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_tagging_indexes.js';
|
|
4
|
+
/**
|
|
5
|
+
* Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
|
|
6
|
+
*
|
|
7
|
+
* @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
|
|
8
|
+
* sender -> recipient matters.
|
|
9
|
+
* @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
|
|
10
|
+
* second round of siloing in this function which is necessary because kernels do it as well (they silo first field
|
|
11
|
+
* of the private log which corresponds to the tag).
|
|
12
|
+
* @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
|
|
13
|
+
* pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
|
|
14
|
+
* is simply the highest pending index plus one (or finalized if pending is undefined).
|
|
15
|
+
* @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
|
|
16
|
+
* updates its status accordingly.
|
|
17
|
+
*/ export async function syncSenderTaggingIndexes(secret, app, aztecNode, taggingStore) {
|
|
18
|
+
// # Explanation of how syncing works
|
|
19
|
+
//
|
|
20
|
+
// When choosing an index, we select: highest pending index + 1 (or highest finalized index + 1 if no pending).
|
|
21
|
+
// If the chosen index is more than WINDOW_LEN from the highest finalized index, we throw an error. By having this
|
|
22
|
+
// hard limit we give a guarantee to a recipient that he doesn't need to look further than WINDOW_LEN ahead of the
|
|
23
|
+
// highest finalized index.
|
|
24
|
+
//
|
|
25
|
+
// This function synchronizes the finalized and pending indexes by iteratively querying the node for a window of
|
|
26
|
+
// indexes at a time, storing all those indexes as pending, and then checking the status of each pending index to
|
|
27
|
+
// update its finalization status accordingly. If we stumble upon a window with no indexes, we stop the loop.
|
|
28
|
+
//
|
|
29
|
+
// Stopping at that point is safe because of the limit described above - there can never be an index that is more
|
|
30
|
+
// than WINDOW_LEN from the highest finalized index.
|
|
31
|
+
//
|
|
32
|
+
// # Note on performance
|
|
33
|
+
// Each window advance requires two queries (logs + tx status). For example, syncing indexes 0–500 with a window of
|
|
34
|
+
// 100 takes at least 10 round trips (5 windows × 2 queries).
|
|
35
|
+
const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
|
|
36
|
+
let start = finalizedIndex === undefined ? 0 : finalizedIndex + 1;
|
|
37
|
+
let end = start + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN;
|
|
38
|
+
let previousFinalizedIndex = finalizedIndex;
|
|
39
|
+
let newFinalizedIndex = undefined;
|
|
40
|
+
while(true){
|
|
41
|
+
// Load and store indexes for the current window. These indexes may already exist in the database if txs using
|
|
42
|
+
// them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
|
|
43
|
+
await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore);
|
|
44
|
+
// Retrieve all indexes within the current window from storage and update their status accordingly.
|
|
45
|
+
const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end);
|
|
46
|
+
if (pendingTxHashes.length === 0) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
|
|
50
|
+
await taggingStore.dropPendingIndexes(txHashesToDrop);
|
|
51
|
+
await taggingStore.finalizePendingIndexes(txHashesToFinalize);
|
|
52
|
+
// We check if the finalized index has been updated.
|
|
53
|
+
newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
|
|
54
|
+
if (previousFinalizedIndex !== newFinalizedIndex) {
|
|
55
|
+
// A new finalized index was found, so we'll run the loop again. For example:
|
|
56
|
+
// - Previous finalized index: 10
|
|
57
|
+
// - New finalized index: 13
|
|
58
|
+
// - Window length: 10
|
|
59
|
+
//
|
|
60
|
+
// In the last iteration, we processed indexes 11-20. To avoid reprocessing the same logs,
|
|
61
|
+
// we'll only look at the new indexes 21-23:
|
|
62
|
+
//
|
|
63
|
+
// Previous window: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
|
64
|
+
// New window: [21, 22, 23]
|
|
65
|
+
const previousEnd = end;
|
|
66
|
+
// Add 1 because `end` is exclusive and the known finalized index is not included in the window.
|
|
67
|
+
end = newFinalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1;
|
|
68
|
+
start = previousEnd;
|
|
69
|
+
previousFinalizedIndex = newFinalizedIndex;
|
|
70
|
+
} else {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
/**
|
|
4
|
+
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
|
|
5
|
+
* dropped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: AztecNode): Promise<{
|
|
8
|
+
txHashesToFinalize: TxHash[];
|
|
9
|
+
txHashesToDrop: TxHash[];
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQUMsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFBO0NBQUUsQ0FBQyxDQWlDckUifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiCrE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
2
|
+
/**
|
|
3
|
+
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
|
|
4
|
+
* dropped.
|
|
5
|
+
*/ export async function getStatusChangeOfPending(pending, aztecNode) {
|
|
6
|
+
// Get receipts for all pending tx hashes and the finalized block number.
|
|
7
|
+
const [receipts, { finalized }] = await Promise.all([
|
|
8
|
+
Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash))),
|
|
9
|
+
aztecNode.getL2Tips()
|
|
10
|
+
]);
|
|
11
|
+
const txHashesToFinalize = [];
|
|
12
|
+
const txHashesToDrop = [];
|
|
13
|
+
for(let i = 0; i < receipts.length; i++){
|
|
14
|
+
const receipt = receipts[i];
|
|
15
|
+
const txHash = pending[i];
|
|
16
|
+
if (receipt.status === TxStatus.SUCCESS && receipt.blockNumber && receipt.blockNumber <= finalized.number) {
|
|
17
|
+
// Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
|
|
18
|
+
// finalized.
|
|
19
|
+
txHashesToFinalize.push(txHash);
|
|
20
|
+
} else if (receipt.status === TxStatus.DROPPED || receipt.status === TxStatus.APP_LOGIC_REVERTED || receipt.status === TxStatus.TEARDOWN_REVERTED || receipt.status === TxStatus.BOTH_REVERTED) {
|
|
21
|
+
// Tx was dropped or reverted --> we drop the corresponding pending indexes.
|
|
22
|
+
// TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
|
|
23
|
+
txHashesToDrop.push(txHash);
|
|
24
|
+
} else {
|
|
25
|
+
// Tx is still pending or the corresponding block is not yet finalized --> we don't do anything.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
txHashesToFinalize,
|
|
30
|
+
txHashesToDrop
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
4
|
+
import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
|
|
5
|
+
/**
|
|
6
|
+
* Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
|
|
7
|
+
* @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
|
|
8
|
+
* place is when a tx is being sent from this PXE.
|
|
9
|
+
* @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
|
|
10
|
+
* @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
|
|
11
|
+
* kernel circuit behavior.
|
|
12
|
+
* @param start - The starting index (inclusive) of the window to process.
|
|
13
|
+
* @param end - The ending index (exclusive) of the window to process.
|
|
14
|
+
* @param aztecNode - The Aztec node instance to query for logs.
|
|
15
|
+
* @param taggingStore - The data provider to store pending indexes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFFakc7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCx3QkFBc0IsNkJBQTZCLENBQ2pELE1BQU0sRUFBRSwyQkFBMkIsRUFDbkMsR0FBRyxFQUFFLFlBQVksRUFDakIsS0FBSyxFQUFFLE1BQU0sRUFDYixHQUFHLEVBQUUsTUFBTSxFQUNYLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFlBQVksRUFBRSxrQkFBa0IsaUJBa0JqQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAEjG;;;;;;;;;;;GAWG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,iBAkBjC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
2
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
/**
|
|
4
|
+
* Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
|
|
5
|
+
* @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
|
|
6
|
+
* place is when a tx is being sent from this PXE.
|
|
7
|
+
* @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
|
|
8
|
+
* @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
|
|
9
|
+
* kernel circuit behavior.
|
|
10
|
+
* @param start - The starting index (inclusive) of the window to process.
|
|
11
|
+
* @param end - The ending index (exclusive) of the window to process.
|
|
12
|
+
* @param aztecNode - The Aztec node instance to query for logs.
|
|
13
|
+
* @param taggingStore - The data provider to store pending indexes.
|
|
14
|
+
*/ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore) {
|
|
15
|
+
// We compute the tags for the current window of indexes
|
|
16
|
+
const preTagsForWindow = Array(end - start).fill(0).map((_, i)=>({
|
|
17
|
+
secret,
|
|
18
|
+
index: start + i
|
|
19
|
+
}));
|
|
20
|
+
const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
|
|
21
|
+
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
|
|
22
|
+
const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
|
|
23
|
+
// Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
|
|
24
|
+
for (const [txHashStr, highestIndex] of highestIndexMap.entries()){
|
|
25
|
+
const txHash = TxHash.fromString(txHashStr);
|
|
26
|
+
await taggingStore.storePendingIndexes([
|
|
27
|
+
{
|
|
28
|
+
secret,
|
|
29
|
+
index: highestIndex
|
|
30
|
+
}
|
|
31
|
+
], txHash);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
|
|
35
|
+
// an array for each tag.
|
|
36
|
+
async function getTxsContainingTags(tags, aztecNode) {
|
|
37
|
+
const allLogs = await aztecNode.getPrivateLogsByTags(tags);
|
|
38
|
+
return allLogs.map((logs)=>logs.map((log)=>log.txHash));
|
|
39
|
+
}
|
|
40
|
+
// Returns a map of txHash to the highest index for that txHash.
|
|
41
|
+
function getTxHighestIndexMap(txHashesForTags, preTagsForWindow) {
|
|
42
|
+
if (txHashesForTags.length !== preTagsForWindow.length) {
|
|
43
|
+
throw new Error(`Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`);
|
|
44
|
+
}
|
|
45
|
+
const highestIndexMap = new Map();
|
|
46
|
+
for(let i = 0; i < txHashesForTags.length; i++){
|
|
47
|
+
const taggingIndex = preTagsForWindow[i].index;
|
|
48
|
+
const txHashesForTag = txHashesForTags[i];
|
|
49
|
+
for (const txHash of txHashesForTag){
|
|
50
|
+
const key = txHash.toString();
|
|
51
|
+
highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return highestIndexMap;
|
|
55
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
8
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
|
+
export declare class TreeMembershipService {
|
|
10
|
+
#private;
|
|
11
|
+
private readonly aztecNode;
|
|
12
|
+
private readonly anchorBlockStore;
|
|
13
|
+
constructor(aztecNode: AztecNode, anchorBlockStore: AnchorBlockStore);
|
|
14
|
+
/**
|
|
15
|
+
* Gets the index of a nullifier in the nullifier tree.
|
|
16
|
+
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
17
|
+
*/
|
|
18
|
+
getNullifierIndex(nullifier: Fr): Promise<bigint | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
21
|
+
* @param blockNumber - The block number at which to get the membership witness.
|
|
22
|
+
* @param treeId - Id of the tree to get the sibling path from.
|
|
23
|
+
* @param leafValue - The leaf value
|
|
24
|
+
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
25
|
+
*/
|
|
26
|
+
getMembershipWitness(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
29
|
+
* @param blockNumber - The block number at which to get the index.
|
|
30
|
+
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
31
|
+
* @returns The low nullifier membership witness (if found).
|
|
32
|
+
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
33
|
+
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
34
|
+
* we are trying to prove non-inclusion for.
|
|
35
|
+
*/
|
|
36
|
+
getLowNullifierMembershipWitness(blockNumber: BlockParameter, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns a witness for a given slot of the public data tree at a given block.
|
|
39
|
+
* @param blockNumber - The block number at which to get the witness.
|
|
40
|
+
* @param leafSlot - The slot of the public data in the public data tree.
|
|
41
|
+
*/
|
|
42
|
+
getPublicDataWitness(blockNumber: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
45
|
+
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
46
|
+
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
47
|
+
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
48
|
+
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
49
|
+
*/
|
|
50
|
+
getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJlZV9tZW1iZXJzaGlwX3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmVlX21lbWJlcnNoaXAvdHJlZV9tZW1iZXJzaGlwX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRSxPQUFPLEVBQUUsWUFBWSxFQUFFLDBCQUEwQixFQUFFLGlCQUFpQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFFbEcsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxREFBcUQsQ0FBQztBQUU1RixxQkFBYSxxQkFBcUI7O0lBRTlCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGdCQUFnQjtJQUZuQyxZQUNtQixTQUFTLEVBQUUsU0FBUyxFQUNwQixnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFDakQ7SUFFSjs7O09BR0c7SUFDSSxpQkFBaUIsQ0FBQyxTQUFTLEVBQUUsRUFBRSwrQkFFckM7SUFFRDs7Ozs7O09BTUc7SUFDVSxvQkFBb0IsQ0FBQyxXQUFXLEVBQUUsY0FBYyxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsU0FBUyxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FNakg7SUFFRDs7Ozs7Ozs7T0FRRztJQUNVLGdDQUFnQyxDQUMzQyxXQUFXLEVBQUUsY0FBYyxFQUMzQixTQUFTLEVBQUUsRUFBRSxHQUNaLE9BQU8sQ0FBQywwQkFBMEIsR0FBRyxTQUFTLENBQUMsQ0FNakQ7SUFFRDs7OztPQUlHO0lBQ1Usb0JBQW9CLENBQUMsV0FBVyxFQUFFLGNBQWMsRUFBRSxRQUFRLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsR0FBRyxTQUFTLENBQUMsQ0FNbkg7SUFFRDs7Ozs7O09BTUc7SUFDSSwwQkFBMEIsQ0FDL0IsZUFBZSxFQUFFLFlBQVksRUFDN0IsV0FBVyxFQUFFLEVBQUUsRUFDZixNQUFNLEVBQUUsRUFBRSxHQUNULE9BQU8sQ0FBQyxDQUFDLE1BQU0sRUFBRSxXQUFXLENBQUMsT0FBTyx3QkFBd0IsQ0FBQyxDQUFDLENBQUMsQ0FFakU7Q0F5QkYifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree_membership_service.d.ts","sourceRoot":"","sources":["../../src/tree_membership/tree_membership_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAE5F,qBAAa,qBAAqB;;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAFnC,YACmB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EACjD;IAEJ;;;OAGG;IACI,iBAAiB,CAAC,SAAS,EAAE,EAAE,+BAErC;IAED;;;;;;OAMG;IACU,oBAAoB,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAMjH;IAED;;;;;;;;OAQG;IACU,gCAAgC,CAC3C,WAAW,EAAE,cAAc,EAC3B,SAAS,EAAE,EAAE,GACZ,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAMjD;IAED;;;;OAIG;IACU,oBAAoB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAMnH;IAED;;;;;;OAMG;IACI,0BAA0B,CAC/B,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,EAAE,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAEjE;CAyBF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
2
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
3
|
+
export class TreeMembershipService {
|
|
4
|
+
aztecNode;
|
|
5
|
+
anchorBlockStore;
|
|
6
|
+
constructor(aztecNode, anchorBlockStore){
|
|
7
|
+
this.aztecNode = aztecNode;
|
|
8
|
+
this.anchorBlockStore = anchorBlockStore;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Gets the index of a nullifier in the nullifier tree.
|
|
12
|
+
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
13
|
+
*/ getNullifierIndex(nullifier) {
|
|
14
|
+
return this.#findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
18
|
+
* @param blockNumber - The block number at which to get the membership witness.
|
|
19
|
+
* @param treeId - Id of the tree to get the sibling path from.
|
|
20
|
+
* @param leafValue - The leaf value
|
|
21
|
+
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
22
|
+
*/ async getMembershipWitness(blockNumber, treeId, leafValue) {
|
|
23
|
+
const witness = await this.#tryGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
24
|
+
if (!witness) {
|
|
25
|
+
throw new Error(`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block ${blockNumber}`);
|
|
26
|
+
}
|
|
27
|
+
return witness;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
31
|
+
* @param blockNumber - The block number at which to get the index.
|
|
32
|
+
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
33
|
+
* @returns The low nullifier membership witness (if found).
|
|
34
|
+
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
35
|
+
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
36
|
+
* we are trying to prove non-inclusion for.
|
|
37
|
+
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
38
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
39
|
+
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
40
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
41
|
+
}
|
|
42
|
+
return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns a witness for a given slot of the public data tree at a given block.
|
|
46
|
+
* @param blockNumber - The block number at which to get the witness.
|
|
47
|
+
* @param leafSlot - The slot of the public data in the public data tree.
|
|
48
|
+
*/ async getPublicDataWitness(blockNumber, leafSlot) {
|
|
49
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
50
|
+
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
51
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
52
|
+
}
|
|
53
|
+
return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
57
|
+
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
58
|
+
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
59
|
+
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
60
|
+
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
61
|
+
*/ getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
|
|
62
|
+
return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
|
|
63
|
+
}
|
|
64
|
+
async #tryGetMembershipWitness(blockNumber, treeId, value) {
|
|
65
|
+
switch(treeId){
|
|
66
|
+
case MerkleTreeId.NULLIFIER_TREE:
|
|
67
|
+
return (await this.aztecNode.getNullifierMembershipWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
68
|
+
case MerkleTreeId.NOTE_HASH_TREE:
|
|
69
|
+
return (await this.aztecNode.getNoteHashMembershipWitness(blockNumber, value))?.toFields();
|
|
70
|
+
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
71
|
+
return (await this.aztecNode.getPublicDataWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
72
|
+
case MerkleTreeId.ARCHIVE:
|
|
73
|
+
return (await this.aztecNode.getArchiveMembershipWitness(blockNumber, value))?.toFields();
|
|
74
|
+
default:
|
|
75
|
+
throw new Error('Not implemented');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async #findLeafIndex(blockNumber, treeId, leafValue) {
|
|
79
|
+
const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [
|
|
80
|
+
leafValue
|
|
81
|
+
]);
|
|
82
|
+
return leafIndex?.data;
|
|
83
|
+
}
|
|
84
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-nightly.20260107",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/entrypoints/server/index.js",
|
|
@@ -61,19 +61,19 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/bb-prover": "
|
|
65
|
-
"@aztec/bb.js": "
|
|
66
|
-
"@aztec/builder": "
|
|
67
|
-
"@aztec/constants": "
|
|
68
|
-
"@aztec/ethereum": "
|
|
69
|
-
"@aztec/foundation": "
|
|
70
|
-
"@aztec/key-store": "
|
|
71
|
-
"@aztec/kv-store": "
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "
|
|
73
|
-
"@aztec/noir-types": "
|
|
74
|
-
"@aztec/protocol-contracts": "
|
|
75
|
-
"@aztec/simulator": "
|
|
76
|
-
"@aztec/stdlib": "
|
|
64
|
+
"@aztec/bb-prover": "4.0.0-nightly.20260107",
|
|
65
|
+
"@aztec/bb.js": "4.0.0-nightly.20260107",
|
|
66
|
+
"@aztec/builder": "4.0.0-nightly.20260107",
|
|
67
|
+
"@aztec/constants": "4.0.0-nightly.20260107",
|
|
68
|
+
"@aztec/ethereum": "4.0.0-nightly.20260107",
|
|
69
|
+
"@aztec/foundation": "4.0.0-nightly.20260107",
|
|
70
|
+
"@aztec/key-store": "4.0.0-nightly.20260107",
|
|
71
|
+
"@aztec/kv-store": "4.0.0-nightly.20260107",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260107",
|
|
73
|
+
"@aztec/noir-types": "4.0.0-nightly.20260107",
|
|
74
|
+
"@aztec/protocol-contracts": "4.0.0-nightly.20260107",
|
|
75
|
+
"@aztec/simulator": "4.0.0-nightly.20260107",
|
|
76
|
+
"@aztec/stdlib": "4.0.0-nightly.20260107",
|
|
77
77
|
"koa": "^2.16.1",
|
|
78
78
|
"koa-router": "^13.1.1",
|
|
79
79
|
"lodash.omit": "^4.5.0",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@aztec/merkle-tree": "
|
|
86
|
-
"@aztec/noir-test-contracts.js": "
|
|
85
|
+
"@aztec/merkle-tree": "4.0.0-nightly.20260107",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "4.0.0-nightly.20260107",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -5,32 +5,32 @@ import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler
|
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
|
|
7
7
|
import type { PXEConfig } from '../config/index.js';
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
8
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
|
+
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
|
|
14
14
|
* view of the L2 chain state. It handles block header retrieval, chain reorganizations, and provides an interface
|
|
15
15
|
* for querying sync status.
|
|
16
16
|
*/
|
|
17
|
-
export class
|
|
17
|
+
export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
18
18
|
private log: Logger;
|
|
19
19
|
private isSyncing: Promise<void> | undefined;
|
|
20
20
|
protected readonly blockStream: L2BlockStream;
|
|
21
21
|
|
|
22
22
|
constructor(
|
|
23
23
|
private node: AztecNode,
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
24
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
25
|
+
private noteStore: NoteStore,
|
|
26
|
+
private privateEventStore: PrivateEventStore,
|
|
27
27
|
private l2TipsStore: L2TipsKVStore,
|
|
28
28
|
config: Partial<Pick<PXEConfig, 'l2BlockBatchSize'>> = {},
|
|
29
29
|
loggerOrSuffix?: string | Logger,
|
|
30
30
|
) {
|
|
31
31
|
this.log =
|
|
32
32
|
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
33
|
-
? createLogger(loggerOrSuffix ? `pxe:
|
|
33
|
+
? createLogger(loggerOrSuffix ? `pxe:block_synchronizer:${loggerOrSuffix}` : `pxe:block_synchronizer`)
|
|
34
34
|
: loggerOrSuffix;
|
|
35
35
|
this.blockStream = this.createBlockStream(config);
|
|
36
36
|
}
|
|
@@ -56,23 +56,21 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
56
56
|
archive: lastBlock.archive.root.toString(),
|
|
57
57
|
header: lastBlock.header.toInspect(),
|
|
58
58
|
});
|
|
59
|
-
await this.
|
|
59
|
+
await this.anchorBlockStore.setHeader(lastBlock.getBlockHeader());
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
case 'chain-pruned': {
|
|
63
63
|
this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
|
|
64
64
|
// We first unnullify and then remove so that unnullified notes that were created after the block number end up deleted.
|
|
65
|
-
const lastSynchedBlockNumber = await this.
|
|
66
|
-
await this.
|
|
67
|
-
|
|
68
|
-
// block number in which each index is used it's all we can do.
|
|
69
|
-
await this.taggingDataProvider.resetNoteSyncData();
|
|
65
|
+
const lastSynchedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
66
|
+
await this.noteStore.rollbackNotesAndNullifiers(event.block.number, lastSynchedBlockNumber);
|
|
67
|
+
await this.privateEventStore.rollbackEventsAfterBlock(event.block.number, lastSynchedBlockNumber);
|
|
70
68
|
// Update the header to the last block.
|
|
71
69
|
const newHeader = await this.node.getBlockHeader(event.block.number);
|
|
72
70
|
if (!newHeader) {
|
|
73
71
|
this.log.error(`Block header not found for block number ${event.block.number} during chain prune`);
|
|
74
72
|
} else {
|
|
75
|
-
await this.
|
|
73
|
+
await this.anchorBlockStore.setHeader(newHeader);
|
|
76
74
|
}
|
|
77
75
|
break;
|
|
78
76
|
}
|
|
@@ -82,6 +80,11 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
82
80
|
/**
|
|
83
81
|
* Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
|
|
84
82
|
* recent data (e.g. notes), and handling any reorgs that might have occurred.
|
|
83
|
+
*
|
|
84
|
+
* Note this BlockSynchronizer is designed to let its users control when a synchronization is run,
|
|
85
|
+
* so this component doesn't proactively stay up to date with the blockchain.
|
|
86
|
+
*
|
|
87
|
+
* We do this so PXE can ensure data consistency.
|
|
85
88
|
*/
|
|
86
89
|
public async sync() {
|
|
87
90
|
if (this.isSyncing !== undefined) {
|
|
@@ -104,18 +107,14 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
104
107
|
let currentHeader;
|
|
105
108
|
|
|
106
109
|
try {
|
|
107
|
-
currentHeader = await this.
|
|
110
|
+
currentHeader = await this.anchorBlockStore.getBlockHeader();
|
|
108
111
|
} catch {
|
|
109
112
|
this.log.debug('Header is not set, requesting from the node');
|
|
110
113
|
}
|
|
111
114
|
if (!currentHeader) {
|
|
112
115
|
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
113
|
-
await this.
|
|
116
|
+
await this.anchorBlockStore.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
|
|
114
117
|
}
|
|
115
118
|
await this.blockStream.sync();
|
|
116
119
|
}
|
|
117
|
-
|
|
118
|
-
public getSynchedBlockNumber() {
|
|
119
|
-
return this.syncDataProvider.getBlockNumber();
|
|
120
|
-
}
|
|
121
120
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './block_synchronizer.js';
|
package/src/config/index.ts
CHANGED
|
@@ -19,14 +19,14 @@ export interface KernelProverConfig {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Configuration settings for the synchronizer.
|
|
22
|
+
* Configuration settings for the block synchronizer.
|
|
23
23
|
*/
|
|
24
|
-
export interface
|
|
24
|
+
export interface BlockSynchronizerConfig {
|
|
25
25
|
/** Maximum amount of blocks to pull from the stream in one request when synchronizing */
|
|
26
26
|
l2BlockBatchSize: number;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig &
|
|
29
|
+
export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
|
|
30
30
|
|
|
31
31
|
export type CliPXEOptions = {
|
|
32
32
|
/** Custom Aztec Node URL to connect to */
|