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