@aztec/pxe 0.0.1-commit.993d240 → 0.0.1-commit.9a89641
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.d.ts +2 -12
- package/dest/bin/check_oracle_version.d.ts.map +1 -1
- package/dest/bin/check_oracle_version.js +9 -122
- package/dest/bin/index.d.ts +2 -2
- package/dest/bin/index.d.ts.map +1 -1
- package/dest/bin/index.js +1 -1
- 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 +5 -5
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
- package/dest/block_synchronizer/block_stream_source.js +4 -29
- package/dest/block_synchronizer/block_synchronizer.d.ts +17 -15
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +41 -18
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- 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_sync → contract}/contract_sync_service.js +26 -45
- 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 +19 -25
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +63 -49
- 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/index.d.ts +24 -6
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +9 -4
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- 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 +2 -2
- 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 +11 -12
- 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 +6 -49
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +10 -8
- 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 +1 -60
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -2
- 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 +3 -3
- package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/option.js +18 -13
- 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 -114
- 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/oracle_registry.d.ts +92 -100
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +296 -479
- 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 +2 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +32 -21
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +152 -49
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +97 -37
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +376 -138
- 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/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +17 -6
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -6
- 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 +9 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +6 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -2
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +16 -4
- 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 +13 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +13 -13
- package/dest/hooks/execution_hooks.d.ts +31 -11
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/execution_hooks.js +3 -3
- package/dest/hooks/index.d.ts +4 -3
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/index.js +1 -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 +18 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +93 -45
- 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 +13 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +10 -10
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +8 -8
- package/dest/private_kernel/batch_planner.d.ts +1 -1
- package/dest/private_kernel/batch_planner.d.ts.map +1 -1
- package/dest/private_kernel/batch_planner.js +1 -1
- 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 +6 -2
- package/dest/private_kernel/hints/test_utils.js +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +61 -40
- package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +17 -5
- package/dest/pxe.d.ts +114 -48
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +251 -148
- 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 +8 -6
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +129 -49
- package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_service.js +6 -9
- 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 +66 -77
- 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 +197 -168
- 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 +5 -3
- package/dest/storage/open_pxe_stores.d.ts.map +1 -1
- package/dest/storage/open_pxe_stores.js +5 -3
- 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 +40 -43
- 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/sender_tagging_store.d.ts +41 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +81 -29
- 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 +29 -8
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +29 -10
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -2
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +27 -9
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +104 -33
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +6 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +23 -36
- 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 +15 -5
- 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 +36 -35
- 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 +17 -17
- package/src/bin/check_oracle_version.ts +8 -151
- package/src/bin/index.ts +1 -1
- package/src/bin/oracle_version_helpers.ts +30 -0
- package/src/block_synchronizer/block_stream_source.ts +6 -45
- package/src/block_synchronizer/block_synchronizer.ts +54 -30
- package/src/config/index.ts +1 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract/contract_class_service.ts +45 -0
- package/src/{contract_sync → contract}/contract_sync_service.ts +37 -50
- 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 +96 -59
- package/src/contract_function_simulator/execution_note_cache.ts +8 -29
- package/src/contract_function_simulator/index.ts +87 -5
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
- 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 +3 -3
- 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 +20 -46
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +13 -60
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -4
- package/src/contract_function_simulator/noir-structs/option.ts +17 -11
- 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 -189
- 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/oracle_registry.ts +289 -483
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +1067 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +2 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +190 -61
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +556 -174
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +24 -5
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +24 -5
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/pxe_creation_options.ts +8 -2
- package/src/entrypoints/server/index.ts +6 -2
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +31 -9
- package/src/error_enriching.ts +27 -11
- package/src/events/event_service.ts +24 -14
- package/src/hooks/execution_hooks.ts +32 -12
- package/src/hooks/index.ts +8 -2
- 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 +122 -61
- 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 +20 -14
- package/src/oracle_version.ts +8 -8
- package/src/private_kernel/batch_planner.ts +0 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
- package/src/private_kernel/hints/test_utils.ts +1 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +112 -56
- package/src/private_kernel/private_kernel_oracle.ts +23 -4
- package/src/pxe.ts +357 -172
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -6
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +9 -15
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +24 -4
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +29 -9
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +141 -50
- package/src/storage/capsule_store/capsule_service.ts +8 -13
- package/src/storage/contract_store/contract_store.ts +88 -94
- 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 +226 -187
- package/src/storage/note_store/stored_note.ts +5 -27
- package/src/storage/open_pxe_stores.ts +6 -3
- package/src/storage/private_event_store/private_event_store.ts +49 -55
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +113 -41
- 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 +47 -11
- package/src/tagging/index.ts +7 -2
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +161 -46
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +27 -57
- 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 +46 -40
- package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +64 -0
- package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/benchmarked_node.js +0 -77
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -89
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -552
- 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 -51
- package/dest/contract_sync/contract_sync_service.d.ts +0 -42
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/helpers.d.ts +0 -27
- package/dest/contract_sync/helpers.d.ts.map +0 -1
- package/dest/contract_sync/helpers.js +0 -53
- 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 -38
- 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/sender_sync/utils/get_status_change_of_pending.d.ts +0 -17
- 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 -60
- package/src/contract_function_simulator/benchmarked_node.ts +0 -103
- package/src/contract_function_simulator/oracle/oracle.ts +0 -711
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
- package/src/contract_sync/helpers.ts +0 -86
- package/src/messages/message_context_service.ts +0 -45
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -66
package/src/pxe.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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
11
|
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
10
12
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
type ContractArtifact,
|
|
13
15
|
EventSelector,
|
|
14
16
|
FunctionCall,
|
|
17
|
+
type FunctionSelector,
|
|
15
18
|
FunctionType,
|
|
16
19
|
decodeFunctionSignature,
|
|
17
20
|
} from '@aztec/stdlib/abi';
|
|
@@ -20,18 +23,21 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
20
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,
|
|
@@ -54,21 +60,20 @@ import { inspect } from 'util';
|
|
|
54
60
|
|
|
55
61
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
62
|
import type { PXEConfig } from './config/index.js';
|
|
57
|
-
import {
|
|
63
|
+
import { ContractClassService } from './contract/contract_class_service.js';
|
|
64
|
+
import { ContractSyncService } from './contract/contract_sync_service.js';
|
|
58
65
|
import {
|
|
59
66
|
ContractFunctionSimulator,
|
|
60
67
|
generateSimulatedProvingResult,
|
|
61
68
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
-
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
69
|
import { displayDebugLogs } from './contract_logging.js';
|
|
64
|
-
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
65
|
-
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
66
70
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
67
71
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
68
72
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
69
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,12 +83,16 @@ 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';
|
|
82
88
|
import { openPxeStores } from './storage/open_pxe_stores.js';
|
|
83
89
|
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
84
90
|
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
85
|
-
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
86
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';
|
|
87
96
|
import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
88
97
|
|
|
89
98
|
export type PackedPrivateEvent = InTx & {
|
|
@@ -160,6 +169,11 @@ export type PreloadedContractsProvider = {
|
|
|
160
169
|
export type PXECreateArgs = {
|
|
161
170
|
/** The Aztec node to connect to. */
|
|
162
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;
|
|
163
177
|
/** The key-value store for persisting PXE state. */
|
|
164
178
|
store: AztecAsyncKVStore;
|
|
165
179
|
/** The prover for generating private kernel proofs. */
|
|
@@ -168,7 +182,11 @@ export type PXECreateArgs = {
|
|
|
168
182
|
simulator: CircuitSimulator;
|
|
169
183
|
/** Provider for protocol contract artifacts and instances. */
|
|
170
184
|
protocolContractsProvider: ProtocolContractsProvider;
|
|
171
|
-
/**
|
|
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
|
+
*/
|
|
172
190
|
preloadedContractsProvider: PreloadedContractsProvider;
|
|
173
191
|
/** PXE configuration options. */
|
|
174
192
|
config: PXEConfig;
|
|
@@ -178,27 +196,58 @@ export type PXECreateArgs = {
|
|
|
178
196
|
hooks?: ExecutionHooks;
|
|
179
197
|
};
|
|
180
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
|
+
|
|
181
227
|
/**
|
|
182
228
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
183
229
|
* manage private state of users.
|
|
184
230
|
*/
|
|
185
231
|
export class PXE {
|
|
186
232
|
private constructor(
|
|
187
|
-
private node:
|
|
233
|
+
private node: CachingAztecNode,
|
|
234
|
+
private nodeDebug: AztecNodeDebug | undefined,
|
|
188
235
|
private db: AztecAsyncKVStore,
|
|
189
236
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
190
237
|
private keyStore: KeyStore,
|
|
191
238
|
private contractStore: ContractStore,
|
|
192
239
|
private noteStore: NoteStore,
|
|
193
240
|
private capsuleStore: CapsuleStore,
|
|
241
|
+
private factStore: FactStore,
|
|
194
242
|
private anchorBlockStore: AnchorBlockStore,
|
|
195
243
|
private senderTaggingStore: SenderTaggingStore,
|
|
196
|
-
private
|
|
244
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
197
245
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
198
246
|
private addressStore: AddressStore,
|
|
199
247
|
private privateEventStore: PrivateEventStore,
|
|
200
248
|
private contractSyncService: ContractSyncService,
|
|
201
|
-
private
|
|
249
|
+
private contractClassService: ContractClassService,
|
|
250
|
+
private txResolver: TxResolverService,
|
|
202
251
|
private l2TipsStore: L2TipsProvider,
|
|
203
252
|
private simulator: CircuitSimulator,
|
|
204
253
|
private proverEnabled: boolean,
|
|
@@ -222,6 +271,7 @@ export class PXE {
|
|
|
222
271
|
*/
|
|
223
272
|
public static async create({
|
|
224
273
|
node,
|
|
274
|
+
nodeDebug,
|
|
225
275
|
store,
|
|
226
276
|
proofCreator,
|
|
227
277
|
simulator,
|
|
@@ -258,26 +308,34 @@ export class PXE {
|
|
|
258
308
|
noteStore,
|
|
259
309
|
anchorBlockStore,
|
|
260
310
|
senderTaggingStore,
|
|
261
|
-
|
|
311
|
+
taggingSecretSourcesStore,
|
|
262
312
|
recipientTaggingStore,
|
|
263
313
|
capsuleStore,
|
|
264
314
|
keyStore,
|
|
265
315
|
l2TipsStore,
|
|
316
|
+
factStore,
|
|
266
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);
|
|
267
323
|
const contractSyncService = new ContractSyncService(
|
|
268
|
-
|
|
324
|
+
readCachedNode,
|
|
269
325
|
contractStore,
|
|
326
|
+
contractClassService,
|
|
270
327
|
noteStore,
|
|
271
328
|
createLogger('pxe:contract_sync', bindings),
|
|
272
329
|
);
|
|
273
|
-
const
|
|
330
|
+
const txResolver = new TxResolverService(readCachedNode);
|
|
274
331
|
|
|
275
332
|
const synchronizer = new BlockSynchronizer(
|
|
276
|
-
|
|
333
|
+
readCachedNode,
|
|
277
334
|
store,
|
|
278
335
|
anchorBlockStore,
|
|
279
336
|
noteStore,
|
|
280
337
|
privateEventStore,
|
|
338
|
+
factStore,
|
|
281
339
|
l2TipsStore,
|
|
282
340
|
contractSyncService,
|
|
283
341
|
config,
|
|
@@ -291,6 +349,7 @@ export class PXE {
|
|
|
291
349
|
recipientTaggingStore,
|
|
292
350
|
privateEventStore,
|
|
293
351
|
noteStore,
|
|
352
|
+
factStore,
|
|
294
353
|
contractSyncService,
|
|
295
354
|
]);
|
|
296
355
|
|
|
@@ -299,21 +358,24 @@ export class PXE {
|
|
|
299
358
|
const jobQueue = new SerialQueue();
|
|
300
359
|
|
|
301
360
|
const pxe = new PXE(
|
|
302
|
-
|
|
361
|
+
readCachedNode,
|
|
362
|
+
nodeDebug,
|
|
303
363
|
store,
|
|
304
364
|
synchronizer,
|
|
305
365
|
keyStore,
|
|
306
366
|
contractStore,
|
|
307
367
|
noteStore,
|
|
308
368
|
capsuleStore,
|
|
369
|
+
factStore,
|
|
309
370
|
anchorBlockStore,
|
|
310
371
|
senderTaggingStore,
|
|
311
|
-
|
|
372
|
+
taggingSecretSourcesStore,
|
|
312
373
|
recipientTaggingStore,
|
|
313
374
|
addressStore,
|
|
314
375
|
privateEventStore,
|
|
315
376
|
contractSyncService,
|
|
316
|
-
|
|
377
|
+
contractClassService,
|
|
378
|
+
txResolver,
|
|
317
379
|
l2TipsStore,
|
|
318
380
|
simulator,
|
|
319
381
|
proverEnabled,
|
|
@@ -344,27 +406,52 @@ export class PXE {
|
|
|
344
406
|
// Internal methods
|
|
345
407
|
|
|
346
408
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
347
|
-
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
348
|
-
|
|
349
409
|
return new ContractFunctionSimulator({
|
|
350
|
-
contractStore:
|
|
410
|
+
contractStore: this.contractStore,
|
|
411
|
+
contractClassService: this.contractClassService,
|
|
412
|
+
overrides: overrides?.contracts,
|
|
351
413
|
noteStore: this.noteStore,
|
|
352
414
|
keyStore: this.keyStore,
|
|
353
415
|
addressStore: this.addressStore,
|
|
354
|
-
aztecNode:
|
|
416
|
+
aztecNode: this.node,
|
|
355
417
|
l2TipsStore: this.l2TipsStore,
|
|
356
418
|
senderTaggingStore: this.senderTaggingStore,
|
|
357
419
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
358
|
-
|
|
420
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
359
421
|
capsuleStore: this.capsuleStore,
|
|
422
|
+
factStore: this.factStore,
|
|
360
423
|
privateEventStore: this.privateEventStore,
|
|
361
424
|
simulator: this.simulator,
|
|
362
425
|
contractSyncService: this.contractSyncService,
|
|
363
|
-
|
|
426
|
+
txResolver: this.txResolver,
|
|
364
427
|
hooks: this.hooks,
|
|
365
428
|
});
|
|
366
429
|
}
|
|
367
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
|
+
|
|
368
455
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
369
456
|
let contextStr = '';
|
|
370
457
|
if (context.length > 0) {
|
|
@@ -428,7 +515,14 @@ export class PXE {
|
|
|
428
515
|
|
|
429
516
|
async #registerPreloadedContracts() {
|
|
430
517
|
const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
|
|
431
|
-
await Promise.all(
|
|
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
|
+
);
|
|
432
526
|
this.log.verbose(`Registered preloaded contracts in pxe`, {
|
|
433
527
|
contracts: contracts.map(({ instance }) => instance.address.toString()),
|
|
434
528
|
});
|
|
@@ -465,8 +559,6 @@ export class PXE {
|
|
|
465
559
|
);
|
|
466
560
|
|
|
467
561
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
468
|
-
contractAddress,
|
|
469
|
-
selector: functionSelector,
|
|
470
562
|
anchorBlockHeader,
|
|
471
563
|
scopes,
|
|
472
564
|
jobId,
|
|
@@ -476,7 +568,7 @@ export class PXE {
|
|
|
476
568
|
return result;
|
|
477
569
|
} catch (err) {
|
|
478
570
|
if (err instanceof SimulationError) {
|
|
479
|
-
await enrichSimulationError(err, this.contractStore, this.log);
|
|
571
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
480
572
|
}
|
|
481
573
|
throw err;
|
|
482
574
|
}
|
|
@@ -511,7 +603,8 @@ export class PXE {
|
|
|
511
603
|
return { result, offchainEffects };
|
|
512
604
|
} catch (err) {
|
|
513
605
|
if (err instanceof SimulationError) {
|
|
514
|
-
|
|
606
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
607
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
515
608
|
}
|
|
516
609
|
throw err;
|
|
517
610
|
}
|
|
@@ -535,7 +628,14 @@ export class PXE {
|
|
|
535
628
|
} catch (err) {
|
|
536
629
|
if (err instanceof SimulationError) {
|
|
537
630
|
try {
|
|
538
|
-
|
|
631
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
632
|
+
await enrichPublicSimulationError(
|
|
633
|
+
err,
|
|
634
|
+
this.contractStore,
|
|
635
|
+
this.contractClassService,
|
|
636
|
+
anchorBlockHeader,
|
|
637
|
+
this.log,
|
|
638
|
+
);
|
|
539
639
|
} catch (enrichErr) {
|
|
540
640
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
541
641
|
}
|
|
@@ -562,7 +662,13 @@ export class PXE {
|
|
|
562
662
|
anchorBlockHeader: BlockHeader,
|
|
563
663
|
config: PrivateKernelExecutionProverConfig,
|
|
564
664
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
565
|
-
const kernelOracle = new PrivateKernelOracle(
|
|
665
|
+
const kernelOracle = new PrivateKernelOracle(
|
|
666
|
+
this.contractStore,
|
|
667
|
+
this.contractClassService,
|
|
668
|
+
this.keyStore,
|
|
669
|
+
this.node,
|
|
670
|
+
anchorBlockHeader,
|
|
671
|
+
);
|
|
566
672
|
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
567
673
|
kernelOracle,
|
|
568
674
|
proofCreator,
|
|
@@ -606,11 +712,11 @@ export class PXE {
|
|
|
606
712
|
}
|
|
607
713
|
|
|
608
714
|
/**
|
|
609
|
-
* Returns the contract instance
|
|
715
|
+
* Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
|
|
610
716
|
* @param address - The contract address.
|
|
611
|
-
* @returns The contract instance if found, undefined otherwise.
|
|
717
|
+
* @returns The contract instance address preimage if found, undefined otherwise.
|
|
612
718
|
*/
|
|
613
|
-
public getContractInstance(address: AztecAddress): Promise<
|
|
719
|
+
public getContractInstance(address: AztecAddress): Promise<ContractInstancePreimageWithAddress | undefined> {
|
|
614
720
|
return this.contractStore.getContractInstance(address);
|
|
615
721
|
}
|
|
616
722
|
|
|
@@ -624,18 +730,22 @@ export class PXE {
|
|
|
624
730
|
}
|
|
625
731
|
|
|
626
732
|
/**
|
|
627
|
-
* Registers a user account in PXE
|
|
628
|
-
*
|
|
629
|
-
* the
|
|
630
|
-
*
|
|
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.
|
|
631
737
|
*
|
|
632
|
-
*
|
|
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.
|
|
633
743
|
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
634
744
|
* @returns The complete address of the account.
|
|
635
745
|
*/
|
|
636
|
-
public async registerAccount(
|
|
746
|
+
public async registerAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
637
747
|
const accounts = await this.keyStore.getAccounts();
|
|
638
|
-
const accountCompleteAddress = await this.keyStore.addAccount(
|
|
748
|
+
const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
|
|
639
749
|
if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
|
|
640
750
|
this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
|
|
641
751
|
return accountCompleteAddress;
|
|
@@ -649,62 +759,189 @@ export class PXE {
|
|
|
649
759
|
}
|
|
650
760
|
|
|
651
761
|
/**
|
|
652
|
-
*
|
|
762
|
+
* Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
|
|
763
|
+
* outgoing-viewing, tagging).
|
|
653
764
|
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
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.
|
|
656
768
|
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
769
|
+
* Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
|
|
770
|
+
* and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
|
|
771
|
+
* these keys. Applications should NEVER be given access to them.
|
|
772
|
+
*
|
|
773
|
+
* @throws If the account is not registered.
|
|
660
774
|
*/
|
|
661
|
-
public
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
665
|
-
);
|
|
666
|
-
}
|
|
775
|
+
public getAccountSecretKeys(account: AztecAddress): Promise<AccountPrivacySecretKeys> {
|
|
776
|
+
return this.keyStore.getAccountSecretKeys(account);
|
|
777
|
+
}
|
|
667
778
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
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
|
+
}
|
|
672
808
|
}
|
|
673
809
|
|
|
674
|
-
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
675
|
-
|
|
676
810
|
if (wasAdded) {
|
|
677
|
-
|
|
678
|
-
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
679
|
-
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
811
|
+
// Queued to avoid wiping while a job is in flight.
|
|
680
812
|
await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
|
|
681
|
-
} else {
|
|
682
|
-
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
683
813
|
}
|
|
814
|
+
}
|
|
684
815
|
|
|
685
|
-
|
|
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
|
+
}
|
|
686
848
|
}
|
|
687
849
|
|
|
688
850
|
/**
|
|
689
|
-
* Retrieves
|
|
690
|
-
*
|
|
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}.
|
|
691
853
|
*/
|
|
692
|
-
public
|
|
693
|
-
|
|
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;
|
|
694
893
|
}
|
|
695
894
|
|
|
696
895
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
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.
|
|
699
904
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
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
|
+
}
|
|
702
912
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
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
|
+
);
|
|
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.`);
|
|
707
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;
|
|
708
945
|
}
|
|
709
946
|
|
|
710
947
|
/**
|
|
@@ -728,98 +965,33 @@ export class PXE {
|
|
|
728
965
|
*/
|
|
729
966
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
730
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
|
+
}
|
|
731
976
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
732
977
|
}
|
|
733
978
|
|
|
734
979
|
/**
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
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.
|
|
739
984
|
*
|
|
740
|
-
* @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.
|
|
741
987
|
*/
|
|
742
|
-
public
|
|
743
|
-
|
|
744
|
-
let { artifact } = contract;
|
|
745
|
-
|
|
746
|
-
if (artifact) {
|
|
747
|
-
// If the user provides an artifact, validate it against the expected class id and register it
|
|
748
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
749
|
-
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
750
|
-
throw new Error(
|
|
751
|
-
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
752
|
-
);
|
|
753
|
-
}
|
|
754
|
-
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
755
|
-
if (!computedAddress.equals(instance.address)) {
|
|
756
|
-
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
760
|
-
|
|
761
|
-
const publicFunctionSignatures = artifact.functions
|
|
762
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
763
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
764
|
-
if (publicFunctionSignatures.length > 0) {
|
|
765
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
766
|
-
}
|
|
767
|
-
} else {
|
|
768
|
-
// Otherwise, make sure there is an artifact already registered for that class id
|
|
769
|
-
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
770
|
-
if (!artifact) {
|
|
771
|
-
throw new Error(
|
|
772
|
-
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
773
|
-
);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
await this.contractStore.addContractInstance(instance);
|
|
778
|
-
this.log.info(
|
|
779
|
-
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
785
|
-
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
786
|
-
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
787
|
-
* @param contractAddress - The address of the contract to update.
|
|
788
|
-
* @param artifact - The updated artifact for the contract.
|
|
789
|
-
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
790
|
-
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
791
|
-
*/
|
|
792
|
-
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
793
|
-
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
794
|
-
// 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.
|
|
795
990
|
return this.#putInJobQueue(async () => {
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
801
|
-
await this.#maybeSync();
|
|
802
|
-
|
|
803
|
-
const header = await this.anchorBlockStore.getBlockHeader();
|
|
804
|
-
|
|
805
|
-
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
806
|
-
if (!contractClass.id.equals(currentClassId)) {
|
|
807
|
-
throw new Error('Could not update contract to a class different from the current one.');
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
const publicFunctionSignatures = artifact.functions
|
|
811
|
-
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
812
|
-
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
813
|
-
if (publicFunctionSignatures.length > 0) {
|
|
814
|
-
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
currentInstance.currentContractClassId = contractClass.id;
|
|
818
|
-
await Promise.all([
|
|
819
|
-
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
820
|
-
this.contractStore.addContractInstance(currentInstance),
|
|
821
|
-
]);
|
|
822
|
-
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;
|
|
823
995
|
});
|
|
824
996
|
}
|
|
825
997
|
|
|
@@ -847,6 +1019,7 @@ export class PXE {
|
|
|
847
1019
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
848
1020
|
return this.#putInJobQueue(async jobId => {
|
|
849
1021
|
const totalTimer = new Timer();
|
|
1022
|
+
const recording = this.node.startRecording();
|
|
850
1023
|
try {
|
|
851
1024
|
const syncTimer = new Timer();
|
|
852
1025
|
await this.#maybeSync();
|
|
@@ -894,7 +1067,7 @@ export class PXE {
|
|
|
894
1067
|
|
|
895
1068
|
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
896
1069
|
timings,
|
|
897
|
-
nodeRPCCalls:
|
|
1070
|
+
nodeRPCCalls: recording.stop(),
|
|
898
1071
|
});
|
|
899
1072
|
|
|
900
1073
|
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
@@ -915,6 +1088,9 @@ export class PXE {
|
|
|
915
1088
|
return txProvingResult;
|
|
916
1089
|
} catch (err: any) {
|
|
917
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();
|
|
918
1094
|
}
|
|
919
1095
|
});
|
|
920
1096
|
}
|
|
@@ -932,6 +1108,7 @@ export class PXE {
|
|
|
932
1108
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
933
1109
|
return this.#putInJobQueue(async jobId => {
|
|
934
1110
|
const totalTimer = new Timer();
|
|
1111
|
+
const recording = this.node.startRecording();
|
|
935
1112
|
try {
|
|
936
1113
|
const txInfo = {
|
|
937
1114
|
origin: txRequest.origin,
|
|
@@ -997,10 +1174,12 @@ export class PXE {
|
|
|
997
1174
|
total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
998
1175
|
};
|
|
999
1176
|
|
|
1000
|
-
|
|
1001
|
-
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: simulatorStats.nodeRPCCalls });
|
|
1177
|
+
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: recording.stop() });
|
|
1002
1178
|
} catch (err: any) {
|
|
1003
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();
|
|
1004
1183
|
}
|
|
1005
1184
|
});
|
|
1006
1185
|
}
|
|
@@ -1039,6 +1218,7 @@ export class PXE {
|
|
|
1039
1218
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1040
1219
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
1041
1220
|
return this.#putInJobQueue(async jobId => {
|
|
1221
|
+
const recording = this.node.startRecording();
|
|
1042
1222
|
try {
|
|
1043
1223
|
const totalTimer = new Timer();
|
|
1044
1224
|
const txInfo = {
|
|
@@ -1081,7 +1261,7 @@ export class PXE {
|
|
|
1081
1261
|
if (skipKernels) {
|
|
1082
1262
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
1083
1263
|
privateExecutionResult,
|
|
1084
|
-
(addr, sel) => this
|
|
1264
|
+
(addr, sel) => this.#getDebugFunctionName(addr, sel, anchorBlockHeader),
|
|
1085
1265
|
this.node,
|
|
1086
1266
|
));
|
|
1087
1267
|
} else {
|
|
@@ -1108,7 +1288,7 @@ export class PXE {
|
|
|
1108
1288
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
1109
1289
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
1110
1290
|
if (publicOutput?.debugLogs?.length) {
|
|
1111
|
-
await displayDebugLogs(publicOutput.debugLogs, addr => this
|
|
1291
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.#getDebugContractName(addr, anchorBlockHeader));
|
|
1112
1292
|
}
|
|
1113
1293
|
}
|
|
1114
1294
|
|
|
@@ -1159,10 +1339,9 @@ export class PXE {
|
|
|
1159
1339
|
: {}),
|
|
1160
1340
|
});
|
|
1161
1341
|
|
|
1162
|
-
const simulatorStats = contractFunctionSimulator.getStats();
|
|
1163
1342
|
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
1164
1343
|
timings,
|
|
1165
|
-
nodeRPCCalls:
|
|
1344
|
+
nodeRPCCalls: recording.stop(),
|
|
1166
1345
|
});
|
|
1167
1346
|
} catch (err: any) {
|
|
1168
1347
|
throw this.#contextualizeError(
|
|
@@ -1172,6 +1351,9 @@ export class PXE {
|
|
|
1172
1351
|
`skipTxValidation=${skipTxValidation}`,
|
|
1173
1352
|
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1174
1353
|
);
|
|
1354
|
+
} finally {
|
|
1355
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1356
|
+
recording.stop();
|
|
1175
1357
|
}
|
|
1176
1358
|
});
|
|
1177
1359
|
}
|
|
@@ -1188,6 +1370,7 @@ export class PXE {
|
|
|
1188
1370
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1189
1371
|
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1190
1372
|
return this.#putInJobQueue(async jobId => {
|
|
1373
|
+
const recording = this.node.startRecording();
|
|
1191
1374
|
try {
|
|
1192
1375
|
const totalTimer = new Timer();
|
|
1193
1376
|
const syncTimer = new Timer();
|
|
@@ -1227,12 +1410,11 @@ export class PXE {
|
|
|
1227
1410
|
unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1228
1411
|
};
|
|
1229
1412
|
|
|
1230
|
-
const simulationStats = contractFunctionSimulator.getStats();
|
|
1231
1413
|
return {
|
|
1232
1414
|
result: executionResult,
|
|
1233
1415
|
offchainEffects,
|
|
1234
1416
|
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1235
|
-
stats: { timings, nodeRPCCalls:
|
|
1417
|
+
stats: { timings, nodeRPCCalls: recording.stop() },
|
|
1236
1418
|
};
|
|
1237
1419
|
} catch (err: any) {
|
|
1238
1420
|
const { to, name, args } = call;
|
|
@@ -1242,6 +1424,9 @@ export class PXE {
|
|
|
1242
1424
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1243
1425
|
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1244
1426
|
);
|
|
1427
|
+
} finally {
|
|
1428
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1429
|
+
recording.stop();
|
|
1245
1430
|
}
|
|
1246
1431
|
});
|
|
1247
1432
|
}
|