@aztec/pxe 0.0.1-commit.6c91f13 → 0.0.1-commit.6d63667d
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 +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +13 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +74 -20
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- 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 +11 -12
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +39 -28
- 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/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- 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 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- 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 +16 -12
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- 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 +11 -9
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +64 -41
- 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 +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -18
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +24 -40
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +38 -24
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +86 -83
- package/dest/contract_sync/contract_sync_service.d.ts +41 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +82 -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 +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -9
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +31 -17
- 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 +22 -7
- 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 +23 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -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 +30 -15
- 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 +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +23 -20
- package/dest/notes/note_service.d.ts +7 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +31 -36
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -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} +13 -7
- 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 +6 -7
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +9 -36
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +87 -97
- 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 +1 -2
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +22 -25
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +51 -52
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +282 -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 +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +231 -73
- 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 +15 -8
- 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 +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +253 -101
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- 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 +46 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
- 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 +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- 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 +5 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- 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 +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -2
- 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 +10 -5
- package/package.json +27 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +93 -32
- package/src/config/index.ts +14 -0
- 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 +46 -32
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +21 -11
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +76 -44
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +41 -49
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +108 -90
- package/src/contract_sync/contract_sync_service.ts +129 -0
- package/src/contract_sync/helpers.ts +93 -0
- package/src/debug/pxe_debug_utils.ts +65 -17
- package/src/entrypoints/client/bundle/utils.ts +15 -16
- package/src/entrypoints/client/lazy/utils.ts +16 -17
- package/src/entrypoints/pxe_creation_options.ts +4 -2
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +26 -34
- package/src/events/event_service.ts +19 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +34 -16
- package/src/notes/note_service.ts +38 -43
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +9 -8
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +156 -132
- 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 +22 -31
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +317 -318
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +301 -79
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +294 -109
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +2 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +21 -7
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
- 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/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 -86
- 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 -133
- 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,
|
|
@@ -54,20 +53,23 @@ import { inspect } from 'util';
|
|
|
54
53
|
|
|
55
54
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
55
|
import type { PXEConfig } from './config/index.js';
|
|
56
|
+
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
57
57
|
import {
|
|
58
58
|
ContractFunctionSimulator,
|
|
59
59
|
generateSimulatedProvingResult,
|
|
60
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
61
|
-
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
62
61
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
62
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
63
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
63
64
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
64
65
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
65
66
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
67
|
+
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
66
68
|
import {
|
|
67
69
|
PrivateKernelExecutionProver,
|
|
68
70
|
type PrivateKernelExecutionProverConfig,
|
|
69
71
|
} from './private_kernel/private_kernel_execution_prover.js';
|
|
70
|
-
import {
|
|
72
|
+
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
71
73
|
import { AddressStore } from './storage/address_store/address_store.js';
|
|
72
74
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
73
75
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
@@ -101,12 +103,14 @@ export class PXE {
|
|
|
101
103
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
102
104
|
private addressStore: AddressStore,
|
|
103
105
|
private privateEventStore: PrivateEventStore,
|
|
106
|
+
private contractSyncService: ContractSyncService,
|
|
104
107
|
private simulator: CircuitSimulator,
|
|
105
108
|
private proverEnabled: boolean,
|
|
106
109
|
private proofCreator: PrivateKernelProver,
|
|
107
110
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
108
111
|
private log: Logger,
|
|
109
112
|
private jobQueue: SerialQueue,
|
|
113
|
+
private jobCoordinator: JobCoordinator,
|
|
110
114
|
public debug: PXEDebugUtils,
|
|
111
115
|
) {}
|
|
112
116
|
|
|
@@ -126,6 +130,10 @@ export class PXE {
|
|
|
126
130
|
config: PXEConfig,
|
|
127
131
|
loggerOrSuffix?: string | Logger,
|
|
128
132
|
) {
|
|
133
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
134
|
+
const bindings: LoggerBindings | undefined =
|
|
135
|
+
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
136
|
+
|
|
129
137
|
const log =
|
|
130
138
|
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
131
139
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
@@ -135,7 +143,7 @@ export class PXE {
|
|
|
135
143
|
const addressStore = new AddressStore(store);
|
|
136
144
|
const privateEventStore = new PrivateEventStore(store);
|
|
137
145
|
const contractStore = new ContractStore(store);
|
|
138
|
-
const noteStore =
|
|
146
|
+
const noteStore = new NoteStore(store);
|
|
139
147
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
140
148
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
141
149
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -143,9 +151,35 @@ export class PXE {
|
|
|
143
151
|
const capsuleStore = new CapsuleStore(store);
|
|
144
152
|
const keyStore = new KeyStore(store);
|
|
145
153
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
146
|
-
const
|
|
154
|
+
const contractSyncService = new ContractSyncService(
|
|
155
|
+
node,
|
|
156
|
+
contractStore,
|
|
157
|
+
noteStore,
|
|
158
|
+
createLogger('pxe:contract_sync', bindings),
|
|
159
|
+
);
|
|
160
|
+
const synchronizer = new BlockSynchronizer(
|
|
161
|
+
node,
|
|
162
|
+
store,
|
|
163
|
+
anchorBlockStore,
|
|
164
|
+
noteStore,
|
|
165
|
+
privateEventStore,
|
|
166
|
+
tipsStore,
|
|
167
|
+
contractSyncService,
|
|
168
|
+
config,
|
|
169
|
+
bindings,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
173
|
+
jobCoordinator.registerStores([
|
|
174
|
+
capsuleStore,
|
|
175
|
+
senderTaggingStore,
|
|
176
|
+
recipientTaggingStore,
|
|
177
|
+
privateEventStore,
|
|
178
|
+
noteStore,
|
|
179
|
+
contractSyncService,
|
|
180
|
+
]);
|
|
147
181
|
|
|
148
|
-
const debugUtils = new PXEDebugUtils(
|
|
182
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
149
183
|
|
|
150
184
|
const jobQueue = new SerialQueue();
|
|
151
185
|
|
|
@@ -162,16 +196,22 @@ export class PXE {
|
|
|
162
196
|
recipientTaggingStore,
|
|
163
197
|
addressStore,
|
|
164
198
|
privateEventStore,
|
|
199
|
+
contractSyncService,
|
|
165
200
|
simulator,
|
|
166
201
|
proverEnabled,
|
|
167
202
|
proofCreator,
|
|
168
203
|
protocolContractsProvider,
|
|
169
204
|
log,
|
|
170
205
|
jobQueue,
|
|
206
|
+
jobCoordinator,
|
|
171
207
|
debugUtils,
|
|
172
208
|
);
|
|
173
209
|
|
|
174
|
-
debugUtils.
|
|
210
|
+
debugUtils.setPXEHelpers(
|
|
211
|
+
pxe.#putInJobQueue.bind(pxe),
|
|
212
|
+
pxe.#getSimulatorForTx.bind(pxe),
|
|
213
|
+
pxe.#simulateUtility.bind(pxe),
|
|
214
|
+
);
|
|
175
215
|
|
|
176
216
|
pxe.jobQueue.start();
|
|
177
217
|
|
|
@@ -191,14 +231,14 @@ export class PXE {
|
|
|
191
231
|
this.noteStore,
|
|
192
232
|
this.keyStore,
|
|
193
233
|
this.addressStore,
|
|
194
|
-
this.node,
|
|
195
|
-
this.anchorBlockStore,
|
|
234
|
+
BenchmarkedNodeFactory.create(this.node),
|
|
196
235
|
this.senderTaggingStore,
|
|
197
236
|
this.recipientTaggingStore,
|
|
198
237
|
this.senderAddressBookStore,
|
|
199
238
|
this.capsuleStore,
|
|
200
239
|
this.privateEventStore,
|
|
201
240
|
this.simulator,
|
|
241
|
+
this.contractSyncService,
|
|
202
242
|
);
|
|
203
243
|
}
|
|
204
244
|
|
|
@@ -222,7 +262,7 @@ export class PXE {
|
|
|
222
262
|
*
|
|
223
263
|
* Useful for tasks that cannot run concurrently, such as contract function simulation.
|
|
224
264
|
*/
|
|
225
|
-
#putInJobQueue<T>(fn: () => Promise<T>): Promise<T> {
|
|
265
|
+
#putInJobQueue<T>(fn: (jobId: string) => Promise<T>): Promise<T> {
|
|
226
266
|
// TODO(#12636): relax the conditions under which we forbid concurrency.
|
|
227
267
|
if (this.jobQueue.length() != 0) {
|
|
228
268
|
this.log.warn(
|
|
@@ -230,7 +270,22 @@ export class PXE {
|
|
|
230
270
|
);
|
|
231
271
|
}
|
|
232
272
|
|
|
233
|
-
return this.jobQueue.put(
|
|
273
|
+
return this.jobQueue.put(async () => {
|
|
274
|
+
const jobId = this.jobCoordinator.beginJob();
|
|
275
|
+
this.log.verbose(`Beginning job ${jobId}`);
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
const result = await fn(jobId);
|
|
279
|
+
this.log.verbose(`Committing job ${jobId}`);
|
|
280
|
+
|
|
281
|
+
await this.jobCoordinator.commitJob(jobId);
|
|
282
|
+
return result;
|
|
283
|
+
} catch (err) {
|
|
284
|
+
this.log.verbose(`Aborting job ${jobId}`);
|
|
285
|
+
await this.jobCoordinator.abortJob(jobId);
|
|
286
|
+
throw err;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
234
289
|
}
|
|
235
290
|
|
|
236
291
|
async #registerProtocolContracts() {
|
|
@@ -245,31 +300,27 @@ export class PXE {
|
|
|
245
300
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
246
301
|
}
|
|
247
302
|
|
|
248
|
-
async #isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
|
|
249
|
-
return !!(await this.node.getContractClass(id));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async #isContractPublished(address: AztecAddress): Promise<boolean> {
|
|
253
|
-
return !!(await this.node.getContract(address));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async #isContractInitialized(address: AztecAddress): Promise<boolean> {
|
|
257
|
-
const initNullifier = await siloNullifier(address, address.toField());
|
|
258
|
-
return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
303
|
// Executes the entrypoint private function, as well as all nested private
|
|
262
304
|
// functions that might arise.
|
|
263
305
|
async #executePrivate(
|
|
264
306
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
265
307
|
txRequest: TxExecutionRequest,
|
|
266
|
-
scopes
|
|
308
|
+
scopes: AztecAddress[] | undefined,
|
|
309
|
+
jobId: string,
|
|
267
310
|
): Promise<PrivateExecutionResult> {
|
|
268
311
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
269
312
|
|
|
270
313
|
try {
|
|
271
314
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
272
315
|
|
|
316
|
+
await this.contractSyncService.ensureContractSynced(
|
|
317
|
+
contractAddress,
|
|
318
|
+
functionSelector,
|
|
319
|
+
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
320
|
+
anchorBlockHeader,
|
|
321
|
+
jobId,
|
|
322
|
+
);
|
|
323
|
+
|
|
273
324
|
const result = await contractFunctionSimulator.run(
|
|
274
325
|
txRequest,
|
|
275
326
|
contractAddress,
|
|
@@ -280,6 +331,7 @@ export class PXE {
|
|
|
280
331
|
// contract entrypoint
|
|
281
332
|
undefined, // senderForTags
|
|
282
333
|
scopes,
|
|
334
|
+
jobId,
|
|
283
335
|
);
|
|
284
336
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
285
337
|
return result;
|
|
@@ -298,17 +350,19 @@ export class PXE {
|
|
|
298
350
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
299
351
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
300
352
|
* accounts if not specified.
|
|
353
|
+
* @param jobId - The job ID for staged writes.
|
|
301
354
|
* @returns The simulation result containing the outputs of the utility function.
|
|
302
355
|
*/
|
|
303
356
|
async #simulateUtility(
|
|
304
357
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
305
358
|
call: FunctionCall,
|
|
306
|
-
authWitnesses
|
|
307
|
-
scopes
|
|
359
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
360
|
+
scopes: AztecAddress[] | undefined,
|
|
361
|
+
jobId: string,
|
|
308
362
|
) {
|
|
309
363
|
try {
|
|
310
364
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
311
|
-
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
|
|
365
|
+
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
312
366
|
} catch (err) {
|
|
313
367
|
if (err instanceof SimulationError) {
|
|
314
368
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -361,14 +415,15 @@ export class PXE {
|
|
|
361
415
|
privateExecutionResult: PrivateExecutionResult,
|
|
362
416
|
config: PrivateKernelExecutionProverConfig,
|
|
363
417
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
364
|
-
const
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
418
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
419
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
420
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
421
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
422
|
+
kernelOracle,
|
|
423
|
+
proofCreator,
|
|
424
|
+
!this.proverEnabled,
|
|
425
|
+
this.log.getBindings(),
|
|
370
426
|
);
|
|
371
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
372
427
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
373
428
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
374
429
|
}
|
|
@@ -380,66 +435,12 @@ export class PXE {
|
|
|
380
435
|
}
|
|
381
436
|
|
|
382
437
|
/**
|
|
383
|
-
* Returns the contract
|
|
384
|
-
*
|
|
385
|
-
* @
|
|
386
|
-
* @param id - Identifier of the class.
|
|
387
|
-
* @param includeArtifact - Identifier of the class.
|
|
388
|
-
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
389
|
-
* for `includeArtifact`
|
|
390
|
-
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
391
|
-
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
392
|
-
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
393
|
-
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
394
|
-
* do for the time being.
|
|
395
|
-
*/
|
|
396
|
-
public async getContractClassMetadata(
|
|
397
|
-
id: Fr,
|
|
398
|
-
includeArtifact: boolean = false,
|
|
399
|
-
): Promise<{
|
|
400
|
-
contractClass: ContractClassWithId | undefined;
|
|
401
|
-
isContractClassPubliclyRegistered: boolean;
|
|
402
|
-
artifact: ContractArtifact | undefined;
|
|
403
|
-
}> {
|
|
404
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
405
|
-
if (!artifact) {
|
|
406
|
-
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return {
|
|
410
|
-
contractClass: artifact && (await getContractClassFromArtifact(artifact)),
|
|
411
|
-
isContractClassPubliclyRegistered: await this.#isContractClassPubliclyRegistered(id),
|
|
412
|
-
artifact: includeArtifact ? artifact : undefined,
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Returns the contract metadata given an address.
|
|
418
|
-
* The metadata consists of its contract instance, which includes the contract class identifier,
|
|
419
|
-
* initialization hash, deployment salt, and public keys hash; whether the contract instance has been initialized;
|
|
420
|
-
* and whether the contract instance with the given address has been publicly deployed.
|
|
421
|
-
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
422
|
-
* This query is not dependent on the PXE.
|
|
423
|
-
* @param address - The address that the contract instance resides at.
|
|
424
|
-
* @returns - It returns the contract metadata
|
|
425
|
-
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
438
|
+
* Returns the contract artifact for a given contract class id, if it's registered in the PXE.
|
|
439
|
+
* @param id - Identifier of the contract class.
|
|
440
|
+
* @returns The contract artifact if found, undefined otherwise.
|
|
426
441
|
*/
|
|
427
|
-
public async
|
|
428
|
-
|
|
429
|
-
isContractInitialized: boolean;
|
|
430
|
-
isContractPublished: boolean;
|
|
431
|
-
}> {
|
|
432
|
-
let instance;
|
|
433
|
-
try {
|
|
434
|
-
instance = await this.contractStore.getContractInstance(address);
|
|
435
|
-
} catch {
|
|
436
|
-
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
437
|
-
}
|
|
438
|
-
return {
|
|
439
|
-
contractInstance: instance,
|
|
440
|
-
isContractInitialized: await this.#isContractInitialized(address),
|
|
441
|
-
isContractPublished: await this.#isContractPublished(address),
|
|
442
|
-
};
|
|
442
|
+
public async getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
|
|
443
|
+
return await this.contractStore.getContractArtifact(id);
|
|
443
444
|
}
|
|
444
445
|
|
|
445
446
|
/**
|
|
@@ -464,7 +465,6 @@ export class PXE {
|
|
|
464
465
|
}
|
|
465
466
|
|
|
466
467
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
467
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
468
468
|
return accountCompleteAddress;
|
|
469
469
|
}
|
|
470
470
|
|
|
@@ -612,13 +612,7 @@ export class PXE {
|
|
|
612
612
|
|
|
613
613
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
614
614
|
|
|
615
|
-
const currentClassId = await readCurrentClassId(
|
|
616
|
-
contractAddress,
|
|
617
|
-
currentInstance,
|
|
618
|
-
this.node,
|
|
619
|
-
header.globalVariables.blockNumber,
|
|
620
|
-
header.globalVariables.timestamp,
|
|
621
|
-
);
|
|
615
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
622
616
|
if (!contractClass.id.equals(currentClassId)) {
|
|
623
617
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
624
618
|
}
|
|
@@ -657,14 +651,14 @@ export class PXE {
|
|
|
657
651
|
let privateExecutionResult: PrivateExecutionResult;
|
|
658
652
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
659
653
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
660
|
-
return this.#putInJobQueue(async
|
|
654
|
+
return this.#putInJobQueue(async jobId => {
|
|
661
655
|
const totalTimer = new Timer();
|
|
662
656
|
try {
|
|
663
657
|
const syncTimer = new Timer();
|
|
664
658
|
await this.blockStateSynchronizer.sync();
|
|
665
659
|
const syncTime = syncTimer.ms();
|
|
666
660
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
667
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
661
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
|
|
668
662
|
|
|
669
663
|
const {
|
|
670
664
|
publicInputs,
|
|
@@ -711,7 +705,7 @@ export class PXE {
|
|
|
711
705
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
712
706
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
713
707
|
|
|
714
|
-
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash);
|
|
708
|
+
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash, jobId);
|
|
715
709
|
this.log.debug(`Stored used pre-tags as sender for the tx`, {
|
|
716
710
|
preTagsUsedInTheTx,
|
|
717
711
|
});
|
|
@@ -741,7 +735,7 @@ export class PXE {
|
|
|
741
735
|
skipProofGeneration: boolean = true,
|
|
742
736
|
): Promise<TxProfileResult> {
|
|
743
737
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
744
|
-
return this.#putInJobQueue(async
|
|
738
|
+
return this.#putInJobQueue(async jobId => {
|
|
745
739
|
const totalTimer = new Timer();
|
|
746
740
|
try {
|
|
747
741
|
const txInfo = {
|
|
@@ -761,7 +755,12 @@ export class PXE {
|
|
|
761
755
|
const syncTime = syncTimer.ms();
|
|
762
756
|
|
|
763
757
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
764
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
758
|
+
const privateExecutionResult = await this.#executePrivate(
|
|
759
|
+
contractFunctionSimulator,
|
|
760
|
+
txRequest,
|
|
761
|
+
undefined,
|
|
762
|
+
jobId,
|
|
763
|
+
);
|
|
765
764
|
|
|
766
765
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
767
766
|
txRequest,
|
|
@@ -841,7 +840,7 @@ export class PXE {
|
|
|
841
840
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
842
841
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
843
842
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
844
|
-
return this.#putInJobQueue(async
|
|
843
|
+
return this.#putInJobQueue(async jobId => {
|
|
845
844
|
try {
|
|
846
845
|
const totalTimer = new Timer();
|
|
847
846
|
const txInfo = {
|
|
@@ -864,23 +863,24 @@ export class PXE {
|
|
|
864
863
|
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
865
864
|
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
866
865
|
// or not.
|
|
867
|
-
const
|
|
866
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
867
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
868
|
+
const skipKernels = hasOverriddenContracts;
|
|
869
|
+
|
|
870
|
+
// Set overridden contracts on the sync service so it knows to skip syncing them
|
|
871
|
+
if (hasOverriddenContracts) {
|
|
872
|
+
this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
|
|
873
|
+
}
|
|
868
874
|
|
|
869
875
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
870
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes);
|
|
876
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
871
877
|
|
|
872
878
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
873
879
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
874
880
|
|
|
875
881
|
if (skipKernels) {
|
|
876
|
-
// According to the protocol rules, the nonce generator for the note hashes
|
|
877
|
-
// can either be the first nullifier in the tx or the protocol nullifier if there are none.
|
|
878
|
-
const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO)
|
|
879
|
-
? await computeProtocolNullifier(await txRequest.toTxRequest().hash())
|
|
880
|
-
: privateExecutionResult.firstNullifier;
|
|
881
882
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
882
883
|
privateExecutionResult,
|
|
883
|
-
nonceGenerator,
|
|
884
884
|
this.contractStore,
|
|
885
885
|
));
|
|
886
886
|
} else {
|
|
@@ -982,7 +982,7 @@ export class PXE {
|
|
|
982
982
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
983
983
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
984
984
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
985
|
-
return this.#putInJobQueue(async
|
|
985
|
+
return this.#putInJobQueue(async jobId => {
|
|
986
986
|
try {
|
|
987
987
|
const totalTimer = new Timer();
|
|
988
988
|
const syncTimer = new Timer();
|
|
@@ -991,11 +991,22 @@ export class PXE {
|
|
|
991
991
|
const functionTimer = new Timer();
|
|
992
992
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
993
993
|
|
|
994
|
-
await this.
|
|
995
|
-
|
|
994
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
995
|
+
await this.contractSyncService.ensureContractSynced(
|
|
996
|
+
call.to,
|
|
997
|
+
call.selector,
|
|
998
|
+
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
999
|
+
anchorBlockHeader,
|
|
1000
|
+
jobId,
|
|
996
1001
|
);
|
|
997
1002
|
|
|
998
|
-
const executionResult = await this.#simulateUtility(
|
|
1003
|
+
const executionResult = await this.#simulateUtility(
|
|
1004
|
+
contractFunctionSimulator,
|
|
1005
|
+
call,
|
|
1006
|
+
authwits ?? [],
|
|
1007
|
+
scopes,
|
|
1008
|
+
jobId,
|
|
1009
|
+
);
|
|
999
1010
|
const functionTime = functionTimer.ms();
|
|
1000
1011
|
|
|
1001
1012
|
const totalTime = totalTimer.ms();
|
|
@@ -1036,25 +1047,38 @@ export class PXE {
|
|
|
1036
1047
|
* Defaults to the latest known block to PXE + 1.
|
|
1037
1048
|
* @returns - The packed events with block and tx metadata.
|
|
1038
1049
|
*/
|
|
1039
|
-
public getPrivateEvents(
|
|
1040
|
-
|
|
1050
|
+
public async getPrivateEvents(
|
|
1051
|
+
eventSelector: EventSelector,
|
|
1052
|
+
filter: PrivateEventFilter,
|
|
1053
|
+
): Promise<PackedPrivateEvent[]> {
|
|
1054
|
+
let anchorBlockNumber: BlockNumber;
|
|
1055
|
+
|
|
1056
|
+
await this.#putInJobQueue(async jobId => {
|
|
1041
1057
|
await this.blockStateSynchronizer.sync();
|
|
1058
|
+
|
|
1059
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1060
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
1061
|
+
|
|
1042
1062
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1043
1063
|
|
|
1044
|
-
await this.
|
|
1064
|
+
await this.contractSyncService.ensureContractSynced(
|
|
1045
1065
|
filter.contractAddress,
|
|
1046
1066
|
null,
|
|
1047
|
-
async privateSyncCall =>
|
|
1067
|
+
async privateSyncCall =>
|
|
1068
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
1069
|
+
anchorBlockHeader,
|
|
1070
|
+
jobId,
|
|
1048
1071
|
);
|
|
1072
|
+
});
|
|
1049
1073
|
|
|
1050
|
-
|
|
1074
|
+
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
1075
|
+
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber!).validate(filter);
|
|
1051
1076
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1077
|
+
this.log.debug(
|
|
1078
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1079
|
+
);
|
|
1055
1080
|
|
|
1056
|
-
|
|
1057
|
-
});
|
|
1081
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1058
1082
|
}
|
|
1059
1083
|
|
|
1060
1084
|
/**
|
|
@@ -43,23 +43,23 @@ export class AddressStore {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async #getCompleteAddress(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
47
|
-
const index = await this.#completeAddressIndex.getAsync(address.toString());
|
|
48
|
-
if (index === undefined) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const value = await this.#completeAddresses.atAsync(index);
|
|
53
|
-
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
46
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
57
|
-
return this.#
|
|
47
|
+
return this.#store.transactionAsync(async () => {
|
|
48
|
+
const index = await this.#completeAddressIndex.getAsync(account.toString());
|
|
49
|
+
if (index === undefined) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const value = await this.#completeAddresses.atAsync(index);
|
|
54
|
+
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
55
|
+
});
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
getCompleteAddresses(): Promise<CompleteAddress[]> {
|
|
59
|
+
return this.#store.transactionAsync(async () => {
|
|
60
|
+
return await Promise.all(
|
|
61
|
+
(await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -10,6 +10,14 @@ export class AnchorBlockStore {
|
|
|
10
10
|
this.#synchronizedHeader = this.#store.openSingleton('header');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Sets the currently synchronized block
|
|
15
|
+
*
|
|
16
|
+
* Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
|
|
17
|
+
* stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
|
|
18
|
+
* deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
13
21
|
async setHeader(header: BlockHeader): Promise<void> {
|
|
14
22
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
15
23
|
}
|