@aztec/pxe 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +1 -1
- package/dest/bin/check_oracle_version.js +110 -10
- 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} +23 -23
- 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 +9 -17
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +10 -16
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +44 -15
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +142 -57
- package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +28 -17
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- 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/noir-structs/log_retrieval_response.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +101 -81
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +11 -12
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +15 -24
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +51 -25
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +103 -27
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +65 -36
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +171 -69
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- 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/contract_function_simulator/proxied_node.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
- 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 +4 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +20 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -2
- package/dest/entrypoints/server/utils.d.ts +5 -24
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +17 -45
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +9 -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/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +9 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +39 -0
- 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/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/index.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +10 -9
- 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 +232 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +299 -324
- 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 -4
- 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/anchor_block_store/anchor_block_store.d.ts +9 -0
- 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 -12
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- 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} +34 -10
- 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} +10 -18
- 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 -18
- 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/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- package/dest/storage/index.d.ts +8 -9
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -8
- package/dest/storage/metadata.d.ts +1 -1
- 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_store/note_store.d.ts +84 -0
- 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} +144 -82
- package/dest/storage/private_event_store/private_event_store.d.ts +56 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +157 -0
- 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 +16 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +23 -0
- 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 +22 -24
- package/src/bin/check_oracle_version.ts +134 -10
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +22 -23
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +18 -32
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +233 -75
- package/src/contract_function_simulator/execution_note_cache.ts +33 -17
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +3 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
- package/src/contract_function_simulator/oracle/oracle.ts +135 -80
- package/src/contract_function_simulator/oracle/private_execution.ts +22 -28
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +200 -56
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +260 -109
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- 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 +3 -2
- package/src/entrypoints/client/bundle/utils.ts +21 -23
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +20 -23
- package/src/entrypoints/pxe_creation_options.ts +4 -1
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +20 -68
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +11 -15
- package/src/events/event_service.ts +77 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +48 -0
- 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/oracle_version.ts +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +10 -9
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +349 -410
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -7
- 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 -17
- 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} +34 -12
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +67 -28
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +7 -8
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +173 -111
- package/src/storage/private_event_store/private_event_store.ts +213 -0
- 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 +28 -0
- 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/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -48
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -285
- 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/oracle/typed_oracle.d.ts +0 -87
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -158
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
- package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
- package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
- package/dest/contract_function_simulator/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -100
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
- 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 -27
- 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/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +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_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
- 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 +0 -37
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -96
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- 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 +0 -12
- 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 -18
- 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 -82
- 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 -35
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -62
- package/src/contract_function_simulator/execution_data_provider.ts +0 -361
- package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1020
- package/src/contract_function_simulator/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- 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/data_provider.ts +0 -3
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_dao.ts +0 -154
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -134
- 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 -123
- package/src/synchronizer/index.ts +0 -1
- package/src/test/pxe_test_suite.ts +0 -113
|
@@ -2,8 +2,13 @@ import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { NoteStatus } from '@aztec/stdlib/note';
|
|
5
|
-
import { NoteDao } from '
|
|
6
|
-
|
|
5
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
6
|
+
/**
|
|
7
|
+
* NoteStore manages the storage and retrieval of notes.
|
|
8
|
+
*
|
|
9
|
+
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
10
|
+
* and performs rollback handling in the case of a reorg.
|
|
11
|
+
**/ export class NoteStore {
|
|
7
12
|
#store;
|
|
8
13
|
#notes;
|
|
9
14
|
#nullifiedNotes;
|
|
@@ -12,15 +17,11 @@ export class NoteDataProvider {
|
|
|
12
17
|
#nullifiedNotesToScope;
|
|
13
18
|
#nullifiedNotesByContract;
|
|
14
19
|
#nullifiedNotesByStorageSlot;
|
|
15
|
-
#nullifiedNotesByTxHash;
|
|
16
|
-
#nullifiedNotesByRecipient;
|
|
17
20
|
#nullifiedNotesByNullifier;
|
|
18
21
|
#scopes;
|
|
19
22
|
#notesToScope;
|
|
20
23
|
#notesByContractAndScope;
|
|
21
24
|
#notesByStorageSlotAndScope;
|
|
22
|
-
#notesByTxHashAndScope;
|
|
23
|
-
#notesByRecipientAndScope;
|
|
24
25
|
constructor(store){
|
|
25
26
|
this.#store = store;
|
|
26
27
|
this.#notes = store.openMap('notes');
|
|
@@ -30,27 +31,37 @@ export class NoteDataProvider {
|
|
|
30
31
|
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
31
32
|
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
32
33
|
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
33
|
-
this.#nullifiedNotesByTxHash = store.openMultiMap('nullified_notes_by_tx_hash');
|
|
34
|
-
this.#nullifiedNotesByRecipient = store.openMultiMap('nullified_notes_by_recipient');
|
|
35
34
|
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
36
35
|
this.#scopes = store.openMap('scopes');
|
|
37
36
|
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
38
37
|
this.#notesByContractAndScope = new Map();
|
|
39
38
|
this.#notesByStorageSlotAndScope = new Map();
|
|
40
|
-
this.#notesByTxHashAndScope = new Map();
|
|
41
|
-
this.#notesByRecipientAndScope = new Map();
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Creates and initializes a new NoteStore instance.
|
|
42
|
+
*
|
|
43
|
+
* This factory method creates a NoteStore and restores any existing
|
|
44
|
+
* scope-specific indexes from the database.
|
|
45
|
+
*
|
|
46
|
+
* @param store - The key-value store to use for persistence
|
|
47
|
+
* @returns Promise resolving to a fully initialized NoteStore instance
|
|
48
|
+
*/ static async create(store) {
|
|
49
|
+
const pxeDB = new NoteStore(store);
|
|
45
50
|
for await (const scope of pxeDB.#scopes.keysAsync()){
|
|
46
51
|
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
47
52
|
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
48
|
-
pxeDB.#notesByTxHashAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_tx_hash`));
|
|
49
|
-
pxeDB.#notesByRecipientAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_recipient`));
|
|
50
53
|
}
|
|
51
54
|
return pxeDB;
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Adds a new scope to the note data provider.
|
|
58
|
+
*
|
|
59
|
+
* Scopes provide privacy isolation by creating separate indexes for each user.
|
|
60
|
+
* Each scope gets its own set of indexes for efficient note retrieval by various criteria.
|
|
61
|
+
*
|
|
62
|
+
* @param scope - The AztecAddress representing the scope/user to add
|
|
63
|
+
* @returns Promise resolving to true if scope was added, false if it already existed
|
|
64
|
+
*/ async addScope(scope) {
|
|
54
65
|
const scopeString = scope.toString();
|
|
55
66
|
if (await this.#scopes.hasAsync(scopeString)) {
|
|
56
67
|
return false;
|
|
@@ -58,32 +69,53 @@ export class NoteDataProvider {
|
|
|
58
69
|
await this.#scopes.set(scopeString, true);
|
|
59
70
|
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
60
71
|
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
61
|
-
this.#notesByTxHashAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_tx_hash`));
|
|
62
|
-
this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`));
|
|
63
72
|
return true;
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Adds multiple notes to the data provider under the specified scope.
|
|
76
|
+
*
|
|
77
|
+
* Notes are stored using their index from the notes hash tree as the key, which provides
|
|
78
|
+
* uniqueness and maintains creation order. Each note is indexed by multiple criteria
|
|
79
|
+
* for efficient retrieval.
|
|
80
|
+
*
|
|
81
|
+
* @param notes - Notes to store
|
|
82
|
+
* @param scope - The scope (user/account) under which to store the notes
|
|
83
|
+
*/ addNotes(notes, scope) {
|
|
66
84
|
return this.#store.transactionAsync(async ()=>{
|
|
67
85
|
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
68
86
|
await this.addScope(scope);
|
|
69
87
|
}
|
|
70
88
|
for (const dao of notes){
|
|
71
|
-
// store notes by their index in the notes hash tree
|
|
72
|
-
// this provides the uniqueness we need to store individual notes
|
|
73
|
-
// and should also return notes in the order that they were created.
|
|
74
|
-
// Had we stored them by their nullifier, they would be returned in random order
|
|
75
89
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
76
90
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
77
91
|
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
78
92
|
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
79
93
|
await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
|
|
80
94
|
await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
|
|
81
|
-
await this.#notesByTxHashAndScope.get(scope.toString()).set(dao.txHash.toString(), noteIndex);
|
|
82
|
-
await this.#notesByRecipientAndScope.get(scope.toString()).set(dao.recipient.toString(), noteIndex);
|
|
83
95
|
}
|
|
84
96
|
});
|
|
85
97
|
}
|
|
86
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Synchronizes notes and nullifiers to a specific block number.
|
|
100
|
+
*
|
|
101
|
+
* This method ensures that the state of notes and nullifiers is consistent with the
|
|
102
|
+
* specified block number. It restores any notes that were nullified after the given block
|
|
103
|
+
* and deletes any active notes created after that block.
|
|
104
|
+
*
|
|
105
|
+
* @param blockNumber - The new chain tip after a reorg
|
|
106
|
+
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
107
|
+
*/ async rollbackNotesAndNullifiers(blockNumber, synchedBlockNumber) {
|
|
108
|
+
await this.#rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber);
|
|
109
|
+
await this.#deleteActiveNotesAfterBlock(blockNumber);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Deletes (removes) all active notes created after the specified block number.
|
|
113
|
+
*
|
|
114
|
+
* Permanently delete notes from the active notes store, e.g. during a reorg.
|
|
115
|
+
* Note: This only affects #notes (active notes), not #nullifiedNotes.
|
|
116
|
+
*
|
|
117
|
+
* @param blockNumber - Notes created after this block number will be deleted
|
|
118
|
+
*/ #deleteActiveNotesAfterBlock(blockNumber) {
|
|
87
119
|
return this.#store.transactionAsync(async ()=>{
|
|
88
120
|
const notes = await toArray(this.#notes.valuesAsync());
|
|
89
121
|
for (const note of notes){
|
|
@@ -95,8 +127,6 @@ export class NoteDataProvider {
|
|
|
95
127
|
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
96
128
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
97
129
|
for (const scope of scopes){
|
|
98
|
-
await this.#notesByRecipientAndScope.get(scope).deleteValue(noteDao.recipient.toString(), noteIndex);
|
|
99
|
-
await this.#notesByTxHashAndScope.get(scope).deleteValue(noteDao.txHash.toString(), noteIndex);
|
|
100
130
|
await this.#notesByContractAndScope.get(scope).deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
101
131
|
await this.#notesByStorageSlotAndScope.get(scope).deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
102
132
|
}
|
|
@@ -104,12 +134,20 @@ export class NoteDataProvider {
|
|
|
104
134
|
}
|
|
105
135
|
});
|
|
106
136
|
}
|
|
107
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Rewinds nullifications after a given block number.
|
|
139
|
+
*
|
|
140
|
+
* This operation "unnullifies" notes, rolling back nullifications that occurred
|
|
141
|
+
* in orphaned blocks, e.g. during a reorg. The notes are restored to the
|
|
142
|
+
* active notes store and removed from the nullified store.
|
|
143
|
+
*
|
|
144
|
+
* @param blockNumber - Revert nullifications that occurred after this block
|
|
145
|
+
* @param synchedBlockNumber - Upper bound for the block range to process
|
|
146
|
+
*/ async #rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber) {
|
|
108
147
|
await this.#store.transactionAsync(async ()=>{
|
|
109
148
|
const nullifiersToUndo = [];
|
|
110
149
|
const currentBlockNumber = blockNumber + 1;
|
|
111
|
-
|
|
112
|
-
for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
|
|
150
|
+
for(let i = currentBlockNumber; i <= synchedBlockNumber; i++){
|
|
113
151
|
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
114
152
|
}
|
|
115
153
|
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
@@ -120,17 +158,15 @@ export class NoteDataProvider {
|
|
|
120
158
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
121
159
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
122
160
|
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
123
|
-
|
|
161
|
+
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
124
162
|
if (scopes.length === 0) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
163
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
164
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
165
|
+
throw new Error(`No scopes found for nullified note with index ${noteIndex}`);
|
|
128
166
|
}
|
|
129
167
|
for (const scope of scopes){
|
|
130
168
|
await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
|
|
131
169
|
await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
|
|
132
|
-
await this.#notesByTxHashAndScope.get(scope.toString()).set(dao.txHash.toString(), noteIndex);
|
|
133
|
-
await this.#notesByRecipientAndScope.get(scope.toString()).set(dao.recipient.toString(), noteIndex);
|
|
134
170
|
await this.#notesToScope.set(noteIndex, scope);
|
|
135
171
|
}
|
|
136
172
|
await this.#nullifiedNotes.delete(noteIndex);
|
|
@@ -138,33 +174,58 @@ export class NoteDataProvider {
|
|
|
138
174
|
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
139
175
|
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
140
176
|
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
141
|
-
await this.#nullifiedNotesByTxHash.deleteValue(dao.txHash.toString(), noteIndex);
|
|
142
|
-
await this.#nullifiedNotesByRecipient.deleteValue(dao.recipient.toString(), noteIndex);
|
|
143
177
|
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
144
178
|
}
|
|
145
179
|
});
|
|
146
180
|
}
|
|
147
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Retrieves notes based on the provided filter criteria.
|
|
183
|
+
*
|
|
184
|
+
* This method queries both active and optionally nullified notes based on the filter
|
|
185
|
+
* parameters.
|
|
186
|
+
*
|
|
187
|
+
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
188
|
+
* owner, storageSlot, status, scopes, and siloedNullifier.
|
|
189
|
+
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
190
|
+
* returned once if this is the case)
|
|
191
|
+
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
192
|
+
*/ async getNotes(filter) {
|
|
148
193
|
filter.status = filter.status ?? NoteStatus.ACTIVE;
|
|
194
|
+
// throw early if scopes is an empty array
|
|
195
|
+
if (filter.scopes !== undefined && filter.scopes.length === 0) {
|
|
196
|
+
throw new Error('Trying to get notes with an empty scopes array. Scopes have to be set to undefined if intending on not filtering by scopes.');
|
|
197
|
+
}
|
|
149
198
|
const candidateNoteSources = [];
|
|
150
199
|
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map((addressString)=>AztecAddress.fromString(addressString));
|
|
151
200
|
const activeNoteIdsPerScope = [];
|
|
152
201
|
for (const scope of new Set(filter.scopes)){
|
|
153
202
|
const formattedScopeString = scope.toString();
|
|
154
203
|
if (!await this.#scopes.hasAsync(formattedScopeString)) {
|
|
155
|
-
throw new Error('Trying to get incoming notes of
|
|
204
|
+
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
156
205
|
}
|
|
157
|
-
activeNoteIdsPerScope.push(filter.
|
|
206
|
+
activeNoteIdsPerScope.push(filter.storageSlot ? await toArray(this.#notesByStorageSlotAndScope.get(formattedScopeString).getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#notesByContractAndScope.get(formattedScopeString).getValuesAsync(filter.contractAddress.toString())));
|
|
158
207
|
}
|
|
159
208
|
candidateNoteSources.push({
|
|
160
209
|
ids: new Set(activeNoteIdsPerScope.flat()),
|
|
161
210
|
notes: this.#notes
|
|
162
211
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
212
|
+
// If status is ACTIVE_OR_NULLIFIED we add nullified notes as candidates on top of the default active ones.
|
|
213
|
+
if (filter.status === NoteStatus.ACTIVE_OR_NULLIFIED) {
|
|
214
|
+
const nullifiedIds = filter.storageSlot ? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString()));
|
|
215
|
+
const setOfScopes = new Set(filter.scopes.map((s)=>s.toString()));
|
|
216
|
+
const filteredNullifiedIds = new Set();
|
|
217
|
+
for (const noteId of nullifiedIds){
|
|
218
|
+
const scopeList = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteId));
|
|
219
|
+
if (scopeList.some((scope)=>setOfScopes.has(scope))) {
|
|
220
|
+
filteredNullifiedIds.add(noteId);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (filteredNullifiedIds.size > 0) {
|
|
224
|
+
candidateNoteSources.push({
|
|
225
|
+
ids: filteredNullifiedIds,
|
|
226
|
+
notes: this.#nullifiedNotes
|
|
227
|
+
});
|
|
228
|
+
}
|
|
168
229
|
}
|
|
169
230
|
const result = [];
|
|
170
231
|
for (const { ids, notes } of candidateNoteSources){
|
|
@@ -177,24 +238,38 @@ export class NoteDataProvider {
|
|
|
177
238
|
if (!note.contractAddress.equals(filter.contractAddress)) {
|
|
178
239
|
continue;
|
|
179
240
|
}
|
|
180
|
-
if (filter.
|
|
241
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
181
242
|
continue;
|
|
182
243
|
}
|
|
183
244
|
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot)) {
|
|
184
245
|
continue;
|
|
185
246
|
}
|
|
186
|
-
if (filter.recipient && !note.recipient.equals(filter.recipient)) {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
247
|
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
190
248
|
continue;
|
|
191
249
|
}
|
|
192
250
|
result.push(note);
|
|
193
251
|
}
|
|
194
252
|
}
|
|
195
|
-
|
|
253
|
+
// A note might be present in multiple scopes - we ensure it is only returned once
|
|
254
|
+
const deduplicated = [];
|
|
255
|
+
for (const note of result){
|
|
256
|
+
if (!deduplicated.some((existing)=>existing.equals(note))) {
|
|
257
|
+
deduplicated.push(note);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return deduplicated;
|
|
196
261
|
}
|
|
197
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Transitions notes from "active" to "nullified" state.
|
|
264
|
+
*
|
|
265
|
+
* This operation processes a batch of nullifiers to mark the corresponding notes
|
|
266
|
+
* as spent/nullified. The operation is atomic - if any nullifier is not found,
|
|
267
|
+
* the entire operation fails and no notes are modified.
|
|
268
|
+
*
|
|
269
|
+
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
270
|
+
* @returns Promise resolving to array of nullified NoteDao objects
|
|
271
|
+
* @throws Error if any nullifier is not found in the active notes
|
|
272
|
+
*/ applyNullifiers(nullifiers) {
|
|
198
273
|
if (nullifiers.length === 0) {
|
|
199
274
|
return Promise.resolve([]);
|
|
200
275
|
}
|
|
@@ -202,59 +277,46 @@ export class NoteDataProvider {
|
|
|
202
277
|
const nullifiedNotes = [];
|
|
203
278
|
for (const blockScopedNullifier of nullifiers){
|
|
204
279
|
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
205
|
-
const
|
|
280
|
+
const nullifierKey = nullifier.toString();
|
|
281
|
+
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
206
282
|
if (!noteIndex) {
|
|
207
|
-
|
|
283
|
+
// Check if already nullified?
|
|
284
|
+
const alreadyNullified = await this.#nullifiedNotesByNullifier.getAsync(nullifierKey);
|
|
285
|
+
if (alreadyNullified) {
|
|
286
|
+
throw new Error(`Nullifier already applied in applyNullifiers`);
|
|
287
|
+
}
|
|
288
|
+
throw new Error('Nullifier not found in applyNullifiers');
|
|
208
289
|
}
|
|
209
290
|
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
210
291
|
if (!noteBuffer) {
|
|
211
|
-
throw new Error('Note not found in
|
|
292
|
+
throw new Error('Note not found in applyNullifiers');
|
|
212
293
|
}
|
|
213
|
-
const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex))
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
294
|
+
const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex));
|
|
295
|
+
if (noteScopes.length === 0) {
|
|
296
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
297
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
298
|
+
throw new Error('Note scopes are missing in applyNullifiers');
|
|
217
299
|
}
|
|
300
|
+
const note = NoteDao.fromBuffer(noteBuffer);
|
|
218
301
|
nullifiedNotes.push(note);
|
|
219
302
|
await this.#notes.delete(noteIndex);
|
|
220
303
|
await this.#notesToScope.delete(noteIndex);
|
|
221
304
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
222
305
|
for (const scope of scopes){
|
|
223
|
-
await this.#notesByRecipientAndScope.get(scope).deleteValue(note.recipient.toString(), noteIndex);
|
|
224
|
-
await this.#notesByTxHashAndScope.get(scope).deleteValue(note.txHash.toString(), noteIndex);
|
|
225
306
|
await this.#notesByContractAndScope.get(scope).deleteValue(note.contractAddress.toString(), noteIndex);
|
|
226
307
|
await this.#notesByStorageSlotAndScope.get(scope).deleteValue(note.storageSlot.toString(), noteIndex);
|
|
227
308
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
231
|
-
}
|
|
309
|
+
for (const scope of noteScopes){
|
|
310
|
+
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
232
311
|
}
|
|
233
312
|
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
234
313
|
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
235
314
|
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
236
315
|
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
237
|
-
await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
|
|
238
|
-
await this.#nullifiedNotesByRecipient.set(note.recipient.toString(), noteIndex);
|
|
239
316
|
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
240
317
|
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
241
318
|
}
|
|
242
319
|
return nullifiedNotes;
|
|
243
320
|
});
|
|
244
321
|
}
|
|
245
|
-
async getSize() {
|
|
246
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
247
|
-
const contractAddresses = new Set();
|
|
248
|
-
// Collect all unique contract addresses across all scopes
|
|
249
|
-
for (const scope of scopes){
|
|
250
|
-
const addresses = await toArray(this.#notesByContractAndScope.get(scope).keysAsync());
|
|
251
|
-
addresses.forEach((addr)=>contractAddresses.add(addr));
|
|
252
|
-
}
|
|
253
|
-
// Get all notes for each contract address
|
|
254
|
-
const allNotes = await Promise.all(Array.from(contractAddresses).map((addr)=>this.getNotes({
|
|
255
|
-
contractAddress: AztecAddress.fromString(addr)
|
|
256
|
-
})));
|
|
257
|
-
// Reduce all notes to get total size
|
|
258
|
-
return allNotes.flat().reduce((sum, note)=>sum + note.getSize(), 0);
|
|
259
|
-
}
|
|
260
322
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { type InTx, TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { PackedPrivateEvent } from '../../pxe.js';
|
|
7
|
+
export type PrivateEventStoreFilter = {
|
|
8
|
+
contractAddress: AztecAddress;
|
|
9
|
+
fromBlock: number;
|
|
10
|
+
toBlock: number;
|
|
11
|
+
scopes: AztecAddress[];
|
|
12
|
+
txHash?: TxHash;
|
|
13
|
+
};
|
|
14
|
+
type PrivateEventMetadata = InTx & {
|
|
15
|
+
contractAddress: AztecAddress;
|
|
16
|
+
scope: AztecAddress;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Stores decrypted private event logs.
|
|
20
|
+
*/
|
|
21
|
+
export declare class PrivateEventStore {
|
|
22
|
+
#private;
|
|
23
|
+
logger: import("@aztec/foundation/log").Logger;
|
|
24
|
+
constructor(store: AztecAsyncKVStore);
|
|
25
|
+
/**
|
|
26
|
+
* Store a private event log.
|
|
27
|
+
* @param eventSelector - The event selector of the event.
|
|
28
|
+
* @param msgContent - The content of the event.
|
|
29
|
+
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
30
|
+
* @param metadata
|
|
31
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
32
|
+
* scope - The address to which the event is scoped.
|
|
33
|
+
* txHash - The transaction hash of the event log.
|
|
34
|
+
* blockNumber - The block number in which the event was emitted.
|
|
35
|
+
*/
|
|
36
|
+
storePrivateEventLog(eventSelector: EventSelector, msgContent: Fr[], eventCommitmentIndex: number, metadata: PrivateEventMetadata): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the private events given search parameters.
|
|
39
|
+
* @param eventSelector - The event selector to filter by.
|
|
40
|
+
* @param filter - Filtering criteria:
|
|
41
|
+
* contractAddress: The address of the contract to get events from.
|
|
42
|
+
* fromBlock: The block number to search from (inclusive).
|
|
43
|
+
* toBlock: The block number to search upto (exclusive).
|
|
44
|
+
* scope: - The addresses that decrypted the logs.
|
|
45
|
+
* @returns - The event log contents, augmented with metadata about
|
|
46
|
+
* the transaction and block it the event was included in .
|
|
47
|
+
*/
|
|
48
|
+
getPrivateEvents(eventSelector: EventSelector, filter: PrivateEventStoreFilter): Promise<PackedPrivateEvent[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
51
|
+
* number up to which PXE managed to sync before the reorg happened).
|
|
52
|
+
*/
|
|
53
|
+
rollbackEventsAfterBlock(blockNumber: number, synchedBlockNumber: number): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9ldmVudF9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvcHJpdmF0ZV9ldmVudF9zdG9yZS9wcml2YXRlX2V2ZW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUdwRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRSxPQUFPLEVBQUUsS0FBSyxJQUFJLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFdkQsTUFBTSxNQUFNLHVCQUF1QixHQUFHO0lBQ3BDLGVBQWUsRUFBRSxZQUFZLENBQUM7SUFDOUIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixPQUFPLEVBQUUsTUFBTSxDQUFDO0lBQ2hCLE1BQU0sRUFBRSxZQUFZLEVBQUUsQ0FBQztJQUN2QixNQUFNLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDakIsQ0FBQztBQVlGLEtBQUssb0JBQW9CLEdBQUcsSUFBSSxHQUFHO0lBQ2pDLGVBQWUsRUFBRSxZQUFZLENBQUM7SUFDOUIsS0FBSyxFQUFFLFlBQVksQ0FBQztDQUNyQixDQUFDO0FBRUY7O0dBRUc7QUFDSCxxQkFBYSxpQkFBaUI7O0lBVzVCLE1BQU0seUNBQXVDO0lBRTdDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQU1uQztJQU1EOzs7Ozs7Ozs7O09BVUc7SUFDSCxvQkFBb0IsQ0FDbEIsYUFBYSxFQUFFLGFBQWEsRUFDNUIsVUFBVSxFQUFFLEVBQUUsRUFBRSxFQUNoQixvQkFBb0IsRUFBRSxNQUFNLEVBQzVCLFFBQVEsRUFBRSxvQkFBb0IsR0FDN0IsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWlDZjtJQUVEOzs7Ozs7Ozs7O09BVUc7SUFDVSxnQkFBZ0IsQ0FDM0IsYUFBYSxFQUFFLGFBQWEsRUFDNUIsTUFBTSxFQUFFLHVCQUF1QixHQUM5QixPQUFPLENBQUMsa0JBQWtCLEVBQUUsQ0FBQyxDQXdDL0I7SUFFRDs7O09BR0c7SUFDVSx3QkFBd0IsQ0FBQyxXQUFXLEVBQUUsTUFBTSxFQUFFLGtCQUFrQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBcUNwRztDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_event_store.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_store/private_event_store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,MAAM,uBAAuB,GAAG;IACpC,eAAe,EAAE,YAAY,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAYF,KAAK,oBAAoB,GAAG,IAAI,GAAG;IACjC,eAAe,EAAE,YAAY,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAiB;;IAW5B,MAAM,yCAAuC;IAE7C,YAAY,KAAK,EAAE,iBAAiB,EAMnC;IAMD;;;;;;;;;;OAUG;IACH,oBAAoB,CAClB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,EAAE,EAAE,EAChB,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiCf;IAED;;;;;;;;;;OAUG;IACU,gBAAgB,CAC3B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwC/B;IAED;;;OAGG;IACU,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqCpG;CACF"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
|
+
/**
|
|
8
|
+
* Stores decrypted private event logs.
|
|
9
|
+
*/ export class PrivateEventStore {
|
|
10
|
+
#store;
|
|
11
|
+
/** Map storing the actual private event log entries, keyed by eventCommitmentIndex */ #eventLogs;
|
|
12
|
+
/** Map from contractAddress_scope_eventSelector to eventCommitmentIndex[] for efficient lookup */ #eventsByContractScopeSelector;
|
|
13
|
+
/** Map from block number to eventCommitmentIndex[] for rollback support */ #eventsByBlockNumber;
|
|
14
|
+
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */ #seenLogs;
|
|
15
|
+
logger = createLogger('private_event_store');
|
|
16
|
+
constructor(store){
|
|
17
|
+
this.#store = store;
|
|
18
|
+
this.#eventLogs = this.#store.openMap('private_event_logs');
|
|
19
|
+
this.#eventsByContractScopeSelector = this.#store.openMap('events_by_contract_scope_selector');
|
|
20
|
+
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
21
|
+
this.#eventsByBlockNumber = this.#store.openMap('events_by_block_number');
|
|
22
|
+
}
|
|
23
|
+
#keyFor(contractAddress, scope, eventSelector) {
|
|
24
|
+
return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Store a private event log.
|
|
28
|
+
* @param eventSelector - The event selector of the event.
|
|
29
|
+
* @param msgContent - The content of the event.
|
|
30
|
+
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
31
|
+
* @param metadata
|
|
32
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
33
|
+
* scope - The address to which the event is scoped.
|
|
34
|
+
* txHash - The transaction hash of the event log.
|
|
35
|
+
* blockNumber - The block number in which the event was emitted.
|
|
36
|
+
*/ storePrivateEventLog(eventSelector, msgContent, eventCommitmentIndex, metadata) {
|
|
37
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
38
|
+
return this.#store.transactionAsync(async ()=>{
|
|
39
|
+
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
40
|
+
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
41
|
+
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
42
|
+
if (hasBeenSeen) {
|
|
43
|
+
this.logger.verbose('Ignoring duplicate event log', {
|
|
44
|
+
txHash: txHash.toString(),
|
|
45
|
+
eventCommitmentIndex
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.logger.verbose('storing private event log', {
|
|
50
|
+
contractAddress,
|
|
51
|
+
scope,
|
|
52
|
+
msgContent,
|
|
53
|
+
l2BlockNumber
|
|
54
|
+
});
|
|
55
|
+
await this.#eventLogs.set(eventCommitmentIndex, {
|
|
56
|
+
msgContent: serializeToBuffer(msgContent),
|
|
57
|
+
l2BlockNumber,
|
|
58
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
59
|
+
eventCommitmentIndex,
|
|
60
|
+
txHash: txHash.toBuffer(),
|
|
61
|
+
lookupKey: key
|
|
62
|
+
});
|
|
63
|
+
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(key) || [];
|
|
64
|
+
await this.#eventsByContractScopeSelector.set(key, [
|
|
65
|
+
...existingIndices,
|
|
66
|
+
eventCommitmentIndex
|
|
67
|
+
]);
|
|
68
|
+
const existingBlockIndices = await this.#eventsByBlockNumber.getAsync(l2BlockNumber) || [];
|
|
69
|
+
await this.#eventsByBlockNumber.set(l2BlockNumber, [
|
|
70
|
+
...existingBlockIndices,
|
|
71
|
+
eventCommitmentIndex
|
|
72
|
+
]);
|
|
73
|
+
// Mark this log as seen using eventCommitmentIndex
|
|
74
|
+
await this.#seenLogs.set(eventCommitmentIndex, true);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the private events given search parameters.
|
|
79
|
+
* @param eventSelector - The event selector to filter by.
|
|
80
|
+
* @param filter - Filtering criteria:
|
|
81
|
+
* contractAddress: The address of the contract to get events from.
|
|
82
|
+
* fromBlock: The block number to search from (inclusive).
|
|
83
|
+
* toBlock: The block number to search upto (exclusive).
|
|
84
|
+
* scope: - The addresses that decrypted the logs.
|
|
85
|
+
* @returns - The event log contents, augmented with metadata about
|
|
86
|
+
* the transaction and block it the event was included in .
|
|
87
|
+
*/ async getPrivateEvents(eventSelector, filter) {
|
|
88
|
+
const events = [];
|
|
89
|
+
for (const scope of filter.scopes){
|
|
90
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
91
|
+
const eventCommitmentIndices = await this.#eventsByContractScopeSelector.getAsync(key) || [];
|
|
92
|
+
for (const eventCommitmentIndex of eventCommitmentIndices){
|
|
93
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
94
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// Convert buffer back to Fr array
|
|
98
|
+
const reader = BufferReader.asReader(entry.msgContent);
|
|
99
|
+
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
100
|
+
const msgContent = reader.readArray(numFields, Fr);
|
|
101
|
+
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
102
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
103
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
events.push({
|
|
107
|
+
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
108
|
+
event: {
|
|
109
|
+
packedEvent: msgContent,
|
|
110
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
111
|
+
txHash,
|
|
112
|
+
l2BlockHash,
|
|
113
|
+
eventSelector
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Sort by eventCommitmentIndex only
|
|
119
|
+
events.sort((a, b)=>a.eventCommitmentIndex - b.eventCommitmentIndex);
|
|
120
|
+
return events.map((ev)=>ev.event);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
124
|
+
* number up to which PXE managed to sync before the reorg happened).
|
|
125
|
+
*/ async rollbackEventsAfterBlock(blockNumber, synchedBlockNumber) {
|
|
126
|
+
await this.#store.transactionAsync(async ()=>{
|
|
127
|
+
let removedCount = 0;
|
|
128
|
+
for(let block = blockNumber + 1; block <= synchedBlockNumber; block++){
|
|
129
|
+
const indices = await this.#eventsByBlockNumber.getAsync(block);
|
|
130
|
+
if (indices) {
|
|
131
|
+
await this.#eventsByBlockNumber.delete(block);
|
|
132
|
+
for (const eventCommitmentIndex of indices){
|
|
133
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
134
|
+
if (!entry) {
|
|
135
|
+
throw new Error(`Event log not found for eventCommitmentIndex ${eventCommitmentIndex}`);
|
|
136
|
+
}
|
|
137
|
+
await this.#eventLogs.delete(eventCommitmentIndex);
|
|
138
|
+
await this.#seenLogs.delete(eventCommitmentIndex);
|
|
139
|
+
// Update #eventsByContractScopeSelector using the stored lookupKey
|
|
140
|
+
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(entry.lookupKey);
|
|
141
|
+
if (!existingIndices || existingIndices.length === 0) {
|
|
142
|
+
throw new Error(`No indices found in #eventsByContractScopeSelector for key ${entry.lookupKey}`);
|
|
143
|
+
}
|
|
144
|
+
const filteredIndices = existingIndices.filter((idx)=>idx !== eventCommitmentIndex);
|
|
145
|
+
if (filteredIndices.length === 0) {
|
|
146
|
+
await this.#eventsByContractScopeSelector.delete(entry.lookupKey);
|
|
147
|
+
} else {
|
|
148
|
+
await this.#eventsByContractScopeSelector.set(entry.lookupKey, filteredIndices);
|
|
149
|
+
}
|
|
150
|
+
removedCount++;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SenderTaggingStore } from './sender_tagging_store.js';
|
|
2
|
+
export { SenderAddressBookStore } from './sender_address_book_store.js';
|
|
3
|
+
export { RecipientTaggingStore } from './recipient_tagging_store.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDL0QsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDeEUsT0FBTyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sOEJBQThCLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
+
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
|
+
/**
|
|
4
|
+
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
5
|
+
* is called SenderTaggingStore. We have the providers separate for the sender and recipient because
|
|
6
|
+
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
7
|
+
*
|
|
8
|
+
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
9
|
+
* blocks, which by definition cannot be affected by reorgs.
|
|
10
|
+
*
|
|
11
|
+
* TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
|
|
12
|
+
*/
|
|
13
|
+
export declare class RecipientTaggingStore {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(store: AztecAsyncKVStore);
|
|
16
|
+
getHighestAgedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
|
|
17
|
+
updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void>;
|
|
18
|
+
getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
|
|
19
|
+
updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvcmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RTs7Ozs7Ozs7O0dBU0c7QUFDSCxxQkFBYSxxQkFBcUI7O0lBTWhDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUtuQztJQUVELG1CQUFtQixDQUFDLE1BQU0sRUFBRSwyQkFBMkIsR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUVwRjtJQUVLLHNCQUFzQixDQUFDLE1BQU0sRUFBRSwyQkFBMkIsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FPOUY7SUFFRCx3QkFBd0IsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FFekY7SUFFSywyQkFBMkIsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBUW5HO0NBQ0YifQ==
|