@aztec/pxe 4.0.0-devnet.1-patch.0 → 4.0.0-devnet.2-patch.0
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/contract_function_simulator/contract_function_simulator.d.ts +53 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +169 -65
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- 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 +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +2 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +71 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +30 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +32 -29
- package/dest/contract_sync/contract_sync_service.d.ts +4 -2
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +34 -19
- package/dest/contract_sync/helpers.d.ts +3 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +3 -3
- package/dest/debug/pxe_debug_utils.d.ts +5 -4
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +9 -1
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +9 -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.js +9 -1
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +5 -10
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -2
- 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 +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +4 -4
- package/dest/private_kernel/private_kernel_execution_prover.js +6 -6
- package/dest/pxe.d.ts +57 -22
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +42 -35
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +317 -124
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +2 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -93
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +69 -26
- package/src/contract_sync/contract_sync_service.ts +49 -26
- package/src/contract_sync/helpers.ts +7 -2
- package/src/debug/pxe_debug_utils.ts +8 -6
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/logs/log_service.ts +7 -19
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +7 -7
- package/src/private_kernel/private_kernel_execution_prover.ts +6 -6
- package/src/pxe.ts +104 -74
- package/src/storage/note_store/note_store.ts +8 -5
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- 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/src/pxe.ts
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
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';
|
|
57
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -86,6 +87,56 @@ export type PackedPrivateEvent = InTx & {
|
|
|
86
87
|
eventSelector: EventSelector;
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
/** Options for PXE.profileTx. */
|
|
91
|
+
export type ProfileTxOpts = {
|
|
92
|
+
/** The profiling mode to use. */
|
|
93
|
+
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
94
|
+
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
95
|
+
skipProofGeneration?: boolean;
|
|
96
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
97
|
+
scopes: AccessScopes;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Options for PXE.simulateTx. */
|
|
101
|
+
export type SimulateTxOpts = {
|
|
102
|
+
/** Whether to simulate the public part of the transaction. */
|
|
103
|
+
simulatePublic: boolean;
|
|
104
|
+
/** If false, this function throws if the transaction is unable to be included in a block at the current state. */
|
|
105
|
+
skipTxValidation?: boolean;
|
|
106
|
+
/** If false, fees are enforced. */
|
|
107
|
+
skipFeeEnforcement?: boolean;
|
|
108
|
+
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
109
|
+
overrides?: SimulationOverrides;
|
|
110
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
111
|
+
scopes: AccessScopes;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** Options for PXE.simulateUtility. */
|
|
115
|
+
export type SimulateUtilityOpts = {
|
|
116
|
+
/** The authentication witnesses required for the function call. */
|
|
117
|
+
authwits?: AuthWitness[];
|
|
118
|
+
/** The accounts whose notes we can access in this call */
|
|
119
|
+
scopes: AccessScopes;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** Args for PXE.create. */
|
|
123
|
+
export type PXECreateArgs = {
|
|
124
|
+
/** The Aztec node to connect to. */
|
|
125
|
+
node: AztecNode;
|
|
126
|
+
/** The key-value store for persisting PXE state. */
|
|
127
|
+
store: AztecAsyncKVStore;
|
|
128
|
+
/** The prover for generating private kernel proofs. */
|
|
129
|
+
proofCreator: PrivateKernelProver;
|
|
130
|
+
/** The circuit simulator for executing ACIR circuits. */
|
|
131
|
+
simulator: CircuitSimulator;
|
|
132
|
+
/** Provider for protocol contract artifacts and instances. */
|
|
133
|
+
protocolContractsProvider: ProtocolContractsProvider;
|
|
134
|
+
/** PXE configuration options. */
|
|
135
|
+
config: PXEConfig;
|
|
136
|
+
/** Optional logger instance or string suffix for the logger name. */
|
|
137
|
+
loggerOrSuffix?: string | Logger;
|
|
138
|
+
};
|
|
139
|
+
|
|
89
140
|
/**
|
|
90
141
|
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
91
142
|
* manage private state of users.
|
|
@@ -122,15 +173,15 @@ export class PXE {
|
|
|
122
173
|
*
|
|
123
174
|
* @returns A promise that resolves PXE is ready to be used.
|
|
124
175
|
*/
|
|
125
|
-
public static async create(
|
|
126
|
-
node
|
|
127
|
-
store
|
|
128
|
-
proofCreator
|
|
129
|
-
simulator
|
|
130
|
-
protocolContractsProvider
|
|
131
|
-
config
|
|
132
|
-
loggerOrSuffix
|
|
133
|
-
) {
|
|
176
|
+
public static async create({
|
|
177
|
+
node,
|
|
178
|
+
store,
|
|
179
|
+
proofCreator,
|
|
180
|
+
simulator,
|
|
181
|
+
protocolContractsProvider,
|
|
182
|
+
config,
|
|
183
|
+
loggerOrSuffix,
|
|
184
|
+
}: PXECreateArgs) {
|
|
134
185
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
135
186
|
const bindings: LoggerBindings | undefined =
|
|
136
187
|
loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
@@ -140,7 +191,9 @@ export class PXE {
|
|
|
140
191
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
141
192
|
: loggerOrSuffix;
|
|
142
193
|
|
|
143
|
-
const
|
|
194
|
+
const info = await node.getNodeInfo();
|
|
195
|
+
|
|
196
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
144
197
|
const addressStore = new AddressStore(store);
|
|
145
198
|
const privateEventStore = new PrivateEventStore(store);
|
|
146
199
|
const contractStore = new ContractStore(store);
|
|
@@ -217,7 +270,6 @@ export class PXE {
|
|
|
217
270
|
pxe.jobQueue.start();
|
|
218
271
|
|
|
219
272
|
await pxe.#registerProtocolContracts();
|
|
220
|
-
const info = await node.getNodeInfo();
|
|
221
273
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
222
274
|
return pxe;
|
|
223
275
|
}
|
|
@@ -227,20 +279,20 @@ export class PXE {
|
|
|
227
279
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
228
280
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
229
281
|
|
|
230
|
-
return new ContractFunctionSimulator(
|
|
231
|
-
proxyContractStore,
|
|
232
|
-
this.noteStore,
|
|
233
|
-
this.keyStore,
|
|
234
|
-
this.addressStore,
|
|
235
|
-
BenchmarkedNodeFactory.create(this.node),
|
|
236
|
-
this.senderTaggingStore,
|
|
237
|
-
this.recipientTaggingStore,
|
|
238
|
-
this.senderAddressBookStore,
|
|
239
|
-
this.capsuleStore,
|
|
240
|
-
this.privateEventStore,
|
|
241
|
-
this.simulator,
|
|
242
|
-
this.contractSyncService,
|
|
243
|
-
);
|
|
282
|
+
return new ContractFunctionSimulator({
|
|
283
|
+
contractStore: proxyContractStore,
|
|
284
|
+
noteStore: this.noteStore,
|
|
285
|
+
keyStore: this.keyStore,
|
|
286
|
+
addressStore: this.addressStore,
|
|
287
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
288
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
289
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
290
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
291
|
+
capsuleStore: this.capsuleStore,
|
|
292
|
+
privateEventStore: this.privateEventStore,
|
|
293
|
+
simulator: this.simulator,
|
|
294
|
+
contractSyncService: this.contractSyncService,
|
|
295
|
+
});
|
|
244
296
|
}
|
|
245
297
|
|
|
246
298
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -306,7 +358,7 @@ export class PXE {
|
|
|
306
358
|
async #executePrivate(
|
|
307
359
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
308
360
|
txRequest: TxExecutionRequest,
|
|
309
|
-
scopes:
|
|
361
|
+
scopes: AccessScopes,
|
|
310
362
|
jobId: string,
|
|
311
363
|
): Promise<PrivateExecutionResult> {
|
|
312
364
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -317,23 +369,20 @@ export class PXE {
|
|
|
317
369
|
await this.contractSyncService.ensureContractSynced(
|
|
318
370
|
contractAddress,
|
|
319
371
|
functionSelector,
|
|
320
|
-
|
|
372
|
+
(privateSyncCall, execScopes) =>
|
|
373
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
321
374
|
anchorBlockHeader,
|
|
322
375
|
jobId,
|
|
376
|
+
scopes,
|
|
323
377
|
);
|
|
324
378
|
|
|
325
|
-
const result = await contractFunctionSimulator.run(
|
|
326
|
-
txRequest,
|
|
379
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
327
380
|
contractAddress,
|
|
328
|
-
functionSelector,
|
|
329
|
-
undefined,
|
|
381
|
+
selector: functionSelector,
|
|
330
382
|
anchorBlockHeader,
|
|
331
|
-
// The sender for tags is set by contracts, typically by an account
|
|
332
|
-
// contract entrypoint
|
|
333
|
-
undefined, // senderForTags
|
|
334
383
|
scopes,
|
|
335
384
|
jobId,
|
|
336
|
-
);
|
|
385
|
+
});
|
|
337
386
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
338
387
|
return result;
|
|
339
388
|
} catch (err) {
|
|
@@ -358,7 +407,7 @@ export class PXE {
|
|
|
358
407
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
359
408
|
call: FunctionCall,
|
|
360
409
|
authWitnesses: AuthWitness[] | undefined,
|
|
361
|
-
scopes:
|
|
410
|
+
scopes: AccessScopes,
|
|
362
411
|
jobId: string,
|
|
363
412
|
) {
|
|
364
413
|
try {
|
|
@@ -657,11 +706,12 @@ export class PXE {
|
|
|
657
706
|
* (where validators prove the public portion).
|
|
658
707
|
*
|
|
659
708
|
* @param txRequest - An authenticated tx request ready for proving
|
|
709
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
660
710
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
661
711
|
* @throws If contract code not found, or public simulation reverts.
|
|
662
712
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
663
713
|
*/
|
|
664
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
714
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
665
715
|
let privateExecutionResult: PrivateExecutionResult;
|
|
666
716
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
667
717
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -672,7 +722,7 @@ export class PXE {
|
|
|
672
722
|
await this.blockStateSynchronizer.sync();
|
|
673
723
|
const syncTime = syncTimer.ms();
|
|
674
724
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
675
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
725
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
676
726
|
|
|
677
727
|
const {
|
|
678
728
|
publicInputs,
|
|
@@ -736,17 +786,13 @@ export class PXE {
|
|
|
736
786
|
|
|
737
787
|
/**
|
|
738
788
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
739
|
-
*
|
|
740
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
741
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
742
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
789
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
743
790
|
* @returns A trace of the program execution with gate counts.
|
|
744
791
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
745
792
|
*/
|
|
746
793
|
public profileTx(
|
|
747
794
|
txRequest: TxExecutionRequest,
|
|
748
|
-
profileMode
|
|
749
|
-
skipProofGeneration: boolean = true,
|
|
795
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
750
796
|
): Promise<TxProfileResult> {
|
|
751
797
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
752
798
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -769,12 +815,7 @@ export class PXE {
|
|
|
769
815
|
const syncTime = syncTimer.ms();
|
|
770
816
|
|
|
771
817
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
772
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
773
|
-
contractFunctionSimulator,
|
|
774
|
-
txRequest,
|
|
775
|
-
undefined,
|
|
776
|
-
jobId,
|
|
777
|
-
);
|
|
818
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
778
819
|
|
|
779
820
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
780
821
|
txRequest,
|
|
@@ -831,12 +872,7 @@ export class PXE {
|
|
|
831
872
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
832
873
|
*
|
|
833
874
|
*
|
|
834
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
835
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
836
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
837
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
838
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
839
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
875
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
840
876
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
841
877
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
842
878
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
@@ -845,11 +881,7 @@ export class PXE {
|
|
|
845
881
|
*/
|
|
846
882
|
public simulateTx(
|
|
847
883
|
txRequest: TxExecutionRequest,
|
|
848
|
-
simulatePublic:
|
|
849
|
-
skipTxValidation: boolean = false,
|
|
850
|
-
skipFeeEnforcement: boolean = false,
|
|
851
|
-
overrides?: SimulationOverrides,
|
|
852
|
-
scopes?: AztecAddress[],
|
|
884
|
+
{ simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }: SimulateTxOpts,
|
|
853
885
|
): Promise<TxSimulationResult> {
|
|
854
886
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
855
887
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -896,6 +928,7 @@ export class PXE {
|
|
|
896
928
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
897
929
|
privateExecutionResult,
|
|
898
930
|
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
931
|
+
this.node,
|
|
899
932
|
));
|
|
900
933
|
} else {
|
|
901
934
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -973,25 +1006,19 @@ export class PXE {
|
|
|
973
1006
|
inspect(txRequest),
|
|
974
1007
|
`simulatePublic=${simulatePublic}`,
|
|
975
1008
|
`skipTxValidation=${skipTxValidation}`,
|
|
976
|
-
`scopes=${scopes
|
|
1009
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
977
1010
|
);
|
|
978
1011
|
}
|
|
979
1012
|
});
|
|
980
1013
|
}
|
|
981
1014
|
|
|
982
1015
|
/**
|
|
983
|
-
*
|
|
984
|
-
*
|
|
1016
|
+
* Simulates the execution of a contract utility function.
|
|
985
1017
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
986
|
-
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
987
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
988
|
-
* default to all.
|
|
989
|
-
* @returns The result of the utility function call, structured based on the function ABI.
|
|
990
1018
|
*/
|
|
991
1019
|
public simulateUtility(
|
|
992
1020
|
call: FunctionCall,
|
|
993
|
-
authwits
|
|
994
|
-
scopes?: AztecAddress[],
|
|
1021
|
+
{ authwits, scopes }: SimulateUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
995
1022
|
): Promise<UtilitySimulationResult> {
|
|
996
1023
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
997
1024
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1009,9 +1036,11 @@ export class PXE {
|
|
|
1009
1036
|
await this.contractSyncService.ensureContractSynced(
|
|
1010
1037
|
call.to,
|
|
1011
1038
|
call.selector,
|
|
1012
|
-
|
|
1039
|
+
(privateSyncCall, execScopes) =>
|
|
1040
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1013
1041
|
anchorBlockHeader,
|
|
1014
1042
|
jobId,
|
|
1043
|
+
scopes,
|
|
1015
1044
|
);
|
|
1016
1045
|
|
|
1017
1046
|
const executionResult = await this.#simulateUtility(
|
|
@@ -1042,7 +1071,7 @@ export class PXE {
|
|
|
1042
1071
|
throw this.#contextualizeError(
|
|
1043
1072
|
err,
|
|
1044
1073
|
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1045
|
-
`scopes=${scopes
|
|
1074
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1046
1075
|
);
|
|
1047
1076
|
}
|
|
1048
1077
|
});
|
|
@@ -1078,10 +1107,11 @@ export class PXE {
|
|
|
1078
1107
|
await this.contractSyncService.ensureContractSynced(
|
|
1079
1108
|
filter.contractAddress,
|
|
1080
1109
|
null,
|
|
1081
|
-
async privateSyncCall =>
|
|
1082
|
-
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [],
|
|
1110
|
+
async (privateSyncCall, execScopes) =>
|
|
1111
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1083
1112
|
anchorBlockHeader,
|
|
1084
1113
|
jobId,
|
|
1114
|
+
filter.scopes,
|
|
1085
1115
|
);
|
|
1086
1116
|
});
|
|
1087
1117
|
|
|
@@ -3,9 +3,10 @@ import type { Fr } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
6
|
-
import { NoteDao, NoteStatus
|
|
6
|
+
import { NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
7
7
|
|
|
8
8
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
9
|
+
import type { NotesFilter } from '../../notes_filter.js';
|
|
9
10
|
import { StoredNote } from './stored_note.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -103,11 +104,10 @@ export class NoteStore implements StagedStore {
|
|
|
103
104
|
* @params jobId - the job context to read from.
|
|
104
105
|
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
105
106
|
* returned once if this is the case)
|
|
106
|
-
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
107
107
|
*/
|
|
108
108
|
getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
|
|
109
|
-
if (filter.scopes !==
|
|
110
|
-
return Promise.
|
|
109
|
+
if (filter.scopes !== 'ALL_SCOPES' && filter.scopes.length === 0) {
|
|
110
|
+
return Promise.resolve([]);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
return this.#store.transactionAsync(async () => {
|
|
@@ -180,7 +180,10 @@ export class NoteStore implements StagedStore {
|
|
|
180
180
|
continue;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
if (
|
|
183
|
+
if (
|
|
184
|
+
filter.scopes !== 'ALL_SCOPES' &&
|
|
185
|
+
note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0
|
|
186
|
+
) {
|
|
184
187
|
continue;
|
|
185
188
|
}
|
|
186
189
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
2
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
|
-
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
|
|
3
|
+
import { MAX_LOGS_PER_TAG, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
4
4
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
6
6
|
|
|
@@ -31,6 +31,26 @@ async function getAllPages<T>(numTags: number, fetchPage: (page: number) => Prom
|
|
|
31
31
|
return allResultsPerTag;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
|
|
36
|
+
* back into a single array preserving the original tag order.
|
|
37
|
+
*/
|
|
38
|
+
async function getAllPagesInBatches<Tag, T>(
|
|
39
|
+
tags: Tag[],
|
|
40
|
+
fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
|
|
41
|
+
): Promise<T[][]> {
|
|
42
|
+
if (tags.length <= MAX_RPC_LEN) {
|
|
43
|
+
return fetchAllPagesForBatch(tags);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const batches: Tag[][] = [];
|
|
47
|
+
for (let i = 0; i < tags.length; i += MAX_RPC_LEN) {
|
|
48
|
+
batches.push(tags.slice(i, i + MAX_RPC_LEN));
|
|
49
|
+
}
|
|
50
|
+
const batchResults = await Promise.all(batches.map(fetchAllPagesForBatch));
|
|
51
|
+
return batchResults.flat();
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
/**
|
|
35
55
|
* Fetches all private logs for the given tags, automatically paginating through all pages.
|
|
36
56
|
* @param aztecNode - The Aztec node to query.
|
|
@@ -44,7 +64,9 @@ export function getAllPrivateLogsByTags(
|
|
|
44
64
|
tags: SiloedTag[],
|
|
45
65
|
anchorBlockHash: BlockHash,
|
|
46
66
|
): Promise<TxScopedL2Log[][]> {
|
|
47
|
-
return
|
|
67
|
+
return getAllPagesInBatches(tags, batch =>
|
|
68
|
+
getAllPages(batch.length, page => aztecNode.getPrivateLogsByTags(batch, page, anchorBlockHash)),
|
|
69
|
+
);
|
|
48
70
|
}
|
|
49
71
|
|
|
50
72
|
/**
|
|
@@ -62,7 +84,9 @@ export function getAllPublicLogsByTagsFromContract(
|
|
|
62
84
|
tags: Tag[],
|
|
63
85
|
anchorBlockHash: BlockHash,
|
|
64
86
|
): Promise<TxScopedL2Log[][]> {
|
|
65
|
-
return
|
|
66
|
-
|
|
87
|
+
return getAllPagesInBatches(tags, batch =>
|
|
88
|
+
getAllPages(batch.length, page =>
|
|
89
|
+
aztecNode.getPublicLogsByTagsFromContract(contractAddress, batch, page, anchorBlockHash),
|
|
90
|
+
),
|
|
67
91
|
);
|
|
68
92
|
}
|
|
@@ -30,7 +30,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
|
|
|
30
30
|
// (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
|
|
31
31
|
//
|
|
32
32
|
// highestAgedIndex is the highest index that was used in a tx that is included in a block at least
|
|
33
|
-
// `
|
|
33
|
+
// `MAX_TX_LIFETIME` seconds ago.
|
|
34
34
|
// highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
|
|
35
35
|
//
|
|
36
36
|
// "(" denotes an open end of the range - the index is not included in the range.
|
|
@@ -42,19 +42,19 @@ export async function loadPrivateLogsForSenderRecipientPair(
|
|
|
42
42
|
// ever appear.
|
|
43
43
|
//
|
|
44
44
|
// This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
|
|
45
|
-
// - a transaction's maximum inclusion timestamp is at most `
|
|
45
|
+
// - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
|
|
46
46
|
// the timestamp of its anchor block; and
|
|
47
47
|
// - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
|
|
48
48
|
//
|
|
49
49
|
// Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
|
|
50
|
-
// least `
|
|
50
|
+
// least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
|
|
51
51
|
// trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
|
|
52
52
|
// a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
|
|
53
53
|
// chosen a larger index.
|
|
54
54
|
// If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
|
|
55
55
|
// because it would already have been expired.
|
|
56
56
|
//
|
|
57
|
-
// Therefore, once we see that index `I` has been used in a block that is at least `
|
|
57
|
+
// Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
|
|
58
58
|
// seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
|
|
59
59
|
//
|
|
60
60
|
// ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_TX_LIFETIME } from '@aztec/constants';
|
|
2
2
|
import type { TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ export function findHighestIndexes(
|
|
|
16
16
|
const ageInSeconds = currentTimestamp - log.blockTimestamp;
|
|
17
17
|
|
|
18
18
|
if (
|
|
19
|
-
ageInSeconds >= BigInt(
|
|
19
|
+
ageInSeconds >= BigInt(MAX_TX_LIFETIME) &&
|
|
20
20
|
(highestAgedIndex === undefined || taggingIndex > highestAgedIndex)
|
|
21
21
|
) {
|
|
22
22
|
highestAgedIndex = taggingIndex;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
2
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
3
|
-
export declare function computeTxIncludeByTimestamp(previousKernel: PrivateKernelCircuitPublicInputs, maxDuration?: number): UInt64;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZV90eF9pbmNsdWRlX2J5X3RpbWVzdGFtcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL2NvbXB1dGVfdHhfaW5jbHVkZV9ieV90aW1lc3RhbXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0NBQWdDLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXFCbEQsd0JBQWdCLDJCQUEyQixDQUN6QyxjQUFjLEVBQUUsZ0NBQWdDLEVBQ2hELFdBQVcsU0FBb0MsR0FDOUMsTUFBTSxDQStCUiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compute_tx_include_by_timestamp.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/compute_tx_include_by_timestamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAqBlD,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,gCAAgC,EAChD,WAAW,SAAoC,GAC9C,MAAM,CA+BR"}
|