@aztec/pxe 5.0.0-private.20260319 → 5.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +45 -111
- 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 +51 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +254 -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 +20 -14
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +78 -28
- package/dest/config/index.d.ts +8 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -19
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +57 -32
- 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 +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
- package/dest/contract_function_simulator/index.d.ts +24 -6
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -4
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +30 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +19 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +12 -24
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +5 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -61
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +8 -10
- package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +67 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -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 +33 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -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 +50 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +16 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/acir_callback.js +71 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -103
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +135 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +976 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +183 -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 +1222 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +3 -4
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -42
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +147 -59
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +143 -71
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +485 -187
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +35 -64
- package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/transient_array_service.js +62 -0
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +11 -9
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +73 -51
- package/dest/contract_sync/helpers.d.ts +8 -9
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +23 -30
- package/dest/debug/pxe_debug_utils.d.ts +3 -8
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +0 -6
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +18 -5
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +18 -5
- package/dest/entrypoints/pxe_creation_options.d.ts +16 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +4 -3
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +20 -6
- package/dest/error_enriching.js +1 -1
- package/dest/events/event_service.d.ts +15 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +44 -11
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +51 -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 +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -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 +12 -12
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +169 -81
- package/dest/messages/tx_resolver_service.d.ts +17 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/tx_resolver_service.js +55 -0
- package/dest/notes/note_service.d.ts +27 -6
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +80 -56
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +3 -4
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +152 -59
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -10
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +24 -22
- package/dest/pxe.d.ts +104 -27
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +229 -130
- package/dest/storage/allowed_scopes.d.ts +6 -0
- package/dest/storage/allowed_scopes.d.ts.map +1 -0
- package/dest/storage/allowed_scopes.js +7 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -6
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -7
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +647 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +47 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +36 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +11 -28
- package/dest/storage/fact_store/fact_service.d.ts +20 -0
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_service.js +30 -0
- package/dest/storage/fact_store/fact_store.d.ts +95 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +408 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store_keys.js +50 -0
- package/dest/storage/fact_store/index.d.ts +5 -0
- package/dest/storage/fact_store/index.d.ts.map +1 -0
- package/dest/storage/fact_store/index.js +3 -0
- package/dest/storage/fact_store/stored_fact.d.ts +32 -0
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
- package/dest/storage/fact_store/stored_fact.js +64 -0
- package/dest/storage/index.d.ts +3 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -1
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +42 -33
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +199 -170
- package/dest/storage/note_store/stored_note.d.ts +3 -8
- package/dest/storage/note_store/stored_note.d.ts.map +1 -1
- package/dest/storage/note_store/stored_note.js +4 -20
- package/dest/storage/open_pxe_stores.d.ts +35 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +29 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +43 -43
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/index.d.ts +2 -2
- package/dest/storage/tagging_store/index.d.ts.map +1 -1
- package/dest/storage/tagging_store/index.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +3 -3
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -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 +92 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +36 -37
- package/dest/tagging/index.d.ts +5 -4
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +69 -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 +203 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +2 -2
- package/package.json +20 -17
- package/src/bin/check_oracle_version.ts +51 -133
- package/src/bin/index.ts +5 -0
- package/src/bin/oracle_version_helpers.ts +311 -0
- package/src/block_synchronizer/block_stream_source.ts +42 -0
- package/src/block_synchronizer/block_synchronizer.ts +93 -38
- package/src/config/index.ts +15 -8
- package/src/contract_function_simulator/contract_function_simulator.ts +86 -48
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
- package/src/contract_function_simulator/index.ts +63 -5
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
- package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
- package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -7
- package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -20
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -61
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -8
- package/src/contract_function_simulator/noir-structs/option.ts +75 -0
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
- package/src/contract_function_simulator/oracle/acir_callback.ts +108 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -15
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -176
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +681 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +947 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +3 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +182 -79
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +743 -295
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +41 -64
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +101 -87
- package/src/contract_sync/helpers.ts +24 -43
- package/src/debug/pxe_debug_utils.ts +3 -11
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +17 -5
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +17 -5
- package/src/entrypoints/pxe_creation_options.ts +21 -1
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +24 -7
- package/src/error_enriching.ts +1 -1
- package/src/events/event_service.ts +69 -21
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +57 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
- package/src/logs/log_service.ts +204 -146
- package/src/messages/tx_resolver_service.ts +69 -0
- package/src/notes/note_service.ts +119 -85
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +1 -1
- package/src/private_kernel/hints/test_utils.ts +3 -10
- package/src/private_kernel/private_kernel_execution_prover.ts +240 -82
- package/src/private_kernel/private_kernel_oracle.ts +35 -25
- package/src/pxe.ts +369 -138
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -7
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -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 +769 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +85 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +16 -37
- package/src/storage/fact_store/fact_service.ts +45 -0
- package/src/storage/fact_store/fact_store.ts +487 -0
- package/src/storage/fact_store/fact_store_keys.ts +75 -0
- package/src/storage/fact_store/index.ts +4 -0
- package/src/storage/fact_store/stored_fact.ts +80 -0
- package/src/storage/index.ts +2 -1
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +228 -192
- package/src/storage/note_store/stored_note.ts +5 -27
- package/src/storage/open_pxe_stores.ts +52 -0
- package/src/storage/private_event_store/private_event_store.ts +52 -54
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
- package/src/storage/tagging_store/sender_tagging_store.ts +6 -6
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
- package/src/tagging/get_all_logs_by_tags.ts +78 -50
- package/src/tagging/index.ts +4 -3
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +301 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -5
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -61
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -437
- package/dest/messages/message_context_service.d.ts +0 -17
- package/dest/messages/message_context_service.d.ts.map +0 -1
- package/dest/messages/message_context_service.js +0 -36
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
- package/src/access_scopes.ts +0 -9
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -135
- package/src/contract_function_simulator/oracle/oracle.ts +0 -675
- package/src/messages/message_context_service.ts +0 -45
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -140
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
package/src/pxe.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
6
7
|
import { Timer } from '@aztec/foundation/timer';
|
|
7
8
|
import { KeyStore } from '@aztec/key-store';
|
|
8
9
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
|
-
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
10
10
|
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
11
11
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
12
12
|
import {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '@aztec/stdlib/abi';
|
|
19
19
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import { GENESIS_BLOCK_HEADER_HASH, type L2TipsProvider } from '@aztec/stdlib/block';
|
|
21
22
|
import {
|
|
22
23
|
CompleteAddress,
|
|
23
24
|
type ContractInstanceWithAddress,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
getContractClassFromArtifact,
|
|
27
28
|
} from '@aztec/stdlib/contract';
|
|
28
29
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
29
|
-
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
30
|
+
import type { AztecNode, AztecNodeDebug, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
30
31
|
import type {
|
|
31
32
|
PrivateExecutionStep,
|
|
32
33
|
PrivateKernelExecutionProofOutput,
|
|
@@ -52,7 +53,6 @@ import {
|
|
|
52
53
|
|
|
53
54
|
import { inspect } from 'util';
|
|
54
55
|
|
|
55
|
-
import type { AccessScopes } from './access_scopes.js';
|
|
56
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
57
57
|
import type { PXEConfig } from './config/index.js';
|
|
58
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -67,8 +67,9 @@ import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
|
67
67
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
68
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
69
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
70
|
+
import type { ExecutionHooks } from './hooks/index.js';
|
|
70
71
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
71
|
-
import {
|
|
72
|
+
import { TxResolverService } from './messages/tx_resolver_service.js';
|
|
72
73
|
import {
|
|
73
74
|
PrivateKernelExecutionProver,
|
|
74
75
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -78,17 +79,28 @@ import { AddressStore } from './storage/address_store/address_store.js';
|
|
|
78
79
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
79
80
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
80
81
|
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
82
|
+
import { FactStore } from './storage/fact_store/index.js';
|
|
81
83
|
import { NoteStore } from './storage/note_store/note_store.js';
|
|
84
|
+
import { openPxeStores } from './storage/open_pxe_stores.js';
|
|
82
85
|
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
83
86
|
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
84
|
-
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
85
87
|
import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
|
|
88
|
+
import { TaggingSecretSourcesStore } from './storage/tagging_store/tagging_secret_sources_store.js';
|
|
89
|
+
import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
86
90
|
|
|
87
91
|
export type PackedPrivateEvent = InTx & {
|
|
88
92
|
packedEvent: Fr[];
|
|
89
93
|
eventSelector: EventSelector;
|
|
90
94
|
};
|
|
91
95
|
|
|
96
|
+
/** Options for PXE.proveTx. */
|
|
97
|
+
export type ProveTxOpts = {
|
|
98
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
99
|
+
scopes: AztecAddress[];
|
|
100
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
101
|
+
senderForTags?: AztecAddress;
|
|
102
|
+
};
|
|
103
|
+
|
|
92
104
|
/** Options for PXE.profileTx. */
|
|
93
105
|
export type ProfileTxOpts = {
|
|
94
106
|
/** The profiling mode to use. */
|
|
@@ -96,7 +108,9 @@ export type ProfileTxOpts = {
|
|
|
96
108
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
97
109
|
skipProofGeneration?: boolean;
|
|
98
110
|
/** Addresses whose private state and keys are accessible during private execution. */
|
|
99
|
-
scopes:
|
|
111
|
+
scopes: AztecAddress[];
|
|
112
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
113
|
+
senderForTags?: AztecAddress;
|
|
100
114
|
};
|
|
101
115
|
|
|
102
116
|
/** Options for PXE.simulateTx. */
|
|
@@ -109,10 +123,16 @@ export type SimulateTxOpts = {
|
|
|
109
123
|
skipFeeEnforcement?: boolean;
|
|
110
124
|
/** If true, kernel logic is emulated in TS for simulation */
|
|
111
125
|
skipKernels?: boolean;
|
|
112
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Pre-simulation overrides applied to the ephemeral fork and contract DB. Bundles publicStorage
|
|
128
|
+
* writes (no skipKernels required) and per-address (instance, artifact?) overrides used by both
|
|
129
|
+
* AVM-side public dispatch and PXE-side ACIR private dispatch (requires skipKernels: true).
|
|
130
|
+
*/
|
|
113
131
|
overrides?: SimulationOverrides;
|
|
114
132
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
115
|
-
scopes:
|
|
133
|
+
scopes: AztecAddress[];
|
|
134
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
135
|
+
senderForTags?: AztecAddress;
|
|
116
136
|
};
|
|
117
137
|
|
|
118
138
|
/** Options for PXE.executeUtility. */
|
|
@@ -120,13 +140,33 @@ export type ExecuteUtilityOpts = {
|
|
|
120
140
|
/** The authentication witnesses required for the function call. */
|
|
121
141
|
authwits?: AuthWitness[];
|
|
122
142
|
/** The accounts whose notes we can access in this call */
|
|
123
|
-
scopes:
|
|
143
|
+
scopes: AztecAddress[];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Supplies the set of "nice to have" contracts that every PXE preloads regardless of which wallet
|
|
148
|
+
* drives it. Today this is just the standard multi-call entrypoint: the SDK's self-paid account
|
|
149
|
+
* deploy flow ({@link DeployAccountMethod} with `from = NO_FROM`) routes its payload through it, so a
|
|
150
|
+
* PXE that did not register it would fail contract sync with an opaque "no contract instance" error.
|
|
151
|
+
*
|
|
152
|
+
* Returning a list keeps this extensible: a wallet may supply its own provider that preloads
|
|
153
|
+
* additional contracts. Injected the same way as {@link ProtocolContractsProvider} so the PXE never
|
|
154
|
+
* statically imports the bundled artifacts, keeping the bundle/lazy split intact.
|
|
155
|
+
*/
|
|
156
|
+
export type PreloadedContractsProvider = {
|
|
157
|
+
/** Returns the contract instances and artifacts the PXE should preload on startup. */
|
|
158
|
+
getPreloadedContracts: () => Promise<Array<{ instance: ContractInstanceWithAddress; artifact: ContractArtifact }>>;
|
|
124
159
|
};
|
|
125
160
|
|
|
126
161
|
/** Args for PXE.create. */
|
|
127
162
|
export type PXECreateArgs = {
|
|
128
163
|
/** The Aztec node to connect to. */
|
|
129
164
|
node: AztecNode;
|
|
165
|
+
/**
|
|
166
|
+
* Optional debug API client. When provided, public function signatures are registered with the node so that
|
|
167
|
+
* node-side public-execution stack traces can be named. Skipped when the node does not expose the debug API.
|
|
168
|
+
*/
|
|
169
|
+
nodeDebug?: AztecNodeDebug;
|
|
130
170
|
/** The key-value store for persisting PXE state. */
|
|
131
171
|
store: AztecAsyncKVStore;
|
|
132
172
|
/** The prover for generating private kernel proofs. */
|
|
@@ -135,12 +175,33 @@ export type PXECreateArgs = {
|
|
|
135
175
|
simulator: CircuitSimulator;
|
|
136
176
|
/** Provider for protocol contract artifacts and instances. */
|
|
137
177
|
protocolContractsProvider: ProtocolContractsProvider;
|
|
178
|
+
/**
|
|
179
|
+
* Contracts to preload on startup. Injected by the entrypoint with the bundle-or-lazy flavor that
|
|
180
|
+
* matches the runtime (bundle for node/eager browser, lazy for code-split browser), so the PXE
|
|
181
|
+
* never statically imports a standard-contract artifact and the bundle/lazy split stays intact.
|
|
182
|
+
*/
|
|
183
|
+
preloadedContractsProvider: PreloadedContractsProvider;
|
|
138
184
|
/** PXE configuration options. */
|
|
139
185
|
config: PXEConfig;
|
|
140
186
|
/** Optional logger instance or string suffix for the logger name. */
|
|
141
187
|
loggerOrSuffix?: string | Logger;
|
|
188
|
+
/** Optional hooks to observe and influence contract execution. */
|
|
189
|
+
hooks?: ExecutionHooks;
|
|
142
190
|
};
|
|
143
191
|
|
|
192
|
+
/**
|
|
193
|
+
* A source from which PXE derives the tagging secrets it scans for to discover incoming private logs.
|
|
194
|
+
*
|
|
195
|
+
* - `address-derived`: derives a shared secret via ECDH from an external `sender` address against every account
|
|
196
|
+
* registered in this PXE (present and future), so registering one sender applies it to all of them. The address is
|
|
197
|
+
* not secret, so unlike `arbitrary-secret` it can be reused freely across recipients.
|
|
198
|
+
* - `arbitrary-secret`: a shared secret point provided directly, scoped to a single recipient. It bypasses ECDH, so it
|
|
199
|
+
* must not be reused across recipients (each would then be able to find the others' tags).
|
|
200
|
+
*/
|
|
201
|
+
export type TaggingSecretSource =
|
|
202
|
+
| { kind: 'address-derived'; sender: AztecAddress }
|
|
203
|
+
| { kind: 'arbitrary-secret'; recipient: AztecAddress; secret: Point };
|
|
204
|
+
|
|
144
205
|
/**
|
|
145
206
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
146
207
|
* manage private state of users.
|
|
@@ -148,28 +209,34 @@ export type PXECreateArgs = {
|
|
|
148
209
|
export class PXE {
|
|
149
210
|
private constructor(
|
|
150
211
|
private node: AztecNode,
|
|
212
|
+
private nodeDebug: AztecNodeDebug | undefined,
|
|
151
213
|
private db: AztecAsyncKVStore,
|
|
152
214
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
153
215
|
private keyStore: KeyStore,
|
|
154
216
|
private contractStore: ContractStore,
|
|
155
217
|
private noteStore: NoteStore,
|
|
156
218
|
private capsuleStore: CapsuleStore,
|
|
219
|
+
private factStore: FactStore,
|
|
157
220
|
private anchorBlockStore: AnchorBlockStore,
|
|
158
221
|
private senderTaggingStore: SenderTaggingStore,
|
|
159
|
-
private
|
|
222
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
160
223
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
161
224
|
private addressStore: AddressStore,
|
|
162
225
|
private privateEventStore: PrivateEventStore,
|
|
163
226
|
private contractSyncService: ContractSyncService,
|
|
164
|
-
private
|
|
227
|
+
private txResolver: TxResolverService,
|
|
228
|
+
private l2TipsStore: L2TipsProvider,
|
|
165
229
|
private simulator: CircuitSimulator,
|
|
166
230
|
private proverEnabled: boolean,
|
|
231
|
+
private autoSync: boolean,
|
|
167
232
|
private proofCreator: PrivateKernelProver,
|
|
168
233
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
234
|
+
private preloadedContractsProvider: PreloadedContractsProvider,
|
|
169
235
|
private log: Logger,
|
|
170
236
|
private jobQueue: SerialQueue,
|
|
171
237
|
private jobCoordinator: JobCoordinator,
|
|
172
238
|
public debug: PXEDebugUtils,
|
|
239
|
+
private hooks: ExecutionHooks | undefined,
|
|
173
240
|
) {}
|
|
174
241
|
|
|
175
242
|
/**
|
|
@@ -181,12 +248,15 @@ export class PXE {
|
|
|
181
248
|
*/
|
|
182
249
|
public static async create({
|
|
183
250
|
node,
|
|
251
|
+
nodeDebug,
|
|
184
252
|
store,
|
|
185
253
|
proofCreator,
|
|
186
254
|
simulator,
|
|
187
255
|
protocolContractsProvider,
|
|
256
|
+
preloadedContractsProvider,
|
|
188
257
|
config,
|
|
189
258
|
loggerOrSuffix,
|
|
259
|
+
hooks,
|
|
190
260
|
}: PXECreateArgs) {
|
|
191
261
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
192
262
|
const bindings: LoggerBindings | undefined =
|
|
@@ -199,25 +269,36 @@ export class PXE {
|
|
|
199
269
|
|
|
200
270
|
const info = await node.getNodeInfo();
|
|
201
271
|
|
|
272
|
+
// Source the genesis block hash from the node so PXE's L2BlockStream agrees with the node's
|
|
273
|
+
// archiver on the dynamic initial header hash. Without this the tip store would fall back to
|
|
274
|
+
// the static `GENESIS_BLOCK_HEADER_HASH` constant, which only matches deployments with the
|
|
275
|
+
// default empty genesis (timestamp 0, no prefilled public data) and diverges otherwise — the
|
|
276
|
+
// sync at block 0 would then get stuck in `areBlockHashesEqualAt` and abort. If the node does
|
|
277
|
+
// not return a genesis block (older node or test fixture) we fall back to the static constant.
|
|
278
|
+
const initialBlockHash = (await node.getBlock(BlockNumber.ZERO))?.hash ?? GENESIS_BLOCK_HEADER_HASH;
|
|
279
|
+
|
|
202
280
|
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
281
|
+
const {
|
|
282
|
+
addressStore,
|
|
283
|
+
privateEventStore,
|
|
284
|
+
contractStore,
|
|
285
|
+
noteStore,
|
|
286
|
+
anchorBlockStore,
|
|
287
|
+
senderTaggingStore,
|
|
288
|
+
taggingSecretSourcesStore,
|
|
289
|
+
recipientTaggingStore,
|
|
290
|
+
capsuleStore,
|
|
291
|
+
keyStore,
|
|
292
|
+
l2TipsStore,
|
|
293
|
+
factStore,
|
|
294
|
+
} = openPxeStores(store, initialBlockHash);
|
|
214
295
|
const contractSyncService = new ContractSyncService(
|
|
215
296
|
node,
|
|
216
297
|
contractStore,
|
|
217
298
|
noteStore,
|
|
218
299
|
createLogger('pxe:contract_sync', bindings),
|
|
219
300
|
);
|
|
220
|
-
const
|
|
301
|
+
const txResolver = new TxResolverService(node);
|
|
221
302
|
|
|
222
303
|
const synchronizer = new BlockSynchronizer(
|
|
223
304
|
node,
|
|
@@ -225,7 +306,8 @@ export class PXE {
|
|
|
225
306
|
anchorBlockStore,
|
|
226
307
|
noteStore,
|
|
227
308
|
privateEventStore,
|
|
228
|
-
|
|
309
|
+
factStore,
|
|
310
|
+
l2TipsStore,
|
|
229
311
|
contractSyncService,
|
|
230
312
|
config,
|
|
231
313
|
bindings,
|
|
@@ -238,6 +320,7 @@ export class PXE {
|
|
|
238
320
|
recipientTaggingStore,
|
|
239
321
|
privateEventStore,
|
|
240
322
|
noteStore,
|
|
323
|
+
factStore,
|
|
241
324
|
contractSyncService,
|
|
242
325
|
]);
|
|
243
326
|
|
|
@@ -247,28 +330,34 @@ export class PXE {
|
|
|
247
330
|
|
|
248
331
|
const pxe = new PXE(
|
|
249
332
|
node,
|
|
333
|
+
nodeDebug,
|
|
250
334
|
store,
|
|
251
335
|
synchronizer,
|
|
252
336
|
keyStore,
|
|
253
337
|
contractStore,
|
|
254
338
|
noteStore,
|
|
255
339
|
capsuleStore,
|
|
340
|
+
factStore,
|
|
256
341
|
anchorBlockStore,
|
|
257
342
|
senderTaggingStore,
|
|
258
|
-
|
|
343
|
+
taggingSecretSourcesStore,
|
|
259
344
|
recipientTaggingStore,
|
|
260
345
|
addressStore,
|
|
261
346
|
privateEventStore,
|
|
262
347
|
contractSyncService,
|
|
263
|
-
|
|
348
|
+
txResolver,
|
|
349
|
+
l2TipsStore,
|
|
264
350
|
simulator,
|
|
265
351
|
proverEnabled,
|
|
352
|
+
config.autoSync,
|
|
266
353
|
proofCreator,
|
|
267
354
|
protocolContractsProvider,
|
|
355
|
+
preloadedContractsProvider,
|
|
268
356
|
log,
|
|
269
357
|
jobQueue,
|
|
270
358
|
jobCoordinator,
|
|
271
359
|
debugUtils,
|
|
360
|
+
hooks,
|
|
272
361
|
);
|
|
273
362
|
|
|
274
363
|
debugUtils.setPXEHelpers(
|
|
@@ -279,7 +368,7 @@ export class PXE {
|
|
|
279
368
|
|
|
280
369
|
pxe.jobQueue.start();
|
|
281
370
|
|
|
282
|
-
await pxe.#registerProtocolContracts();
|
|
371
|
+
await Promise.all([pxe.#registerProtocolContracts(), pxe.#registerPreloadedContracts()]);
|
|
283
372
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
284
373
|
return pxe;
|
|
285
374
|
}
|
|
@@ -295,14 +384,17 @@ export class PXE {
|
|
|
295
384
|
keyStore: this.keyStore,
|
|
296
385
|
addressStore: this.addressStore,
|
|
297
386
|
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
387
|
+
l2TipsStore: this.l2TipsStore,
|
|
298
388
|
senderTaggingStore: this.senderTaggingStore,
|
|
299
389
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
300
|
-
|
|
390
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
301
391
|
capsuleStore: this.capsuleStore,
|
|
392
|
+
factStore: this.factStore,
|
|
302
393
|
privateEventStore: this.privateEventStore,
|
|
303
394
|
simulator: this.simulator,
|
|
304
395
|
contractSyncService: this.contractSyncService,
|
|
305
|
-
|
|
396
|
+
txResolver: this.txResolver,
|
|
397
|
+
hooks: this.hooks,
|
|
306
398
|
});
|
|
307
399
|
}
|
|
308
400
|
|
|
@@ -353,29 +445,48 @@ export class PXE {
|
|
|
353
445
|
}
|
|
354
446
|
|
|
355
447
|
async #registerProtocolContracts() {
|
|
356
|
-
const registered
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
448
|
+
const registered = Object.fromEntries(
|
|
449
|
+
await Promise.all(
|
|
450
|
+
protocolContractNames.map(async name => {
|
|
451
|
+
const { address, instance, artifact } =
|
|
452
|
+
await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
453
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
454
|
+
await this.contractStore.addContractInstance(instance);
|
|
455
|
+
return [name, address.toString()] as const;
|
|
456
|
+
}),
|
|
457
|
+
),
|
|
458
|
+
);
|
|
363
459
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
364
460
|
}
|
|
365
461
|
|
|
462
|
+
async #registerPreloadedContracts() {
|
|
463
|
+
const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
|
|
464
|
+
await Promise.all(contracts.map(({ instance, artifact }) => this.registerContract({ instance, artifact })));
|
|
465
|
+
this.log.verbose(`Registered preloaded contracts in pxe`, {
|
|
466
|
+
contracts: contracts.map(({ instance }) => instance.address.toString()),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
366
470
|
// Executes the entrypoint private function, as well as all nested private
|
|
367
471
|
// functions that might arise.
|
|
368
|
-
async #executePrivate(
|
|
369
|
-
contractFunctionSimulator
|
|
370
|
-
txRequest
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
472
|
+
async #executePrivate({
|
|
473
|
+
contractFunctionSimulator,
|
|
474
|
+
txRequest,
|
|
475
|
+
anchorBlockHeader,
|
|
476
|
+
scopes,
|
|
477
|
+
jobId,
|
|
478
|
+
senderForTags,
|
|
479
|
+
}: {
|
|
480
|
+
contractFunctionSimulator: ContractFunctionSimulator;
|
|
481
|
+
txRequest: TxExecutionRequest;
|
|
482
|
+
anchorBlockHeader: BlockHeader;
|
|
483
|
+
scopes: AztecAddress[];
|
|
484
|
+
jobId: string;
|
|
485
|
+
senderForTags?: AztecAddress;
|
|
486
|
+
}): Promise<PrivateExecutionResult> {
|
|
374
487
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
375
488
|
|
|
376
489
|
try {
|
|
377
|
-
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
378
|
-
|
|
379
490
|
await this.contractSyncService.ensureContractSynced(
|
|
380
491
|
contractAddress,
|
|
381
492
|
functionSelector,
|
|
@@ -387,11 +498,10 @@ export class PXE {
|
|
|
387
498
|
);
|
|
388
499
|
|
|
389
500
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
390
|
-
contractAddress,
|
|
391
|
-
selector: functionSelector,
|
|
392
501
|
anchorBlockHeader,
|
|
393
502
|
scopes,
|
|
394
503
|
jobId,
|
|
504
|
+
senderForTags,
|
|
395
505
|
});
|
|
396
506
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
397
507
|
return result;
|
|
@@ -417,7 +527,7 @@ export class PXE {
|
|
|
417
527
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
418
528
|
call: FunctionCall,
|
|
419
529
|
authWitnesses: AuthWitness[] | undefined,
|
|
420
|
-
scopes:
|
|
530
|
+
scopes: AztecAddress[],
|
|
421
531
|
jobId: string,
|
|
422
532
|
) {
|
|
423
533
|
try {
|
|
@@ -444,11 +554,11 @@ export class PXE {
|
|
|
444
554
|
* It can also be used for estimating gas in the future.
|
|
445
555
|
* @param tx - The transaction to be simulated.
|
|
446
556
|
*/
|
|
447
|
-
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean) {
|
|
557
|
+
async #simulatePublicCalls(tx: Tx, skipFeeEnforcement: boolean, overrides?: SimulationOverrides) {
|
|
448
558
|
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
449
559
|
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
450
560
|
try {
|
|
451
|
-
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
|
|
561
|
+
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement, overrides);
|
|
452
562
|
if (result.revertReason) {
|
|
453
563
|
throw result.revertReason;
|
|
454
564
|
}
|
|
@@ -480,11 +590,10 @@ export class PXE {
|
|
|
480
590
|
txExecutionRequest: TxExecutionRequest,
|
|
481
591
|
proofCreator: PrivateKernelProver,
|
|
482
592
|
privateExecutionResult: PrivateExecutionResult,
|
|
593
|
+
anchorBlockHeader: BlockHeader,
|
|
483
594
|
config: PrivateKernelExecutionProverConfig,
|
|
484
595
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
485
|
-
const
|
|
486
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
487
|
-
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
596
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
488
597
|
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
489
598
|
kernelOracle,
|
|
490
599
|
proofCreator,
|
|
@@ -495,14 +604,36 @@ export class PXE {
|
|
|
495
604
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
496
605
|
}
|
|
497
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Syncs with the node only when `autoSync` is enabled.
|
|
609
|
+
* When `autoSync` is disabled, callers (typically a wallet) are
|
|
610
|
+
* responsible for invoking `pxe.sync()` at the right granularity.
|
|
611
|
+
*/
|
|
612
|
+
async #maybeSync(): Promise<void> {
|
|
613
|
+
if (this.autoSync) {
|
|
614
|
+
await this.blockStateSynchronizer.sync();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
498
618
|
// Public API
|
|
499
619
|
|
|
620
|
+
/**
|
|
621
|
+
* Triggers a sync of PXE state with the node, regardless of the `autoSync` config flag. Use this to
|
|
622
|
+
* batch syncs across composite flows when `autoSync` is disabled (e.g. one sync per simulate+send
|
|
623
|
+
* instead of one per inner PXE call). Serialized through the job queue.
|
|
624
|
+
*/
|
|
625
|
+
public sync(): Promise<void> {
|
|
626
|
+
return this.#putInJobQueue(() => this.blockStateSynchronizer.sync());
|
|
627
|
+
}
|
|
628
|
+
|
|
500
629
|
/**
|
|
501
630
|
* Returns the block header up to which the PXE has synced.
|
|
502
631
|
* @returns The synced block header
|
|
503
632
|
*/
|
|
504
633
|
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
505
|
-
return this
|
|
634
|
+
return this.#putInJobQueue(() => {
|
|
635
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
636
|
+
});
|
|
506
637
|
}
|
|
507
638
|
|
|
508
639
|
/**
|
|
@@ -536,7 +667,7 @@ export class PXE {
|
|
|
536
667
|
public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
537
668
|
const accounts = await this.keyStore.getAccounts();
|
|
538
669
|
const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
|
|
539
|
-
if (accounts.
|
|
670
|
+
if (accounts.some(a => a.equals(accountCompleteAddress.address))) {
|
|
540
671
|
this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
|
|
541
672
|
return accountCompleteAddress;
|
|
542
673
|
} else {
|
|
@@ -549,56 +680,131 @@ export class PXE {
|
|
|
549
680
|
}
|
|
550
681
|
|
|
551
682
|
/**
|
|
552
|
-
* Registers a
|
|
553
|
-
*
|
|
554
|
-
* After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
|
|
555
|
-
* Will do nothing if the address is already registered.
|
|
683
|
+
* Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
|
|
684
|
+
* See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
|
|
556
685
|
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
686
|
+
* After a new source is added we clear the cache tracking which contracts have finished syncing, so every contract
|
|
687
|
+
* re-syncs against the new source's logs (whose notes/events could belong to any contract). Already-discovered
|
|
688
|
+
* notes/events are not discarded.
|
|
560
689
|
*/
|
|
561
|
-
public async
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
690
|
+
public async registerTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
|
|
691
|
+
let wasAdded: boolean;
|
|
692
|
+
|
|
693
|
+
switch (source.kind) {
|
|
694
|
+
case 'address-derived':
|
|
695
|
+
wasAdded = await this.#registerSender(source.sender);
|
|
696
|
+
break;
|
|
697
|
+
case 'arbitrary-secret':
|
|
698
|
+
wasAdded = await this.#registerArbitrarySecret(source.recipient, source.secret);
|
|
699
|
+
break;
|
|
700
|
+
default: {
|
|
701
|
+
const _: never = source;
|
|
702
|
+
throw new Error('Unhandled tagging secret source kind');
|
|
703
|
+
}
|
|
566
704
|
}
|
|
567
705
|
|
|
568
|
-
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
569
|
-
|
|
570
706
|
if (wasAdded) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
// all contracts must re-sync to discover them.
|
|
574
|
-
this.contractSyncService.wipe();
|
|
575
|
-
} else {
|
|
576
|
-
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
707
|
+
// Queued to avoid wiping while a job is in flight.
|
|
708
|
+
await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
|
|
577
709
|
}
|
|
578
|
-
|
|
579
|
-
return sender;
|
|
580
710
|
}
|
|
581
711
|
|
|
582
712
|
/**
|
|
583
|
-
*
|
|
584
|
-
* @returns Senders registered in this PXE.
|
|
713
|
+
* Removes a previously registered tagging secret source. Does nothing if it was not registered.
|
|
585
714
|
*/
|
|
586
|
-
public
|
|
587
|
-
|
|
715
|
+
public async removeTaggingSecretSource(source: TaggingSecretSource): Promise<void> {
|
|
716
|
+
switch (source.kind) {
|
|
717
|
+
case 'address-derived': {
|
|
718
|
+
const { sender } = source;
|
|
719
|
+
const wasRemoved = await this.taggingSecretSourcesStore.removeSender(sender);
|
|
720
|
+
this.log.info(
|
|
721
|
+
wasRemoved
|
|
722
|
+
? `Removed sender:\n ${sender.toString()}`
|
|
723
|
+
: `Sender:\n "${sender.toString()}"\n not registered in PXE.`,
|
|
724
|
+
);
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
case 'arbitrary-secret': {
|
|
728
|
+
const { recipient, secret } = source;
|
|
729
|
+
const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, secret);
|
|
730
|
+
this.log.info(
|
|
731
|
+
wasRemoved
|
|
732
|
+
? `Removed shared secret for recipient:\n ${recipient.toString()}`
|
|
733
|
+
: `Shared secret not registered for recipient:\n ${recipient.toString()}`,
|
|
734
|
+
);
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
default: {
|
|
738
|
+
const _: never = source;
|
|
739
|
+
throw new Error('Unhandled tagging secret source kind');
|
|
740
|
+
}
|
|
741
|
+
}
|
|
588
742
|
}
|
|
589
743
|
|
|
590
744
|
/**
|
|
591
|
-
*
|
|
592
|
-
*
|
|
745
|
+
* Retrieves the tagging secret sources registered in this PXE. Without a filter it returns every source; pass
|
|
746
|
+
* `{ kind }` to narrow to a single variant. See {@link TaggingSecretSource}.
|
|
593
747
|
*/
|
|
594
|
-
public
|
|
595
|
-
|
|
748
|
+
public getTaggingSecretSources<K extends TaggingSecretSource['kind']>(filter: {
|
|
749
|
+
kind: K;
|
|
750
|
+
}): Promise<Extract<TaggingSecretSource, { kind: K }>[]>;
|
|
751
|
+
public getTaggingSecretSources(): Promise<TaggingSecretSource[]>;
|
|
752
|
+
public async getTaggingSecretSources(filter?: {
|
|
753
|
+
kind?: TaggingSecretSource['kind'];
|
|
754
|
+
}): Promise<TaggingSecretSource[]> {
|
|
755
|
+
const [senders, secrets] = await Promise.all([
|
|
756
|
+
this.taggingSecretSourcesStore.getSenders(),
|
|
757
|
+
this.taggingSecretSourcesStore.getAllSharedSecrets(),
|
|
758
|
+
]);
|
|
596
759
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
760
|
+
const sources: TaggingSecretSource[] = [
|
|
761
|
+
...senders.map((sender): TaggingSecretSource => ({ kind: 'address-derived', sender })),
|
|
762
|
+
...secrets.map(({ recipient, secret }): TaggingSecretSource => ({ kind: 'arbitrary-secret', recipient, secret })),
|
|
763
|
+
];
|
|
764
|
+
|
|
765
|
+
return filter?.kind ? sources.filter(source => source.kind === filter.kind) : sources;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** Registers a sender, skipping addresses that belong to a local account. Returns whether it was newly added. */
|
|
769
|
+
async #registerSender(address: AztecAddress): Promise<boolean> {
|
|
770
|
+
if (!(await address.isValid())) {
|
|
771
|
+
throw new Error(
|
|
772
|
+
`Address ${address} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const accounts = await this.keyStore.getAccounts();
|
|
777
|
+
if (accounts.some(a => a.equals(address))) {
|
|
778
|
+
this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const wasAdded = await this.taggingSecretSourcesStore.addSender(address);
|
|
783
|
+
this.log.info(
|
|
784
|
+
wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`,
|
|
785
|
+
);
|
|
786
|
+
return wasAdded;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/** Registers a directly-provided shared secret scoped to a recipient. Returns whether it was newly added. */
|
|
790
|
+
async #registerArbitrarySecret(recipient: AztecAddress, secret: Point): Promise<boolean> {
|
|
791
|
+
if (!(await recipient.isValid())) {
|
|
792
|
+
throw new Error(
|
|
793
|
+
`Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`,
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (secret.isZero() || !secret.isOnCurve()) {
|
|
798
|
+
throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
|
|
601
799
|
}
|
|
800
|
+
|
|
801
|
+
const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, secret);
|
|
802
|
+
this.log.info(
|
|
803
|
+
wasAdded
|
|
804
|
+
? `Added shared secret for recipient:\n ${recipient.toString()}`
|
|
805
|
+
: `Shared secret already registered for recipient:\n ${recipient.toString()}`,
|
|
806
|
+
);
|
|
807
|
+
return wasAdded;
|
|
602
808
|
}
|
|
603
809
|
|
|
604
810
|
/**
|
|
@@ -655,7 +861,9 @@ export class PXE {
|
|
|
655
861
|
const publicFunctionSignatures = artifact.functions
|
|
656
862
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
657
863
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
658
|
-
|
|
864
|
+
if (publicFunctionSignatures.length > 0) {
|
|
865
|
+
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
866
|
+
}
|
|
659
867
|
} else {
|
|
660
868
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
661
869
|
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
@@ -690,7 +898,7 @@ export class PXE {
|
|
|
690
898
|
throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
|
|
691
899
|
}
|
|
692
900
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
693
|
-
await this
|
|
901
|
+
await this.#maybeSync();
|
|
694
902
|
|
|
695
903
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
696
904
|
|
|
@@ -702,7 +910,9 @@ export class PXE {
|
|
|
702
910
|
const publicFunctionSignatures = artifact.functions
|
|
703
911
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
704
912
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
705
|
-
|
|
913
|
+
if (publicFunctionSignatures.length > 0) {
|
|
914
|
+
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
915
|
+
}
|
|
706
916
|
|
|
707
917
|
currentInstance.currentContractClassId = contractClass.id;
|
|
708
918
|
await Promise.all([
|
|
@@ -731,7 +941,7 @@ export class PXE {
|
|
|
731
941
|
* @throws If contract code not found, or public simulation reverts.
|
|
732
942
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
733
943
|
*/
|
|
734
|
-
public proveTx(txRequest: TxExecutionRequest, scopes:
|
|
944
|
+
public proveTx(txRequest: TxExecutionRequest, { scopes, senderForTags }: ProveTxOpts): Promise<TxProvingResult> {
|
|
735
945
|
let privateExecutionResult: PrivateExecutionResult;
|
|
736
946
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
737
947
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -739,17 +949,25 @@ export class PXE {
|
|
|
739
949
|
const totalTimer = new Timer();
|
|
740
950
|
try {
|
|
741
951
|
const syncTimer = new Timer();
|
|
742
|
-
await this
|
|
952
|
+
await this.#maybeSync();
|
|
953
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
743
954
|
const syncTime = syncTimer.ms();
|
|
744
955
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
745
|
-
privateExecutionResult = await this.#executePrivate(
|
|
956
|
+
privateExecutionResult = await this.#executePrivate({
|
|
957
|
+
contractFunctionSimulator,
|
|
958
|
+
txRequest,
|
|
959
|
+
anchorBlockHeader,
|
|
960
|
+
scopes,
|
|
961
|
+
jobId,
|
|
962
|
+
senderForTags,
|
|
963
|
+
});
|
|
746
964
|
|
|
747
965
|
const {
|
|
748
966
|
publicInputs,
|
|
749
967
|
chonkProof,
|
|
750
968
|
executionSteps,
|
|
751
969
|
timings: { proving } = {},
|
|
752
|
-
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
970
|
+
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
753
971
|
simulate: false,
|
|
754
972
|
skipFeeEnforcement: false,
|
|
755
973
|
profileMode: 'none',
|
|
@@ -779,23 +997,20 @@ export class PXE {
|
|
|
779
997
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
780
998
|
});
|
|
781
999
|
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
} else {
|
|
797
|
-
this.log.debug(`No tagging index ranges used in the tx`);
|
|
798
|
-
}
|
|
1000
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
1001
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
1002
|
+
// onchain).
|
|
1003
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
1004
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
1005
|
+
// actually used to being reduced.
|
|
1006
|
+
await persistSenderTaggingIndexRangesForTx(
|
|
1007
|
+
this.senderTaggingStore,
|
|
1008
|
+
privateExecutionResult.entrypoint.taggingIndexRanges,
|
|
1009
|
+
publicInputs,
|
|
1010
|
+
() => txProvingResult.getTxHash(),
|
|
1011
|
+
jobId,
|
|
1012
|
+
this.log,
|
|
1013
|
+
);
|
|
799
1014
|
|
|
800
1015
|
return txProvingResult;
|
|
801
1016
|
} catch (err: any) {
|
|
@@ -812,7 +1027,7 @@ export class PXE {
|
|
|
812
1027
|
*/
|
|
813
1028
|
public profileTx(
|
|
814
1029
|
txRequest: TxExecutionRequest,
|
|
815
|
-
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
1030
|
+
{ profileMode, skipProofGeneration = true, scopes, senderForTags }: ProfileTxOpts,
|
|
816
1031
|
): Promise<TxProfileResult> {
|
|
817
1032
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
818
1033
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -831,16 +1046,25 @@ export class PXE {
|
|
|
831
1046
|
txInfo,
|
|
832
1047
|
);
|
|
833
1048
|
const syncTimer = new Timer();
|
|
834
|
-
await this
|
|
1049
|
+
await this.#maybeSync();
|
|
1050
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
835
1051
|
const syncTime = syncTimer.ms();
|
|
836
1052
|
|
|
837
1053
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
838
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1054
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1055
|
+
contractFunctionSimulator,
|
|
1056
|
+
txRequest,
|
|
1057
|
+
anchorBlockHeader,
|
|
1058
|
+
scopes,
|
|
1059
|
+
jobId,
|
|
1060
|
+
senderForTags,
|
|
1061
|
+
});
|
|
839
1062
|
|
|
840
1063
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
841
1064
|
txRequest,
|
|
842
1065
|
this.proofCreator,
|
|
843
1066
|
privateExecutionResult,
|
|
1067
|
+
anchorBlockHeader,
|
|
844
1068
|
{
|
|
845
1069
|
simulate: skipProofGeneration,
|
|
846
1070
|
skipFeeEnforcement: false,
|
|
@@ -908,6 +1132,7 @@ export class PXE {
|
|
|
908
1132
|
skipKernels = true,
|
|
909
1133
|
overrides,
|
|
910
1134
|
scopes,
|
|
1135
|
+
senderForTags,
|
|
911
1136
|
}: SimulateTxOpts,
|
|
912
1137
|
): Promise<TxSimulationResult> {
|
|
913
1138
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
@@ -929,27 +1154,26 @@ export class PXE {
|
|
|
929
1154
|
txInfo,
|
|
930
1155
|
);
|
|
931
1156
|
const syncTimer = new Timer();
|
|
932
|
-
await this
|
|
1157
|
+
await this.#maybeSync();
|
|
1158
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
933
1159
|
const syncTime = syncTimer.ms();
|
|
934
1160
|
|
|
935
|
-
|
|
936
|
-
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
937
|
-
|
|
938
|
-
if (hasOverriddenContracts && !skipKernels) {
|
|
1161
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
939
1162
|
throw new Error(
|
|
940
1163
|
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
941
1164
|
);
|
|
942
1165
|
}
|
|
943
1166
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
944
1167
|
|
|
945
|
-
if (hasOverriddenContracts) {
|
|
946
|
-
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
947
|
-
// We exclude them so the sync service skips them entirely.
|
|
948
|
-
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
1168
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
952
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1169
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1170
|
+
contractFunctionSimulator,
|
|
1171
|
+
txRequest,
|
|
1172
|
+
anchorBlockHeader,
|
|
1173
|
+
scopes,
|
|
1174
|
+
jobId,
|
|
1175
|
+
senderForTags,
|
|
1176
|
+
});
|
|
953
1177
|
|
|
954
1178
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
955
1179
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
@@ -962,11 +1186,17 @@ export class PXE {
|
|
|
962
1186
|
));
|
|
963
1187
|
} else {
|
|
964
1188
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
965
|
-
({ publicInputs, executionSteps } = await this.#prove(
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1189
|
+
({ publicInputs, executionSteps } = await this.#prove(
|
|
1190
|
+
txRequest,
|
|
1191
|
+
this.proofCreator,
|
|
1192
|
+
privateExecutionResult,
|
|
1193
|
+
anchorBlockHeader,
|
|
1194
|
+
{
|
|
1195
|
+
simulate: true,
|
|
1196
|
+
skipFeeEnforcement,
|
|
1197
|
+
profileMode: 'none',
|
|
1198
|
+
},
|
|
1199
|
+
));
|
|
970
1200
|
}
|
|
971
1201
|
|
|
972
1202
|
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
@@ -975,7 +1205,7 @@ export class PXE {
|
|
|
975
1205
|
let publicOutput: PublicSimulationOutput | undefined;
|
|
976
1206
|
if (simulatePublic && publicInputs.forPublic) {
|
|
977
1207
|
const publicSimulationTimer = new Timer();
|
|
978
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
1208
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
979
1209
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
980
1210
|
if (publicOutput?.debugLogs?.length) {
|
|
981
1211
|
await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
|
|
@@ -1040,7 +1270,7 @@ export class PXE {
|
|
|
1040
1270
|
inspect(txRequest),
|
|
1041
1271
|
`simulatePublic=${simulatePublic}`,
|
|
1042
1272
|
`skipTxValidation=${skipTxValidation}`,
|
|
1043
|
-
`scopes=${scopes
|
|
1273
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1044
1274
|
);
|
|
1045
1275
|
}
|
|
1046
1276
|
});
|
|
@@ -1052,7 +1282,7 @@ export class PXE {
|
|
|
1052
1282
|
*/
|
|
1053
1283
|
public executeUtility(
|
|
1054
1284
|
call: FunctionCall,
|
|
1055
|
-
{ authwits, scopes }: ExecuteUtilityOpts = { scopes:
|
|
1285
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1056
1286
|
): Promise<UtilityExecutionResult> {
|
|
1057
1287
|
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1058
1288
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1061,7 +1291,7 @@ export class PXE {
|
|
|
1061
1291
|
try {
|
|
1062
1292
|
const totalTimer = new Timer();
|
|
1063
1293
|
const syncTimer = new Timer();
|
|
1064
|
-
await this
|
|
1294
|
+
await this.#maybeSync();
|
|
1065
1295
|
const syncTime = syncTimer.ms();
|
|
1066
1296
|
const functionTimer = new Timer();
|
|
1067
1297
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -1110,7 +1340,7 @@ export class PXE {
|
|
|
1110
1340
|
throw this.#contextualizeError(
|
|
1111
1341
|
err,
|
|
1112
1342
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1113
|
-
`scopes=${scopes
|
|
1343
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1114
1344
|
);
|
|
1115
1345
|
}
|
|
1116
1346
|
});
|
|
@@ -1136,7 +1366,7 @@ export class PXE {
|
|
|
1136
1366
|
let anchorBlockNumber: BlockNumber;
|
|
1137
1367
|
|
|
1138
1368
|
await this.#putInJobQueue(async jobId => {
|
|
1139
|
-
await this
|
|
1369
|
+
await this.#maybeSync();
|
|
1140
1370
|
|
|
1141
1371
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1142
1372
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
@@ -1169,6 +1399,7 @@ export class PXE {
|
|
|
1169
1399
|
*/
|
|
1170
1400
|
public async stop(): Promise<void> {
|
|
1171
1401
|
await this.jobQueue.end();
|
|
1402
|
+
await this.blockStateSynchronizer.stop();
|
|
1172
1403
|
await this.db.close();
|
|
1173
1404
|
}
|
|
1174
1405
|
}
|