@aztec/pxe 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec
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.d.ts +1 -1
- package/dest/bin/check_oracle_version.js +105 -15
- package/dest/block_synchronizer/block_synchronizer.d.ts +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +20 -22
- 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 -12
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +7 -13
- package/dest/config/package_info.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +43 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +55 -29
- package/dest/contract_function_simulator/execution_note_cache.d.ts +9 -7
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +21 -13
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +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/index.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -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 +12 -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/index.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +19 -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 -4
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -4
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +34 -17
- 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 +12 -12
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +24 -18
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +58 -17
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +147 -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/contract_function_simulator/proxied_node.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +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.js +4 -4
- 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.js +4 -4
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- 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 +5 -16
- 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/logs/log_service.d.ts +26 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +120 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/index.d.ts +1 -1
- 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 +11 -10
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +8 -7
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +7 -7
- package/dest/public_storage/public_storage_service.d.ts +24 -0
- package/dest/public_storage/public_storage_service.d.ts.map +1 -0
- package/dest/public_storage/public_storage_service.js +26 -0
- package/dest/pxe.d.ts +47 -48
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +142 -171
- 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/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -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} +7 -15
- 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} +34 -15
- 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/metadata.d.ts +1 -1
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +14 -13
- 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} +33 -19
- package/dest/storage/private_event_store/private_event_store.d.ts +51 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/{private_event_data_provider/private_event_data_provider.js → private_event_store/private_event_store.js} +39 -28
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
- package/dest/tagging/index.d.ts +15 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +23 -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 +20 -19
- package/src/bin/check_oracle_version.ts +130 -20
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +19 -22
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +10 -25
- package/src/contract_function_simulator/contract_function_simulator.ts +95 -28
- package/src/contract_function_simulator/execution_note_cache.ts +22 -11
- 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 +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +26 -11
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
- package/src/contract_function_simulator/oracle/oracle.ts +43 -13
- package/src/contract_function_simulator/oracle/private_execution.ts +17 -15
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +100 -23
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +223 -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 +4 -4
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +4 -4
- package/src/entrypoints/pxe_creation_options.ts +2 -0
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +5 -19
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +77 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +48 -0
- package/src/logs/log_service.ts +202 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
- package/src/private_kernel/private_kernel_execution_prover.ts +12 -16
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +10 -9
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +167 -223
- 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} +45 -20
- 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} +41 -22
- package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +61 -47
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
- package/src/tagging/index.ts +27 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +96 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
- package/src/tree_membership/tree_membership_service.ts +112 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -274
- 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 -701
- 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_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -43
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -10
- 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/constants.d.ts +0 -2
- package/dest/tagging/constants.d.ts.map +0 -1
- package/dest/tagging/constants.js +0 -2
- 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 -343
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1019
- 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/note_data_provider/note_dao.ts +0 -154
- 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/constants.ts +0 -2
- 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,5 +1,5 @@
|
|
|
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';
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
type FunctionAbi,
|
|
9
9
|
type FunctionArtifact,
|
|
10
10
|
type FunctionArtifactWithContractName,
|
|
11
|
+
FunctionCall,
|
|
11
12
|
type FunctionDebugMetadata,
|
|
12
13
|
FunctionSelector,
|
|
13
14
|
FunctionType,
|
|
14
15
|
contractArtifactFromBuffer,
|
|
15
16
|
contractArtifactToBuffer,
|
|
17
|
+
encodeArguments,
|
|
16
18
|
getFunctionDebugMetadata,
|
|
17
19
|
} from '@aztec/stdlib/abi';
|
|
18
20
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -26,13 +28,13 @@ import {
|
|
|
26
28
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
30
32
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
31
33
|
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
32
34
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
33
35
|
* the required information and facilitate cryptographic proof generation.
|
|
34
36
|
*/
|
|
35
|
-
export class
|
|
37
|
+
export class ContractStore {
|
|
36
38
|
/** Map from contract class id to private function tree. */
|
|
37
39
|
// TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
38
40
|
#privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
|
|
@@ -176,6 +178,21 @@ export class ContractDataProvider {
|
|
|
176
178
|
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
public async getFunctionArtifactWithDebugMetadata(
|
|
182
|
+
contractAddress: AztecAddress,
|
|
183
|
+
selector: FunctionSelector,
|
|
184
|
+
): Promise<FunctionArtifactWithContractName> {
|
|
185
|
+
const artifact = await this.getFunctionArtifact(contractAddress, selector);
|
|
186
|
+
if (!artifact) {
|
|
187
|
+
throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
|
|
188
|
+
}
|
|
189
|
+
const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
|
|
190
|
+
return {
|
|
191
|
+
...artifact,
|
|
192
|
+
debug,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
179
196
|
public async getPublicFunctionArtifact(
|
|
180
197
|
contractAddress: AztecAddress,
|
|
181
198
|
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
@@ -184,23 +201,6 @@ export class ContractDataProvider {
|
|
|
184
201
|
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
185
202
|
}
|
|
186
203
|
|
|
187
|
-
/**
|
|
188
|
-
* Retrieves the artifact of a specified function within a given contract.
|
|
189
|
-
* The function is identified by its name, which is unique within a contract.
|
|
190
|
-
* Throws if the contract has not been added to the database.
|
|
191
|
-
*
|
|
192
|
-
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
193
|
-
* @param functionName - The name of the function.
|
|
194
|
-
* @returns The corresponding function's artifact as an object
|
|
195
|
-
*/
|
|
196
|
-
public async getFunctionArtifactByName(
|
|
197
|
-
contractAddress: AztecAddress,
|
|
198
|
-
functionName: string,
|
|
199
|
-
): Promise<FunctionArtifact | undefined> {
|
|
200
|
-
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
201
|
-
return artifact?.functions.find(fn => fn.name === functionName);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
204
|
public async getFunctionAbi(
|
|
205
205
|
contractAddress: AztecAddress,
|
|
206
206
|
selector: FunctionSelector,
|
|
@@ -291,4 +291,29 @@ export class ContractDataProvider {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
296
|
+
const contract = await this.getContract(to);
|
|
297
|
+
if (!contract) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`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`,
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
304
|
+
if (!functionDao) {
|
|
305
|
+
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
name: functionDao.name,
|
|
310
|
+
args: encodeArguments(functionDao, args),
|
|
311
|
+
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
312
|
+
type: functionDao.functionType,
|
|
313
|
+
to,
|
|
314
|
+
hideMsgSender: false,
|
|
315
|
+
isStatic: functionDao.isStatic,
|
|
316
|
+
returnTypes: functionDao.returnTypes,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
294
319
|
}
|
|
@@ -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,20 +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
|
-
|
|
9
|
-
import { NoteDao } from './note_dao.js';
|
|
8
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* NoteStore manages the storage and retrieval of notes.
|
|
13
12
|
*
|
|
14
13
|
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
15
14
|
* and performs rollback handling in the case of a reorg.
|
|
16
15
|
**/
|
|
17
|
-
export class
|
|
16
|
+
export class NoteStore {
|
|
18
17
|
#store: AztecAsyncKVStore;
|
|
19
18
|
#notes: AztecAsyncMap<string, Buffer>;
|
|
20
19
|
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
@@ -50,16 +49,16 @@ export class NoteDataProvider {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
|
-
* Creates and initializes a new
|
|
52
|
+
* Creates and initializes a new NoteStore instance.
|
|
54
53
|
*
|
|
55
|
-
* This factory method creates a
|
|
54
|
+
* This factory method creates a NoteStore and restores any existing
|
|
56
55
|
* scope-specific indexes from the database.
|
|
57
56
|
*
|
|
58
57
|
* @param store - The key-value store to use for persistence
|
|
59
|
-
* @returns Promise resolving to a fully initialized
|
|
58
|
+
* @returns Promise resolving to a fully initialized NoteStore instance
|
|
60
59
|
*/
|
|
61
|
-
public static async create(store: AztecAsyncKVStore): Promise<
|
|
62
|
-
const pxeDB = new
|
|
60
|
+
public static async create(store: AztecAsyncKVStore): Promise<NoteStore> {
|
|
61
|
+
const pxeDB = new NoteStore(store);
|
|
63
62
|
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
64
63
|
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
65
64
|
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
@@ -194,10 +193,12 @@ export class NoteDataProvider {
|
|
|
194
193
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
195
194
|
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
196
195
|
|
|
197
|
-
|
|
196
|
+
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
198
197
|
|
|
199
198
|
if (scopes.length === 0) {
|
|
200
|
-
|
|
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}`);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
for (const scope of scopes) {
|
|
@@ -223,8 +224,9 @@ export class NoteDataProvider {
|
|
|
223
224
|
* parameters.
|
|
224
225
|
*
|
|
225
226
|
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
226
|
-
* storageSlot, status, scopes and siloedNullifier.
|
|
227
|
-
* @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)
|
|
228
230
|
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
229
231
|
*/
|
|
230
232
|
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
@@ -306,6 +308,10 @@ export class NoteDataProvider {
|
|
|
306
308
|
continue;
|
|
307
309
|
}
|
|
308
310
|
|
|
311
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
|
|
309
315
|
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) {
|
|
310
316
|
continue;
|
|
311
317
|
}
|
|
@@ -318,7 +324,15 @@ export class NoteDataProvider {
|
|
|
318
324
|
}
|
|
319
325
|
}
|
|
320
326
|
|
|
321
|
-
|
|
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;
|
|
322
336
|
}
|
|
323
337
|
|
|
324
338
|
/**
|
|
@@ -332,7 +346,7 @@ export class NoteDataProvider {
|
|
|
332
346
|
* @returns Promise resolving to array of nullified NoteDao objects
|
|
333
347
|
* @throws Error if any nullifier is not found in the active notes
|
|
334
348
|
*/
|
|
335
|
-
applyNullifiers(nullifiers:
|
|
349
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[]): Promise<NoteDao[]> {
|
|
336
350
|
if (nullifiers.length === 0) {
|
|
337
351
|
return Promise.resolve([]);
|
|
338
352
|
}
|
|
@@ -359,7 +373,14 @@ export class NoteDataProvider {
|
|
|
359
373
|
if (!noteBuffer) {
|
|
360
374
|
throw new Error('Note not found in applyNullifiers');
|
|
361
375
|
}
|
|
362
|
-
|
|
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
|
+
|
|
363
384
|
const note = NoteDao.fromBuffer(noteBuffer);
|
|
364
385
|
|
|
365
386
|
nullifiedNotes.push(note);
|
|
@@ -374,10 +395,8 @@ export class NoteDataProvider {
|
|
|
374
395
|
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
|
|
375
396
|
}
|
|
376
397
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
380
|
-
}
|
|
398
|
+
for (const scope of noteScopes) {
|
|
399
|
+
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
381
400
|
}
|
|
382
401
|
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
383
402
|
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
6
|
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
8
|
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
8
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
import { type InTx, TxHash } from '@aztec/stdlib/tx';
|
|
9
10
|
|
|
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 = {
|
|
11
22
|
msgContent: Buffer;
|
|
12
|
-
blockNumber: number;
|
|
13
|
-
blockHash: Buffer;
|
|
14
23
|
eventCommitmentIndex: number;
|
|
24
|
+
l2BlockNumber: number;
|
|
25
|
+
l2BlockHash: Buffer;
|
|
15
26
|
txHash: Buffer;
|
|
16
|
-
}
|
|
27
|
+
};
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
blockHash: L2BlockHash;
|
|
22
|
-
txHash: TxHash;
|
|
23
|
-
recipient: AztecAddress;
|
|
29
|
+
type PrivateEventMetadata = InTx & {
|
|
30
|
+
contractAddress: AztecAddress;
|
|
31
|
+
scope: AztecAddress;
|
|
24
32
|
};
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* Stores decrypted private event logs.
|
|
28
36
|
*/
|
|
29
|
-
export class
|
|
37
|
+
export class PrivateEventStore {
|
|
30
38
|
#store: AztecAsyncKVStore;
|
|
31
39
|
/** Array storing the actual private event log entries containing the log content and block number */
|
|
32
40
|
#eventLogs: AztecAsyncArray<PrivateEventEntry>;
|
|
33
|
-
/** Map from
|
|
41
|
+
/** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
|
|
34
42
|
#eventLogIndex: AztecAsyncMap<string, number[]>;
|
|
35
43
|
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
|
|
36
44
|
#seenLogs: AztecAsyncMap<number, boolean>;
|
|
37
45
|
|
|
38
|
-
logger = createLogger('
|
|
46
|
+
logger = createLogger('private_event_store');
|
|
39
47
|
|
|
40
48
|
constructor(store: AztecAsyncKVStore) {
|
|
41
49
|
this.#store = store;
|
|
@@ -44,28 +52,31 @@ export class PrivateEventDataProvider {
|
|
|
44
52
|
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
45
53
|
}
|
|
46
54
|
|
|
55
|
+
#keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
|
|
56
|
+
return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
/**
|
|
48
60
|
* Store a private event log.
|
|
49
|
-
* @param contractAddress - The address of the contract that emitted the event.
|
|
50
|
-
* @param recipient - The recipient of the event.
|
|
51
61
|
* @param eventSelector - The event selector of the event.
|
|
52
62
|
* @param msgContent - The content of the event.
|
|
53
|
-
* @param txHash - The transaction hash of the event log.
|
|
54
63
|
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
55
|
-
* @param
|
|
64
|
+
* @param metadata
|
|
65
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
66
|
+
* scope - The address to which the event is scoped.
|
|
67
|
+
* txHash - The transaction hash of the event log.
|
|
68
|
+
* blockNumber - The block number in which the event was emitted.
|
|
56
69
|
*/
|
|
57
70
|
storePrivateEventLog(
|
|
58
|
-
contractAddress: AztecAddress,
|
|
59
|
-
recipient: AztecAddress,
|
|
60
71
|
eventSelector: EventSelector,
|
|
61
72
|
msgContent: Fr[],
|
|
62
|
-
txHash: TxHash,
|
|
63
73
|
eventCommitmentIndex: number,
|
|
64
|
-
|
|
65
|
-
blockHash: L2BlockHash,
|
|
74
|
+
metadata: PrivateEventMetadata,
|
|
66
75
|
): Promise<void> {
|
|
76
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
77
|
+
|
|
67
78
|
return this.#store.transactionAsync(async () => {
|
|
68
|
-
const key =
|
|
79
|
+
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
69
80
|
|
|
70
81
|
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
71
82
|
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
@@ -74,13 +85,13 @@ export class PrivateEventDataProvider {
|
|
|
74
85
|
return;
|
|
75
86
|
}
|
|
76
87
|
|
|
77
|
-
this.logger.verbose('storing private event log', { contractAddress,
|
|
88
|
+
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
78
89
|
|
|
79
90
|
const index = await this.#eventLogs.lengthAsync();
|
|
80
91
|
await this.#eventLogs.push({
|
|
81
92
|
msgContent: serializeToBuffer(msgContent),
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
l2BlockNumber,
|
|
94
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
84
95
|
eventCommitmentIndex,
|
|
85
96
|
txHash: txHash.toBuffer(),
|
|
86
97
|
});
|
|
@@ -95,29 +106,28 @@ export class PrivateEventDataProvider {
|
|
|
95
106
|
|
|
96
107
|
/**
|
|
97
108
|
* Returns the private events given search parameters.
|
|
98
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
99
|
-
* @param from - The block number to search from.
|
|
100
|
-
* @param numBlocks - The amount of blocks to search.
|
|
101
|
-
* @param recipients - The addresses that decrypted the logs.
|
|
102
109
|
* @param eventSelector - The event selector to filter by.
|
|
103
|
-
* @
|
|
110
|
+
* @param filter - Filtering criteria:
|
|
111
|
+
* contractAddress: The address of the contract to get events from.
|
|
112
|
+
* fromBlock: The block number to search from (inclusive).
|
|
113
|
+
* toBlock: The block number to search upto (exclusive).
|
|
114
|
+
* scope: - The addresses that decrypted the logs.
|
|
115
|
+
* @returns - The event log contents, augmented with metadata about
|
|
116
|
+
* the transaction and block it the event was included in .
|
|
104
117
|
*/
|
|
105
118
|
public async getPrivateEvents(
|
|
106
|
-
contractAddress: AztecAddress,
|
|
107
|
-
from: number,
|
|
108
|
-
numBlocks: number,
|
|
109
|
-
recipients: AztecAddress[],
|
|
110
119
|
eventSelector: EventSelector,
|
|
111
|
-
|
|
112
|
-
|
|
120
|
+
filter: PrivateEventStoreFilter,
|
|
121
|
+
): Promise<PackedPrivateEvent[]> {
|
|
122
|
+
const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
|
|
113
123
|
|
|
114
|
-
for (const
|
|
115
|
-
const key =
|
|
124
|
+
for (const scope of filter.scopes) {
|
|
125
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
116
126
|
const indices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
117
127
|
|
|
118
128
|
for (const index of indices) {
|
|
119
129
|
const entry = await this.#eventLogs.atAsync(index);
|
|
120
|
-
if (!entry || entry.
|
|
130
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
121
131
|
continue;
|
|
122
132
|
}
|
|
123
133
|
|
|
@@ -126,16 +136,20 @@ export class PrivateEventDataProvider {
|
|
|
126
136
|
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
127
137
|
const msgContent = reader.readArray(numFields, Fr);
|
|
128
138
|
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
129
|
-
const
|
|
139
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
140
|
+
|
|
141
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
130
144
|
|
|
131
145
|
events.push({
|
|
132
146
|
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
133
147
|
event: {
|
|
134
|
-
msgContent,
|
|
135
|
-
|
|
136
|
-
recipient,
|
|
148
|
+
packedEvent: msgContent,
|
|
149
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
137
150
|
txHash,
|
|
138
|
-
|
|
151
|
+
l2BlockHash,
|
|
152
|
+
eventSelector,
|
|
139
153
|
},
|
|
140
154
|
});
|
|
141
155
|
}
|
|
@@ -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
|
+
}
|