@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
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
6
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
7
7
|
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* NoteStore manages the storage and retrieval of notes.
|
|
12
|
+
*
|
|
13
|
+
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
14
|
+
* and performs rollback handling in the case of a reorg.
|
|
15
|
+
**/
|
|
16
|
+
export class NoteStore {
|
|
13
17
|
#store: AztecAsyncKVStore;
|
|
14
|
-
|
|
15
18
|
#notes: AztecAsyncMap<string, Buffer>;
|
|
16
19
|
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
17
20
|
#nullifierToNoteId: AztecAsyncMap<string, string>;
|
|
@@ -20,16 +23,12 @@ export class NoteDataProvider implements DataProvider {
|
|
|
20
23
|
#nullifiedNotesToScope: AztecAsyncMultiMap<string, string>;
|
|
21
24
|
#nullifiedNotesByContract: AztecAsyncMultiMap<string, string>;
|
|
22
25
|
#nullifiedNotesByStorageSlot: AztecAsyncMultiMap<string, string>;
|
|
23
|
-
#nullifiedNotesByTxHash: AztecAsyncMultiMap<string, string>;
|
|
24
|
-
#nullifiedNotesByRecipient: AztecAsyncMultiMap<string, string>;
|
|
25
26
|
#nullifiedNotesByNullifier: AztecAsyncMap<string, string>;
|
|
26
27
|
|
|
27
28
|
#scopes: AztecAsyncMap<string, true>;
|
|
28
29
|
#notesToScope: AztecAsyncMultiMap<string, string>;
|
|
29
30
|
#notesByContractAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
30
31
|
#notesByStorageSlotAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
31
|
-
#notesByTxHashAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
32
|
-
#notesByRecipientAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
33
32
|
|
|
34
33
|
private constructor(store: AztecAsyncKVStore) {
|
|
35
34
|
this.#store = store;
|
|
@@ -41,29 +40,41 @@ export class NoteDataProvider implements DataProvider {
|
|
|
41
40
|
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
42
41
|
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
43
42
|
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
44
|
-
this.#nullifiedNotesByTxHash = store.openMultiMap('nullified_notes_by_tx_hash');
|
|
45
|
-
this.#nullifiedNotesByRecipient = store.openMultiMap('nullified_notes_by_recipient');
|
|
46
43
|
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
47
44
|
|
|
48
45
|
this.#scopes = store.openMap('scopes');
|
|
49
46
|
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
50
47
|
this.#notesByContractAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
51
48
|
this.#notesByStorageSlotAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
52
|
-
this.#notesByTxHashAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
53
|
-
this.#notesByRecipientAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Creates and initializes a new NoteStore instance.
|
|
53
|
+
*
|
|
54
|
+
* This factory method creates a NoteStore and restores any existing
|
|
55
|
+
* scope-specific indexes from the database.
|
|
56
|
+
*
|
|
57
|
+
* @param store - The key-value store to use for persistence
|
|
58
|
+
* @returns Promise resolving to a fully initialized NoteStore instance
|
|
59
|
+
*/
|
|
60
|
+
public static async create(store: AztecAsyncKVStore): Promise<NoteStore> {
|
|
61
|
+
const pxeDB = new NoteStore(store);
|
|
58
62
|
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
59
63
|
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
60
64
|
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
61
|
-
pxeDB.#notesByTxHashAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_tx_hash`));
|
|
62
|
-
pxeDB.#notesByRecipientAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_recipient`));
|
|
63
65
|
}
|
|
64
66
|
return pxeDB;
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Adds a new scope to the note data provider.
|
|
71
|
+
*
|
|
72
|
+
* Scopes provide privacy isolation by creating separate indexes for each user.
|
|
73
|
+
* Each scope gets its own set of indexes for efficient note retrieval by various criteria.
|
|
74
|
+
*
|
|
75
|
+
* @param scope - The AztecAddress representing the scope/user to add
|
|
76
|
+
* @returns Promise resolving to true if scope was added, false if it already existed
|
|
77
|
+
*/
|
|
67
78
|
public async addScope(scope: AztecAddress): Promise<boolean> {
|
|
68
79
|
const scopeString = scope.toString();
|
|
69
80
|
|
|
@@ -74,23 +85,27 @@ export class NoteDataProvider implements DataProvider {
|
|
|
74
85
|
await this.#scopes.set(scopeString, true);
|
|
75
86
|
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
76
87
|
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
77
|
-
this.#notesByTxHashAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_tx_hash`));
|
|
78
|
-
this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`));
|
|
79
88
|
|
|
80
89
|
return true;
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Adds multiple notes to the data provider under the specified scope.
|
|
94
|
+
*
|
|
95
|
+
* Notes are stored using their index from the notes hash tree as the key, which provides
|
|
96
|
+
* uniqueness and maintains creation order. Each note is indexed by multiple criteria
|
|
97
|
+
* for efficient retrieval.
|
|
98
|
+
*
|
|
99
|
+
* @param notes - Notes to store
|
|
100
|
+
* @param scope - The scope (user/account) under which to store the notes
|
|
101
|
+
*/
|
|
102
|
+
addNotes(notes: NoteDao[], scope: AztecAddress): Promise<void> {
|
|
84
103
|
return this.#store.transactionAsync(async () => {
|
|
85
104
|
if (!(await this.#scopes.hasAsync(scope.toString()))) {
|
|
86
105
|
await this.addScope(scope);
|
|
87
106
|
}
|
|
88
107
|
|
|
89
108
|
for (const dao of notes) {
|
|
90
|
-
// store notes by their index in the notes hash tree
|
|
91
|
-
// this provides the uniqueness we need to store individual notes
|
|
92
|
-
// and should also return notes in the order that they were created.
|
|
93
|
-
// Had we stored them by their nullifier, they would be returned in random order
|
|
94
109
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
95
110
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
96
111
|
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
@@ -98,13 +113,34 @@ export class NoteDataProvider implements DataProvider {
|
|
|
98
113
|
|
|
99
114
|
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
100
115
|
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
101
|
-
await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
|
|
102
|
-
await this.#notesByRecipientAndScope.get(scope.toString())!.set(dao.recipient.toString(), noteIndex);
|
|
103
116
|
}
|
|
104
117
|
});
|
|
105
118
|
}
|
|
106
119
|
|
|
107
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Synchronizes notes and nullifiers to a specific block number.
|
|
122
|
+
*
|
|
123
|
+
* This method ensures that the state of notes and nullifiers is consistent with the
|
|
124
|
+
* specified block number. It restores any notes that were nullified after the given block
|
|
125
|
+
* and deletes any active notes created after that block.
|
|
126
|
+
*
|
|
127
|
+
* @param blockNumber - The new chain tip after a reorg
|
|
128
|
+
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
129
|
+
*/
|
|
130
|
+
public async rollbackNotesAndNullifiers(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
131
|
+
await this.#rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber);
|
|
132
|
+
await this.#deleteActiveNotesAfterBlock(blockNumber);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Deletes (removes) all active notes created after the specified block number.
|
|
137
|
+
*
|
|
138
|
+
* Permanently delete notes from the active notes store, e.g. during a reorg.
|
|
139
|
+
* Note: This only affects #notes (active notes), not #nullifiedNotes.
|
|
140
|
+
*
|
|
141
|
+
* @param blockNumber - Notes created after this block number will be deleted
|
|
142
|
+
*/
|
|
143
|
+
#deleteActiveNotesAfterBlock(blockNumber: number): Promise<void> {
|
|
108
144
|
return this.#store.transactionAsync(async () => {
|
|
109
145
|
const notes = await toArray(this.#notes.valuesAsync());
|
|
110
146
|
for (const note of notes) {
|
|
@@ -116,8 +152,6 @@ export class NoteDataProvider implements DataProvider {
|
|
|
116
152
|
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
117
153
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
118
154
|
for (const scope of scopes) {
|
|
119
|
-
await this.#notesByRecipientAndScope.get(scope)!.deleteValue(noteDao.recipient.toString(), noteIndex);
|
|
120
|
-
await this.#notesByTxHashAndScope.get(scope)!.deleteValue(noteDao.txHash.toString(), noteIndex);
|
|
121
155
|
await this.#notesByContractAndScope.get(scope)!.deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
122
156
|
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
123
157
|
}
|
|
@@ -126,12 +160,21 @@ export class NoteDataProvider implements DataProvider {
|
|
|
126
160
|
});
|
|
127
161
|
}
|
|
128
162
|
|
|
129
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Rewinds nullifications after a given block number.
|
|
165
|
+
*
|
|
166
|
+
* This operation "unnullifies" notes, rolling back nullifications that occurred
|
|
167
|
+
* in orphaned blocks, e.g. during a reorg. The notes are restored to the
|
|
168
|
+
* active notes store and removed from the nullified store.
|
|
169
|
+
*
|
|
170
|
+
* @param blockNumber - Revert nullifications that occurred after this block
|
|
171
|
+
* @param synchedBlockNumber - Upper bound for the block range to process
|
|
172
|
+
*/
|
|
173
|
+
async #rewindNullifiersAfterBlock(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
130
174
|
await this.#store.transactionAsync(async () => {
|
|
131
175
|
const nullifiersToUndo: string[] = [];
|
|
132
176
|
const currentBlockNumber = blockNumber + 1;
|
|
133
|
-
|
|
134
|
-
for (let i = currentBlockNumber; i <= maxBlockNumber; i++) {
|
|
177
|
+
for (let i = currentBlockNumber; i <= synchedBlockNumber; i++) {
|
|
135
178
|
nullifiersToUndo.push(...(await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i))));
|
|
136
179
|
}
|
|
137
180
|
const notesIndexesToReinsert = await Promise.all(
|
|
@@ -150,17 +193,17 @@ export class NoteDataProvider implements DataProvider {
|
|
|
150
193
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
151
194
|
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
152
195
|
|
|
153
|
-
|
|
196
|
+
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
154
197
|
|
|
155
198
|
if (scopes.length === 0) {
|
|
156
|
-
|
|
199
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
200
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
201
|
+
throw new Error(`No scopes found for nullified note with index ${noteIndex}`);
|
|
157
202
|
}
|
|
158
203
|
|
|
159
204
|
for (const scope of scopes) {
|
|
160
205
|
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
161
206
|
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
162
|
-
await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
|
|
163
|
-
await this.#notesByRecipientAndScope.get(scope.toString())!.set(dao.recipient.toString(), noteIndex);
|
|
164
207
|
await this.#notesToScope.set(noteIndex, scope);
|
|
165
208
|
}
|
|
166
209
|
|
|
@@ -169,16 +212,33 @@ export class NoteDataProvider implements DataProvider {
|
|
|
169
212
|
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
170
213
|
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
171
214
|
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
172
|
-
await this.#nullifiedNotesByTxHash.deleteValue(dao.txHash.toString(), noteIndex);
|
|
173
|
-
await this.#nullifiedNotesByRecipient.deleteValue(dao.recipient.toString(), noteIndex);
|
|
174
215
|
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
175
216
|
}
|
|
176
217
|
});
|
|
177
218
|
}
|
|
178
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves notes based on the provided filter criteria.
|
|
222
|
+
*
|
|
223
|
+
* This method queries both active and optionally nullified notes based on the filter
|
|
224
|
+
* parameters.
|
|
225
|
+
*
|
|
226
|
+
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
227
|
+
* owner, storageSlot, status, scopes, and siloedNullifier.
|
|
228
|
+
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
229
|
+
* returned once if this is the case)
|
|
230
|
+
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
231
|
+
*/
|
|
179
232
|
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
180
233
|
filter.status = filter.status ?? NoteStatus.ACTIVE;
|
|
181
234
|
|
|
235
|
+
// throw early if scopes is an empty array
|
|
236
|
+
if (filter.scopes !== undefined && filter.scopes.length === 0) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
'Trying to get notes with an empty scopes array. Scopes have to be set to undefined if intending on not filtering by scopes.',
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
182
242
|
const candidateNoteSources = [];
|
|
183
243
|
|
|
184
244
|
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map(addressString =>
|
|
@@ -190,29 +250,19 @@ export class NoteDataProvider implements DataProvider {
|
|
|
190
250
|
for (const scope of new Set(filter.scopes)) {
|
|
191
251
|
const formattedScopeString = scope.toString();
|
|
192
252
|
if (!(await this.#scopes.hasAsync(formattedScopeString))) {
|
|
193
|
-
throw new Error('Trying to get incoming notes of
|
|
253
|
+
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
194
254
|
}
|
|
195
255
|
|
|
196
256
|
activeNoteIdsPerScope.push(
|
|
197
|
-
filter.
|
|
257
|
+
filter.storageSlot
|
|
198
258
|
? await toArray(
|
|
199
|
-
this.#
|
|
259
|
+
this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValuesAsync(filter.storageSlot.toString()),
|
|
200
260
|
)
|
|
201
|
-
:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
? await toArray(
|
|
207
|
-
this.#notesByStorageSlotAndScope
|
|
208
|
-
.get(formattedScopeString)!
|
|
209
|
-
.getValuesAsync(filter.storageSlot.toString()),
|
|
210
|
-
)
|
|
211
|
-
: await toArray(
|
|
212
|
-
this.#notesByContractAndScope
|
|
213
|
-
.get(formattedScopeString)!
|
|
214
|
-
.getValuesAsync(filter.contractAddress.toString()),
|
|
215
|
-
),
|
|
261
|
+
: await toArray(
|
|
262
|
+
this.#notesByContractAndScope
|
|
263
|
+
.get(formattedScopeString)!
|
|
264
|
+
.getValuesAsync(filter.contractAddress.toString()),
|
|
265
|
+
),
|
|
216
266
|
);
|
|
217
267
|
}
|
|
218
268
|
|
|
@@ -221,17 +271,28 @@ export class NoteDataProvider implements DataProvider {
|
|
|
221
271
|
notes: this.#notes,
|
|
222
272
|
});
|
|
223
273
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
274
|
+
// If status is ACTIVE_OR_NULLIFIED we add nullified notes as candidates on top of the default active ones.
|
|
275
|
+
if (filter.status === NoteStatus.ACTIVE_OR_NULLIFIED) {
|
|
276
|
+
const nullifiedIds = filter.storageSlot
|
|
277
|
+
? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString()))
|
|
278
|
+
: await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString()));
|
|
279
|
+
|
|
280
|
+
const setOfScopes = new Set(filter.scopes.map(s => s.toString() as string));
|
|
281
|
+
const filteredNullifiedIds = new Set<string>();
|
|
282
|
+
|
|
283
|
+
for (const noteId of nullifiedIds) {
|
|
284
|
+
const scopeList = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteId));
|
|
285
|
+
if (scopeList.some(scope => setOfScopes.has(scope))) {
|
|
286
|
+
filteredNullifiedIds.add(noteId);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (filteredNullifiedIds.size > 0) {
|
|
291
|
+
candidateNoteSources.push({
|
|
292
|
+
ids: filteredNullifiedIds,
|
|
293
|
+
notes: this.#nullifiedNotes,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
235
296
|
}
|
|
236
297
|
|
|
237
298
|
const result: NoteDao[] = [];
|
|
@@ -247,7 +308,7 @@ export class NoteDataProvider implements DataProvider {
|
|
|
247
308
|
continue;
|
|
248
309
|
}
|
|
249
310
|
|
|
250
|
-
if (filter.
|
|
311
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
251
312
|
continue;
|
|
252
313
|
}
|
|
253
314
|
|
|
@@ -255,10 +316,6 @@ export class NoteDataProvider implements DataProvider {
|
|
|
255
316
|
continue;
|
|
256
317
|
}
|
|
257
318
|
|
|
258
|
-
if (filter.recipient && !note.recipient.equals(filter.recipient)) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
319
|
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
263
320
|
continue;
|
|
264
321
|
}
|
|
@@ -267,10 +324,29 @@ export class NoteDataProvider implements DataProvider {
|
|
|
267
324
|
}
|
|
268
325
|
}
|
|
269
326
|
|
|
270
|
-
|
|
327
|
+
// A note might be present in multiple scopes - we ensure it is only returned once
|
|
328
|
+
const deduplicated: NoteDao[] = [];
|
|
329
|
+
for (const note of result) {
|
|
330
|
+
if (!deduplicated.some(existing => existing.equals(note))) {
|
|
331
|
+
deduplicated.push(note);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return deduplicated;
|
|
271
336
|
}
|
|
272
337
|
|
|
273
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Transitions notes from "active" to "nullified" state.
|
|
340
|
+
*
|
|
341
|
+
* This operation processes a batch of nullifiers to mark the corresponding notes
|
|
342
|
+
* as spent/nullified. The operation is atomic - if any nullifier is not found,
|
|
343
|
+
* the entire operation fails and no notes are modified.
|
|
344
|
+
*
|
|
345
|
+
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
346
|
+
* @returns Promise resolving to array of nullified NoteDao objects
|
|
347
|
+
* @throws Error if any nullifier is not found in the active notes
|
|
348
|
+
*/
|
|
349
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[]): Promise<NoteDao[]> {
|
|
274
350
|
if (nullifiers.length === 0) {
|
|
275
351
|
return Promise.resolve([]);
|
|
276
352
|
}
|
|
@@ -280,22 +356,33 @@ export class NoteDataProvider implements DataProvider {
|
|
|
280
356
|
|
|
281
357
|
for (const blockScopedNullifier of nullifiers) {
|
|
282
358
|
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
283
|
-
const
|
|
359
|
+
const nullifierKey = nullifier.toString();
|
|
360
|
+
|
|
361
|
+
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
284
362
|
if (!noteIndex) {
|
|
285
|
-
|
|
363
|
+
// Check if already nullified?
|
|
364
|
+
const alreadyNullified = await this.#nullifiedNotesByNullifier.getAsync(nullifierKey);
|
|
365
|
+
if (alreadyNullified) {
|
|
366
|
+
throw new Error(`Nullifier already applied in applyNullifiers`);
|
|
367
|
+
}
|
|
368
|
+
throw new Error('Nullifier not found in applyNullifiers');
|
|
286
369
|
}
|
|
287
370
|
|
|
288
371
|
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
289
372
|
|
|
290
373
|
if (!noteBuffer) {
|
|
291
|
-
throw new Error('Note not found in
|
|
374
|
+
throw new Error('Note not found in applyNullifiers');
|
|
292
375
|
}
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
|
|
376
|
+
|
|
377
|
+
const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex));
|
|
378
|
+
if (noteScopes.length === 0) {
|
|
379
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
380
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
381
|
+
throw new Error('Note scopes are missing in applyNullifiers');
|
|
297
382
|
}
|
|
298
383
|
|
|
384
|
+
const note = NoteDao.fromBuffer(noteBuffer);
|
|
385
|
+
|
|
299
386
|
nullifiedNotes.push(note);
|
|
300
387
|
|
|
301
388
|
await this.#notes.delete(noteIndex);
|
|
@@ -304,23 +391,17 @@ export class NoteDataProvider implements DataProvider {
|
|
|
304
391
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
305
392
|
|
|
306
393
|
for (const scope of scopes) {
|
|
307
|
-
await this.#notesByRecipientAndScope.get(scope)!.deleteValue(note.recipient.toString(), noteIndex);
|
|
308
|
-
await this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex);
|
|
309
394
|
await this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
|
|
310
395
|
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
|
|
311
396
|
}
|
|
312
397
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
316
|
-
}
|
|
398
|
+
for (const scope of noteScopes) {
|
|
399
|
+
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
317
400
|
}
|
|
318
401
|
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
319
402
|
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
320
403
|
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
321
404
|
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
322
|
-
await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
|
|
323
|
-
await this.#nullifiedNotesByRecipient.set(note.recipient.toString(), noteIndex);
|
|
324
405
|
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
325
406
|
|
|
326
407
|
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
@@ -328,23 +409,4 @@ export class NoteDataProvider implements DataProvider {
|
|
|
328
409
|
return nullifiedNotes;
|
|
329
410
|
});
|
|
330
411
|
}
|
|
331
|
-
|
|
332
|
-
async getSize() {
|
|
333
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
334
|
-
const contractAddresses = new Set<string>();
|
|
335
|
-
|
|
336
|
-
// Collect all unique contract addresses across all scopes
|
|
337
|
-
for (const scope of scopes) {
|
|
338
|
-
const addresses = await toArray(this.#notesByContractAndScope.get(scope)!.keysAsync());
|
|
339
|
-
addresses.forEach(addr => contractAddresses.add(addr));
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Get all notes for each contract address
|
|
343
|
-
const allNotes = await Promise.all(
|
|
344
|
-
Array.from(contractAddresses).map(addr => this.getNotes({ contractAddress: AztecAddress.fromString(addr) })),
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
// Reduce all notes to get total size
|
|
348
|
-
return allNotes.flat().reduce((sum, note) => sum + note.getSize(), 0);
|
|
349
|
-
}
|
|
350
412
|
}
|