@aztec/pxe 0.0.1-commit.858058eac → 0.0.1-commit.85d7d01
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/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -6
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +111 -41
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- 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/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 +9 -9
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +14 -12
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +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 +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/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 +9 -14
- 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/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.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +16 -12
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +38 -30
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- 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/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +4 -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/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +217 -60
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- 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/private_execution_oracle.ts +16 -11
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +21 -14
- package/src/contract_logging.ts +39 -0
- 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 +11 -9
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/server/index.ts +2 -0
- package/src/logs/log_service.ts +17 -24
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- 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 +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +58 -49
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/note_store/note_store.ts +8 -5
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
- 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
|
@@ -2,23 +2,26 @@ import {
|
|
|
2
2
|
AVM_EMITNOTEHASH_BASE_L2_GAS,
|
|
3
3
|
AVM_EMITNULLIFIER_BASE_L2_GAS,
|
|
4
4
|
AVM_SENDL2TOL1MSG_BASE_L2_GAS,
|
|
5
|
-
|
|
6
|
-
DA_GAS_PER_BYTE,
|
|
5
|
+
DA_GAS_PER_FIELD,
|
|
7
6
|
FIXED_AVM_STARTUP_L2_GAS,
|
|
8
|
-
FIXED_DA_GAS,
|
|
9
|
-
FIXED_L2_GAS,
|
|
10
|
-
GeneratorIndex,
|
|
11
7
|
L2_GAS_PER_CONTRACT_CLASS_LOG,
|
|
8
|
+
L2_GAS_PER_L2_TO_L1_MSG,
|
|
9
|
+
L2_GAS_PER_NOTE_HASH,
|
|
10
|
+
L2_GAS_PER_NULLIFIER,
|
|
12
11
|
L2_GAS_PER_PRIVATE_LOG,
|
|
13
12
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
14
13
|
MAX_ENQUEUED_CALLS_PER_TX,
|
|
15
14
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
16
15
|
MAX_NOTE_HASHES_PER_TX,
|
|
16
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
17
17
|
MAX_NULLIFIERS_PER_TX,
|
|
18
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
18
19
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
20
|
+
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
21
|
+
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
22
|
+
TX_DA_GAS_OVERHEAD,
|
|
19
23
|
} from '@aztec/constants';
|
|
20
24
|
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
21
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
22
25
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
23
26
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
24
27
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -38,25 +41,36 @@ import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
|
38
41
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
39
42
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
40
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
44
|
+
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
41
45
|
import { Gas } from '@aztec/stdlib/gas';
|
|
42
46
|
import {
|
|
43
47
|
computeNoteHashNonce,
|
|
44
48
|
computeProtocolNullifier,
|
|
49
|
+
computeSiloedPrivateLogFirstField,
|
|
45
50
|
computeUniqueNoteHash,
|
|
46
51
|
siloNoteHash,
|
|
47
52
|
siloNullifier,
|
|
48
53
|
} from '@aztec/stdlib/hash';
|
|
49
54
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
50
55
|
import {
|
|
56
|
+
ClaimedLengthArray,
|
|
51
57
|
PartialPrivateTailPublicInputsForPublic,
|
|
52
58
|
PartialPrivateTailPublicInputsForRollup,
|
|
53
59
|
type PrivateExecutionStep,
|
|
54
60
|
type PrivateKernelExecutionProofOutput,
|
|
55
61
|
PrivateKernelTailCircuitPublicInputs,
|
|
62
|
+
PrivateLogData,
|
|
56
63
|
PrivateToPublicAccumulatedData,
|
|
57
64
|
PrivateToRollupAccumulatedData,
|
|
58
65
|
PublicCallRequest,
|
|
66
|
+
ReadRequestActionEnum,
|
|
59
67
|
ScopedLogHash,
|
|
68
|
+
ScopedNoteHash,
|
|
69
|
+
ScopedNullifier,
|
|
70
|
+
ScopedReadRequest,
|
|
71
|
+
buildTransientDataHints,
|
|
72
|
+
getNoteHashReadRequestResetActions,
|
|
73
|
+
getNullifierReadRequestResetActions,
|
|
60
74
|
} from '@aztec/stdlib/kernel';
|
|
61
75
|
import { PrivateLog } from '@aztec/stdlib/logs';
|
|
62
76
|
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
@@ -69,9 +83,11 @@ import {
|
|
|
69
83
|
TxConstantData,
|
|
70
84
|
TxExecutionRequest,
|
|
71
85
|
collectNested,
|
|
86
|
+
collectNoteHashNullifierCounterMap,
|
|
72
87
|
getFinalMinRevertibleSideEffectCounter,
|
|
73
88
|
} from '@aztec/stdlib/tx';
|
|
74
89
|
|
|
90
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
75
91
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
76
92
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
77
93
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
@@ -102,8 +118,8 @@ export type ContractSimulatorRunOpts = {
|
|
|
102
118
|
anchorBlockHeader: BlockHeader;
|
|
103
119
|
/** The address used as a tagging sender when emitting private logs. */
|
|
104
120
|
senderForTags?: AztecAddress;
|
|
105
|
-
/** The accounts whose notes we can access in this call.
|
|
106
|
-
scopes
|
|
121
|
+
/** The accounts whose notes we can access in this call. */
|
|
122
|
+
scopes: AccessScopes;
|
|
107
123
|
/** The job ID for staged writes. */
|
|
108
124
|
jobId: string;
|
|
109
125
|
};
|
|
@@ -207,8 +223,8 @@ export class ContractFunctionSimulator {
|
|
|
207
223
|
txContext: request.txContext,
|
|
208
224
|
callContext,
|
|
209
225
|
anchorBlockHeader,
|
|
210
|
-
utilityExecutor: async call => {
|
|
211
|
-
await this.runUtility(call, [], anchorBlockHeader,
|
|
226
|
+
utilityExecutor: async (call, execScopes) => {
|
|
227
|
+
await this.runUtility(call, [], anchorBlockHeader, execScopes, jobId);
|
|
212
228
|
},
|
|
213
229
|
authWitnesses: request.authWitnesses,
|
|
214
230
|
capsules: request.capsules,
|
|
@@ -296,7 +312,7 @@ export class ContractFunctionSimulator {
|
|
|
296
312
|
call: FunctionCall,
|
|
297
313
|
authwits: AuthWitness[],
|
|
298
314
|
anchorBlockHeader: BlockHeader,
|
|
299
|
-
scopes:
|
|
315
|
+
scopes: AccessScopes,
|
|
300
316
|
jobId: string,
|
|
301
317
|
): Promise<Fr[]> {
|
|
302
318
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
@@ -345,7 +361,7 @@ export class ContractFunctionSimulator {
|
|
|
345
361
|
);
|
|
346
362
|
});
|
|
347
363
|
|
|
348
|
-
this.log.verbose(`Utility
|
|
364
|
+
this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
349
365
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
350
366
|
} catch (err) {
|
|
351
367
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
@@ -387,7 +403,8 @@ class OrderedSideEffect<T> {
|
|
|
387
403
|
* (allowing state overrides) and is much faster, while still generating a valid
|
|
388
404
|
* output that can be sent to the node for public simulation
|
|
389
405
|
* @param privateExecutionResult - The result of the private execution.
|
|
390
|
-
* @param
|
|
406
|
+
* @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
|
|
407
|
+
* @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
|
|
391
408
|
* @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
|
|
392
409
|
* Used by TXE to simulate account contract behavior (setting the counter before app execution).
|
|
393
410
|
* @returns The simulated proving result.
|
|
@@ -395,16 +412,24 @@ class OrderedSideEffect<T> {
|
|
|
395
412
|
export async function generateSimulatedProvingResult(
|
|
396
413
|
privateExecutionResult: PrivateExecutionResult,
|
|
397
414
|
debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>,
|
|
415
|
+
node: AztecNode,
|
|
398
416
|
minRevertibleSideEffectCounterOverride?: number,
|
|
399
417
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
400
|
-
const
|
|
401
|
-
const nullifiers: OrderedSideEffect<Fr>[] = [];
|
|
402
|
-
const taggedPrivateLogs: OrderedSideEffect<PrivateLog>[] = [];
|
|
418
|
+
const taggedPrivateLogs: OrderedSideEffect<PrivateLogData>[] = [];
|
|
403
419
|
const l2ToL1Messages: OrderedSideEffect<ScopedL2ToL1Message>[] = [];
|
|
404
420
|
const contractClassLogsHashes: OrderedSideEffect<ScopedLogHash>[] = [];
|
|
405
421
|
const publicCallRequests: OrderedSideEffect<PublicCallRequest>[] = [];
|
|
406
422
|
const executionSteps: PrivateExecutionStep[] = [];
|
|
407
423
|
|
|
424
|
+
// Unsiloed scoped arrays — used for squashing, read request verification,
|
|
425
|
+
// and siloed at the end only for the surviving items
|
|
426
|
+
const scopedNoteHashes: ScopedNoteHash[] = [];
|
|
427
|
+
const scopedNullifiers: ScopedNullifier[] = [];
|
|
428
|
+
|
|
429
|
+
// Read requests for verification
|
|
430
|
+
const noteHashReadRequests: ScopedReadRequest[] = [];
|
|
431
|
+
const nullifierReadRequests: ScopedReadRequest[] = [];
|
|
432
|
+
|
|
408
433
|
let publicTeardownCallRequest;
|
|
409
434
|
|
|
410
435
|
const executions = [privateExecutionResult.entrypoint];
|
|
@@ -415,38 +440,25 @@ export async function generateSimulatedProvingResult(
|
|
|
415
440
|
|
|
416
441
|
const { contractAddress } = execution.publicInputs.callContext;
|
|
417
442
|
|
|
418
|
-
|
|
419
|
-
execution.publicInputs.noteHashes
|
|
420
|
-
.getActiveItems()
|
|
421
|
-
.filter(noteHash => !noteHash.isEmpty())
|
|
422
|
-
.map(
|
|
423
|
-
async noteHash =>
|
|
424
|
-
new OrderedSideEffect(await siloNoteHash(contractAddress, noteHash.value), noteHash.counter),
|
|
425
|
-
),
|
|
426
|
-
);
|
|
427
|
-
|
|
428
|
-
const nullifiersFromExecution = await Promise.all(
|
|
429
|
-
execution.publicInputs.nullifiers
|
|
443
|
+
scopedNoteHashes.push(
|
|
444
|
+
...execution.publicInputs.noteHashes
|
|
430
445
|
.getActiveItems()
|
|
431
|
-
.
|
|
432
|
-
|
|
433
|
-
new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter),
|
|
434
|
-
),
|
|
446
|
+
.filter(nh => !nh.isEmpty())
|
|
447
|
+
.map(nh => nh.scope(contractAddress)),
|
|
435
448
|
);
|
|
449
|
+
scopedNullifiers.push(...execution.publicInputs.nullifiers.getActiveItems().map(n => n.scope(contractAddress)));
|
|
436
450
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
[contractAddress, metadata.log.fields[0]
|
|
441
|
-
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
}),
|
|
451
|
+
taggedPrivateLogs.push(
|
|
452
|
+
...(await Promise.all(
|
|
453
|
+
execution.publicInputs.privateLogs.getActiveItems().map(async metadata => {
|
|
454
|
+
metadata.log.fields[0] = await computeSiloedPrivateLogFirstField(contractAddress, metadata.log.fields[0]);
|
|
455
|
+
return new OrderedSideEffect(metadata, metadata.counter);
|
|
456
|
+
}),
|
|
457
|
+
)),
|
|
445
458
|
);
|
|
446
459
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
nullifiers.push(...nullifiersFromExecution);
|
|
460
|
+
noteHashReadRequests.push(...execution.publicInputs.noteHashReadRequests.getActiveItems());
|
|
461
|
+
nullifierReadRequests.push(...execution.publicInputs.nullifierReadRequests.getActiveItems());
|
|
450
462
|
l2ToL1Messages.push(
|
|
451
463
|
...execution.publicInputs.l2ToL1Msgs
|
|
452
464
|
.getActiveItems()
|
|
@@ -486,6 +498,47 @@ export async function generateSimulatedProvingResult(
|
|
|
486
498
|
});
|
|
487
499
|
}
|
|
488
500
|
|
|
501
|
+
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(privateExecutionResult);
|
|
502
|
+
const minRevertibleSideEffectCounter =
|
|
503
|
+
minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
504
|
+
|
|
505
|
+
const scopedNoteHashesCLA = new ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>(
|
|
506
|
+
padArrayEnd(scopedNoteHashes, ScopedNoteHash.empty(), MAX_NOTE_HASHES_PER_TX),
|
|
507
|
+
scopedNoteHashes.length,
|
|
508
|
+
);
|
|
509
|
+
const scopedNullifiersCLA = new ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>(
|
|
510
|
+
padArrayEnd(scopedNullifiers, ScopedNullifier.empty(), MAX_NULLIFIERS_PER_TX),
|
|
511
|
+
scopedNullifiers.length,
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
const { filteredNoteHashes, filteredNullifiers, filteredPrivateLogs } = squashTransientSideEffects(
|
|
515
|
+
taggedPrivateLogs,
|
|
516
|
+
scopedNoteHashesCLA,
|
|
517
|
+
scopedNullifiersCLA,
|
|
518
|
+
noteHashNullifierCounterMap,
|
|
519
|
+
minRevertibleSideEffectCounter,
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
await verifyReadRequests(
|
|
523
|
+
node,
|
|
524
|
+
await privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.hash(),
|
|
525
|
+
noteHashReadRequests,
|
|
526
|
+
nullifierReadRequests,
|
|
527
|
+
scopedNoteHashesCLA,
|
|
528
|
+
scopedNullifiersCLA,
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
const siloedNoteHashes = await Promise.all(
|
|
532
|
+
filteredNoteHashes
|
|
533
|
+
.sort((a, b) => a.counter - b.counter)
|
|
534
|
+
.map(async nh => new OrderedSideEffect(await siloNoteHash(nh.contractAddress, nh.value), nh.counter)),
|
|
535
|
+
);
|
|
536
|
+
const siloedNullifiers = await Promise.all(
|
|
537
|
+
filteredNullifiers
|
|
538
|
+
.sort((a, b) => a.counter - b.counter)
|
|
539
|
+
.map(async n => new OrderedSideEffect(await siloNullifier(n.contractAddress, n.value), n.counter)),
|
|
540
|
+
);
|
|
541
|
+
|
|
489
542
|
const constantData = new TxConstantData(
|
|
490
543
|
privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader,
|
|
491
544
|
privateExecutionResult.entrypoint.publicInputs.txContext,
|
|
@@ -502,11 +555,9 @@ export async function generateSimulatedProvingResult(
|
|
|
502
555
|
const getEffect = <T>(orderedSideEffect: OrderedSideEffect<T>) => orderedSideEffect.sideEffect;
|
|
503
556
|
|
|
504
557
|
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
505
|
-
const minRevertibleSideEffectCounter =
|
|
506
|
-
minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
507
558
|
|
|
508
559
|
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(
|
|
509
|
-
|
|
560
|
+
siloedNullifiers,
|
|
510
561
|
minRevertibleSideEffectCounter,
|
|
511
562
|
);
|
|
512
563
|
const nonceGenerator = privateExecutionResult.firstNullifier;
|
|
@@ -520,7 +571,7 @@ export async function generateSimulatedProvingResult(
|
|
|
520
571
|
// We must make the note hashes unique by using the
|
|
521
572
|
// nonce generator and their index in the tx.
|
|
522
573
|
const uniqueNoteHashes = await Promise.all(
|
|
523
|
-
siloedNoteHashes.
|
|
574
|
+
siloedNoteHashes.map(async (orderedSideEffect, i) => {
|
|
524
575
|
const siloedNoteHash = orderedSideEffect.sideEffect;
|
|
525
576
|
const nonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
526
577
|
const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
|
|
@@ -535,18 +586,18 @@ export async function generateSimulatedProvingResult(
|
|
|
535
586
|
ScopedL2ToL1Message.empty(),
|
|
536
587
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
537
588
|
),
|
|
538
|
-
padArrayEnd(
|
|
589
|
+
padArrayEnd(filteredPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
|
|
539
590
|
padArrayEnd(
|
|
540
591
|
contractClassLogsHashes.sort(sortByCounter).map(getEffect),
|
|
541
592
|
ScopedLogHash.empty(),
|
|
542
593
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
543
594
|
),
|
|
544
595
|
);
|
|
545
|
-
gasUsed = meterGasUsed(accumulatedDataForRollup);
|
|
596
|
+
gasUsed = meterGasUsed(accumulatedDataForRollup, isPrivateOnlyTx);
|
|
546
597
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
547
598
|
} else {
|
|
548
599
|
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(
|
|
549
|
-
siloedNoteHashes
|
|
600
|
+
siloedNoteHashes,
|
|
550
601
|
minRevertibleSideEffectCounter,
|
|
551
602
|
);
|
|
552
603
|
const nonRevertibleUniqueNoteHashes = await Promise.all(
|
|
@@ -560,7 +611,7 @@ export async function generateSimulatedProvingResult(
|
|
|
560
611
|
minRevertibleSideEffectCounter,
|
|
561
612
|
);
|
|
562
613
|
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
|
|
563
|
-
|
|
614
|
+
filteredPrivateLogs,
|
|
564
615
|
minRevertibleSideEffectCounter,
|
|
565
616
|
);
|
|
566
617
|
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(
|
|
@@ -589,9 +640,9 @@ export async function generateSimulatedProvingResult(
|
|
|
589
640
|
padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
|
|
590
641
|
padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
|
|
591
642
|
);
|
|
592
|
-
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
643
|
+
gasUsed = meterGasUsed(revertibleData, isPrivateOnlyTx).add(meterGasUsed(nonRevertibleData, isPrivateOnlyTx));
|
|
593
644
|
if (publicTeardownCallRequest) {
|
|
594
|
-
gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
645
|
+
gasUsed = gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
595
646
|
}
|
|
596
647
|
|
|
597
648
|
inputsForPublic = new PartialPrivateTailPublicInputsForPublic(
|
|
@@ -603,9 +654,14 @@ export async function generateSimulatedProvingResult(
|
|
|
603
654
|
|
|
604
655
|
const publicInputs = new PrivateKernelTailCircuitPublicInputs(
|
|
605
656
|
constantData,
|
|
606
|
-
/*gasUsed=*/ gasUsed.add(
|
|
657
|
+
/*gasUsed=*/ gasUsed.add(
|
|
658
|
+
Gas.from({
|
|
659
|
+
l2Gas: isPrivateOnlyTx ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
660
|
+
daGas: TX_DA_GAS_OVERHEAD,
|
|
661
|
+
}),
|
|
662
|
+
),
|
|
607
663
|
/*feePayer=*/ AztecAddress.zero(),
|
|
608
|
-
/*
|
|
664
|
+
/*expirationTimestamp=*/ 0n,
|
|
609
665
|
hasPublicCalls ? inputsForPublic : undefined,
|
|
610
666
|
!hasPublicCalls ? inputsForRollup : undefined,
|
|
611
667
|
);
|
|
@@ -617,6 +673,104 @@ export async function generateSimulatedProvingResult(
|
|
|
617
673
|
};
|
|
618
674
|
}
|
|
619
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Squashes transient note hashes and nullifiers, mimicking the behavior
|
|
678
|
+
* of the reset kernels. Returns the filtered (surviving) scoped items and private logs.
|
|
679
|
+
*/
|
|
680
|
+
function squashTransientSideEffects(
|
|
681
|
+
taggedPrivateLogs: OrderedSideEffect<PrivateLogData>[],
|
|
682
|
+
scopedNoteHashesCLA: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
683
|
+
scopedNullifiersCLA: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
684
|
+
noteHashNullifierCounterMap: Map<number, number>,
|
|
685
|
+
minRevertibleSideEffectCounter: number,
|
|
686
|
+
) {
|
|
687
|
+
const { numTransientData, hints: transientDataHints } = buildTransientDataHints(
|
|
688
|
+
scopedNoteHashesCLA,
|
|
689
|
+
scopedNullifiersCLA,
|
|
690
|
+
/*futureNoteHashReads=*/ [],
|
|
691
|
+
/*futureNullifierReads=*/ [],
|
|
692
|
+
/*futureLogs=*/ [],
|
|
693
|
+
noteHashNullifierCounterMap,
|
|
694
|
+
minRevertibleSideEffectCounter,
|
|
695
|
+
);
|
|
696
|
+
|
|
697
|
+
const squashedNoteHashCounters = new Set<number>();
|
|
698
|
+
const squashedNullifierCounters = new Set<number>();
|
|
699
|
+
for (let i = 0; i < numTransientData; i++) {
|
|
700
|
+
const hint = transientDataHints[i];
|
|
701
|
+
squashedNoteHashCounters.add(scopedNoteHashesCLA.array[hint.noteHashIndex].counter);
|
|
702
|
+
squashedNullifierCounters.add(scopedNullifiersCLA.array[hint.nullifierIndex].counter);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return {
|
|
706
|
+
filteredNoteHashes: scopedNoteHashesCLA.getActiveItems().filter(nh => !squashedNoteHashCounters.has(nh.counter)),
|
|
707
|
+
filteredNullifiers: scopedNullifiersCLA.getActiveItems().filter(n => !squashedNullifierCounters.has(n.counter)),
|
|
708
|
+
filteredPrivateLogs: taggedPrivateLogs
|
|
709
|
+
.filter(item => !squashedNoteHashCounters.has(item.sideEffect.noteHashCounter))
|
|
710
|
+
.map(item => new OrderedSideEffect(item.sideEffect.log, item.counter)),
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Verifies settled read requests by checking membership in the note hash and nullifier trees
|
|
716
|
+
* at the tx's anchor block, mimicking the behavior of the kernels
|
|
717
|
+
*/
|
|
718
|
+
async function verifyReadRequests(
|
|
719
|
+
node: Pick<AztecNode, 'getNoteHashMembershipWitness' | 'getNullifierMembershipWitness'>,
|
|
720
|
+
anchorBlockHash: BlockParameter,
|
|
721
|
+
noteHashReadRequests: ScopedReadRequest[],
|
|
722
|
+
nullifierReadRequests: ScopedReadRequest[],
|
|
723
|
+
scopedNoteHashesCLA: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
724
|
+
scopedNullifiersCLA: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
725
|
+
) {
|
|
726
|
+
const noteHashReadRequestsCLA = new ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>(
|
|
727
|
+
padArrayEnd(noteHashReadRequests, ScopedReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_TX),
|
|
728
|
+
noteHashReadRequests.length,
|
|
729
|
+
);
|
|
730
|
+
const nullifierReadRequestsCLA = new ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>(
|
|
731
|
+
padArrayEnd(nullifierReadRequests, ScopedReadRequest.empty(), MAX_NULLIFIER_READ_REQUESTS_PER_TX),
|
|
732
|
+
nullifierReadRequests.length,
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA);
|
|
736
|
+
const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA);
|
|
737
|
+
|
|
738
|
+
const settledNoteHashReads: { index: number; value: Fr }[] = [];
|
|
739
|
+
for (let i = 0; i < noteHashResetActions.actions.length; i++) {
|
|
740
|
+
if (noteHashResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
741
|
+
settledNoteHashReads.push({ index: i, value: noteHashReadRequests[i].value });
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
const settledNullifierReads: { index: number; value: Fr }[] = [];
|
|
746
|
+
for (let i = 0; i < nullifierResetActions.actions.length; i++) {
|
|
747
|
+
if (nullifierResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
748
|
+
settledNullifierReads.push({ index: i, value: nullifierReadRequests[i].value });
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const [noteHashWitnesses, nullifierWitnesses] = await Promise.all([
|
|
753
|
+
Promise.all(settledNoteHashReads.map(({ value }) => node.getNoteHashMembershipWitness(anchorBlockHash, value))),
|
|
754
|
+
Promise.all(settledNullifierReads.map(({ value }) => node.getNullifierMembershipWitness(anchorBlockHash, value))),
|
|
755
|
+
]);
|
|
756
|
+
|
|
757
|
+
for (let i = 0; i < settledNoteHashReads.length; i++) {
|
|
758
|
+
if (!noteHashWitnesses[i]) {
|
|
759
|
+
throw new Error(
|
|
760
|
+
`Note hash read request at index ${settledNoteHashReads[i].index} is reading an unknown note hash: ${settledNoteHashReads[i].value}`,
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
for (let i = 0; i < settledNullifierReads.length; i++) {
|
|
766
|
+
if (!nullifierWitnesses[i]) {
|
|
767
|
+
throw new Error(
|
|
768
|
+
`Nullifier read request at index ${settledNullifierReads[i].index} is reading an unknown nullifier: ${settledNullifierReads[i].value}`,
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
620
774
|
function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertibleSideEffectCounter: number) {
|
|
621
775
|
const revertibleSideEffects: T[] = [];
|
|
622
776
|
const nonRevertibleSideEffects: T[] = [];
|
|
@@ -630,21 +784,24 @@ function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertib
|
|
|
630
784
|
return [nonRevertibleSideEffects, revertibleSideEffects];
|
|
631
785
|
}
|
|
632
786
|
|
|
633
|
-
function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData) {
|
|
787
|
+
function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData, isPrivateOnlyTx: boolean) {
|
|
634
788
|
let meteredDAFields = 0;
|
|
635
789
|
let meteredL2Gas = 0;
|
|
636
790
|
|
|
637
791
|
const numNoteHashes = arrayNonEmptyLength(data.noteHashes, hash => hash.isEmpty());
|
|
638
792
|
meteredDAFields += numNoteHashes;
|
|
639
|
-
|
|
793
|
+
const noteHashBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NOTE_HASH : AVM_EMITNOTEHASH_BASE_L2_GAS;
|
|
794
|
+
meteredL2Gas += numNoteHashes * noteHashBaseGas;
|
|
640
795
|
|
|
641
796
|
const numNullifiers = arrayNonEmptyLength(data.nullifiers, nullifier => nullifier.isEmpty());
|
|
642
797
|
meteredDAFields += numNullifiers;
|
|
643
|
-
|
|
798
|
+
const nullifierBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NULLIFIER : AVM_EMITNULLIFIER_BASE_L2_GAS;
|
|
799
|
+
meteredL2Gas += numNullifiers * nullifierBaseGas;
|
|
644
800
|
|
|
645
801
|
const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, msg => msg.isEmpty());
|
|
646
802
|
meteredDAFields += numL2toL1Messages;
|
|
647
|
-
|
|
803
|
+
const l2ToL1MessageBaseGas = isPrivateOnlyTx ? L2_GAS_PER_L2_TO_L1_MSG : AVM_SENDL2TOL1MSG_BASE_L2_GAS;
|
|
804
|
+
meteredL2Gas += numL2toL1Messages * l2ToL1MessageBaseGas;
|
|
648
805
|
|
|
649
806
|
const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, log => log.isEmpty());
|
|
650
807
|
// Every private log emits its length as an additional field
|
|
@@ -659,7 +816,7 @@ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccu
|
|
|
659
816
|
);
|
|
660
817
|
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
661
818
|
|
|
662
|
-
const meteredDAGas = meteredDAFields *
|
|
819
|
+
const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
|
|
663
820
|
|
|
664
821
|
if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
|
|
665
822
|
const dataForPublic = data as PrivateToPublicAccumulatedData;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A map that stores the tagging index for a given directional app tagging secret.
|
|
4
|
+
* A map that stores the tagging index for a given extended directional app tagging secret.
|
|
5
5
|
* Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
|
|
6
6
|
* of sender -> recipient matters.
|
|
7
7
|
*/
|
|
8
8
|
export class ExecutionTaggingIndexCache {
|
|
9
9
|
private taggingIndexMap: Map<string, number> = new Map();
|
|
10
10
|
|
|
11
|
-
public getLastUsedIndex(secret:
|
|
11
|
+
public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
|
|
12
12
|
return this.taggingIndexMap.get(secret.toString());
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
public setLastUsedIndex(secret:
|
|
15
|
+
public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
|
|
16
16
|
const currentValue = this.taggingIndexMap.get(secret.toString());
|
|
17
17
|
if (currentValue !== undefined && currentValue !== index - 1) {
|
|
18
18
|
throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
|
|
@@ -25,7 +25,7 @@ export class ExecutionTaggingIndexCache {
|
|
|
25
25
|
*/
|
|
26
26
|
public getUsedPreTags(): PreTag[] {
|
|
27
27
|
return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
|
|
28
|
-
|
|
28
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
|
|
29
29
|
index,
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
@@ -5,7 +5,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
8
|
-
const MAX_EVENT_SERIALIZED_LEN =
|
|
8
|
+
const MAX_EVENT_SERIALIZED_LEN = 10;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
@@ -4,7 +4,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
7
|
-
export const MAX_NOTE_PACKED_LEN =
|
|
7
|
+
export const MAX_NOTE_PACKED_LEN = 8;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
15
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
16
16
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
17
|
-
import { type ContractClassLog,
|
|
17
|
+
import { type ContractClassLog, ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
18
18
|
import { Tag } from '@aztec/stdlib/logs';
|
|
19
19
|
import { Note, type NoteStatus } from '@aztec/stdlib/note';
|
|
20
20
|
import {
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type TxContext,
|
|
26
26
|
} from '@aztec/stdlib/tx';
|
|
27
27
|
|
|
28
|
+
import type { AccessScopes } from '../../access_scopes.js';
|
|
28
29
|
import type { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
|
|
29
30
|
import { NoteService } from '../../notes/note_service.js';
|
|
30
31
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
@@ -43,7 +44,7 @@ export type PrivateExecutionOracleArgs = Omit<UtilityExecutionOracleArgs, 'contr
|
|
|
43
44
|
txContext: TxContext;
|
|
44
45
|
callContext: CallContext;
|
|
45
46
|
/** Needed to trigger contract synchronization before nested calls */
|
|
46
|
-
utilityExecutor: (call: FunctionCall) => Promise<void>;
|
|
47
|
+
utilityExecutor: (call: FunctionCall, scopes: AccessScopes) => Promise<void>;
|
|
47
48
|
executionCache: HashedValuesCache;
|
|
48
49
|
noteCache: ExecutionNoteCache;
|
|
49
50
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -78,7 +79,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
78
79
|
private readonly argsHash: Fr;
|
|
79
80
|
private readonly txContext: TxContext;
|
|
80
81
|
private readonly callContext: CallContext;
|
|
81
|
-
private readonly utilityExecutor: (call: FunctionCall) => Promise<void>;
|
|
82
|
+
private readonly utilityExecutor: (call: FunctionCall, scopes: AccessScopes) => Promise<void>;
|
|
82
83
|
private readonly executionCache: HashedValuesCache;
|
|
83
84
|
private readonly noteCache: ExecutionNoteCache;
|
|
84
85
|
private readonly taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -215,25 +216,29 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
215
216
|
* @returns An app tag to be used in a log.
|
|
216
217
|
*/
|
|
217
218
|
public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
|
|
218
|
-
const
|
|
219
|
+
const extendedSecret = await this.#calculateExtendedDirectionalAppTaggingSecret(
|
|
220
|
+
this.contractAddress,
|
|
221
|
+
sender,
|
|
222
|
+
recipient,
|
|
223
|
+
);
|
|
219
224
|
|
|
220
|
-
const index = await this.#getIndexToUseForSecret(
|
|
225
|
+
const index = await this.#getIndexToUseForSecret(extendedSecret);
|
|
221
226
|
this.log.debug(
|
|
222
227
|
`Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
|
|
223
228
|
);
|
|
224
|
-
this.taggingIndexCache.setLastUsedIndex(
|
|
229
|
+
this.taggingIndexCache.setLastUsedIndex(extendedSecret, index);
|
|
225
230
|
|
|
226
|
-
return Tag.compute({
|
|
231
|
+
return Tag.compute({ extendedSecret, index });
|
|
227
232
|
}
|
|
228
233
|
|
|
229
|
-
async #
|
|
234
|
+
async #calculateExtendedDirectionalAppTaggingSecret(
|
|
230
235
|
contractAddress: AztecAddress,
|
|
231
236
|
sender: AztecAddress,
|
|
232
237
|
recipient: AztecAddress,
|
|
233
238
|
) {
|
|
234
239
|
const senderCompleteAddress = await this.getCompleteAddressOrFail(sender);
|
|
235
240
|
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
|
|
236
|
-
return
|
|
241
|
+
return ExtendedDirectionalAppTaggingSecret.compute(
|
|
237
242
|
senderCompleteAddress,
|
|
238
243
|
senderIvsk,
|
|
239
244
|
recipient,
|
|
@@ -242,7 +247,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
242
247
|
);
|
|
243
248
|
}
|
|
244
249
|
|
|
245
|
-
async #getIndexToUseForSecret(secret:
|
|
250
|
+
async #getIndexToUseForSecret(secret: ExtendedDirectionalAppTaggingSecret): Promise<number> {
|
|
246
251
|
// If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
|
|
247
252
|
const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
|
|
248
253
|
|
|
@@ -254,7 +259,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
254
259
|
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
255
260
|
await syncSenderTaggingIndexes(
|
|
256
261
|
secret,
|
|
257
|
-
this.contractAddress,
|
|
258
262
|
this.aztecNode,
|
|
259
263
|
this.senderTaggingStore,
|
|
260
264
|
await this.anchorBlockHeader.hash(),
|
|
@@ -532,6 +536,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
532
536
|
this.utilityExecutor,
|
|
533
537
|
this.anchorBlockHeader,
|
|
534
538
|
this.jobId,
|
|
539
|
+
this.scopes,
|
|
535
540
|
);
|
|
536
541
|
|
|
537
542
|
const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
|