@aztec/pxe 0.0.1-commit.9593d84 → 0.0.1-commit.96bb3f7
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 +105 -15
- 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} +24 -23
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +4 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +42 -12
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +50 -19
- package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -3
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +4 -3
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/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 +5 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -13
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +7 -3
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +7 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +27 -15
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +9 -10
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +13 -14
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +27 -27
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +32 -46
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +59 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +149 -40
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +12 -3
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +12 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +12 -8
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +47 -0
- package/dest/events/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 +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +2 -2
- 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 +7 -8
- package/dest/private_kernel/private_kernel_oracle.d.ts +5 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +8 -7
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +9 -10
- 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 +39 -46
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +165 -154
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.d.ts → anchor_block_store/anchor_block_store.d.ts} +2 -3
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -6
- 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} +8 -5
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -3
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +13 -12
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +20 -9
- 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 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -2
- package/dest/tagging/index.d.ts +15 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +14 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +20 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +32 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +55 -0
- package/dest/tree_membership/tree_membership_service.d.ts +52 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +84 -0
- package/package.json +17 -17
- package/src/bin/check_oracle_version.ts +130 -20
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +23 -23
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +3 -3
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +93 -19
- package/src/contract_function_simulator/execution_note_cache.ts +7 -3
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +5 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +15 -10
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +17 -3
- package/src/contract_function_simulator/oracle/oracle.ts +33 -11
- package/src/contract_function_simulator/oracle/private_execution.ts +17 -17
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +101 -58
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +225 -47
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/debug/pxe_debug_utils.ts +48 -0
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +9 -3
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +9 -4
- package/src/entrypoints/pxe_creation_options.ts +4 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +12 -16
- package/src/error_enriching.ts +7 -15
- 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 +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +2 -3
- package/src/private_kernel/private_kernel_execution_prover.ts +7 -8
- package/src/private_kernel/private_kernel_oracle.ts +4 -2
- package/src/private_kernel/private_kernel_oracle_impl.ts +12 -17
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +214 -188
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -11
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +34 -2
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +65 -3
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +26 -13
- 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 -2
- package/src/tagging/index.ts +17 -5
- 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/contract_function_simulator/execution_data_provider.d.ts +0 -265
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -122
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -694
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -105
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -35
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -333
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1008
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -143
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
|
@@ -3,7 +3,7 @@ import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/k
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
|
|
6
|
-
export class
|
|
6
|
+
export class AddressStore {
|
|
7
7
|
#store: AztecAsyncKVStore;
|
|
8
8
|
#completeAddresses: AztecAsyncArray<Buffer>;
|
|
9
9
|
#completeAddressIndex: AztecAsyncMap<string, number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AddressStore } from './address_store.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
2
2
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class AnchorBlockStore {
|
|
5
5
|
#store: AztecAsyncKVStore;
|
|
6
6
|
#synchronizedHeader: AztecAsyncSingleton<Buffer>;
|
|
7
7
|
|
|
@@ -14,19 +14,10 @@ export class SyncDataProvider {
|
|
|
14
14
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async getBlockNumber(): Promise<number> {
|
|
18
|
-
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
19
|
-
if (!headerBuffer) {
|
|
20
|
-
throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return BlockHeader.fromBuffer(headerBuffer).globalVariables.blockNumber;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
17
|
async getBlockHeader(): Promise<BlockHeader> {
|
|
27
18
|
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
28
19
|
if (!headerBuffer) {
|
|
29
|
-
throw new Error(`
|
|
20
|
+
throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
|
|
30
21
|
}
|
|
31
22
|
|
|
32
23
|
return BlockHeader.fromBuffer(headerBuffer);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnchorBlockStore } from './anchor_block_store.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
|
|
6
|
-
export class
|
|
6
|
+
export class CapsuleStore {
|
|
7
7
|
#store: AztecAsyncKVStore;
|
|
8
8
|
|
|
9
9
|
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
@@ -19,10 +19,26 @@ export class CapsuleDataProvider {
|
|
|
19
19
|
this.logger = createLogger('pxe:capsule-data-provider');
|
|
20
20
|
}
|
|
21
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
|
+
*/
|
|
22
32
|
async storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
23
33
|
await this.#capsules.set(dbSlotToKey(contractAddress, slot), Buffer.concat(capsule.map(value => value.toBuffer())));
|
|
24
34
|
}
|
|
25
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
|
+
*/
|
|
26
42
|
async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
|
|
27
43
|
const dataBuffer = await this.#capsules.getAsync(dbSlotToKey(contractAddress, slot));
|
|
28
44
|
if (!dataBuffer) {
|
|
@@ -36,10 +52,26 @@ export class CapsuleDataProvider {
|
|
|
36
52
|
return capsule;
|
|
37
53
|
}
|
|
38
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
|
+
*/
|
|
39
60
|
async deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
|
|
40
61
|
await this.#capsules.delete(dbSlotToKey(contractAddress, slot));
|
|
41
62
|
}
|
|
42
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
|
+
*/
|
|
43
75
|
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
|
|
44
76
|
return this.#store.transactionAsync(async () => {
|
|
45
77
|
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CapsuleStore } from './capsule_store.js';
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
|
+
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
6
7
|
import {
|
|
7
8
|
type ContractArtifact,
|
|
8
9
|
type FunctionAbi,
|
|
9
10
|
type FunctionArtifact,
|
|
10
11
|
type FunctionArtifactWithContractName,
|
|
12
|
+
FunctionCall,
|
|
11
13
|
type FunctionDebugMetadata,
|
|
12
14
|
FunctionSelector,
|
|
13
15
|
FunctionType,
|
|
14
16
|
contractArtifactFromBuffer,
|
|
15
17
|
contractArtifactToBuffer,
|
|
18
|
+
encodeArguments,
|
|
16
19
|
getFunctionDebugMetadata,
|
|
17
20
|
} from '@aztec/stdlib/abi';
|
|
18
21
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -26,13 +29,13 @@ import {
|
|
|
26
29
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
27
30
|
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
30
33
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
31
34
|
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
32
35
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
33
36
|
* the required information and facilitate cryptographic proof generation.
|
|
34
37
|
*/
|
|
35
|
-
export class
|
|
38
|
+
export class ContractStore {
|
|
36
39
|
/** Map from contract class id to private function tree. */
|
|
37
40
|
// TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
38
41
|
#privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
|
|
@@ -176,6 +179,21 @@ export class ContractDataProvider {
|
|
|
176
179
|
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
177
180
|
}
|
|
178
181
|
|
|
182
|
+
public async getFunctionArtifactWithDebugMetadata(
|
|
183
|
+
contractAddress: AztecAddress,
|
|
184
|
+
selector: FunctionSelector,
|
|
185
|
+
): Promise<FunctionArtifactWithContractName> {
|
|
186
|
+
const artifact = await this.getFunctionArtifact(contractAddress, selector);
|
|
187
|
+
if (!artifact) {
|
|
188
|
+
throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
|
|
189
|
+
}
|
|
190
|
+
const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
|
|
191
|
+
return {
|
|
192
|
+
...artifact,
|
|
193
|
+
debug,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
179
197
|
public async getPublicFunctionArtifact(
|
|
180
198
|
contractAddress: AztecAddress,
|
|
181
199
|
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
@@ -274,4 +292,48 @@ export class ContractDataProvider {
|
|
|
274
292
|
}
|
|
275
293
|
}
|
|
276
294
|
}
|
|
295
|
+
|
|
296
|
+
public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
297
|
+
const contract = await this.getContract(to);
|
|
298
|
+
if (!contract) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
305
|
+
if (!functionDao) {
|
|
306
|
+
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
name: functionDao.name,
|
|
311
|
+
args: encodeArguments(functionDao, args),
|
|
312
|
+
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
313
|
+
type: functionDao.functionType,
|
|
314
|
+
to,
|
|
315
|
+
hideMsgSender: false,
|
|
316
|
+
isStatic: functionDao.isStatic,
|
|
317
|
+
returnTypes: functionDao.returnTypes,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Synchronize target contract data
|
|
322
|
+
public async syncPrivateState(
|
|
323
|
+
contractAddress: AztecAddress,
|
|
324
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
325
|
+
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
326
|
+
) {
|
|
327
|
+
// Protocol contracts don't have private state to sync
|
|
328
|
+
if (!isProtocolContract(contractAddress)) {
|
|
329
|
+
const syncPrivateStateFunctionCall = await this.getFunctionCall('sync_private_state', [], contractAddress);
|
|
330
|
+
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncPrivateStateFunctionCall.selector)) {
|
|
331
|
+
throw new Error(
|
|
332
|
+
'Forbidden `sync_private_state` invocation. `sync_private_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return utilityExecutor(syncPrivateStateFunctionCall);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
277
339
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContractStore } from './contract_store.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
4
4
|
import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
|
|
5
5
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
package/src/storage/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './address_store/index.js';
|
|
2
|
+
export * from './capsule_store/index.js';
|
|
3
|
+
export * from './contract_store/index.js';
|
|
4
|
+
export * from './note_store/index.js';
|
|
5
|
+
export * from './anchor_block_store/index.js';
|
|
6
|
+
export * from './tagging_store/index.js';
|
|
7
7
|
export * from './metadata.js';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './private_event_store/private_event_store.js';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
6
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
7
7
|
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
8
8
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* NoteStore manages the storage and retrieval of notes.
|
|
12
12
|
*
|
|
13
13
|
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
14
14
|
* and performs rollback handling in the case of a reorg.
|
|
15
15
|
**/
|
|
16
|
-
export class
|
|
16
|
+
export class NoteStore {
|
|
17
17
|
#store: AztecAsyncKVStore;
|
|
18
18
|
#notes: AztecAsyncMap<string, Buffer>;
|
|
19
19
|
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
@@ -49,16 +49,16 @@ export class NoteDataProvider {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Creates and initializes a new
|
|
52
|
+
* Creates and initializes a new NoteStore instance.
|
|
53
53
|
*
|
|
54
|
-
* This factory method creates a
|
|
54
|
+
* This factory method creates a NoteStore and restores any existing
|
|
55
55
|
* scope-specific indexes from the database.
|
|
56
56
|
*
|
|
57
57
|
* @param store - The key-value store to use for persistence
|
|
58
|
-
* @returns Promise resolving to a fully initialized
|
|
58
|
+
* @returns Promise resolving to a fully initialized NoteStore instance
|
|
59
59
|
*/
|
|
60
|
-
public static async create(store: AztecAsyncKVStore): Promise<
|
|
61
|
-
const pxeDB = new
|
|
60
|
+
public static async create(store: AztecAsyncKVStore): Promise<NoteStore> {
|
|
61
|
+
const pxeDB = new NoteStore(store);
|
|
62
62
|
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
63
63
|
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
64
64
|
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
@@ -224,8 +224,9 @@ export class NoteDataProvider {
|
|
|
224
224
|
* parameters.
|
|
225
225
|
*
|
|
226
226
|
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
227
|
-
* storageSlot, status, scopes and siloedNullifier.
|
|
228
|
-
* @returns
|
|
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)
|
|
229
230
|
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
230
231
|
*/
|
|
231
232
|
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
@@ -307,6 +308,10 @@ export class NoteDataProvider {
|
|
|
307
308
|
continue;
|
|
308
309
|
}
|
|
309
310
|
|
|
311
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
|
|
310
315
|
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) {
|
|
311
316
|
continue;
|
|
312
317
|
}
|
|
@@ -319,7 +324,15 @@ export class NoteDataProvider {
|
|
|
319
324
|
}
|
|
320
325
|
}
|
|
321
326
|
|
|
322
|
-
|
|
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;
|
|
323
336
|
}
|
|
324
337
|
|
|
325
338
|
/**
|
|
@@ -333,7 +346,7 @@ export class NoteDataProvider {
|
|
|
333
346
|
* @returns Promise resolving to array of nullified NoteDao objects
|
|
334
347
|
* @throws Error if any nullifier is not found in the active notes
|
|
335
348
|
*/
|
|
336
|
-
applyNullifiers(nullifiers:
|
|
349
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[]): Promise<NoteDao[]> {
|
|
337
350
|
if (nullifiers.length === 0) {
|
|
338
351
|
return Promise.resolve([]);
|
|
339
352
|
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
|
+
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
7
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
9
|
+
import { type InTx, TxHash } from '@aztec/stdlib/tx';
|
|
10
|
+
|
|
11
|
+
import type { PackedPrivateEvent } from '../../pxe.js';
|
|
12
|
+
|
|
13
|
+
export type PrivateEventStoreFilter = {
|
|
14
|
+
contractAddress: AztecAddress;
|
|
15
|
+
fromBlock: number;
|
|
16
|
+
toBlock: number;
|
|
17
|
+
scopes: AztecAddress[];
|
|
18
|
+
txHash?: TxHash;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type PrivateEventEntry = {
|
|
22
|
+
randomness: Fr; // Note that this value is currently not being returned on queries and is therefore temporarily unused
|
|
23
|
+
msgContent: Buffer;
|
|
24
|
+
eventCommitmentIndex: number;
|
|
25
|
+
l2BlockNumber: number;
|
|
26
|
+
l2BlockHash: Buffer;
|
|
27
|
+
txHash: Buffer;
|
|
28
|
+
/** The lookup key for #eventsByContractScopeSelector, used for cleanup during rollback */
|
|
29
|
+
lookupKey: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type PrivateEventMetadata = InTx & {
|
|
33
|
+
contractAddress: AztecAddress;
|
|
34
|
+
scope: AztecAddress;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Stores decrypted private event logs.
|
|
39
|
+
*/
|
|
40
|
+
export class PrivateEventStore {
|
|
41
|
+
#store: AztecAsyncKVStore;
|
|
42
|
+
/** Map storing the actual private event log entries, keyed by eventCommitmentIndex */
|
|
43
|
+
#eventLogs: AztecAsyncMap<number, PrivateEventEntry>;
|
|
44
|
+
/** Map from contractAddress_scope_eventSelector to eventCommitmentIndex[] for efficient lookup */
|
|
45
|
+
#eventsByContractScopeSelector: AztecAsyncMap<string, number[]>;
|
|
46
|
+
/** Map from block number to eventCommitmentIndex[] for rollback support */
|
|
47
|
+
#eventsByBlockNumber: AztecAsyncMap<number, number[]>;
|
|
48
|
+
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
|
|
49
|
+
#seenLogs: AztecAsyncMap<number, boolean>;
|
|
50
|
+
|
|
51
|
+
logger = createLogger('private_event_store');
|
|
52
|
+
|
|
53
|
+
constructor(store: AztecAsyncKVStore) {
|
|
54
|
+
this.#store = store;
|
|
55
|
+
this.#eventLogs = this.#store.openMap('private_event_logs');
|
|
56
|
+
this.#eventsByContractScopeSelector = this.#store.openMap('events_by_contract_scope_selector');
|
|
57
|
+
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
58
|
+
this.#eventsByBlockNumber = this.#store.openMap('events_by_block_number');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
|
|
62
|
+
return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Store a private event log.
|
|
67
|
+
* @param eventSelector - The event selector of the event.
|
|
68
|
+
* @param msgContent - The content of the event.
|
|
69
|
+
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
70
|
+
* @param metadata
|
|
71
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
72
|
+
* scope - The address to which the event is scoped.
|
|
73
|
+
* txHash - The transaction hash of the event log.
|
|
74
|
+
* blockNumber - The block number in which the event was emitted.
|
|
75
|
+
*/
|
|
76
|
+
storePrivateEventLog(
|
|
77
|
+
eventSelector: EventSelector,
|
|
78
|
+
randomness: Fr,
|
|
79
|
+
msgContent: Fr[],
|
|
80
|
+
eventCommitmentIndex: number,
|
|
81
|
+
metadata: PrivateEventMetadata,
|
|
82
|
+
): Promise<void> {
|
|
83
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
84
|
+
|
|
85
|
+
return this.#store.transactionAsync(async () => {
|
|
86
|
+
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
87
|
+
|
|
88
|
+
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
89
|
+
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
90
|
+
if (hasBeenSeen) {
|
|
91
|
+
this.logger.verbose('Ignoring duplicate event log', { txHash: txHash.toString(), eventCommitmentIndex });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
96
|
+
|
|
97
|
+
await this.#eventLogs.set(eventCommitmentIndex, {
|
|
98
|
+
randomness,
|
|
99
|
+
msgContent: serializeToBuffer(msgContent),
|
|
100
|
+
l2BlockNumber,
|
|
101
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
102
|
+
eventCommitmentIndex,
|
|
103
|
+
txHash: txHash.toBuffer(),
|
|
104
|
+
lookupKey: key,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const existingIndices = (await this.#eventsByContractScopeSelector.getAsync(key)) || [];
|
|
108
|
+
await this.#eventsByContractScopeSelector.set(key, [...existingIndices, eventCommitmentIndex]);
|
|
109
|
+
|
|
110
|
+
const existingBlockIndices = (await this.#eventsByBlockNumber.getAsync(l2BlockNumber)) || [];
|
|
111
|
+
await this.#eventsByBlockNumber.set(l2BlockNumber, [...existingBlockIndices, eventCommitmentIndex]);
|
|
112
|
+
|
|
113
|
+
// Mark this log as seen using eventCommitmentIndex
|
|
114
|
+
await this.#seenLogs.set(eventCommitmentIndex, true);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns the private events given search parameters.
|
|
120
|
+
* @param eventSelector - The event selector to filter by.
|
|
121
|
+
* @param filter - Filtering criteria:
|
|
122
|
+
* contractAddress: The address of the contract to get events from.
|
|
123
|
+
* fromBlock: The block number to search from (inclusive).
|
|
124
|
+
* toBlock: The block number to search upto (exclusive).
|
|
125
|
+
* scope: - The addresses that decrypted the logs.
|
|
126
|
+
* @returns - The event log contents, augmented with metadata about
|
|
127
|
+
* the transaction and block it the event was included in .
|
|
128
|
+
*/
|
|
129
|
+
public async getPrivateEvents(
|
|
130
|
+
eventSelector: EventSelector,
|
|
131
|
+
filter: PrivateEventStoreFilter,
|
|
132
|
+
): Promise<PackedPrivateEvent[]> {
|
|
133
|
+
const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
|
|
134
|
+
|
|
135
|
+
for (const scope of filter.scopes) {
|
|
136
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
137
|
+
const eventCommitmentIndices = (await this.#eventsByContractScopeSelector.getAsync(key)) || [];
|
|
138
|
+
|
|
139
|
+
for (const eventCommitmentIndex of eventCommitmentIndices) {
|
|
140
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
141
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Convert buffer back to Fr array
|
|
146
|
+
const reader = BufferReader.asReader(entry.msgContent);
|
|
147
|
+
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
148
|
+
const msgContent = reader.readArray(numFields, Fr);
|
|
149
|
+
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
150
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
151
|
+
|
|
152
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
events.push({
|
|
157
|
+
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
158
|
+
event: {
|
|
159
|
+
packedEvent: msgContent,
|
|
160
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
161
|
+
txHash,
|
|
162
|
+
l2BlockHash,
|
|
163
|
+
eventSelector,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Sort by eventCommitmentIndex only
|
|
170
|
+
events.sort((a, b) => a.eventCommitmentIndex - b.eventCommitmentIndex);
|
|
171
|
+
return events.map(ev => ev.event);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
176
|
+
* number up to which PXE managed to sync before the reorg happened).
|
|
177
|
+
*/
|
|
178
|
+
public async rollbackEventsAfterBlock(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
179
|
+
await this.#store.transactionAsync(async () => {
|
|
180
|
+
let removedCount = 0;
|
|
181
|
+
|
|
182
|
+
for (let block = blockNumber + 1; block <= synchedBlockNumber; block++) {
|
|
183
|
+
const indices = await this.#eventsByBlockNumber.getAsync(block);
|
|
184
|
+
if (indices) {
|
|
185
|
+
await this.#eventsByBlockNumber.delete(block);
|
|
186
|
+
|
|
187
|
+
for (const eventCommitmentIndex of indices) {
|
|
188
|
+
const entry = await this.#eventLogs.getAsync(eventCommitmentIndex);
|
|
189
|
+
if (!entry) {
|
|
190
|
+
throw new Error(`Event log not found for eventCommitmentIndex ${eventCommitmentIndex}`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await this.#eventLogs.delete(eventCommitmentIndex);
|
|
194
|
+
await this.#seenLogs.delete(eventCommitmentIndex);
|
|
195
|
+
|
|
196
|
+
// Update #eventsByContractScopeSelector using the stored lookupKey
|
|
197
|
+
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(entry.lookupKey);
|
|
198
|
+
if (!existingIndices || existingIndices.length === 0) {
|
|
199
|
+
throw new Error(`No indices found in #eventsByContractScopeSelector for key ${entry.lookupKey}`);
|
|
200
|
+
}
|
|
201
|
+
const filteredIndices = existingIndices.filter(idx => idx !== eventCommitmentIndex);
|
|
202
|
+
if (filteredIndices.length === 0) {
|
|
203
|
+
await this.#eventsByContractScopeSelector.delete(entry.lookupKey);
|
|
204
|
+
} else {
|
|
205
|
+
await this.#eventsByContractScopeSelector.set(entry.lookupKey, filteredIndices);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
removedCount++;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
|
+
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
6
|
+
* is called SenderTaggingStore. We have the providers separate for the sender and recipient because
|
|
7
|
+
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
8
|
+
*
|
|
9
|
+
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
10
|
+
* blocks, which by definition cannot be affected by reorgs.
|
|
11
|
+
*
|
|
12
|
+
* TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
|
|
13
|
+
*/
|
|
14
|
+
export class RecipientTaggingStore {
|
|
15
|
+
#store: AztecAsyncKVStore;
|
|
16
|
+
|
|
17
|
+
#highestAgedIndex: AztecAsyncMap<string, number>;
|
|
18
|
+
#highestFinalizedIndex: AztecAsyncMap<string, number>;
|
|
19
|
+
|
|
20
|
+
constructor(store: AztecAsyncKVStore) {
|
|
21
|
+
this.#store = store;
|
|
22
|
+
|
|
23
|
+
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
24
|
+
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getHighestAgedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
28
|
+
return this.#highestAgedIndex.getAsync(secret.toString());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
|
|
32
|
+
const currentIndex = await this.#highestAgedIndex.getAsync(secret.toString());
|
|
33
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
34
|
+
// Log sync should never set a lower highest aged index.
|
|
35
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
36
|
+
}
|
|
37
|
+
await this.#highestAgedIndex.set(secret.toString(), index);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
41
|
+
return this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
|
|
45
|
+
const currentIndex = await this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
46
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
47
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
48
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
49
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
50
|
+
}
|
|
51
|
+
await this.#highestFinalizedIndex.set(secret.toString(), index);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { toArray } from '@aztec/foundation/iterable';
|
|
2
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Stores sender addresses. During recipient log synchronization, these senders are used, along with a given recipient,
|
|
7
|
+
* to derive directional app tagging secrets that are then used to sync the logs.
|
|
8
|
+
*/
|
|
9
|
+
export class SenderAddressBookStore {
|
|
10
|
+
#store: AztecAsyncKVStore;
|
|
11
|
+
#addressBook: AztecAsyncMap<string, true>;
|
|
12
|
+
|
|
13
|
+
constructor(store: AztecAsyncKVStore) {
|
|
14
|
+
this.#store = store;
|
|
15
|
+
|
|
16
|
+
this.#addressBook = this.#store.openMap('address_book');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async addSender(address: AztecAddress): Promise<boolean> {
|
|
20
|
+
if (await this.#addressBook.hasAsync(address.toString())) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await this.#addressBook.set(address.toString(), true);
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getSenders(): Promise<AztecAddress[]> {
|
|
30
|
+
return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async removeSender(address: AztecAddress): Promise<boolean> {
|
|
34
|
+
if (!(await this.#addressBook.hasAsync(address.toString()))) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await this.#addressBook.delete(address.toString());
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|