@aztec/pxe 0.0.1-commit.fffb133c → 0.0.1-dev
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 +5 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -6
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -31
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +214 -75
- 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_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
- 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 +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- 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 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- 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 +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +66 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +78 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +363 -114
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -86
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +123 -98
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +145 -70
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +435 -145
- 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 +3 -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/contract_sync/contract_sync_service.d.ts +45 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +150 -0
- package/dest/contract_sync/helpers.d.ts +27 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +16 -17
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -18
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- 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 +24 -9
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +25 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +8 -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 +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +31 -11
- package/dest/events/event_service.d.ts +16 -8
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +46 -14
- 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 +37 -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 +42 -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/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +10 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +50 -85
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +38 -0
- package/dest/notes/note_service.d.ts +29 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +89 -65
- 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/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/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_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- 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 +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -19
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +26 -20
- package/dest/pxe.d.ts +87 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +178 -119
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- 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 -2
- 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 +588 -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 +50 -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 +42 -36
- 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 +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -73
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +147 -107
- package/dest/storage/open_pxe_stores.d.ts +31 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +26 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +87 -61
- package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
- package/dest/storage/private_event_store/stored_private_event.js +2 -2
- 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/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
- package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +20 -3
- package/dest/tagging/index.d.ts +6 -5
- 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 +56 -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 +158 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- 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 +5 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +30 -13
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
- 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 +41 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +26 -16
- package/src/bin/check_oracle_version.ts +5 -5
- package/src/block_synchronizer/block_synchronizer.ts +45 -21
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +389 -134
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +101 -62
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +464 -151
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +152 -191
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +709 -200
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +208 -0
- package/src/contract_sync/{index.ts → helpers.ts} +17 -29
- package/src/debug/pxe_debug_utils.ts +63 -19
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +19 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +20 -18
- package/src/entrypoints/pxe_creation_options.ts +13 -1
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +25 -29
- package/src/events/event_service.ts +70 -24
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +40 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +88 -141
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +124 -91
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +53 -22
- package/src/private_kernel/private_kernel_oracle.ts +36 -26
- package/src/pxe.ts +351 -168
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
- 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__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +42 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -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__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +707 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +52 -34
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -81
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +166 -132
- package/src/storage/open_pxe_stores.ts +47 -0
- package/src/storage/private_event_store/private_event_store.ts +106 -81
- package/src/storage/private_event_store/stored_private_event.ts +3 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
- package/src/tagging/get_all_logs_by_tags.ts +35 -7
- package/src/tagging/index.ts +5 -4
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +236 -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 +54 -18
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +30 -29
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
- 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 -15
- 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 -32
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
package/dest/pxe.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
6
4
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
7
5
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
8
6
|
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
@@ -13,22 +11,18 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
|
13
11
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
14
12
|
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
15
13
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
16
|
-
import {
|
|
14
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
15
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
16
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
17
17
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
18
18
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
19
19
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
20
20
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
21
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
21
22
|
import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
|
|
22
23
|
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
26
|
-
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
27
|
-
import { NoteStore } from './storage/note_store/note_store.js';
|
|
28
|
-
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
29
|
-
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
30
|
-
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
31
|
-
import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
|
|
24
|
+
import { openPxeStores } from './storage/open_pxe_stores.js';
|
|
25
|
+
import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
32
26
|
/**
|
|
33
27
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
34
28
|
* manage private state of users.
|
|
@@ -45,6 +39,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
45
39
|
recipientTaggingStore;
|
|
46
40
|
addressStore;
|
|
47
41
|
privateEventStore;
|
|
42
|
+
contractSyncService;
|
|
43
|
+
messageContextService;
|
|
44
|
+
l2TipsStore;
|
|
48
45
|
simulator;
|
|
49
46
|
proverEnabled;
|
|
50
47
|
proofCreator;
|
|
@@ -53,7 +50,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
53
50
|
jobQueue;
|
|
54
51
|
jobCoordinator;
|
|
55
52
|
debug;
|
|
56
|
-
|
|
53
|
+
hooks;
|
|
54
|
+
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug, hooks){
|
|
57
55
|
this.node = node;
|
|
58
56
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
59
57
|
this.keyStore = keyStore;
|
|
@@ -66,6 +64,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
66
64
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
67
65
|
this.addressStore = addressStore;
|
|
68
66
|
this.privateEventStore = privateEventStore;
|
|
67
|
+
this.contractSyncService = contractSyncService;
|
|
68
|
+
this.messageContextService = messageContextService;
|
|
69
|
+
this.l2TipsStore = l2TipsStore;
|
|
69
70
|
this.simulator = simulator;
|
|
70
71
|
this.proverEnabled = proverEnabled;
|
|
71
72
|
this.proofCreator = proofCreator;
|
|
@@ -74,6 +75,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
74
75
|
this.jobQueue = jobQueue;
|
|
75
76
|
this.jobCoordinator = jobCoordinator;
|
|
76
77
|
this.debug = debug;
|
|
78
|
+
this.hooks = hooks;
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
79
81
|
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
@@ -81,43 +83,54 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
81
83
|
* can be contacted.
|
|
82
84
|
*
|
|
83
85
|
* @returns A promise that resolves PXE is ready to be used.
|
|
84
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
86
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix, hooks }) {
|
|
87
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
88
|
+
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
85
89
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const privateEventStore =
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
94
|
-
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
95
|
-
const capsuleStore = new CapsuleStore(store);
|
|
96
|
-
const keyStore = new KeyStore(store);
|
|
97
|
-
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
98
|
-
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, config, loggerOrSuffix);
|
|
99
|
-
const jobCoordinator = new JobCoordinator(store);
|
|
90
|
+
const info = await node.getNodeInfo();
|
|
91
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
92
|
+
const { addressStore, privateEventStore, contractStore, noteStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, capsuleStore, keyStore, l2TipsStore } = openPxeStores(store);
|
|
93
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
94
|
+
const messageContextService = new MessageContextService(node);
|
|
95
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, l2TipsStore, contractSyncService, config, bindings);
|
|
96
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
100
97
|
jobCoordinator.registerStores([
|
|
101
98
|
capsuleStore,
|
|
102
99
|
senderTaggingStore,
|
|
103
100
|
recipientTaggingStore,
|
|
104
101
|
privateEventStore,
|
|
105
|
-
noteStore
|
|
102
|
+
noteStore,
|
|
103
|
+
contractSyncService
|
|
106
104
|
]);
|
|
107
|
-
const debugUtils = new PXEDebugUtils(
|
|
105
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
108
106
|
const jobQueue = new SerialQueue();
|
|
109
|
-
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
110
|
-
debugUtils.
|
|
107
|
+
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils, hooks);
|
|
108
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
111
109
|
pxe.jobQueue.start();
|
|
112
110
|
await pxe.#registerProtocolContracts();
|
|
113
|
-
const info = await node.getNodeInfo();
|
|
114
111
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
115
112
|
return pxe;
|
|
116
113
|
}
|
|
117
114
|
// Internal methods
|
|
118
115
|
#getSimulatorForTx(overrides) {
|
|
119
116
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
120
|
-
return new ContractFunctionSimulator(
|
|
117
|
+
return new ContractFunctionSimulator({
|
|
118
|
+
contractStore: proxyContractStore,
|
|
119
|
+
noteStore: this.noteStore,
|
|
120
|
+
keyStore: this.keyStore,
|
|
121
|
+
addressStore: this.addressStore,
|
|
122
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
123
|
+
l2TipsStore: this.l2TipsStore,
|
|
124
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
125
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
126
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
127
|
+
capsuleStore: this.capsuleStore,
|
|
128
|
+
privateEventStore: this.privateEventStore,
|
|
129
|
+
simulator: this.simulator,
|
|
130
|
+
contractSyncService: this.contractSyncService,
|
|
131
|
+
messageContextService: this.messageContextService,
|
|
132
|
+
hooks: this.hooks
|
|
133
|
+
});
|
|
121
134
|
}
|
|
122
135
|
#contextualizeError(err, ...context) {
|
|
123
136
|
let contextStr = '';
|
|
@@ -160,8 +173,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
160
173
|
async #registerProtocolContracts() {
|
|
161
174
|
const registered = {};
|
|
162
175
|
for (const name of protocolContractNames){
|
|
163
|
-
const { address,
|
|
164
|
-
await this.contractStore.addContractArtifact(
|
|
176
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
177
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
165
178
|
await this.contractStore.addContractInstance(instance);
|
|
166
179
|
registered[name] = address.toString();
|
|
167
180
|
}
|
|
@@ -169,14 +182,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
169
182
|
}
|
|
170
183
|
// Executes the entrypoint private function, as well as all nested private
|
|
171
184
|
// functions that might arise.
|
|
172
|
-
async #executePrivate(contractFunctionSimulator, txRequest, scopes, jobId) {
|
|
185
|
+
async #executePrivate({ contractFunctionSimulator, txRequest, anchorBlockHeader, scopes, jobId, senderForTags }) {
|
|
173
186
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
174
187
|
try {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
189
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
190
|
+
contractAddress,
|
|
191
|
+
selector: functionSelector,
|
|
192
|
+
anchorBlockHeader,
|
|
193
|
+
scopes,
|
|
194
|
+
jobId,
|
|
195
|
+
senderForTags
|
|
196
|
+
});
|
|
180
197
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
181
198
|
return result;
|
|
182
199
|
} catch (err) {
|
|
@@ -187,18 +204,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
187
204
|
}
|
|
188
205
|
}
|
|
189
206
|
/**
|
|
190
|
-
*
|
|
207
|
+
* Execute a utility function call on the given contract.
|
|
191
208
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
192
209
|
* @param call - The function call to execute.
|
|
193
210
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
194
211
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
195
212
|
* accounts if not specified.
|
|
196
213
|
* @param jobId - The job ID for staged writes.
|
|
197
|
-
* @returns The
|
|
198
|
-
*/ async #
|
|
214
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
215
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
199
216
|
try {
|
|
200
217
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
201
|
-
|
|
218
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
219
|
+
return {
|
|
220
|
+
result,
|
|
221
|
+
offchainEffects
|
|
222
|
+
};
|
|
202
223
|
} catch (err) {
|
|
203
224
|
if (err instanceof SimulationError) {
|
|
204
225
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -241,16 +262,26 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
241
262
|
* @param privateExecutionResult - The result of the private execution
|
|
242
263
|
* @param config - The configuration for the kernel execution prover.
|
|
243
264
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
244
|
-
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
248
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
265
|
+
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, anchorBlockHeader, config) {
|
|
266
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
267
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
249
268
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
250
269
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
251
270
|
}
|
|
252
271
|
// Public API
|
|
253
|
-
|
|
272
|
+
/**
|
|
273
|
+
* Returns the block header up to which the PXE has synced.
|
|
274
|
+
* @returns The synced block header
|
|
275
|
+
*/ getSyncedBlockHeader() {
|
|
276
|
+
return this.#putInJobQueue(()=>{
|
|
277
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
282
|
+
* @param address - The contract address.
|
|
283
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
284
|
+
*/ getContractInstance(address) {
|
|
254
285
|
return this.contractStore.getContractInstance(address);
|
|
255
286
|
}
|
|
256
287
|
/**
|
|
@@ -292,6 +323,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
292
323
|
* @returns The address of the sender.
|
|
293
324
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
294
325
|
*/ async registerSender(sender) {
|
|
326
|
+
if (!await sender.isValid()) {
|
|
327
|
+
throw new Error(`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`);
|
|
328
|
+
}
|
|
295
329
|
const accounts = await this.keyStore.getAccounts();
|
|
296
330
|
if (accounts.includes(sender)) {
|
|
297
331
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -300,6 +334,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
300
334
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
301
335
|
if (wasAdded) {
|
|
302
336
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
337
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
338
|
+
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
339
|
+
await this.#putInJobQueue(()=>Promise.resolve(this.contractSyncService.wipe()));
|
|
303
340
|
} else {
|
|
304
341
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
305
342
|
}
|
|
@@ -337,8 +374,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
337
374
|
*
|
|
338
375
|
* @param artifact - The build artifact for the contract class.
|
|
339
376
|
*/ async registerContractClass(artifact) {
|
|
340
|
-
const
|
|
341
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
377
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
342
378
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
343
379
|
}
|
|
344
380
|
/**
|
|
@@ -354,17 +390,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
354
390
|
if (artifact) {
|
|
355
391
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
356
392
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
throw new Error(`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`);
|
|
393
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
394
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
360
395
|
}
|
|
361
396
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
362
397
|
if (!computedAddress.equals(instance.address)) {
|
|
363
398
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
364
399
|
}
|
|
365
|
-
await this.contractStore.addContractArtifact(
|
|
400
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
366
401
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
367
|
-
|
|
402
|
+
if (publicFunctionSignatures.length > 0) {
|
|
403
|
+
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
404
|
+
}
|
|
368
405
|
} else {
|
|
369
406
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
370
407
|
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
@@ -398,11 +435,15 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
398
435
|
if (!contractClass.id.equals(currentClassId)) {
|
|
399
436
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
400
437
|
}
|
|
401
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
402
438
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
403
|
-
|
|
439
|
+
if (publicFunctionSignatures.length > 0) {
|
|
440
|
+
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
441
|
+
}
|
|
404
442
|
currentInstance.currentContractClassId = contractClass.id;
|
|
405
|
-
await
|
|
443
|
+
await Promise.all([
|
|
444
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
445
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
446
|
+
]);
|
|
406
447
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
407
448
|
});
|
|
408
449
|
}
|
|
@@ -417,10 +458,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
417
458
|
* (where validators prove the public portion).
|
|
418
459
|
*
|
|
419
460
|
* @param txRequest - An authenticated tx request ready for proving
|
|
461
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
420
462
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
421
463
|
* @throws If contract code not found, or public simulation reverts.
|
|
422
464
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
423
|
-
*/ proveTx(txRequest) {
|
|
465
|
+
*/ proveTx(txRequest, { scopes, senderForTags }) {
|
|
424
466
|
let privateExecutionResult;
|
|
425
467
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
426
468
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -429,10 +471,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
429
471
|
try {
|
|
430
472
|
const syncTimer = new Timer();
|
|
431
473
|
await this.blockStateSynchronizer.sync();
|
|
474
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
432
475
|
const syncTime = syncTimer.ms();
|
|
433
476
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
434
|
-
privateExecutionResult = await this.#executePrivate(
|
|
435
|
-
|
|
477
|
+
privateExecutionResult = await this.#executePrivate({
|
|
478
|
+
contractFunctionSimulator,
|
|
479
|
+
txRequest,
|
|
480
|
+
anchorBlockHeader,
|
|
481
|
+
scopes,
|
|
482
|
+
jobId,
|
|
483
|
+
senderForTags
|
|
484
|
+
});
|
|
485
|
+
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
436
486
|
simulate: false,
|
|
437
487
|
skipFeeEnforcement: false,
|
|
438
488
|
profileMode: 'none'
|
|
@@ -457,22 +507,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
457
507
|
timings,
|
|
458
508
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls
|
|
459
509
|
});
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
//
|
|
464
|
-
//
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
468
|
-
const txHash = (await txProvingResult.toTx()).txHash;
|
|
469
|
-
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash, jobId);
|
|
470
|
-
this.log.debug(`Stored used pre-tags as sender for the tx`, {
|
|
471
|
-
preTagsUsedInTheTx
|
|
472
|
-
});
|
|
473
|
-
} else {
|
|
474
|
-
this.log.debug(`No pre-tags used in the tx`);
|
|
475
|
-
}
|
|
510
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
511
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
512
|
+
// onchain).
|
|
513
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
514
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
515
|
+
// actually used to being reduced.
|
|
516
|
+
await persistSenderTaggingIndexRangesForTx(this.senderTaggingStore, privateExecutionResult.entrypoint.taggingIndexRanges, publicInputs, ()=>txProvingResult.getTxHash(), jobId, this.log);
|
|
476
517
|
return txProvingResult;
|
|
477
518
|
} catch (err) {
|
|
478
519
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
@@ -481,13 +522,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
481
522
|
}
|
|
482
523
|
/**
|
|
483
524
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
484
|
-
*
|
|
485
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
486
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
487
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
525
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
488
526
|
* @returns A trace of the program execution with gate counts.
|
|
489
527
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
490
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
528
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes, senderForTags }) {
|
|
491
529
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
492
530
|
return this.#putInJobQueue(async (jobId)=>{
|
|
493
531
|
const totalTimer = new Timer();
|
|
@@ -503,10 +541,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
503
541
|
this.log.info(`Profiling transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
504
542
|
const syncTimer = new Timer();
|
|
505
543
|
await this.blockStateSynchronizer.sync();
|
|
544
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
506
545
|
const syncTime = syncTimer.ms();
|
|
507
546
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
508
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
509
|
-
|
|
547
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
548
|
+
contractFunctionSimulator,
|
|
549
|
+
txRequest,
|
|
550
|
+
anchorBlockHeader,
|
|
551
|
+
scopes,
|
|
552
|
+
jobId,
|
|
553
|
+
senderForTags
|
|
554
|
+
});
|
|
555
|
+
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
510
556
|
simulate: skipProofGeneration,
|
|
511
557
|
skipFeeEnforcement: false,
|
|
512
558
|
profileMode
|
|
@@ -550,18 +596,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
550
596
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
551
597
|
*
|
|
552
598
|
*
|
|
553
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
554
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
555
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
556
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
557
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
558
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
599
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
559
600
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
560
601
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
561
602
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
562
603
|
*
|
|
563
604
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
564
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
605
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes, senderForTags }) {
|
|
565
606
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
566
607
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
567
608
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -579,21 +620,35 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
579
620
|
this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
580
621
|
const syncTimer = new Timer();
|
|
581
622
|
await this.blockStateSynchronizer.sync();
|
|
623
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
582
624
|
const syncTime = syncTimer.ms();
|
|
625
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
626
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
627
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
628
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
629
|
+
}
|
|
583
630
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
631
|
+
if (hasOverriddenContracts) {
|
|
632
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
633
|
+
// We exclude them so the sync service skips them entirely.
|
|
634
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
635
|
+
}
|
|
588
636
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
589
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
637
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
638
|
+
contractFunctionSimulator,
|
|
639
|
+
txRequest,
|
|
640
|
+
anchorBlockHeader,
|
|
641
|
+
scopes,
|
|
642
|
+
jobId,
|
|
643
|
+
senderForTags
|
|
644
|
+
});
|
|
590
645
|
let publicInputs;
|
|
591
646
|
let executionSteps = [];
|
|
592
647
|
if (skipKernels) {
|
|
593
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
|
|
648
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
594
649
|
} else {
|
|
595
650
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
596
|
-
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
651
|
+
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
597
652
|
simulate: true,
|
|
598
653
|
skipFeeEnforcement,
|
|
599
654
|
profileMode: 'none'
|
|
@@ -607,6 +662,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
607
662
|
const publicSimulationTimer = new Timer();
|
|
608
663
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
609
664
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
665
|
+
if (publicOutput?.debugLogs?.length) {
|
|
666
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
667
|
+
}
|
|
610
668
|
}
|
|
611
669
|
let validationTime;
|
|
612
670
|
if (!skipTxValidation) {
|
|
@@ -617,7 +675,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
617
675
|
});
|
|
618
676
|
validationTime = validationTimer.ms();
|
|
619
677
|
if (validationResult.result === 'invalid') {
|
|
620
|
-
|
|
678
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
679
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
621
680
|
}
|
|
622
681
|
}
|
|
623
682
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -650,22 +709,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
650
709
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
651
710
|
});
|
|
652
711
|
} catch (err) {
|
|
653
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
712
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
654
713
|
}
|
|
655
714
|
});
|
|
656
715
|
}
|
|
657
716
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
717
|
+
* Executes a contract utility function.
|
|
660
718
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
*/ simulateUtility(call, authwits, scopes) {
|
|
666
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
719
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
720
|
+
scopes: []
|
|
721
|
+
}) {
|
|
722
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
667
723
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
668
|
-
// delete the same read value, or reading values that another
|
|
724
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
669
725
|
return this.#putInJobQueue(async (jobId)=>{
|
|
670
726
|
try {
|
|
671
727
|
const totalTimer = new Timer();
|
|
@@ -675,8 +731,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
675
731
|
const functionTimer = new Timer();
|
|
676
732
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
677
733
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
678
|
-
await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#
|
|
679
|
-
const executionResult = await this.#
|
|
734
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
735
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
680
736
|
const functionTime = functionTimer.ms();
|
|
681
737
|
const totalTime = totalTimer.ms();
|
|
682
738
|
const perFunction = [
|
|
@@ -694,6 +750,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
694
750
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
695
751
|
return {
|
|
696
752
|
result: executionResult,
|
|
753
|
+
offchainEffects,
|
|
754
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
697
755
|
stats: {
|
|
698
756
|
timings,
|
|
699
757
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -702,7 +760,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
702
760
|
} catch (err) {
|
|
703
761
|
const { to, name, args } = call;
|
|
704
762
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
705
|
-
throw this.#contextualizeError(err, `
|
|
763
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
706
764
|
}
|
|
707
765
|
});
|
|
708
766
|
}
|
|
@@ -725,7 +783,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
725
783
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
726
784
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
727
785
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
728
|
-
await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#
|
|
786
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
729
787
|
});
|
|
730
788
|
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
731
789
|
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
@@ -734,7 +792,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
734
792
|
}
|
|
735
793
|
/**
|
|
736
794
|
* Stops the PXE's job queue.
|
|
737
|
-
*/ stop() {
|
|
738
|
-
|
|
795
|
+
*/ async stop() {
|
|
796
|
+
await this.jobQueue.end();
|
|
797
|
+
await this.blockStateSynchronizer.stop();
|
|
739
798
|
}
|
|
740
799
|
}
|
|
@@ -8,4 +8,4 @@ export declare class AddressStore {
|
|
|
8
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
9
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvYWRkcmVzc19zdG9yZS9hZGRyZXNzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFtQixpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RixPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsWUFBWTs7SUFLdkIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBS25DO0lBRUQsa0JBQWtCLENBQUMsZUFBZSxFQUFFLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBMEJyRTtJQUVELGtCQUFrQixDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FVOUU7SUFFRCxvQkFBb0IsSUFBSSxPQUFPLENBQUMsZUFBZSxFQUFFLENBQUMsQ0FNakQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;
|
|
1
|
+
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAED,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU9E;IAED,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMjD;CACF"}
|