@aztec/pxe 0.0.1-commit.d3ec352c → 0.0.1-commit.fcb71a6
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 +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +19 -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 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +41 -12
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +49 -19
- package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -4
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +3 -3
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +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 +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 +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +7 -3
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +7 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +18 -7
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +8 -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 +25 -11
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +26 -14
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +51 -11
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +146 -40
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- 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.js +2 -2
- 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.js +1 -1
- 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 +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -4
- 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 +6 -5
- 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 +38 -46
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +135 -143
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.d.ts → anchor_block_store/anchor_block_store.d.ts} +2 -4
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -6
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +8 -5
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -3
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +10 -9
- 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} +16 -8
- 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} +37 -27
- 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 +16 -16
- package/src/bin/check_oracle_version.ts +130 -20
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +18 -22
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +3 -3
- package/src/contract_function_simulator/contract_function_simulator.ts +86 -17
- package/src/contract_function_simulator/execution_note_cache.ts +7 -4
- 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 +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +5 -5
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +17 -3
- package/src/contract_function_simulator/oracle/oracle.ts +21 -7
- package/src/contract_function_simulator/oracle/private_execution.ts +15 -14
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -22
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +213 -49
- 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 +2 -2
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +2 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -0
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +1 -1
- 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 +1 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +4 -4
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +8 -7
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +162 -181
- 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 -12
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +34 -2
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +65 -3
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +19 -10
- package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +60 -41
- 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 -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/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/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -36
- 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 -342
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
- 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/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
package/src/error_enriching.ts
CHANGED
|
@@ -4,18 +4,14 @@ import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/stdlib/errors';
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { ContractStore } from './storage/contract_store/contract_store.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Adds contract and function names to a simulation error, if they
|
|
11
11
|
* can be found in the PXE database
|
|
12
12
|
* @param err - The error to enrich.
|
|
13
13
|
*/
|
|
14
|
-
export async function enrichSimulationError(
|
|
15
|
-
err: SimulationError,
|
|
16
|
-
contractDataProvider: ContractDataProvider,
|
|
17
|
-
logger: Logger,
|
|
18
|
-
) {
|
|
14
|
+
export async function enrichSimulationError(err: SimulationError, contractStore: ContractStore, logger: Logger) {
|
|
19
15
|
// Maps contract addresses to the set of function selectors that were in error.
|
|
20
16
|
// Map and Set do reference equality for their keys instead of value equality, so we store the string
|
|
21
17
|
// representation to get e.g. different contract address objects with the same address value to match.
|
|
@@ -34,7 +30,7 @@ export async function enrichSimulationError(
|
|
|
34
30
|
await Promise.all(
|
|
35
31
|
[...mentionedFunctions.entries()].map(async ([contractAddress, fnSelectors]) => {
|
|
36
32
|
const parsedContractAddress = AztecAddress.fromString(contractAddress);
|
|
37
|
-
const contract = await
|
|
33
|
+
const contract = await contractStore.getContract(parsedContractAddress);
|
|
38
34
|
if (contract) {
|
|
39
35
|
err.enrichWithContractName(parsedContractAddress, contract.name);
|
|
40
36
|
// Map from function selector to function name. It uses a stringified key for the same reason as mentionedFunctions.
|
|
@@ -68,11 +64,7 @@ export async function enrichSimulationError(
|
|
|
68
64
|
);
|
|
69
65
|
}
|
|
70
66
|
|
|
71
|
-
export async function enrichPublicSimulationError(
|
|
72
|
-
err: SimulationError,
|
|
73
|
-
contractDataProvider: ContractDataProvider,
|
|
74
|
-
logger: Logger,
|
|
75
|
-
) {
|
|
67
|
+
export async function enrichPublicSimulationError(err: SimulationError, contractStore: ContractStore, logger: Logger) {
|
|
76
68
|
const callStack = err.getCallStack();
|
|
77
69
|
const originalFailingFunction = callStack[callStack.length - 1];
|
|
78
70
|
|
|
@@ -80,7 +72,7 @@ export async function enrichPublicSimulationError(
|
|
|
80
72
|
throw new Error(`Original failing function not found when enriching public simulation, missing callstack`);
|
|
81
73
|
}
|
|
82
74
|
|
|
83
|
-
const artifact = await
|
|
75
|
+
const artifact = await contractStore.getPublicFunctionArtifact(originalFailingFunction.contractAddress);
|
|
84
76
|
if (!artifact) {
|
|
85
77
|
throw new Error(
|
|
86
78
|
`Artifact not found when enriching public simulation error. Contract address: ${originalFailingFunction.contractAddress}.`,
|
|
@@ -92,7 +84,7 @@ export async function enrichPublicSimulationError(
|
|
|
92
84
|
err.setOriginalMessage(err.getOriginalMessage() + `${assertionMessage}`);
|
|
93
85
|
}
|
|
94
86
|
|
|
95
|
-
const debugInfo = await
|
|
87
|
+
const debugInfo = await contractStore.getPublicFunctionDebugMetadata(originalFailingFunction.contractAddress);
|
|
96
88
|
|
|
97
89
|
const noirCallStack = err.getNoirCallStack();
|
|
98
90
|
if (debugInfo) {
|
|
@@ -110,6 +102,6 @@ export async function enrichPublicSimulationError(
|
|
|
110
102
|
);
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
|
-
await enrichSimulationError(err,
|
|
105
|
+
await enrichSimulationError(err, contractStore, logger);
|
|
114
106
|
}
|
|
115
107
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
|
|
9
|
+
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
10
|
+
import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
11
|
+
|
|
12
|
+
export class EventService {
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
15
|
+
private readonly aztecNode: AztecNode,
|
|
16
|
+
private readonly privateEventStore: PrivateEventStore,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
public async deliverEvent(
|
|
20
|
+
contractAddress: AztecAddress,
|
|
21
|
+
selector: EventSelector,
|
|
22
|
+
content: Fr[],
|
|
23
|
+
eventCommitment: Fr,
|
|
24
|
+
txHash: TxHash,
|
|
25
|
+
scope: AztecAddress,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
// While using 'latest' block number would be fine for private events since they cannot be accessed from Aztec.nr
|
|
28
|
+
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
29
|
+
// maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
|
|
30
|
+
// since `fetchTaggedLogs` only processes logs up to the synced block.
|
|
31
|
+
const [syncedBlockHeader, siloedEventCommitment, txEffect] = await Promise.all([
|
|
32
|
+
this.anchorBlockStore.getBlockHeader(),
|
|
33
|
+
siloNullifier(contractAddress, eventCommitment),
|
|
34
|
+
this.aztecNode.getTxEffect(txHash),
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const syncedBlockNumber = syncedBlockHeader.getBlockNumber();
|
|
38
|
+
|
|
39
|
+
if (!txEffect) {
|
|
40
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (txEffect.l2BlockNumber > syncedBlockNumber) {
|
|
44
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const eventInTx = txEffect.data.nullifiers.some(n => n.equals(siloedEventCommitment));
|
|
48
|
+
if (!eventInTx) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present in tx ${txHash}`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const [nullifierIndex] = await this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
|
|
55
|
+
siloedEventCommitment,
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
if (nullifierIndex === undefined) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present on the nullifier tree at block ${syncedBlockNumber} (from tx ${txHash})`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return this.privateEventStore.storePrivateEventLog(
|
|
65
|
+
selector,
|
|
66
|
+
content,
|
|
67
|
+
Number(nullifierIndex.data), // Index of the event commitment in the nullifier tree
|
|
68
|
+
{
|
|
69
|
+
contractAddress,
|
|
70
|
+
scope,
|
|
71
|
+
txHash,
|
|
72
|
+
l2BlockNumber: nullifierIndex.l2BlockNumber, // Block number in which the event was emitted
|
|
73
|
+
l2BlockHash: nullifierIndex.l2BlockHash, // Block hash in which the event was emitted
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './private_event_filter_validator.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
|
|
5
|
+
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
6
|
+
import type { PrivateEventStoreFilter } from '../storage/private_event_store/private_event_store.js';
|
|
7
|
+
|
|
8
|
+
export class PrivateEventFilterValidator {
|
|
9
|
+
constructor(private anchorBlockStore: AnchorBlockStore) {}
|
|
10
|
+
|
|
11
|
+
async validate(filter: PrivateEventFilter): Promise<PrivateEventStoreFilter> {
|
|
12
|
+
let { fromBlock, toBlock } = filter;
|
|
13
|
+
|
|
14
|
+
// Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
|
|
15
|
+
// we respect that convention here for consistency.
|
|
16
|
+
// We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
|
|
17
|
+
// the first block to the latest known block.
|
|
18
|
+
if (!fromBlock || !toBlock) {
|
|
19
|
+
const lastKnownBlock = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
20
|
+
fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
|
|
21
|
+
toBlock = toBlock ?? BlockNumber(lastKnownBlock + 1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (filter.scopes.length === 0) {
|
|
25
|
+
throw new Error('At least one scope is required to get private events');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (fromBlock < 1) {
|
|
29
|
+
throw new Error('fromBlock must be greater than or equal to 1');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (toBlock < 1) {
|
|
33
|
+
throw new Error('toBlock must be greater than or equal to 1');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (fromBlock >= toBlock) {
|
|
37
|
+
throw new Error('toBlock must be strictly greater than fromBlock');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
contractAddress: filter.contractAddress,
|
|
42
|
+
scopes: filter.scopes,
|
|
43
|
+
txHash: filter.txHash,
|
|
44
|
+
toBlock,
|
|
45
|
+
fromBlock,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { 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
|
+
|
|
9
|
+
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
|
+
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
|
+
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
+
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_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 { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
17
|
+
|
|
18
|
+
export class LogService {
|
|
19
|
+
private log = createLogger('log_service');
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
private readonly aztecNode: AztecNode,
|
|
23
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
24
|
+
private readonly keyStore: KeyStore,
|
|
25
|
+
private readonly capsuleStore: CapsuleStore,
|
|
26
|
+
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
27
|
+
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
28
|
+
private readonly addressStore: AddressStore,
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
32
|
+
return await Promise.all(
|
|
33
|
+
logRetrievalRequests.map(async request => {
|
|
34
|
+
const [publicLog, privateLog] = await Promise.all([
|
|
35
|
+
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
36
|
+
this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
if (publicLog !== null && privateLog !== null) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return publicLog ?? privateLog;
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
51
|
+
const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
|
|
52
|
+
const logsForTag = logs[0];
|
|
53
|
+
|
|
54
|
+
if (logsForTag.length == 0) {
|
|
55
|
+
return null;
|
|
56
|
+
} else if (logsForTag.length > 1) {
|
|
57
|
+
// TODO(#11627): handle this case
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const scopedLog = logsForTag[0];
|
|
64
|
+
|
|
65
|
+
return new LogRetrievalResponse(
|
|
66
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
67
|
+
scopedLog.txHash,
|
|
68
|
+
scopedLog.noteHashes,
|
|
69
|
+
scopedLog.firstNullifier,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
74
|
+
const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
|
|
75
|
+
const logsForTag = logs[0];
|
|
76
|
+
|
|
77
|
+
if (logsForTag.length == 0) {
|
|
78
|
+
return null;
|
|
79
|
+
} else if (logsForTag.length > 1) {
|
|
80
|
+
// TODO(#11627): handle this case
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const scopedLog = logsForTag[0];
|
|
87
|
+
|
|
88
|
+
return new LogRetrievalResponse(
|
|
89
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
90
|
+
scopedLog.txHash,
|
|
91
|
+
scopedLog.noteHashes,
|
|
92
|
+
scopedLog.firstNullifier,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public async syncTaggedLogs(
|
|
97
|
+
contractAddress: AztecAddress,
|
|
98
|
+
pendingTaggedLogArrayBaseSlot: Fr,
|
|
99
|
+
scopes?: AztecAddress[],
|
|
100
|
+
) {
|
|
101
|
+
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
102
|
+
|
|
103
|
+
// We only load logs from block up to and including the anchor block number
|
|
104
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
105
|
+
|
|
106
|
+
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
107
|
+
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
108
|
+
|
|
109
|
+
// For each recipient, fetch secrets, load logs, and store them.
|
|
110
|
+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
111
|
+
await Promise.all(
|
|
112
|
+
recipients.map(async recipient => {
|
|
113
|
+
// Get all secrets for this recipient (one per sender)
|
|
114
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
115
|
+
|
|
116
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
117
|
+
const logArrays = await Promise.all(
|
|
118
|
+
secrets.map(secret =>
|
|
119
|
+
loadPrivateLogsForSenderRecipientPair(
|
|
120
|
+
secret,
|
|
121
|
+
contractAddress,
|
|
122
|
+
this.aztecNode,
|
|
123
|
+
this.recipientTaggingStore,
|
|
124
|
+
anchorBlockNumber,
|
|
125
|
+
),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Flatten all logs from all secrets
|
|
130
|
+
const allLogs = logArrays.flat();
|
|
131
|
+
|
|
132
|
+
// Store the logs for this recipient
|
|
133
|
+
if (allLogs.length > 0) {
|
|
134
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async #getSecretsForSenders(
|
|
141
|
+
contractAddress: AztecAddress,
|
|
142
|
+
recipient: AztecAddress,
|
|
143
|
+
): Promise<DirectionalAppTaggingSecret[]> {
|
|
144
|
+
const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
|
|
145
|
+
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
146
|
+
|
|
147
|
+
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
148
|
+
// (recipient = us, sender = us)
|
|
149
|
+
const allSenders = [...(await this.senderAddressBookStore.getSenders()), ...(await this.keyStore.getAccounts())];
|
|
150
|
+
|
|
151
|
+
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
152
|
+
const deduplicatedSenders = Array.from(new Set(allSenders.map(sender => sender.toString()))).map(sender =>
|
|
153
|
+
AztecAddress.fromString(sender),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return Promise.all(
|
|
157
|
+
deduplicatedSenders.map(sender => {
|
|
158
|
+
return DirectionalAppTaggingSecret.compute(
|
|
159
|
+
recipientCompleteAddress,
|
|
160
|
+
recipientIvsk,
|
|
161
|
+
sender,
|
|
162
|
+
contractAddress,
|
|
163
|
+
recipient,
|
|
164
|
+
);
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#storePendingTaggedLogs(
|
|
170
|
+
contractAddress: AztecAddress,
|
|
171
|
+
capsuleArrayBaseSlot: Fr,
|
|
172
|
+
recipient: AztecAddress,
|
|
173
|
+
privateLogs: TxScopedL2Log[],
|
|
174
|
+
) {
|
|
175
|
+
// Build all pending tagged logs from the scoped logs
|
|
176
|
+
const pendingTaggedLogs = privateLogs.map(scopedLog => {
|
|
177
|
+
const pendingTaggedLog = new PendingTaggedLog(
|
|
178
|
+
scopedLog.logData,
|
|
179
|
+
scopedLog.txHash,
|
|
180
|
+
scopedLog.noteHashes,
|
|
181
|
+
scopedLog.firstNullifier,
|
|
182
|
+
recipient,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return pendingTaggedLog.toFields();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// TODO: This looks like it could belong more at the oracle interface level
|
|
189
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
193
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
194
|
+
if (!completeAddress) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`No public key registered for address ${account}.
|
|
197
|
+
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`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return completeAddress;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NoteService } from './note_service.js';
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
11
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
|
+
|
|
13
|
+
export class NoteService {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly noteStore: NoteStore,
|
|
16
|
+
private readonly aztecNode: AztecNode,
|
|
17
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
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
|
+
contractAddress,
|
|
38
|
+
owner,
|
|
39
|
+
storageSlot,
|
|
40
|
+
status,
|
|
41
|
+
scopes,
|
|
42
|
+
});
|
|
43
|
+
return noteDaos.map(
|
|
44
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
|
|
45
|
+
contractAddress,
|
|
46
|
+
owner,
|
|
47
|
+
storageSlot,
|
|
48
|
+
randomness,
|
|
49
|
+
noteNonce,
|
|
50
|
+
note,
|
|
51
|
+
noteHash,
|
|
52
|
+
siloedNullifier,
|
|
53
|
+
// PXE can use this index to get full MembershipWitness
|
|
54
|
+
index,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
61
|
+
*
|
|
62
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
63
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
64
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
65
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
66
|
+
* block up to which the PXE has synced.
|
|
67
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
68
|
+
*
|
|
69
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
70
|
+
*/
|
|
71
|
+
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
72
|
+
const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
73
|
+
|
|
74
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress });
|
|
75
|
+
|
|
76
|
+
if (contractNotes.length === 0) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const nullifiersToCheck = contractNotes.map(note => note.siloedNullifier);
|
|
81
|
+
const nullifierBatches = nullifiersToCheck.reduce(
|
|
82
|
+
(acc, nullifier) => {
|
|
83
|
+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
|
|
84
|
+
acc[acc.length - 1].push(nullifier);
|
|
85
|
+
} else {
|
|
86
|
+
acc.push([nullifier]);
|
|
87
|
+
}
|
|
88
|
+
return acc;
|
|
89
|
+
},
|
|
90
|
+
[[]] as Fr[][],
|
|
91
|
+
);
|
|
92
|
+
const nullifierIndexes = (
|
|
93
|
+
await Promise.all(
|
|
94
|
+
nullifierBatches.map(batch =>
|
|
95
|
+
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch),
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
).flat();
|
|
99
|
+
|
|
100
|
+
const foundNullifiers = nullifiersToCheck
|
|
101
|
+
.map((nullifier, i) => {
|
|
102
|
+
if (nullifierIndexes[i] !== undefined) {
|
|
103
|
+
return { ...nullifierIndexes[i], ...{ data: nullifier } } as DataInBlock<Fr>;
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
107
|
+
|
|
108
|
+
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public async deliverNote(
|
|
112
|
+
contractAddress: AztecAddress,
|
|
113
|
+
owner: AztecAddress,
|
|
114
|
+
storageSlot: Fr,
|
|
115
|
+
randomness: Fr,
|
|
116
|
+
noteNonce: Fr,
|
|
117
|
+
content: Fr[],
|
|
118
|
+
noteHash: Fr,
|
|
119
|
+
nullifier: Fr,
|
|
120
|
+
txHash: TxHash,
|
|
121
|
+
recipient: AztecAddress,
|
|
122
|
+
): Promise<void> {
|
|
123
|
+
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
124
|
+
// There's two things we need to check before we do this however:
|
|
125
|
+
// - we must make sure the note does actually exist in the note hash tree
|
|
126
|
+
// - we need to check if the note has already been nullified
|
|
127
|
+
//
|
|
128
|
+
// Failing to do either of the above would result in circuits getting either non-existent notes and failing to
|
|
129
|
+
// produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
|
|
130
|
+
// are catastrophic failure modes.
|
|
131
|
+
//
|
|
132
|
+
// Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
|
|
133
|
+
// emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
|
|
134
|
+
// so we must store both the note hash and nullifier block information.
|
|
135
|
+
|
|
136
|
+
// We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
|
|
137
|
+
// in time of the locally synced state.
|
|
138
|
+
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
139
|
+
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
140
|
+
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
141
|
+
// logs up to the synced block making this only an additional safety check.
|
|
142
|
+
const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
143
|
+
|
|
144
|
+
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
145
|
+
// of other contracts, which would constitute a security breach.
|
|
146
|
+
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
147
|
+
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
148
|
+
|
|
149
|
+
const txEffect = await this.aztecNode.getTxEffect(txHash);
|
|
150
|
+
if (!txEffect) {
|
|
151
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (txEffect.l2BlockNumber > syncedBlockNumber) {
|
|
155
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const noteInTx = txEffect.data.noteHashes.some(nh => nh.equals(uniqueNoteHash));
|
|
159
|
+
if (!noteInTx) {
|
|
160
|
+
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// We store notes by their index in the global note hash tree, which has the convenient side effect of validating
|
|
164
|
+
// note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
|
|
165
|
+
// queries in a single round-trip.
|
|
166
|
+
const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
|
|
167
|
+
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]),
|
|
168
|
+
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
if (uniqueNoteHashTreeIndexInBlock === undefined) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const noteDao = new NoteDao(
|
|
178
|
+
new Note(content),
|
|
179
|
+
contractAddress,
|
|
180
|
+
owner,
|
|
181
|
+
storageSlot,
|
|
182
|
+
randomness,
|
|
183
|
+
noteNonce,
|
|
184
|
+
noteHash,
|
|
185
|
+
siloedNullifier,
|
|
186
|
+
txHash,
|
|
187
|
+
uniqueNoteHashTreeIndexInBlock.l2BlockNumber,
|
|
188
|
+
uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(),
|
|
189
|
+
uniqueNoteHashTreeIndexInBlock.data,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
193
|
+
await this.noteStore.addNotes([noteDao], recipient);
|
|
194
|
+
|
|
195
|
+
if (nullifierIndex !== undefined) {
|
|
196
|
+
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
197
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
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 = 5;
|
|
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
10
|
/// which in turn implies that you need to update the ORACLE_VERSION constant.
|
|
11
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
11
|
+
export const ORACLE_INTERFACE_HASH = 'd603c17a97034d978ca453d2bce3aacae139539dee28bbc46e8f8c7177a348ec';
|
|
@@ -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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
5
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -290,8 +290,8 @@ export class PrivateKernelExecutionProver {
|
|
|
290
290
|
},
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
// Hiding
|
|
294
|
-
// For simulation, we can end with the tail, since the
|
|
293
|
+
// Hiding kernel is only executed if we are generating witnesses.
|
|
294
|
+
// For simulation, we can end with the tail, since the Hiding kernel will simply return the same tail output.
|
|
295
295
|
if (generateWitnesses) {
|
|
296
296
|
const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
|
|
297
297
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
3
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
5
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|