@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +129 -0
- 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} +34 -35
- 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 +11 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -33
- 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 +86 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +331 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +95 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +191 -0
- 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 +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +40 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
- 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 +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- 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 +17 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +345 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +47 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +122 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +231 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +414 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +196 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +374 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
- package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_node.js +27 -0
- 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 +10 -10
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +27 -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 +9 -9
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +26 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +17 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +6 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -3
- package/dest/entrypoints/server/utils.d.ts +8 -16
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +35 -36
- 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} +30 -22
- 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/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -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 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +10 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +64 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +46 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +27 -18
- 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 +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +782 -0
- 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_store/capsule_store.js +146 -0
- 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_store/contract_store.d.ts +67 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +236 -0
- 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_store/private_functions_tree.d.ts +27 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/contract_store/private_functions_tree.js +47 -0
- package/dest/storage/index.d.ts +9 -10
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +8 -9
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- 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_store/note_store.js +322 -0
- 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 +158 -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/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/index.d.ts +16 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +14 -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 +37 -34
- package/src/bin/check_oracle_version.ts +160 -0
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +37 -38
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +27 -55
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +627 -0
- package/src/contract_function_simulator/execution_note_cache.ts +233 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +51 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
- package/src/contract_function_simulator/oracle/oracle.ts +605 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +676 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +536 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
- package/src/contract_function_simulator/proxied_node.ts +33 -0
- 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 +42 -36
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +41 -31
- package/src/entrypoints/pxe_creation_options.ts +13 -0
- package/src/entrypoints/server/index.ts +5 -3
- package/src/entrypoints/server/utils.ts +55 -51
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +40 -39
- package/src/events/event_service.ts +79 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +48 -0
- package/src/job_coordinator/job_coordinator.ts +149 -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 +11 -0
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +159 -148
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +430 -0
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +19 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +40 -30
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +1111 -0
- 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_store/capsule_store.ts +179 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +339 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/contract_store/private_functions_tree.ts +67 -0
- package/src/storage/index.ts +8 -10
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +190 -123
- package/src/storage/private_event_store/private_event_store.ts +216 -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/constants.ts +10 -0
- package/src/tagging/index.ts +18 -0
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +132 -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 +48 -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 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts +0 -45
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/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 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- 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/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -16
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -57
- 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 +0 -109
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -183
- package/dest/storage/contract_data_provider/index.d.ts +0 -3
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -2
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +0 -66
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +0 -99
- 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 -106
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -106
- 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/note_data_provider/note_data_provider.js +0 -249
- 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 -65
- 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 -37
- 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 -38
- package/src/entrypoints/client/pxe_creation_options.ts +0 -7
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -80
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -261
- package/src/storage/contract_data_provider/index.ts +0 -2
- package/src/storage/contract_data_provider/private_functions_tree.ts +0 -131
- 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 -162
- 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 -92
- package/src/synchronizer/index.ts +0 -1
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { NoteStatus } from '@aztec/stdlib/note';
|
|
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 {
|
|
12
|
+
#store;
|
|
13
|
+
#notes;
|
|
14
|
+
#nullifiedNotes;
|
|
15
|
+
#nullifierToNoteId;
|
|
16
|
+
#nullifiersByBlockNumber;
|
|
17
|
+
#nullifiedNotesToScope;
|
|
18
|
+
#nullifiedNotesByContract;
|
|
19
|
+
#nullifiedNotesByStorageSlot;
|
|
20
|
+
#nullifiedNotesByNullifier;
|
|
21
|
+
#scopes;
|
|
22
|
+
#notesToScope;
|
|
23
|
+
#notesByContractAndScope;
|
|
24
|
+
#notesByStorageSlotAndScope;
|
|
25
|
+
constructor(store){
|
|
26
|
+
this.#store = store;
|
|
27
|
+
this.#notes = store.openMap('notes');
|
|
28
|
+
this.#nullifiedNotes = store.openMap('nullified_notes');
|
|
29
|
+
this.#nullifierToNoteId = store.openMap('nullifier_to_note');
|
|
30
|
+
this.#nullifiersByBlockNumber = store.openMultiMap('nullifier_to_block_number');
|
|
31
|
+
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
32
|
+
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
33
|
+
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
34
|
+
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
35
|
+
this.#scopes = store.openMap('scopes');
|
|
36
|
+
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
37
|
+
this.#notesByContractAndScope = new Map();
|
|
38
|
+
this.#notesByStorageSlotAndScope = new Map();
|
|
39
|
+
}
|
|
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);
|
|
50
|
+
for await (const scope of pxeDB.#scopes.keysAsync()){
|
|
51
|
+
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
52
|
+
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
53
|
+
}
|
|
54
|
+
return pxeDB;
|
|
55
|
+
}
|
|
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) {
|
|
65
|
+
const scopeString = scope.toString();
|
|
66
|
+
if (await this.#scopes.hasAsync(scopeString)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
await this.#scopes.set(scopeString, true);
|
|
70
|
+
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
71
|
+
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
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) {
|
|
84
|
+
return this.#store.transactionAsync(async ()=>{
|
|
85
|
+
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
86
|
+
await this.addScope(scope);
|
|
87
|
+
}
|
|
88
|
+
for (const dao of notes){
|
|
89
|
+
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
90
|
+
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
91
|
+
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
92
|
+
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
93
|
+
await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
|
|
94
|
+
await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
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) {
|
|
119
|
+
return this.#store.transactionAsync(async ()=>{
|
|
120
|
+
const notes = await toArray(this.#notes.valuesAsync());
|
|
121
|
+
for (const note of notes){
|
|
122
|
+
const noteDao = NoteDao.fromBuffer(note);
|
|
123
|
+
if (noteDao.l2BlockNumber > blockNumber) {
|
|
124
|
+
const noteIndex = toBufferBE(noteDao.index, 32).toString('hex');
|
|
125
|
+
await this.#notes.delete(noteIndex);
|
|
126
|
+
await this.#notesToScope.delete(noteIndex);
|
|
127
|
+
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
128
|
+
const scopes = await toArray(this.#scopes.keysAsync());
|
|
129
|
+
for (const scope of scopes){
|
|
130
|
+
await this.#notesByContractAndScope.get(scope).deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
131
|
+
await this.#notesByStorageSlotAndScope.get(scope).deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
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) {
|
|
147
|
+
await this.#store.transactionAsync(async ()=>{
|
|
148
|
+
const nullifiersToUndo = [];
|
|
149
|
+
const currentBlockNumber = blockNumber + 1;
|
|
150
|
+
for(let i = currentBlockNumber; i <= synchedBlockNumber; i++){
|
|
151
|
+
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
152
|
+
}
|
|
153
|
+
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
154
|
+
const notNullNoteIndexes = notesIndexesToReinsert.filter((noteIndex)=>noteIndex != undefined);
|
|
155
|
+
const nullifiedNoteBuffers = await Promise.all(notNullNoteIndexes.map((noteIndex)=>this.#nullifiedNotes.getAsync(noteIndex)));
|
|
156
|
+
const noteDaos = nullifiedNoteBuffers.filter((buffer)=>buffer != undefined).map((buffer)=>NoteDao.fromBuffer(buffer));
|
|
157
|
+
for (const dao of noteDaos){
|
|
158
|
+
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
159
|
+
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
160
|
+
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
161
|
+
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
162
|
+
if (scopes.length === 0) {
|
|
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}`);
|
|
166
|
+
}
|
|
167
|
+
for (const scope of scopes){
|
|
168
|
+
await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
|
|
169
|
+
await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
|
|
170
|
+
await this.#notesToScope.set(noteIndex, scope);
|
|
171
|
+
}
|
|
172
|
+
await this.#nullifiedNotes.delete(noteIndex);
|
|
173
|
+
await this.#nullifiedNotesToScope.delete(noteIndex);
|
|
174
|
+
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
175
|
+
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
176
|
+
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
177
|
+
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
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) {
|
|
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
|
+
}
|
|
198
|
+
const candidateNoteSources = [];
|
|
199
|
+
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map((addressString)=>AztecAddress.fromString(addressString));
|
|
200
|
+
const activeNoteIdsPerScope = [];
|
|
201
|
+
for (const scope of new Set(filter.scopes)){
|
|
202
|
+
const formattedScopeString = scope.toString();
|
|
203
|
+
if (!await this.#scopes.hasAsync(formattedScopeString)) {
|
|
204
|
+
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
205
|
+
}
|
|
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())));
|
|
207
|
+
}
|
|
208
|
+
candidateNoteSources.push({
|
|
209
|
+
ids: new Set(activeNoteIdsPerScope.flat()),
|
|
210
|
+
notes: this.#notes
|
|
211
|
+
});
|
|
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
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const result = [];
|
|
231
|
+
for (const { ids, notes } of candidateNoteSources){
|
|
232
|
+
for (const id of ids){
|
|
233
|
+
const serializedNote = await notes.getAsync(id);
|
|
234
|
+
if (!serializedNote) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const note = NoteDao.fromBuffer(serializedNote);
|
|
238
|
+
if (!note.contractAddress.equals(filter.contractAddress)) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot)) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
result.push(note);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
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;
|
|
261
|
+
}
|
|
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) {
|
|
273
|
+
if (nullifiers.length === 0) {
|
|
274
|
+
return Promise.resolve([]);
|
|
275
|
+
}
|
|
276
|
+
return this.#store.transactionAsync(async ()=>{
|
|
277
|
+
const nullifiedNotes = [];
|
|
278
|
+
for (const blockScopedNullifier of nullifiers){
|
|
279
|
+
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
280
|
+
const nullifierKey = nullifier.toString();
|
|
281
|
+
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
282
|
+
if (!noteIndex) {
|
|
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');
|
|
289
|
+
}
|
|
290
|
+
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
291
|
+
if (!noteBuffer) {
|
|
292
|
+
throw new Error('Note not found in applyNullifiers');
|
|
293
|
+
}
|
|
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');
|
|
299
|
+
}
|
|
300
|
+
const note = NoteDao.fromBuffer(noteBuffer);
|
|
301
|
+
nullifiedNotes.push(note);
|
|
302
|
+
await this.#notes.delete(noteIndex);
|
|
303
|
+
await this.#notesToScope.delete(noteIndex);
|
|
304
|
+
const scopes = await toArray(this.#scopes.keysAsync());
|
|
305
|
+
for (const scope of scopes){
|
|
306
|
+
await this.#notesByContractAndScope.get(scope).deleteValue(note.contractAddress.toString(), noteIndex);
|
|
307
|
+
await this.#notesByStorageSlotAndScope.get(scope).deleteValue(note.storageSlot.toString(), noteIndex);
|
|
308
|
+
}
|
|
309
|
+
for (const scope of noteScopes){
|
|
310
|
+
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
311
|
+
}
|
|
312
|
+
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
313
|
+
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
314
|
+
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
315
|
+
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
316
|
+
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
317
|
+
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
318
|
+
}
|
|
319
|
+
return nullifiedNotes;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
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, randomness: Fr, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9ldmVudF9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvcHJpdmF0ZV9ldmVudF9zdG9yZS9wcml2YXRlX2V2ZW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUdwRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRSxPQUFPLEVBQUUsS0FBSyxJQUFJLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFdkQsTUFBTSxNQUFNLHVCQUF1QixHQUFHO0lBQ3BDLGVBQWUsRUFBRSxZQUFZLENBQUM7SUFDOUIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixPQUFPLEVBQUUsTUFBTSxDQUFDO0lBQ2hCLE1BQU0sRUFBRSxZQUFZLEVBQUUsQ0FBQztJQUN2QixNQUFNLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDakIsQ0FBQztBQWFGLEtBQUssb0JBQW9CLEdBQUcsSUFBSSxHQUFHO0lBQ2pDLGVBQWUsRUFBRSxZQUFZLENBQUM7SUFDOUIsS0FBSyxFQUFFLFlBQVksQ0FBQztDQUNyQixDQUFDO0FBRUY7O0dBRUc7QUFDSCxxQkFBYSxpQkFBaUI7O0lBVzVCLE1BQU0seUNBQXVDO0lBRTdDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQU1uQztJQU1EOzs7Ozs7Ozs7O09BVUc7SUFDSCxvQkFBb0IsQ0FDbEIsYUFBYSxFQUFFLGFBQWEsRUFDNUIsVUFBVSxFQUFFLEVBQUUsRUFDZCxVQUFVLEVBQUUsRUFBRSxFQUFFLEVBQ2hCLG9CQUFvQixFQUFFLE1BQU0sRUFDNUIsUUFBUSxFQUFFLG9CQUFvQixHQUM3QixPQUFPLENBQUMsSUFBSSxDQUFDLENBa0NmO0lBRUQ7Ozs7Ozs7Ozs7T0FVRztJQUNVLGdCQUFnQixDQUMzQixhQUFhLEVBQUUsYUFBYSxFQUM1QixNQUFNLEVBQUUsdUJBQXVCLEdBQzlCLE9BQU8sQ0FBQyxrQkFBa0IsRUFBRSxDQUFDLENBd0MvQjtJQUVEOzs7T0FHRztJQUNVLHdCQUF3QixDQUFDLFdBQVcsRUFBRSxNQUFNLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FxQ3BHO0NBQ0YifQ==
|
|
@@ -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;AAaF,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,EACd,UAAU,EAAE,EAAE,EAAE,EAChB,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAkCf;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,158 @@
|
|
|
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, randomness, 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
|
+
randomness,
|
|
57
|
+
msgContent: serializeToBuffer(msgContent),
|
|
58
|
+
l2BlockNumber,
|
|
59
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
60
|
+
eventCommitmentIndex,
|
|
61
|
+
txHash: txHash.toBuffer(),
|
|
62
|
+
lookupKey: key
|
|
63
|
+
});
|
|
64
|
+
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(key) || [];
|
|
65
|
+
await this.#eventsByContractScopeSelector.set(key, [
|
|
66
|
+
...existingIndices,
|
|
67
|
+
eventCommitmentIndex
|
|
68
|
+
]);
|
|
69
|
+
const existingBlockIndices = await this.#eventsByBlockNumber.getAsync(l2BlockNumber) || [];
|
|
70
|
+
await this.#eventsByBlockNumber.set(l2BlockNumber, [
|
|
71
|
+
...existingBlockIndices,
|
|
72
|
+
eventCommitmentIndex
|
|
73
|
+
]);
|
|
74
|
+
// Mark this log as seen using eventCommitmentIndex
|
|
75
|
+
await this.#seenLogs.set(eventCommitmentIndex, true);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns the private events given search parameters.
|
|
80
|
+
* @param eventSelector - The event selector to filter by.
|
|
81
|
+
* @param filter - Filtering criteria:
|
|
82
|
+
* contractAddress: The address of the contract to get events from.
|
|
83
|
+
* fromBlock: The block number to search from (inclusive).
|
|
84
|
+
* toBlock: The block number to search upto (exclusive).
|
|
85
|
+
* scope: - The addresses that decrypted the logs.
|
|
86
|
+
* @returns - The event log contents, augmented with metadata about
|
|
87
|
+
* the transaction and block it the event was included in .
|
|
88
|
+
*/ async getPrivateEvents(eventSelector, filter) {
|
|
89
|
+
const events = [];
|
|
90
|
+
for (const scope of filter.scopes){
|
|
91
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
92
|
+
const eventCommitmentIndices = await this.#eventsByContractScopeSelector.getAsync(key) || [];
|
|
93
|
+
for (const eventCommitmentIndex of eventCommitmentIndices){
|
|
94
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
95
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// Convert buffer back to Fr array
|
|
99
|
+
const reader = BufferReader.asReader(entry.msgContent);
|
|
100
|
+
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
101
|
+
const msgContent = reader.readArray(numFields, Fr);
|
|
102
|
+
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
103
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
104
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
events.push({
|
|
108
|
+
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
109
|
+
event: {
|
|
110
|
+
packedEvent: msgContent,
|
|
111
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
112
|
+
txHash,
|
|
113
|
+
l2BlockHash,
|
|
114
|
+
eventSelector
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Sort by eventCommitmentIndex only
|
|
120
|
+
events.sort((a, b)=>a.eventCommitmentIndex - b.eventCommitmentIndex);
|
|
121
|
+
return events.map((ev)=>ev.event);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
125
|
+
* number up to which PXE managed to sync before the reorg happened).
|
|
126
|
+
*/ async rollbackEventsAfterBlock(blockNumber, synchedBlockNumber) {
|
|
127
|
+
await this.#store.transactionAsync(async ()=>{
|
|
128
|
+
let removedCount = 0;
|
|
129
|
+
for(let block = blockNumber + 1; block <= synchedBlockNumber; block++){
|
|
130
|
+
const indices = await this.#eventsByBlockNumber.getAsync(block);
|
|
131
|
+
if (indices) {
|
|
132
|
+
await this.#eventsByBlockNumber.delete(block);
|
|
133
|
+
for (const eventCommitmentIndex of indices){
|
|
134
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
135
|
+
if (!entry) {
|
|
136
|
+
throw new Error(`Event log not found for eventCommitmentIndex ${eventCommitmentIndex}`);
|
|
137
|
+
}
|
|
138
|
+
await this.#eventLogs.delete(eventCommitmentIndex);
|
|
139
|
+
await this.#seenLogs.delete(eventCommitmentIndex);
|
|
140
|
+
// Update #eventsByContractScopeSelector using the stored lookupKey
|
|
141
|
+
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(entry.lookupKey);
|
|
142
|
+
if (!existingIndices || existingIndices.length === 0) {
|
|
143
|
+
throw new Error(`No indices found in #eventsByContractScopeSelector for key ${entry.lookupKey}`);
|
|
144
|
+
}
|
|
145
|
+
const filteredIndices = existingIndices.filter((idx)=>idx !== eventCommitmentIndex);
|
|
146
|
+
if (filteredIndices.length === 0) {
|
|
147
|
+
await this.#eventsByContractScopeSelector.delete(entry.lookupKey);
|
|
148
|
+
} else {
|
|
149
|
+
await this.#eventsByContractScopeSelector.set(entry.lookupKey, filteredIndices);
|
|
150
|
+
}
|
|
151
|
+
removedCount++;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -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==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE;;;;;;;;;GASG;AACH,qBAAa,qBAAqB;;IAMhC,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,mBAAmB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEpF;IAEK,sBAAsB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9F;IAED,wBAAwB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEzF;IAEK,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnG;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
3
|
+
* is called SenderTaggingStore. We have the providers separate for the sender and recipient because
|
|
4
|
+
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
5
|
+
*
|
|
6
|
+
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
7
|
+
* blocks, which by definition cannot be affected by reorgs.
|
|
8
|
+
*
|
|
9
|
+
* TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
|
|
10
|
+
*/ export class RecipientTaggingStore {
|
|
11
|
+
#store;
|
|
12
|
+
#highestAgedIndex;
|
|
13
|
+
#highestFinalizedIndex;
|
|
14
|
+
constructor(store){
|
|
15
|
+
this.#store = store;
|
|
16
|
+
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
17
|
+
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
18
|
+
}
|
|
19
|
+
getHighestAgedIndex(secret) {
|
|
20
|
+
return this.#highestAgedIndex.getAsync(secret.toString());
|
|
21
|
+
}
|
|
22
|
+
async updateHighestAgedIndex(secret, index) {
|
|
23
|
+
const currentIndex = await this.#highestAgedIndex.getAsync(secret.toString());
|
|
24
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
25
|
+
// Log sync should never set a lower highest aged index.
|
|
26
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
27
|
+
}
|
|
28
|
+
await this.#highestAgedIndex.set(secret.toString(), index);
|
|
29
|
+
}
|
|
30
|
+
getHighestFinalizedIndex(secret) {
|
|
31
|
+
return this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
32
|
+
}
|
|
33
|
+
async updateHighestFinalizedIndex(secret, index) {
|
|
34
|
+
const currentIndex = await this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
35
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
36
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
37
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
38
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
39
|
+
}
|
|
40
|
+
await this.#highestFinalizedIndex.set(secret.toString(), index);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
/**
|
|
4
|
+
* Stores sender addresses. During recipient log synchronization, these senders are used, along with a given recipient,
|
|
5
|
+
* to derive directional app tagging secrets that are then used to sync the logs.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SenderAddressBookStore {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(store: AztecAsyncKVStore);
|
|
10
|
+
addSender(address: AztecAddress): Promise<boolean>;
|
|
11
|
+
getSenders(): Promise<AztecAddress[]>;
|
|
12
|
+
removeSender(address: AztecAddress): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX2FkZHJlc3NfYm9va19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvdGFnZ2luZ19zdG9yZS9zZW5kZXJfYWRkcmVzc19ib29rX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRDs7O0dBR0c7QUFDSCxxQkFBYSxzQkFBc0I7O0lBSWpDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUluQztJQUVLLFNBQVMsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FRdkQ7SUFFSyxVQUFVLElBQUksT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBRTFDO0lBRUssWUFBWSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVExRDtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;IAEK,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvD;IAEK,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAE1C;IAEK,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ1D;CACF"}
|