@aztec/pxe 4.0.0-devnet.1-patch.1 → 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 +5 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +7 -11
- 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 +3 -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 +10 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +5 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +12 -7
- 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/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/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/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 +11 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +13 -10
- 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 +11 -15
- 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 +14 -3
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +15 -9
- 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/lazy/index.ts +2 -0
- package/src/entrypoints/server/index.ts +2 -0
- 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 +26 -22
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_TX_LIFETIME } from '@aztec/constants';
|
|
2
2
|
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
3
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
4
|
|
|
@@ -8,12 +8,12 @@ const ROUNDED_DURATIONS = [
|
|
|
8
8
|
1, // 1 second
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
-
function roundTimestamp(blockTimestamp: bigint,
|
|
11
|
+
function roundTimestamp(blockTimestamp: bigint, expirationTimestamp: bigint): UInt64 {
|
|
12
12
|
return ROUNDED_DURATIONS.reduce((timestamp, duration) => {
|
|
13
13
|
if (timestamp <= blockTimestamp) {
|
|
14
14
|
// The timestamp must be greater than the block timestamp.
|
|
15
15
|
// If it is too small, round it down again using a smaller duration.
|
|
16
|
-
const totalDuration =
|
|
16
|
+
const totalDuration = expirationTimestamp - blockTimestamp;
|
|
17
17
|
const roundedDuration = totalDuration - (totalDuration % BigInt(duration));
|
|
18
18
|
return blockTimestamp + roundedDuration;
|
|
19
19
|
}
|
|
@@ -21,36 +21,36 @@ function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UIn
|
|
|
21
21
|
}, 0n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function computeTxExpirationTimestamp(
|
|
25
25
|
previousKernel: PrivateKernelCircuitPublicInputs,
|
|
26
|
-
|
|
26
|
+
txLifetime = MAX_TX_LIFETIME,
|
|
27
27
|
): UInt64 {
|
|
28
|
-
if (
|
|
28
|
+
if (txLifetime > MAX_TX_LIFETIME) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Custom
|
|
30
|
+
`Custom tx lifetime cannot be greater than the max allowed. Max allowed: ${MAX_TX_LIFETIME}. Custom value: ${txLifetime}.`,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
35
|
-
const maxTimestamp = anchorBlockTimestamp + BigInt(
|
|
36
|
-
const
|
|
35
|
+
const maxTimestamp = anchorBlockTimestamp + BigInt(txLifetime);
|
|
36
|
+
const expirationTimestamp = previousKernel.expirationTimestamp;
|
|
37
37
|
|
|
38
|
-
// If the
|
|
38
|
+
// If the expirationTimestamp set during the tx execution is greater than or equal to the max allowed duration,
|
|
39
39
|
// use the maximum allowed timestamp.
|
|
40
40
|
// Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
|
|
41
|
-
if (
|
|
41
|
+
if (expirationTimestamp >= maxTimestamp) {
|
|
42
42
|
return maxTimestamp;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
|
|
46
46
|
// This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
|
|
47
|
-
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp,
|
|
47
|
+
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, expirationTimestamp);
|
|
48
48
|
|
|
49
49
|
// The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
|
|
50
50
|
// Future blocks will have a greater timestamp, so the tx would never be included.
|
|
51
51
|
if (roundedTimestamp <= anchorBlockTimestamp) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
53
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestamp}.`,
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './compute_tx_expiration_timestamp.js';
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
type PrivateKernelSimulateOutput,
|
|
27
27
|
ReadRequestActionEnum,
|
|
28
28
|
ReadRequestResetActions,
|
|
29
|
-
type
|
|
29
|
+
type ScopedKeyValidationRequestAndSeparator,
|
|
30
30
|
ScopedNoteHash,
|
|
31
31
|
ScopedNullifier,
|
|
32
32
|
ScopedReadRequest,
|
|
@@ -68,9 +68,9 @@ function getNullifierMembershipWitnessResolver(oracle: PrivateKernelOracle) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async function
|
|
71
|
+
async function getMasterSecretKeysAndKeyTypeDomainSeparators(
|
|
72
72
|
keyValidationRequests: ClaimedLengthArray<
|
|
73
|
-
|
|
73
|
+
ScopedKeyValidationRequestAndSeparator,
|
|
74
74
|
typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX
|
|
75
75
|
>,
|
|
76
76
|
numRequestsToVerify: number,
|
|
@@ -189,8 +189,8 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
189
189
|
this.previousKernel.validationRequests.nullifierReadRequests,
|
|
190
190
|
this.nullifierResetActions,
|
|
191
191
|
),
|
|
192
|
-
|
|
193
|
-
this.previousKernel.validationRequests.
|
|
192
|
+
getMasterSecretKeysAndKeyTypeDomainSeparators(
|
|
193
|
+
this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators,
|
|
194
194
|
dimensions.KEY_VALIDATION,
|
|
195
195
|
oracle,
|
|
196
196
|
),
|
|
@@ -357,8 +357,8 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
private needsResetNullifierKeys() {
|
|
360
|
-
const numCurr = this.previousKernel.validationRequests.
|
|
361
|
-
const numNext = this.nextIteration ? this.nextIteration.
|
|
360
|
+
const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators.claimedLength;
|
|
361
|
+
const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndSeparators.claimedLength : 0;
|
|
362
362
|
const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
|
|
363
363
|
if (numCurr + numNext <= maxAmountToKeep) {
|
|
364
364
|
return false;
|
|
@@ -260,20 +260,20 @@ export class PrivateKernelExecutionProver {
|
|
|
260
260
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
261
261
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
262
262
|
|
|
263
|
-
// Use the aggregated
|
|
264
|
-
// TODO: Call `
|
|
265
|
-
const
|
|
263
|
+
// Use the aggregated expirationTimestamp set throughout the tx execution.
|
|
264
|
+
// TODO: Call `computeTxExpirationTimestamp` to round the value down and reduce precision, improving privacy.
|
|
265
|
+
const expirationTimestampUpperBound = previousKernelData.publicInputs.expirationTimestamp;
|
|
266
266
|
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
267
|
-
if (
|
|
267
|
+
if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
|
|
268
268
|
throw new Error(
|
|
269
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
269
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`,
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
|
|
274
274
|
previousKernelData,
|
|
275
275
|
paddedSideEffectAmounts,
|
|
276
|
-
|
|
276
|
+
expirationTimestampUpperBound,
|
|
277
277
|
);
|
|
278
278
|
|
|
279
279
|
const witgenTimer = new Timer();
|
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';
|
|
@@ -92,6 +93,8 @@ export type ProfileTxOpts = {
|
|
|
92
93
|
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
93
94
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
94
95
|
skipProofGeneration?: boolean;
|
|
96
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
97
|
+
scopes: AccessScopes;
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
/** Options for PXE.simulateTx. */
|
|
@@ -104,16 +107,16 @@ export type SimulateTxOpts = {
|
|
|
104
107
|
skipFeeEnforcement?: boolean;
|
|
105
108
|
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
106
109
|
overrides?: SimulationOverrides;
|
|
107
|
-
/**
|
|
108
|
-
scopes
|
|
110
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
111
|
+
scopes: AccessScopes;
|
|
109
112
|
};
|
|
110
113
|
|
|
111
114
|
/** Options for PXE.simulateUtility. */
|
|
112
115
|
export type SimulateUtilityOpts = {
|
|
113
116
|
/** The authentication witnesses required for the function call. */
|
|
114
117
|
authwits?: AuthWitness[];
|
|
115
|
-
/** The accounts whose notes we can access in this call
|
|
116
|
-
scopes
|
|
118
|
+
/** The accounts whose notes we can access in this call */
|
|
119
|
+
scopes: AccessScopes;
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
/** Args for PXE.create. */
|
|
@@ -355,7 +358,7 @@ export class PXE {
|
|
|
355
358
|
async #executePrivate(
|
|
356
359
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
357
360
|
txRequest: TxExecutionRequest,
|
|
358
|
-
scopes:
|
|
361
|
+
scopes: AccessScopes,
|
|
359
362
|
jobId: string,
|
|
360
363
|
): Promise<PrivateExecutionResult> {
|
|
361
364
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -366,9 +369,11 @@ export class PXE {
|
|
|
366
369
|
await this.contractSyncService.ensureContractSynced(
|
|
367
370
|
contractAddress,
|
|
368
371
|
functionSelector,
|
|
369
|
-
|
|
372
|
+
(privateSyncCall, execScopes) =>
|
|
373
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
370
374
|
anchorBlockHeader,
|
|
371
375
|
jobId,
|
|
376
|
+
scopes,
|
|
372
377
|
);
|
|
373
378
|
|
|
374
379
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
@@ -402,7 +407,7 @@ export class PXE {
|
|
|
402
407
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
403
408
|
call: FunctionCall,
|
|
404
409
|
authWitnesses: AuthWitness[] | undefined,
|
|
405
|
-
scopes:
|
|
410
|
+
scopes: AccessScopes,
|
|
406
411
|
jobId: string,
|
|
407
412
|
) {
|
|
408
413
|
try {
|
|
@@ -701,11 +706,12 @@ export class PXE {
|
|
|
701
706
|
* (where validators prove the public portion).
|
|
702
707
|
*
|
|
703
708
|
* @param txRequest - An authenticated tx request ready for proving
|
|
709
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
704
710
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
705
711
|
* @throws If contract code not found, or public simulation reverts.
|
|
706
712
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
707
713
|
*/
|
|
708
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
714
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
709
715
|
let privateExecutionResult: PrivateExecutionResult;
|
|
710
716
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
711
717
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -716,7 +722,7 @@ export class PXE {
|
|
|
716
722
|
await this.blockStateSynchronizer.sync();
|
|
717
723
|
const syncTime = syncTimer.ms();
|
|
718
724
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
719
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
725
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
720
726
|
|
|
721
727
|
const {
|
|
722
728
|
publicInputs,
|
|
@@ -786,7 +792,7 @@ export class PXE {
|
|
|
786
792
|
*/
|
|
787
793
|
public profileTx(
|
|
788
794
|
txRequest: TxExecutionRequest,
|
|
789
|
-
{ profileMode, skipProofGeneration = true }: ProfileTxOpts,
|
|
795
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
790
796
|
): Promise<TxProfileResult> {
|
|
791
797
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
792
798
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -809,12 +815,7 @@ export class PXE {
|
|
|
809
815
|
const syncTime = syncTimer.ms();
|
|
810
816
|
|
|
811
817
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
812
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
813
|
-
contractFunctionSimulator,
|
|
814
|
-
txRequest,
|
|
815
|
-
undefined,
|
|
816
|
-
jobId,
|
|
817
|
-
);
|
|
818
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
818
819
|
|
|
819
820
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
820
821
|
txRequest,
|
|
@@ -1005,7 +1006,7 @@ export class PXE {
|
|
|
1005
1006
|
inspect(txRequest),
|
|
1006
1007
|
`simulatePublic=${simulatePublic}`,
|
|
1007
1008
|
`skipTxValidation=${skipTxValidation}`,
|
|
1008
|
-
`scopes=${scopes
|
|
1009
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1009
1010
|
);
|
|
1010
1011
|
}
|
|
1011
1012
|
});
|
|
@@ -1017,7 +1018,7 @@ export class PXE {
|
|
|
1017
1018
|
*/
|
|
1018
1019
|
public simulateUtility(
|
|
1019
1020
|
call: FunctionCall,
|
|
1020
|
-
{ authwits, scopes }: SimulateUtilityOpts = {},
|
|
1021
|
+
{ authwits, scopes }: SimulateUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1021
1022
|
): Promise<UtilitySimulationResult> {
|
|
1022
1023
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1023
1024
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1035,9 +1036,11 @@ export class PXE {
|
|
|
1035
1036
|
await this.contractSyncService.ensureContractSynced(
|
|
1036
1037
|
call.to,
|
|
1037
1038
|
call.selector,
|
|
1038
|
-
|
|
1039
|
+
(privateSyncCall, execScopes) =>
|
|
1040
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1039
1041
|
anchorBlockHeader,
|
|
1040
1042
|
jobId,
|
|
1043
|
+
scopes,
|
|
1041
1044
|
);
|
|
1042
1045
|
|
|
1043
1046
|
const executionResult = await this.#simulateUtility(
|
|
@@ -1068,7 +1071,7 @@ export class PXE {
|
|
|
1068
1071
|
throw this.#contextualizeError(
|
|
1069
1072
|
err,
|
|
1070
1073
|
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1071
|
-
`scopes=${scopes
|
|
1074
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1072
1075
|
);
|
|
1073
1076
|
}
|
|
1074
1077
|
});
|
|
@@ -1104,10 +1107,11 @@ export class PXE {
|
|
|
1104
1107
|
await this.contractSyncService.ensureContractSynced(
|
|
1105
1108
|
filter.contractAddress,
|
|
1106
1109
|
null,
|
|
1107
|
-
async privateSyncCall =>
|
|
1108
|
-
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [],
|
|
1110
|
+
async (privateSyncCall, execScopes) =>
|
|
1111
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1109
1112
|
anchorBlockHeader,
|
|
1110
1113
|
jobId,
|
|
1114
|
+
filter.scopes,
|
|
1111
1115
|
);
|
|
1112
1116
|
});
|
|
1113
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"}
|