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