@aztec/pxe 4.0.0-nightly.20260108 → 4.0.0-nightly.20260110
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/contract_function_simulator/contract_function_simulator.d.ts +4 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +7 -6
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- 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 +5 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +3 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +4 -2
- package/dest/events/event_service.d.ts +2 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +2 -2
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/pxe.d.ts +2 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +38 -19
- package/dest/storage/private_event_store/private_event_store.d.ts +2 -2
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +2 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +1 -1
- 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/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
- package/package.json +16 -16
- package/src/contract_function_simulator/contract_function_simulator.ts +10 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +4 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +3 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +2 -0
- package/src/events/event_service.ts +2 -0
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/pxe.ts +55 -18
- package/src/storage/private_event_store/private_event_store.ts +3 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +1 -1
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/index.ts +1 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface that stores must implement to support staged writes.
|
|
7
|
+
*/
|
|
8
|
+
export interface StagedStore {
|
|
9
|
+
/** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
|
|
10
|
+
readonly storeName: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Commits staged data to main storage.
|
|
14
|
+
* Should be called within a transaction for atomicity.
|
|
15
|
+
*
|
|
16
|
+
* @param jobId - The job identifier
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Discards staged data without committing.
|
|
22
|
+
* Called on abort.
|
|
23
|
+
*
|
|
24
|
+
* @param jobId - The job identifier
|
|
25
|
+
*/
|
|
26
|
+
discardStaged(jobId: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
|
|
31
|
+
*
|
|
32
|
+
* It uses a staged writes pattern:
|
|
33
|
+
* 1. When a job begins, a unique job ID is created
|
|
34
|
+
* 2. During the job, all writes go to staging (keyed by job ID)
|
|
35
|
+
* 3. On commit, staging is promoted to main storage
|
|
36
|
+
* 4. On abort, staged data is discarded
|
|
37
|
+
*
|
|
38
|
+
* Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
|
|
39
|
+
* orchestrate concurrent jobs. Right now it doesn't make a difference because we're
|
|
40
|
+
* using a job queue with concurrency=1.
|
|
41
|
+
*/
|
|
42
|
+
export class JobCoordinator {
|
|
43
|
+
private readonly log = createLogger('pxe:job_coordinator');
|
|
44
|
+
|
|
45
|
+
/** The underlying KV store */
|
|
46
|
+
kvStore: AztecAsyncKVStore;
|
|
47
|
+
|
|
48
|
+
#currentJobId: string | undefined;
|
|
49
|
+
#stores: Map<string, StagedStore> = new Map();
|
|
50
|
+
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore) {
|
|
52
|
+
this.kvStore = kvStore;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Registers a staged store.
|
|
57
|
+
* Must be called during initialization for all stores that need staging support.
|
|
58
|
+
*/
|
|
59
|
+
registerStore(store: StagedStore): void {
|
|
60
|
+
if (this.#stores.has(store.storeName)) {
|
|
61
|
+
throw new Error(`Store "${store.storeName}" is already registered`);
|
|
62
|
+
}
|
|
63
|
+
this.#stores.set(store.storeName, store);
|
|
64
|
+
this.log.debug(`Registered staged store: ${store.storeName}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Registers multiple staged stores.
|
|
69
|
+
*/
|
|
70
|
+
registerStores(stores: StagedStore[]): void {
|
|
71
|
+
for (const store of stores) {
|
|
72
|
+
this.registerStore(store);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Begins a new job and returns a job ID for staged writes.
|
|
78
|
+
*
|
|
79
|
+
* @returns Job ID to pass to store operations
|
|
80
|
+
*/
|
|
81
|
+
beginJob(): string {
|
|
82
|
+
if (this.#currentJobId) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Cannot begin job: job ${this.#currentJobId} is already in progress. ` +
|
|
85
|
+
`This should not happen - ensure jobs are properly committed or aborted.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const jobId = randomBytes(8).toString('hex');
|
|
90
|
+
this.#currentJobId = jobId;
|
|
91
|
+
|
|
92
|
+
this.log.debug(`Started job ${jobId}`);
|
|
93
|
+
return jobId;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Commits a job by promoting all staged data to main storage.
|
|
98
|
+
*
|
|
99
|
+
* @param jobId - The job ID returned from beginJob
|
|
100
|
+
*/
|
|
101
|
+
async commitJob(jobId: string): Promise<void> {
|
|
102
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.log.debug(`Committing job ${jobId}`);
|
|
109
|
+
|
|
110
|
+
// Commit all stores atomically in a single transaction.
|
|
111
|
+
// Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
|
|
112
|
+
await this.kvStore.transactionAsync(async () => {
|
|
113
|
+
for (const store of this.#stores.values()) {
|
|
114
|
+
await store.commit(jobId);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.#currentJobId = undefined;
|
|
119
|
+
this.log.debug(`Job ${jobId} committed successfully`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Aborts a job by discarding all staged data.
|
|
124
|
+
*
|
|
125
|
+
* @param jobId - The job ID returned from beginJob
|
|
126
|
+
*/
|
|
127
|
+
async abortJob(jobId: string): Promise<void> {
|
|
128
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
129
|
+
// Job may have already been aborted or never started properly
|
|
130
|
+
this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.log.debug(`Aborting job ${jobId}`);
|
|
134
|
+
|
|
135
|
+
for (const store of this.#stores.values()) {
|
|
136
|
+
await store.discardStaged(jobId);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.#currentJobId = undefined;
|
|
140
|
+
this.log.debug(`Job ${jobId} aborted`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Checks if there's a job currently in progress.
|
|
145
|
+
*/
|
|
146
|
+
hasJobInProgress(): boolean {
|
|
147
|
+
return this.#currentJobId !== undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
package/src/pxe.ts
CHANGED
|
@@ -60,9 +60,11 @@ import {
|
|
|
60
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
61
61
|
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
62
62
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
|
+
import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.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,
|
|
@@ -107,6 +109,7 @@ export class PXE {
|
|
|
107
109
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
108
110
|
private log: Logger,
|
|
109
111
|
private jobQueue: SerialQueue,
|
|
112
|
+
private jobCoordinator: JobCoordinator,
|
|
110
113
|
public debug: PXEDebugUtils,
|
|
111
114
|
) {}
|
|
112
115
|
|
|
@@ -153,6 +156,8 @@ export class PXE {
|
|
|
153
156
|
loggerOrSuffix,
|
|
154
157
|
);
|
|
155
158
|
|
|
159
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
160
|
+
|
|
156
161
|
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
157
162
|
|
|
158
163
|
const jobQueue = new SerialQueue();
|
|
@@ -176,6 +181,7 @@ export class PXE {
|
|
|
176
181
|
protocolContractsProvider,
|
|
177
182
|
log,
|
|
178
183
|
jobQueue,
|
|
184
|
+
jobCoordinator,
|
|
179
185
|
debugUtils,
|
|
180
186
|
);
|
|
181
187
|
|
|
@@ -199,7 +205,7 @@ export class PXE {
|
|
|
199
205
|
this.noteStore,
|
|
200
206
|
this.keyStore,
|
|
201
207
|
this.addressStore,
|
|
202
|
-
this.node,
|
|
208
|
+
ProxiedNodeFactory.create(this.node),
|
|
203
209
|
this.anchorBlockStore,
|
|
204
210
|
this.senderTaggingStore,
|
|
205
211
|
this.recipientTaggingStore,
|
|
@@ -230,7 +236,7 @@ export class PXE {
|
|
|
230
236
|
*
|
|
231
237
|
* Useful for tasks that cannot run concurrently, such as contract function simulation.
|
|
232
238
|
*/
|
|
233
|
-
#putInJobQueue<T>(fn: () => Promise<T>): Promise<T> {
|
|
239
|
+
#putInJobQueue<T>(fn: (jobId: string) => Promise<T>): Promise<T> {
|
|
234
240
|
// TODO(#12636): relax the conditions under which we forbid concurrency.
|
|
235
241
|
if (this.jobQueue.length() != 0) {
|
|
236
242
|
this.log.warn(
|
|
@@ -238,7 +244,22 @@ export class PXE {
|
|
|
238
244
|
);
|
|
239
245
|
}
|
|
240
246
|
|
|
241
|
-
return this.jobQueue.put(
|
|
247
|
+
return this.jobQueue.put(async () => {
|
|
248
|
+
const jobId = this.jobCoordinator.beginJob();
|
|
249
|
+
this.log.verbose(`Beginning job ${jobId}`);
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
const result = await fn(jobId);
|
|
253
|
+
this.log.verbose(`Committing job ${jobId}`);
|
|
254
|
+
|
|
255
|
+
await this.jobCoordinator.commitJob(jobId);
|
|
256
|
+
return result;
|
|
257
|
+
} catch (err) {
|
|
258
|
+
this.log.verbose(`Aborting job ${jobId}`);
|
|
259
|
+
await this.jobCoordinator.abortJob(jobId);
|
|
260
|
+
throw err;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
242
263
|
}
|
|
243
264
|
|
|
244
265
|
async #registerProtocolContracts() {
|
|
@@ -271,7 +292,8 @@ export class PXE {
|
|
|
271
292
|
async #executePrivate(
|
|
272
293
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
273
294
|
txRequest: TxExecutionRequest,
|
|
274
|
-
scopes
|
|
295
|
+
scopes: AztecAddress[] | undefined,
|
|
296
|
+
jobId: string,
|
|
275
297
|
): Promise<PrivateExecutionResult> {
|
|
276
298
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
277
299
|
|
|
@@ -288,6 +310,7 @@ export class PXE {
|
|
|
288
310
|
// contract entrypoint
|
|
289
311
|
undefined, // senderForTags
|
|
290
312
|
scopes,
|
|
313
|
+
jobId,
|
|
291
314
|
);
|
|
292
315
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
293
316
|
return result;
|
|
@@ -306,17 +329,19 @@ export class PXE {
|
|
|
306
329
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
307
330
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
308
331
|
* accounts if not specified.
|
|
332
|
+
* @param jobId - The job ID for staged writes.
|
|
309
333
|
* @returns The simulation result containing the outputs of the utility function.
|
|
310
334
|
*/
|
|
311
335
|
async #simulateUtility(
|
|
312
336
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
313
337
|
call: FunctionCall,
|
|
314
|
-
authWitnesses
|
|
315
|
-
scopes
|
|
338
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
339
|
+
scopes: AztecAddress[] | undefined,
|
|
340
|
+
jobId: string,
|
|
316
341
|
) {
|
|
317
342
|
try {
|
|
318
343
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
319
|
-
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
|
|
344
|
+
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
320
345
|
} catch (err) {
|
|
321
346
|
if (err instanceof SimulationError) {
|
|
322
347
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -665,14 +690,14 @@ export class PXE {
|
|
|
665
690
|
let privateExecutionResult: PrivateExecutionResult;
|
|
666
691
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
667
692
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
668
|
-
return this.#putInJobQueue(async
|
|
693
|
+
return this.#putInJobQueue(async jobId => {
|
|
669
694
|
const totalTimer = new Timer();
|
|
670
695
|
try {
|
|
671
696
|
const syncTimer = new Timer();
|
|
672
697
|
await this.blockStateSynchronizer.sync();
|
|
673
698
|
const syncTime = syncTimer.ms();
|
|
674
699
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
675
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
700
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
|
|
676
701
|
|
|
677
702
|
const {
|
|
678
703
|
publicInputs,
|
|
@@ -749,7 +774,7 @@ export class PXE {
|
|
|
749
774
|
skipProofGeneration: boolean = true,
|
|
750
775
|
): Promise<TxProfileResult> {
|
|
751
776
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
752
|
-
return this.#putInJobQueue(async
|
|
777
|
+
return this.#putInJobQueue(async jobId => {
|
|
753
778
|
const totalTimer = new Timer();
|
|
754
779
|
try {
|
|
755
780
|
const txInfo = {
|
|
@@ -769,7 +794,12 @@ export class PXE {
|
|
|
769
794
|
const syncTime = syncTimer.ms();
|
|
770
795
|
|
|
771
796
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
772
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
797
|
+
const privateExecutionResult = await this.#executePrivate(
|
|
798
|
+
contractFunctionSimulator,
|
|
799
|
+
txRequest,
|
|
800
|
+
undefined,
|
|
801
|
+
jobId,
|
|
802
|
+
);
|
|
773
803
|
|
|
774
804
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
775
805
|
txRequest,
|
|
@@ -849,7 +879,7 @@ export class PXE {
|
|
|
849
879
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
850
880
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
851
881
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
852
|
-
return this.#putInJobQueue(async
|
|
882
|
+
return this.#putInJobQueue(async jobId => {
|
|
853
883
|
try {
|
|
854
884
|
const totalTimer = new Timer();
|
|
855
885
|
const txInfo = {
|
|
@@ -875,7 +905,7 @@ export class PXE {
|
|
|
875
905
|
const skipKernels = overrides?.contracts !== undefined && Object.keys(overrides.contracts ?? {}).length > 0;
|
|
876
906
|
|
|
877
907
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
878
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes);
|
|
908
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
879
909
|
|
|
880
910
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
881
911
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
@@ -990,7 +1020,7 @@ export class PXE {
|
|
|
990
1020
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
991
1021
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
992
1022
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
993
|
-
return this.#putInJobQueue(async
|
|
1023
|
+
return this.#putInJobQueue(async jobId => {
|
|
994
1024
|
try {
|
|
995
1025
|
const totalTimer = new Timer();
|
|
996
1026
|
const syncTimer = new Timer();
|
|
@@ -1000,10 +1030,16 @@ export class PXE {
|
|
|
1000
1030
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1001
1031
|
|
|
1002
1032
|
await this.contractStore.syncPrivateState(call.to, call.selector, privateSyncCall =>
|
|
1003
|
-
this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1033
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
1004
1034
|
);
|
|
1005
1035
|
|
|
1006
|
-
const executionResult = await this.#simulateUtility(
|
|
1036
|
+
const executionResult = await this.#simulateUtility(
|
|
1037
|
+
contractFunctionSimulator,
|
|
1038
|
+
call,
|
|
1039
|
+
authwits ?? [],
|
|
1040
|
+
scopes,
|
|
1041
|
+
jobId,
|
|
1042
|
+
);
|
|
1007
1043
|
const functionTime = functionTimer.ms();
|
|
1008
1044
|
|
|
1009
1045
|
const totalTime = totalTimer.ms();
|
|
@@ -1045,14 +1081,15 @@ export class PXE {
|
|
|
1045
1081
|
* @returns - The packed events with block and tx metadata.
|
|
1046
1082
|
*/
|
|
1047
1083
|
public getPrivateEvents(eventSelector: EventSelector, filter: PrivateEventFilter): Promise<PackedPrivateEvent[]> {
|
|
1048
|
-
return this.#putInJobQueue(async
|
|
1084
|
+
return this.#putInJobQueue(async jobId => {
|
|
1049
1085
|
await this.blockStateSynchronizer.sync();
|
|
1050
1086
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1051
1087
|
|
|
1052
1088
|
await this.contractStore.syncPrivateState(
|
|
1053
1089
|
filter.contractAddress,
|
|
1054
1090
|
null,
|
|
1055
|
-
async privateSyncCall =>
|
|
1091
|
+
async privateSyncCall =>
|
|
1092
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
1056
1093
|
);
|
|
1057
1094
|
|
|
1058
1095
|
const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockStore).validate(filter);
|
|
@@ -19,6 +19,7 @@ export type PrivateEventStoreFilter = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
type PrivateEventEntry = {
|
|
22
|
+
randomness: Fr; // Note that this value is currently not being returned on queries and is therefore temporarily unused
|
|
22
23
|
msgContent: Buffer;
|
|
23
24
|
eventCommitmentIndex: number;
|
|
24
25
|
l2BlockNumber: number;
|
|
@@ -74,6 +75,7 @@ export class PrivateEventStore {
|
|
|
74
75
|
*/
|
|
75
76
|
storePrivateEventLog(
|
|
76
77
|
eventSelector: EventSelector,
|
|
78
|
+
randomness: Fr,
|
|
77
79
|
msgContent: Fr[],
|
|
78
80
|
eventCommitmentIndex: number,
|
|
79
81
|
metadata: PrivateEventMetadata,
|
|
@@ -93,6 +95,7 @@ export class PrivateEventStore {
|
|
|
93
95
|
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
94
96
|
|
|
95
97
|
await this.#eventLogs.set(eventCommitmentIndex, {
|
|
98
|
+
randomness,
|
|
96
99
|
msgContent: serializeToBuffer(msgContent),
|
|
97
100
|
l2BlockNumber,
|
|
98
101
|
l2BlockHash: l2BlockHash.toBuffer(),
|
|
@@ -3,7 +3,7 @@ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
|
3
3
|
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/
|
|
6
|
+
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/constants.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Data provider of tagging data used when syncing the sender tagging indexes. The recipient counterpart of this class
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This window has to be as large as the largest expected number of logs emitted in a tx for a given directional app
|
|
2
|
+
// tagging secret. If we get more tag indexes consumed than this window, an error is thrown in `PXE::proveTx` function.
|
|
3
|
+
// This is set to a larger value than MAX_PRIVATE_LOGS_PER_TX (currently 64) because there could be more than
|
|
4
|
+
// MAX_PRIVATE_LOGS_PER_TX indexes consumed in case the logs are squashed. This happens when the log contains a note
|
|
5
|
+
// and the note is nullified in the same tx.
|
|
6
|
+
//
|
|
7
|
+
// Having a large window significantly slowed down `e2e_l1_with_wall_time` test as there we perform sync for more than
|
|
8
|
+
// 1000 secrets. For this reason we set it to a relatively low value of 20. 20 should be sufficient for all the use
|
|
9
|
+
// cases.
|
|
10
|
+
export const UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN = 20;
|
package/src/tagging/index.ts
CHANGED
|
@@ -11,17 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
|
|
13
13
|
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
|
|
14
|
-
|
|
15
|
-
// This window has to be as large as the largest expected number of logs emitted in a tx for a given directional app
|
|
16
|
-
// tagging secret. If we get more tag indexes consumed than this window, an error is thrown in `PXE::proveTx` function.
|
|
17
|
-
// This is set to a larger value than MAX_PRIVATE_LOGS_PER_TX (currently 64) because there could be more than
|
|
18
|
-
// MAX_PRIVATE_LOGS_PER_TX indexes consumed in case the logs are squashed. This happens when the log contains a note
|
|
19
|
-
// and the note is nullified in the same tx.
|
|
20
|
-
//
|
|
21
|
-
// Having a large window significantly slowed down `e2e_l1_with_wall_time` test as there we perform sync for more than
|
|
22
|
-
// 1000 secrets. For this reason we set it to a relatively low value of 20. 20 should be sufficient for all the use
|
|
23
|
-
// cases.
|
|
24
|
-
export const UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN = 20;
|
|
14
|
+
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
25
15
|
|
|
26
16
|
// Re-export tagging-related types from stdlib
|
|
27
17
|
export { DirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
@@ -4,7 +4,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
4
4
|
import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
5
5
|
|
|
6
6
|
import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
|
|
7
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../
|
|
7
|
+
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
8
8
|
import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
9
9
|
import { loadLogsForRange } from './utils/load_logs_for_range.js';
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
|
3
3
|
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
4
4
|
|
|
5
5
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
6
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../
|
|
6
|
+
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
7
7
|
import { getStatusChangeOfPending } from './utils/get_status_change_of_pending.js';
|
|
8
8
|
import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_tagging_indexes.js';
|
|
9
9
|
|