@aztec/pxe 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +11 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -21
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -1
- 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 +64 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +224 -88
- 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 +3 -4
- 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 +6 -5
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +4 -6
- 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 +56 -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 +42 -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 +45 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +209 -117
- 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 +60 -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 +113 -88
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +107 -56
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +214 -137
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -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 +114 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -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 +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -7
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +28 -9
- package/dest/events/event_service.d.ts +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -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 +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +31 -33
- 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 +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +5 -4
- 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 +22 -14
- package/dest/private_kernel/private_kernel_oracle.d.ts +23 -24
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +155 -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 +8 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- 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 +157 -84
- 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 +226 -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 +11 -11
- 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/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +91 -33
- package/src/config/index.ts +15 -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 +386 -153
- 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 +9 -6
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -7
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +69 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +235 -165
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +153 -184
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +318 -154
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +181 -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 +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +17 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +51 -40
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +41 -45
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +5 -4
- 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 +26 -16
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +286 -223
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +186 -96
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +292 -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 +22 -14
- 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';
|
|
@@ -19,14 +20,12 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
19
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
20
21
|
import {
|
|
21
22
|
CompleteAddress,
|
|
22
|
-
type ContractClassWithId,
|
|
23
23
|
type ContractInstanceWithAddress,
|
|
24
24
|
type PartialAddress,
|
|
25
25
|
computeContractAddressFromInstance,
|
|
26
26
|
getContractClassFromArtifact,
|
|
27
27
|
} from '@aztec/stdlib/contract';
|
|
28
28
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
29
|
-
import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
30
29
|
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
31
30
|
import type {
|
|
32
31
|
PrivateExecutionStep,
|
|
@@ -34,6 +33,7 @@ import type {
|
|
|
34
33
|
PrivateKernelTailCircuitPublicInputs,
|
|
35
34
|
} from '@aztec/stdlib/kernel';
|
|
36
35
|
import {
|
|
36
|
+
BlockHeader,
|
|
37
37
|
type ContractOverrides,
|
|
38
38
|
type InTx,
|
|
39
39
|
PrivateExecutionResult,
|
|
@@ -47,29 +47,33 @@ import {
|
|
|
47
47
|
TxProfileResult,
|
|
48
48
|
TxProvingResult,
|
|
49
49
|
TxSimulationResult,
|
|
50
|
-
|
|
50
|
+
UtilityExecutionResult,
|
|
51
51
|
} from '@aztec/stdlib/tx';
|
|
52
52
|
|
|
53
53
|
import { inspect } from 'util';
|
|
54
54
|
|
|
55
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
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: AccessScopes;
|
|
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: AccessScopes;
|
|
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: AccessScopes;
|
|
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,8 @@ 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,
|
|
106
165
|
private simulator: CircuitSimulator,
|
|
107
166
|
private proverEnabled: boolean,
|
|
108
167
|
private proofCreator: PrivateKernelProver,
|
|
@@ -120,25 +179,31 @@ export class PXE {
|
|
|
120
179
|
*
|
|
121
180
|
* @returns A promise that resolves PXE is ready to be used.
|
|
122
181
|
*/
|
|
123
|
-
public static async create(
|
|
124
|
-
node
|
|
125
|
-
store
|
|
126
|
-
proofCreator
|
|
127
|
-
simulator
|
|
128
|
-
protocolContractsProvider
|
|
129
|
-
config
|
|
130
|
-
loggerOrSuffix
|
|
131
|
-
) {
|
|
182
|
+
public static async create({
|
|
183
|
+
node,
|
|
184
|
+
store,
|
|
185
|
+
proofCreator,
|
|
186
|
+
simulator,
|
|
187
|
+
protocolContractsProvider,
|
|
188
|
+
config,
|
|
189
|
+
loggerOrSuffix,
|
|
190
|
+
}: PXECreateArgs) {
|
|
191
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
192
|
+
const bindings: LoggerBindings | undefined =
|
|
193
|
+
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
194
|
+
|
|
132
195
|
const log =
|
|
133
196
|
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
134
197
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
135
198
|
: loggerOrSuffix;
|
|
136
199
|
|
|
137
|
-
const
|
|
200
|
+
const info = await node.getNodeInfo();
|
|
201
|
+
|
|
202
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
138
203
|
const addressStore = new AddressStore(store);
|
|
139
204
|
const privateEventStore = new PrivateEventStore(store);
|
|
140
205
|
const contractStore = new ContractStore(store);
|
|
141
|
-
const noteStore =
|
|
206
|
+
const noteStore = new NoteStore(store);
|
|
142
207
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
143
208
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
144
209
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -146,24 +211,43 @@ export class PXE {
|
|
|
146
211
|
const capsuleStore = new CapsuleStore(store);
|
|
147
212
|
const keyStore = new KeyStore(store);
|
|
148
213
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
214
|
+
const contractSyncService = new ContractSyncService(
|
|
215
|
+
node,
|
|
216
|
+
contractStore,
|
|
217
|
+
noteStore,
|
|
218
|
+
createLogger('pxe:contract_sync', bindings),
|
|
219
|
+
);
|
|
220
|
+
const messageContextService = new MessageContextService(node);
|
|
221
|
+
|
|
149
222
|
const synchronizer = new BlockSynchronizer(
|
|
150
223
|
node,
|
|
224
|
+
store,
|
|
151
225
|
anchorBlockStore,
|
|
152
226
|
noteStore,
|
|
153
227
|
privateEventStore,
|
|
154
228
|
tipsStore,
|
|
229
|
+
contractSyncService,
|
|
155
230
|
config,
|
|
156
|
-
|
|
231
|
+
bindings,
|
|
157
232
|
);
|
|
158
233
|
|
|
159
|
-
const jobCoordinator = new JobCoordinator(store);
|
|
234
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
235
|
+
jobCoordinator.registerStores([
|
|
236
|
+
capsuleStore,
|
|
237
|
+
senderTaggingStore,
|
|
238
|
+
recipientTaggingStore,
|
|
239
|
+
privateEventStore,
|
|
240
|
+
noteStore,
|
|
241
|
+
contractSyncService,
|
|
242
|
+
]);
|
|
160
243
|
|
|
161
|
-
const debugUtils = new PXEDebugUtils(
|
|
244
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
162
245
|
|
|
163
246
|
const jobQueue = new SerialQueue();
|
|
164
247
|
|
|
165
248
|
const pxe = new PXE(
|
|
166
249
|
node,
|
|
250
|
+
store,
|
|
167
251
|
synchronizer,
|
|
168
252
|
keyStore,
|
|
169
253
|
contractStore,
|
|
@@ -175,6 +259,8 @@ export class PXE {
|
|
|
175
259
|
recipientTaggingStore,
|
|
176
260
|
addressStore,
|
|
177
261
|
privateEventStore,
|
|
262
|
+
contractSyncService,
|
|
263
|
+
messageContextService,
|
|
178
264
|
simulator,
|
|
179
265
|
proverEnabled,
|
|
180
266
|
proofCreator,
|
|
@@ -185,12 +271,15 @@ export class PXE {
|
|
|
185
271
|
debugUtils,
|
|
186
272
|
);
|
|
187
273
|
|
|
188
|
-
debugUtils.
|
|
274
|
+
debugUtils.setPXEHelpers(
|
|
275
|
+
pxe.#putInJobQueue.bind(pxe),
|
|
276
|
+
pxe.#getSimulatorForTx.bind(pxe),
|
|
277
|
+
pxe.#executeUtility.bind(pxe),
|
|
278
|
+
);
|
|
189
279
|
|
|
190
280
|
pxe.jobQueue.start();
|
|
191
281
|
|
|
192
282
|
await pxe.#registerProtocolContracts();
|
|
193
|
-
const info = await node.getNodeInfo();
|
|
194
283
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
195
284
|
return pxe;
|
|
196
285
|
}
|
|
@@ -200,20 +289,21 @@ export class PXE {
|
|
|
200
289
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
201
290
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
202
291
|
|
|
203
|
-
return new ContractFunctionSimulator(
|
|
204
|
-
proxyContractStore,
|
|
205
|
-
this.noteStore,
|
|
206
|
-
this.keyStore,
|
|
207
|
-
this.addressStore,
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
214
|
-
this.
|
|
215
|
-
this.
|
|
216
|
-
|
|
292
|
+
return new ContractFunctionSimulator({
|
|
293
|
+
contractStore: proxyContractStore,
|
|
294
|
+
noteStore: this.noteStore,
|
|
295
|
+
keyStore: this.keyStore,
|
|
296
|
+
addressStore: this.addressStore,
|
|
297
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
298
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
299
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
300
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
301
|
+
capsuleStore: this.capsuleStore,
|
|
302
|
+
privateEventStore: this.privateEventStore,
|
|
303
|
+
simulator: this.simulator,
|
|
304
|
+
contractSyncService: this.contractSyncService,
|
|
305
|
+
messageContextService: this.messageContextService,
|
|
306
|
+
});
|
|
217
307
|
}
|
|
218
308
|
|
|
219
309
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -265,34 +355,20 @@ export class PXE {
|
|
|
265
355
|
async #registerProtocolContracts() {
|
|
266
356
|
const registered: Record<string, string> = {};
|
|
267
357
|
for (const name of protocolContractNames) {
|
|
268
|
-
const { address,
|
|
269
|
-
|
|
270
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
358
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
359
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
271
360
|
await this.contractStore.addContractInstance(instance);
|
|
272
361
|
registered[name] = address.toString();
|
|
273
362
|
}
|
|
274
363
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
275
364
|
}
|
|
276
365
|
|
|
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
366
|
// Executes the entrypoint private function, as well as all nested private
|
|
291
367
|
// functions that might arise.
|
|
292
368
|
async #executePrivate(
|
|
293
369
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
294
370
|
txRequest: TxExecutionRequest,
|
|
295
|
-
scopes:
|
|
371
|
+
scopes: AccessScopes,
|
|
296
372
|
jobId: string,
|
|
297
373
|
): Promise<PrivateExecutionResult> {
|
|
298
374
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -300,18 +376,23 @@ export class PXE {
|
|
|
300
376
|
try {
|
|
301
377
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
302
378
|
|
|
303
|
-
|
|
304
|
-
txRequest,
|
|
379
|
+
await this.contractSyncService.ensureContractSynced(
|
|
305
380
|
contractAddress,
|
|
306
381
|
functionSelector,
|
|
307
|
-
|
|
382
|
+
(privateSyncCall, execScopes) =>
|
|
383
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
308
384
|
anchorBlockHeader,
|
|
309
|
-
// The sender for tags is set by contracts, typically by an account
|
|
310
|
-
// contract entrypoint
|
|
311
|
-
undefined, // senderForTags
|
|
312
|
-
scopes,
|
|
313
385
|
jobId,
|
|
386
|
+
scopes,
|
|
314
387
|
);
|
|
388
|
+
|
|
389
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
390
|
+
contractAddress,
|
|
391
|
+
selector: functionSelector,
|
|
392
|
+
anchorBlockHeader,
|
|
393
|
+
scopes,
|
|
394
|
+
jobId,
|
|
395
|
+
});
|
|
315
396
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
316
397
|
return result;
|
|
317
398
|
} catch (err) {
|
|
@@ -323,25 +404,32 @@ export class PXE {
|
|
|
323
404
|
}
|
|
324
405
|
|
|
325
406
|
/**
|
|
326
|
-
*
|
|
407
|
+
* Execute a utility function call on the given contract.
|
|
327
408
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
328
409
|
* @param call - The function call to execute.
|
|
329
410
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
330
411
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
331
412
|
* accounts if not specified.
|
|
332
413
|
* @param jobId - The job ID for staged writes.
|
|
333
|
-
* @returns The
|
|
414
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
334
415
|
*/
|
|
335
|
-
async #
|
|
416
|
+
async #executeUtility(
|
|
336
417
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
337
418
|
call: FunctionCall,
|
|
338
419
|
authWitnesses: AuthWitness[] | undefined,
|
|
339
|
-
scopes:
|
|
420
|
+
scopes: AccessScopes,
|
|
340
421
|
jobId: string,
|
|
341
422
|
) {
|
|
342
423
|
try {
|
|
343
424
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
344
|
-
|
|
425
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
|
|
426
|
+
call,
|
|
427
|
+
authWitnesses ?? [],
|
|
428
|
+
anchorBlockHeader,
|
|
429
|
+
scopes,
|
|
430
|
+
jobId,
|
|
431
|
+
);
|
|
432
|
+
return { result, offchainEffects };
|
|
345
433
|
} catch (err) {
|
|
346
434
|
if (err instanceof SimulationError) {
|
|
347
435
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -394,85 +482,45 @@ export class PXE {
|
|
|
394
482
|
privateExecutionResult: PrivateExecutionResult,
|
|
395
483
|
config: PrivateKernelExecutionProverConfig,
|
|
396
484
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
397
|
-
const
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
485
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
486
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
487
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
488
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
489
|
+
kernelOracle,
|
|
490
|
+
proofCreator,
|
|
491
|
+
!this.proverEnabled,
|
|
492
|
+
this.log.getBindings(),
|
|
403
493
|
);
|
|
404
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
405
494
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
406
495
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
407
496
|
}
|
|
408
497
|
|
|
409
498
|
// Public API
|
|
410
499
|
|
|
411
|
-
|
|
412
|
-
|
|
500
|
+
/**
|
|
501
|
+
* Returns the block header up to which the PXE has synced.
|
|
502
|
+
* @returns The synced block header
|
|
503
|
+
*/
|
|
504
|
+
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
505
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
413
506
|
}
|
|
414
507
|
|
|
415
508
|
/**
|
|
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.
|
|
509
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
510
|
+
* @param address - The contract address.
|
|
511
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
428
512
|
*/
|
|
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
|
-
};
|
|
513
|
+
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
514
|
+
return this.contractStore.getContractInstance(address);
|
|
447
515
|
}
|
|
448
516
|
|
|
449
517
|
/**
|
|
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?
|
|
518
|
+
* Returns the contract artifact for a given contract class id, if it's registered in the PXE.
|
|
519
|
+
* @param id - Identifier of the contract class.
|
|
520
|
+
* @returns The contract artifact if found, undefined otherwise.
|
|
459
521
|
*/
|
|
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
|
-
};
|
|
522
|
+
public async getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
|
|
523
|
+
return await this.contractStore.getContractArtifact(id);
|
|
476
524
|
}
|
|
477
525
|
|
|
478
526
|
/**
|
|
@@ -497,7 +545,6 @@ export class PXE {
|
|
|
497
545
|
}
|
|
498
546
|
|
|
499
547
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
500
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
501
548
|
return accountCompleteAddress;
|
|
502
549
|
}
|
|
503
550
|
|
|
@@ -522,6 +569,9 @@ export class PXE {
|
|
|
522
569
|
|
|
523
570
|
if (wasAdded) {
|
|
524
571
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
572
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
573
|
+
// all contracts must re-sync to discover them.
|
|
574
|
+
this.contractSyncService.wipe();
|
|
525
575
|
} else {
|
|
526
576
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
527
577
|
}
|
|
@@ -571,8 +621,7 @@ export class PXE {
|
|
|
571
621
|
* @param artifact - The build artifact for the contract class.
|
|
572
622
|
*/
|
|
573
623
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
574
|
-
const
|
|
575
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
624
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
576
625
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
577
626
|
}
|
|
578
627
|
|
|
@@ -591,17 +640,17 @@ export class PXE {
|
|
|
591
640
|
if (artifact) {
|
|
592
641
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
593
642
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
594
|
-
|
|
595
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
643
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
596
644
|
throw new Error(
|
|
597
|
-
`Artifact does not match expected class id (computed ${
|
|
645
|
+
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
598
646
|
);
|
|
599
647
|
}
|
|
600
648
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
601
649
|
if (!computedAddress.equals(instance.address)) {
|
|
602
650
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
603
651
|
}
|
|
604
|
-
|
|
652
|
+
|
|
653
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
605
654
|
|
|
606
655
|
const publicFunctionSignatures = artifact.functions
|
|
607
656
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -645,26 +694,21 @@ export class PXE {
|
|
|
645
694
|
|
|
646
695
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
647
696
|
|
|
648
|
-
const currentClassId = await readCurrentClassId(
|
|
649
|
-
contractAddress,
|
|
650
|
-
currentInstance,
|
|
651
|
-
this.node,
|
|
652
|
-
header.globalVariables.blockNumber,
|
|
653
|
-
header.globalVariables.timestamp,
|
|
654
|
-
);
|
|
697
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
655
698
|
if (!contractClass.id.equals(currentClassId)) {
|
|
656
699
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
657
700
|
}
|
|
658
701
|
|
|
659
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
660
|
-
|
|
661
702
|
const publicFunctionSignatures = artifact.functions
|
|
662
703
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
663
704
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
664
705
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
665
706
|
|
|
666
707
|
currentInstance.currentContractClassId = contractClass.id;
|
|
667
|
-
await
|
|
708
|
+
await Promise.all([
|
|
709
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
710
|
+
this.contractStore.addContractInstance(currentInstance),
|
|
711
|
+
]);
|
|
668
712
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
669
713
|
});
|
|
670
714
|
}
|
|
@@ -682,11 +726,12 @@ export class PXE {
|
|
|
682
726
|
* (where validators prove the public portion).
|
|
683
727
|
*
|
|
684
728
|
* @param txRequest - An authenticated tx request ready for proving
|
|
729
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
685
730
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
686
731
|
* @throws If contract code not found, or public simulation reverts.
|
|
687
732
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
688
733
|
*/
|
|
689
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
734
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
690
735
|
let privateExecutionResult: PrivateExecutionResult;
|
|
691
736
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
692
737
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -697,7 +742,7 @@ export class PXE {
|
|
|
697
742
|
await this.blockStateSynchronizer.sync();
|
|
698
743
|
const syncTime = syncTimer.ms();
|
|
699
744
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
700
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
745
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
701
746
|
|
|
702
747
|
const {
|
|
703
748
|
publicInputs,
|
|
@@ -739,17 +784,17 @@ export class PXE {
|
|
|
739
784
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
740
785
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
741
786
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
787
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
788
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
744
789
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
745
790
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
746
791
|
|
|
747
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
748
|
-
this.log.debug(`Stored used
|
|
749
|
-
|
|
792
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
793
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
794
|
+
taggingIndexRangesUsedInTheTx,
|
|
750
795
|
});
|
|
751
796
|
} else {
|
|
752
|
-
this.log.debug(`No
|
|
797
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
753
798
|
}
|
|
754
799
|
|
|
755
800
|
return txProvingResult;
|
|
@@ -761,17 +806,13 @@ export class PXE {
|
|
|
761
806
|
|
|
762
807
|
/**
|
|
763
808
|
* 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.
|
|
809
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
768
810
|
* @returns A trace of the program execution with gate counts.
|
|
769
811
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
770
812
|
*/
|
|
771
813
|
public profileTx(
|
|
772
814
|
txRequest: TxExecutionRequest,
|
|
773
|
-
profileMode
|
|
774
|
-
skipProofGeneration: boolean = true,
|
|
815
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
775
816
|
): Promise<TxProfileResult> {
|
|
776
817
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
777
818
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -794,12 +835,7 @@ export class PXE {
|
|
|
794
835
|
const syncTime = syncTimer.ms();
|
|
795
836
|
|
|
796
837
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
797
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
798
|
-
contractFunctionSimulator,
|
|
799
|
-
txRequest,
|
|
800
|
-
undefined,
|
|
801
|
-
jobId,
|
|
802
|
-
);
|
|
838
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
803
839
|
|
|
804
840
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
805
841
|
txRequest,
|
|
@@ -856,12 +892,7 @@ export class PXE {
|
|
|
856
892
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
857
893
|
*
|
|
858
894
|
*
|
|
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.
|
|
895
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
865
896
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
866
897
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
867
898
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
@@ -870,11 +901,14 @@ export class PXE {
|
|
|
870
901
|
*/
|
|
871
902
|
public simulateTx(
|
|
872
903
|
txRequest: TxExecutionRequest,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
904
|
+
{
|
|
905
|
+
simulatePublic,
|
|
906
|
+
skipTxValidation = false,
|
|
907
|
+
skipFeeEnforcement = false,
|
|
908
|
+
skipKernels = true,
|
|
909
|
+
overrides,
|
|
910
|
+
scopes,
|
|
911
|
+
}: SimulateTxOpts,
|
|
878
912
|
): Promise<TxSimulationResult> {
|
|
879
913
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
880
914
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -898,11 +932,21 @@ export class PXE {
|
|
|
898
932
|
await this.blockStateSynchronizer.sync();
|
|
899
933
|
const syncTime = syncTimer.ms();
|
|
900
934
|
|
|
935
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
936
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
937
|
+
|
|
938
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
939
|
+
throw new Error(
|
|
940
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
941
|
+
);
|
|
942
|
+
}
|
|
901
943
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
944
|
+
|
|
945
|
+
if (hasOverriddenContracts) {
|
|
946
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
947
|
+
// We exclude them so the sync service skips them entirely.
|
|
948
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
949
|
+
}
|
|
906
950
|
|
|
907
951
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
908
952
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
@@ -911,15 +955,10 @@ export class PXE {
|
|
|
911
955
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
912
956
|
|
|
913
957
|
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
958
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
920
959
|
privateExecutionResult,
|
|
921
|
-
|
|
922
|
-
this.
|
|
960
|
+
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
961
|
+
this.node,
|
|
923
962
|
));
|
|
924
963
|
} else {
|
|
925
964
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -938,6 +977,9 @@ export class PXE {
|
|
|
938
977
|
const publicSimulationTimer = new Timer();
|
|
939
978
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
940
979
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
980
|
+
if (publicOutput?.debugLogs?.length) {
|
|
981
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
|
|
982
|
+
}
|
|
941
983
|
}
|
|
942
984
|
|
|
943
985
|
let validationTime: number | undefined;
|
|
@@ -946,7 +988,8 @@ export class PXE {
|
|
|
946
988
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
947
989
|
validationTime = validationTimer.ms();
|
|
948
990
|
if (validationResult.result === 'invalid') {
|
|
949
|
-
|
|
991
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
992
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
950
993
|
}
|
|
951
994
|
}
|
|
952
995
|
|
|
@@ -997,29 +1040,23 @@ export class PXE {
|
|
|
997
1040
|
inspect(txRequest),
|
|
998
1041
|
`simulatePublic=${simulatePublic}`,
|
|
999
1042
|
`skipTxValidation=${skipTxValidation}`,
|
|
1000
|
-
`scopes=${scopes
|
|
1043
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1001
1044
|
);
|
|
1002
1045
|
}
|
|
1003
1046
|
});
|
|
1004
1047
|
}
|
|
1005
1048
|
|
|
1006
1049
|
/**
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1050
|
+
* Executes a contract utility function.
|
|
1009
1051
|
* @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
1052
|
*/
|
|
1015
|
-
public
|
|
1053
|
+
public executeUtility(
|
|
1016
1054
|
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.
|
|
1055
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1056
|
+
): Promise<UtilityExecutionResult> {
|
|
1057
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1021
1058
|
// 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
|
|
1059
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1023
1060
|
return this.#putInJobQueue(async jobId => {
|
|
1024
1061
|
try {
|
|
1025
1062
|
const totalTimer = new Timer();
|
|
@@ -1029,11 +1066,18 @@ export class PXE {
|
|
|
1029
1066
|
const functionTimer = new Timer();
|
|
1030
1067
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1031
1068
|
|
|
1032
|
-
await this.
|
|
1033
|
-
|
|
1069
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1070
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1071
|
+
call.to,
|
|
1072
|
+
call.selector,
|
|
1073
|
+
(privateSyncCall, execScopes) =>
|
|
1074
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1075
|
+
anchorBlockHeader,
|
|
1076
|
+
jobId,
|
|
1077
|
+
scopes,
|
|
1034
1078
|
);
|
|
1035
1079
|
|
|
1036
|
-
const executionResult = await this.#
|
|
1080
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(
|
|
1037
1081
|
contractFunctionSimulator,
|
|
1038
1082
|
call,
|
|
1039
1083
|
authwits ?? [],
|
|
@@ -1054,14 +1098,19 @@ export class PXE {
|
|
|
1054
1098
|
};
|
|
1055
1099
|
|
|
1056
1100
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1057
|
-
return {
|
|
1101
|
+
return {
|
|
1102
|
+
result: executionResult,
|
|
1103
|
+
offchainEffects,
|
|
1104
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1105
|
+
stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
|
|
1106
|
+
};
|
|
1058
1107
|
} catch (err: any) {
|
|
1059
1108
|
const { to, name, args } = call;
|
|
1060
1109
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1061
1110
|
throw this.#contextualizeError(
|
|
1062
1111
|
err,
|
|
1063
|
-
`
|
|
1064
|
-
`scopes=${scopes
|
|
1112
|
+
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1113
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1065
1114
|
);
|
|
1066
1115
|
}
|
|
1067
1116
|
});
|
|
@@ -1080,32 +1129,46 @@ export class PXE {
|
|
|
1080
1129
|
* Defaults to the latest known block to PXE + 1.
|
|
1081
1130
|
* @returns - The packed events with block and tx metadata.
|
|
1082
1131
|
*/
|
|
1083
|
-
public getPrivateEvents(
|
|
1084
|
-
|
|
1132
|
+
public async getPrivateEvents(
|
|
1133
|
+
eventSelector: EventSelector,
|
|
1134
|
+
filter: PrivateEventFilter,
|
|
1135
|
+
): Promise<PackedPrivateEvent[]> {
|
|
1136
|
+
let anchorBlockNumber: BlockNumber;
|
|
1137
|
+
|
|
1138
|
+
await this.#putInJobQueue(async jobId => {
|
|
1085
1139
|
await this.blockStateSynchronizer.sync();
|
|
1140
|
+
|
|
1141
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1142
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
1143
|
+
|
|
1086
1144
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1087
1145
|
|
|
1088
|
-
await this.
|
|
1146
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1089
1147
|
filter.contractAddress,
|
|
1090
1148
|
null,
|
|
1091
|
-
async privateSyncCall =>
|
|
1092
|
-
await this.#
|
|
1149
|
+
async (privateSyncCall, execScopes) =>
|
|
1150
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1151
|
+
anchorBlockHeader,
|
|
1152
|
+
jobId,
|
|
1153
|
+
filter.scopes,
|
|
1093
1154
|
);
|
|
1155
|
+
});
|
|
1094
1156
|
|
|
1095
|
-
|
|
1157
|
+
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
1158
|
+
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber!).validate(filter);
|
|
1096
1159
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1160
|
+
this.log.debug(
|
|
1161
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1162
|
+
);
|
|
1100
1163
|
|
|
1101
|
-
|
|
1102
|
-
});
|
|
1164
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1103
1165
|
}
|
|
1104
1166
|
|
|
1105
1167
|
/**
|
|
1106
|
-
* Stops the PXE's job queue.
|
|
1168
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1107
1169
|
*/
|
|
1108
|
-
public stop(): Promise<void> {
|
|
1109
|
-
|
|
1170
|
+
public async stop(): Promise<void> {
|
|
1171
|
+
await this.jobQueue.end();
|
|
1172
|
+
await this.db.close();
|
|
1110
1173
|
}
|
|
1111
1174
|
}
|