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