@aztec/pxe 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +1 -1
- package/dest/bin/check_oracle_version.js +110 -10
- package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +23 -23
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +9 -17
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +10 -16
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +44 -15
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +142 -57
- package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +28 -17
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +101 -81
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +11 -12
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +15 -24
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +51 -25
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +103 -27
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +65 -36
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +171 -69
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +20 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -2
- package/dest/entrypoints/server/utils.d.ts +5 -24
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +17 -45
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +9 -6
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +47 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +9 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +39 -0
- package/dest/logs/log_service.d.ts +26 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +120 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/index.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
- 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 +10 -9
- 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 +232 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +299 -324
- 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 -4
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -12
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +34 -10
- 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} +10 -18
- 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 -18
- 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 -9
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -8
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +84 -0
- 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} +144 -82
- package/dest/storage/private_event_store/private_event_store.d.ts +56 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +157 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
- package/dest/tagging/index.d.ts +16 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +23 -0
- 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 +22 -24
- package/src/bin/check_oracle_version.ts +134 -10
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +22 -23
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +18 -32
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +233 -75
- package/src/contract_function_simulator/execution_note_cache.ts +33 -17
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +3 -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 +10 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
- package/src/contract_function_simulator/oracle/oracle.ts +135 -80
- package/src/contract_function_simulator/oracle/private_execution.ts +22 -28
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +200 -56
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +260 -109
- 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 +3 -2
- package/src/entrypoints/client/bundle/utils.ts +21 -23
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +20 -23
- package/src/entrypoints/pxe_creation_options.ts +4 -1
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +20 -68
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +11 -15
- package/src/events/event_service.ts +77 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +48 -0
- package/src/logs/log_service.ts +202 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +10 -9
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +349 -410
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -7
- 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 -17
- 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 -12
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +67 -28
- 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 -8
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +173 -111
- package/src/storage/private_event_store/private_event_store.ts +213 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
- package/src/tagging/index.ts +28 -0
- 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/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -48
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -285
- 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/oracle/typed_oracle.d.ts +0 -87
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -158
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
- package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
- package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
- package/dest/contract_function_simulator/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -100
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
- 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 -27
- 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/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -96
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
- 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 -18
- 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 -82
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -35
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -62
- package/src/contract_function_simulator/execution_data_provider.ts +0 -361
- package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1020
- package/src/contract_function_simulator/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- 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/data_provider.ts +0 -3
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_dao.ts +0 -154
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -134
- 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 -123
- package/src/synchronizer/index.ts +0 -1
- package/src/test/pxe_test_suite.ts +0 -113
|
@@ -1,64 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
6
|
-
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
7
6
|
import { KeyStore } from '@aztec/key-store';
|
|
8
7
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
8
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
10
|
-
import {
|
|
11
|
-
ProtocolContractAddress,
|
|
12
|
-
type ProtocolContractsProvider,
|
|
13
|
-
protocolContractNames,
|
|
14
|
-
} from '@aztec/protocol-contracts';
|
|
9
|
+
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
15
10
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
16
11
|
import {
|
|
17
12
|
type ContractArtifact,
|
|
18
13
|
EventSelector,
|
|
19
14
|
FunctionCall,
|
|
20
|
-
FunctionSelector,
|
|
21
15
|
FunctionType,
|
|
22
|
-
decodeFromAbi,
|
|
23
16
|
decodeFunctionSignature,
|
|
24
|
-
encodeArguments,
|
|
25
17
|
} from '@aztec/stdlib/abi';
|
|
26
18
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
27
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
28
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
29
20
|
import {
|
|
30
21
|
CompleteAddress,
|
|
31
22
|
type ContractClassWithId,
|
|
32
23
|
type ContractInstanceWithAddress,
|
|
33
|
-
type NodeInfo,
|
|
34
24
|
type PartialAddress,
|
|
35
25
|
computeContractAddressFromInstance,
|
|
36
26
|
getContractClassFromArtifact,
|
|
37
27
|
} from '@aztec/stdlib/contract';
|
|
38
28
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
39
|
-
import
|
|
40
|
-
import {
|
|
41
|
-
import type {
|
|
42
|
-
AztecNode,
|
|
43
|
-
EventMetadataDefinition,
|
|
44
|
-
GetContractClassLogsResponse,
|
|
45
|
-
GetPublicLogsResponse,
|
|
46
|
-
PXE,
|
|
47
|
-
PXEInfo,
|
|
48
|
-
PrivateKernelProver,
|
|
49
|
-
} from '@aztec/stdlib/interfaces/client';
|
|
29
|
+
import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
30
|
+
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
50
31
|
import type {
|
|
51
32
|
PrivateExecutionStep,
|
|
52
33
|
PrivateKernelExecutionProofOutput,
|
|
53
34
|
PrivateKernelTailCircuitPublicInputs,
|
|
54
35
|
} from '@aztec/stdlib/kernel';
|
|
55
|
-
import type { LogFilter } from '@aztec/stdlib/logs';
|
|
56
|
-
import { computeL2ToL1MembershipWitness, getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
57
|
-
import { type NotesFilter, UniqueNote } from '@aztec/stdlib/note';
|
|
58
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
59
36
|
import {
|
|
60
37
|
type ContractOverrides,
|
|
61
|
-
type
|
|
38
|
+
type InTx,
|
|
62
39
|
PrivateExecutionResult,
|
|
63
40
|
PrivateSimulationResult,
|
|
64
41
|
type ProvingTimings,
|
|
@@ -67,73 +44,78 @@ import {
|
|
|
67
44
|
type SimulationTimings,
|
|
68
45
|
Tx,
|
|
69
46
|
TxExecutionRequest,
|
|
70
|
-
type TxHash,
|
|
71
47
|
TxProfileResult,
|
|
72
48
|
TxProvingResult,
|
|
73
|
-
type TxReceipt,
|
|
74
49
|
TxSimulationResult,
|
|
75
50
|
UtilitySimulationResult,
|
|
76
51
|
} from '@aztec/stdlib/tx';
|
|
77
52
|
|
|
78
53
|
import { inspect } from 'util';
|
|
79
54
|
|
|
80
|
-
import
|
|
81
|
-
import {
|
|
55
|
+
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
|
+
import type { PXEConfig } from './config/index.js';
|
|
82
57
|
import {
|
|
83
58
|
ContractFunctionSimulator,
|
|
84
59
|
generateSimulatedProvingResult,
|
|
85
|
-
} from '
|
|
86
|
-
import { readCurrentClassId } from '
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
60
|
+
} from './contract_function_simulator/contract_function_simulator.js';
|
|
61
|
+
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
62
|
+
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
|
+
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
64
|
+
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
65
|
+
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
90
66
|
import {
|
|
91
67
|
PrivateKernelExecutionProver,
|
|
92
68
|
type PrivateKernelExecutionProverConfig,
|
|
93
|
-
} from '
|
|
94
|
-
import { PrivateKernelOracleImpl } from '
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
69
|
+
} from './private_kernel/private_kernel_execution_prover.js';
|
|
70
|
+
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
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 & {
|
|
82
|
+
packedEvent: Fr[];
|
|
83
|
+
eventSelector: EventSelector;
|
|
84
|
+
};
|
|
104
85
|
|
|
105
86
|
/**
|
|
106
|
-
*
|
|
87
|
+
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
88
|
+
* manage private state of users.
|
|
107
89
|
*/
|
|
108
|
-
export class
|
|
109
|
-
#nodeInfo?: NodeInfo;
|
|
110
|
-
|
|
90
|
+
export class PXE {
|
|
111
91
|
private constructor(
|
|
112
92
|
private node: AztecNode,
|
|
113
|
-
private
|
|
93
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
114
94
|
private keyStore: KeyStore,
|
|
115
|
-
private
|
|
116
|
-
private
|
|
117
|
-
private
|
|
118
|
-
private
|
|
119
|
-
private
|
|
120
|
-
private
|
|
121
|
-
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,
|
|
122
104
|
private simulator: CircuitSimulator,
|
|
123
|
-
private packageVersion: string,
|
|
124
105
|
private proverEnabled: boolean,
|
|
125
106
|
private proofCreator: PrivateKernelProver,
|
|
126
107
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
127
108
|
private log: Logger,
|
|
128
109
|
private jobQueue: SerialQueue,
|
|
110
|
+
public debug: PXEDebugUtils,
|
|
129
111
|
) {}
|
|
130
112
|
|
|
131
113
|
/**
|
|
132
|
-
* Creates an instance of a PXE
|
|
114
|
+
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
133
115
|
* Also triggers the registration of the protocol contracts and makes sure the provided node
|
|
134
116
|
* can be contacted.
|
|
135
117
|
*
|
|
136
|
-
* @returns A promise that resolves PXE
|
|
118
|
+
* @returns A promise that resolves PXE is ready to be used.
|
|
137
119
|
*/
|
|
138
120
|
public static async create(
|
|
139
121
|
node: AztecNode,
|
|
@@ -141,7 +123,7 @@ export class PXEService implements PXE {
|
|
|
141
123
|
proofCreator: PrivateKernelProver,
|
|
142
124
|
simulator: CircuitSimulator,
|
|
143
125
|
protocolContractsProvider: ProtocolContractsProvider,
|
|
144
|
-
config:
|
|
126
|
+
config: PXEConfig,
|
|
145
127
|
loggerOrSuffix?: string | Logger,
|
|
146
128
|
) {
|
|
147
129
|
const log =
|
|
@@ -149,126 +131,83 @@ export class PXEService implements PXE {
|
|
|
149
131
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
150
132
|
: loggerOrSuffix;
|
|
151
133
|
|
|
152
|
-
const packageVersion = getPackageInfo().version;
|
|
153
134
|
const proverEnabled = !!config.proverEnabled;
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
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);
|
|
161
144
|
const keyStore = new KeyStore(store);
|
|
162
145
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
163
|
-
const synchronizer = new
|
|
146
|
+
const synchronizer = new BlockSynchronizer(
|
|
164
147
|
node,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
148
|
+
anchorBlockStore,
|
|
149
|
+
noteStore,
|
|
150
|
+
privateEventStore,
|
|
168
151
|
tipsStore,
|
|
169
152
|
config,
|
|
170
153
|
loggerOrSuffix,
|
|
171
154
|
);
|
|
172
155
|
|
|
156
|
+
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
157
|
+
|
|
173
158
|
const jobQueue = new SerialQueue();
|
|
174
159
|
|
|
175
|
-
const
|
|
160
|
+
const pxe = new PXE(
|
|
176
161
|
node,
|
|
177
162
|
synchronizer,
|
|
178
163
|
keyStore,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
164
|
+
contractStore,
|
|
165
|
+
noteStore,
|
|
166
|
+
capsuleStore,
|
|
167
|
+
anchorBlockStore,
|
|
168
|
+
senderTaggingStore,
|
|
169
|
+
senderAddressBookStore,
|
|
170
|
+
recipientTaggingStore,
|
|
171
|
+
addressStore,
|
|
172
|
+
privateEventStore,
|
|
186
173
|
simulator,
|
|
187
|
-
packageVersion,
|
|
188
174
|
proverEnabled,
|
|
189
175
|
proofCreator,
|
|
190
176
|
protocolContractsProvider,
|
|
191
177
|
log,
|
|
192
178
|
jobQueue,
|
|
179
|
+
debugUtils,
|
|
193
180
|
);
|
|
194
181
|
|
|
195
|
-
|
|
182
|
+
debugUtils.setPXE(pxe);
|
|
196
183
|
|
|
197
|
-
|
|
198
|
-
const info = await pxeService.getNodeInfo();
|
|
199
|
-
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
200
|
-
return pxeService;
|
|
201
|
-
}
|
|
184
|
+
pxe.jobQueue.start();
|
|
202
185
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
public async getL2ToL1MembershipWitness(
|
|
210
|
-
blockNumber: number,
|
|
211
|
-
l2Tol1Message: Fr,
|
|
212
|
-
): Promise<[bigint, SiblingPath<number>]> {
|
|
213
|
-
const result = await computeL2ToL1MembershipWitness(this.node, blockNumber, l2Tol1Message);
|
|
214
|
-
if (!result) {
|
|
215
|
-
throw new Error(`L2 to L1 message not found in block ${blockNumber}`);
|
|
216
|
-
}
|
|
217
|
-
return [result.leafIndex, result.siblingPath];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
221
|
-
return this.node.getTxReceipt(txHash);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
225
|
-
return this.node.getTxEffect(txHash);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public getBlockNumber(): Promise<number> {
|
|
229
|
-
return this.node.getBlockNumber();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public getProvenBlockNumber(): Promise<number> {
|
|
233
|
-
return this.node.getProvenBlockNumber();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
237
|
-
return this.node.getPublicLogs(filter);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
241
|
-
return this.node.getContractClassLogs(filter);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public getPublicStorageAt(contract: AztecAddress, slot: Fr) {
|
|
245
|
-
return this.node.getPublicStorageAt('latest', contract, slot);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public async getL1ToL2MembershipWitness(
|
|
249
|
-
contractAddress: AztecAddress,
|
|
250
|
-
messageHash: Fr,
|
|
251
|
-
secret: Fr,
|
|
252
|
-
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
253
|
-
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
186
|
+
await pxe.#registerProtocolContracts();
|
|
187
|
+
const info = await node.getNodeInfo();
|
|
188
|
+
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
189
|
+
return pxe;
|
|
254
190
|
}
|
|
255
191
|
|
|
256
192
|
// Internal methods
|
|
257
193
|
|
|
258
194
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
259
|
-
const
|
|
260
|
-
|
|
195
|
+
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
196
|
+
|
|
197
|
+
return new ContractFunctionSimulator(
|
|
198
|
+
proxyContractStore,
|
|
199
|
+
this.noteStore,
|
|
261
200
|
this.keyStore,
|
|
262
|
-
|
|
263
|
-
this.
|
|
264
|
-
this.
|
|
265
|
-
this.
|
|
266
|
-
this.
|
|
267
|
-
this.
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
201
|
+
this.addressStore,
|
|
202
|
+
this.node,
|
|
203
|
+
this.anchorBlockStore,
|
|
204
|
+
this.senderTaggingStore,
|
|
205
|
+
this.recipientTaggingStore,
|
|
206
|
+
this.senderAddressBookStore,
|
|
207
|
+
this.capsuleStore,
|
|
208
|
+
this.privateEventStore,
|
|
209
|
+
this.simulator,
|
|
270
210
|
);
|
|
271
|
-
return new ContractFunctionSimulator(pxeOracleInterface, this.simulator);
|
|
272
211
|
}
|
|
273
212
|
|
|
274
213
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -307,8 +246,8 @@ export class PXEService implements PXE {
|
|
|
307
246
|
for (const name of protocolContractNames) {
|
|
308
247
|
const { address, contractClass, instance, artifact } =
|
|
309
248
|
await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
310
|
-
await this.
|
|
311
|
-
await this.
|
|
249
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
250
|
+
await this.contractStore.addContractInstance(instance);
|
|
312
251
|
registered[name] = address.toString();
|
|
313
252
|
}
|
|
314
253
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
@@ -327,30 +266,6 @@ export class PXEService implements PXE {
|
|
|
327
266
|
return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
|
|
328
267
|
}
|
|
329
268
|
|
|
330
|
-
async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
331
|
-
const contract = await this.contractDataProvider.getContract(to);
|
|
332
|
-
if (!contract) {
|
|
333
|
-
throw new Error(
|
|
334
|
-
`Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/reference/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
339
|
-
if (!functionDao) {
|
|
340
|
-
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
name: functionDao.name,
|
|
345
|
-
args: encodeArguments(functionDao, args),
|
|
346
|
-
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
347
|
-
type: functionDao.functionType,
|
|
348
|
-
to,
|
|
349
|
-
isStatic: functionDao.isStatic,
|
|
350
|
-
returnTypes: functionDao.returnTypes,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
269
|
// Executes the entrypoint private function, as well as all nested private
|
|
355
270
|
// functions that might arise.
|
|
356
271
|
async #executePrivate(
|
|
@@ -361,11 +276,14 @@ export class PXEService implements PXE {
|
|
|
361
276
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
362
277
|
|
|
363
278
|
try {
|
|
279
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
280
|
+
|
|
364
281
|
const result = await contractFunctionSimulator.run(
|
|
365
282
|
txRequest,
|
|
366
283
|
contractAddress,
|
|
367
284
|
functionSelector,
|
|
368
285
|
undefined,
|
|
286
|
+
anchorBlockHeader,
|
|
369
287
|
// The sender for tags is set by contracts, typically by an account
|
|
370
288
|
// contract entrypoint
|
|
371
289
|
undefined, // senderForTags
|
|
@@ -375,7 +293,7 @@ export class PXEService implements PXE {
|
|
|
375
293
|
return result;
|
|
376
294
|
} catch (err) {
|
|
377
295
|
if (err instanceof SimulationError) {
|
|
378
|
-
await enrichSimulationError(err, this.
|
|
296
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
379
297
|
}
|
|
380
298
|
throw err;
|
|
381
299
|
}
|
|
@@ -397,10 +315,11 @@ export class PXEService implements PXE {
|
|
|
397
315
|
scopes?: AztecAddress[],
|
|
398
316
|
) {
|
|
399
317
|
try {
|
|
400
|
-
|
|
318
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
319
|
+
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
|
|
401
320
|
} catch (err) {
|
|
402
321
|
if (err instanceof SimulationError) {
|
|
403
|
-
await enrichSimulationError(err, this.
|
|
322
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
404
323
|
}
|
|
405
324
|
throw err;
|
|
406
325
|
}
|
|
@@ -424,7 +343,7 @@ export class PXEService implements PXE {
|
|
|
424
343
|
} catch (err) {
|
|
425
344
|
if (err instanceof SimulationError) {
|
|
426
345
|
try {
|
|
427
|
-
await enrichPublicSimulationError(err, this.
|
|
346
|
+
await enrichPublicSimulationError(err, this.contractStore, this.log);
|
|
428
347
|
} catch (enrichErr) {
|
|
429
348
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
430
349
|
}
|
|
@@ -442,7 +361,7 @@ export class PXEService implements PXE {
|
|
|
442
361
|
* @param proofCreator - The proof creator to use for proving the execution.
|
|
443
362
|
* @param privateExecutionResult - The result of the private execution
|
|
444
363
|
* @param config - The configuration for the kernel execution prover.
|
|
445
|
-
* @returns An object that contains the output of the kernel execution, including the
|
|
364
|
+
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
446
365
|
*/
|
|
447
366
|
async #prove(
|
|
448
367
|
txExecutionRequest: TxExecutionRequest,
|
|
@@ -450,8 +369,13 @@ export class PXEService implements PXE {
|
|
|
450
369
|
privateExecutionResult: PrivateExecutionResult,
|
|
451
370
|
config: PrivateKernelExecutionProverConfig,
|
|
452
371
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
453
|
-
const
|
|
454
|
-
const kernelOracle = new PrivateKernelOracleImpl(
|
|
372
|
+
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
373
|
+
const kernelOracle = new PrivateKernelOracleImpl(
|
|
374
|
+
this.contractStore,
|
|
375
|
+
this.keyStore,
|
|
376
|
+
this.node,
|
|
377
|
+
simulationAnchorBlock,
|
|
378
|
+
);
|
|
455
379
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
456
380
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
457
381
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
@@ -459,24 +383,24 @@ export class PXEService implements PXE {
|
|
|
459
383
|
|
|
460
384
|
// Public API
|
|
461
385
|
|
|
462
|
-
/** Returns an estimate of the db size in bytes. */
|
|
463
|
-
public async estimateDbSize() {
|
|
464
|
-
const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
|
|
465
|
-
const dbSizes = await Promise.all([
|
|
466
|
-
this.addressDataProvider.getSize(),
|
|
467
|
-
this.capsuleDataProvider.getSize(),
|
|
468
|
-
this.contractDataProvider.getSize(),
|
|
469
|
-
this.noteDataProvider.getSize(),
|
|
470
|
-
this.syncDataProvider.getSize(),
|
|
471
|
-
this.taggingDataProvider.getSize(),
|
|
472
|
-
]);
|
|
473
|
-
return [...dbSizes, treeRootsSize].reduce((sum, size) => sum + size, 0);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
386
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
477
|
-
return this.
|
|
387
|
+
return this.contractStore.getContractInstance(address);
|
|
478
388
|
}
|
|
479
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Returns the contract class metadata given a contract class id.
|
|
392
|
+
* The metadata consists of its contract class, whether it has been publicly registered, and its artifact.
|
|
393
|
+
* @remark - it queries the node to check whether the contract class with the given id has been publicly registered.
|
|
394
|
+
* @param id - Identifier of the class.
|
|
395
|
+
* @param includeArtifact - Identifier of the class.
|
|
396
|
+
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
397
|
+
* for `includeArtifact`
|
|
398
|
+
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
399
|
+
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
400
|
+
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
401
|
+
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
402
|
+
* do for the time being.
|
|
403
|
+
*/
|
|
480
404
|
public async getContractClassMetadata(
|
|
481
405
|
id: Fr,
|
|
482
406
|
includeArtifact: boolean = false,
|
|
@@ -485,7 +409,7 @@ export class PXEService implements PXE {
|
|
|
485
409
|
isContractClassPubliclyRegistered: boolean;
|
|
486
410
|
artifact: ContractArtifact | undefined;
|
|
487
411
|
}> {
|
|
488
|
-
const artifact = await this.
|
|
412
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
489
413
|
if (!artifact) {
|
|
490
414
|
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
491
415
|
}
|
|
@@ -497,6 +421,17 @@ export class PXEService implements PXE {
|
|
|
497
421
|
};
|
|
498
422
|
}
|
|
499
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Returns the contract metadata given an address.
|
|
426
|
+
* The metadata consists of its contract instance, which includes the contract class identifier,
|
|
427
|
+
* initialization hash, deployment salt, and public keys hash; whether the contract instance has been initialized;
|
|
428
|
+
* and whether the contract instance with the given address has been publicly deployed.
|
|
429
|
+
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
430
|
+
* This query is not dependent on the PXE.
|
|
431
|
+
* @param address - The address that the contract instance resides at.
|
|
432
|
+
* @returns - It returns the contract metadata
|
|
433
|
+
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
434
|
+
*/
|
|
500
435
|
public async getContractMetadata(address: AztecAddress): Promise<{
|
|
501
436
|
contractInstance: ContractInstanceWithAddress | undefined;
|
|
502
437
|
isContractInitialized: boolean;
|
|
@@ -504,7 +439,7 @@ export class PXEService implements PXE {
|
|
|
504
439
|
}> {
|
|
505
440
|
let instance;
|
|
506
441
|
try {
|
|
507
|
-
instance = await this.
|
|
442
|
+
instance = await this.contractStore.getContractInstance(address);
|
|
508
443
|
} catch {
|
|
509
444
|
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
510
445
|
}
|
|
@@ -515,6 +450,16 @@ export class PXEService implements PXE {
|
|
|
515
450
|
};
|
|
516
451
|
}
|
|
517
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Registers a user account in PXE given its master encryption private key.
|
|
455
|
+
* Once a new account is registered, the PXE will trial-decrypt all published notes on
|
|
456
|
+
* the chain and store those that correspond to the registered account. Will do nothing if the
|
|
457
|
+
* account is already registered.
|
|
458
|
+
*
|
|
459
|
+
* @param secretKey - Secret key of the corresponding user master public key.
|
|
460
|
+
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
461
|
+
* @returns The complete address of the account.
|
|
462
|
+
*/
|
|
518
463
|
public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
519
464
|
const accounts = await this.keyStore.getAccounts();
|
|
520
465
|
const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
|
|
@@ -526,46 +471,68 @@ export class PXEService implements PXE {
|
|
|
526
471
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
527
472
|
}
|
|
528
473
|
|
|
529
|
-
await this.
|
|
530
|
-
await this.
|
|
474
|
+
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
475
|
+
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
531
476
|
return accountCompleteAddress;
|
|
532
477
|
}
|
|
533
478
|
|
|
534
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Registers a sender in this PXE.
|
|
481
|
+
*
|
|
482
|
+
* After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
|
|
483
|
+
* Will do nothing if the address is already registered.
|
|
484
|
+
*
|
|
485
|
+
* @param sender - Address of the sender to register.
|
|
486
|
+
* @returns The address of the sender.
|
|
487
|
+
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
488
|
+
*/
|
|
489
|
+
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
535
490
|
const accounts = await this.keyStore.getAccounts();
|
|
536
|
-
if (accounts.includes(
|
|
537
|
-
this.log.info(`Sender:\n "${
|
|
538
|
-
return
|
|
491
|
+
if (accounts.includes(sender)) {
|
|
492
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
493
|
+
return sender;
|
|
539
494
|
}
|
|
540
495
|
|
|
541
|
-
const wasAdded = await this.
|
|
496
|
+
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
542
497
|
|
|
543
498
|
if (wasAdded) {
|
|
544
|
-
this.log.info(`Added sender:\n ${
|
|
499
|
+
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
545
500
|
} else {
|
|
546
|
-
this.log.info(`Sender:\n "${
|
|
501
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
547
502
|
}
|
|
548
503
|
|
|
549
|
-
return
|
|
504
|
+
return sender;
|
|
550
505
|
}
|
|
551
506
|
|
|
507
|
+
/**
|
|
508
|
+
* Retrieves senders registered in this PXE.
|
|
509
|
+
* @returns Senders registered in this PXE.
|
|
510
|
+
*/
|
|
552
511
|
public getSenders(): Promise<AztecAddress[]> {
|
|
553
|
-
return this.
|
|
512
|
+
return this.senderAddressBookStore.getSenders();
|
|
554
513
|
}
|
|
555
514
|
|
|
556
|
-
|
|
557
|
-
|
|
515
|
+
/**
|
|
516
|
+
* Removes a sender registered in this PXE.
|
|
517
|
+
* @param sender - The address of the sender to remove.
|
|
518
|
+
*/
|
|
519
|
+
public async removeSender(sender: AztecAddress): Promise<void> {
|
|
520
|
+
const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
|
|
558
521
|
|
|
559
522
|
if (wasRemoved) {
|
|
560
|
-
this.log.info(`Removed sender:\n ${
|
|
523
|
+
this.log.info(`Removed sender:\n ${sender.toString()}`);
|
|
561
524
|
} else {
|
|
562
|
-
this.log.info(`Sender:\n "${
|
|
525
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
|
|
563
526
|
}
|
|
564
527
|
}
|
|
565
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Retrieves the user accounts registered on this PXE.
|
|
531
|
+
* @returns An array of the accounts registered on this PXE.
|
|
532
|
+
*/
|
|
566
533
|
public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
567
534
|
// Get complete addresses of both the recipients and the accounts
|
|
568
|
-
const completeAddresses = await this.
|
|
535
|
+
const completeAddresses = await this.addressStore.getCompleteAddresses();
|
|
569
536
|
// Filter out the addresses not corresponding to accounts
|
|
570
537
|
const accounts = await this.keyStore.getAccounts();
|
|
571
538
|
return completeAddresses.filter(completeAddress =>
|
|
@@ -573,12 +540,25 @@ export class PXEService implements PXE {
|
|
|
573
540
|
);
|
|
574
541
|
}
|
|
575
542
|
|
|
543
|
+
/**
|
|
544
|
+
* Registers a contract class in the PXE without registering any associated contract instance with it.
|
|
545
|
+
*
|
|
546
|
+
* @param artifact - The build artifact for the contract class.
|
|
547
|
+
*/
|
|
576
548
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
577
549
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
578
|
-
await this.
|
|
550
|
+
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
579
551
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
580
552
|
}
|
|
581
553
|
|
|
554
|
+
/**
|
|
555
|
+
* Adds deployed contracts to the PXE. Deployed contract information is used to access the
|
|
556
|
+
* contract code when simulating local transactions. This is automatically called by aztec.js when
|
|
557
|
+
* deploying a contract. Dapps that wish to interact with contracts already deployed should register
|
|
558
|
+
* these contracts in their users' PXE through this method.
|
|
559
|
+
*
|
|
560
|
+
* @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
|
|
561
|
+
*/
|
|
582
562
|
public async registerContract(contract: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact }) {
|
|
583
563
|
const { instance } = contract;
|
|
584
564
|
let { artifact } = contract;
|
|
@@ -596,7 +576,7 @@ export class PXEService implements PXE {
|
|
|
596
576
|
if (!computedAddress.equals(instance.address)) {
|
|
597
577
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
598
578
|
}
|
|
599
|
-
await this.
|
|
579
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
600
580
|
|
|
601
581
|
const publicFunctionSignatures = artifact.functions
|
|
602
582
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -604,7 +584,7 @@ export class PXEService implements PXE {
|
|
|
604
584
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
605
585
|
} else {
|
|
606
586
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
607
|
-
artifact = await this.
|
|
587
|
+
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
608
588
|
if (!artifact) {
|
|
609
589
|
throw new Error(
|
|
610
590
|
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
@@ -612,24 +592,33 @@ export class PXEService implements PXE {
|
|
|
612
592
|
}
|
|
613
593
|
}
|
|
614
594
|
|
|
615
|
-
await this.
|
|
595
|
+
await this.contractStore.addContractInstance(instance);
|
|
616
596
|
this.log.info(
|
|
617
597
|
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
618
598
|
);
|
|
619
599
|
}
|
|
620
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
603
|
+
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
604
|
+
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
605
|
+
* @param contractAddress - The address of the contract to update.
|
|
606
|
+
* @param artifact - The updated artifact for the contract.
|
|
607
|
+
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
608
|
+
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
609
|
+
*/
|
|
621
610
|
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
622
611
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
623
612
|
// class while we're simulating it.
|
|
624
613
|
return this.#putInJobQueue(async () => {
|
|
625
|
-
const currentInstance = await this.
|
|
614
|
+
const currentInstance = await this.contractStore.getContractInstance(contractAddress);
|
|
626
615
|
if (!currentInstance) {
|
|
627
616
|
throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
|
|
628
617
|
}
|
|
629
618
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
630
|
-
await this.
|
|
619
|
+
await this.blockStateSynchronizer.sync();
|
|
631
620
|
|
|
632
|
-
const header = await this.
|
|
621
|
+
const header = await this.anchorBlockStore.getBlockHeader();
|
|
633
622
|
|
|
634
623
|
const currentClassId = await readCurrentClassId(
|
|
635
624
|
contractAddress,
|
|
@@ -642,7 +631,7 @@ export class PXEService implements PXE {
|
|
|
642
631
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
643
632
|
}
|
|
644
633
|
|
|
645
|
-
await this.
|
|
634
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
646
635
|
|
|
647
636
|
const publicFunctionSignatures = artifact.functions
|
|
648
637
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -650,72 +639,44 @@ export class PXEService implements PXE {
|
|
|
650
639
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
651
640
|
|
|
652
641
|
currentInstance.currentContractClassId = contractClass.id;
|
|
653
|
-
await this.
|
|
642
|
+
await this.contractStore.addContractInstance(currentInstance);
|
|
654
643
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
655
644
|
});
|
|
656
645
|
}
|
|
657
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Retrieves the addresses of contracts added to this PXE.
|
|
649
|
+
* @returns An array of contracts addresses registered on this PXE.
|
|
650
|
+
*/
|
|
658
651
|
public getContracts(): Promise<AztecAddress[]> {
|
|
659
|
-
return this.
|
|
652
|
+
return this.contractStore.getContractsAddresses();
|
|
660
653
|
}
|
|
661
654
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
completeAddress.address.equals(dao.recipient),
|
|
674
|
-
);
|
|
675
|
-
const completeAddress = completeAddresses[completeAddressIndex];
|
|
676
|
-
if (completeAddress === undefined) {
|
|
677
|
-
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
678
|
-
}
|
|
679
|
-
recipient = completeAddress.address;
|
|
680
|
-
}
|
|
681
|
-
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.noteNonce);
|
|
682
|
-
});
|
|
683
|
-
return Promise.all(extendedNotes);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
public async getBlock(blockNumber: number): Promise<L2Block | undefined> {
|
|
687
|
-
// If a negative block number is provided the current block number is fetched.
|
|
688
|
-
if (blockNumber < 0) {
|
|
689
|
-
blockNumber = await this.node.getBlockNumber();
|
|
690
|
-
}
|
|
691
|
-
return await this.node.getBlock(blockNumber);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
public async getCurrentBaseFees(): Promise<GasFees> {
|
|
695
|
-
return await this.node.getCurrentBaseFees();
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
public proveTx(
|
|
699
|
-
txRequest: TxExecutionRequest,
|
|
700
|
-
privateExecutionResult?: PrivateExecutionResult,
|
|
701
|
-
): Promise<TxProvingResult> {
|
|
655
|
+
/**
|
|
656
|
+
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
657
|
+
* (where validators prove the public portion).
|
|
658
|
+
*
|
|
659
|
+
* @param txRequest - An authenticated tx request ready for proving
|
|
660
|
+
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
661
|
+
* @throws If contract code not found, or public simulation reverts.
|
|
662
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
663
|
+
*/
|
|
664
|
+
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
665
|
+
let privateExecutionResult: PrivateExecutionResult;
|
|
702
666
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
703
667
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
704
668
|
return this.#putInJobQueue(async () => {
|
|
705
669
|
const totalTimer = new Timer();
|
|
706
670
|
try {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
contractFunctionSimulator = this.#getSimulatorForTx();
|
|
714
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
715
|
-
}
|
|
671
|
+
const syncTimer = new Timer();
|
|
672
|
+
await this.blockStateSynchronizer.sync();
|
|
673
|
+
const syncTime = syncTimer.ms();
|
|
674
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
675
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
676
|
+
|
|
716
677
|
const {
|
|
717
678
|
publicInputs,
|
|
718
|
-
|
|
679
|
+
chonkProof,
|
|
719
680
|
executionSteps,
|
|
720
681
|
timings: { proving } = {},
|
|
721
682
|
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -742,16 +703,46 @@ export class PXEService implements PXE {
|
|
|
742
703
|
};
|
|
743
704
|
|
|
744
705
|
this.log.debug(`Proving completed in ${totalTime}ms`, { timings });
|
|
745
|
-
|
|
706
|
+
|
|
707
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
746
708
|
timings,
|
|
747
709
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
748
710
|
});
|
|
711
|
+
|
|
712
|
+
// While not strictly necessary to store tagging cache contents in the DB since we sync tagging indexes from
|
|
713
|
+
// chain before sending new logs, the sync can only see logs already included in blocks. If we send another
|
|
714
|
+
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
715
|
+
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
716
|
+
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
717
|
+
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
718
|
+
if (preTagsUsedInTheTx.length > 0) {
|
|
719
|
+
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
720
|
+
const txHash = (await txProvingResult.toTx()).txHash;
|
|
721
|
+
|
|
722
|
+
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash);
|
|
723
|
+
this.log.debug(`Stored used pre-tags as sender for the tx`, {
|
|
724
|
+
preTagsUsedInTheTx,
|
|
725
|
+
});
|
|
726
|
+
} else {
|
|
727
|
+
this.log.debug(`No pre-tags used in the tx`);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return txProvingResult;
|
|
749
731
|
} catch (err: any) {
|
|
750
732
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
751
733
|
}
|
|
752
734
|
});
|
|
753
735
|
}
|
|
754
736
|
|
|
737
|
+
/**
|
|
738
|
+
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
739
|
+
*
|
|
740
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
741
|
+
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
742
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
743
|
+
* @returns A trace of the program execution with gate counts.
|
|
744
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
745
|
+
*/
|
|
755
746
|
public profileTx(
|
|
756
747
|
txRequest: TxExecutionRequest,
|
|
757
748
|
profileMode: 'full' | 'execution-steps' | 'gates',
|
|
@@ -774,7 +765,7 @@ export class PXEService implements PXE {
|
|
|
774
765
|
txInfo,
|
|
775
766
|
);
|
|
776
767
|
const syncTimer = new Timer();
|
|
777
|
-
await this.
|
|
768
|
+
await this.blockStateSynchronizer.sync();
|
|
778
769
|
const syncTime = syncTimer.ms();
|
|
779
770
|
|
|
780
771
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -824,7 +815,29 @@ export class PXEService implements PXE {
|
|
|
824
815
|
});
|
|
825
816
|
}
|
|
826
817
|
|
|
827
|
-
|
|
818
|
+
/**
|
|
819
|
+
* Simulates a transaction based on the provided preauthenticated execution request.
|
|
820
|
+
* This will run a local simulation of private execution (and optionally of public as well), run the
|
|
821
|
+
* kernel circuits to ensure adherence to protocol rules (without generating a proof), and return the
|
|
822
|
+
* simulation results .
|
|
823
|
+
*
|
|
824
|
+
*
|
|
825
|
+
* Note that this is used with `ContractFunctionInteraction::simulateTx` to bypass certain checks.
|
|
826
|
+
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
827
|
+
*
|
|
828
|
+
*
|
|
829
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
830
|
+
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
831
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
832
|
+
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
833
|
+
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
834
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
835
|
+
* @returns A simulated transaction result object that includes public and private return values.
|
|
836
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
837
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
838
|
+
*
|
|
839
|
+
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
840
|
+
*/
|
|
828
841
|
public simulateTx(
|
|
829
842
|
txRequest: TxExecutionRequest,
|
|
830
843
|
simulatePublic: boolean,
|
|
@@ -852,7 +865,7 @@ export class PXEService implements PXE {
|
|
|
852
865
|
txInfo,
|
|
853
866
|
);
|
|
854
867
|
const syncTimer = new Timer();
|
|
855
|
-
await this.
|
|
868
|
+
await this.blockStateSynchronizer.sync();
|
|
856
869
|
const syncTime = syncTimer.ms();
|
|
857
870
|
|
|
858
871
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
@@ -869,15 +882,14 @@ export class PXEService implements PXE {
|
|
|
869
882
|
|
|
870
883
|
if (skipKernels) {
|
|
871
884
|
// According to the protocol rules, the nonce generator for the note hashes
|
|
872
|
-
// can either be the first nullifier in the tx or the
|
|
873
|
-
// if there are none.
|
|
885
|
+
// can either be the first nullifier in the tx or the protocol nullifier if there are none.
|
|
874
886
|
const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO)
|
|
875
|
-
? await txRequest.toTxRequest().hash()
|
|
887
|
+
? await computeProtocolNullifier(await txRequest.toTxRequest().hash())
|
|
876
888
|
: privateExecutionResult.firstNullifier;
|
|
877
889
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
878
890
|
privateExecutionResult,
|
|
879
891
|
nonceGenerator,
|
|
880
|
-
this.
|
|
892
|
+
this.contractStore,
|
|
881
893
|
));
|
|
882
894
|
} else {
|
|
883
895
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -961,25 +973,18 @@ export class PXEService implements PXE {
|
|
|
961
973
|
});
|
|
962
974
|
}
|
|
963
975
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
this.log.info(`Sent transaction ${txHash}`);
|
|
974
|
-
return txHash;
|
|
975
|
-
}
|
|
976
|
-
|
|
976
|
+
/**
|
|
977
|
+
* Simulate the execution of a contract utility function.
|
|
978
|
+
*
|
|
979
|
+
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
980
|
+
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
981
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
982
|
+
* default to all.
|
|
983
|
+
* @returns The result of the utility function call, structured based on the function ABI.
|
|
984
|
+
*/
|
|
977
985
|
public simulateUtility(
|
|
978
|
-
|
|
979
|
-
args: any[],
|
|
980
|
-
to: AztecAddress,
|
|
986
|
+
call: FunctionCall,
|
|
981
987
|
authwits?: AuthWitness[],
|
|
982
|
-
_from?: AztecAddress,
|
|
983
988
|
scopes?: AztecAddress[],
|
|
984
989
|
): Promise<UtilitySimulationResult> {
|
|
985
990
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
@@ -989,23 +994,21 @@ export class PXEService implements PXE {
|
|
|
989
994
|
try {
|
|
990
995
|
const totalTimer = new Timer();
|
|
991
996
|
const syncTimer = new Timer();
|
|
992
|
-
await this.
|
|
997
|
+
await this.blockStateSynchronizer.sync();
|
|
993
998
|
const syncTime = syncTimer.ms();
|
|
994
|
-
// TODO - Should check if `from` has the permission to call the view function.
|
|
995
|
-
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
996
999
|
const functionTimer = new Timer();
|
|
997
1000
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
authwits ?? [],
|
|
1002
|
-
scopes,
|
|
1001
|
+
|
|
1002
|
+
await this.contractStore.syncPrivateState(call.to, call.selector, privateSyncCall =>
|
|
1003
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1003
1004
|
);
|
|
1005
|
+
|
|
1006
|
+
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
1004
1007
|
const functionTime = functionTimer.ms();
|
|
1005
1008
|
|
|
1006
1009
|
const totalTime = totalTimer.ms();
|
|
1007
1010
|
|
|
1008
|
-
const perFunction = [{ functionName, time: functionTime }];
|
|
1011
|
+
const perFunction = [{ functionName: call.name, time: functionTime }];
|
|
1009
1012
|
|
|
1010
1013
|
const timings: SimulationTimings = {
|
|
1011
1014
|
total: totalTime,
|
|
@@ -1017,118 +1020,54 @@ export class PXEService implements PXE {
|
|
|
1017
1020
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1018
1021
|
return { result: executionResult, stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls } };
|
|
1019
1022
|
} catch (err: any) {
|
|
1023
|
+
const { to, name, args } = call;
|
|
1020
1024
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1021
1025
|
throw this.#contextualizeError(
|
|
1022
1026
|
err,
|
|
1023
|
-
`simulateUtility ${to}:${
|
|
1027
|
+
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1024
1028
|
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
1025
1029
|
);
|
|
1026
1030
|
}
|
|
1027
1031
|
});
|
|
1028
1032
|
}
|
|
1029
1033
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
this
|
|
1046
|
-
|
|
1047
|
-
l1ChainId: chainId,
|
|
1048
|
-
rollupVersion,
|
|
1049
|
-
enr,
|
|
1050
|
-
l1ContractAddresses: contractAddresses,
|
|
1051
|
-
protocolContractAddresses: protocolContractAddresses,
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
return this.#nodeInfo;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
public getPXEInfo(): Promise<PXEInfo> {
|
|
1059
|
-
return Promise.resolve({
|
|
1060
|
-
pxeVersion: this.packageVersion,
|
|
1061
|
-
protocolContractAddresses: {
|
|
1062
|
-
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1063
|
-
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1064
|
-
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1065
|
-
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint,
|
|
1066
|
-
},
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
public async getPrivateEvents<T>(
|
|
1071
|
-
contractAddress: AztecAddress,
|
|
1072
|
-
eventMetadataDef: EventMetadataDefinition,
|
|
1073
|
-
from: number,
|
|
1074
|
-
numBlocks: number,
|
|
1075
|
-
recipients: AztecAddress[],
|
|
1076
|
-
): Promise<T[]> {
|
|
1077
|
-
if (recipients.length === 0) {
|
|
1078
|
-
throw new Error('Recipients are required to get private events');
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
1082
|
-
|
|
1083
|
-
// We need to manually trigger private state sync to have a guarantee that all the events are available.
|
|
1084
|
-
await this.simulateUtility('sync_private_state', [], contractAddress);
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns the private events given search parameters.
|
|
1036
|
+
* @param eventSelector - Event selector to search for.
|
|
1037
|
+
* @param filter
|
|
1038
|
+
* contractAddress - The address of the contract to get events from. Required.
|
|
1039
|
+
* scopes - One or more event scope addresses to filter by. Required.
|
|
1040
|
+
* fromBlock - The block number to search from (inclusive). Optional. If provided, it must be >= 0.
|
|
1041
|
+
* Defaults to 0.
|
|
1042
|
+
* If toBlock is defined but fromBlock is not, fromBlock defaults to toBlock - 1.
|
|
1043
|
+
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
1044
|
+
* Defaults to the latest known block to PXE + 1.
|
|
1045
|
+
* @returns - The packed events with block and tx metadata.
|
|
1046
|
+
*/
|
|
1047
|
+
public getPrivateEvents(eventSelector: EventSelector, filter: PrivateEventFilter): Promise<PackedPrivateEvent[]> {
|
|
1048
|
+
return this.#putInJobQueue(async () => {
|
|
1049
|
+
await this.blockStateSynchronizer.sync();
|
|
1050
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1085
1051
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
eventMetadataDef.eventSelector,
|
|
1092
|
-
);
|
|
1052
|
+
await this.contractStore.syncPrivateState(
|
|
1053
|
+
filter.contractAddress,
|
|
1054
|
+
null,
|
|
1055
|
+
async privateSyncCall => await this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1056
|
+
);
|
|
1093
1057
|
|
|
1094
|
-
|
|
1058
|
+
const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockStore).validate(filter);
|
|
1095
1059
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1060
|
+
this.log.debug(
|
|
1061
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1062
|
+
);
|
|
1098
1063
|
|
|
1099
|
-
|
|
1100
|
-
const { logs } = await this.node.getPublicLogs({
|
|
1101
|
-
fromBlock: from,
|
|
1102
|
-
toBlock: from + limit,
|
|
1064
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1103
1065
|
});
|
|
1104
|
-
|
|
1105
|
-
const decodedEvents = logs
|
|
1106
|
-
.map(log => {
|
|
1107
|
-
// +1 for the event selector
|
|
1108
|
-
const expectedLength = eventMetadataDef.fieldNames.length + 1;
|
|
1109
|
-
if (log.log.emittedLength !== expectedLength) {
|
|
1110
|
-
throw new Error(
|
|
1111
|
-
`Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.emittedLength}.`,
|
|
1112
|
-
);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
const logFields = log.log.getEmittedFields();
|
|
1116
|
-
// We are assuming here that event logs are the last 4 bytes of the event. This is not enshrined but is a function of aztec.nr raw log emission.
|
|
1117
|
-
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
|
|
1118
|
-
return undefined;
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
|
|
1122
|
-
})
|
|
1123
|
-
.filter(log => log !== undefined) as T[];
|
|
1124
|
-
|
|
1125
|
-
return decodedEvents;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
async resetNoteSyncData() {
|
|
1129
|
-
return await this.taggingDataProvider.resetNoteSyncData();
|
|
1130
1066
|
}
|
|
1131
1067
|
|
|
1068
|
+
/**
|
|
1069
|
+
* Stops the PXE's job queue.
|
|
1070
|
+
*/
|
|
1132
1071
|
public stop(): Promise<void> {
|
|
1133
1072
|
return this.jobQueue.end();
|
|
1134
1073
|
}
|