@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +14 -10
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -32
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +28 -27
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +56 -40
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +43 -32
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -26
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +28 -41
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +44 -34
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +92 -92
- 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 +5 -5
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +6 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +8 -7
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +8 -7
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +22 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -6
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- 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 +15 -31
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +77 -188
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +40 -44
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +17 -44
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +131 -147
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/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/{anchor_block_data_provider/anchor_block_data_provider.js → anchor_block_store/anchor_block_store.js} +1 -1
- 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 +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +255 -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_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +3 -3
- 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} +2 -2
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +73 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +303 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -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 +250 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -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 +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +99 -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_data_provider/sender_tagging_data_provider.d.ts → tagging_store/sender_tagging_store.d.ts} +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.js → tagging_store/sender_tagging_store.js} +111 -29
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -3
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +15 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +14 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.d.ts +4 -4
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +8 -23
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.d.ts +7 -4
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.js +12 -7
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +83 -34
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +79 -64
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -10
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +56 -41
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +77 -78
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +121 -105
- package/src/contract_function_simulator/proxied_contract_data_source.ts +7 -7
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +7 -6
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +23 -27
- package/src/events/private_event_filter_validator.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +116 -260
- package/src/notes/note_service.ts +43 -46
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +189 -190
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +1 -1
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +2 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +381 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +363 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +129 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/{tagging_data_provider/sender_tagging_data_provider.ts → tagging_store/sender_tagging_store.ts} +129 -28
- package/src/tagging/constants.ts +10 -3
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +17 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +23 -9
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.ts +12 -25
- package/src/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.ts +19 -7
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
- package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -57
- 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 -146
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
- 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 -322
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
- 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 -115
- package/dest/storage/tagging_data_provider/index.d.ts +0 -3
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -2
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +0 -42
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -25
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/anchor_block_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -179
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_data_provider.ts +0 -412
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
- package/src/storage/tagging_data_provider/index.ts +0 -2
- package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
- package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +0 -53
- package/src/tagging/utils.ts +0 -32
- package/src/tree_membership/tree_membership_service.ts +0 -112
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
|
|
6
|
-
export class CapsuleDataProvider {
|
|
7
|
-
#store: AztecAsyncKVStore;
|
|
8
|
-
|
|
9
|
-
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
10
|
-
#capsules: AztecAsyncMap<string, Buffer>;
|
|
11
|
-
|
|
12
|
-
logger: Logger;
|
|
13
|
-
|
|
14
|
-
constructor(store: AztecAsyncKVStore) {
|
|
15
|
-
this.#store = store;
|
|
16
|
-
|
|
17
|
-
this.#capsules = this.#store.openMap('capsules');
|
|
18
|
-
|
|
19
|
-
this.logger = createLogger('pxe:capsule-data-provider');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
24
|
-
* * If data was already stored at this slot, it is overwritten.
|
|
25
|
-
* @param contractAddress - The contract address to scope the data under.
|
|
26
|
-
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
27
|
-
* @param capsule - An array of field elements representing the capsule.
|
|
28
|
-
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
29
|
-
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
30
|
-
* network state it's backed by local PXE db.
|
|
31
|
-
*/
|
|
32
|
-
async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
33
|
-
await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map(value => value.toBuffer())));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
38
|
-
* @param contractAddress - The contract address under which the data is scoped.
|
|
39
|
-
* @param slot - The slot in the database to read.
|
|
40
|
-
* @returns The stored data or `null` if no data is stored under the slot.
|
|
41
|
-
*/
|
|
42
|
-
async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
|
|
43
|
-
const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
|
|
44
|
-
if (!dataBuffer) {
|
|
45
|
-
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const capsule: Fr[] = [];
|
|
49
|
-
for (let i = 0; i < dataBuffer.length; i += Fr.SIZE_IN_BYTES) {
|
|
50
|
-
capsule.push(Fr.fromBuffer(dataBuffer.subarray(i, i + Fr.SIZE_IN_BYTES)));
|
|
51
|
-
}
|
|
52
|
-
return capsule;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
57
|
-
* @param contractAddress - The contract address under which the data is scoped.
|
|
58
|
-
* @param slot - The slot in the database to delete.
|
|
59
|
-
*/
|
|
60
|
-
async deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
|
|
61
|
-
await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
66
|
-
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
67
|
-
* Supports overlapping source and destination regions (which will result in the overlapped source values being
|
|
68
|
-
* overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
|
|
69
|
-
*
|
|
70
|
-
* @param contractAddress - The contract address under which the data is scoped.
|
|
71
|
-
* @param srcSlot - The first slot to copy from.
|
|
72
|
-
* @param dstSlot - The first slot to copy to.
|
|
73
|
-
* @param numEntries - The number of entries to copy.
|
|
74
|
-
*/
|
|
75
|
-
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
|
|
76
|
-
return this.#store.transactionAsync(async () => {
|
|
77
|
-
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
78
|
-
// and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
|
|
79
|
-
// indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
|
|
80
|
-
// indexes to avoid reading elements that've been overwritten.
|
|
81
|
-
|
|
82
|
-
const indexes = Array.from(Array(numEntries).keys());
|
|
83
|
-
if (srcSlot.lt(dstSlot)) {
|
|
84
|
-
indexes.reverse();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
for (const i of indexes) {
|
|
88
|
-
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
89
|
-
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
90
|
-
|
|
91
|
-
const toCopy = await this.#capsules.getAsync(currentSrcSlot);
|
|
92
|
-
if (!toCopy) {
|
|
93
|
-
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
await this.#capsules.set(currentDstSlot, toCopy);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
103
|
-
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
104
|
-
* All operations are performed in a single transaction.
|
|
105
|
-
* @param contractAddress - The contract address that owns the capsule array
|
|
106
|
-
* @param baseSlot - The slot where the array length is stored
|
|
107
|
-
* @param content - Array of capsule data to append
|
|
108
|
-
*/
|
|
109
|
-
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void> {
|
|
110
|
-
return this.#store.transactionAsync(async () => {
|
|
111
|
-
// Load current length, defaulting to 0 if not found
|
|
112
|
-
const lengthData = await this.loadCapsule(contractAddress, baseSlot);
|
|
113
|
-
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
114
|
-
|
|
115
|
-
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
116
|
-
for (let i = 0; i < content.length; i++) {
|
|
117
|
-
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
118
|
-
await this.storeCapsule(contractAddress, nextSlot, content[i]);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Update length to include all new capsules
|
|
122
|
-
const newLength = currentLength + content.length;
|
|
123
|
-
await this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)]);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]> {
|
|
128
|
-
return this.#store.transactionAsync(async () => {
|
|
129
|
-
// Load length, defaulting to 0 if not found
|
|
130
|
-
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
131
|
-
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
132
|
-
|
|
133
|
-
const values: Fr[][] = [];
|
|
134
|
-
|
|
135
|
-
// Read each capsule at consecutive slots after baseSlot
|
|
136
|
-
for (let i = 0; i < length; i++) {
|
|
137
|
-
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
138
|
-
if (currentValue == undefined) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
values.push(currentValue);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return values;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]) {
|
|
152
|
-
return this.#store.transactionAsync(async () => {
|
|
153
|
-
// Load current length, defaulting to 0 if not found
|
|
154
|
-
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
155
|
-
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
156
|
-
|
|
157
|
-
// Set the new length
|
|
158
|
-
await this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)]);
|
|
159
|
-
|
|
160
|
-
// Store the new content, possibly overwriting existing values
|
|
161
|
-
for (let i = 0; i < content.length; i++) {
|
|
162
|
-
await this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i]);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Clear any stragglers
|
|
166
|
-
for (let i = content.length; i < originalLength; i++) {
|
|
167
|
-
await this.deleteCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
|
|
174
|
-
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function arraySlot(baseSlot: Fr, index: number) {
|
|
178
|
-
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
179
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CapsuleDataProvider } from './capsule_data_provider.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ContractDataProvider } from './contract_data_provider.js';
|
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
4
|
-
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
7
|
-
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
8
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* NoteDataProvider 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 NoteDataProvider {
|
|
17
|
-
#store: AztecAsyncKVStore;
|
|
18
|
-
#notes: AztecAsyncMap<string, Buffer>;
|
|
19
|
-
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
20
|
-
#nullifierToNoteId: AztecAsyncMap<string, string>;
|
|
21
|
-
#nullifiersByBlockNumber: AztecAsyncMultiMap<number, string>;
|
|
22
|
-
|
|
23
|
-
#nullifiedNotesToScope: AztecAsyncMultiMap<string, string>;
|
|
24
|
-
#nullifiedNotesByContract: AztecAsyncMultiMap<string, string>;
|
|
25
|
-
#nullifiedNotesByStorageSlot: AztecAsyncMultiMap<string, string>;
|
|
26
|
-
#nullifiedNotesByNullifier: AztecAsyncMap<string, string>;
|
|
27
|
-
|
|
28
|
-
#scopes: AztecAsyncMap<string, true>;
|
|
29
|
-
#notesToScope: AztecAsyncMultiMap<string, string>;
|
|
30
|
-
#notesByContractAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
31
|
-
#notesByStorageSlotAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
32
|
-
|
|
33
|
-
private constructor(store: AztecAsyncKVStore) {
|
|
34
|
-
this.#store = store;
|
|
35
|
-
this.#notes = store.openMap('notes');
|
|
36
|
-
this.#nullifiedNotes = store.openMap('nullified_notes');
|
|
37
|
-
this.#nullifierToNoteId = store.openMap('nullifier_to_note');
|
|
38
|
-
this.#nullifiersByBlockNumber = store.openMultiMap('nullifier_to_block_number');
|
|
39
|
-
|
|
40
|
-
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
41
|
-
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
42
|
-
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
43
|
-
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
44
|
-
|
|
45
|
-
this.#scopes = store.openMap('scopes');
|
|
46
|
-
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
47
|
-
this.#notesByContractAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
48
|
-
this.#notesByStorageSlotAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates and initializes a new NoteDataProvider instance.
|
|
53
|
-
*
|
|
54
|
-
* This factory method creates a NoteDataProvider 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 NoteDataProvider instance
|
|
59
|
-
*/
|
|
60
|
-
public static async create(store: AztecAsyncKVStore): Promise<NoteDataProvider> {
|
|
61
|
-
const pxeDB = new NoteDataProvider(store);
|
|
62
|
-
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
63
|
-
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
64
|
-
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
65
|
-
}
|
|
66
|
-
return pxeDB;
|
|
67
|
-
}
|
|
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
|
-
*/
|
|
78
|
-
public async addScope(scope: AztecAddress): Promise<boolean> {
|
|
79
|
-
const scopeString = scope.toString();
|
|
80
|
-
|
|
81
|
-
if (await this.#scopes.hasAsync(scopeString)) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
await this.#scopes.set(scopeString, true);
|
|
86
|
-
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
87
|
-
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
88
|
-
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
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> {
|
|
103
|
-
return this.#store.transactionAsync(async () => {
|
|
104
|
-
if (!(await this.#scopes.hasAsync(scope.toString()))) {
|
|
105
|
-
await this.addScope(scope);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
for (const dao of notes) {
|
|
109
|
-
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
110
|
-
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
111
|
-
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
112
|
-
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
113
|
-
|
|
114
|
-
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
115
|
-
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
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> {
|
|
144
|
-
return this.#store.transactionAsync(async () => {
|
|
145
|
-
const notes = await toArray(this.#notes.valuesAsync());
|
|
146
|
-
for (const note of notes) {
|
|
147
|
-
const noteDao = NoteDao.fromBuffer(note);
|
|
148
|
-
if (noteDao.l2BlockNumber > blockNumber) {
|
|
149
|
-
const noteIndex = toBufferBE(noteDao.index, 32).toString('hex');
|
|
150
|
-
await this.#notes.delete(noteIndex);
|
|
151
|
-
await this.#notesToScope.delete(noteIndex);
|
|
152
|
-
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
153
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
154
|
-
for (const scope of scopes) {
|
|
155
|
-
await this.#notesByContractAndScope.get(scope)!.deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
156
|
-
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
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> {
|
|
174
|
-
await this.#store.transactionAsync(async () => {
|
|
175
|
-
const nullifiersToUndo: string[] = [];
|
|
176
|
-
const currentBlockNumber = blockNumber + 1;
|
|
177
|
-
for (let i = currentBlockNumber; i <= synchedBlockNumber; i++) {
|
|
178
|
-
nullifiersToUndo.push(...(await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i))));
|
|
179
|
-
}
|
|
180
|
-
const notesIndexesToReinsert = await Promise.all(
|
|
181
|
-
nullifiersToUndo.map(nullifier => this.#nullifiedNotesByNullifier.getAsync(nullifier)),
|
|
182
|
-
);
|
|
183
|
-
const notNullNoteIndexes = notesIndexesToReinsert.filter(noteIndex => noteIndex != undefined);
|
|
184
|
-
const nullifiedNoteBuffers = await Promise.all(
|
|
185
|
-
notNullNoteIndexes.map(noteIndex => this.#nullifiedNotes.getAsync(noteIndex!)),
|
|
186
|
-
);
|
|
187
|
-
const noteDaos = nullifiedNoteBuffers
|
|
188
|
-
.filter(buffer => buffer != undefined)
|
|
189
|
-
.map(buffer => NoteDao.fromBuffer(buffer!));
|
|
190
|
-
|
|
191
|
-
for (const dao of noteDaos) {
|
|
192
|
-
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
193
|
-
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
194
|
-
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
195
|
-
|
|
196
|
-
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
197
|
-
|
|
198
|
-
if (scopes.length === 0) {
|
|
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}`);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
for (const scope of scopes) {
|
|
205
|
-
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
206
|
-
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
207
|
-
await this.#notesToScope.set(noteIndex, scope);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
await this.#nullifiedNotes.delete(noteIndex);
|
|
211
|
-
await this.#nullifiedNotesToScope.delete(noteIndex);
|
|
212
|
-
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
213
|
-
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
214
|
-
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
215
|
-
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
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
|
-
*/
|
|
232
|
-
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
233
|
-
filter.status = filter.status ?? NoteStatus.ACTIVE;
|
|
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
|
-
|
|
242
|
-
const candidateNoteSources = [];
|
|
243
|
-
|
|
244
|
-
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map(addressString =>
|
|
245
|
-
AztecAddress.fromString(addressString),
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
const activeNoteIdsPerScope: string[][] = [];
|
|
249
|
-
|
|
250
|
-
for (const scope of new Set(filter.scopes)) {
|
|
251
|
-
const formattedScopeString = scope.toString();
|
|
252
|
-
if (!(await this.#scopes.hasAsync(formattedScopeString))) {
|
|
253
|
-
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
activeNoteIdsPerScope.push(
|
|
257
|
-
filter.storageSlot
|
|
258
|
-
? await toArray(
|
|
259
|
-
this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValuesAsync(filter.storageSlot.toString()),
|
|
260
|
-
)
|
|
261
|
-
: await toArray(
|
|
262
|
-
this.#notesByContractAndScope
|
|
263
|
-
.get(formattedScopeString)!
|
|
264
|
-
.getValuesAsync(filter.contractAddress.toString()),
|
|
265
|
-
),
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
candidateNoteSources.push({
|
|
270
|
-
ids: new Set(activeNoteIdsPerScope.flat()),
|
|
271
|
-
notes: this.#notes,
|
|
272
|
-
});
|
|
273
|
-
|
|
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
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const result: NoteDao[] = [];
|
|
299
|
-
for (const { ids, notes } of candidateNoteSources) {
|
|
300
|
-
for (const id of ids) {
|
|
301
|
-
const serializedNote = await notes.getAsync(id);
|
|
302
|
-
if (!serializedNote) {
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const note = NoteDao.fromBuffer(serializedNote);
|
|
307
|
-
if (!note.contractAddress.equals(filter.contractAddress)) {
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) {
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
result.push(note);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
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;
|
|
336
|
-
}
|
|
337
|
-
|
|
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[]> {
|
|
350
|
-
if (nullifiers.length === 0) {
|
|
351
|
-
return Promise.resolve([]);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return this.#store.transactionAsync(async () => {
|
|
355
|
-
const nullifiedNotes: NoteDao[] = [];
|
|
356
|
-
|
|
357
|
-
for (const blockScopedNullifier of nullifiers) {
|
|
358
|
-
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
359
|
-
const nullifierKey = nullifier.toString();
|
|
360
|
-
|
|
361
|
-
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
362
|
-
if (!noteIndex) {
|
|
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');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
372
|
-
|
|
373
|
-
if (!noteBuffer) {
|
|
374
|
-
throw new Error('Note not found in applyNullifiers');
|
|
375
|
-
}
|
|
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');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const note = NoteDao.fromBuffer(noteBuffer);
|
|
385
|
-
|
|
386
|
-
nullifiedNotes.push(note);
|
|
387
|
-
|
|
388
|
-
await this.#notes.delete(noteIndex);
|
|
389
|
-
await this.#notesToScope.delete(noteIndex);
|
|
390
|
-
|
|
391
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
392
|
-
|
|
393
|
-
for (const scope of scopes) {
|
|
394
|
-
await this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
|
|
395
|
-
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
for (const scope of noteScopes) {
|
|
399
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
400
|
-
}
|
|
401
|
-
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
402
|
-
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
403
|
-
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
404
|
-
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
405
|
-
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
406
|
-
|
|
407
|
-
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
408
|
-
}
|
|
409
|
-
return nullifiedNotes;
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|