@aztec/pxe 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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 +41 -112
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +34 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +46 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +22 -16
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +71 -28
- package/dest/config/index.d.ts +9 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +14 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract/contract_class_service.d.ts +24 -0
- package/dest/contract/contract_class_service.d.ts.map +1 -0
- package/dest/contract/contract_class_service.js +36 -0
- package/dest/contract/contract_sync_service.d.ts +48 -0
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/contract/contract_sync_service.js +119 -0
- package/dest/contract/helpers.d.ts +7 -0
- package/dest/contract/helpers.d.ts.map +1 -0
- package/dest/contract/helpers.js +20 -0
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +72 -43
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +266 -114
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +4 -10
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +10 -29
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -11
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -15
- package/dest/contract_function_simulator/index.d.ts +26 -5
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -3
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +30 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +9 -10
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +19 -10
- 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 +12 -24
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +11 -9
- 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 +2 -63
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
- 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 +8 -12
- package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +67 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +19 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +9 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +15 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
- 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 -20
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
- 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 +15 -98
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
- 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 -24
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +1016 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +274 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1243 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +7 -6
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +82 -98
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +263 -117
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +206 -83
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +688 -188
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/transient_array_service.js +62 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/debug/pxe_debug_utils.d.ts +5 -9
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -10
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +29 -8
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +29 -8
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +42 -0
- package/dest/entrypoints/pxe_creation_options.d.ts +16 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +8 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +6 -2
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +4 -3
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +30 -8
- package/dest/error_enriching.d.ts +5 -3
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +15 -12
- package/dest/events/event_service.d.ts +21 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +51 -17
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +62 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +5 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +2 -0
- package/dest/hooks/resolve_custom_request.d.ts +23 -0
- package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
- package/dest/hooks/resolve_custom_request.js +3 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
- package/dest/logs/log_service.d.ts +21 -10
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +184 -90
- package/dest/messages/tx_resolver_service.d.ts +28 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/tx_resolver_service.js +62 -0
- package/dest/node/benchmarked_node.d.ts +20 -0
- package/dest/node/benchmarked_node.d.ts.map +1 -0
- package/dest/node/benchmarked_node.js +94 -0
- package/dest/node/caching_aztec_node.d.ts +24 -0
- package/dest/node/caching_aztec_node.d.ts.map +1 -0
- package/dest/node/caching_aztec_node.js +268 -0
- package/dest/notes/note_service.d.ts +34 -6
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +85 -59
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +138 -72
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +202 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +165 -82
- package/dest/private_kernel/private_kernel_oracle.d.ts +17 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +47 -29
- package/dest/pxe.d.ts +219 -68
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +423 -243
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +2 -1
- package/dest/storage/allowed_scopes.d.ts +6 -0
- package/dest/storage/allowed_scopes.d.ts.map +1 -0
- package/dest/storage/allowed_scopes.js +7 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -7
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +671 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +47 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +37 -29
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +63 -33
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +179 -130
- package/dest/storage/contract_store/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_store/private_functions_tree.js +2 -1
- package/dest/storage/fact_store/fact_service.d.ts +22 -0
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_service.js +45 -0
- package/dest/storage/fact_store/fact_store.d.ts +95 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +411 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store_keys.js +50 -0
- package/dest/storage/fact_store/index.d.ts +6 -0
- package/dest/storage/fact_store/index.d.ts.map +1 -0
- package/dest/storage/fact_store/index.js +4 -0
- package/dest/storage/fact_store/origin_state.d.ts +59 -0
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
- package/dest/storage/fact_store/origin_state.js +60 -0
- package/dest/storage/fact_store/stored_fact.d.ts +32 -0
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
- package/dest/storage/fact_store/stored_fact.js +64 -0
- package/dest/storage/index.d.ts +3 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -1
- package/dest/storage/metadata.d.ts +2 -2
- package/dest/storage/metadata.d.ts.map +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +44 -35
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +203 -174
- package/dest/storage/note_store/stored_note.d.ts +3 -8
- package/dest/storage/note_store/stored_note.d.ts.map +1 -1
- package/dest/storage/note_store/stored_note.js +4 -20
- package/dest/storage/open_pxe_stores.d.ts +35 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +29 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +48 -45
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/index.d.ts +2 -2
- package/dest/storage/tagging_store/index.d.ts.map +1 -1
- package/dest/storage/tagging_store/index.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +63 -31
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +210 -129
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
- package/dest/tagging/constants.d.ts +11 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +38 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts +55 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +65 -32
- package/dest/tagging/index.d.ts +8 -7
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +6 -5
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +74 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +235 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +8 -10
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +25 -22
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.js +62 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +17 -9
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +53 -39
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +42 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +20 -17
- package/src/bin/check_oracle_version.ts +46 -135
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +54 -0
- package/src/block_synchronizer/block_stream_source.ts +42 -0
- package/src/block_synchronizer/block_synchronizer.ts +86 -40
- package/src/config/index.ts +16 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract/contract_class_service.ts +45 -0
- package/src/contract/contract_sync_service.ts +179 -0
- package/src/contract/helpers.ts +35 -0
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +468 -180
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +10 -30
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
- package/src/contract_function_simulator/index.ts +89 -4
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
- package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
- package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -9
- package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -20
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +14 -64
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -11
- package/src/contract_function_simulator/noir-structs/option.ts +75 -0
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +19 -0
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +16 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
- package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -15
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -176
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +710 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +1052 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +6 -7
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +320 -210
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +1028 -268
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/contract_logging.ts +52 -0
- package/src/debug/pxe_debug_utils.ts +11 -17
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +35 -9
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +35 -9
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/pxe_creation_options.ts +21 -1
- package/src/entrypoints/server/index.ts +8 -2
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +46 -21
- package/src/error_enriching.ts +30 -13
- package/src/events/event_service.ts +85 -26
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +68 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/resolve_custom_request.ts +24 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
- package/src/logs/log_service.ts +231 -157
- package/src/messages/tx_resolver_service.ts +81 -0
- package/src/node/benchmarked_node.ts +140 -0
- package/src/node/caching_aztec_node.ts +407 -0
- package/src/notes/note_service.ts +128 -86
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +179 -121
- package/src/private_kernel/hints/test_utils.ts +318 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +252 -116
- package/src/private_kernel/private_kernel_oracle.ts +65 -36
- package/src/pxe.ts +698 -311
- package/src/storage/address_store/address_store.ts +2 -1
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -7
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +26 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +117 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +803 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +85 -0
- package/src/storage/capsule_store/capsule_store.ts +45 -27
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +238 -166
- package/src/storage/contract_store/private_functions_tree.ts +2 -1
- package/src/storage/fact_store/fact_service.ts +69 -0
- package/src/storage/fact_store/fact_store.ts +488 -0
- package/src/storage/fact_store/fact_store_keys.ts +75 -0
- package/src/storage/fact_store/index.ts +15 -0
- package/src/storage/fact_store/origin_state.ts +84 -0
- package/src/storage/fact_store/stored_fact.ts +80 -0
- package/src/storage/index.ts +2 -1
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +236 -194
- package/src/storage/note_store/stored_note.ts +5 -27
- package/src/storage/open_pxe_stores.ts +52 -0
- package/src/storage/private_event_store/private_event_store.ts +55 -56
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +278 -158
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
- package/src/tagging/constants.ts +42 -10
- package/src/tagging/get_all_logs_by_tags.ts +125 -36
- package/src/tagging/index.ts +12 -6
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +356 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +4 -4
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +32 -27
- package/src/tagging/sender_sync/utils/classify_pending_txs.ts +92 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +57 -50
- package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +65 -0
- package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/benchmarked_node.js +0 -77
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -60
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -368
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -80
- package/dest/contract_sync/contract_sync_service.d.ts +0 -41
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/contract_sync_service.js +0 -82
- package/dest/contract_sync/helpers.d.ts +0 -28
- package/dest/contract_sync/helpers.d.ts.map +0 -1
- package/dest/contract_sync/helpers.js +0 -55
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -15
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -32
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +0 -11
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +0 -29
- package/src/contract_function_simulator/benchmarked_node.ts +0 -103
- package/src/contract_function_simulator/oracle/oracle.ts +0 -637
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -83
- package/src/contract_sync/contract_sync_service.ts +0 -129
- package/src/contract_sync/helpers.ts +0 -93
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -36
package/src/pxe.ts
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { allToCompletion } from '@aztec/foundation/promise';
|
|
5
7
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
6
8
|
import { Timer } from '@aztec/foundation/timer';
|
|
7
9
|
import { KeyStore } from '@aztec/key-store';
|
|
10
|
+
import type { AccountPrivacyKeys, AccountPrivacySecretKeys } from '@aztec/key-store';
|
|
8
11
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
|
-
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
10
12
|
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
11
13
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
12
14
|
import {
|
|
13
15
|
type ContractArtifact,
|
|
14
16
|
EventSelector,
|
|
15
17
|
FunctionCall,
|
|
18
|
+
type FunctionSelector,
|
|
16
19
|
FunctionType,
|
|
17
20
|
decodeFunctionSignature,
|
|
18
21
|
} from '@aztec/stdlib/abi';
|
|
19
22
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
23
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
|
+
import { GENESIS_BLOCK_HEADER_HASH, type L2TipsProvider } from '@aztec/stdlib/block';
|
|
21
25
|
import {
|
|
22
26
|
CompleteAddress,
|
|
27
|
+
type ContractInstancePreimage,
|
|
28
|
+
type ContractInstancePreimageWithAddress,
|
|
23
29
|
type ContractInstanceWithAddress,
|
|
24
30
|
type PartialAddress,
|
|
25
31
|
computeContractAddressFromInstance,
|
|
26
|
-
getContractClassFromArtifact,
|
|
27
32
|
} from '@aztec/stdlib/contract';
|
|
28
33
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
29
|
-
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
34
|
+
import type { AztecNode, AztecNodeDebug, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
30
35
|
import type {
|
|
31
36
|
PrivateExecutionStep,
|
|
32
37
|
PrivateKernelExecutionProofOutput,
|
|
33
38
|
PrivateKernelTailCircuitPublicInputs,
|
|
34
39
|
} from '@aztec/stdlib/kernel';
|
|
40
|
+
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
41
|
+
import { deriveEcdhSharedSecretPoint, protectFromForgery } from '@aztec/stdlib/logs';
|
|
35
42
|
import {
|
|
36
43
|
BlockHeader,
|
|
37
44
|
type ContractOverrides,
|
|
@@ -47,25 +54,27 @@ import {
|
|
|
47
54
|
TxProfileResult,
|
|
48
55
|
TxProvingResult,
|
|
49
56
|
TxSimulationResult,
|
|
50
|
-
|
|
57
|
+
UtilityExecutionResult,
|
|
51
58
|
} from '@aztec/stdlib/tx';
|
|
52
59
|
|
|
53
60
|
import { inspect } from 'util';
|
|
54
61
|
|
|
55
62
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
63
|
import type { PXEConfig } from './config/index.js';
|
|
57
|
-
import {
|
|
64
|
+
import { ContractClassService } from './contract/contract_class_service.js';
|
|
65
|
+
import { ContractSyncService } from './contract/contract_sync_service.js';
|
|
58
66
|
import {
|
|
59
67
|
ContractFunctionSimulator,
|
|
60
68
|
generateSimulatedProvingResult,
|
|
61
69
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
-
import {
|
|
63
|
-
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
64
|
-
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
70
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
65
71
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
66
72
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
67
73
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
74
|
+
import type { ExecutionHooks } from './hooks/index.js';
|
|
68
75
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
76
|
+
import { TxResolverService } from './messages/tx_resolver_service.js';
|
|
77
|
+
import { type CachingAztecNode, withCache } from './node/caching_aztec_node.js';
|
|
69
78
|
import {
|
|
70
79
|
PrivateKernelExecutionProver,
|
|
71
80
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -75,44 +84,183 @@ import { AddressStore } from './storage/address_store/address_store.js';
|
|
|
75
84
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
76
85
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
77
86
|
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
87
|
+
import { FactStore } from './storage/fact_store/index.js';
|
|
78
88
|
import { NoteStore } from './storage/note_store/note_store.js';
|
|
89
|
+
import { openPxeStores } from './storage/open_pxe_stores.js';
|
|
79
90
|
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
80
91
|
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
81
|
-
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
82
92
|
import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
|
|
93
|
+
import {
|
|
94
|
+
type SharedSecretKind,
|
|
95
|
+
TaggingSecretSourcesStore,
|
|
96
|
+
} from './storage/tagging_store/tagging_secret_sources_store.js';
|
|
97
|
+
import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
83
98
|
|
|
84
99
|
export type PackedPrivateEvent = InTx & {
|
|
85
100
|
packedEvent: Fr[];
|
|
86
101
|
eventSelector: EventSelector;
|
|
87
102
|
};
|
|
88
103
|
|
|
104
|
+
/** Options for PXE.proveTx. */
|
|
105
|
+
export type ProveTxOpts = {
|
|
106
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
107
|
+
scopes: AztecAddress[];
|
|
108
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
109
|
+
senderForTags?: AztecAddress;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** Options for PXE.profileTx. */
|
|
113
|
+
export type ProfileTxOpts = {
|
|
114
|
+
/** The profiling mode to use. */
|
|
115
|
+
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
116
|
+
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
117
|
+
skipProofGeneration?: boolean;
|
|
118
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
119
|
+
scopes: AztecAddress[];
|
|
120
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
121
|
+
senderForTags?: AztecAddress;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Options for PXE.simulateTx. */
|
|
125
|
+
export type SimulateTxOpts = {
|
|
126
|
+
/** Whether to simulate the public part of the transaction. */
|
|
127
|
+
simulatePublic: boolean;
|
|
128
|
+
/** If false, this function throws if the transaction is unable to be included in a block at the current state. */
|
|
129
|
+
skipTxValidation?: boolean;
|
|
130
|
+
/** If false, fees are enforced. */
|
|
131
|
+
skipFeeEnforcement?: boolean;
|
|
132
|
+
/** If true, kernel logic is emulated in TS for simulation */
|
|
133
|
+
skipKernels?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Pre-simulation overrides applied to the ephemeral fork and contract DB. Bundles publicStorage
|
|
136
|
+
* writes (no skipKernels required) and per-address (instance, artifact?) overrides used by both
|
|
137
|
+
* AVM-side public dispatch and PXE-side ACIR private dispatch (requires skipKernels: true).
|
|
138
|
+
*/
|
|
139
|
+
overrides?: SimulationOverrides;
|
|
140
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
141
|
+
scopes: AztecAddress[];
|
|
142
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
143
|
+
senderForTags?: AztecAddress;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** Options for PXE.executeUtility. */
|
|
147
|
+
export type ExecuteUtilityOpts = {
|
|
148
|
+
/** The authentication witnesses required for the function call. */
|
|
149
|
+
authwits?: AuthWitness[];
|
|
150
|
+
/** The accounts whose notes we can access in this call */
|
|
151
|
+
scopes: AztecAddress[];
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Supplies the set of "nice to have" contracts that every PXE preloads regardless of which wallet
|
|
156
|
+
* drives it. Today this is just the standard multi-call entrypoint: the SDK's self-paid account
|
|
157
|
+
* deploy flow ({@link DeployAccountMethod} with `from = NO_FROM`) routes its payload through it, so a
|
|
158
|
+
* PXE that did not register it would fail contract sync with an opaque "no contract instance" error.
|
|
159
|
+
*
|
|
160
|
+
* Returning a list keeps this extensible: a wallet may supply its own provider that preloads
|
|
161
|
+
* additional contracts. Injected the same way as {@link ProtocolContractsProvider} so the PXE never
|
|
162
|
+
* statically imports the bundled artifacts, keeping the bundle/lazy split intact.
|
|
163
|
+
*/
|
|
164
|
+
export type PreloadedContractsProvider = {
|
|
165
|
+
/** Returns the contract instances and artifacts the PXE should preload on startup. */
|
|
166
|
+
getPreloadedContracts: () => Promise<Array<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }>>;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** Args for PXE.create. */
|
|
170
|
+
export type PXECreateArgs = {
|
|
171
|
+
/** The Aztec node to connect to. */
|
|
172
|
+
node: AztecNode;
|
|
173
|
+
/**
|
|
174
|
+
* Optional debug API client. When provided, public function signatures are registered with the node so that
|
|
175
|
+
* node-side public-execution stack traces can be named. Skipped when the node does not expose the debug API.
|
|
176
|
+
*/
|
|
177
|
+
nodeDebug?: AztecNodeDebug;
|
|
178
|
+
/** The key-value store for persisting PXE state. */
|
|
179
|
+
store: AztecAsyncKVStore;
|
|
180
|
+
/** The prover for generating private kernel proofs. */
|
|
181
|
+
proofCreator: PrivateKernelProver;
|
|
182
|
+
/** The circuit simulator for executing ACIR circuits. */
|
|
183
|
+
simulator: CircuitSimulator;
|
|
184
|
+
/** Provider for protocol contract artifacts and instances. */
|
|
185
|
+
protocolContractsProvider: ProtocolContractsProvider;
|
|
186
|
+
/**
|
|
187
|
+
* Contracts to preload on startup. Injected by the entrypoint with the bundle-or-lazy flavor that
|
|
188
|
+
* matches the runtime (bundle for node/eager browser, lazy for code-split browser), so the PXE
|
|
189
|
+
* never statically imports a standard-contract artifact and the bundle/lazy split stays intact.
|
|
190
|
+
*/
|
|
191
|
+
preloadedContractsProvider: PreloadedContractsProvider;
|
|
192
|
+
/** PXE configuration options. */
|
|
193
|
+
config: PXEConfig;
|
|
194
|
+
/** Optional logger instance or string suffix for the logger name. */
|
|
195
|
+
loggerOrSuffix?: string | Logger;
|
|
196
|
+
/** Optional hooks to observe and influence contract execution. */
|
|
197
|
+
hooks?: ExecutionHooks;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/** A source from which PXE derives the tagging secrets it scans for to discover incoming private logs. */
|
|
201
|
+
export type TaggingSecretSource =
|
|
202
|
+
/**
|
|
203
|
+
* Derives a shared secret via ECDH from an external `sender` address against every account registered in this PXE
|
|
204
|
+
* (present and future), so registering one sender applies it to all of them. The address is not secret, so unlike
|
|
205
|
+
* `arbitrary-secret` it can be reused freely across recipients.
|
|
206
|
+
*/
|
|
207
|
+
| { kind: 'address-derived'; sender: AztecAddress }
|
|
208
|
+
/**
|
|
209
|
+
* A shared secret point provided directly, scoped to a single recipient. It bypasses ECDH, so it must not be
|
|
210
|
+
* reused across recipients (each would then be able to find the others' tags).
|
|
211
|
+
*/
|
|
212
|
+
| { kind: 'arbitrary-secret'; recipient: AztecAddress; secret: Point }
|
|
213
|
+
/**
|
|
214
|
+
* A handshake known by the x-coordinate of its ephemeral public key (the value a recipient learns while authorizing
|
|
215
|
+
* an interactive handshake, which emits no discoverable announcement). The ephemeral key's y-coordinate is always
|
|
216
|
+
* positive by protocol construction, so the x-coordinate alone identifies it.
|
|
217
|
+
*/
|
|
218
|
+
| { kind: 'handshake'; recipient: AztecAddress; ephPk: Fr };
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The registered form of a {@link TaggingSecretSource}.
|
|
222
|
+
*/
|
|
223
|
+
export type RegisteredTaggingSecretSource =
|
|
224
|
+
| Exclude<TaggingSecretSource, { kind: 'handshake' }>
|
|
225
|
+
/** A handshake's resolved shared secret, derived at registration from the handshake's ephemeral key. */
|
|
226
|
+
| { kind: 'handshake'; recipient: AztecAddress; secret: Point };
|
|
227
|
+
|
|
89
228
|
/**
|
|
90
229
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
91
230
|
* manage private state of users.
|
|
92
231
|
*/
|
|
93
232
|
export class PXE {
|
|
94
233
|
private constructor(
|
|
95
|
-
private node:
|
|
234
|
+
private node: CachingAztecNode,
|
|
235
|
+
private nodeDebug: AztecNodeDebug | undefined,
|
|
236
|
+
private db: AztecAsyncKVStore,
|
|
96
237
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
97
238
|
private keyStore: KeyStore,
|
|
98
239
|
private contractStore: ContractStore,
|
|
99
240
|
private noteStore: NoteStore,
|
|
100
241
|
private capsuleStore: CapsuleStore,
|
|
242
|
+
private factStore: FactStore,
|
|
101
243
|
private anchorBlockStore: AnchorBlockStore,
|
|
102
244
|
private senderTaggingStore: SenderTaggingStore,
|
|
103
|
-
private
|
|
245
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
104
246
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
105
247
|
private addressStore: AddressStore,
|
|
106
248
|
private privateEventStore: PrivateEventStore,
|
|
107
249
|
private contractSyncService: ContractSyncService,
|
|
250
|
+
private contractClassService: ContractClassService,
|
|
251
|
+
private txResolver: TxResolverService,
|
|
252
|
+
private l2TipsStore: L2TipsProvider,
|
|
108
253
|
private simulator: CircuitSimulator,
|
|
109
254
|
private proverEnabled: boolean,
|
|
255
|
+
private autoSync: boolean,
|
|
110
256
|
private proofCreator: PrivateKernelProver,
|
|
111
257
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
258
|
+
private preloadedContractsProvider: PreloadedContractsProvider,
|
|
112
259
|
private log: Logger,
|
|
113
260
|
private jobQueue: SerialQueue,
|
|
114
261
|
private jobCoordinator: JobCoordinator,
|
|
115
262
|
public debug: PXEDebugUtils,
|
|
263
|
+
private hooks: ExecutionHooks | undefined,
|
|
116
264
|
) {}
|
|
117
265
|
|
|
118
266
|
/**
|
|
@@ -122,15 +270,18 @@ export class PXE {
|
|
|
122
270
|
*
|
|
123
271
|
* @returns A promise that resolves PXE is ready to be used.
|
|
124
272
|
*/
|
|
125
|
-
public static async create(
|
|
126
|
-
node
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
273
|
+
public static async create({
|
|
274
|
+
node,
|
|
275
|
+
nodeDebug,
|
|
276
|
+
store,
|
|
277
|
+
proofCreator,
|
|
278
|
+
simulator,
|
|
279
|
+
protocolContractsProvider,
|
|
280
|
+
preloadedContractsProvider,
|
|
281
|
+
config,
|
|
282
|
+
loggerOrSuffix,
|
|
283
|
+
hooks,
|
|
284
|
+
}: PXECreateArgs) {
|
|
134
285
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
135
286
|
const bindings: LoggerBindings | undefined =
|
|
136
287
|
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
@@ -140,31 +291,53 @@ export class PXE {
|
|
|
140
291
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
141
292
|
: loggerOrSuffix;
|
|
142
293
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
const
|
|
294
|
+
const info = await node.getNodeInfo();
|
|
295
|
+
|
|
296
|
+
// Source the genesis block hash from the node so PXE's L2BlockStream agrees with the node's
|
|
297
|
+
// archiver on the dynamic initial header hash. Without this the tip store would fall back to
|
|
298
|
+
// the static `GENESIS_BLOCK_HEADER_HASH` constant, which only matches deployments with the
|
|
299
|
+
// default empty genesis (timestamp 0, no prefilled public data) and diverges otherwise — the
|
|
300
|
+
// sync at block 0 would then get stuck in `areBlockHashesEqualAt` and abort. If the node does
|
|
301
|
+
// not return a genesis block (older node or test fixture) we fall back to the static constant.
|
|
302
|
+
const initialBlockHash = (await node.getBlock(BlockNumber.ZERO))?.hash ?? GENESIS_BLOCK_HEADER_HASH;
|
|
303
|
+
|
|
304
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
305
|
+
const {
|
|
306
|
+
addressStore,
|
|
307
|
+
privateEventStore,
|
|
308
|
+
contractStore,
|
|
309
|
+
noteStore,
|
|
310
|
+
anchorBlockStore,
|
|
311
|
+
senderTaggingStore,
|
|
312
|
+
taggingSecretSourcesStore,
|
|
313
|
+
recipientTaggingStore,
|
|
314
|
+
capsuleStore,
|
|
315
|
+
keyStore,
|
|
316
|
+
l2TipsStore,
|
|
317
|
+
factStore,
|
|
318
|
+
} = openPxeStores(store, initialBlockHash);
|
|
319
|
+
// Every PXE consumer reads through this one wrapper, so a read cached by one is served to the rest. Only
|
|
320
|
+
// immutable, hash-pinned reads are cached (the rule lives on `withCache`), which makes it safe regardless of
|
|
321
|
+
// the consumer's anchor block; the block synchronizer wipes it on anchor updates to bound memory.
|
|
322
|
+
const readCachedNode = withCache(node);
|
|
323
|
+
const contractClassService = new ContractClassService(readCachedNode, contractStore);
|
|
155
324
|
const contractSyncService = new ContractSyncService(
|
|
156
|
-
|
|
325
|
+
readCachedNode,
|
|
157
326
|
contractStore,
|
|
327
|
+
contractClassService,
|
|
158
328
|
noteStore,
|
|
159
329
|
createLogger('pxe:contract_sync', bindings),
|
|
160
330
|
);
|
|
331
|
+
const txResolver = new TxResolverService(readCachedNode);
|
|
332
|
+
|
|
161
333
|
const synchronizer = new BlockSynchronizer(
|
|
162
|
-
|
|
334
|
+
readCachedNode,
|
|
163
335
|
store,
|
|
164
336
|
anchorBlockStore,
|
|
165
337
|
noteStore,
|
|
166
338
|
privateEventStore,
|
|
167
|
-
|
|
339
|
+
factStore,
|
|
340
|
+
l2TipsStore,
|
|
168
341
|
contractSyncService,
|
|
169
342
|
config,
|
|
170
343
|
bindings,
|
|
@@ -177,6 +350,7 @@ export class PXE {
|
|
|
177
350
|
recipientTaggingStore,
|
|
178
351
|
privateEventStore,
|
|
179
352
|
noteStore,
|
|
353
|
+
factStore,
|
|
180
354
|
contractSyncService,
|
|
181
355
|
]);
|
|
182
356
|
|
|
@@ -185,39 +359,47 @@ export class PXE {
|
|
|
185
359
|
const jobQueue = new SerialQueue();
|
|
186
360
|
|
|
187
361
|
const pxe = new PXE(
|
|
188
|
-
|
|
362
|
+
readCachedNode,
|
|
363
|
+
nodeDebug,
|
|
364
|
+
store,
|
|
189
365
|
synchronizer,
|
|
190
366
|
keyStore,
|
|
191
367
|
contractStore,
|
|
192
368
|
noteStore,
|
|
193
369
|
capsuleStore,
|
|
370
|
+
factStore,
|
|
194
371
|
anchorBlockStore,
|
|
195
372
|
senderTaggingStore,
|
|
196
|
-
|
|
373
|
+
taggingSecretSourcesStore,
|
|
197
374
|
recipientTaggingStore,
|
|
198
375
|
addressStore,
|
|
199
376
|
privateEventStore,
|
|
200
377
|
contractSyncService,
|
|
378
|
+
contractClassService,
|
|
379
|
+
txResolver,
|
|
380
|
+
l2TipsStore,
|
|
201
381
|
simulator,
|
|
202
382
|
proverEnabled,
|
|
383
|
+
config.autoSync,
|
|
203
384
|
proofCreator,
|
|
204
385
|
protocolContractsProvider,
|
|
386
|
+
preloadedContractsProvider,
|
|
205
387
|
log,
|
|
206
388
|
jobQueue,
|
|
207
389
|
jobCoordinator,
|
|
208
390
|
debugUtils,
|
|
391
|
+
hooks,
|
|
209
392
|
);
|
|
210
393
|
|
|
211
394
|
debugUtils.setPXEHelpers(
|
|
212
395
|
pxe.#putInJobQueue.bind(pxe),
|
|
213
396
|
pxe.#getSimulatorForTx.bind(pxe),
|
|
214
|
-
pxe.#
|
|
397
|
+
pxe.#executeUtility.bind(pxe),
|
|
215
398
|
);
|
|
216
399
|
|
|
217
400
|
pxe.jobQueue.start();
|
|
218
401
|
|
|
219
|
-
await pxe.#registerProtocolContracts();
|
|
220
|
-
const info = await node.getNodeInfo();
|
|
402
|
+
await allToCompletion([pxe.#registerProtocolContracts(), pxe.#registerPreloadedContracts()]);
|
|
221
403
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
222
404
|
return pxe;
|
|
223
405
|
}
|
|
@@ -225,22 +407,50 @@ export class PXE {
|
|
|
225
407
|
// Internal methods
|
|
226
408
|
|
|
227
409
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
228
|
-
|
|
410
|
+
return new ContractFunctionSimulator({
|
|
411
|
+
contractStore: this.contractStore,
|
|
412
|
+
contractClassService: this.contractClassService,
|
|
413
|
+
overrides: overrides?.contracts,
|
|
414
|
+
noteStore: this.noteStore,
|
|
415
|
+
keyStore: this.keyStore,
|
|
416
|
+
addressStore: this.addressStore,
|
|
417
|
+
aztecNode: this.node,
|
|
418
|
+
l2TipsStore: this.l2TipsStore,
|
|
419
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
420
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
421
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
422
|
+
capsuleStore: this.capsuleStore,
|
|
423
|
+
factStore: this.factStore,
|
|
424
|
+
privateEventStore: this.privateEventStore,
|
|
425
|
+
simulator: this.simulator,
|
|
426
|
+
contractSyncService: this.contractSyncService,
|
|
427
|
+
txResolver: this.txResolver,
|
|
428
|
+
hooks: this.hooks,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
229
431
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
432
|
+
/** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
|
|
433
|
+
async #getDebugFunctionName(
|
|
434
|
+
address: AztecAddress,
|
|
435
|
+
selector: FunctionSelector,
|
|
436
|
+
anchorBlockHeader: BlockHeader,
|
|
437
|
+
): Promise<string> {
|
|
438
|
+
try {
|
|
439
|
+
const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
|
|
440
|
+
return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
|
|
441
|
+
} catch {
|
|
442
|
+
return `${address}:${selector}`;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */
|
|
447
|
+
async #getDebugContractName(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<string | undefined> {
|
|
448
|
+
try {
|
|
449
|
+
const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
|
|
450
|
+
return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
|
|
451
|
+
} catch {
|
|
452
|
+
return undefined;
|
|
453
|
+
}
|
|
244
454
|
}
|
|
245
455
|
|
|
246
456
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -290,83 +500,112 @@ export class PXE {
|
|
|
290
500
|
}
|
|
291
501
|
|
|
292
502
|
async #registerProtocolContracts() {
|
|
293
|
-
const registered
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
503
|
+
const registered = Object.fromEntries(
|
|
504
|
+
await allToCompletion(
|
|
505
|
+
protocolContractNames.map(async name => {
|
|
506
|
+
const { address, instance, artifact } =
|
|
507
|
+
await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
508
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
509
|
+
await this.contractStore.addContractInstance(instance);
|
|
510
|
+
return [name, address.toString()] as const;
|
|
511
|
+
}),
|
|
512
|
+
),
|
|
513
|
+
);
|
|
301
514
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
302
515
|
}
|
|
303
516
|
|
|
517
|
+
async #registerPreloadedContracts() {
|
|
518
|
+
const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
|
|
519
|
+
await allToCompletion(
|
|
520
|
+
contracts.map(async ({ instance, artifact }) => {
|
|
521
|
+
if (artifact) {
|
|
522
|
+
await this.registerContractClass(artifact);
|
|
523
|
+
}
|
|
524
|
+
await this.registerContract(instance);
|
|
525
|
+
}),
|
|
526
|
+
);
|
|
527
|
+
this.log.verbose(`Registered preloaded contracts in pxe`, {
|
|
528
|
+
contracts: contracts.map(({ instance }) => instance.address.toString()),
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
304
532
|
// Executes the entrypoint private function, as well as all nested private
|
|
305
533
|
// functions that might arise.
|
|
306
|
-
async #executePrivate(
|
|
307
|
-
contractFunctionSimulator
|
|
308
|
-
txRequest
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
534
|
+
async #executePrivate({
|
|
535
|
+
contractFunctionSimulator,
|
|
536
|
+
txRequest,
|
|
537
|
+
anchorBlockHeader,
|
|
538
|
+
scopes,
|
|
539
|
+
jobId,
|
|
540
|
+
senderForTags,
|
|
541
|
+
}: {
|
|
542
|
+
contractFunctionSimulator: ContractFunctionSimulator;
|
|
543
|
+
txRequest: TxExecutionRequest;
|
|
544
|
+
anchorBlockHeader: BlockHeader;
|
|
545
|
+
scopes: AztecAddress[];
|
|
546
|
+
jobId: string;
|
|
547
|
+
senderForTags?: AztecAddress;
|
|
548
|
+
}): Promise<PrivateExecutionResult> {
|
|
312
549
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
313
550
|
|
|
314
551
|
try {
|
|
315
|
-
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
316
|
-
|
|
317
552
|
await this.contractSyncService.ensureContractSynced(
|
|
318
553
|
contractAddress,
|
|
319
554
|
functionSelector,
|
|
320
|
-
|
|
555
|
+
(privateSyncCall, execScopes) =>
|
|
556
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
321
557
|
anchorBlockHeader,
|
|
322
558
|
jobId,
|
|
559
|
+
scopes,
|
|
323
560
|
);
|
|
324
561
|
|
|
325
|
-
const result = await contractFunctionSimulator.run(
|
|
326
|
-
txRequest,
|
|
327
|
-
contractAddress,
|
|
328
|
-
functionSelector,
|
|
329
|
-
undefined,
|
|
562
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
330
563
|
anchorBlockHeader,
|
|
331
|
-
// The sender for tags is set by contracts, typically by an account
|
|
332
|
-
// contract entrypoint
|
|
333
|
-
undefined, // senderForTags
|
|
334
564
|
scopes,
|
|
335
565
|
jobId,
|
|
336
|
-
|
|
566
|
+
senderForTags,
|
|
567
|
+
});
|
|
337
568
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
338
569
|
return result;
|
|
339
570
|
} catch (err) {
|
|
340
571
|
if (err instanceof SimulationError) {
|
|
341
|
-
await enrichSimulationError(err, this.contractStore, this.log);
|
|
572
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
342
573
|
}
|
|
343
574
|
throw err;
|
|
344
575
|
}
|
|
345
576
|
}
|
|
346
577
|
|
|
347
578
|
/**
|
|
348
|
-
*
|
|
579
|
+
* Execute a utility function call on the given contract.
|
|
349
580
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
350
581
|
* @param call - The function call to execute.
|
|
351
582
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
352
583
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
353
584
|
* accounts if not specified.
|
|
354
585
|
* @param jobId - The job ID for staged writes.
|
|
355
|
-
* @returns The
|
|
586
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
356
587
|
*/
|
|
357
|
-
async #
|
|
588
|
+
async #executeUtility(
|
|
358
589
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
359
590
|
call: FunctionCall,
|
|
360
591
|
authWitnesses: AuthWitness[] | undefined,
|
|
361
|
-
scopes: AztecAddress[]
|
|
592
|
+
scopes: AztecAddress[],
|
|
362
593
|
jobId: string,
|
|
363
594
|
) {
|
|
364
595
|
try {
|
|
365
596
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
366
|
-
|
|
597
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
|
|
598
|
+
call,
|
|
599
|
+
authWitnesses ?? [],
|
|
600
|
+
anchorBlockHeader,
|
|
601
|
+
scopes,
|
|
602
|
+
jobId,
|
|
603
|
+
);
|
|
604
|
+
return { result, offchainEffects };
|
|
367
605
|
} catch (err) {
|
|
368
606
|
if (err instanceof SimulationError) {
|
|
369
|
-
|
|
607
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
608
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
370
609
|
}
|
|
371
610
|
throw err;
|
|
372
611
|
}
|
|
@@ -378,11 +617,11 @@ export class PXE {
|
|
|
378
617
|
* It can also be used for estimating gas in the future.
|
|
379
618
|
* @param tx - The transaction to be simulated.
|
|
380
619
|
*/
|
|
381
|
-
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean) {
|
|
620
|
+
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean, overrides?: SimulationOverrides) {
|
|
382
621
|
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
383
622
|
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
384
623
|
try {
|
|
385
|
-
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
|
|
624
|
+
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement, overrides);
|
|
386
625
|
if (result.revertReason) {
|
|
387
626
|
throw result.revertReason;
|
|
388
627
|
}
|
|
@@ -390,7 +629,14 @@ export class PXE {
|
|
|
390
629
|
} catch (err) {
|
|
391
630
|
if (err instanceof SimulationError) {
|
|
392
631
|
try {
|
|
393
|
-
|
|
632
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
633
|
+
await enrichPublicSimulationError(
|
|
634
|
+
err,
|
|
635
|
+
this.contractStore,
|
|
636
|
+
this.contractClassService,
|
|
637
|
+
anchorBlockHeader,
|
|
638
|
+
this.log,
|
|
639
|
+
);
|
|
394
640
|
} catch (enrichErr) {
|
|
395
641
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
396
642
|
}
|
|
@@ -414,11 +660,16 @@ export class PXE {
|
|
|
414
660
|
txExecutionRequest: TxExecutionRequest,
|
|
415
661
|
proofCreator: PrivateKernelProver,
|
|
416
662
|
privateExecutionResult: PrivateExecutionResult,
|
|
663
|
+
anchorBlockHeader: BlockHeader,
|
|
417
664
|
config: PrivateKernelExecutionProverConfig,
|
|
418
665
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
666
|
+
const kernelOracle = new PrivateKernelOracle(
|
|
667
|
+
this.contractStore,
|
|
668
|
+
this.contractClassService,
|
|
669
|
+
this.keyStore,
|
|
670
|
+
this.node,
|
|
671
|
+
anchorBlockHeader,
|
|
672
|
+
);
|
|
422
673
|
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
423
674
|
kernelOracle,
|
|
424
675
|
proofCreator,
|
|
@@ -429,22 +680,44 @@ export class PXE {
|
|
|
429
680
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
430
681
|
}
|
|
431
682
|
|
|
683
|
+
/**
|
|
684
|
+
* Syncs with the node only when `autoSync` is enabled.
|
|
685
|
+
* When `autoSync` is disabled, callers (typically a wallet) are
|
|
686
|
+
* responsible for invoking `pxe.sync()` at the right granularity.
|
|
687
|
+
*/
|
|
688
|
+
async #maybeSync(): Promise<void> {
|
|
689
|
+
if (this.autoSync) {
|
|
690
|
+
await this.blockStateSynchronizer.sync();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
432
694
|
// Public API
|
|
433
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Triggers a sync of PXE state with the node, regardless of the `autoSync` config flag. Use this to
|
|
698
|
+
* batch syncs across composite flows when `autoSync` is disabled (e.g. one sync per simulate+send
|
|
699
|
+
* instead of one per inner PXE call). Serialized through the job queue.
|
|
700
|
+
*/
|
|
701
|
+
public sync(): Promise<void> {
|
|
702
|
+
return this.#putInJobQueue(() => this.blockStateSynchronizer.sync());
|
|
703
|
+
}
|
|
704
|
+
|
|
434
705
|
/**
|
|
435
706
|
* Returns the block header up to which the PXE has synced.
|
|
436
707
|
* @returns The synced block header
|
|
437
708
|
*/
|
|
438
709
|
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
439
|
-
return this
|
|
710
|
+
return this.#putInJobQueue(() => {
|
|
711
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
712
|
+
});
|
|
440
713
|
}
|
|
441
714
|
|
|
442
715
|
/**
|
|
443
|
-
* Returns the contract instance
|
|
716
|
+
* Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
|
|
444
717
|
* @param address - The contract address.
|
|
445
|
-
* @returns The contract instance if found, undefined otherwise.
|
|
718
|
+
* @returns The contract instance address preimage if found, undefined otherwise.
|
|
446
719
|
*/
|
|
447
|
-
public getContractInstance(address: AztecAddress): Promise<
|
|
720
|
+
public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
|
|
448
721
|
return this.contractStore.getContractInstance(address);
|
|
449
722
|
}
|
|
450
723
|
|
|
@@ -458,19 +731,23 @@ export class PXE {
|
|
|
458
731
|
}
|
|
459
732
|
|
|
460
733
|
/**
|
|
461
|
-
* Registers a user account in PXE
|
|
462
|
-
*
|
|
463
|
-
* the
|
|
464
|
-
*
|
|
734
|
+
* Registers a user account in PXE.
|
|
735
|
+
*
|
|
736
|
+
* PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
|
|
737
|
+
* secret keys are withheld, since PXE is not trusted to hold them.
|
|
738
|
+
*
|
|
739
|
+
* Does nothing if the account is already registered.
|
|
465
740
|
*
|
|
466
|
-
*
|
|
741
|
+
* The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
|
|
742
|
+
*
|
|
743
|
+
* @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
|
|
467
744
|
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
468
745
|
* @returns The complete address of the account.
|
|
469
746
|
*/
|
|
470
|
-
public async registerAccount(
|
|
747
|
+
public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
471
748
|
const accounts = await this.keyStore.getAccounts();
|
|
472
|
-
const accountCompleteAddress = await this.keyStore.addAccount(
|
|
473
|
-
if (accounts.
|
|
749
|
+
const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
|
|
750
|
+
if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
|
|
474
751
|
this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
|
|
475
752
|
return accountCompleteAddress;
|
|
476
753
|
} else {
|
|
@@ -483,53 +760,189 @@ export class PXE {
|
|
|
483
760
|
}
|
|
484
761
|
|
|
485
762
|
/**
|
|
486
|
-
*
|
|
763
|
+
* Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
|
|
764
|
+
* outgoing-viewing, tagging).
|
|
765
|
+
*
|
|
766
|
+
* These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
|
|
767
|
+
* spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
|
|
768
|
+
* messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
|
|
487
769
|
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
770
|
+
* Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
|
|
771
|
+
* and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
|
|
772
|
+
* these keys. Applications should NEVER be given access to them.
|
|
490
773
|
*
|
|
491
|
-
* @
|
|
492
|
-
* @returns The address of the sender.
|
|
493
|
-
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
774
|
+
* @throws If the account is not registered.
|
|
494
775
|
*/
|
|
495
|
-
public
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
499
|
-
return sender;
|
|
500
|
-
}
|
|
776
|
+
public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
|
|
777
|
+
return this.keyStore.getAccountSecretKeys(account);
|
|
778
|
+
}
|
|
501
779
|
|
|
502
|
-
|
|
780
|
+
/**
|
|
781
|
+
* Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
|
|
782
|
+
* See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
|
|
783
|
+
*
|
|
784
|
+
* After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
|
|
785
|
+
* re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
|
|
786
|
+
* notes/events are not discarded.
|
|
787
|
+
*/
|
|
788
|
+
public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
|
|
789
|
+
let wasAdded: boolean;
|
|
790
|
+
|
|
791
|
+
switch (source.kind) {
|
|
792
|
+
case 'address-derived':
|
|
793
|
+
wasAdded = await this.#registerSender(source.sender);
|
|
794
|
+
break;
|
|
795
|
+
case 'arbitrary-secret':
|
|
796
|
+
wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
|
|
797
|
+
break;
|
|
798
|
+
case 'handshake':
|
|
799
|
+
wasAdded = await this.#registerSharedSecret(
|
|
800
|
+
source.recipient,
|
|
801
|
+
'handshake',
|
|
802
|
+
await this.#deriveHandshakeSecret(source.recipient, source.ephPk),
|
|
803
|
+
);
|
|
804
|
+
break;
|
|
805
|
+
default: {
|
|
806
|
+
const _: never = source;
|
|
807
|
+
throw new Error('Unhandled tagging secret source kind');
|
|
808
|
+
}
|
|
809
|
+
}
|
|
503
810
|
|
|
504
811
|
if (wasAdded) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
812
|
+
// Queued to avoid wiping while a job is in flight.
|
|
813
|
+
await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
|
|
508
814
|
}
|
|
815
|
+
}
|
|
509
816
|
|
|
510
|
-
|
|
817
|
+
/**
|
|
818
|
+
* Removes a previously registered tagging secret source, identified by its registered form (see
|
|
819
|
+
* {@link getTaggingSecretSources}). Does nothing if it was not registered.
|
|
820
|
+
*/
|
|
821
|
+
public async removeTaggingSecretSource(source: RegisteredTaggingSecretSource): Promise<void> {
|
|
822
|
+
switch (source.kind) {
|
|
823
|
+
case 'address-derived': {
|
|
824
|
+
const { sender } = source;
|
|
825
|
+
const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
|
|
826
|
+
this.log.info(
|
|
827
|
+
wasRemoved
|
|
828
|
+
? `Removed sender:\n ${sender.toString()}`
|
|
829
|
+
: `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
|
|
830
|
+
);
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
case 'arbitrary-secret':
|
|
834
|
+
case 'handshake': {
|
|
835
|
+
const { kind, recipient, secret } = source;
|
|
836
|
+
const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
|
|
837
|
+
this.log.info(
|
|
838
|
+
wasRemoved
|
|
839
|
+
? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}`
|
|
840
|
+
: `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`,
|
|
841
|
+
);
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
default: {
|
|
845
|
+
const _: never = source;
|
|
846
|
+
throw new Error('Unhandled tagging secret source kind');
|
|
847
|
+
}
|
|
848
|
+
}
|
|
511
849
|
}
|
|
512
850
|
|
|
513
851
|
/**
|
|
514
|
-
* Retrieves
|
|
515
|
-
*
|
|
852
|
+
* Retrieves the tagging secret sources registered in this PXE, in their registered form. Without a filter it
|
|
853
|
+
* returns every source; pass `{ kind }` to narrow to a single variant. See {@link RegisteredTaggingSecretSource}.
|
|
516
854
|
*/
|
|
517
|
-
public
|
|
518
|
-
|
|
855
|
+
public getTaggingSecretSources<K extends RegisteredTaggingSecretSource['kind']>(filter: {
|
|
856
|
+
kind: K;
|
|
857
|
+
}): Promise<Extract<RegisteredTaggingSecretSource, { kind: K }>[]>;
|
|
858
|
+
public getTaggingSecretSources(): Promise<RegisteredTaggingSecretSource[]>;
|
|
859
|
+
public async getTaggingSecretSources(filter?: {
|
|
860
|
+
kind?: RegisteredTaggingSecretSource['kind'];
|
|
861
|
+
}): Promise<RegisteredTaggingSecretSource[]> {
|
|
862
|
+
const [senders, secrets] = await allToCompletion([
|
|
863
|
+
this.taggingSecretSourcesStore.getSenders(),
|
|
864
|
+
this.taggingSecretSourcesStore.getAllSharedSecrets(),
|
|
865
|
+
]);
|
|
866
|
+
|
|
867
|
+
const sources: RegisteredTaggingSecretSource[] = [
|
|
868
|
+
...senders.map((sender): RegisteredTaggingSecretSource => ({ kind: 'address-derived', sender })),
|
|
869
|
+
...secrets.map(({ recipient, kind, secret }): RegisteredTaggingSecretSource => ({ kind, recipient, secret })),
|
|
870
|
+
];
|
|
871
|
+
|
|
872
|
+
return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
|
|
876
|
+
async #registerSender(address: AztecAddress): Promise<boolean> {
|
|
877
|
+
if (!(await address.isValid())) {
|
|
878
|
+
throw new Error(
|
|
879
|
+
`Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
const accounts = await this.keyStore.getAccounts();
|
|
884
|
+
if (accounts.some(a => a.equals(address))) {
|
|
885
|
+
this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
|
|
890
|
+
this.log.info(
|
|
891
|
+
wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
|
|
892
|
+
);
|
|
893
|
+
return wasAdded;
|
|
519
894
|
}
|
|
520
895
|
|
|
521
896
|
/**
|
|
522
|
-
*
|
|
523
|
-
*
|
|
897
|
+
* Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
|
|
898
|
+
* `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
|
|
899
|
+
* matching the protected secret the registry stores and the derivation the recipient-side scan uses for
|
|
900
|
+
* handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
|
|
901
|
+
* matching how the protocol generates it.
|
|
902
|
+
*
|
|
903
|
+
* @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
|
|
904
|
+
* this PXE, since the derivation needs its keys.
|
|
524
905
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
906
|
+
async #deriveHandshakeSecret(recipient: AztecAddress, ephPk: Fr): Promise<Point> {
|
|
907
|
+
let ephPkPoint: Point;
|
|
908
|
+
try {
|
|
909
|
+
ephPkPoint = await Point.fromXAndSign(ephPk, true);
|
|
910
|
+
} catch {
|
|
911
|
+
throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
|
|
912
|
+
}
|
|
527
913
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
914
|
+
const completeAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
915
|
+
if (!completeAddress || !(await this.keyStore.hasAccount(recipient))) {
|
|
916
|
+
throw new Error(
|
|
917
|
+
`Recipient ${recipient} is not an account of this PXE. A handshake's shared secret can only be derived for an account whose keys are held.`,
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
922
|
+
const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
|
|
923
|
+
const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
|
|
924
|
+
return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */
|
|
928
|
+
async #registerSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
|
|
929
|
+
if (!(await recipient.isValid())) {
|
|
930
|
+
throw new Error(
|
|
931
|
+
`Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
if (secret.isZero() || !secret.isOnCurve()) {
|
|
936
|
+
throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
|
|
532
937
|
}
|
|
938
|
+
|
|
939
|
+
const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
|
|
940
|
+
this.log.info(
|
|
941
|
+
wasAdded
|
|
942
|
+
? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}`
|
|
943
|
+
: `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`,
|
|
944
|
+
);
|
|
945
|
+
return wasAdded;
|
|
533
946
|
}
|
|
534
947
|
|
|
535
948
|
/**
|
|
@@ -552,95 +965,34 @@ export class PXE {
|
|
|
552
965
|
* @param artifact - The build artifact for the contract class.
|
|
553
966
|
*/
|
|
554
967
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
555
|
-
const
|
|
556
|
-
|
|
968
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
969
|
+
// Publishing the artifact's public function signatures to the node is part of "registering a class", so that
|
|
970
|
+
// node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
|
|
971
|
+
const publicFunctionSignatures = artifact.functions
|
|
972
|
+
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
973
|
+
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
974
|
+
if (publicFunctionSignatures.length > 0) {
|
|
975
|
+
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
976
|
+
}
|
|
557
977
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
558
978
|
}
|
|
559
979
|
|
|
560
980
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
981
|
+
* Registers a deployed contract instance so its private state can be synced and its functions simulated. The
|
|
982
|
+
* artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
|
|
983
|
+
* or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
|
|
984
|
+
* the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
|
|
565
985
|
*
|
|
566
|
-
* @param
|
|
986
|
+
* @param instance - The address preimage of the contract instance to register. The address is derived from it.
|
|
987
|
+
* @returns The address of the registered instance.
|
|
567
988
|
*/
|
|
568
|
-
public
|
|
569
|
-
|
|
570
|
-
let { artifact } = contract;
|
|
571
|
-
|
|
572
|
-
if (artifact) {
|
|
573
|
-
// If the user provides an artifact, validate it against the expected class id and register it
|
|
574
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
575
|
-
const contractClassId = contractClass.id;
|
|
576
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
577
|
-
throw new Error(
|
|
578
|
-
`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`,
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
582
|
-
if (!computedAddress.equals(instance.address)) {
|
|
583
|
-
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
584
|
-
}
|
|
585
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
586
|
-
|
|
587
|
-
const publicFunctionSignatures = artifact.functions
|
|
588
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
589
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
590
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
591
|
-
} else {
|
|
592
|
-
// Otherwise, make sure there is an artifact already registered for that class id
|
|
593
|
-
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
594
|
-
if (!artifact) {
|
|
595
|
-
throw new Error(
|
|
596
|
-
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
await this.contractStore.addContractInstance(instance);
|
|
602
|
-
this.log.info(
|
|
603
|
-
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
609
|
-
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
610
|
-
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
611
|
-
* @param contractAddress - The address of the contract to update.
|
|
612
|
-
* @param artifact - The updated artifact for the contract.
|
|
613
|
-
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
614
|
-
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
615
|
-
*/
|
|
616
|
-
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
617
|
-
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
618
|
-
// class while we're simulating it.
|
|
989
|
+
public registerContract(instance: ContractInstancePreimage): Promise<AztecAddress> {
|
|
990
|
+
// Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
|
|
619
991
|
return this.#putInJobQueue(async () => {
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
625
|
-
await this.blockStateSynchronizer.sync();
|
|
626
|
-
|
|
627
|
-
const header = await this.anchorBlockStore.getBlockHeader();
|
|
628
|
-
|
|
629
|
-
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
630
|
-
if (!contractClass.id.equals(currentClassId)) {
|
|
631
|
-
throw new Error('Could not update contract to a class different from the current one.');
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
635
|
-
|
|
636
|
-
const publicFunctionSignatures = artifact.functions
|
|
637
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
638
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
639
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
640
|
-
|
|
641
|
-
currentInstance.currentContractClassId = contractClass.id;
|
|
642
|
-
await this.contractStore.addContractInstance(currentInstance);
|
|
643
|
-
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
992
|
+
const address = await computeContractAddressFromInstance(instance);
|
|
993
|
+
await this.contractStore.addContractInstance({ ...instance, address });
|
|
994
|
+
this.log.info(`Added contract at ${address}`, { address });
|
|
995
|
+
return address;
|
|
644
996
|
});
|
|
645
997
|
}
|
|
646
998
|
|
|
@@ -657,29 +1009,39 @@ export class PXE {
|
|
|
657
1009
|
* (where validators prove the public portion).
|
|
658
1010
|
*
|
|
659
1011
|
* @param txRequest - An authenticated tx request ready for proving
|
|
1012
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
660
1013
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
661
1014
|
* @throws If contract code not found, or public simulation reverts.
|
|
662
1015
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
663
1016
|
*/
|
|
664
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
1017
|
+
public proveTx(txRequest: TxExecutionRequest, { scopes, senderForTags }: ProveTxOpts): Promise<TxProvingResult> {
|
|
665
1018
|
let privateExecutionResult: PrivateExecutionResult;
|
|
666
1019
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
667
1020
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
668
1021
|
return this.#putInJobQueue(async jobId => {
|
|
669
1022
|
const totalTimer = new Timer();
|
|
1023
|
+
const recording = this.node.startRecording();
|
|
670
1024
|
try {
|
|
671
1025
|
const syncTimer = new Timer();
|
|
672
|
-
await this
|
|
1026
|
+
await this.#maybeSync();
|
|
1027
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
673
1028
|
const syncTime = syncTimer.ms();
|
|
674
1029
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
675
|
-
privateExecutionResult = await this.#executePrivate(
|
|
1030
|
+
privateExecutionResult = await this.#executePrivate({
|
|
1031
|
+
contractFunctionSimulator,
|
|
1032
|
+
txRequest,
|
|
1033
|
+
anchorBlockHeader,
|
|
1034
|
+
scopes,
|
|
1035
|
+
jobId,
|
|
1036
|
+
senderForTags,
|
|
1037
|
+
});
|
|
676
1038
|
|
|
677
1039
|
const {
|
|
678
1040
|
publicInputs,
|
|
679
1041
|
chonkProof,
|
|
680
1042
|
executionSteps,
|
|
681
1043
|
timings: { proving } = {},
|
|
682
|
-
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
1044
|
+
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
683
1045
|
simulate: false,
|
|
684
1046
|
skipFeeEnforcement: false,
|
|
685
1047
|
profileMode: 'none',
|
|
@@ -706,51 +1068,48 @@ export class PXE {
|
|
|
706
1068
|
|
|
707
1069
|
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
708
1070
|
timings,
|
|
709
|
-
nodeRPCCalls:
|
|
1071
|
+
nodeRPCCalls: recording.stop(),
|
|
710
1072
|
});
|
|
711
1073
|
|
|
712
|
-
//
|
|
713
|
-
//
|
|
714
|
-
//
|
|
715
|
-
//
|
|
716
|
-
//
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
} else {
|
|
727
|
-
this.log.debug(`No pre-tags used in the tx`);
|
|
728
|
-
}
|
|
1074
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
1075
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
1076
|
+
// onchain).
|
|
1077
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
1078
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
1079
|
+
// actually used to being reduced.
|
|
1080
|
+
await persistSenderTaggingIndexRangesForTx(
|
|
1081
|
+
this.senderTaggingStore,
|
|
1082
|
+
privateExecutionResult.entrypoint.taggingIndexRanges,
|
|
1083
|
+
publicInputs,
|
|
1084
|
+
() => txProvingResult.getTxHash(),
|
|
1085
|
+
jobId,
|
|
1086
|
+
this.log,
|
|
1087
|
+
);
|
|
729
1088
|
|
|
730
1089
|
return txProvingResult;
|
|
731
1090
|
} catch (err: any) {
|
|
732
1091
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
1092
|
+
} finally {
|
|
1093
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1094
|
+
recording.stop();
|
|
733
1095
|
}
|
|
734
1096
|
});
|
|
735
1097
|
}
|
|
736
1098
|
|
|
737
1099
|
/**
|
|
738
1100
|
* 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.
|
|
1101
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
743
1102
|
* @returns A trace of the program execution with gate counts.
|
|
744
1103
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
745
1104
|
*/
|
|
746
1105
|
public profileTx(
|
|
747
1106
|
txRequest: TxExecutionRequest,
|
|
748
|
-
profileMode
|
|
749
|
-
skipProofGeneration: boolean = true,
|
|
1107
|
+
{ profileMode, skipProofGeneration = true, scopes, senderForTags }: ProfileTxOpts,
|
|
750
1108
|
): Promise<TxProfileResult> {
|
|
751
1109
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
752
1110
|
return this.#putInJobQueue(async jobId => {
|
|
753
1111
|
const totalTimer = new Timer();
|
|
1112
|
+
const recording = this.node.startRecording();
|
|
754
1113
|
try {
|
|
755
1114
|
const txInfo = {
|
|
756
1115
|
origin: txRequest.origin,
|
|
@@ -765,21 +1124,25 @@ export class PXE {
|
|
|
765
1124
|
txInfo,
|
|
766
1125
|
);
|
|
767
1126
|
const syncTimer = new Timer();
|
|
768
|
-
await this
|
|
1127
|
+
await this.#maybeSync();
|
|
1128
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
769
1129
|
const syncTime = syncTimer.ms();
|
|
770
1130
|
|
|
771
1131
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
772
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1132
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
773
1133
|
contractFunctionSimulator,
|
|
774
1134
|
txRequest,
|
|
775
|
-
|
|
1135
|
+
anchorBlockHeader,
|
|
1136
|
+
scopes,
|
|
776
1137
|
jobId,
|
|
777
|
-
|
|
1138
|
+
senderForTags,
|
|
1139
|
+
});
|
|
778
1140
|
|
|
779
1141
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
780
1142
|
txRequest,
|
|
781
1143
|
this.proofCreator,
|
|
782
1144
|
privateExecutionResult,
|
|
1145
|
+
anchorBlockHeader,
|
|
783
1146
|
{
|
|
784
1147
|
simulate: skipProofGeneration,
|
|
785
1148
|
skipFeeEnforcement: false,
|
|
@@ -812,10 +1175,12 @@ export class PXE {
|
|
|
812
1175
|
total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
813
1176
|
};
|
|
814
1177
|
|
|
815
|
-
|
|
816
|
-
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: simulatorStats.nodeRPCCalls });
|
|
1178
|
+
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: recording.stop() });
|
|
817
1179
|
} catch (err: any) {
|
|
818
1180
|
throw this.#contextualizeError(err, inspect(txRequest), `profileMode=${profileMode}`);
|
|
1181
|
+
} finally {
|
|
1182
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1183
|
+
recording.stop();
|
|
819
1184
|
}
|
|
820
1185
|
});
|
|
821
1186
|
}
|
|
@@ -831,12 +1196,7 @@ export class PXE {
|
|
|
831
1196
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
832
1197
|
*
|
|
833
1198
|
*
|
|
834
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
835
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
836
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
837
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
838
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
839
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
1199
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
840
1200
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
841
1201
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
842
1202
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
@@ -845,16 +1205,21 @@ export class PXE {
|
|
|
845
1205
|
*/
|
|
846
1206
|
public simulateTx(
|
|
847
1207
|
txRequest: TxExecutionRequest,
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1208
|
+
{
|
|
1209
|
+
simulatePublic,
|
|
1210
|
+
skipTxValidation = false,
|
|
1211
|
+
skipFeeEnforcement = false,
|
|
1212
|
+
skipKernels = true,
|
|
1213
|
+
overrides,
|
|
1214
|
+
scopes,
|
|
1215
|
+
senderForTags,
|
|
1216
|
+
}: SimulateTxOpts,
|
|
853
1217
|
): Promise<TxSimulationResult> {
|
|
854
1218
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
855
1219
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
856
1220
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
857
1221
|
return this.#putInJobQueue(async jobId => {
|
|
1222
|
+
const recording = this.node.startRecording();
|
|
858
1223
|
try {
|
|
859
1224
|
const totalTimer = new Timer();
|
|
860
1225
|
const txInfo = {
|
|
@@ -870,24 +1235,26 @@ export class PXE {
|
|
|
870
1235
|
txInfo,
|
|
871
1236
|
);
|
|
872
1237
|
const syncTimer = new Timer();
|
|
873
|
-
await this
|
|
1238
|
+
await this.#maybeSync();
|
|
1239
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
874
1240
|
const syncTime = syncTimer.ms();
|
|
875
1241
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
881
|
-
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
882
|
-
const skipKernels = hasOverriddenContracts;
|
|
883
|
-
|
|
884
|
-
// Set overridden contracts on the sync service so it knows to skip syncing them
|
|
885
|
-
if (hasOverriddenContracts) {
|
|
886
|
-
this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
|
|
1242
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
1243
|
+
throw new Error(
|
|
1244
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
1245
|
+
);
|
|
887
1246
|
}
|
|
1247
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
888
1248
|
|
|
889
1249
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
890
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1250
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1251
|
+
contractFunctionSimulator,
|
|
1252
|
+
txRequest,
|
|
1253
|
+
anchorBlockHeader,
|
|
1254
|
+
scopes,
|
|
1255
|
+
jobId,
|
|
1256
|
+
senderForTags,
|
|
1257
|
+
});
|
|
891
1258
|
|
|
892
1259
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
893
1260
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
@@ -895,15 +1262,22 @@ export class PXE {
|
|
|
895
1262
|
if (skipKernels) {
|
|
896
1263
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
897
1264
|
privateExecutionResult,
|
|
898
|
-
(addr, sel) => this
|
|
1265
|
+
(addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
|
|
1266
|
+
this.node,
|
|
899
1267
|
));
|
|
900
1268
|
} else {
|
|
901
1269
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
902
|
-
({ publicInputs, executionSteps } = await this.#prove(
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1270
|
+
({ publicInputs, executionSteps } = await this.#prove(
|
|
1271
|
+
txRequest,
|
|
1272
|
+
this.proofCreator,
|
|
1273
|
+
privateExecutionResult,
|
|
1274
|
+
anchorBlockHeader,
|
|
1275
|
+
{
|
|
1276
|
+
simulate: true,
|
|
1277
|
+
skipFeeEnforcement,
|
|
1278
|
+
profileMode: 'none',
|
|
1279
|
+
},
|
|
1280
|
+
));
|
|
907
1281
|
}
|
|
908
1282
|
|
|
909
1283
|
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
@@ -912,8 +1286,11 @@ export class PXE {
|
|
|
912
1286
|
let publicOutput: PublicSimulationOutput | undefined;
|
|
913
1287
|
if (simulatePublic && publicInputs.forPublic) {
|
|
914
1288
|
const publicSimulationTimer = new Timer();
|
|
915
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
1289
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
916
1290
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
1291
|
+
if (publicOutput?.debugLogs?.length) {
|
|
1292
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
|
|
1293
|
+
}
|
|
917
1294
|
}
|
|
918
1295
|
|
|
919
1296
|
let validationTime: number | undefined;
|
|
@@ -922,7 +1299,8 @@ export class PXE {
|
|
|
922
1299
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
923
1300
|
validationTime = validationTimer.ms();
|
|
924
1301
|
if (validationResult.result === 'invalid') {
|
|
925
|
-
|
|
1302
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
1303
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
926
1304
|
}
|
|
927
1305
|
}
|
|
928
1306
|
|
|
@@ -962,10 +1340,9 @@ export class PXE {
|
|
|
962
1340
|
: {}),
|
|
963
1341
|
});
|
|
964
1342
|
|
|
965
|
-
const simulatorStats = contractFunctionSimulator.getStats();
|
|
966
1343
|
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
967
1344
|
timings,
|
|
968
|
-
nodeRPCCalls:
|
|
1345
|
+
nodeRPCCalls: recording.stop(),
|
|
969
1346
|
});
|
|
970
1347
|
} catch (err: any) {
|
|
971
1348
|
throw this.#contextualizeError(
|
|
@@ -973,34 +1350,32 @@ export class PXE {
|
|
|
973
1350
|
inspect(txRequest),
|
|
974
1351
|
`simulatePublic=${simulatePublic}`,
|
|
975
1352
|
`skipTxValidation=${skipTxValidation}`,
|
|
976
|
-
`scopes=${scopes
|
|
1353
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
977
1354
|
);
|
|
1355
|
+
} finally {
|
|
1356
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1357
|
+
recording.stop();
|
|
978
1358
|
}
|
|
979
1359
|
});
|
|
980
1360
|
}
|
|
981
1361
|
|
|
982
1362
|
/**
|
|
983
|
-
*
|
|
984
|
-
*
|
|
1363
|
+
* Executes a contract utility function.
|
|
985
1364
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
986
|
-
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
987
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
988
|
-
* default to all.
|
|
989
|
-
* @returns The result of the utility function call, structured based on the function ABI.
|
|
990
1365
|
*/
|
|
991
|
-
public
|
|
1366
|
+
public executeUtility(
|
|
992
1367
|
call: FunctionCall,
|
|
993
|
-
authwits
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1368
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1369
|
+
): Promise<UtilityExecutionResult> {
|
|
1370
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
997
1371
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
998
|
-
// delete the same read value, or reading values that another
|
|
1372
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
999
1373
|
return this.#putInJobQueue(async jobId => {
|
|
1374
|
+
const recording = this.node.startRecording();
|
|
1000
1375
|
try {
|
|
1001
1376
|
const totalTimer = new Timer();
|
|
1002
1377
|
const syncTimer = new Timer();
|
|
1003
|
-
await this
|
|
1378
|
+
await this.#maybeSync();
|
|
1004
1379
|
const syncTime = syncTimer.ms();
|
|
1005
1380
|
const functionTimer = new Timer();
|
|
1006
1381
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -1009,12 +1384,14 @@ export class PXE {
|
|
|
1009
1384
|
await this.contractSyncService.ensureContractSynced(
|
|
1010
1385
|
call.to,
|
|
1011
1386
|
call.selector,
|
|
1012
|
-
|
|
1387
|
+
(privateSyncCall, execScopes) =>
|
|
1388
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1013
1389
|
anchorBlockHeader,
|
|
1014
1390
|
jobId,
|
|
1391
|
+
scopes,
|
|
1015
1392
|
);
|
|
1016
1393
|
|
|
1017
|
-
const executionResult = await this.#
|
|
1394
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(
|
|
1018
1395
|
contractFunctionSimulator,
|
|
1019
1396
|
call,
|
|
1020
1397
|
authwits ?? [],
|
|
@@ -1034,16 +1411,23 @@ export class PXE {
|
|
|
1034
1411
|
unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1035
1412
|
};
|
|
1036
1413
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1414
|
+
return {
|
|
1415
|
+
result: executionResult,
|
|
1416
|
+
offchainEffects,
|
|
1417
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1418
|
+
stats: { timings, nodeRPCCalls: recording.stop() },
|
|
1419
|
+
};
|
|
1039
1420
|
} catch (err: any) {
|
|
1040
1421
|
const { to, name, args } = call;
|
|
1041
1422
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1042
1423
|
throw this.#contextualizeError(
|
|
1043
1424
|
err,
|
|
1044
|
-
`
|
|
1045
|
-
`scopes=${scopes
|
|
1425
|
+
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1426
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1046
1427
|
);
|
|
1428
|
+
} finally {
|
|
1429
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1430
|
+
recording.stop();
|
|
1047
1431
|
}
|
|
1048
1432
|
});
|
|
1049
1433
|
}
|
|
@@ -1068,7 +1452,7 @@ export class PXE {
|
|
|
1068
1452
|
let anchorBlockNumber: BlockNumber;
|
|
1069
1453
|
|
|
1070
1454
|
await this.#putInJobQueue(async jobId => {
|
|
1071
|
-
await this
|
|
1455
|
+
await this.#maybeSync();
|
|
1072
1456
|
|
|
1073
1457
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1074
1458
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
@@ -1078,10 +1462,11 @@ export class PXE {
|
|
|
1078
1462
|
await this.contractSyncService.ensureContractSynced(
|
|
1079
1463
|
filter.contractAddress,
|
|
1080
1464
|
null,
|
|
1081
|
-
async privateSyncCall =>
|
|
1082
|
-
await this.#
|
|
1465
|
+
async (privateSyncCall, execScopes) =>
|
|
1466
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1083
1467
|
anchorBlockHeader,
|
|
1084
1468
|
jobId,
|
|
1469
|
+
filter.scopes,
|
|
1085
1470
|
);
|
|
1086
1471
|
});
|
|
1087
1472
|
|
|
@@ -1096,9 +1481,11 @@ export class PXE {
|
|
|
1096
1481
|
}
|
|
1097
1482
|
|
|
1098
1483
|
/**
|
|
1099
|
-
* Stops the PXE's job queue.
|
|
1484
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1100
1485
|
*/
|
|
1101
|
-
public stop(): Promise<void> {
|
|
1102
|
-
|
|
1486
|
+
public async stop(): Promise<void> {
|
|
1487
|
+
await this.jobQueue.end();
|
|
1488
|
+
await this.blockStateSynchronizer.stop();
|
|
1489
|
+
await this.db.close();
|
|
1103
1490
|
}
|
|
1104
1491
|
}
|