@aztec/pxe 0.0.1-commit.d3ec352c → 0.0.1-commit.e310a4c8
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 +43 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +147 -0
- 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 +6 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +40 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +72 -33
- package/dest/contract_function_simulator/execution_note_cache.d.ts +21 -12
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +48 -31
- 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/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/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 +3 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +20 -16
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +4 -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 +11 -7
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +14 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +59 -37
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -28
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +2 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +32 -25
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -45
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +80 -26
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +175 -65
- 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_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +41 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +47 -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 +23 -8
- 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 +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +24 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +30 -15
- 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 +44 -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 +38 -0
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +28 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +125 -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 +147 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +10 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +26 -29
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +45 -81
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +188 -217
- 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} +13 -12
- 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 +17 -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} +10 -10
- 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 +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +253 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +7 -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} +56 -16
- 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/metadata.js +1 -1
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +83 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +341 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +273 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +111 -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 +36 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +348 -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/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +16 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +15 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -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 +15 -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 +32 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -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 +29 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -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 +60 -0
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +131 -20
- package/src/block_synchronizer/block_synchronizer.ts +172 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +17 -3
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +114 -34
- package/src/contract_function_simulator/execution_note_cache.ts +51 -29
- 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/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
- 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 +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +25 -15
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +27 -13
- package/src/contract_function_simulator/oracle/oracle.ts +83 -44
- package/src/contract_function_simulator/oracle/private_execution.ts +2 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +120 -59
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +266 -82
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -0
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +15 -16
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +16 -17
- package/src/entrypoints/pxe_creation_options.ts +6 -2
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +26 -34
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +71 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +46 -0
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +220 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +195 -0
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +34 -23
- package/src/private_kernel/private_kernel_execution_prover.ts +13 -12
- package/src/private_kernel/private_kernel_oracle.ts +118 -37
- package/src/pxe.ts +267 -282
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
- 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} +10 -12
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +67 -14
- 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/metadata.ts +1 -1
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +411 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +384 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
- package/src/tagging/constants.ts +10 -2
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +18 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -267
- 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/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -123
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -696
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/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/capsule_data_provider.js +0 -118
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -83
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -314
- 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 +0 -11
- 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 -36
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -102
- 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 -342
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_data_provider.ts +0 -403
- 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/synchronizer/synchronizer.ts +0 -121
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface that stores must implement to support staged writes.
|
|
7
|
+
*/
|
|
8
|
+
export interface StagedStore {
|
|
9
|
+
/** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
|
|
10
|
+
readonly storeName: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Commits staged data to main storage.
|
|
14
|
+
* Should be called within a transaction for atomicity.
|
|
15
|
+
*
|
|
16
|
+
* @param jobId - The job identifier
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Discards staged data without committing.
|
|
22
|
+
* Called on abort.
|
|
23
|
+
*
|
|
24
|
+
* @param jobId - The job identifier
|
|
25
|
+
*/
|
|
26
|
+
discardStaged(jobId: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
|
|
31
|
+
*
|
|
32
|
+
* It uses a staged writes pattern:
|
|
33
|
+
* 1. When a job begins, a unique job ID is created
|
|
34
|
+
* 2. During the job, all writes go to staging (keyed by job ID)
|
|
35
|
+
* 3. On commit, staging is promoted to main storage
|
|
36
|
+
* 4. On abort, staged data is discarded
|
|
37
|
+
*
|
|
38
|
+
* Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
|
|
39
|
+
* orchestrate concurrent jobs. Right now it doesn't make a difference because we're
|
|
40
|
+
* using a job queue with concurrency=1.
|
|
41
|
+
*/
|
|
42
|
+
export class JobCoordinator {
|
|
43
|
+
private readonly log: Logger;
|
|
44
|
+
|
|
45
|
+
/** The underlying KV store */
|
|
46
|
+
kvStore: AztecAsyncKVStore;
|
|
47
|
+
|
|
48
|
+
#currentJobId: string | undefined;
|
|
49
|
+
#stores: Map<string, StagedStore> = new Map();
|
|
50
|
+
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings) {
|
|
52
|
+
this.kvStore = kvStore;
|
|
53
|
+
this.log = createLogger('pxe:job_coordinator', bindings);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Registers a staged store.
|
|
58
|
+
* Must be called during initialization for all stores that need staging support.
|
|
59
|
+
*/
|
|
60
|
+
registerStore(store: StagedStore): void {
|
|
61
|
+
if (this.#stores.has(store.storeName)) {
|
|
62
|
+
throw new Error(`Store "${store.storeName}" is already registered`);
|
|
63
|
+
}
|
|
64
|
+
this.#stores.set(store.storeName, store);
|
|
65
|
+
this.log.debug(`Registered staged store: ${store.storeName}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Registers multiple staged stores.
|
|
70
|
+
*/
|
|
71
|
+
registerStores(stores: StagedStore[]): void {
|
|
72
|
+
for (const store of stores) {
|
|
73
|
+
this.registerStore(store);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Begins a new job and returns a job ID for staged writes.
|
|
79
|
+
*
|
|
80
|
+
* @returns Job ID to pass to store operations
|
|
81
|
+
*/
|
|
82
|
+
beginJob(): string {
|
|
83
|
+
if (this.#currentJobId) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Cannot begin job: job ${this.#currentJobId} is already in progress. ` +
|
|
86
|
+
`This should not happen - ensure jobs are properly committed or aborted.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const jobId = randomBytes(8).toString('hex');
|
|
91
|
+
this.#currentJobId = jobId;
|
|
92
|
+
|
|
93
|
+
this.log.debug(`Started job ${jobId}`);
|
|
94
|
+
return jobId;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Commits a job by promoting all staged data to main storage.
|
|
99
|
+
*
|
|
100
|
+
* @param jobId - The job ID returned from beginJob
|
|
101
|
+
*/
|
|
102
|
+
async commitJob(jobId: string): Promise<void> {
|
|
103
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.log.debug(`Committing job ${jobId}`);
|
|
110
|
+
|
|
111
|
+
// Commit all stores atomically in a single transaction.
|
|
112
|
+
// Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
|
|
113
|
+
await this.kvStore.transactionAsync(async () => {
|
|
114
|
+
for (const store of this.#stores.values()) {
|
|
115
|
+
await store.commit(jobId);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
this.#currentJobId = undefined;
|
|
120
|
+
this.log.debug(`Job ${jobId} committed successfully`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Aborts a job by discarding all staged data.
|
|
125
|
+
*
|
|
126
|
+
* @param jobId - The job ID returned from beginJob
|
|
127
|
+
*/
|
|
128
|
+
async abortJob(jobId: string): Promise<void> {
|
|
129
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
130
|
+
// Job may have already been aborted or never started properly
|
|
131
|
+
this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this.log.debug(`Aborting job ${jobId}`);
|
|
135
|
+
|
|
136
|
+
for (const store of this.#stores.values()) {
|
|
137
|
+
await store.discardStaged(jobId);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.#currentJobId = undefined;
|
|
141
|
+
this.log.debug(`Job ${jobId} aborted`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Checks if there's a job currently in progress.
|
|
146
|
+
*/
|
|
147
|
+
hasJobInProgress(): boolean {
|
|
148
|
+
return this.#currentJobId !== undefined;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
8
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
11
|
+
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
12
|
+
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
13
|
+
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
|
+
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
|
+
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
16
|
+
import {
|
|
17
|
+
getAllPrivateLogsByTags,
|
|
18
|
+
getAllPublicLogsByTagsFromContract,
|
|
19
|
+
loadPrivateLogsForSenderRecipientPair,
|
|
20
|
+
} from '../tagging/index.js';
|
|
21
|
+
|
|
22
|
+
export class LogService {
|
|
23
|
+
private log: Logger;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly aztecNode: AztecNode,
|
|
27
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
28
|
+
private readonly keyStore: KeyStore,
|
|
29
|
+
private readonly capsuleStore: CapsuleStore,
|
|
30
|
+
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
31
|
+
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
32
|
+
private readonly addressStore: AddressStore,
|
|
33
|
+
private readonly jobId: string,
|
|
34
|
+
bindings?: LoggerBindings,
|
|
35
|
+
) {
|
|
36
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
40
|
+
return await Promise.all(
|
|
41
|
+
logRetrievalRequests.map(async request => {
|
|
42
|
+
const [publicLog, privateLog] = await Promise.all([
|
|
43
|
+
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
44
|
+
this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
if (publicLog !== null && privateLog !== null) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return publicLog ?? privateLog;
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
59
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
60
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
61
|
+
this.aztecNode,
|
|
62
|
+
contractAddress,
|
|
63
|
+
[tag],
|
|
64
|
+
anchorBlockHash,
|
|
65
|
+
);
|
|
66
|
+
const logsForTag = allLogsPerTag[0];
|
|
67
|
+
|
|
68
|
+
if (logsForTag.length === 0) {
|
|
69
|
+
return null;
|
|
70
|
+
} else if (logsForTag.length > 1) {
|
|
71
|
+
// TODO(#11627): handle this case
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const scopedLog = logsForTag[0];
|
|
78
|
+
|
|
79
|
+
return new LogRetrievalResponse(
|
|
80
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
81
|
+
scopedLog.txHash,
|
|
82
|
+
scopedLog.noteHashes,
|
|
83
|
+
scopedLog.firstNullifier,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
88
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
89
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
90
|
+
const logsForTag = allLogsPerTag[0];
|
|
91
|
+
|
|
92
|
+
if (logsForTag.length === 0) {
|
|
93
|
+
return null;
|
|
94
|
+
} else if (logsForTag.length > 1) {
|
|
95
|
+
// TODO(#11627): handle this case
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const scopedLog = logsForTag[0];
|
|
102
|
+
|
|
103
|
+
return new LogRetrievalResponse(
|
|
104
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
105
|
+
scopedLog.txHash,
|
|
106
|
+
scopedLog.noteHashes,
|
|
107
|
+
scopedLog.firstNullifier,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public async syncTaggedLogs(
|
|
112
|
+
contractAddress: AztecAddress,
|
|
113
|
+
pendingTaggedLogArrayBaseSlot: Fr,
|
|
114
|
+
scopes?: AztecAddress[],
|
|
115
|
+
) {
|
|
116
|
+
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
117
|
+
|
|
118
|
+
// We only load logs from block up to and including the anchor block number
|
|
119
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
120
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
121
|
+
|
|
122
|
+
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
123
|
+
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
124
|
+
|
|
125
|
+
// For each recipient, fetch secrets, load logs, and store them.
|
|
126
|
+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
127
|
+
await Promise.all(
|
|
128
|
+
recipients.map(async recipient => {
|
|
129
|
+
// Get all secrets for this recipient (one per sender)
|
|
130
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
131
|
+
|
|
132
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
133
|
+
const logArrays = await Promise.all(
|
|
134
|
+
secrets.map(secret =>
|
|
135
|
+
loadPrivateLogsForSenderRecipientPair(
|
|
136
|
+
secret,
|
|
137
|
+
contractAddress,
|
|
138
|
+
this.aztecNode,
|
|
139
|
+
this.recipientTaggingStore,
|
|
140
|
+
anchorBlockNumber,
|
|
141
|
+
anchorBlockHash,
|
|
142
|
+
this.jobId,
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Flatten all logs from all secrets
|
|
148
|
+
const allLogs = logArrays.flat();
|
|
149
|
+
|
|
150
|
+
// Store the logs for this recipient
|
|
151
|
+
if (allLogs.length > 0) {
|
|
152
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async #getSecretsForSenders(
|
|
159
|
+
contractAddress: AztecAddress,
|
|
160
|
+
recipient: AztecAddress,
|
|
161
|
+
): Promise<DirectionalAppTaggingSecret[]> {
|
|
162
|
+
const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
|
|
163
|
+
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
164
|
+
|
|
165
|
+
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
166
|
+
// (recipient = us, sender = us)
|
|
167
|
+
const allSenders = [...(await this.senderAddressBookStore.getSenders()), ...(await this.keyStore.getAccounts())];
|
|
168
|
+
|
|
169
|
+
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
170
|
+
const deduplicatedSenders = Array.from(new Set(allSenders.map(sender => sender.toString()))).map(sender =>
|
|
171
|
+
AztecAddress.fromString(sender),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
return Promise.all(
|
|
175
|
+
deduplicatedSenders.map(sender => {
|
|
176
|
+
return DirectionalAppTaggingSecret.compute(
|
|
177
|
+
recipientCompleteAddress,
|
|
178
|
+
recipientIvsk,
|
|
179
|
+
sender,
|
|
180
|
+
contractAddress,
|
|
181
|
+
recipient,
|
|
182
|
+
);
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#storePendingTaggedLogs(
|
|
188
|
+
contractAddress: AztecAddress,
|
|
189
|
+
capsuleArrayBaseSlot: Fr,
|
|
190
|
+
recipient: AztecAddress,
|
|
191
|
+
privateLogs: TxScopedL2Log[],
|
|
192
|
+
) {
|
|
193
|
+
// Build all pending tagged logs from the scoped logs
|
|
194
|
+
const pendingTaggedLogs = privateLogs.map(scopedLog => {
|
|
195
|
+
const pendingTaggedLog = new PendingTaggedLog(
|
|
196
|
+
scopedLog.logData,
|
|
197
|
+
scopedLog.txHash,
|
|
198
|
+
scopedLog.noteHashes,
|
|
199
|
+
scopedLog.firstNullifier,
|
|
200
|
+
recipient,
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
return pendingTaggedLog.toFields();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// TODO: This looks like it could belong more at the oracle interface level
|
|
207
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
211
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
212
|
+
if (!completeAddress) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`No public key registered for address ${account}.
|
|
215
|
+
Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
return completeAddress;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NoteService } from './note_service.js';
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
4
|
+
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
5
|
+
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
7
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
11
|
+
|
|
12
|
+
export class NoteService {
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly noteStore: NoteStore,
|
|
15
|
+
private readonly aztecNode: AztecNode,
|
|
16
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
17
|
+
private readonly jobId: string,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
22
|
+
* The query result is paginated using 'limit' and 'offset' values.
|
|
23
|
+
* Returns an object containing an array of note data.
|
|
24
|
+
*
|
|
25
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all known owners.
|
|
26
|
+
* @param status - The status of notes to fetch.
|
|
27
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
28
|
+
*/
|
|
29
|
+
public async getNotes(
|
|
30
|
+
contractAddress: AztecAddress,
|
|
31
|
+
owner: AztecAddress | undefined,
|
|
32
|
+
storageSlot: Fr,
|
|
33
|
+
status: NoteStatus,
|
|
34
|
+
scopes?: AztecAddress[],
|
|
35
|
+
) {
|
|
36
|
+
const noteDaos = await this.noteStore.getNotes(
|
|
37
|
+
{
|
|
38
|
+
contractAddress,
|
|
39
|
+
owner,
|
|
40
|
+
storageSlot,
|
|
41
|
+
status,
|
|
42
|
+
scopes,
|
|
43
|
+
},
|
|
44
|
+
this.jobId,
|
|
45
|
+
);
|
|
46
|
+
return noteDaos.map(
|
|
47
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
48
|
+
contractAddress,
|
|
49
|
+
owner,
|
|
50
|
+
storageSlot,
|
|
51
|
+
randomness,
|
|
52
|
+
noteNonce,
|
|
53
|
+
note,
|
|
54
|
+
noteHash,
|
|
55
|
+
isPending: false, // Note service deals only with settled notes
|
|
56
|
+
siloedNullifier,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
63
|
+
*
|
|
64
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
65
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
66
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
67
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
68
|
+
* block up to which the PXE has synced.
|
|
69
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
70
|
+
*
|
|
71
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
72
|
+
*/
|
|
73
|
+
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
74
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
75
|
+
|
|
76
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
77
|
+
|
|
78
|
+
if (contractNotes.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const nullifiersToCheck = contractNotes.map(note => note.siloedNullifier);
|
|
83
|
+
const nullifierBatches = nullifiersToCheck.reduce(
|
|
84
|
+
(acc, nullifier) => {
|
|
85
|
+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
|
|
86
|
+
acc[acc.length - 1].push(nullifier);
|
|
87
|
+
} else {
|
|
88
|
+
acc.push([nullifier]);
|
|
89
|
+
}
|
|
90
|
+
return acc;
|
|
91
|
+
},
|
|
92
|
+
[[]] as Fr[][],
|
|
93
|
+
);
|
|
94
|
+
const nullifierIndexes = (
|
|
95
|
+
await Promise.all(
|
|
96
|
+
nullifierBatches.map(batch =>
|
|
97
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
).flat();
|
|
101
|
+
|
|
102
|
+
const foundNullifiers = nullifiersToCheck
|
|
103
|
+
.map((nullifier, i) => {
|
|
104
|
+
if (nullifierIndexes[i] !== undefined) {
|
|
105
|
+
return { ...nullifierIndexes[i], ...{ data: nullifier } } as DataInBlock<Fr>;
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
109
|
+
|
|
110
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public async validateAndStoreNote(
|
|
114
|
+
contractAddress: AztecAddress,
|
|
115
|
+
owner: AztecAddress,
|
|
116
|
+
storageSlot: Fr,
|
|
117
|
+
randomness: Fr,
|
|
118
|
+
noteNonce: Fr,
|
|
119
|
+
content: Fr[],
|
|
120
|
+
noteHash: Fr,
|
|
121
|
+
nullifier: Fr,
|
|
122
|
+
txHash: TxHash,
|
|
123
|
+
recipient: AztecAddress,
|
|
124
|
+
): Promise<void> {
|
|
125
|
+
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
126
|
+
// There's two things we need to check before we do this however:
|
|
127
|
+
// - we must make sure the note does actually exist in the note hash tree
|
|
128
|
+
// - we need to check if the note has already been nullified
|
|
129
|
+
//
|
|
130
|
+
// Failing to do either of the above would result in circuits getting either non-existent notes and failing to
|
|
131
|
+
// produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
|
|
132
|
+
// are catastrophic failure modes.
|
|
133
|
+
//
|
|
134
|
+
// Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
|
|
135
|
+
// emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
|
|
136
|
+
// so we must store both the note hash and nullifier block information.
|
|
137
|
+
|
|
138
|
+
// We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
|
|
139
|
+
// in time of the locally synced state.
|
|
140
|
+
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
141
|
+
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
142
|
+
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
143
|
+
// logs up to the synced block making this only an additional safety check.
|
|
144
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
145
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
146
|
+
|
|
147
|
+
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
148
|
+
// of other contracts, which would constitute a security breach.
|
|
149
|
+
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
150
|
+
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
151
|
+
|
|
152
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
153
|
+
this.aztecNode.getTxEffect(txHash),
|
|
154
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
155
|
+
]);
|
|
156
|
+
if (!txEffect) {
|
|
157
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
161
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
165
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
|
|
166
|
+
if (noteIndexInTx === -1) {
|
|
167
|
+
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const noteDao = new NoteDao(
|
|
171
|
+
new Note(content),
|
|
172
|
+
contractAddress,
|
|
173
|
+
owner,
|
|
174
|
+
storageSlot,
|
|
175
|
+
randomness,
|
|
176
|
+
noteNonce,
|
|
177
|
+
noteHash,
|
|
178
|
+
siloedNullifier,
|
|
179
|
+
txHash,
|
|
180
|
+
txEffect.l2BlockNumber,
|
|
181
|
+
txEffect.l2BlockHash.toString(),
|
|
182
|
+
txEffect.txIndexInBlock,
|
|
183
|
+
noteIndexInTx,
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
187
|
+
await this.noteStore.addNotes([noteDao], recipient, this.jobId);
|
|
188
|
+
|
|
189
|
+
if (nullifierIndex !== undefined) {
|
|
190
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
191
|
+
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
192
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
///
|
|
5
5
|
/// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 10;
|
|
8
8
|
|
|
9
9
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
10
|
-
/// which in turn implies that you need to update the ORACLE_VERSION constant
|
|
11
|
-
|
|
10
|
+
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
|
+
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = 'a3b284ee5abff0509986d6d2fa78a3e6e2ec212325674de78355c5e70b05784c';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
2
|
export * from './compute_tx_include_by_timestamp.js';
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@aztec/constants';
|
|
10
10
|
import { makeTuple } from '@aztec/foundation/array';
|
|
11
11
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
12
|
-
import type { Fr } from '@aztec/foundation/
|
|
12
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
14
14
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
15
15
|
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
@@ -138,7 +138,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
async build(oracle: PrivateKernelOracle
|
|
141
|
+
async build(oracle: PrivateKernelOracle) {
|
|
142
142
|
if (privateKernelResetDimensionNames.every(name => !this.requestedDimensions[name])) {
|
|
143
143
|
throw new Error('Reset is not required.');
|
|
144
144
|
}
|
|
@@ -157,16 +157,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
157
157
|
allowRemainder,
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
const previousVkMembershipWitness = await oracle.getVkMembershipWitness(
|
|
161
|
-
this.previousKernelOutput.verificationKey.keyAsFields,
|
|
162
|
-
);
|
|
163
|
-
const vkData = new VkData(
|
|
164
|
-
this.previousKernelOutput.verificationKey,
|
|
165
|
-
Number(previousVkMembershipWitness.leafIndex),
|
|
166
|
-
previousVkMembershipWitness.siblingPath,
|
|
167
|
-
);
|
|
168
|
-
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
169
|
-
|
|
170
160
|
this.reduceReadRequestActions(
|
|
171
161
|
this.noteHashResetActions,
|
|
172
162
|
dimensions.NOTE_HASH_PENDING_READ,
|
|
@@ -178,30 +168,51 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
178
168
|
dimensions.NULLIFIER_SETTLED_READ,
|
|
179
169
|
);
|
|
180
170
|
|
|
181
|
-
//
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
// Execute all the expensive node querying operations in parallel.
|
|
172
|
+
const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] =
|
|
173
|
+
await Promise.all([
|
|
174
|
+
oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
|
|
175
|
+
buildNoteHashReadRequestHintsFromResetActions<
|
|
176
|
+
typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
177
|
+
typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX
|
|
178
|
+
>(
|
|
189
179
|
oracle,
|
|
190
180
|
this.previousKernel.validationRequests.noteHashReadRequests,
|
|
191
181
|
this.previousKernel.end.noteHashes,
|
|
192
182
|
this.noteHashResetActions,
|
|
193
|
-
noteHashLeafIndexMap,
|
|
194
183
|
),
|
|
195
|
-
|
|
184
|
+
buildNullifierReadRequestHintsFromResetActions<
|
|
185
|
+
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
186
|
+
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX
|
|
187
|
+
>(
|
|
196
188
|
{ getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle) },
|
|
197
189
|
this.previousKernel.validationRequests.nullifierReadRequests,
|
|
198
190
|
this.nullifierResetActions,
|
|
199
191
|
),
|
|
200
|
-
|
|
192
|
+
getMasterSecretKeysAndAppKeyGenerators(
|
|
201
193
|
this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators,
|
|
202
194
|
dimensions.KEY_VALIDATION,
|
|
203
195
|
oracle,
|
|
204
196
|
),
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
const vkData = new VkData(
|
|
200
|
+
this.previousKernelOutput.verificationKey,
|
|
201
|
+
Number(previousVkMembershipWitness.leafIndex),
|
|
202
|
+
previousVkMembershipWitness.siblingPath,
|
|
203
|
+
);
|
|
204
|
+
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
205
|
+
|
|
206
|
+
// TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
|
|
207
|
+
const paddedSideEffects = PaddedSideEffects.empty();
|
|
208
|
+
|
|
209
|
+
return new PrivateKernelResetCircuitPrivateInputs(
|
|
210
|
+
previousKernelData,
|
|
211
|
+
paddedSideEffects,
|
|
212
|
+
new PrivateKernelResetHints(
|
|
213
|
+
noteHashReadRequestHints,
|
|
214
|
+
nullifierReadRequestHints,
|
|
215
|
+
keyValidationHints,
|
|
205
216
|
this.transientDataSquashingHints,
|
|
206
217
|
),
|
|
207
218
|
dimensions,
|