@aztec/pxe 0.0.1-commit.c2eed6949 → 0.0.1-commit.c52d6e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +11 -118
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +20 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +25 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +22 -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 +8 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -14
- 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 +27 -28
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +86 -59
- 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 +5 -9
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
- package/dest/contract_function_simulator/index.d.ts +26 -6
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -4
- 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 +5 -5
- 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 +7 -9
- 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 -61
- 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 +5 -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 -10
- 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 -103
- 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 +3 -4
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +52 -42
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +197 -65
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +164 -77
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +607 -193
- 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 +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +7 -3
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +3 -4
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +203 -89
- 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 +167 -55
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +366 -216
- 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 +44 -13
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +84 -32
- 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 +7 -6
- 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 +24 -27
- 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 -7
- 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 +37 -36
- 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 +15 -8
- 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 +140 -75
- 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 +5 -9
- package/src/contract_function_simulator/index.ts +89 -5
- 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 +5 -7
- 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 -61
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -8
- 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 +3 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +247 -83
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +890 -305
- 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 +12 -2
- package/src/private_kernel/hints/test_utils.ts +3 -10
- package/src/private_kernel/private_kernel_execution_prover.ts +335 -121
- package/src/private_kernel/private_kernel_oracle.ts +58 -29
- package/src/pxe.ts +565 -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 +118 -46
- 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 +11 -5
- 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 +30 -38
- 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 +48 -43
- 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/noir-structs/message_tx_context.d.ts +0 -16
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -61
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -437
- 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 -45
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/contract_sync_service.js +0 -114
- 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/messages/message_context_service.d.ts +0 -17
- package/dest/messages/message_context_service.d.ts.map +0 -1
- package/dest/messages/message_context_service.js +0 -36
- 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 -12
- 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 -39
- package/src/access_scopes.ts +0 -9
- package/src/contract_function_simulator/benchmarked_node.ts +0 -103
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -135
- package/src/contract_function_simulator/oracle/oracle.ts +0 -675
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -83
- package/src/contract_sync/contract_sync_service.ts +0 -181
- package/src/contract_sync/helpers.ts +0 -98
- package/src/messages/message_context_service.ts +0 -45
- 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 -51
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,23 +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';
|
|
71
|
-
import {
|
|
75
|
+
import { TxResolverService } from './messages/tx_resolver_service.js';
|
|
76
|
+
import { type CachingAztecNode, withCache } from './node/caching_aztec_node.js';
|
|
72
77
|
import {
|
|
73
78
|
PrivateKernelExecutionProver,
|
|
74
79
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -78,17 +83,31 @@ import { AddressStore } from './storage/address_store/address_store.js';
|
|
|
78
83
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
79
84
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
80
85
|
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
86
|
+
import { FactStore } from './storage/fact_store/index.js';
|
|
81
87
|
import { NoteStore } from './storage/note_store/note_store.js';
|
|
88
|
+
import { openPxeStores } from './storage/open_pxe_stores.js';
|
|
82
89
|
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
83
90
|
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
84
|
-
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
85
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';
|
|
86
97
|
|
|
87
98
|
export type PackedPrivateEvent = InTx & {
|
|
88
99
|
packedEvent: Fr[];
|
|
89
100
|
eventSelector: EventSelector;
|
|
90
101
|
};
|
|
91
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
|
+
|
|
92
111
|
/** Options for PXE.profileTx. */
|
|
93
112
|
export type ProfileTxOpts = {
|
|
94
113
|
/** The profiling mode to use. */
|
|
@@ -96,7 +115,9 @@ export type ProfileTxOpts = {
|
|
|
96
115
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
97
116
|
skipProofGeneration?: boolean;
|
|
98
117
|
/** Addresses whose private state and keys are accessible during private execution. */
|
|
99
|
-
scopes:
|
|
118
|
+
scopes: AztecAddress[];
|
|
119
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
120
|
+
senderForTags?: AztecAddress;
|
|
100
121
|
};
|
|
101
122
|
|
|
102
123
|
/** Options for PXE.simulateTx. */
|
|
@@ -109,10 +130,16 @@ export type SimulateTxOpts = {
|
|
|
109
130
|
skipFeeEnforcement?: boolean;
|
|
110
131
|
/** If true, kernel logic is emulated in TS for simulation */
|
|
111
132
|
skipKernels?: boolean;
|
|
112
|
-
/**
|
|
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
|
+
*/
|
|
113
138
|
overrides?: SimulationOverrides;
|
|
114
139
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
115
|
-
scopes:
|
|
140
|
+
scopes: AztecAddress[];
|
|
141
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
142
|
+
senderForTags?: AztecAddress;
|
|
116
143
|
};
|
|
117
144
|
|
|
118
145
|
/** Options for PXE.executeUtility. */
|
|
@@ -120,13 +147,33 @@ export type ExecuteUtilityOpts = {
|
|
|
120
147
|
/** The authentication witnesses required for the function call. */
|
|
121
148
|
authwits?: AuthWitness[];
|
|
122
149
|
/** The accounts whose notes we can access in this call */
|
|
123
|
-
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 }>>;
|
|
124
166
|
};
|
|
125
167
|
|
|
126
168
|
/** Args for PXE.create. */
|
|
127
169
|
export type PXECreateArgs = {
|
|
128
170
|
/** The Aztec node to connect to. */
|
|
129
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;
|
|
130
177
|
/** The key-value store for persisting PXE state. */
|
|
131
178
|
store: AztecAsyncKVStore;
|
|
132
179
|
/** The prover for generating private kernel proofs. */
|
|
@@ -135,41 +182,84 @@ export type PXECreateArgs = {
|
|
|
135
182
|
simulator: CircuitSimulator;
|
|
136
183
|
/** Provider for protocol contract artifacts and instances. */
|
|
137
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;
|
|
138
191
|
/** PXE configuration options. */
|
|
139
192
|
config: PXEConfig;
|
|
140
193
|
/** Optional logger instance or string suffix for the logger name. */
|
|
141
194
|
loggerOrSuffix?: string | Logger;
|
|
195
|
+
/** Optional hooks to observe and influence contract execution. */
|
|
196
|
+
hooks?: ExecutionHooks;
|
|
142
197
|
};
|
|
143
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
|
+
|
|
144
227
|
/**
|
|
145
228
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
146
229
|
* manage private state of users.
|
|
147
230
|
*/
|
|
148
231
|
export class PXE {
|
|
149
232
|
private constructor(
|
|
150
|
-
private node:
|
|
233
|
+
private node: CachingAztecNode,
|
|
234
|
+
private nodeDebug: AztecNodeDebug | undefined,
|
|
151
235
|
private db: AztecAsyncKVStore,
|
|
152
236
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
153
237
|
private keyStore: KeyStore,
|
|
154
238
|
private contractStore: ContractStore,
|
|
155
239
|
private noteStore: NoteStore,
|
|
156
240
|
private capsuleStore: CapsuleStore,
|
|
241
|
+
private factStore: FactStore,
|
|
157
242
|
private anchorBlockStore: AnchorBlockStore,
|
|
158
243
|
private senderTaggingStore: SenderTaggingStore,
|
|
159
|
-
private
|
|
244
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
160
245
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
161
246
|
private addressStore: AddressStore,
|
|
162
247
|
private privateEventStore: PrivateEventStore,
|
|
163
248
|
private contractSyncService: ContractSyncService,
|
|
164
|
-
private
|
|
249
|
+
private contractClassService: ContractClassService,
|
|
250
|
+
private txResolver: TxResolverService,
|
|
251
|
+
private l2TipsStore: L2TipsProvider,
|
|
165
252
|
private simulator: CircuitSimulator,
|
|
166
253
|
private proverEnabled: boolean,
|
|
254
|
+
private autoSync: boolean,
|
|
167
255
|
private proofCreator: PrivateKernelProver,
|
|
168
256
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
257
|
+
private preloadedContractsProvider: PreloadedContractsProvider,
|
|
169
258
|
private log: Logger,
|
|
170
259
|
private jobQueue: SerialQueue,
|
|
171
260
|
private jobCoordinator: JobCoordinator,
|
|
172
261
|
public debug: PXEDebugUtils,
|
|
262
|
+
private hooks: ExecutionHooks | undefined,
|
|
173
263
|
) {}
|
|
174
264
|
|
|
175
265
|
/**
|
|
@@ -181,12 +271,15 @@ export class PXE {
|
|
|
181
271
|
*/
|
|
182
272
|
public static async create({
|
|
183
273
|
node,
|
|
274
|
+
nodeDebug,
|
|
184
275
|
store,
|
|
185
276
|
proofCreator,
|
|
186
277
|
simulator,
|
|
187
278
|
protocolContractsProvider,
|
|
279
|
+
preloadedContractsProvider,
|
|
188
280
|
config,
|
|
189
281
|
loggerOrSuffix,
|
|
282
|
+
hooks,
|
|
190
283
|
}: PXECreateArgs) {
|
|
191
284
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
192
285
|
const bindings: LoggerBindings | undefined =
|
|
@@ -199,33 +292,51 @@ export class PXE {
|
|
|
199
292
|
|
|
200
293
|
const info = await node.getNodeInfo();
|
|
201
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
|
+
|
|
202
303
|
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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);
|
|
214
323
|
const contractSyncService = new ContractSyncService(
|
|
215
|
-
|
|
324
|
+
readCachedNode,
|
|
216
325
|
contractStore,
|
|
326
|
+
contractClassService,
|
|
217
327
|
noteStore,
|
|
218
328
|
createLogger('pxe:contract_sync', bindings),
|
|
219
329
|
);
|
|
220
|
-
const
|
|
330
|
+
const txResolver = new TxResolverService(readCachedNode);
|
|
221
331
|
|
|
222
332
|
const synchronizer = new BlockSynchronizer(
|
|
223
|
-
|
|
333
|
+
readCachedNode,
|
|
224
334
|
store,
|
|
225
335
|
anchorBlockStore,
|
|
226
336
|
noteStore,
|
|
227
337
|
privateEventStore,
|
|
228
|
-
|
|
338
|
+
factStore,
|
|
339
|
+
l2TipsStore,
|
|
229
340
|
contractSyncService,
|
|
230
341
|
config,
|
|
231
342
|
bindings,
|
|
@@ -238,6 +349,7 @@ export class PXE {
|
|
|
238
349
|
recipientTaggingStore,
|
|
239
350
|
privateEventStore,
|
|
240
351
|
noteStore,
|
|
352
|
+
factStore,
|
|
241
353
|
contractSyncService,
|
|
242
354
|
]);
|
|
243
355
|
|
|
@@ -246,29 +358,36 @@ export class PXE {
|
|
|
246
358
|
const jobQueue = new SerialQueue();
|
|
247
359
|
|
|
248
360
|
const pxe = new PXE(
|
|
249
|
-
|
|
361
|
+
readCachedNode,
|
|
362
|
+
nodeDebug,
|
|
250
363
|
store,
|
|
251
364
|
synchronizer,
|
|
252
365
|
keyStore,
|
|
253
366
|
contractStore,
|
|
254
367
|
noteStore,
|
|
255
368
|
capsuleStore,
|
|
369
|
+
factStore,
|
|
256
370
|
anchorBlockStore,
|
|
257
371
|
senderTaggingStore,
|
|
258
|
-
|
|
372
|
+
taggingSecretSourcesStore,
|
|
259
373
|
recipientTaggingStore,
|
|
260
374
|
addressStore,
|
|
261
375
|
privateEventStore,
|
|
262
376
|
contractSyncService,
|
|
263
|
-
|
|
377
|
+
contractClassService,
|
|
378
|
+
txResolver,
|
|
379
|
+
l2TipsStore,
|
|
264
380
|
simulator,
|
|
265
381
|
proverEnabled,
|
|
382
|
+
config.autoSync,
|
|
266
383
|
proofCreator,
|
|
267
384
|
protocolContractsProvider,
|
|
385
|
+
preloadedContractsProvider,
|
|
268
386
|
log,
|
|
269
387
|
jobQueue,
|
|
270
388
|
jobCoordinator,
|
|
271
389
|
debugUtils,
|
|
390
|
+
hooks,
|
|
272
391
|
);
|
|
273
392
|
|
|
274
393
|
debugUtils.setPXEHelpers(
|
|
@@ -279,7 +398,7 @@ export class PXE {
|
|
|
279
398
|
|
|
280
399
|
pxe.jobQueue.start();
|
|
281
400
|
|
|
282
|
-
await pxe.#registerProtocolContracts();
|
|
401
|
+
await Promise.all([pxe.#registerProtocolContracts(), pxe.#registerPreloadedContracts()]);
|
|
283
402
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
284
403
|
return pxe;
|
|
285
404
|
}
|
|
@@ -287,25 +406,52 @@ export class PXE {
|
|
|
287
406
|
// Internal methods
|
|
288
407
|
|
|
289
408
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
290
|
-
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
291
|
-
|
|
292
409
|
return new ContractFunctionSimulator({
|
|
293
|
-
contractStore:
|
|
410
|
+
contractStore: this.contractStore,
|
|
411
|
+
contractClassService: this.contractClassService,
|
|
412
|
+
overrides: overrides?.contracts,
|
|
294
413
|
noteStore: this.noteStore,
|
|
295
414
|
keyStore: this.keyStore,
|
|
296
415
|
addressStore: this.addressStore,
|
|
297
|
-
aztecNode:
|
|
416
|
+
aztecNode: this.node,
|
|
417
|
+
l2TipsStore: this.l2TipsStore,
|
|
298
418
|
senderTaggingStore: this.senderTaggingStore,
|
|
299
419
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
300
|
-
|
|
420
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
301
421
|
capsuleStore: this.capsuleStore,
|
|
422
|
+
factStore: this.factStore,
|
|
302
423
|
privateEventStore: this.privateEventStore,
|
|
303
424
|
simulator: this.simulator,
|
|
304
425
|
contractSyncService: this.contractSyncService,
|
|
305
|
-
|
|
426
|
+
txResolver: this.txResolver,
|
|
427
|
+
hooks: this.hooks,
|
|
306
428
|
});
|
|
307
429
|
}
|
|
308
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
|
+
|
|
309
455
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
310
456
|
let contextStr = '';
|
|
311
457
|
if (context.length > 0) {
|
|
@@ -353,29 +499,55 @@ export class PXE {
|
|
|
353
499
|
}
|
|
354
500
|
|
|
355
501
|
async #registerProtocolContracts() {
|
|
356
|
-
const registered
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
+
);
|
|
363
513
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
364
514
|
}
|
|
365
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
|
+
|
|
366
531
|
// Executes the entrypoint private function, as well as all nested private
|
|
367
532
|
// functions that might arise.
|
|
368
|
-
async #executePrivate(
|
|
369
|
-
contractFunctionSimulator
|
|
370
|
-
txRequest
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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> {
|
|
374
548
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
375
549
|
|
|
376
550
|
try {
|
|
377
|
-
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
378
|
-
|
|
379
551
|
await this.contractSyncService.ensureContractSynced(
|
|
380
552
|
contractAddress,
|
|
381
553
|
functionSelector,
|
|
@@ -387,17 +559,16 @@ export class PXE {
|
|
|
387
559
|
);
|
|
388
560
|
|
|
389
561
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
390
|
-
contractAddress,
|
|
391
|
-
selector: functionSelector,
|
|
392
562
|
anchorBlockHeader,
|
|
393
563
|
scopes,
|
|
394
564
|
jobId,
|
|
565
|
+
senderForTags,
|
|
395
566
|
});
|
|
396
567
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
397
568
|
return result;
|
|
398
569
|
} catch (err) {
|
|
399
570
|
if (err instanceof SimulationError) {
|
|
400
|
-
await enrichSimulationError(err, this.contractStore, this.log);
|
|
571
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
401
572
|
}
|
|
402
573
|
throw err;
|
|
403
574
|
}
|
|
@@ -417,7 +588,7 @@ export class PXE {
|
|
|
417
588
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
418
589
|
call: FunctionCall,
|
|
419
590
|
authWitnesses: AuthWitness[] | undefined,
|
|
420
|
-
scopes:
|
|
591
|
+
scopes: AztecAddress[],
|
|
421
592
|
jobId: string,
|
|
422
593
|
) {
|
|
423
594
|
try {
|
|
@@ -432,7 +603,8 @@ export class PXE {
|
|
|
432
603
|
return { result, offchainEffects };
|
|
433
604
|
} catch (err) {
|
|
434
605
|
if (err instanceof SimulationError) {
|
|
435
|
-
|
|
606
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
607
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
436
608
|
}
|
|
437
609
|
throw err;
|
|
438
610
|
}
|
|
@@ -444,11 +616,11 @@ export class PXE {
|
|
|
444
616
|
* It can also be used for estimating gas in the future.
|
|
445
617
|
* @param tx - The transaction to be simulated.
|
|
446
618
|
*/
|
|
447
|
-
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean) {
|
|
619
|
+
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean, overrides?: SimulationOverrides) {
|
|
448
620
|
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
449
621
|
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
450
622
|
try {
|
|
451
|
-
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
|
|
623
|
+
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement, overrides);
|
|
452
624
|
if (result.revertReason) {
|
|
453
625
|
throw result.revertReason;
|
|
454
626
|
}
|
|
@@ -456,7 +628,14 @@ export class PXE {
|
|
|
456
628
|
} catch (err) {
|
|
457
629
|
if (err instanceof SimulationError) {
|
|
458
630
|
try {
|
|
459
|
-
|
|
631
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
632
|
+
await enrichPublicSimulationError(
|
|
633
|
+
err,
|
|
634
|
+
this.contractStore,
|
|
635
|
+
this.contractClassService,
|
|
636
|
+
anchorBlockHeader,
|
|
637
|
+
this.log,
|
|
638
|
+
);
|
|
460
639
|
} catch (enrichErr) {
|
|
461
640
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
462
641
|
}
|
|
@@ -480,11 +659,16 @@ export class PXE {
|
|
|
480
659
|
txExecutionRequest: TxExecutionRequest,
|
|
481
660
|
proofCreator: PrivateKernelProver,
|
|
482
661
|
privateExecutionResult: PrivateExecutionResult,
|
|
662
|
+
anchorBlockHeader: BlockHeader,
|
|
483
663
|
config: PrivateKernelExecutionProverConfig,
|
|
484
664
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
665
|
+
const kernelOracle = new PrivateKernelOracle(
|
|
666
|
+
this.contractStore,
|
|
667
|
+
this.contractClassService,
|
|
668
|
+
this.keyStore,
|
|
669
|
+
this.node,
|
|
670
|
+
anchorBlockHeader,
|
|
671
|
+
);
|
|
488
672
|
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
489
673
|
kernelOracle,
|
|
490
674
|
proofCreator,
|
|
@@ -495,22 +679,44 @@ export class PXE {
|
|
|
495
679
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
496
680
|
}
|
|
497
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
|
+
|
|
498
693
|
// Public API
|
|
499
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
|
+
|
|
500
704
|
/**
|
|
501
705
|
* Returns the block header up to which the PXE has synced.
|
|
502
706
|
* @returns The synced block header
|
|
503
707
|
*/
|
|
504
708
|
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
505
|
-
return this
|
|
709
|
+
return this.#putInJobQueue(() => {
|
|
710
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
711
|
+
});
|
|
506
712
|
}
|
|
507
713
|
|
|
508
714
|
/**
|
|
509
|
-
* Returns the contract instance
|
|
715
|
+
* Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
|
|
510
716
|
* @param address - The contract address.
|
|
511
|
-
* @returns The contract instance if found, undefined otherwise.
|
|
717
|
+
* @returns The contract instance address preimage if found, undefined otherwise.
|
|
512
718
|
*/
|
|
513
|
-
public getContractInstance(address: AztecAddress): Promise<
|
|
719
|
+
public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
|
|
514
720
|
return this.contractStore.getContractInstance(address);
|
|
515
721
|
}
|
|
516
722
|
|
|
@@ -524,19 +730,23 @@ export class PXE {
|
|
|
524
730
|
}
|
|
525
731
|
|
|
526
732
|
/**
|
|
527
|
-
* Registers a user account in PXE
|
|
528
|
-
*
|
|
529
|
-
* the
|
|
530
|
-
*
|
|
733
|
+
* Registers a user account in PXE.
|
|
734
|
+
*
|
|
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.
|
|
531
737
|
*
|
|
532
|
-
*
|
|
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.
|
|
533
743
|
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
534
744
|
* @returns The complete address of the account.
|
|
535
745
|
*/
|
|
536
|
-
public async registerAccount(
|
|
746
|
+
public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
537
747
|
const accounts = await this.keyStore.getAccounts();
|
|
538
|
-
const accountCompleteAddress = await this.keyStore.addAccount(
|
|
539
|
-
if (accounts.
|
|
748
|
+
const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
|
|
749
|
+
if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
|
|
540
750
|
this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
|
|
541
751
|
return accountCompleteAddress;
|
|
542
752
|
} else {
|
|
@@ -549,56 +759,189 @@ export class PXE {
|
|
|
549
759
|
}
|
|
550
760
|
|
|
551
761
|
/**
|
|
552
|
-
*
|
|
762
|
+
* Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
|
|
763
|
+
* outgoing-viewing, tagging).
|
|
764
|
+
*
|
|
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.
|
|
553
768
|
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
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.
|
|
556
772
|
*
|
|
557
|
-
* @
|
|
558
|
-
* @returns The address of the sender.
|
|
559
|
-
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
773
|
+
* @throws If the account is not registered.
|
|
560
774
|
*/
|
|
561
|
-
public
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
565
|
-
return sender;
|
|
566
|
-
}
|
|
775
|
+
public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
|
|
776
|
+
return this.keyStore.getAccountSecretKeys(account);
|
|
777
|
+
}
|
|
567
778
|
|
|
568
|
-
|
|
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
|
+
}
|
|
569
809
|
|
|
570
810
|
if (wasAdded) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
// all contracts must re-sync to discover them.
|
|
574
|
-
this.contractSyncService.wipe();
|
|
575
|
-
} else {
|
|
576
|
-
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()));
|
|
577
813
|
}
|
|
814
|
+
}
|
|
578
815
|
|
|
579
|
-
|
|
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
|
+
}
|
|
580
848
|
}
|
|
581
849
|
|
|
582
850
|
/**
|
|
583
|
-
* Retrieves
|
|
584
|
-
*
|
|
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}.
|
|
585
853
|
*/
|
|
586
|
-
public
|
|
587
|
-
|
|
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;
|
|
588
893
|
}
|
|
589
894
|
|
|
590
895
|
/**
|
|
591
|
-
*
|
|
592
|
-
*
|
|
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.
|
|
593
904
|
*/
|
|
594
|
-
|
|
595
|
-
|
|
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
|
+
}
|
|
596
912
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
+
);
|
|
601
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;
|
|
602
945
|
}
|
|
603
946
|
|
|
604
947
|
/**
|
|
@@ -622,94 +965,33 @@ export class PXE {
|
|
|
622
965
|
*/
|
|
623
966
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
624
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
|
+
}
|
|
625
976
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
626
977
|
}
|
|
627
978
|
|
|
628
979
|
/**
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
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.
|
|
633
984
|
*
|
|
634
|
-
* @param
|
|
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.
|
|
635
987
|
*/
|
|
636
|
-
public
|
|
637
|
-
|
|
638
|
-
let { artifact } = contract;
|
|
639
|
-
|
|
640
|
-
if (artifact) {
|
|
641
|
-
// If the user provides an artifact, validate it against the expected class id and register it
|
|
642
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
643
|
-
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
644
|
-
throw new Error(
|
|
645
|
-
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
649
|
-
if (!computedAddress.equals(instance.address)) {
|
|
650
|
-
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
654
|
-
|
|
655
|
-
const publicFunctionSignatures = artifact.functions
|
|
656
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
657
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
658
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
659
|
-
} else {
|
|
660
|
-
// Otherwise, make sure there is an artifact already registered for that class id
|
|
661
|
-
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
662
|
-
if (!artifact) {
|
|
663
|
-
throw new Error(
|
|
664
|
-
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
await this.contractStore.addContractInstance(instance);
|
|
670
|
-
this.log.info(
|
|
671
|
-
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
677
|
-
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
678
|
-
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
679
|
-
* @param contractAddress - The address of the contract to update.
|
|
680
|
-
* @param artifact - The updated artifact for the contract.
|
|
681
|
-
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
682
|
-
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
683
|
-
*/
|
|
684
|
-
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
685
|
-
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
686
|
-
// 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.
|
|
687
990
|
return this.#putInJobQueue(async () => {
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
693
|
-
await this.blockStateSynchronizer.sync();
|
|
694
|
-
|
|
695
|
-
const header = await this.anchorBlockStore.getBlockHeader();
|
|
696
|
-
|
|
697
|
-
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
698
|
-
if (!contractClass.id.equals(currentClassId)) {
|
|
699
|
-
throw new Error('Could not update contract to a class different from the current one.');
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
const publicFunctionSignatures = artifact.functions
|
|
703
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
704
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
705
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
706
|
-
|
|
707
|
-
currentInstance.currentContractClassId = contractClass.id;
|
|
708
|
-
await Promise.all([
|
|
709
|
-
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
710
|
-
this.contractStore.addContractInstance(currentInstance),
|
|
711
|
-
]);
|
|
712
|
-
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;
|
|
713
995
|
});
|
|
714
996
|
}
|
|
715
997
|
|
|
@@ -731,25 +1013,34 @@ export class PXE {
|
|
|
731
1013
|
* @throws If contract code not found, or public simulation reverts.
|
|
732
1014
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
733
1015
|
*/
|
|
734
|
-
public proveTx(txRequest: TxExecutionRequest, scopes:
|
|
1016
|
+
public proveTx(txRequest: TxExecutionRequest, { scopes, senderForTags }: ProveTxOpts): Promise<TxProvingResult> {
|
|
735
1017
|
let privateExecutionResult: PrivateExecutionResult;
|
|
736
1018
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
737
1019
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
738
1020
|
return this.#putInJobQueue(async jobId => {
|
|
739
1021
|
const totalTimer = new Timer();
|
|
1022
|
+
const recording = this.node.startRecording();
|
|
740
1023
|
try {
|
|
741
1024
|
const syncTimer = new Timer();
|
|
742
|
-
await this
|
|
1025
|
+
await this.#maybeSync();
|
|
1026
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
743
1027
|
const syncTime = syncTimer.ms();
|
|
744
1028
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
745
|
-
privateExecutionResult = await this.#executePrivate(
|
|
1029
|
+
privateExecutionResult = await this.#executePrivate({
|
|
1030
|
+
contractFunctionSimulator,
|
|
1031
|
+
txRequest,
|
|
1032
|
+
anchorBlockHeader,
|
|
1033
|
+
scopes,
|
|
1034
|
+
jobId,
|
|
1035
|
+
senderForTags,
|
|
1036
|
+
});
|
|
746
1037
|
|
|
747
1038
|
const {
|
|
748
1039
|
publicInputs,
|
|
749
1040
|
chonkProof,
|
|
750
1041
|
executionSteps,
|
|
751
1042
|
timings: { proving } = {},
|
|
752
|
-
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
1043
|
+
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
753
1044
|
simulate: false,
|
|
754
1045
|
skipFeeEnforcement: false,
|
|
755
1046
|
profileMode: 'none',
|
|
@@ -776,30 +1067,30 @@ export class PXE {
|
|
|
776
1067
|
|
|
777
1068
|
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
778
1069
|
timings,
|
|
779
|
-
nodeRPCCalls:
|
|
1070
|
+
nodeRPCCalls: recording.stop(),
|
|
780
1071
|
});
|
|
781
1072
|
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
} else {
|
|
797
|
-
this.log.debug(`No tagging index ranges used in the tx`);
|
|
798
|
-
}
|
|
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
|
+
);
|
|
799
1087
|
|
|
800
1088
|
return txProvingResult;
|
|
801
1089
|
} catch (err: any) {
|
|
802
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();
|
|
803
1094
|
}
|
|
804
1095
|
});
|
|
805
1096
|
}
|
|
@@ -812,11 +1103,12 @@ export class PXE {
|
|
|
812
1103
|
*/
|
|
813
1104
|
public profileTx(
|
|
814
1105
|
txRequest: TxExecutionRequest,
|
|
815
|
-
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
1106
|
+
{ profileMode, skipProofGeneration = true, scopes, senderForTags }: ProfileTxOpts,
|
|
816
1107
|
): Promise<TxProfileResult> {
|
|
817
1108
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
818
1109
|
return this.#putInJobQueue(async jobId => {
|
|
819
1110
|
const totalTimer = new Timer();
|
|
1111
|
+
const recording = this.node.startRecording();
|
|
820
1112
|
try {
|
|
821
1113
|
const txInfo = {
|
|
822
1114
|
origin: txRequest.origin,
|
|
@@ -831,16 +1123,25 @@ export class PXE {
|
|
|
831
1123
|
txInfo,
|
|
832
1124
|
);
|
|
833
1125
|
const syncTimer = new Timer();
|
|
834
|
-
await this
|
|
1126
|
+
await this.#maybeSync();
|
|
1127
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
835
1128
|
const syncTime = syncTimer.ms();
|
|
836
1129
|
|
|
837
1130
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
838
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1131
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1132
|
+
contractFunctionSimulator,
|
|
1133
|
+
txRequest,
|
|
1134
|
+
anchorBlockHeader,
|
|
1135
|
+
scopes,
|
|
1136
|
+
jobId,
|
|
1137
|
+
senderForTags,
|
|
1138
|
+
});
|
|
839
1139
|
|
|
840
1140
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
841
1141
|
txRequest,
|
|
842
1142
|
this.proofCreator,
|
|
843
1143
|
privateExecutionResult,
|
|
1144
|
+
anchorBlockHeader,
|
|
844
1145
|
{
|
|
845
1146
|
simulate: skipProofGeneration,
|
|
846
1147
|
skipFeeEnforcement: false,
|
|
@@ -873,10 +1174,12 @@ export class PXE {
|
|
|
873
1174
|
total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
874
1175
|
};
|
|
875
1176
|
|
|
876
|
-
|
|
877
|
-
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: simulatorStats.nodeRPCCalls });
|
|
1177
|
+
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: recording.stop() });
|
|
878
1178
|
} catch (err: any) {
|
|
879
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();
|
|
880
1183
|
}
|
|
881
1184
|
});
|
|
882
1185
|
}
|
|
@@ -908,12 +1211,14 @@ export class PXE {
|
|
|
908
1211
|
skipKernels = true,
|
|
909
1212
|
overrides,
|
|
910
1213
|
scopes,
|
|
1214
|
+
senderForTags,
|
|
911
1215
|
}: SimulateTxOpts,
|
|
912
1216
|
): Promise<TxSimulationResult> {
|
|
913
1217
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
914
1218
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
915
1219
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
916
1220
|
return this.#putInJobQueue(async jobId => {
|
|
1221
|
+
const recording = this.node.startRecording();
|
|
917
1222
|
try {
|
|
918
1223
|
const totalTimer = new Timer();
|
|
919
1224
|
const txInfo = {
|
|
@@ -929,27 +1234,26 @@ export class PXE {
|
|
|
929
1234
|
txInfo,
|
|
930
1235
|
);
|
|
931
1236
|
const syncTimer = new Timer();
|
|
932
|
-
await this
|
|
1237
|
+
await this.#maybeSync();
|
|
1238
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
933
1239
|
const syncTime = syncTimer.ms();
|
|
934
1240
|
|
|
935
|
-
|
|
936
|
-
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
937
|
-
|
|
938
|
-
if (hasOverriddenContracts && !skipKernels) {
|
|
1241
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
939
1242
|
throw new Error(
|
|
940
1243
|
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
941
1244
|
);
|
|
942
1245
|
}
|
|
943
1246
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
944
1247
|
|
|
945
|
-
if (hasOverriddenContracts) {
|
|
946
|
-
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
947
|
-
// We exclude them so the sync service skips them entirely.
|
|
948
|
-
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
1248
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
952
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1249
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1250
|
+
contractFunctionSimulator,
|
|
1251
|
+
txRequest,
|
|
1252
|
+
anchorBlockHeader,
|
|
1253
|
+
scopes,
|
|
1254
|
+
jobId,
|
|
1255
|
+
senderForTags,
|
|
1256
|
+
});
|
|
953
1257
|
|
|
954
1258
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
955
1259
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
@@ -957,16 +1261,22 @@ export class PXE {
|
|
|
957
1261
|
if (skipKernels) {
|
|
958
1262
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
959
1263
|
privateExecutionResult,
|
|
960
|
-
(addr, sel) => this
|
|
1264
|
+
(addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
|
|
961
1265
|
this.node,
|
|
962
1266
|
));
|
|
963
1267
|
} else {
|
|
964
1268
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
965
|
-
({ publicInputs, executionSteps } = await this.#prove(
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
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
|
+
));
|
|
970
1280
|
}
|
|
971
1281
|
|
|
972
1282
|
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
@@ -975,10 +1285,10 @@ export class PXE {
|
|
|
975
1285
|
let publicOutput: PublicSimulationOutput | undefined;
|
|
976
1286
|
if (simulatePublic && publicInputs.forPublic) {
|
|
977
1287
|
const publicSimulationTimer = new Timer();
|
|
978
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
1288
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
979
1289
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
980
1290
|
if (publicOutput?.debugLogs?.length) {
|
|
981
|
-
await displayDebugLogs(publicOutput.debugLogs, addr => this
|
|
1291
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
|
|
982
1292
|
}
|
|
983
1293
|
}
|
|
984
1294
|
|
|
@@ -1029,10 +1339,9 @@ export class PXE {
|
|
|
1029
1339
|
: {}),
|
|
1030
1340
|
});
|
|
1031
1341
|
|
|
1032
|
-
const simulatorStats = contractFunctionSimulator.getStats();
|
|
1033
1342
|
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
1034
1343
|
timings,
|
|
1035
|
-
nodeRPCCalls:
|
|
1344
|
+
nodeRPCCalls: recording.stop(),
|
|
1036
1345
|
});
|
|
1037
1346
|
} catch (err: any) {
|
|
1038
1347
|
throw this.#contextualizeError(
|
|
@@ -1040,8 +1349,11 @@ export class PXE {
|
|
|
1040
1349
|
inspect(txRequest),
|
|
1041
1350
|
`simulatePublic=${simulatePublic}`,
|
|
1042
1351
|
`skipTxValidation=${skipTxValidation}`,
|
|
1043
|
-
`scopes=${scopes
|
|
1352
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1044
1353
|
);
|
|
1354
|
+
} finally {
|
|
1355
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1356
|
+
recording.stop();
|
|
1045
1357
|
}
|
|
1046
1358
|
});
|
|
1047
1359
|
}
|
|
@@ -1052,16 +1364,17 @@ export class PXE {
|
|
|
1052
1364
|
*/
|
|
1053
1365
|
public executeUtility(
|
|
1054
1366
|
call: FunctionCall,
|
|
1055
|
-
{ authwits, scopes }: ExecuteUtilityOpts = { scopes:
|
|
1367
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1056
1368
|
): Promise<UtilityExecutionResult> {
|
|
1057
1369
|
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1058
1370
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1059
1371
|
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1060
1372
|
return this.#putInJobQueue(async jobId => {
|
|
1373
|
+
const recording = this.node.startRecording();
|
|
1061
1374
|
try {
|
|
1062
1375
|
const totalTimer = new Timer();
|
|
1063
1376
|
const syncTimer = new Timer();
|
|
1064
|
-
await this
|
|
1377
|
+
await this.#maybeSync();
|
|
1065
1378
|
const syncTime = syncTimer.ms();
|
|
1066
1379
|
const functionTimer = new Timer();
|
|
1067
1380
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -1097,12 +1410,11 @@ export class PXE {
|
|
|
1097
1410
|
unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1098
1411
|
};
|
|
1099
1412
|
|
|
1100
|
-
const simulationStats = contractFunctionSimulator.getStats();
|
|
1101
1413
|
return {
|
|
1102
1414
|
result: executionResult,
|
|
1103
1415
|
offchainEffects,
|
|
1104
1416
|
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1105
|
-
stats: { timings, nodeRPCCalls:
|
|
1417
|
+
stats: { timings, nodeRPCCalls: recording.stop() },
|
|
1106
1418
|
};
|
|
1107
1419
|
} catch (err: any) {
|
|
1108
1420
|
const { to, name, args } = call;
|
|
@@ -1110,8 +1422,11 @@ export class PXE {
|
|
|
1110
1422
|
throw this.#contextualizeError(
|
|
1111
1423
|
err,
|
|
1112
1424
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1113
|
-
`scopes=${scopes
|
|
1425
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1114
1426
|
);
|
|
1427
|
+
} finally {
|
|
1428
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1429
|
+
recording.stop();
|
|
1115
1430
|
}
|
|
1116
1431
|
});
|
|
1117
1432
|
}
|
|
@@ -1136,7 +1451,7 @@ export class PXE {
|
|
|
1136
1451
|
let anchorBlockNumber: BlockNumber;
|
|
1137
1452
|
|
|
1138
1453
|
await this.#putInJobQueue(async jobId => {
|
|
1139
|
-
await this
|
|
1454
|
+
await this.#maybeSync();
|
|
1140
1455
|
|
|
1141
1456
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1142
1457
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
@@ -1169,6 +1484,7 @@ export class PXE {
|
|
|
1169
1484
|
*/
|
|
1170
1485
|
public async stop(): Promise<void> {
|
|
1171
1486
|
await this.jobQueue.end();
|
|
1487
|
+
await this.blockStateSynchronizer.stop();
|
|
1172
1488
|
await this.db.close();
|
|
1173
1489
|
}
|
|
1174
1490
|
}
|