@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/pxe.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -11,14 +12,11 @@ import {
|
|
|
11
12
|
type ContractArtifact,
|
|
12
13
|
EventSelector,
|
|
13
14
|
FunctionCall,
|
|
14
|
-
FunctionSelector,
|
|
15
15
|
FunctionType,
|
|
16
16
|
decodeFunctionSignature,
|
|
17
|
-
encodeArguments,
|
|
18
17
|
} from '@aztec/stdlib/abi';
|
|
19
18
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
-
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
20
|
import {
|
|
23
21
|
CompleteAddress,
|
|
24
22
|
type ContractClassWithId,
|
|
@@ -35,10 +33,9 @@ import type {
|
|
|
35
33
|
PrivateKernelExecutionProofOutput,
|
|
36
34
|
PrivateKernelTailCircuitPublicInputs,
|
|
37
35
|
} from '@aztec/stdlib/kernel';
|
|
38
|
-
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
39
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
40
36
|
import {
|
|
41
37
|
type ContractOverrides,
|
|
38
|
+
type InTx,
|
|
42
39
|
PrivateExecutionResult,
|
|
43
40
|
PrivateSimulationResult,
|
|
44
41
|
type ProvingTimings,
|
|
@@ -47,7 +44,6 @@ import {
|
|
|
47
44
|
type SimulationTimings,
|
|
48
45
|
Tx,
|
|
49
46
|
TxExecutionRequest,
|
|
50
|
-
TxHash,
|
|
51
47
|
TxProfileResult,
|
|
52
48
|
TxProvingResult,
|
|
53
49
|
TxSimulationResult,
|
|
@@ -56,36 +52,34 @@ import {
|
|
|
56
52
|
|
|
57
53
|
import { inspect } from 'util';
|
|
58
54
|
|
|
55
|
+
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
59
56
|
import type { PXEConfig } from './config/index.js';
|
|
60
57
|
import {
|
|
61
58
|
ContractFunctionSimulator,
|
|
62
59
|
generateSimulatedProvingResult,
|
|
63
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
64
61
|
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
62
|
+
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
|
+
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
68
64
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
65
|
+
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
69
66
|
import {
|
|
70
67
|
PrivateKernelExecutionProver,
|
|
71
68
|
type PrivateKernelExecutionProverConfig,
|
|
72
69
|
} from './private_kernel/private_kernel_execution_prover.js';
|
|
73
70
|
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
import { AddressStore } from './storage/address_store/address_store.js';
|
|
72
|
+
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
73
|
+
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
74
|
+
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
75
|
+
import { NoteStore } from './storage/note_store/note_store.js';
|
|
76
|
+
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
77
|
+
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
78
|
+
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
79
|
+
import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
|
|
80
|
+
|
|
81
|
+
export type PackedPrivateEvent = InTx & {
|
|
84
82
|
packedEvent: Fr[];
|
|
85
|
-
blockNumber: number;
|
|
86
|
-
blockHash: L2BlockHash;
|
|
87
|
-
txHash: TxHash;
|
|
88
|
-
recipient: AztecAddress;
|
|
89
83
|
eventSelector: EventSelector;
|
|
90
84
|
};
|
|
91
85
|
|
|
@@ -96,21 +90,24 @@ export type PrivateEvent = {
|
|
|
96
90
|
export class PXE {
|
|
97
91
|
private constructor(
|
|
98
92
|
private node: AztecNode,
|
|
99
|
-
private
|
|
93
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
100
94
|
private keyStore: KeyStore,
|
|
101
|
-
private
|
|
102
|
-
private
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
107
|
-
private
|
|
95
|
+
private contractStore: ContractStore,
|
|
96
|
+
private noteStore: NoteStore,
|
|
97
|
+
private capsuleStore: CapsuleStore,
|
|
98
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
99
|
+
private senderTaggingStore: SenderTaggingStore,
|
|
100
|
+
private senderAddressBookStore: SenderAddressBookStore,
|
|
101
|
+
private recipientTaggingStore: RecipientTaggingStore,
|
|
102
|
+
private addressStore: AddressStore,
|
|
103
|
+
private privateEventStore: PrivateEventStore,
|
|
108
104
|
private simulator: CircuitSimulator,
|
|
109
105
|
private proverEnabled: boolean,
|
|
110
106
|
private proofCreator: PrivateKernelProver,
|
|
111
107
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
112
108
|
private log: Logger,
|
|
113
109
|
private jobQueue: SerialQueue,
|
|
110
|
+
public debug: PXEDebugUtils,
|
|
114
111
|
) {}
|
|
115
112
|
|
|
116
113
|
/**
|
|
@@ -135,24 +132,20 @@ export class PXE {
|
|
|
135
132
|
: loggerOrSuffix;
|
|
136
133
|
|
|
137
134
|
const proverEnabled = !!config.proverEnabled;
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const
|
|
135
|
+
const addressStore = new AddressStore(store);
|
|
136
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
137
|
+
const contractStore = new ContractStore(store);
|
|
138
|
+
const noteStore = await NoteStore.create(store);
|
|
139
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
140
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
141
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
142
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
143
|
+
const capsuleStore = new CapsuleStore(store);
|
|
145
144
|
const keyStore = new KeyStore(store);
|
|
146
145
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
147
|
-
const synchronizer = new
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
noteDataProvider,
|
|
151
|
-
taggingDataProvider,
|
|
152
|
-
tipsStore,
|
|
153
|
-
config,
|
|
154
|
-
loggerOrSuffix,
|
|
155
|
-
);
|
|
146
|
+
const synchronizer = new BlockSynchronizer(node, anchorBlockStore, noteStore, tipsStore, config, loggerOrSuffix);
|
|
147
|
+
|
|
148
|
+
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
156
149
|
|
|
157
150
|
const jobQueue = new SerialQueue();
|
|
158
151
|
|
|
@@ -160,21 +153,26 @@ export class PXE {
|
|
|
160
153
|
node,
|
|
161
154
|
synchronizer,
|
|
162
155
|
keyStore,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
156
|
+
contractStore,
|
|
157
|
+
noteStore,
|
|
158
|
+
capsuleStore,
|
|
159
|
+
anchorBlockStore,
|
|
160
|
+
senderTaggingStore,
|
|
161
|
+
senderAddressBookStore,
|
|
162
|
+
recipientTaggingStore,
|
|
163
|
+
addressStore,
|
|
164
|
+
privateEventStore,
|
|
170
165
|
simulator,
|
|
171
166
|
proverEnabled,
|
|
172
167
|
proofCreator,
|
|
173
168
|
protocolContractsProvider,
|
|
174
169
|
log,
|
|
175
170
|
jobQueue,
|
|
171
|
+
debugUtils,
|
|
176
172
|
);
|
|
177
173
|
|
|
174
|
+
debugUtils.setPXE(pxe);
|
|
175
|
+
|
|
178
176
|
pxe.jobQueue.start();
|
|
179
177
|
|
|
180
178
|
await pxe.#registerProtocolContracts();
|
|
@@ -186,19 +184,22 @@ export class PXE {
|
|
|
186
184
|
// Internal methods
|
|
187
185
|
|
|
188
186
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
189
|
-
const
|
|
190
|
-
|
|
187
|
+
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
188
|
+
|
|
189
|
+
return new ContractFunctionSimulator(
|
|
190
|
+
proxyContractStore,
|
|
191
|
+
this.noteStore,
|
|
191
192
|
this.keyStore,
|
|
192
|
-
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
196
|
-
this.
|
|
197
|
-
this.
|
|
198
|
-
this.
|
|
199
|
-
this.
|
|
193
|
+
this.addressStore,
|
|
194
|
+
this.node,
|
|
195
|
+
this.anchorBlockStore,
|
|
196
|
+
this.senderTaggingStore,
|
|
197
|
+
this.recipientTaggingStore,
|
|
198
|
+
this.senderAddressBookStore,
|
|
199
|
+
this.capsuleStore,
|
|
200
|
+
this.privateEventStore,
|
|
201
|
+
this.simulator,
|
|
200
202
|
);
|
|
201
|
-
return new ContractFunctionSimulator(pxeOracleInterface, this.simulator);
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -237,8 +238,8 @@ export class PXE {
|
|
|
237
238
|
for (const name of protocolContractNames) {
|
|
238
239
|
const { address, contractClass, instance, artifact } =
|
|
239
240
|
await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
240
|
-
await this.
|
|
241
|
-
await this.
|
|
241
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
242
|
+
await this.contractStore.addContractInstance(instance);
|
|
242
243
|
registered[name] = address.toString();
|
|
243
244
|
}
|
|
244
245
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
@@ -257,31 +258,6 @@ export class PXE {
|
|
|
257
258
|
return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
|
|
258
259
|
}
|
|
259
260
|
|
|
260
|
-
async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
261
|
-
const contract = await this.contractDataProvider.getContract(to);
|
|
262
|
-
if (!contract) {
|
|
263
|
-
throw new Error(
|
|
264
|
-
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
269
|
-
if (!functionDao) {
|
|
270
|
-
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
name: functionDao.name,
|
|
275
|
-
args: encodeArguments(functionDao, args),
|
|
276
|
-
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
277
|
-
type: functionDao.functionType,
|
|
278
|
-
to,
|
|
279
|
-
hideMsgSender: false,
|
|
280
|
-
isStatic: functionDao.isStatic,
|
|
281
|
-
returnTypes: functionDao.returnTypes,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
261
|
// Executes the entrypoint private function, as well as all nested private
|
|
286
262
|
// functions that might arise.
|
|
287
263
|
async #executePrivate(
|
|
@@ -292,11 +268,14 @@ export class PXE {
|
|
|
292
268
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
293
269
|
|
|
294
270
|
try {
|
|
271
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
272
|
+
|
|
295
273
|
const result = await contractFunctionSimulator.run(
|
|
296
274
|
txRequest,
|
|
297
275
|
contractAddress,
|
|
298
276
|
functionSelector,
|
|
299
277
|
undefined,
|
|
278
|
+
anchorBlockHeader,
|
|
300
279
|
// The sender for tags is set by contracts, typically by an account
|
|
301
280
|
// contract entrypoint
|
|
302
281
|
undefined, // senderForTags
|
|
@@ -306,7 +285,7 @@ export class PXE {
|
|
|
306
285
|
return result;
|
|
307
286
|
} catch (err) {
|
|
308
287
|
if (err instanceof SimulationError) {
|
|
309
|
-
await enrichSimulationError(err, this.
|
|
288
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
310
289
|
}
|
|
311
290
|
throw err;
|
|
312
291
|
}
|
|
@@ -328,10 +307,11 @@ export class PXE {
|
|
|
328
307
|
scopes?: AztecAddress[],
|
|
329
308
|
) {
|
|
330
309
|
try {
|
|
331
|
-
|
|
310
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
311
|
+
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
|
|
332
312
|
} catch (err) {
|
|
333
313
|
if (err instanceof SimulationError) {
|
|
334
|
-
await enrichSimulationError(err, this.
|
|
314
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
335
315
|
}
|
|
336
316
|
throw err;
|
|
337
317
|
}
|
|
@@ -355,7 +335,7 @@ export class PXE {
|
|
|
355
335
|
} catch (err) {
|
|
356
336
|
if (err instanceof SimulationError) {
|
|
357
337
|
try {
|
|
358
|
-
await enrichPublicSimulationError(err, this.
|
|
338
|
+
await enrichPublicSimulationError(err, this.contractStore, this.log);
|
|
359
339
|
} catch (enrichErr) {
|
|
360
340
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
361
341
|
}
|
|
@@ -383,7 +363,7 @@ export class PXE {
|
|
|
383
363
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
384
364
|
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
385
365
|
const kernelOracle = new PrivateKernelOracleImpl(
|
|
386
|
-
this.
|
|
366
|
+
this.contractStore,
|
|
387
367
|
this.keyStore,
|
|
388
368
|
this.node,
|
|
389
369
|
simulationAnchorBlock,
|
|
@@ -396,7 +376,7 @@ export class PXE {
|
|
|
396
376
|
// Public API
|
|
397
377
|
|
|
398
378
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
399
|
-
return this.
|
|
379
|
+
return this.contractStore.getContractInstance(address);
|
|
400
380
|
}
|
|
401
381
|
|
|
402
382
|
/**
|
|
@@ -421,7 +401,7 @@ export class PXE {
|
|
|
421
401
|
isContractClassPubliclyRegistered: boolean;
|
|
422
402
|
artifact: ContractArtifact | undefined;
|
|
423
403
|
}> {
|
|
424
|
-
const artifact = await this.
|
|
404
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
425
405
|
if (!artifact) {
|
|
426
406
|
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
427
407
|
}
|
|
@@ -451,7 +431,7 @@ export class PXE {
|
|
|
451
431
|
}> {
|
|
452
432
|
let instance;
|
|
453
433
|
try {
|
|
454
|
-
instance = await this.
|
|
434
|
+
instance = await this.contractStore.getContractInstance(address);
|
|
455
435
|
} catch {
|
|
456
436
|
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
457
437
|
}
|
|
@@ -483,56 +463,58 @@ export class PXE {
|
|
|
483
463
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
484
464
|
}
|
|
485
465
|
|
|
486
|
-
await this.
|
|
487
|
-
await this.
|
|
466
|
+
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
467
|
+
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
488
468
|
return accountCompleteAddress;
|
|
489
469
|
}
|
|
490
470
|
|
|
491
471
|
/**
|
|
492
|
-
* Registers a
|
|
472
|
+
* Registers a sender in this PXE.
|
|
493
473
|
*
|
|
494
|
-
*
|
|
495
|
-
* Will do nothing if the
|
|
474
|
+
* After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
|
|
475
|
+
* Will do nothing if the address is already registered.
|
|
496
476
|
*
|
|
497
|
-
* @param
|
|
498
|
-
* @returns The address
|
|
477
|
+
* @param sender - Address of the sender to register.
|
|
478
|
+
* @returns The address of the sender.
|
|
479
|
+
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
499
480
|
*/
|
|
500
|
-
public async registerSender(
|
|
481
|
+
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
501
482
|
const accounts = await this.keyStore.getAccounts();
|
|
502
|
-
if (accounts.includes(
|
|
503
|
-
this.log.info(`Sender:\n "${
|
|
504
|
-
return
|
|
483
|
+
if (accounts.includes(sender)) {
|
|
484
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
485
|
+
return sender;
|
|
505
486
|
}
|
|
506
487
|
|
|
507
|
-
const wasAdded = await this.
|
|
488
|
+
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
508
489
|
|
|
509
490
|
if (wasAdded) {
|
|
510
|
-
this.log.info(`Added sender:\n ${
|
|
491
|
+
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
511
492
|
} else {
|
|
512
|
-
this.log.info(`Sender:\n "${
|
|
493
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
513
494
|
}
|
|
514
495
|
|
|
515
|
-
return
|
|
496
|
+
return sender;
|
|
516
497
|
}
|
|
517
498
|
|
|
518
499
|
/**
|
|
519
|
-
* Retrieves
|
|
520
|
-
* @returns
|
|
500
|
+
* Retrieves senders registered in this PXE.
|
|
501
|
+
* @returns Senders registered in this PXE.
|
|
521
502
|
*/
|
|
522
503
|
public getSenders(): Promise<AztecAddress[]> {
|
|
523
|
-
return this.
|
|
504
|
+
return this.senderAddressBookStore.getSenders();
|
|
524
505
|
}
|
|
525
506
|
|
|
526
507
|
/**
|
|
527
|
-
* Removes a sender in
|
|
508
|
+
* Removes a sender registered in this PXE.
|
|
509
|
+
* @param sender - The address of the sender to remove.
|
|
528
510
|
*/
|
|
529
|
-
public async removeSender(
|
|
530
|
-
const wasRemoved = await this.
|
|
511
|
+
public async removeSender(sender: AztecAddress): Promise<void> {
|
|
512
|
+
const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
|
|
531
513
|
|
|
532
514
|
if (wasRemoved) {
|
|
533
|
-
this.log.info(`Removed sender:\n ${
|
|
515
|
+
this.log.info(`Removed sender:\n ${sender.toString()}`);
|
|
534
516
|
} else {
|
|
535
|
-
this.log.info(`Sender:\n "${
|
|
517
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
|
|
536
518
|
}
|
|
537
519
|
}
|
|
538
520
|
|
|
@@ -542,7 +524,7 @@ export class PXE {
|
|
|
542
524
|
*/
|
|
543
525
|
public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
544
526
|
// Get complete addresses of both the recipients and the accounts
|
|
545
|
-
const completeAddresses = await this.
|
|
527
|
+
const completeAddresses = await this.addressStore.getCompleteAddresses();
|
|
546
528
|
// Filter out the addresses not corresponding to accounts
|
|
547
529
|
const accounts = await this.keyStore.getAccounts();
|
|
548
530
|
return completeAddresses.filter(completeAddress =>
|
|
@@ -557,7 +539,7 @@ export class PXE {
|
|
|
557
539
|
*/
|
|
558
540
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
559
541
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
560
|
-
await this.
|
|
542
|
+
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
561
543
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
562
544
|
}
|
|
563
545
|
|
|
@@ -586,7 +568,7 @@ export class PXE {
|
|
|
586
568
|
if (!computedAddress.equals(instance.address)) {
|
|
587
569
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
588
570
|
}
|
|
589
|
-
await this.
|
|
571
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
590
572
|
|
|
591
573
|
const publicFunctionSignatures = artifact.functions
|
|
592
574
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -594,7 +576,7 @@ export class PXE {
|
|
|
594
576
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
595
577
|
} else {
|
|
596
578
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
597
|
-
artifact = await this.
|
|
579
|
+
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
598
580
|
if (!artifact) {
|
|
599
581
|
throw new Error(
|
|
600
582
|
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
@@ -602,7 +584,7 @@ export class PXE {
|
|
|
602
584
|
}
|
|
603
585
|
}
|
|
604
586
|
|
|
605
|
-
await this.
|
|
587
|
+
await this.contractStore.addContractInstance(instance);
|
|
606
588
|
this.log.info(
|
|
607
589
|
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
608
590
|
);
|
|
@@ -621,14 +603,14 @@ export class PXE {
|
|
|
621
603
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
622
604
|
// class while we're simulating it.
|
|
623
605
|
return this.#putInJobQueue(async () => {
|
|
624
|
-
const currentInstance = await this.
|
|
606
|
+
const currentInstance = await this.contractStore.getContractInstance(contractAddress);
|
|
625
607
|
if (!currentInstance) {
|
|
626
608
|
throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
|
|
627
609
|
}
|
|
628
610
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
629
|
-
await this.
|
|
611
|
+
await this.blockStateSynchronizer.sync();
|
|
630
612
|
|
|
631
|
-
const header = await this.
|
|
613
|
+
const header = await this.anchorBlockStore.getBlockHeader();
|
|
632
614
|
|
|
633
615
|
const currentClassId = await readCurrentClassId(
|
|
634
616
|
contractAddress,
|
|
@@ -641,7 +623,7 @@ export class PXE {
|
|
|
641
623
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
642
624
|
}
|
|
643
625
|
|
|
644
|
-
await this.
|
|
626
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
645
627
|
|
|
646
628
|
const publicFunctionSignatures = artifact.functions
|
|
647
629
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -649,7 +631,7 @@ export class PXE {
|
|
|
649
631
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
650
632
|
|
|
651
633
|
currentInstance.currentContractClassId = contractClass.id;
|
|
652
|
-
await this.
|
|
634
|
+
await this.contractStore.addContractInstance(currentInstance);
|
|
653
635
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
654
636
|
});
|
|
655
637
|
}
|
|
@@ -659,26 +641,7 @@ export class PXE {
|
|
|
659
641
|
* @returns An array of contracts addresses registered on this PXE.
|
|
660
642
|
*/
|
|
661
643
|
public getContracts(): Promise<AztecAddress[]> {
|
|
662
|
-
return this.
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* A debugging utility to get notes based on the provided filter.
|
|
667
|
-
*
|
|
668
|
-
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
669
|
-
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
670
|
-
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
671
|
-
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
672
|
-
*
|
|
673
|
-
* @param filter - The filter to apply to the notes.
|
|
674
|
-
* @returns The requested notes.
|
|
675
|
-
*/
|
|
676
|
-
public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
677
|
-
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
678
|
-
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
679
|
-
await this.simulateUtility(call);
|
|
680
|
-
|
|
681
|
-
return this.noteDataProvider.getNotes(filter);
|
|
644
|
+
return this.contractStore.getContractsAddresses();
|
|
682
645
|
}
|
|
683
646
|
|
|
684
647
|
/**
|
|
@@ -698,7 +661,7 @@ export class PXE {
|
|
|
698
661
|
const totalTimer = new Timer();
|
|
699
662
|
try {
|
|
700
663
|
const syncTimer = new Timer();
|
|
701
|
-
await this.
|
|
664
|
+
await this.blockStateSynchronizer.sync();
|
|
702
665
|
const syncTime = syncTimer.ms();
|
|
703
666
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
704
667
|
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
@@ -738,14 +701,22 @@ export class PXE {
|
|
|
738
701
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
739
702
|
});
|
|
740
703
|
|
|
704
|
+
// While not strictly necessary to store tagging cache contents in the DB since we sync tagging indexes from
|
|
705
|
+
// chain before sending new logs, the sync can only see logs already included in blocks. If we send another
|
|
706
|
+
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
707
|
+
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
708
|
+
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
741
709
|
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
742
710
|
if (preTagsUsedInTheTx.length > 0) {
|
|
743
|
-
|
|
744
|
-
|
|
711
|
+
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
712
|
+
const txHash = (await txProvingResult.toTx()).txHash;
|
|
713
|
+
|
|
714
|
+
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash);
|
|
715
|
+
this.log.debug(`Stored used pre-tags as sender for the tx`, {
|
|
745
716
|
preTagsUsedInTheTx,
|
|
746
717
|
});
|
|
747
718
|
} else {
|
|
748
|
-
this.log.debug(`No pre
|
|
719
|
+
this.log.debug(`No pre-tags used in the tx`);
|
|
749
720
|
}
|
|
750
721
|
|
|
751
722
|
return txProvingResult;
|
|
@@ -786,7 +757,7 @@ export class PXE {
|
|
|
786
757
|
txInfo,
|
|
787
758
|
);
|
|
788
759
|
const syncTimer = new Timer();
|
|
789
|
-
await this.
|
|
760
|
+
await this.blockStateSynchronizer.sync();
|
|
790
761
|
const syncTime = syncTimer.ms();
|
|
791
762
|
|
|
792
763
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -886,7 +857,7 @@ export class PXE {
|
|
|
886
857
|
txInfo,
|
|
887
858
|
);
|
|
888
859
|
const syncTimer = new Timer();
|
|
889
|
-
await this.
|
|
860
|
+
await this.blockStateSynchronizer.sync();
|
|
890
861
|
const syncTime = syncTimer.ms();
|
|
891
862
|
|
|
892
863
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
@@ -910,7 +881,7 @@ export class PXE {
|
|
|
910
881
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
911
882
|
privateExecutionResult,
|
|
912
883
|
nonceGenerator,
|
|
913
|
-
this.
|
|
884
|
+
this.contractStore,
|
|
914
885
|
));
|
|
915
886
|
} else {
|
|
916
887
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -1015,10 +986,15 @@ export class PXE {
|
|
|
1015
986
|
try {
|
|
1016
987
|
const totalTimer = new Timer();
|
|
1017
988
|
const syncTimer = new Timer();
|
|
1018
|
-
await this.
|
|
989
|
+
await this.blockStateSynchronizer.sync();
|
|
1019
990
|
const syncTime = syncTimer.ms();
|
|
1020
991
|
const functionTimer = new Timer();
|
|
1021
992
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
993
|
+
|
|
994
|
+
await this.contractStore.syncPrivateState(call.to, call.selector, privateSyncCall =>
|
|
995
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
996
|
+
);
|
|
997
|
+
|
|
1022
998
|
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
1023
999
|
const functionTime = functionTimer.ms();
|
|
1024
1000
|
|
|
@@ -1049,31 +1025,36 @@ export class PXE {
|
|
|
1049
1025
|
|
|
1050
1026
|
/**
|
|
1051
1027
|
* Returns the private events given search parameters.
|
|
1052
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
1053
1028
|
* @param eventSelector - Event selector to search for.
|
|
1054
|
-
* @param
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1029
|
+
* @param filter
|
|
1030
|
+
* contractAddress - The address of the contract to get events from. Required.
|
|
1031
|
+
* scopes - One or more event scope addresses to filter by. Required.
|
|
1032
|
+
* fromBlock - The block number to search from (inclusive). Optional. If provided, it must be >= 0.
|
|
1033
|
+
* Defaults to 0.
|
|
1034
|
+
* If toBlock is defined but fromBlock is not, fromBlock defaults to toBlock - 1.
|
|
1035
|
+
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
1036
|
+
* Defaults to the latest known block to PXE + 1.
|
|
1057
1037
|
* @returns - The packed events with block and tx metadata.
|
|
1058
1038
|
*/
|
|
1059
|
-
public
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
numBlocks: number,
|
|
1064
|
-
recipients: AztecAddress[],
|
|
1065
|
-
): Promise<PrivateEvent[]> {
|
|
1066
|
-
if (recipients.length === 0) {
|
|
1067
|
-
throw new Error('Recipients are required to get private events');
|
|
1068
|
-
}
|
|
1039
|
+
public getPrivateEvents(eventSelector: EventSelector, filter: PrivateEventFilter): Promise<PackedPrivateEvent[]> {
|
|
1040
|
+
return this.#putInJobQueue(async () => {
|
|
1041
|
+
await this.blockStateSynchronizer.sync();
|
|
1042
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1069
1043
|
|
|
1070
|
-
|
|
1044
|
+
await this.contractStore.syncPrivateState(
|
|
1045
|
+
filter.contractAddress,
|
|
1046
|
+
null,
|
|
1047
|
+
async privateSyncCall => await this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1048
|
+
);
|
|
1049
|
+
|
|
1050
|
+
const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockStore).validate(filter);
|
|
1071
1051
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1052
|
+
this.log.debug(
|
|
1053
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1054
|
+
);
|
|
1075
1055
|
|
|
1076
|
-
|
|
1056
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1057
|
+
});
|
|
1077
1058
|
}
|
|
1078
1059
|
|
|
1079
1060
|
/**
|