@aztec/pxe 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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 +16 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +91 -22
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +12 -2
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +230 -89
- 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 +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- 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 +3 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -7
- 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 +9 -11
- 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 +5 -8
- 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 +7 -12
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +67 -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/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +327 -119
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +59 -76
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +125 -90
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +140 -73
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +347 -162
- 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 +44 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +116 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +60 -0
- 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 -17
- 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 +23 -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 +24 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -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 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- 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 +30 -11
- package/dest/events/event_service.d.ts +7 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +33 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +20 -6
- 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 +11 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +52 -64
- 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 +36 -0
- package/dest/notes/note_service.d.ts +9 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +45 -40
- 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 -9
- 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 +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +140 -73
- 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 +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -16
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +91 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +163 -145
- 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/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 +25 -10
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +143 -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 +42 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -85
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +229 -111
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -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 +43 -32
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +300 -122
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +4 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -26
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +18 -12
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +23 -16
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +8 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +44 -27
- package/package.json +27 -18
- package/src/bin/check_oracle_version.ts +5 -4
- package/src/block_synchronizer/block_synchronizer.ts +113 -35
- package/src/config/index.ts +9 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +392 -154
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +2 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -10
- 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 +5 -11
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +97 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +422 -166
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +169 -185
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +578 -193
- 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 +176 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +18 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +19 -18
- package/src/entrypoints/pxe_creation_options.ts +9 -1
- package/src/entrypoints/server/index.ts +4 -1
- package/src/entrypoints/server/utils.ts +24 -29
- package/src/events/event_service.ts +31 -26
- package/src/events/private_event_filter_validator.ts +23 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +94 -104
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +54 -48
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -9
- 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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +195 -136
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +25 -20
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +297 -223
- 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/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +183 -29
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -101
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +323 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +296 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +366 -134
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +3 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +27 -29
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +31 -15
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +42 -29
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.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/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
package/src/pxe.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
6
7
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -17,16 +18,15 @@ import {
|
|
|
17
18
|
} from '@aztec/stdlib/abi';
|
|
18
19
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
19
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import type { L2TipsProvider } from '@aztec/stdlib/block';
|
|
20
22
|
import {
|
|
21
23
|
CompleteAddress,
|
|
22
|
-
type ContractClassWithId,
|
|
23
24
|
type ContractInstanceWithAddress,
|
|
24
25
|
type PartialAddress,
|
|
25
26
|
computeContractAddressFromInstance,
|
|
26
27
|
getContractClassFromArtifact,
|
|
27
28
|
} from '@aztec/stdlib/contract';
|
|
28
29
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
29
|
-
import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
30
30
|
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
31
31
|
import type {
|
|
32
32
|
PrivateExecutionStep,
|
|
@@ -34,6 +34,7 @@ import type {
|
|
|
34
34
|
PrivateKernelTailCircuitPublicInputs,
|
|
35
35
|
} from '@aztec/stdlib/kernel';
|
|
36
36
|
import {
|
|
37
|
+
BlockHeader,
|
|
37
38
|
type ContractOverrides,
|
|
38
39
|
type InTx,
|
|
39
40
|
PrivateExecutionResult,
|
|
@@ -47,29 +48,32 @@ import {
|
|
|
47
48
|
TxProfileResult,
|
|
48
49
|
TxProvingResult,
|
|
49
50
|
TxSimulationResult,
|
|
50
|
-
|
|
51
|
+
UtilityExecutionResult,
|
|
51
52
|
} from '@aztec/stdlib/tx';
|
|
52
53
|
|
|
53
54
|
import { inspect } from 'util';
|
|
54
55
|
|
|
55
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
57
|
import type { PXEConfig } from './config/index.js';
|
|
58
|
+
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
57
59
|
import {
|
|
58
60
|
ContractFunctionSimulator,
|
|
59
61
|
generateSimulatedProvingResult,
|
|
60
62
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
61
|
-
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
62
63
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
|
-
import {
|
|
64
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
65
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
66
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
64
67
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
65
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
66
69
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
67
70
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
71
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
68
72
|
import {
|
|
69
73
|
PrivateKernelExecutionProver,
|
|
70
74
|
type PrivateKernelExecutionProverConfig,
|
|
71
75
|
} from './private_kernel/private_kernel_execution_prover.js';
|
|
72
|
-
import {
|
|
76
|
+
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
73
77
|
import { AddressStore } from './storage/address_store/address_store.js';
|
|
74
78
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
75
79
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
@@ -85,6 +89,58 @@ export type PackedPrivateEvent = InTx & {
|
|
|
85
89
|
eventSelector: EventSelector;
|
|
86
90
|
};
|
|
87
91
|
|
|
92
|
+
/** Options for PXE.profileTx. */
|
|
93
|
+
export type ProfileTxOpts = {
|
|
94
|
+
/** The profiling mode to use. */
|
|
95
|
+
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
96
|
+
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
97
|
+
skipProofGeneration?: boolean;
|
|
98
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
99
|
+
scopes: AztecAddress[];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** Options for PXE.simulateTx. */
|
|
103
|
+
export type SimulateTxOpts = {
|
|
104
|
+
/** Whether to simulate the public part of the transaction. */
|
|
105
|
+
simulatePublic: boolean;
|
|
106
|
+
/** If false, this function throws if the transaction is unable to be included in a block at the current state. */
|
|
107
|
+
skipTxValidation?: boolean;
|
|
108
|
+
/** If false, fees are enforced. */
|
|
109
|
+
skipFeeEnforcement?: boolean;
|
|
110
|
+
/** If true, kernel logic is emulated in TS for simulation */
|
|
111
|
+
skipKernels?: boolean;
|
|
112
|
+
/** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
|
|
113
|
+
overrides?: SimulationOverrides;
|
|
114
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
115
|
+
scopes: AztecAddress[];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** Options for PXE.executeUtility. */
|
|
119
|
+
export type ExecuteUtilityOpts = {
|
|
120
|
+
/** The authentication witnesses required for the function call. */
|
|
121
|
+
authwits?: AuthWitness[];
|
|
122
|
+
/** The accounts whose notes we can access in this call */
|
|
123
|
+
scopes: AztecAddress[];
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** Args for PXE.create. */
|
|
127
|
+
export type PXECreateArgs = {
|
|
128
|
+
/** The Aztec node to connect to. */
|
|
129
|
+
node: AztecNode;
|
|
130
|
+
/** The key-value store for persisting PXE state. */
|
|
131
|
+
store: AztecAsyncKVStore;
|
|
132
|
+
/** The prover for generating private kernel proofs. */
|
|
133
|
+
proofCreator: PrivateKernelProver;
|
|
134
|
+
/** The circuit simulator for executing ACIR circuits. */
|
|
135
|
+
simulator: CircuitSimulator;
|
|
136
|
+
/** Provider for protocol contract artifacts and instances. */
|
|
137
|
+
protocolContractsProvider: ProtocolContractsProvider;
|
|
138
|
+
/** PXE configuration options. */
|
|
139
|
+
config: PXEConfig;
|
|
140
|
+
/** Optional logger instance or string suffix for the logger name. */
|
|
141
|
+
loggerOrSuffix?: string | Logger;
|
|
142
|
+
};
|
|
143
|
+
|
|
88
144
|
/**
|
|
89
145
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
90
146
|
* manage private state of users.
|
|
@@ -92,6 +148,7 @@ export type PackedPrivateEvent = InTx & {
|
|
|
92
148
|
export class PXE {
|
|
93
149
|
private constructor(
|
|
94
150
|
private node: AztecNode,
|
|
151
|
+
private db: AztecAsyncKVStore,
|
|
95
152
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
96
153
|
private keyStore: KeyStore,
|
|
97
154
|
private contractStore: ContractStore,
|
|
@@ -103,6 +160,9 @@ export class PXE {
|
|
|
103
160
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
104
161
|
private addressStore: AddressStore,
|
|
105
162
|
private privateEventStore: PrivateEventStore,
|
|
163
|
+
private contractSyncService: ContractSyncService,
|
|
164
|
+
private messageContextService: MessageContextService,
|
|
165
|
+
private l2TipsStore: L2TipsProvider,
|
|
106
166
|
private simulator: CircuitSimulator,
|
|
107
167
|
private proverEnabled: boolean,
|
|
108
168
|
private proofCreator: PrivateKernelProver,
|
|
@@ -120,25 +180,31 @@ export class PXE {
|
|
|
120
180
|
*
|
|
121
181
|
* @returns A promise that resolves PXE is ready to be used.
|
|
122
182
|
*/
|
|
123
|
-
public static async create(
|
|
124
|
-
node
|
|
125
|
-
store
|
|
126
|
-
proofCreator
|
|
127
|
-
simulator
|
|
128
|
-
protocolContractsProvider
|
|
129
|
-
config
|
|
130
|
-
loggerOrSuffix
|
|
131
|
-
) {
|
|
183
|
+
public static async create({
|
|
184
|
+
node,
|
|
185
|
+
store,
|
|
186
|
+
proofCreator,
|
|
187
|
+
simulator,
|
|
188
|
+
protocolContractsProvider,
|
|
189
|
+
config,
|
|
190
|
+
loggerOrSuffix,
|
|
191
|
+
}: PXECreateArgs) {
|
|
192
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
193
|
+
const bindings: LoggerBindings | undefined =
|
|
194
|
+
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
195
|
+
|
|
132
196
|
const log =
|
|
133
197
|
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
134
198
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
135
199
|
: loggerOrSuffix;
|
|
136
200
|
|
|
137
|
-
const
|
|
201
|
+
const info = await node.getNodeInfo();
|
|
202
|
+
|
|
203
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
138
204
|
const addressStore = new AddressStore(store);
|
|
139
205
|
const privateEventStore = new PrivateEventStore(store);
|
|
140
206
|
const contractStore = new ContractStore(store);
|
|
141
|
-
const noteStore =
|
|
207
|
+
const noteStore = new NoteStore(store);
|
|
142
208
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
143
209
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
144
210
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -146,24 +212,43 @@ export class PXE {
|
|
|
146
212
|
const capsuleStore = new CapsuleStore(store);
|
|
147
213
|
const keyStore = new KeyStore(store);
|
|
148
214
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
215
|
+
const contractSyncService = new ContractSyncService(
|
|
216
|
+
node,
|
|
217
|
+
contractStore,
|
|
218
|
+
noteStore,
|
|
219
|
+
createLogger('pxe:contract_sync', bindings),
|
|
220
|
+
);
|
|
221
|
+
const messageContextService = new MessageContextService(node);
|
|
222
|
+
|
|
149
223
|
const synchronizer = new BlockSynchronizer(
|
|
150
224
|
node,
|
|
225
|
+
store,
|
|
151
226
|
anchorBlockStore,
|
|
152
227
|
noteStore,
|
|
153
228
|
privateEventStore,
|
|
154
229
|
tipsStore,
|
|
230
|
+
contractSyncService,
|
|
155
231
|
config,
|
|
156
|
-
|
|
232
|
+
bindings,
|
|
157
233
|
);
|
|
158
234
|
|
|
159
|
-
const jobCoordinator = new JobCoordinator(store);
|
|
235
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
236
|
+
jobCoordinator.registerStores([
|
|
237
|
+
capsuleStore,
|
|
238
|
+
senderTaggingStore,
|
|
239
|
+
recipientTaggingStore,
|
|
240
|
+
privateEventStore,
|
|
241
|
+
noteStore,
|
|
242
|
+
contractSyncService,
|
|
243
|
+
]);
|
|
160
244
|
|
|
161
|
-
const debugUtils = new PXEDebugUtils(
|
|
245
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
162
246
|
|
|
163
247
|
const jobQueue = new SerialQueue();
|
|
164
248
|
|
|
165
249
|
const pxe = new PXE(
|
|
166
250
|
node,
|
|
251
|
+
store,
|
|
167
252
|
synchronizer,
|
|
168
253
|
keyStore,
|
|
169
254
|
contractStore,
|
|
@@ -175,6 +260,9 @@ export class PXE {
|
|
|
175
260
|
recipientTaggingStore,
|
|
176
261
|
addressStore,
|
|
177
262
|
privateEventStore,
|
|
263
|
+
contractSyncService,
|
|
264
|
+
messageContextService,
|
|
265
|
+
tipsStore,
|
|
178
266
|
simulator,
|
|
179
267
|
proverEnabled,
|
|
180
268
|
proofCreator,
|
|
@@ -185,12 +273,15 @@ export class PXE {
|
|
|
185
273
|
debugUtils,
|
|
186
274
|
);
|
|
187
275
|
|
|
188
|
-
debugUtils.
|
|
276
|
+
debugUtils.setPXEHelpers(
|
|
277
|
+
pxe.#putInJobQueue.bind(pxe),
|
|
278
|
+
pxe.#getSimulatorForTx.bind(pxe),
|
|
279
|
+
pxe.#executeUtility.bind(pxe),
|
|
280
|
+
);
|
|
189
281
|
|
|
190
282
|
pxe.jobQueue.start();
|
|
191
283
|
|
|
192
284
|
await pxe.#registerProtocolContracts();
|
|
193
|
-
const info = await node.getNodeInfo();
|
|
194
285
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
195
286
|
return pxe;
|
|
196
287
|
}
|
|
@@ -200,20 +291,22 @@ export class PXE {
|
|
|
200
291
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
201
292
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
202
293
|
|
|
203
|
-
return new ContractFunctionSimulator(
|
|
204
|
-
proxyContractStore,
|
|
205
|
-
this.noteStore,
|
|
206
|
-
this.keyStore,
|
|
207
|
-
this.addressStore,
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
this.senderTaggingStore,
|
|
211
|
-
this.recipientTaggingStore,
|
|
212
|
-
this.senderAddressBookStore,
|
|
213
|
-
this.capsuleStore,
|
|
214
|
-
this.privateEventStore,
|
|
215
|
-
this.simulator,
|
|
216
|
-
|
|
294
|
+
return new ContractFunctionSimulator({
|
|
295
|
+
contractStore: proxyContractStore,
|
|
296
|
+
noteStore: this.noteStore,
|
|
297
|
+
keyStore: this.keyStore,
|
|
298
|
+
addressStore: this.addressStore,
|
|
299
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
300
|
+
l2TipsStore: this.l2TipsStore,
|
|
301
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
302
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
303
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
304
|
+
capsuleStore: this.capsuleStore,
|
|
305
|
+
privateEventStore: this.privateEventStore,
|
|
306
|
+
simulator: this.simulator,
|
|
307
|
+
contractSyncService: this.contractSyncService,
|
|
308
|
+
messageContextService: this.messageContextService,
|
|
309
|
+
});
|
|
217
310
|
}
|
|
218
311
|
|
|
219
312
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -265,34 +358,20 @@ export class PXE {
|
|
|
265
358
|
async #registerProtocolContracts() {
|
|
266
359
|
const registered: Record<string, string> = {};
|
|
267
360
|
for (const name of protocolContractNames) {
|
|
268
|
-
const { address,
|
|
269
|
-
|
|
270
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
361
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
362
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
271
363
|
await this.contractStore.addContractInstance(instance);
|
|
272
364
|
registered[name] = address.toString();
|
|
273
365
|
}
|
|
274
366
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
275
367
|
}
|
|
276
368
|
|
|
277
|
-
async #isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
|
|
278
|
-
return !!(await this.node.getContractClass(id));
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
async #isContractPublished(address: AztecAddress): Promise<boolean> {
|
|
282
|
-
return !!(await this.node.getContract(address));
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async #isContractInitialized(address: AztecAddress): Promise<boolean> {
|
|
286
|
-
const initNullifier = await siloNullifier(address, address.toField());
|
|
287
|
-
return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
369
|
// Executes the entrypoint private function, as well as all nested private
|
|
291
370
|
// functions that might arise.
|
|
292
371
|
async #executePrivate(
|
|
293
372
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
294
373
|
txRequest: TxExecutionRequest,
|
|
295
|
-
scopes: AztecAddress[]
|
|
374
|
+
scopes: AztecAddress[],
|
|
296
375
|
jobId: string,
|
|
297
376
|
): Promise<PrivateExecutionResult> {
|
|
298
377
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -300,18 +379,23 @@ export class PXE {
|
|
|
300
379
|
try {
|
|
301
380
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
302
381
|
|
|
303
|
-
|
|
304
|
-
txRequest,
|
|
382
|
+
await this.contractSyncService.ensureContractSynced(
|
|
305
383
|
contractAddress,
|
|
306
384
|
functionSelector,
|
|
307
|
-
|
|
385
|
+
(privateSyncCall, execScopes) =>
|
|
386
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
308
387
|
anchorBlockHeader,
|
|
309
|
-
// The sender for tags is set by contracts, typically by an account
|
|
310
|
-
// contract entrypoint
|
|
311
|
-
undefined, // senderForTags
|
|
312
|
-
scopes,
|
|
313
388
|
jobId,
|
|
389
|
+
scopes,
|
|
314
390
|
);
|
|
391
|
+
|
|
392
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
393
|
+
contractAddress,
|
|
394
|
+
selector: functionSelector,
|
|
395
|
+
anchorBlockHeader,
|
|
396
|
+
scopes,
|
|
397
|
+
jobId,
|
|
398
|
+
});
|
|
315
399
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
316
400
|
return result;
|
|
317
401
|
} catch (err) {
|
|
@@ -323,25 +407,32 @@ export class PXE {
|
|
|
323
407
|
}
|
|
324
408
|
|
|
325
409
|
/**
|
|
326
|
-
*
|
|
410
|
+
* Execute a utility function call on the given contract.
|
|
327
411
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
328
412
|
* @param call - The function call to execute.
|
|
329
413
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
330
414
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
331
415
|
* accounts if not specified.
|
|
332
416
|
* @param jobId - The job ID for staged writes.
|
|
333
|
-
* @returns The
|
|
417
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
334
418
|
*/
|
|
335
|
-
async #
|
|
419
|
+
async #executeUtility(
|
|
336
420
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
337
421
|
call: FunctionCall,
|
|
338
422
|
authWitnesses: AuthWitness[] | undefined,
|
|
339
|
-
scopes: AztecAddress[]
|
|
423
|
+
scopes: AztecAddress[],
|
|
340
424
|
jobId: string,
|
|
341
425
|
) {
|
|
342
426
|
try {
|
|
343
427
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
344
|
-
|
|
428
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
|
|
429
|
+
call,
|
|
430
|
+
authWitnesses ?? [],
|
|
431
|
+
anchorBlockHeader,
|
|
432
|
+
scopes,
|
|
433
|
+
jobId,
|
|
434
|
+
);
|
|
435
|
+
return { result, offchainEffects };
|
|
345
436
|
} catch (err) {
|
|
346
437
|
if (err instanceof SimulationError) {
|
|
347
438
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -394,85 +485,46 @@ export class PXE {
|
|
|
394
485
|
privateExecutionResult: PrivateExecutionResult,
|
|
395
486
|
config: PrivateKernelExecutionProverConfig,
|
|
396
487
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
397
|
-
const
|
|
398
|
-
const kernelOracle = new
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
488
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
489
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
490
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
491
|
+
kernelOracle,
|
|
492
|
+
proofCreator,
|
|
493
|
+
!this.proverEnabled,
|
|
494
|
+
this.log.getBindings(),
|
|
403
495
|
);
|
|
404
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
405
496
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
406
497
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
407
498
|
}
|
|
408
499
|
|
|
409
500
|
// Public API
|
|
410
501
|
|
|
411
|
-
|
|
412
|
-
|
|
502
|
+
/**
|
|
503
|
+
* Returns the block header up to which the PXE has synced.
|
|
504
|
+
* @returns The synced block header
|
|
505
|
+
*/
|
|
506
|
+
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
507
|
+
return this.#putInJobQueue(() => {
|
|
508
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
509
|
+
});
|
|
413
510
|
}
|
|
414
511
|
|
|
415
512
|
/**
|
|
416
|
-
* Returns the contract
|
|
417
|
-
*
|
|
418
|
-
* @
|
|
419
|
-
* @param id - Identifier of the class.
|
|
420
|
-
* @param includeArtifact - Identifier of the class.
|
|
421
|
-
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
422
|
-
* for `includeArtifact`
|
|
423
|
-
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
424
|
-
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
425
|
-
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
426
|
-
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
427
|
-
* do for the time being.
|
|
513
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
514
|
+
* @param address - The contract address.
|
|
515
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
428
516
|
*/
|
|
429
|
-
public
|
|
430
|
-
|
|
431
|
-
includeArtifact: boolean = false,
|
|
432
|
-
): Promise<{
|
|
433
|
-
contractClass: ContractClassWithId | undefined;
|
|
434
|
-
isContractClassPubliclyRegistered: boolean;
|
|
435
|
-
artifact: ContractArtifact | undefined;
|
|
436
|
-
}> {
|
|
437
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
438
|
-
if (!artifact) {
|
|
439
|
-
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return {
|
|
443
|
-
contractClass: artifact && (await getContractClassFromArtifact(artifact)),
|
|
444
|
-
isContractClassPubliclyRegistered: await this.#isContractClassPubliclyRegistered(id),
|
|
445
|
-
artifact: includeArtifact ? artifact : undefined,
|
|
446
|
-
};
|
|
517
|
+
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
518
|
+
return this.contractStore.getContractInstance(address);
|
|
447
519
|
}
|
|
448
520
|
|
|
449
521
|
/**
|
|
450
|
-
* Returns the contract
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* and whether the contract instance with the given address has been publicly deployed.
|
|
454
|
-
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
455
|
-
* This query is not dependent on the PXE.
|
|
456
|
-
* @param address - The address that the contract instance resides at.
|
|
457
|
-
* @returns - It returns the contract metadata
|
|
458
|
-
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
522
|
+
* Returns the contract artifact for a given contract class id, if it's registered in the PXE.
|
|
523
|
+
* @param id - Identifier of the contract class.
|
|
524
|
+
* @returns The contract artifact if found, undefined otherwise.
|
|
459
525
|
*/
|
|
460
|
-
public async
|
|
461
|
-
|
|
462
|
-
isContractInitialized: boolean;
|
|
463
|
-
isContractPublished: boolean;
|
|
464
|
-
}> {
|
|
465
|
-
let instance;
|
|
466
|
-
try {
|
|
467
|
-
instance = await this.contractStore.getContractInstance(address);
|
|
468
|
-
} catch {
|
|
469
|
-
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
470
|
-
}
|
|
471
|
-
return {
|
|
472
|
-
contractInstance: instance,
|
|
473
|
-
isContractInitialized: await this.#isContractInitialized(address),
|
|
474
|
-
isContractPublished: await this.#isContractPublished(address),
|
|
475
|
-
};
|
|
526
|
+
public async getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
|
|
527
|
+
return await this.contractStore.getContractArtifact(id);
|
|
476
528
|
}
|
|
477
529
|
|
|
478
530
|
/**
|
|
@@ -497,7 +549,6 @@ export class PXE {
|
|
|
497
549
|
}
|
|
498
550
|
|
|
499
551
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
500
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
501
552
|
return accountCompleteAddress;
|
|
502
553
|
}
|
|
503
554
|
|
|
@@ -512,6 +563,12 @@ export class PXE {
|
|
|
512
563
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
513
564
|
*/
|
|
514
565
|
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
566
|
+
if (!(await sender.isValid())) {
|
|
567
|
+
throw new Error(
|
|
568
|
+
`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
515
572
|
const accounts = await this.keyStore.getAccounts();
|
|
516
573
|
if (accounts.includes(sender)) {
|
|
517
574
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -522,6 +579,9 @@ export class PXE {
|
|
|
522
579
|
|
|
523
580
|
if (wasAdded) {
|
|
524
581
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
582
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
583
|
+
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
584
|
+
await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
|
|
525
585
|
} else {
|
|
526
586
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
527
587
|
}
|
|
@@ -571,8 +631,7 @@ export class PXE {
|
|
|
571
631
|
* @param artifact - The build artifact for the contract class.
|
|
572
632
|
*/
|
|
573
633
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
574
|
-
const
|
|
575
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
634
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
576
635
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
577
636
|
}
|
|
578
637
|
|
|
@@ -591,17 +650,17 @@ export class PXE {
|
|
|
591
650
|
if (artifact) {
|
|
592
651
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
593
652
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
594
|
-
|
|
595
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
653
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
596
654
|
throw new Error(
|
|
597
|
-
`Artifact does not match expected class id (computed ${
|
|
655
|
+
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
598
656
|
);
|
|
599
657
|
}
|
|
600
658
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
601
659
|
if (!computedAddress.equals(instance.address)) {
|
|
602
660
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
603
661
|
}
|
|
604
|
-
|
|
662
|
+
|
|
663
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
605
664
|
|
|
606
665
|
const publicFunctionSignatures = artifact.functions
|
|
607
666
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -645,26 +704,21 @@ export class PXE {
|
|
|
645
704
|
|
|
646
705
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
647
706
|
|
|
648
|
-
const currentClassId = await readCurrentClassId(
|
|
649
|
-
contractAddress,
|
|
650
|
-
currentInstance,
|
|
651
|
-
this.node,
|
|
652
|
-
header.globalVariables.blockNumber,
|
|
653
|
-
header.globalVariables.timestamp,
|
|
654
|
-
);
|
|
707
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
655
708
|
if (!contractClass.id.equals(currentClassId)) {
|
|
656
709
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
657
710
|
}
|
|
658
711
|
|
|
659
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
660
|
-
|
|
661
712
|
const publicFunctionSignatures = artifact.functions
|
|
662
713
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
663
714
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
664
715
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
665
716
|
|
|
666
717
|
currentInstance.currentContractClassId = contractClass.id;
|
|
667
|
-
await
|
|
718
|
+
await Promise.all([
|
|
719
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
720
|
+
this.contractStore.addContractInstance(currentInstance),
|
|
721
|
+
]);
|
|
668
722
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
669
723
|
});
|
|
670
724
|
}
|
|
@@ -682,11 +736,12 @@ export class PXE {
|
|
|
682
736
|
* (where validators prove the public portion).
|
|
683
737
|
*
|
|
684
738
|
* @param txRequest - An authenticated tx request ready for proving
|
|
739
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
685
740
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
686
741
|
* @throws If contract code not found, or public simulation reverts.
|
|
687
742
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
688
743
|
*/
|
|
689
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
744
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
690
745
|
let privateExecutionResult: PrivateExecutionResult;
|
|
691
746
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
692
747
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -697,7 +752,7 @@ export class PXE {
|
|
|
697
752
|
await this.blockStateSynchronizer.sync();
|
|
698
753
|
const syncTime = syncTimer.ms();
|
|
699
754
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
700
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
755
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
701
756
|
|
|
702
757
|
const {
|
|
703
758
|
publicInputs,
|
|
@@ -739,17 +794,17 @@ export class PXE {
|
|
|
739
794
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
740
795
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
741
796
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
797
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
798
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
744
799
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
745
800
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
746
801
|
|
|
747
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
748
|
-
this.log.debug(`Stored used
|
|
749
|
-
|
|
802
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
803
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
804
|
+
taggingIndexRangesUsedInTheTx,
|
|
750
805
|
});
|
|
751
806
|
} else {
|
|
752
|
-
this.log.debug(`No
|
|
807
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
753
808
|
}
|
|
754
809
|
|
|
755
810
|
return txProvingResult;
|
|
@@ -761,17 +816,13 @@ export class PXE {
|
|
|
761
816
|
|
|
762
817
|
/**
|
|
763
818
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
764
|
-
*
|
|
765
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
766
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
767
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
819
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
768
820
|
* @returns A trace of the program execution with gate counts.
|
|
769
821
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
770
822
|
*/
|
|
771
823
|
public profileTx(
|
|
772
824
|
txRequest: TxExecutionRequest,
|
|
773
|
-
profileMode
|
|
774
|
-
skipProofGeneration: boolean = true,
|
|
825
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
775
826
|
): Promise<TxProfileResult> {
|
|
776
827
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
777
828
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -794,12 +845,7 @@ export class PXE {
|
|
|
794
845
|
const syncTime = syncTimer.ms();
|
|
795
846
|
|
|
796
847
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
797
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
798
|
-
contractFunctionSimulator,
|
|
799
|
-
txRequest,
|
|
800
|
-
undefined,
|
|
801
|
-
jobId,
|
|
802
|
-
);
|
|
848
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
803
849
|
|
|
804
850
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
805
851
|
txRequest,
|
|
@@ -856,12 +902,7 @@ export class PXE {
|
|
|
856
902
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
857
903
|
*
|
|
858
904
|
*
|
|
859
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
860
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
861
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
862
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
863
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
864
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
905
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
865
906
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
866
907
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
867
908
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
@@ -870,11 +911,14 @@ export class PXE {
|
|
|
870
911
|
*/
|
|
871
912
|
public simulateTx(
|
|
872
913
|
txRequest: TxExecutionRequest,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
914
|
+
{
|
|
915
|
+
simulatePublic,
|
|
916
|
+
skipTxValidation = false,
|
|
917
|
+
skipFeeEnforcement = false,
|
|
918
|
+
skipKernels = true,
|
|
919
|
+
overrides,
|
|
920
|
+
scopes,
|
|
921
|
+
}: SimulateTxOpts,
|
|
878
922
|
): Promise<TxSimulationResult> {
|
|
879
923
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
880
924
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -898,11 +942,21 @@ export class PXE {
|
|
|
898
942
|
await this.blockStateSynchronizer.sync();
|
|
899
943
|
const syncTime = syncTimer.ms();
|
|
900
944
|
|
|
945
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
946
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
947
|
+
|
|
948
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
949
|
+
throw new Error(
|
|
950
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
951
|
+
);
|
|
952
|
+
}
|
|
901
953
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
954
|
+
|
|
955
|
+
if (hasOverriddenContracts) {
|
|
956
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
957
|
+
// We exclude them so the sync service skips them entirely.
|
|
958
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
959
|
+
}
|
|
906
960
|
|
|
907
961
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
908
962
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
@@ -911,15 +965,10 @@ export class PXE {
|
|
|
911
965
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
912
966
|
|
|
913
967
|
if (skipKernels) {
|
|
914
|
-
// According to the protocol rules, the nonce generator for the note hashes
|
|
915
|
-
// can either be the first nullifier in the tx or the protocol nullifier if there are none.
|
|
916
|
-
const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO)
|
|
917
|
-
? await computeProtocolNullifier(await txRequest.toTxRequest().hash())
|
|
918
|
-
: privateExecutionResult.firstNullifier;
|
|
919
968
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
920
969
|
privateExecutionResult,
|
|
921
|
-
|
|
922
|
-
this.
|
|
970
|
+
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
971
|
+
this.node,
|
|
923
972
|
));
|
|
924
973
|
} else {
|
|
925
974
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -938,6 +987,9 @@ export class PXE {
|
|
|
938
987
|
const publicSimulationTimer = new Timer();
|
|
939
988
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
940
989
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
990
|
+
if (publicOutput?.debugLogs?.length) {
|
|
991
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
|
|
992
|
+
}
|
|
941
993
|
}
|
|
942
994
|
|
|
943
995
|
let validationTime: number | undefined;
|
|
@@ -946,7 +998,8 @@ export class PXE {
|
|
|
946
998
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
947
999
|
validationTime = validationTimer.ms();
|
|
948
1000
|
if (validationResult.result === 'invalid') {
|
|
949
|
-
|
|
1001
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
1002
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
950
1003
|
}
|
|
951
1004
|
}
|
|
952
1005
|
|
|
@@ -997,29 +1050,23 @@ export class PXE {
|
|
|
997
1050
|
inspect(txRequest),
|
|
998
1051
|
`simulatePublic=${simulatePublic}`,
|
|
999
1052
|
`skipTxValidation=${skipTxValidation}`,
|
|
1000
|
-
`scopes=${scopes
|
|
1053
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1001
1054
|
);
|
|
1002
1055
|
}
|
|
1003
1056
|
});
|
|
1004
1057
|
}
|
|
1005
1058
|
|
|
1006
1059
|
/**
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1060
|
+
* Executes a contract utility function.
|
|
1009
1061
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
1010
|
-
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
1011
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
1012
|
-
* default to all.
|
|
1013
|
-
* @returns The result of the utility function call, structured based on the function ABI.
|
|
1014
1062
|
*/
|
|
1015
|
-
public
|
|
1063
|
+
public executeUtility(
|
|
1016
1064
|
call: FunctionCall,
|
|
1017
|
-
authwits
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1065
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1066
|
+
): Promise<UtilityExecutionResult> {
|
|
1067
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1021
1068
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1022
|
-
// delete the same read value, or reading values that another
|
|
1069
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1023
1070
|
return this.#putInJobQueue(async jobId => {
|
|
1024
1071
|
try {
|
|
1025
1072
|
const totalTimer = new Timer();
|
|
@@ -1029,11 +1076,18 @@ export class PXE {
|
|
|
1029
1076
|
const functionTimer = new Timer();
|
|
1030
1077
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1031
1078
|
|
|
1032
|
-
await this.
|
|
1033
|
-
|
|
1079
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1080
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1081
|
+
call.to,
|
|
1082
|
+
call.selector,
|
|
1083
|
+
(privateSyncCall, execScopes) =>
|
|
1084
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1085
|
+
anchorBlockHeader,
|
|
1086
|
+
jobId,
|
|
1087
|
+
scopes,
|
|
1034
1088
|
);
|
|
1035
1089
|
|
|
1036
|
-
const executionResult = await this.#
|
|
1090
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(
|
|
1037
1091
|
contractFunctionSimulator,
|
|
1038
1092
|
call,
|
|
1039
1093
|
authwits ?? [],
|
|
@@ -1054,14 +1108,19 @@ export class PXE {
|
|
|
1054
1108
|
};
|
|
1055
1109
|
|
|
1056
1110
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1057
|
-
return {
|
|
1111
|
+
return {
|
|
1112
|
+
result: executionResult,
|
|
1113
|
+
offchainEffects,
|
|
1114
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1115
|
+
stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
|
|
1116
|
+
};
|
|
1058
1117
|
} catch (err: any) {
|
|
1059
1118
|
const { to, name, args } = call;
|
|
1060
1119
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1061
1120
|
throw this.#contextualizeError(
|
|
1062
1121
|
err,
|
|
1063
|
-
`
|
|
1064
|
-
`scopes=${scopes
|
|
1122
|
+
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1123
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1065
1124
|
);
|
|
1066
1125
|
}
|
|
1067
1126
|
});
|
|
@@ -1080,32 +1139,47 @@ export class PXE {
|
|
|
1080
1139
|
* Defaults to the latest known block to PXE + 1.
|
|
1081
1140
|
* @returns - The packed events with block and tx metadata.
|
|
1082
1141
|
*/
|
|
1083
|
-
public getPrivateEvents(
|
|
1084
|
-
|
|
1142
|
+
public async getPrivateEvents(
|
|
1143
|
+
eventSelector: EventSelector,
|
|
1144
|
+
filter: PrivateEventFilter,
|
|
1145
|
+
): Promise<PackedPrivateEvent[]> {
|
|
1146
|
+
let anchorBlockNumber: BlockNumber;
|
|
1147
|
+
|
|
1148
|
+
await this.#putInJobQueue(async jobId => {
|
|
1085
1149
|
await this.blockStateSynchronizer.sync();
|
|
1150
|
+
|
|
1151
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1152
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
1153
|
+
|
|
1086
1154
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1087
1155
|
|
|
1088
|
-
await this.
|
|
1156
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1089
1157
|
filter.contractAddress,
|
|
1090
1158
|
null,
|
|
1091
|
-
async privateSyncCall =>
|
|
1092
|
-
await this.#
|
|
1159
|
+
async (privateSyncCall, execScopes) =>
|
|
1160
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1161
|
+
anchorBlockHeader,
|
|
1162
|
+
jobId,
|
|
1163
|
+
filter.scopes,
|
|
1093
1164
|
);
|
|
1165
|
+
});
|
|
1094
1166
|
|
|
1095
|
-
|
|
1167
|
+
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
1168
|
+
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber!).validate(filter);
|
|
1096
1169
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1170
|
+
this.log.debug(
|
|
1171
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1172
|
+
);
|
|
1100
1173
|
|
|
1101
|
-
|
|
1102
|
-
});
|
|
1174
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1103
1175
|
}
|
|
1104
1176
|
|
|
1105
1177
|
/**
|
|
1106
|
-
* Stops the PXE's job queue.
|
|
1178
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1107
1179
|
*/
|
|
1108
|
-
public stop(): Promise<void> {
|
|
1109
|
-
|
|
1180
|
+
public async stop(): Promise<void> {
|
|
1181
|
+
await this.jobQueue.end();
|
|
1182
|
+
await this.blockStateSynchronizer.stop();
|
|
1183
|
+
await this.db.close();
|
|
1110
1184
|
}
|
|
1111
1185
|
}
|