@aztec-labs/pxe 6.0.0-nightly.20260829
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/README.md +13 -0
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +22 -0
- 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 +47 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +192 -0
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +57 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +80 -0
- package/dest/config/package_info.d.ts +5 -0
- package/dest/config/package_info.d.ts.map +1 -0
- package/dest/config/package_info.js +6 -0
- package/dest/contract/contract_call_graph.d.ts +51 -0
- package/dest/contract/contract_call_graph.d.ts.map +1 -0
- package/dest/contract/contract_call_graph.js +91 -0
- 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 +82 -0
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/contract/contract_sync_service.js +210 -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 +114 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +495 -0
- 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 +98 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +189 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +12 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +30 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +36 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +20 -0
- 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 +20 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +39 -0
- 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 +25 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +14 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +19 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +4 -0
- 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 +22 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +47 -0
- package/dest/contract_function_simulator/noir-structs/nullifier_membership_witness_data.d.ts +12 -0
- package/dest/contract_function_simulator/noir-structs/nullifier_membership_witness_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/nullifier_membership_witness_data.js +6 -0
- 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/public_data_witness_data.d.ts +13 -0
- package/dest/contract_function_simulator/noir-structs/public_data_witness_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/public_data_witness_data.js +3 -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 +11 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +3 -0
- 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 +3 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +24 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- 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/note_packing_utils.d.ts +28 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
- 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 +1024 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +292 -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 +1258 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +23 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +88 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +226 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +585 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +333 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +900 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +68 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/transient_array_service.js +62 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/debug/pxe_debug_utils.d.ts +38 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +44 -0
- package/dest/entrypoints/client/bundle/index.d.ts +10 -0
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -0
- package/dest/entrypoints/client/bundle/index.js +8 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +16 -0
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -0
- package/dest/entrypoints/client/bundle/utils.js +78 -0
- package/dest/entrypoints/client/lazy/index.d.ts +10 -0
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -0
- package/dest/entrypoints/client/lazy/index.js +8 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +15 -0
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -0
- package/dest/entrypoints/client/lazy/utils.js +77 -0
- 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 +32 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/pxe_creation_options.js +3 -0
- package/dest/entrypoints/server/circuit_recording/circuit_recorder.d.ts +121 -0
- package/dest/entrypoints/server/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/entrypoints/server/circuit_recording/circuit_recorder.js +208 -0
- package/dest/entrypoints/server/circuit_recording/file_circuit_recorder.d.ts +20 -0
- package/dest/entrypoints/server/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/entrypoints/server/circuit_recording/file_circuit_recorder.js +131 -0
- package/dest/entrypoints/server/circuit_recording/memory_circuit_recorder.d.ts +10 -0
- package/dest/entrypoints/server/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/entrypoints/server/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts +18 -0
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.js +41 -0
- package/dest/entrypoints/server/index.d.ts +17 -0
- package/dest/entrypoints/server/index.d.ts.map +1 -0
- package/dest/entrypoints/server/index.js +14 -0
- 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 +9 -0
- package/dest/entrypoints/server/utils.d.ts.map +1 -0
- package/dest/entrypoints/server/utils.js +84 -0
- package/dest/error_enriching.d.ts +13 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/error_enriching.js +80 -0
- package/dest/events/event_service.d.ts +30 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +76 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +10 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +53 -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 +40 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +217 -0
- package/dest/messages/tx_resolver_service.d.ts +28 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/tx_resolver_service.js +62 -0
- package/dest/node/benchmarked_node.d.ts +22 -0
- package/dest/node/benchmarked_node.d.ts.map +1 -0
- package/dest/node/benchmarked_node.js +93 -0
- package/dest/node/caching_aztec_node.d.ts +24 -0
- package/dest/node/caching_aztec_node.d.ts.map +1 -0
- package/dest/node/caching_aztec_node.js +268 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +77 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +173 -0
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/operation_lifecycle.d.ts +45 -0
- package/dest/operation_lifecycle.d.ts.map +1 -0
- package/dest/operation_lifecycle.js +68 -0
- package/dest/operation_queue.d.ts +75 -0
- package/dest/operation_queue.d.ts.map +1 -0
- package/dest/operation_queue.js +100 -0
- package/dest/oracle_version.d.ts +4 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +21 -0
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/private_kernel/hints/index.js +2 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +343 -0
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +202 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +49 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +408 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +65 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +110 -0
- package/dest/pxe.d.ts +364 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +903 -0
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/address_store/address_store.js +49 -0
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- 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 +20 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.js +28 -0
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- 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 +674 -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/base_staging_store.d.ts +110 -0
- package/dest/storage/base_staging_store.d.ts.map +1 -0
- package/dest/storage/base_staging_store.js +141 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +22 -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 +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +256 -0
- package/dest/storage/capsule_store/index.d.ts +3 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +2 -0
- package/dest/storage/contract_store/contract_store.d.ts +96 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +282 -0
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts +27 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/contract_store/private_functions_tree.js +48 -0
- package/dest/storage/fact_store/fact_service.d.ts +23 -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 +101 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +350 -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 +10 -0
- package/dest/storage/index.d.ts.map +1 -0
- package/dest/storage/index.js +9 -0
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +92 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +273 -0
- package/dest/storage/note_store/stored_note.d.ts +11 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +27 -0
- package/dest/storage/note_store/test_utils.d.ts +9 -0
- package/dest/storage/note_store/test_utils.d.ts.map +1 -0
- package/dest/storage/note_store/test_utils.js +10 -0
- 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 +90 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +276 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/rollbackable.d.ts +15 -0
- package/dest/storage/rollbackable.d.ts.map +1 -0
- package/dest/storage/rollbackable.js +3 -0
- package/dest/storage/staged_write_coordinator.d.ts +103 -0
- package/dest/storage/staged_write_coordinator.d.ts.map +1 -0
- package/dest/storage/staged_write_coordinator.js +141 -0
- 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 +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +36 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +74 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +113 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +432 -0
- 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 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +38 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +69 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +79 -0
- package/dest/tagging/index.d.ts +18 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +16 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +31 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +43 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +75 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +235 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- 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 +20 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +77 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.js +62 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +30 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +42 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/dest/test_utils.d.ts +3 -0
- package/dest/test_utils.d.ts.map +1 -0
- package/dest/test_utils.js +1 -0
- package/package.json +119 -0
- package/src/bin/check_oracle_version.ts +28 -0
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +30 -0
- package/src/block_synchronizer/block_stream_source.ts +48 -0
- package/src/block_synchronizer/block_synchronizer.ts +225 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +141 -0
- package/src/config/package_info.ts +3 -0
- package/src/contract/contract_call_graph.ts +121 -0
- package/src/contract/contract_class_service.ts +45 -0
- package/src/contract/contract_sync_service.ts +349 -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 +928 -0
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +232 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +33 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +107 -0
- 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 +52 -0
- 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 +35 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +19 -0
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +59 -0
- package/src/contract_function_simulator/noir-structs/nullifier_membership_witness_data.ts +15 -0
- 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/public_data_witness_data.ts +13 -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 +11 -0
- package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
- package/src/contract_function_simulator/oracle/index.ts +2 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -0
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
- package/src/contract_function_simulator/oracle/oracle_registry.ts +709 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +1089 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +140 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +812 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +1341 -0
- package/src/contract_function_simulator/pick_notes.ts +160 -0
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/contract_logging.ts +52 -0
- package/src/debug/pxe_debug_utils.ts +89 -0
- package/src/entrypoints/client/bundle/index.ts +9 -0
- package/src/entrypoints/client/bundle/utils.ts +89 -0
- package/src/entrypoints/client/lazy/index.ts +9 -0
- package/src/entrypoints/client/lazy/utils.ts +89 -0
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/pxe_creation_options.ts +34 -0
- package/src/entrypoints/server/circuit_recording/circuit_recorder.ts +267 -0
- package/src/entrypoints/server/circuit_recording/file_circuit_recorder.ts +152 -0
- package/src/entrypoints/server/circuit_recording/memory_circuit_recorder.ts +13 -0
- package/src/entrypoints/server/circuit_recording/simulator_recorder_wrapper.ts +90 -0
- package/src/entrypoints/server/index.ts +17 -0
- package/src/entrypoints/server/store.ts +46 -0
- package/src/entrypoints/server/utils.ts +103 -0
- package/src/error_enriching.ts +124 -0
- package/src/events/event_service.ts +129 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +66 -0
- 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 +295 -0
- package/src/messages/tx_resolver_service.ts +81 -0
- package/src/node/benchmarked_node.ts +141 -0
- package/src/node/caching_aztec_node.ts +407 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +238 -0
- package/src/notes_filter.ts +24 -0
- package/src/operation_lifecycle.ts +99 -0
- package/src/operation_queue.ts +149 -0
- package/src/oracle_version.ts +22 -0
- package/src/private_kernel/batch_planner.ts +168 -0
- package/src/private_kernel/hints/compute_tx_expiration_timestamp.ts +58 -0
- package/src/private_kernel/hints/index.ts +2 -0
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +553 -0
- package/src/private_kernel/hints/test_utils.ts +318 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +656 -0
- package/src/private_kernel/private_kernel_oracle.ts +184 -0
- package/src/pxe.ts +1417 -0
- package/src/storage/address_store/address_store.ts +66 -0
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +35 -0
- package/src/storage/anchor_block_store/index.ts +1 -0
- 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 +813 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/base_staging_store.ts +227 -0
- package/src/storage/capsule_store/capsule_service.ts +97 -0
- package/src/storage/capsule_store/capsule_store.ts +349 -0
- package/src/storage/capsule_store/index.ts +2 -0
- package/src/storage/contract_store/contract_store.ts +403 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/contract_store/private_functions_tree.ts +68 -0
- package/src/storage/fact_store/fact_service.ts +70 -0
- package/src/storage/fact_store/fact_store.ts +424 -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 +9 -0
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +367 -0
- package/src/storage/note_store/stored_note.ts +26 -0
- package/src/storage/note_store/test_utils.ts +16 -0
- package/src/storage/open_pxe_stores.ts +52 -0
- package/src/storage/private_event_store/private_event_store.ts +383 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/rollbackable.ts +14 -0
- package/src/storage/staged_write_coordinator.ts +218 -0
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +114 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +564 -0
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
- package/src/tagging/constants.ts +42 -0
- package/src/tagging/get_all_logs_by_tags.ts +157 -0
- package/src/tagging/index.ts +25 -0
- package/src/tagging/persist_sender_tagging_index_ranges.ts +59 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +357 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +113 -0
- package/src/tagging/sender_sync/utils/classify_pending_txs.ts +92 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +92 -0
- package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +65 -0
- package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/src/test_utils.ts +2 -0
|
@@ -0,0 +1,900 @@
|
|
|
1
|
+
import { L1_TO_L2_MSG_TREE_HEIGHT, PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec-labs/constants';
|
|
2
|
+
import { uniqueBy } from '@aztec-labs/foundation/collection';
|
|
3
|
+
import { Aes128 } from '@aztec-labs/foundation/crypto/aes128';
|
|
4
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
5
|
+
import { Point } from '@aztec-labs/foundation/curves/grumpkin';
|
|
6
|
+
import { LogLevels, createLogger } from '@aztec-labs/foundation/log';
|
|
7
|
+
import { allToCompletion } from '@aztec-labs/foundation/promise';
|
|
8
|
+
import { MembershipWitness } from '@aztec-labs/foundation/trees';
|
|
9
|
+
import { ExecutionError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec-labs/simulator/client';
|
|
10
|
+
import { STANDARD_HANDSHAKE_REGISTRY_ADDRESS } from '@aztec-labs/standard-contracts/handshake-registry/constants';
|
|
11
|
+
import { FunctionSelector } from '@aztec-labs/stdlib/abi';
|
|
12
|
+
import { siloNullifier } from '@aztec-labs/stdlib/hash';
|
|
13
|
+
import { computeAddressSecret, hashPublicKey } from '@aztec-labs/stdlib/keys';
|
|
14
|
+
import { AppTaggingSecret, FlatPublicLogs, appSiloEcdhSharedSecret } from '@aztec-labs/stdlib/logs';
|
|
15
|
+
import { getL1ToL2MessageWitness } from '@aztec-labs/stdlib/messaging';
|
|
16
|
+
import { MerkleTreeId } from '@aztec-labs/stdlib/trees';
|
|
17
|
+
import { CallContext } from '@aztec-labs/stdlib/tx';
|
|
18
|
+
import { createContractLogger, logContractMessage, stripAztecnrLogPrefix } from '../../contract_logging.js';
|
|
19
|
+
import { EventService } from '../../events/event_service.js';
|
|
20
|
+
import { LogService } from '../../logs/log_service.js';
|
|
21
|
+
import { NoteService } from '../../notes/note_service.js';
|
|
22
|
+
import { ORACLE_VERSION_MAJOR } from '../../oracle_version.js';
|
|
23
|
+
import { assertAllowedScope } from '../../storage/allowed_scopes.js';
|
|
24
|
+
import { FactCollectionKey, FactCollectionTypeKey, anchoredTipBlockNumbers } from '../../storage/fact_store/index.js';
|
|
25
|
+
import { EphemeralArrayService } from '../ephemeral_array_service.js';
|
|
26
|
+
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
27
|
+
import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
|
|
28
|
+
import { emptyFactCollection, toNoirFactCollection } from '../noir-structs/fact_collection.js';
|
|
29
|
+
import { toNullifierMembershipWitnessData } from '../noir-structs/nullifier_membership_witness_data.js';
|
|
30
|
+
import { Option } from '../noir-structs/option.js';
|
|
31
|
+
import { pickNotes } from '../pick_notes.js';
|
|
32
|
+
import { buildACIRCallback } from './acir_callback.js';
|
|
33
|
+
/**
|
|
34
|
+
* The oracle for an execution of utility contract functions.
|
|
35
|
+
*/ export class UtilityExecutionOracle {
|
|
36
|
+
isMisc = true;
|
|
37
|
+
isUtility = true;
|
|
38
|
+
contractLogger;
|
|
39
|
+
aztecnrLogger;
|
|
40
|
+
offchainEffects = [];
|
|
41
|
+
ephemeralArrayService = new EphemeralArrayService();
|
|
42
|
+
transientArrayService;
|
|
43
|
+
/** Keyed by tx hash string. */ txReceiptsCache = new Map();
|
|
44
|
+
/**
|
|
45
|
+
* Information that can be used to validate the existence of a note or an event, keyed by tx hash string. It is
|
|
46
|
+
* populated by the node queries that precede validation (tagged log retrieval, tx resolution), which already return
|
|
47
|
+
* everything validation needs, so validating a note or event created in one of those txs costs no node roundtrip.
|
|
48
|
+
* Notes and events reached through other paths (e.g. offchain inbox messages) still need a receipt.
|
|
49
|
+
*/ validationTxDataCache = new Map();
|
|
50
|
+
// We store oracle version to be able to show a nice error message when an oracle handler is missing.
|
|
51
|
+
contractOracleVersion;
|
|
52
|
+
callContext;
|
|
53
|
+
authWitnesses;
|
|
54
|
+
capsules;
|
|
55
|
+
anchorBlockHeader;
|
|
56
|
+
anchoredContractData;
|
|
57
|
+
noteStore;
|
|
58
|
+
keyStore;
|
|
59
|
+
addressStore;
|
|
60
|
+
aztecNode;
|
|
61
|
+
recipientTaggingStore;
|
|
62
|
+
taggingSecretSourcesStore;
|
|
63
|
+
capsuleService;
|
|
64
|
+
factService;
|
|
65
|
+
privateEventStore;
|
|
66
|
+
txResolver;
|
|
67
|
+
contractSyncService;
|
|
68
|
+
l2TipsStore;
|
|
69
|
+
changeSetId;
|
|
70
|
+
logger;
|
|
71
|
+
scopes;
|
|
72
|
+
simulator;
|
|
73
|
+
hooks;
|
|
74
|
+
utilityExecutor;
|
|
75
|
+
constructor(args){
|
|
76
|
+
this.callContext = args.callContext;
|
|
77
|
+
this.authWitnesses = args.authWitnesses;
|
|
78
|
+
this.capsules = args.capsules;
|
|
79
|
+
this.anchorBlockHeader = args.anchorBlockHeader;
|
|
80
|
+
this.anchoredContractData = args.anchoredContractData;
|
|
81
|
+
this.noteStore = args.noteStore;
|
|
82
|
+
this.keyStore = args.keyStore;
|
|
83
|
+
this.addressStore = args.addressStore;
|
|
84
|
+
this.aztecNode = args.aztecNode;
|
|
85
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
86
|
+
this.taggingSecretSourcesStore = args.taggingSecretSourcesStore;
|
|
87
|
+
this.capsuleService = args.capsuleService;
|
|
88
|
+
this.factService = args.factService;
|
|
89
|
+
this.privateEventStore = args.privateEventStore;
|
|
90
|
+
this.txResolver = args.txResolver;
|
|
91
|
+
this.contractSyncService = args.contractSyncService;
|
|
92
|
+
this.l2TipsStore = args.l2TipsStore;
|
|
93
|
+
this.changeSetId = args.changeSetId;
|
|
94
|
+
this.logger = args.log ?? createLogger('simulator:client_view_context');
|
|
95
|
+
this.scopes = args.scopes;
|
|
96
|
+
this.simulator = args.simulator;
|
|
97
|
+
this.hooks = args.hooks;
|
|
98
|
+
this.utilityExecutor = args.utilityExecutor;
|
|
99
|
+
this.transientArrayService = args.transientArrayService;
|
|
100
|
+
}
|
|
101
|
+
assertCompatibleOracleVersion(major, minor) {
|
|
102
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
103
|
+
const hint = major > ORACLE_VERSION_MAJOR ? 'The contract was compiled with a newer version of Aztec.nr than your private environment supports. Upgrade your private environment to a compatible version.' : 'The contract was compiled with an older version of Aztec.nr than your private environment supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
104
|
+
throw new Error(`Incompatible private environment version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
105
|
+
}
|
|
106
|
+
this.contractOracleVersion = {
|
|
107
|
+
major,
|
|
108
|
+
minor
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
112
|
+
nonOracleFunctionGetContractOracleVersion() {
|
|
113
|
+
return this.contractOracleVersion;
|
|
114
|
+
}
|
|
115
|
+
getRandomField() {
|
|
116
|
+
return Fr.random();
|
|
117
|
+
}
|
|
118
|
+
getUtilityContext() {
|
|
119
|
+
return {
|
|
120
|
+
blockHeader: this.anchorBlockHeader,
|
|
121
|
+
contractAddress: this.callContext.contractAddress,
|
|
122
|
+
msgSender: this.callContext.msgSender
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Retrieve keys associated with a specific master public key and app address.
|
|
127
|
+
* @param pkMHash - The master public key hash.
|
|
128
|
+
* @param _keyIndex - Sent by the Noir oracle caller but unused here; kept to match the oracle signature.
|
|
129
|
+
* @returns A Promise that resolves to nullifier keys.
|
|
130
|
+
* @throws If the keys are not registered in the key store.
|
|
131
|
+
* @throws If scopes are defined and the account is not in the scopes.
|
|
132
|
+
*/ async getKeyValidationRequest(pkMHash, _keyIndex) {
|
|
133
|
+
let hasAccess = false;
|
|
134
|
+
for(let i = 0; i < this.scopes.length && !hasAccess; i++){
|
|
135
|
+
if (await this.keyStore.accountHasKey(this.scopes[i], pkMHash)) {
|
|
136
|
+
hasAccess = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (!hasAccess) {
|
|
140
|
+
throw new Error(`Key validation request denied: no scoped account has a key with hash ${pkMHash.toString()}.`);
|
|
141
|
+
}
|
|
142
|
+
return this.keyStore.getKeyValidationRequest(pkMHash, this.contractAddress);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Fetches the index and sibling path of a leaf at a given block from the note hash tree.
|
|
146
|
+
* @param blockHash - The hash of a block that contains the note hash tree root in which to find the
|
|
147
|
+
* membership witness.
|
|
148
|
+
* @param noteHash - The note hash to find in the note hash tree.
|
|
149
|
+
* @returns The membership witness containing the leaf index and sibling path
|
|
150
|
+
*/ async getNoteHashMembershipWitness(blockHash, noteHash) {
|
|
151
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getNoteHashMembershipWitness(blockHash, noteHash));
|
|
152
|
+
if (!witness) {
|
|
153
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
154
|
+
}
|
|
155
|
+
return witness;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Fetches the index and sibling path of a block hash in the archive tree.
|
|
159
|
+
*
|
|
160
|
+
* Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
|
|
161
|
+
* its block hash is appended as a new leaf to the archive tree.
|
|
162
|
+
*
|
|
163
|
+
* @param referenceBlockHash - The hash of a block that contains the archive tree root in which to find the membership
|
|
164
|
+
* witness.
|
|
165
|
+
* @param blockHash - The block hash to find in the archive tree.
|
|
166
|
+
* @returns The membership witness containing the leaf index and sibling path
|
|
167
|
+
*/ async getBlockHashMembershipWitness(referenceBlockHash, blockHash) {
|
|
168
|
+
// Note that we validate that the reference block hash is at or before the anchor block - we don't test the block
|
|
169
|
+
// hash at all. If the block hash did not exist by the reference block hash, then the node will not return the
|
|
170
|
+
// membership witness as there is none.
|
|
171
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, ()=>this.aztecNode.getBlockHashMembershipWitness(referenceBlockHash, blockHash));
|
|
172
|
+
return witness ? Option.some(witness) : Option.none();
|
|
173
|
+
}
|
|
174
|
+
/** Returns whether each block hash is present in the archive tree at the referenced block. */ async areBlockHashesInArchive(referenceBlockHash, blockHashes) {
|
|
175
|
+
const hashes = blockHashes.readAll(this.ephemeralArrayService);
|
|
176
|
+
const memberships = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, ()=>allToCompletion(hashes.map((blockHash)=>this.aztecNode.getBlockHashMembershipWitness(referenceBlockHash, blockHash).then(Boolean))));
|
|
177
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, memberships);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
181
|
+
* @param blockHash - The block hash at which to get the index.
|
|
182
|
+
* @param nullifier - Nullifier we try to find witness for.
|
|
183
|
+
* @returns The nullifier membership witness (if found).
|
|
184
|
+
*/ async getNullifierMembershipWitness(blockHash, nullifier) {
|
|
185
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier));
|
|
186
|
+
if (!witness) {
|
|
187
|
+
throw new Error(`Nullifier membership witness not found at block ${blockHash.toString()}.`);
|
|
188
|
+
}
|
|
189
|
+
return toNullifierMembershipWitnessData(witness);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
193
|
+
* @param blockHash - The block hash at which to get the index.
|
|
194
|
+
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
195
|
+
* @returns The low nullifier membership witness (if found).
|
|
196
|
+
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
197
|
+
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
198
|
+
* we are trying to prove non-inclusion for.
|
|
199
|
+
*/ async getLowNullifierMembershipWitness(blockHash, nullifier) {
|
|
200
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier));
|
|
201
|
+
if (!witness) {
|
|
202
|
+
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block hash ${blockHash.toString()}.`);
|
|
203
|
+
}
|
|
204
|
+
return toNullifierMembershipWitnessData(witness);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
208
|
+
* @param blockHash - The block hash at which to get the index.
|
|
209
|
+
* @param leafSlot - The slot of the public data tree to get the witness for.
|
|
210
|
+
* @returns - The witness
|
|
211
|
+
*/ async getPublicDataWitness(blockHash, leafSlot) {
|
|
212
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getPublicDataWitness(blockHash, leafSlot));
|
|
213
|
+
if (!witness) {
|
|
214
|
+
throw new Error(`Public data witness not found for slot ${leafSlot} at block hash ${blockHash.toString()}.`);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
index: witness.index,
|
|
218
|
+
leafPreimage: witness.leafPreimage,
|
|
219
|
+
siblingPath: witness.siblingPath.toTuple()
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Fetches a block header of a given block.
|
|
224
|
+
* @param blockNumber - The number of a block of which to get the block header.
|
|
225
|
+
* @returns Block extracted from a block with block number `blockNumber`.
|
|
226
|
+
*/ async getBlockHeader(blockNumber) {
|
|
227
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
228
|
+
if (blockNumber > anchorBlockNumber) {
|
|
229
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
230
|
+
}
|
|
231
|
+
// Most contracts query state at the "current" block, which is the anchor. Skip the RPC when we can.
|
|
232
|
+
if (blockNumber === anchorBlockNumber) {
|
|
233
|
+
return this.anchorBlockHeader;
|
|
234
|
+
}
|
|
235
|
+
const block = await this.aztecNode.getBlock(blockNumber);
|
|
236
|
+
if (!block?.header) {
|
|
237
|
+
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
238
|
+
}
|
|
239
|
+
return block.header;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Retrieve the public keys and partial address associated to a given address.
|
|
243
|
+
* @param account - The account address.
|
|
244
|
+
* @returns The public keys and partial address, or `undefined` if the account is not registered.
|
|
245
|
+
*/ async getPublicKeysAndPartialAddress(account) {
|
|
246
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
247
|
+
if (!completeAddress) {
|
|
248
|
+
return Option.none();
|
|
249
|
+
}
|
|
250
|
+
return Option.some({
|
|
251
|
+
publicKeys: completeAddress.publicKeys,
|
|
252
|
+
partialAddress: completeAddress.partialAddress
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async getCompleteAddressOrFail(account) {
|
|
256
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
257
|
+
if (!completeAddress) {
|
|
258
|
+
throw new Error(`No public key registered for address ${account}.
|
|
259
|
+
Register it by calling wallet.registerSender(...).\nSee docs for context: https://docs.aztec.network/errors/14`);
|
|
260
|
+
}
|
|
261
|
+
return completeAddress;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Returns a contract instance associated with an address or throws if not found.
|
|
265
|
+
* @param address - Address.
|
|
266
|
+
* @returns A contract instance.
|
|
267
|
+
*/ async getContractInstance(address) {
|
|
268
|
+
const instance = await this.anchoredContractData.getContractInstance(address);
|
|
269
|
+
if (!instance) {
|
|
270
|
+
throw new Error(`No contract instance found for address ${address.toString()}`);
|
|
271
|
+
}
|
|
272
|
+
return instance;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Returns an auth witness for the given message hash from the list of transient witnesses for this transaction.
|
|
276
|
+
* @param messageHash - Hash of the message to authenticate.
|
|
277
|
+
* @returns Authentication witness for the requested message hash, or undefined if not found.
|
|
278
|
+
*/ getAuthWitness(messageHash) {
|
|
279
|
+
const witness = this.authWitnesses.find((w)=>w.requestHash.equals(messageHash))?.witness;
|
|
280
|
+
if (!witness) {
|
|
281
|
+
throw new Error(`Unknown auth witness for message hash ${messageHash}`);
|
|
282
|
+
}
|
|
283
|
+
return Promise.resolve(witness);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Gets some notes for a contract address and storage slot.
|
|
287
|
+
* Returns a flattened array containing filtered notes.
|
|
288
|
+
*
|
|
289
|
+
* @remarks
|
|
290
|
+
* Check for pending notes with matching slot.
|
|
291
|
+
* Real notes coming from DB will have a leafIndex which
|
|
292
|
+
* represents their index in the note hash tree.
|
|
293
|
+
*
|
|
294
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all owners.
|
|
295
|
+
* @param storageSlot - The storage slot.
|
|
296
|
+
* @param numSelects - The number of valid selects in selectBy and selectValues.
|
|
297
|
+
* @param selectBy - An array of indices of the fields to selects.
|
|
298
|
+
* @param selectValues - The values to match.
|
|
299
|
+
* @param selectComparators - The comparators to use to match values.
|
|
300
|
+
* @param sortBy - An array of indices of the fields to sort.
|
|
301
|
+
* @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
|
|
302
|
+
* @param limit - The number of notes to retrieve per query.
|
|
303
|
+
* @param offset - The starting index for pagination.
|
|
304
|
+
* @param status - The status of notes to fetch.
|
|
305
|
+
* @returns Array of note data.
|
|
306
|
+
*/ async getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status, maxNotes, packedHintedNoteLength) {
|
|
307
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.changeSetId);
|
|
308
|
+
const dbNotes = await noteService.getNotes(this.contractAddress, owner.value, storageSlot, status, this.scopes);
|
|
309
|
+
const picked = pickNotes(dbNotes, {
|
|
310
|
+
selects: selectByIndexes.slice(0, numSelects).map((index, i)=>({
|
|
311
|
+
selector: {
|
|
312
|
+
index,
|
|
313
|
+
offset: selectByOffsets[i],
|
|
314
|
+
length: selectByLengths[i]
|
|
315
|
+
},
|
|
316
|
+
value: selectValues[i],
|
|
317
|
+
comparator: selectComparators[i]
|
|
318
|
+
})),
|
|
319
|
+
sorts: sortByIndexes.map((index, i)=>({
|
|
320
|
+
selector: {
|
|
321
|
+
index,
|
|
322
|
+
offset: sortByOffsets[i],
|
|
323
|
+
length: sortByLengths[i]
|
|
324
|
+
},
|
|
325
|
+
order: sortOrder[i]
|
|
326
|
+
})),
|
|
327
|
+
limit,
|
|
328
|
+
offset
|
|
329
|
+
});
|
|
330
|
+
return BoundedVec.from({
|
|
331
|
+
data: picked,
|
|
332
|
+
maxLength: maxNotes,
|
|
333
|
+
elementSize: packedHintedNoteLength
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Check if a nullifier exists in the nullifier tree.
|
|
338
|
+
* @param innerNullifier - The inner nullifier.
|
|
339
|
+
* @returns A boolean indicating whether the nullifier exists in the tree or not.
|
|
340
|
+
*/ async doesNullifierExist(innerNullifier) {
|
|
341
|
+
const [nullifier, anchorBlockHash] = await allToCompletion([
|
|
342
|
+
siloNullifier(this.contractAddress, innerNullifier),
|
|
343
|
+
this.anchorBlockHeader.hash()
|
|
344
|
+
]);
|
|
345
|
+
const [leafIndex] = await this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [
|
|
346
|
+
nullifier
|
|
347
|
+
]);
|
|
348
|
+
return leafIndex?.data !== undefined;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns the membership witness of an L1 to L2 message.
|
|
352
|
+
* @param messageHash - Hash of the message.
|
|
353
|
+
* @param nullifier - When present, the unsiloed nullifier of the message and the address to silo it with. The witness
|
|
354
|
+
* is only returned if the siloed nullifier is absent from the nullifier tree, i.e. the message has not been consumed.
|
|
355
|
+
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
356
|
+
*/ async getL1ToL2MembershipWitnessV2(messageHash, nullifier) {
|
|
357
|
+
const [messageIndex, siblingPath] = await getL1ToL2MessageWitness(this.aztecNode, messageHash, nullifier.value, await this.anchorBlockHeader.hash());
|
|
358
|
+
return new MembershipWitness(L1_TO_L2_MSG_TREE_HEIGHT, messageIndex, siblingPath.toTuple());
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Read the public storage data.
|
|
362
|
+
* @param blockHash - The block hash to read storage at.
|
|
363
|
+
* @param contractAddress - The address to read storage from.
|
|
364
|
+
* @param startStorageSlot - The starting storage slot.
|
|
365
|
+
* @param numberOfElements - Number of elements to read from the starting storage slot.
|
|
366
|
+
*/ getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements) {
|
|
367
|
+
return this.#queryWithBlockHashNotAfterAnchor(blockHash, async ()=>{
|
|
368
|
+
const slots = Array(numberOfElements).fill(0).map((_, i)=>new Fr(startStorageSlot.toBigInt() + BigInt(i)));
|
|
369
|
+
const values = await allToCompletion(slots.map((storageSlot)=>this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)));
|
|
370
|
+
this.logger.debug(`Oracle storage read: start=${startStorageSlot.toString()} count=${numberOfElements} ` + `address=${contractAddress.toString()} values=[${values.join(', ')}]`);
|
|
371
|
+
return values;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns a per-contract logger whose output is prefixed with `contract:<name>(<addrAbbrev>)`.
|
|
376
|
+
*/ async #getContractLogger() {
|
|
377
|
+
if (!this.contractLogger) {
|
|
378
|
+
// Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
|
|
379
|
+
// to re-use changeSetId as instanceId here as executions of different PXE operations are isolated.
|
|
380
|
+
this.contractLogger = await createContractLogger(this.contractAddress, (addr)=>this.anchoredContractData.getDebugContractName(addr), 'user', {
|
|
381
|
+
instanceId: this.changeSetId
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return this.contractLogger;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Returns a per-contract logger whose output is prefixed with `aztecnr:<name>(<addrAbbrev>)`.
|
|
388
|
+
*/ async #getAztecnrLogger() {
|
|
389
|
+
if (!this.aztecnrLogger) {
|
|
390
|
+
// Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
|
|
391
|
+
// to re-use changeSetId as instanceId here as executions of different PXE operations are isolated.
|
|
392
|
+
this.aztecnrLogger = await createContractLogger(this.contractAddress, (addr)=>this.anchoredContractData.getDebugContractName(addr), 'aztecnr', {
|
|
393
|
+
instanceId: this.changeSetId
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return this.aztecnrLogger;
|
|
397
|
+
}
|
|
398
|
+
async log(level, message, _fieldsSize, fields) {
|
|
399
|
+
if (!LogLevels[level]) {
|
|
400
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
401
|
+
}
|
|
402
|
+
const { kind, message: strippedMessage } = stripAztecnrLogPrefix(message);
|
|
403
|
+
const logger = kind == 'aztecnr' ? await this.#getAztecnrLogger() : await this.#getContractLogger();
|
|
404
|
+
logContractMessage(logger, LogLevels[level], strippedMessage, fields);
|
|
405
|
+
}
|
|
406
|
+
/** Fetches pending tagged logs into a freshly allocated ephemeral array and returns it. */ async getPendingTaggedLogsV2(scope, providedSecrets) {
|
|
407
|
+
const secrets = providedSecrets.readAll(this.ephemeralArrayService).map((ps)=>new AppTaggingSecret(ps.secret, this.contractAddress, ps.mode));
|
|
408
|
+
const logService = this.#createLogService();
|
|
409
|
+
const retrievedLogs = await logService.fetchTaggedLogs(this.contractAddress, scope, secrets);
|
|
410
|
+
this.#cacheValidationTxData(retrievedLogs);
|
|
411
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, retrievedLogs.map(toPendingTaggedLog));
|
|
412
|
+
}
|
|
413
|
+
#createLogService() {
|
|
414
|
+
return new LogService(this.aztecNode, this.anchorBlockHeader, this.l2TipsStore, this.keyStore, this.recipientTaggingStore, this.taggingSecretSourcesStore, this.addressStore, this.scopes, this.changeSetId, this.logger.getBindings());
|
|
415
|
+
}
|
|
416
|
+
async validateAndStoreEnqueuedNotesAndEvents(noteValidationRequests, eventValidationRequests, scope) {
|
|
417
|
+
await this.#processValidationRequests(noteValidationRequests.readAll(this.ephemeralArrayService), eventValidationRequests.readAll(this.ephemeralArrayService), scope);
|
|
418
|
+
}
|
|
419
|
+
async #processValidationRequests(noteValidationRequests, eventValidationRequests, scope) {
|
|
420
|
+
const validationTxData = await this.#getValidationTxData([
|
|
421
|
+
...noteValidationRequests.map((r)=>r.txHash),
|
|
422
|
+
...eventValidationRequests.map((r)=>r.txHash)
|
|
423
|
+
]);
|
|
424
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.changeSetId);
|
|
425
|
+
const eventService = new EventService(this.anchorBlockHeader, this.privateEventStore, this.changeSetId);
|
|
426
|
+
await allToCompletion([
|
|
427
|
+
noteService.validateAndStoreNotes(noteValidationRequests, scope, validationTxData),
|
|
428
|
+
eventService.validateAndStoreEvents(eventValidationRequests, scope, validationTxData)
|
|
429
|
+
]);
|
|
430
|
+
}
|
|
431
|
+
async getLogsByTagV2(requests) {
|
|
432
|
+
const logRetrievalRequests = requests.readAll(this.ephemeralArrayService);
|
|
433
|
+
const logService = this.#createLogService();
|
|
434
|
+
const retrievedLogsPerRequest = await logService.fetchLogsByTag(this.contractAddress, logRetrievalRequests);
|
|
435
|
+
this.#cacheValidationTxData(retrievedLogsPerRequest.flat());
|
|
436
|
+
// Create an inner ephemeral array for each request's matching logs, then wrap all slots in an outer array.
|
|
437
|
+
const innerArrays = retrievedLogsPerRequest.map((retrievedLogs)=>EphemeralArray.fromValues(this.ephemeralArrayService, retrievedLogs.map(toLogRetrievalResponse)));
|
|
438
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, innerArrays);
|
|
439
|
+
}
|
|
440
|
+
/** Given an array of tx hashes, returns an aligned array of tx info if the tx is available. */ async getResolvedTxs(requests) {
|
|
441
|
+
const txHashes = requests.readAll(this.ephemeralArrayService);
|
|
442
|
+
const resolved = await this.txResolver.resolveTxs(txHashes, this.anchorBlockHeader.getBlockNumber());
|
|
443
|
+
this.#cacheValidationTxData(resolved.filter((tx)=>tx !== null));
|
|
444
|
+
const options = resolved.map((tx)=>tx ? Option.some(toResolvedTx(tx)) : Option.none());
|
|
445
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, options);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Fetches the effects of a transaction by its hash. Returns null if the tx is not found or is beyond the anchor
|
|
449
|
+
* block.
|
|
450
|
+
*/ async getTxEffect(txHash) {
|
|
451
|
+
if (txHash.hash.isZero()) {
|
|
452
|
+
throw new Error('Invalid tx hash passed into aztec_utl_getTxEffect oracle handler');
|
|
453
|
+
}
|
|
454
|
+
return await this.#getTxEffectOption(txHash);
|
|
455
|
+
}
|
|
456
|
+
/** Fetches transaction effects for all hashes, preserving request order. */ async getTxEffects(txHashes) {
|
|
457
|
+
const hashes = txHashes.readAll(this.ephemeralArrayService);
|
|
458
|
+
const invalidHash = hashes.find((txHash)=>txHash.hash.isZero());
|
|
459
|
+
if (invalidHash) {
|
|
460
|
+
throw new Error('Invalid tx hash passed into aztec_utl_getTxEffects oracle handler');
|
|
461
|
+
}
|
|
462
|
+
const uniqueTxHashes = uniqueBy(hashes, (h)=>h.toString());
|
|
463
|
+
const options = await allToCompletion(uniqueTxHashes.map((txHash)=>this.#getTxEffectOption(txHash)));
|
|
464
|
+
const optionsByHash = new Map(uniqueTxHashes.map((txHash, i)=>[
|
|
465
|
+
txHash.toString(),
|
|
466
|
+
options[i]
|
|
467
|
+
]));
|
|
468
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, hashes.map((txHash)=>optionsByHash.get(txHash.toString())));
|
|
469
|
+
}
|
|
470
|
+
setCapsule(contractAddress, slot, capsule, scope) {
|
|
471
|
+
this.#assertOwnContract(contractAddress);
|
|
472
|
+
this.capsuleService.setCapsule(contractAddress, slot, capsule, this.changeSetId, scope);
|
|
473
|
+
}
|
|
474
|
+
async getCapsule(contractAddress, slot, tSize, scope) {
|
|
475
|
+
this.#assertOwnContract(contractAddress);
|
|
476
|
+
const values = await this.capsuleService.getCapsule(contractAddress, slot, this.changeSetId, scope, this.capsules);
|
|
477
|
+
return values ? Option.some(values) : Option.none({
|
|
478
|
+
length: tSize
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
deleteCapsule(contractAddress, slot, scope) {
|
|
482
|
+
this.#assertOwnContract(contractAddress);
|
|
483
|
+
this.capsuleService.deleteCapsule(contractAddress, slot, this.changeSetId, scope);
|
|
484
|
+
}
|
|
485
|
+
copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope) {
|
|
486
|
+
this.#assertOwnContract(contractAddress);
|
|
487
|
+
return this.capsuleService.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, this.changeSetId, scope);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Asserts the executing contract may only access its own slice of PXE DB.
|
|
491
|
+
*/ #assertOwnContract(contractAddress) {
|
|
492
|
+
if (!contractAddress.equals(this.contractAddress)) {
|
|
493
|
+
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Records a fact into a collection. A `Some` origin block makes the fact retractable (pruned on reorg of that
|
|
498
|
+
* block), a `None` origin block makes it non-retractable, surviving reorgs.
|
|
499
|
+
*/ recordFact(contractAddress, scope, factCollectionTypeId, factCollectionId, factTypeId, payload, originBlock) {
|
|
500
|
+
this.#assertOwnContract(contractAddress);
|
|
501
|
+
return this.factService.recordFact(new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId), factTypeId, payload.readAll(this.ephemeralArrayService), originBlock.isSome() ? originBlock.value : undefined, this.changeSetId);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Deletes a fact collection, removing all its facts. A no-op if no such collection exists.
|
|
505
|
+
*/ deleteFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId) {
|
|
506
|
+
this.#assertOwnContract(contractAddress);
|
|
507
|
+
return this.factService.deleteFactCollection(new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId), this.changeSetId);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Returns a fact collection.
|
|
511
|
+
*/ async getFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId) {
|
|
512
|
+
this.#assertOwnContract(contractAddress);
|
|
513
|
+
const tips = anchoredTipBlockNumbers(await this.l2TipsStore.getL2Tips(), this.anchorBlockHeader.getBlockNumber());
|
|
514
|
+
const collection = await this.factService.getFactCollection(new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId), tips, this.changeSetId);
|
|
515
|
+
return collection ? Option.some(toNoirFactCollection(this.ephemeralArrayService, contractAddress, scope, factCollectionTypeId, factCollectionId, collection.facts)) : Option.none(emptyFactCollection(this.ephemeralArrayService));
|
|
516
|
+
}
|
|
517
|
+
/** Returns every fact collection of `factCollectionTypeId`. */ async getFactCollectionsByType(contractAddress, scope, factCollectionTypeId) {
|
|
518
|
+
this.#assertOwnContract(contractAddress);
|
|
519
|
+
const tips = anchoredTipBlockNumbers(await this.l2TipsStore.getL2Tips(), this.anchorBlockHeader.getBlockNumber());
|
|
520
|
+
const collections = await this.factService.getFactCollectionsByType(new FactCollectionTypeKey(contractAddress, scope, factCollectionTypeId), tips, this.changeSetId);
|
|
521
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, collections.map((collection)=>toNoirFactCollection(this.ephemeralArrayService, collection.key.contractAddress, collection.key.scope, collection.key.factCollectionTypeId, collection.key.factCollectionId, collection.facts)));
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Clears cached sync state for a contract for a set of scopes, forcing re-sync on the next query so that newly
|
|
525
|
+
* stored notes or events are discovered.
|
|
526
|
+
*/ setContractSyncCacheInvalid(contractAddress, scopes) {
|
|
527
|
+
if (!contractAddress.equals(this.contractAddress)) {
|
|
528
|
+
throw new Error(`Contract ${this.contractAddress} cannot invalidate sync cache of ${contractAddress}`);
|
|
529
|
+
}
|
|
530
|
+
this.contractSyncService.invalidateContractForScopes(contractAddress, scopes.data);
|
|
531
|
+
}
|
|
532
|
+
// TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
|
|
533
|
+
async decryptAes128(ciphertext, iv, symKey) {
|
|
534
|
+
const capacity = ciphertext.maxLength;
|
|
535
|
+
try {
|
|
536
|
+
const aes128 = new Aes128();
|
|
537
|
+
const plaintext = await aes128.decryptBufferCBC(Buffer.from(ciphertext.data), Buffer.from(iv), Buffer.from(symKey));
|
|
538
|
+
return Option.some(BoundedVec.from({
|
|
539
|
+
data: [
|
|
540
|
+
...plaintext
|
|
541
|
+
],
|
|
542
|
+
maxLength: capacity
|
|
543
|
+
}));
|
|
544
|
+
} catch {
|
|
545
|
+
return Option.none({
|
|
546
|
+
maxLength: capacity
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Retrieves app-siloed shared secrets for multiple ephemeral public keys stored in an ephemeral array.
|
|
552
|
+
* @param address - The recipient address.
|
|
553
|
+
* @param ephPks - Ephemeral array containing the serialized Points.
|
|
554
|
+
* @param contractAddress - The contract address for app-siloing (validated against execution context).
|
|
555
|
+
* @returns A new ephemeral array containing the computed shared secrets, or an empty array when the PXE does not
|
|
556
|
+
* hold the keys for `address`.
|
|
557
|
+
* @throws If `address` is not in the execution's allowed scopes.
|
|
558
|
+
*/ async getSharedSecrets(address, ephPks, contractAddress) {
|
|
559
|
+
if (!contractAddress.equals(this.contractAddress)) {
|
|
560
|
+
throw new Error(`getSharedSecrets called with contract address ${contractAddress}, expected ${this.contractAddress}`);
|
|
561
|
+
}
|
|
562
|
+
assertAllowedScope(address, this.scopes);
|
|
563
|
+
// An address can be in scope without the PXE holding its keys (e.g. syncing a registered but non-owned account),
|
|
564
|
+
// in which case no secrets can be derived and we return an empty array rather than failing.
|
|
565
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(address);
|
|
566
|
+
if (!recipientCompleteAddress) {
|
|
567
|
+
this.logger.warn(`Computing shared secrets for address ${address} whose keys are not held - returning no secrets`, {
|
|
568
|
+
address,
|
|
569
|
+
contractAddress: this.contractAddress
|
|
570
|
+
});
|
|
571
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, []);
|
|
572
|
+
}
|
|
573
|
+
const ivpkMHash = await hashPublicKey(recipientCompleteAddress.publicKeys.ivpkM);
|
|
574
|
+
const ivskM = await this.keyStore.getMasterSecretKey(ivpkMHash);
|
|
575
|
+
const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
|
|
576
|
+
const ephPkPoints = ephPks.readAll(this.ephemeralArrayService);
|
|
577
|
+
const secrets = await allToCompletion(ephPkPoints.map(({ x, y })=>appSiloEcdhSharedSecret(addressSecret, new Point(x, y), this.contractAddress)));
|
|
578
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, secrets);
|
|
579
|
+
}
|
|
580
|
+
pushEphemeral(slot, elements) {
|
|
581
|
+
return this.ephemeralArrayService.push(slot, elements);
|
|
582
|
+
}
|
|
583
|
+
popEphemeral(slot) {
|
|
584
|
+
return this.ephemeralArrayService.pop(slot);
|
|
585
|
+
}
|
|
586
|
+
getEphemeral(slot, index) {
|
|
587
|
+
return this.ephemeralArrayService.get(slot, index);
|
|
588
|
+
}
|
|
589
|
+
setEphemeral(slot, index, elements) {
|
|
590
|
+
this.ephemeralArrayService.set(slot, index, elements);
|
|
591
|
+
}
|
|
592
|
+
getEphemeralLen(slot) {
|
|
593
|
+
return this.ephemeralArrayService.len(slot);
|
|
594
|
+
}
|
|
595
|
+
removeEphemeral(slot, index) {
|
|
596
|
+
this.ephemeralArrayService.remove(slot, index);
|
|
597
|
+
}
|
|
598
|
+
clearEphemeral(slot) {
|
|
599
|
+
this.ephemeralArrayService.clear(slot);
|
|
600
|
+
}
|
|
601
|
+
pushTransient(slot, elements) {
|
|
602
|
+
return this.transientArrayService.push(this.contractAddress, slot, elements);
|
|
603
|
+
}
|
|
604
|
+
popTransient(slot) {
|
|
605
|
+
return this.transientArrayService.pop(this.contractAddress, slot);
|
|
606
|
+
}
|
|
607
|
+
getTransient(slot, index) {
|
|
608
|
+
return this.transientArrayService.get(this.contractAddress, slot, index);
|
|
609
|
+
}
|
|
610
|
+
setTransient(slot, index, elements) {
|
|
611
|
+
this.transientArrayService.set(this.contractAddress, slot, index, elements);
|
|
612
|
+
}
|
|
613
|
+
getTransientLen(slot) {
|
|
614
|
+
return this.transientArrayService.len(this.contractAddress, slot);
|
|
615
|
+
}
|
|
616
|
+
removeTransient(slot, index) {
|
|
617
|
+
this.transientArrayService.remove(this.contractAddress, slot, index);
|
|
618
|
+
}
|
|
619
|
+
clearTransient(slot) {
|
|
620
|
+
this.transientArrayService.clear(this.contractAddress, slot);
|
|
621
|
+
}
|
|
622
|
+
emitOffchainEffect(data) {
|
|
623
|
+
this.offchainEffects.push({
|
|
624
|
+
data,
|
|
625
|
+
contractAddress: this.contractAddress
|
|
626
|
+
});
|
|
627
|
+
return Promise.resolve();
|
|
628
|
+
}
|
|
629
|
+
/** Executes another utility function from within this one and returns its serialized return values. */ async callUtilityFunction(targetContractAddress, functionSelector, args) {
|
|
630
|
+
const targetArtifact = await this.anchoredContractData.getFunctionArtifactWithDebugMetadata(targetContractAddress, functionSelector);
|
|
631
|
+
if (!targetArtifact) {
|
|
632
|
+
throw new Error(`Cannot call ${targetContractAddress}:${functionSelector}: the contract is not registered. ` + `Register it via wallet.registerContract(...).`);
|
|
633
|
+
}
|
|
634
|
+
if (!targetContractAddress.equals(this.contractAddress)) {
|
|
635
|
+
// Standard handshake registry reads are authorized by default; every other cross-contract call needs the hook.
|
|
636
|
+
if (!await isStandardHandshakeRegistryUtilityRead(targetContractAddress, functionSelector)) {
|
|
637
|
+
const [callerClassId, targetClassId] = await allToCompletion([
|
|
638
|
+
this.anchoredContractData.getCurrentClassId(this.contractAddress),
|
|
639
|
+
this.anchoredContractData.getCurrentClassId(targetContractAddress)
|
|
640
|
+
]);
|
|
641
|
+
if (!callerClassId || !targetClassId) {
|
|
642
|
+
throw new Error(`Cannot authorize utility call from ${this.contractAddress} to ${targetContractAddress}: ` + `${!callerClassId ? this.contractAddress : targetContractAddress} is not registered.`);
|
|
643
|
+
}
|
|
644
|
+
const request = {
|
|
645
|
+
caller: this.contractAddress,
|
|
646
|
+
callerClassId,
|
|
647
|
+
target: targetContractAddress,
|
|
648
|
+
targetClassId,
|
|
649
|
+
functionSelector,
|
|
650
|
+
functionName: targetArtifact.name,
|
|
651
|
+
args,
|
|
652
|
+
callerContext: this.callerContext
|
|
653
|
+
};
|
|
654
|
+
const response = this.hooks?.authorizeUtilityCall ? await this.hooks.authorizeUtilityCall(request) : {
|
|
655
|
+
authorized: false,
|
|
656
|
+
reason: 'No authorizeUtilityCall hook configured'
|
|
657
|
+
};
|
|
658
|
+
if (!response.authorized) {
|
|
659
|
+
const reason = response.reason ? `: ${response.reason}` : '';
|
|
660
|
+
throw new Error(`Cross-contract utility call denied${reason}. ${this.contractAddress} attempted to call ` + `${targetContractAddress}:${functionSelector} (${targetArtifact.name}). ` + `See https://docs.aztec.network/errors/11`);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
await this.contractSyncService.ensureContractSynced({
|
|
664
|
+
contract: targetContractAddress,
|
|
665
|
+
functionToInvokeAfterSync: functionSelector,
|
|
666
|
+
utilityExecutor: this.utilityExecutor,
|
|
667
|
+
anchorBlockHeader: this.anchorBlockHeader,
|
|
668
|
+
changeSetId: this.changeSetId,
|
|
669
|
+
scopes: this.scopes,
|
|
670
|
+
triggeredBy: {
|
|
671
|
+
address: this.contractAddress,
|
|
672
|
+
selector: this.callContext.functionSelector
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
this.logger.debug(`Calling nested utility function ${targetContractAddress}:${functionSelector} from ${this.contractAddress}`);
|
|
677
|
+
const nestedOracle = new UtilityExecutionOracle({
|
|
678
|
+
callContext: CallContext.from({
|
|
679
|
+
msgSender: this.contractAddress,
|
|
680
|
+
contractAddress: targetContractAddress,
|
|
681
|
+
functionSelector,
|
|
682
|
+
isStaticCall: true
|
|
683
|
+
}),
|
|
684
|
+
authWitnesses: this.authWitnesses,
|
|
685
|
+
capsules: this.capsules,
|
|
686
|
+
anchorBlockHeader: this.anchorBlockHeader,
|
|
687
|
+
anchoredContractData: this.anchoredContractData,
|
|
688
|
+
noteStore: this.noteStore,
|
|
689
|
+
keyStore: this.keyStore,
|
|
690
|
+
addressStore: this.addressStore,
|
|
691
|
+
aztecNode: this.aztecNode,
|
|
692
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
693
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
694
|
+
capsuleService: this.capsuleService,
|
|
695
|
+
factService: this.factService,
|
|
696
|
+
privateEventStore: this.privateEventStore,
|
|
697
|
+
txResolver: this.txResolver,
|
|
698
|
+
contractSyncService: this.contractSyncService,
|
|
699
|
+
l2TipsStore: this.l2TipsStore,
|
|
700
|
+
changeSetId: this.changeSetId,
|
|
701
|
+
scopes: this.scopes,
|
|
702
|
+
simulator: this.simulator,
|
|
703
|
+
hooks: this.hooks,
|
|
704
|
+
utilityExecutor: this.utilityExecutor,
|
|
705
|
+
log: this.logger,
|
|
706
|
+
// Shared across the whole execution tree: nested utility frames inherit the caller's transient-array store.
|
|
707
|
+
transientArrayService: this.transientArrayService
|
|
708
|
+
});
|
|
709
|
+
const initialWitness = toACVMWitness(0, args);
|
|
710
|
+
const acirExecutionResult = await this.simulator.executeUserCircuit(initialWitness, targetArtifact, buildACIRCallback(nestedOracle)).catch((err)=>{
|
|
711
|
+
err.message = resolveAssertionMessageFromError(err, targetArtifact);
|
|
712
|
+
throw new ExecutionError(err.message, {
|
|
713
|
+
contractAddress: targetContractAddress,
|
|
714
|
+
functionSelector
|
|
715
|
+
}, extractCallStack(err, targetArtifact.debug), {
|
|
716
|
+
cause: err
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
720
|
+
}
|
|
721
|
+
/** Returns offchain effects collected during execution. */ getOffchainEffects() {
|
|
722
|
+
return this.offchainEffects;
|
|
723
|
+
}
|
|
724
|
+
/** Stores the onchain context of the given txs, so that validating the notes and events they created is free. */ #cacheValidationTxData(txs) {
|
|
725
|
+
txs.forEach((tx)=>this.validationTxDataCache.set(tx.txHash.toString(), toValidationTxData(tx)));
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Returns the information needed to validate the notes and events created in the given txs, keyed by
|
|
729
|
+
* `TxHash.toString()`. Txs already in {@link validationTxDataCache} cost no node request, and the rest are read from
|
|
730
|
+
* the node. Txs with no tx effect are absent from the returned map.
|
|
731
|
+
*/ async #getValidationTxData(txHashes) {
|
|
732
|
+
const known = [];
|
|
733
|
+
const misses = [];
|
|
734
|
+
for (const txHash of uniqueBy(txHashes, (h)=>h.toString())){
|
|
735
|
+
const key = txHash.toString();
|
|
736
|
+
const cached = this.validationTxDataCache.get(key);
|
|
737
|
+
if (cached) {
|
|
738
|
+
known.push([
|
|
739
|
+
key,
|
|
740
|
+
cached
|
|
741
|
+
]);
|
|
742
|
+
} else {
|
|
743
|
+
misses.push(txHash);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const fetched = await allToCompletion(misses.map((h)=>this.#getTxReceiptWithEffect(h)));
|
|
747
|
+
return new Map([
|
|
748
|
+
...known,
|
|
749
|
+
...misses.map((h, i)=>{
|
|
750
|
+
const receipt = fetched[i];
|
|
751
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
752
|
+
return [
|
|
753
|
+
h.toString(),
|
|
754
|
+
undefined
|
|
755
|
+
];
|
|
756
|
+
}
|
|
757
|
+
return [
|
|
758
|
+
h.toString(),
|
|
759
|
+
{
|
|
760
|
+
noteHashes: receipt.txEffect.noteHashes,
|
|
761
|
+
nullifiers: receipt.txEffect.nullifiers,
|
|
762
|
+
l2BlockNumber: receipt.blockNumber,
|
|
763
|
+
l2BlockHash: receipt.blockHash,
|
|
764
|
+
txIndexInBlock: receipt.txIndexInBlock
|
|
765
|
+
}
|
|
766
|
+
];
|
|
767
|
+
}).filter((entry)=>entry[1] !== undefined)
|
|
768
|
+
]);
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Reads a receipt with its effect, at most once per tx for the lifetime of this execution.
|
|
772
|
+
*
|
|
773
|
+
* A receipt is not cacheable in general, since pending, mined and dropped are all correct answers to the same call
|
|
774
|
+
* over time. Within one execution it is: the execution is anchored at a fixed block, and validation runs in several
|
|
775
|
+
* batches that name overlapping tx hashes, so re-reading would both cost extra requests and let one execution see a
|
|
776
|
+
* tx as included in one batch and absent in the next.
|
|
777
|
+
*/ #getTxReceiptWithEffect(txHash) {
|
|
778
|
+
const key = txHash.toString();
|
|
779
|
+
let receipt = this.txReceiptsCache.get(key);
|
|
780
|
+
if (!receipt) {
|
|
781
|
+
receipt = this.aztecNode.getTxReceipt(txHash, {
|
|
782
|
+
includeTxEffect: true
|
|
783
|
+
}).catch((err)=>{
|
|
784
|
+
this.txReceiptsCache.delete(key);
|
|
785
|
+
throw err;
|
|
786
|
+
});
|
|
787
|
+
this.txReceiptsCache.set(key, receipt);
|
|
788
|
+
}
|
|
789
|
+
return receipt;
|
|
790
|
+
}
|
|
791
|
+
async #getTxEffectOption(txHash) {
|
|
792
|
+
const receipt = await this.#getTxReceiptWithEffect(txHash);
|
|
793
|
+
if (!receipt.isMined() || !receipt.txEffect || receipt.blockNumber > this.anchorBlockHeader.getBlockNumber()) {
|
|
794
|
+
return Option.none();
|
|
795
|
+
}
|
|
796
|
+
return Option.some(this.#toTxEffectData(receipt.txEffect));
|
|
797
|
+
}
|
|
798
|
+
#toTxEffectData(txEffect) {
|
|
799
|
+
return {
|
|
800
|
+
...txEffect,
|
|
801
|
+
revertCode: txEffect.revertCode.getCode(),
|
|
802
|
+
publicLogs: FlatPublicLogs.fromLogs(txEffect.publicLogs),
|
|
803
|
+
contractClassLogs: txEffect.contractClassLogs.map((log)=>({
|
|
804
|
+
contractAddress: log.contractAddress,
|
|
805
|
+
fields: log.fields.toFields(),
|
|
806
|
+
emittedLength: log.emittedLength
|
|
807
|
+
}))
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
/** Runs a query concurrently with a validation that the block hash is not ahead of the anchor block. */ async #queryWithBlockHashNotAfterAnchor(blockHash, query) {
|
|
811
|
+
// Most contracts query state at the "current" block, which is the anchor. Skip the validation when we can.
|
|
812
|
+
const anchorHash = await this.anchorBlockHeader.hash();
|
|
813
|
+
if (blockHash.equals(anchorHash)) {
|
|
814
|
+
return query();
|
|
815
|
+
}
|
|
816
|
+
const [response] = await allToCompletion([
|
|
817
|
+
query(),
|
|
818
|
+
(async ()=>{
|
|
819
|
+
const block = await this.aztecNode.getBlock(blockHash);
|
|
820
|
+
const header = block?.header;
|
|
821
|
+
if (!header) {
|
|
822
|
+
throw new Error(`Could not find block header for block hash ${blockHash}`);
|
|
823
|
+
}
|
|
824
|
+
if (header.getBlockNumber() > this.anchorBlockHeader.getBlockNumber()) {
|
|
825
|
+
throw new Error(`Made a node query with a reference block hash ${blockHash} with block number ${header.getBlockNumber()}, which is ahead of the anchor block number ${this.anchorBlockHeader.getBlockNumber()} (from anchor block hash ${anchorHash}).`);
|
|
826
|
+
}
|
|
827
|
+
})()
|
|
828
|
+
]);
|
|
829
|
+
return response;
|
|
830
|
+
}
|
|
831
|
+
/** The execution context of the current call. */ get callerContext() {
|
|
832
|
+
return 'utility';
|
|
833
|
+
}
|
|
834
|
+
/** The address of the contract whose function is being executed, from the call context. */ get contractAddress() {
|
|
835
|
+
return this.callContext.contractAddress;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
// Registry reads that any contract may issue without an `authorizeUtilityCall` hook. The constrained-delivery
|
|
839
|
+
// library calls these implicitly for the app, and they are safe to default-authorize: `get_app_siloed_secrets`
|
|
840
|
+
// siloes every returned secret to `msg_sender`, and `get_non_interactive_handshakes` only exposes ephemeral public
|
|
841
|
+
// keys, from which the shared secret cannot be derived without the recipient's secret keys.
|
|
842
|
+
const STANDARD_HANDSHAKE_REGISTRY_DEFAULT_AUTHORIZED_READ_SIGNATURES = [
|
|
843
|
+
'get_non_interactive_handshakes((Field),u32)',
|
|
844
|
+
'get_app_siloed_secrets((Field),(Field))'
|
|
845
|
+
];
|
|
846
|
+
async function doesSelectorHaveSignature(functionSelector, signature) {
|
|
847
|
+
return functionSelector.equals(await FunctionSelector.fromSignature(signature));
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Whether a cross-contract utility call targets one of the standard handshake registry's read functions.
|
|
851
|
+
*
|
|
852
|
+
* These reads are authorized by PXE for every wallet, without consulting the `authorizeUtilityCall` hook, so that
|
|
853
|
+
* wallets don't need to know the handshake registry exists in order to deliver and discover messages through it.
|
|
854
|
+
*/ async function isStandardHandshakeRegistryUtilityRead(targetContractAddress, functionSelector) {
|
|
855
|
+
if (!targetContractAddress.equals(STANDARD_HANDSHAKE_REGISTRY_ADDRESS)) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
const matches = await allToCompletion(STANDARD_HANDSHAKE_REGISTRY_DEFAULT_AUTHORIZED_READ_SIGNATURES.map((signature)=>doesSelectorHaveSignature(functionSelector, signature)));
|
|
859
|
+
return matches.some(Boolean);
|
|
860
|
+
}
|
|
861
|
+
function toPendingTaggedLog(retrievedLog) {
|
|
862
|
+
return {
|
|
863
|
+
log: retrievedLog.logData,
|
|
864
|
+
context: toResolvedTx(retrievedLog)
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function toResolvedTx(tx) {
|
|
868
|
+
const { txHash, blockNumber, blockHash, noteHashes, nullifiers } = tx;
|
|
869
|
+
return {
|
|
870
|
+
txHash,
|
|
871
|
+
uniqueNoteHashesInTx: noteHashes,
|
|
872
|
+
firstNullifierInTx: nullifiers[0],
|
|
873
|
+
blockNumber,
|
|
874
|
+
blockHash: blockHash.toFr()
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function toLogRetrievalResponse(retrievedLog) {
|
|
878
|
+
const { logData, txHash, blockNumber, blockHash, blockTimestamp, noteHashes, nullifiers } = retrievedLog;
|
|
879
|
+
return {
|
|
880
|
+
// Skip the tag, and clip to the wire cap: public logs can exceed PRIVATE_LOG_CIPHERTEXT_LEN, which is the fixed
|
|
881
|
+
// size of the oracle's BoundedVec slot. A no-op for private logs, which are already within the cap.
|
|
882
|
+
logPayload: logData.slice(1, 1 + PRIVATE_LOG_CIPHERTEXT_LEN),
|
|
883
|
+
txHash,
|
|
884
|
+
uniqueNoteHashesInTx: noteHashes,
|
|
885
|
+
firstNullifierInTx: nullifiers[0],
|
|
886
|
+
blockNumber,
|
|
887
|
+
blockTimestamp,
|
|
888
|
+
blockHash
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function toValidationTxData(tx) {
|
|
892
|
+
const { blockNumber, blockHash, txIndexInBlock, noteHashes, nullifiers } = tx;
|
|
893
|
+
return {
|
|
894
|
+
noteHashes,
|
|
895
|
+
nullifiers,
|
|
896
|
+
l2BlockNumber: blockNumber,
|
|
897
|
+
l2BlockHash: blockHash,
|
|
898
|
+
txIndexInBlock
|
|
899
|
+
};
|
|
900
|
+
}
|