@aztec/pxe 4.0.0-devnet.1-patch.0 → 4.0.0-devnet.1-patch.1

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.
Files changed (27) hide show
  1. package/dest/contract_function_simulator/contract_function_simulator.d.ts +51 -28
  2. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  3. package/dest/contract_function_simulator/contract_function_simulator.js +165 -57
  4. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -36
  5. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +62 -17
  7. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +28 -11
  8. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +20 -22
  10. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  11. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  12. package/dest/entrypoints/client/bundle/utils.js +9 -1
  13. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  14. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  15. package/dest/entrypoints/client/lazy/utils.js +9 -1
  16. package/dest/entrypoints/server/utils.js +9 -1
  17. package/dest/pxe.d.ts +52 -21
  18. package/dest/pxe.d.ts.map +1 -1
  19. package/dest/pxe.js +31 -27
  20. package/package.json +16 -16
  21. package/src/contract_function_simulator/contract_function_simulator.ts +314 -117
  22. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +81 -93
  23. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +56 -19
  24. package/src/entrypoints/client/bundle/utils.ts +9 -1
  25. package/src/entrypoints/client/lazy/utils.ts +9 -1
  26. package/src/entrypoints/server/utils.ts +7 -7
  27. package/src/pxe.ts +84 -58
@@ -17,39 +17,61 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
17
17
  import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
18
18
  import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
19
19
  import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
20
+ /** Options for ContractFunctionSimulator.run. */
21
+ export type ContractSimulatorRunOpts = {
22
+ /** The address of the contract (should match request.origin). */
23
+ contractAddress: AztecAddress;
24
+ /** The function selector of the entry point. */
25
+ selector: FunctionSelector;
26
+ /** The address calling the function. Can be replaced to simulate a call from another contract or account. */
27
+ msgSender?: AztecAddress;
28
+ /** The block header to use as base state for this run. */
29
+ anchorBlockHeader: BlockHeader;
30
+ /** The address used as a tagging sender when emitting private logs. */
31
+ senderForTags?: AztecAddress;
32
+ /** The accounts whose notes we can access in this call. Defaults to all. */
33
+ scopes?: AztecAddress[];
34
+ /** The job ID for staged writes. */
35
+ jobId: string;
36
+ };
37
+ /** Args for ContractFunctionSimulator constructor. */
38
+ export type ContractFunctionSimulatorArgs = {
39
+ contractStore: ContractStore;
40
+ noteStore: NoteStore;
41
+ keyStore: KeyStore;
42
+ addressStore: AddressStore;
43
+ aztecNode: AztecNode;
44
+ senderTaggingStore: SenderTaggingStore;
45
+ recipientTaggingStore: RecipientTaggingStore;
46
+ senderAddressBookStore: SenderAddressBookStore;
47
+ capsuleStore: CapsuleStore;
48
+ privateEventStore: PrivateEventStore;
49
+ simulator: CircuitSimulator;
50
+ contractSyncService: ContractSyncService;
51
+ };
20
52
  /**
21
53
  * The contract function simulator.
22
54
  */
23
55
  export declare class ContractFunctionSimulator {
24
- private contractStore;
25
- private noteStore;
26
- private keyStore;
27
- private addressStore;
28
- private aztecNode;
29
- private senderTaggingStore;
30
- private recipientTaggingStore;
31
- private senderAddressBookStore;
32
- private capsuleStore;
33
- private privateEventStore;
34
- private simulator;
35
- private contractSyncService;
36
- private log;
37
- constructor(contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, aztecNode: AztecNode, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, simulator: CircuitSimulator, contractSyncService: ContractSyncService);
56
+ private readonly log;
57
+ private readonly contractStore;
58
+ private readonly noteStore;
59
+ private readonly keyStore;
60
+ private readonly addressStore;
61
+ private readonly aztecNode;
62
+ private readonly senderTaggingStore;
63
+ private readonly recipientTaggingStore;
64
+ private readonly senderAddressBookStore;
65
+ private readonly capsuleStore;
66
+ private readonly privateEventStore;
67
+ private readonly simulator;
68
+ private readonly contractSyncService;
69
+ constructor(args: ContractFunctionSimulatorArgs);
38
70
  /**
39
71
  * Runs a private function.
40
72
  * @param request - The transaction request.
41
- * @param entryPointArtifact - The artifact of the entry point function.
42
- * @param contractAddress - The address of the contract (should match request.origin)
43
- * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
44
- * or a specific account.
45
- * @param anchorBlockHeader - The block header to use as base state for this run.
46
- * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
47
- * the `privateGetSenderForTags` oracle.
48
- * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
49
- * @param jobId - The job ID for staged writes.
50
- * @returns The result of the execution.
51
73
  */
52
- run(request: TxExecutionRequest, contractAddress: AztecAddress, selector: FunctionSelector, msgSender: AztecAddress | undefined, anchorBlockHeader: BlockHeader, senderForTags: AztecAddress | undefined, scopes: AztecAddress[] | undefined, jobId: string): Promise<PrivateExecutionResult>;
74
+ run(request: TxExecutionRequest, { contractAddress, selector, msgSender, anchorBlockHeader, senderForTags, scopes, jobId }: ContractSimulatorRunOpts): Promise<PrivateExecutionResult>;
53
75
  /**
54
76
  * Runs a utility function.
55
77
  * @param call - The function call to execute.
@@ -75,10 +97,11 @@ export declare class ContractFunctionSimulator {
75
97
  * (allowing state overrides) and is much faster, while still generating a valid
76
98
  * output that can be sent to the node for public simulation
77
99
  * @param privateExecutionResult - The result of the private execution.
78
- * @param contractStore - A provider for contract data in order to get function names and debug info.
100
+ * @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
101
+ * @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
79
102
  * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
80
103
  * Used by TXE to simulate account contract behavior (setting the counter before app execution).
81
104
  * @returns The simulated proving result.
82
105
  */
83
- export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
84
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR2pELE9BQU8sRUFDTCxLQUFLLGdCQUFnQixFQU90QixNQUFNLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxnQkFBZ0IsRUFBZ0IsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE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FQUFFLEVBQ3ZCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsTUFBTSxFQUFFLFlBQVksRUFBRSxHQUFHLFNBQVMsRUFDbEMsS0FBSyxFQUFFLE1BQU0sR0FDWixPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FxRGY7SUFHRDs7O09BR0c7SUFDSCxRQUFROztNQVVQO0NBQ0Y7QUFZRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILHdCQUFzQiw4QkFBOEIsQ0FDbEQsc0JBQXNCLEVBQUUsc0JBQXNCLEVBQzlDLHVCQUF1QixFQUFFLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxnQkFBZ0IsRUFBRSxnQkFBZ0IsS0FBSyxPQUFPLENBQUMsTUFBTSxDQUFDLEVBQy9HLHNDQUFzQyxDQUFDLEVBQUUsTUFBTSxHQUM5QyxPQUFPLENBQUMsaUNBQWlDLENBQUMsb0NBQW9DLENBQUMsQ0FBQyxDQTJObEYifQ==
106
+ export declare function generateSimulatedProvingResult(privateExecutionResult: PrivateExecutionResult, debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>, node: AztecNode, minRevertibleSideEffectCounterOverride?: number): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>>;
107
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUEwQkEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUF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VFHO0lBQ1UsVUFBVSxDQUNyQixJQUFJLEVBQUUsWUFBWSxFQUNsQixRQUFRLEVBQUUsV0FBVyxFQUFFLEVBQ3ZCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsTUFBTSxFQUFFLFlBQVksRUFBRSxHQUFHLFNBQVMsRUFDbEMsS0FBSyxFQUFFLE1BQU0sR0FDWixPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FvRGY7SUFHRDs7O09BR0c7SUFDSCxRQUFROztNQVVQO0NBQ0Y7QUFZRDs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCx3QkFBc0IsOEJBQThCLENBQ2xELHNCQUFzQixFQUFFLHNCQUFzQixFQUM5Qyx1QkFBdUIsRUFBRSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsZ0JBQWdCLEtBQUssT0FBTyxDQUFDLE1BQU0sQ0FBQyxFQUMvRyxJQUFJLEVBQUUsU0FBUyxFQUNmLHNDQUFzQyxDQUFDLEVBQUUsTUFBTSxHQUM5QyxPQUFPLENBQUMsaUNBQWlDLENBQUMsb0NBQW9DLENBQUMsQ0FBQyxDQStQbEYifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CA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AS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,gBAAgB,EAC3B,mBAAmB,EAAE,mBAAmB,EAGjD;IAED;;;;;;;;;;;;;OAaG;IACU,GAAG,CACd,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,0BAA6C,EACtD,iBAAiB,EAAE,WAAW,EAC9B,aAAa,EAAE,YAAY,GAAG,SAAS,EACvC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CA4GjC;IAGD;;;;;;;;OAQG;IACU,UAAU,CACrB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,WAAW,EAAE,EACvB,iBAAiB,EAAE,WAAW,EAC9B,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,EAAE,EAAE,CAAC,CAqDf;IAGD;;;OAGG;IACH,QAAQ;;MAUP;CACF;AAYD;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAClD,sBAAsB,EAAE,sBAAsB,EAC9C,uBAAuB,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,KAAK,OAAO,CAAC,MAAM,CAAC,EAC/G,sCAAsC,CAAC,EAAE,MAAM,GAC9C,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CA2NlF"}
1
+ {"version":3,"file":"contract_function_simulator.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/contract_function_simulator.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KA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_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
1
+ import { AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS, GeneratorIndex, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
2
2
  import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
3
3
  import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -11,11 +11,11 @@ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
11
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
12
  import { Gas } from '@aztec/stdlib/gas';
13
13
  import { computeNoteHashNonce, computeProtocolNullifier, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
14
- import { PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ScopedLogHash } from '@aztec/stdlib/kernel';
14
+ import { ClaimedLengthArray, PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PrivateToRollupAccumulatedData, PublicCallRequest, ReadRequestActionEnum, ScopedLogHash, ScopedNoteHash, ScopedNullifier, ScopedReadRequest, buildTransientDataHints, getNoteHashReadRequestResetActions, getNullifierReadRequestResetActions } from '@aztec/stdlib/kernel';
15
15
  import { PrivateLog } from '@aztec/stdlib/logs';
16
16
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
17
  import { ChonkProof } from '@aztec/stdlib/proofs';
18
- import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
18
+ import { CallContext, HashedValues, PrivateExecutionResult, TxConstantData, collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
19
19
  import { ExecutionNoteCache } from './execution_note_cache.js';
20
20
  import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
21
21
  import { HashedValuesCache } from './hashed_values_cache.js';
@@ -26,6 +26,7 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
26
26
  /**
27
27
  * The contract function simulator.
28
28
  */ export class ContractFunctionSimulator {
29
+ log;
29
30
  contractStore;
30
31
  noteStore;
31
32
  keyStore;
@@ -38,36 +39,25 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
38
39
  privateEventStore;
39
40
  simulator;
40
41
  contractSyncService;
41
- log;
42
- constructor(contractStore, noteStore, keyStore, addressStore, aztecNode, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, simulator, contractSyncService){
43
- this.contractStore = contractStore;
44
- this.noteStore = noteStore;
45
- this.keyStore = keyStore;
46
- this.addressStore = addressStore;
47
- this.aztecNode = aztecNode;
48
- this.senderTaggingStore = senderTaggingStore;
49
- this.recipientTaggingStore = recipientTaggingStore;
50
- this.senderAddressBookStore = senderAddressBookStore;
51
- this.capsuleStore = capsuleStore;
52
- this.privateEventStore = privateEventStore;
53
- this.simulator = simulator;
54
- this.contractSyncService = contractSyncService;
42
+ constructor(args){
43
+ this.contractStore = args.contractStore;
44
+ this.noteStore = args.noteStore;
45
+ this.keyStore = args.keyStore;
46
+ this.addressStore = args.addressStore;
47
+ this.aztecNode = args.aztecNode;
48
+ this.senderTaggingStore = args.senderTaggingStore;
49
+ this.recipientTaggingStore = args.recipientTaggingStore;
50
+ this.senderAddressBookStore = args.senderAddressBookStore;
51
+ this.capsuleStore = args.capsuleStore;
52
+ this.privateEventStore = args.privateEventStore;
53
+ this.simulator = args.simulator;
54
+ this.contractSyncService = args.contractSyncService;
55
55
  this.log = createLogger('simulator');
56
56
  }
57
57
  /**
58
58
  * Runs a private function.
59
59
  * @param request - The transaction request.
60
- * @param entryPointArtifact - The artifact of the entry point function.
61
- * @param contractAddress - The address of the contract (should match request.origin)
62
- * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
63
- * or a specific account.
64
- * @param anchorBlockHeader - The block header to use as base state for this run.
65
- * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
66
- * the `privateGetSenderForTags` oracle.
67
- * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
68
- * @param jobId - The job ID for staged writes.
69
- * @returns The result of the execution.
70
- */ async run(request, contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId) {
60
+ */ async run(request, { contractAddress, selector, msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE), anchorBlockHeader, senderForTags, scopes, jobId }) {
71
61
  const simulatorSetupTimer = new Timer();
72
62
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
73
63
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
@@ -82,9 +72,37 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
82
72
  const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
83
73
  const noteCache = new ExecutionNoteCache(protocolNullifier);
84
74
  const taggingIndexCache = new ExecutionTaggingIndexCache();
85
- const privateExecutionOracle = new PrivateExecutionOracle(request.firstCallArgsHash, request.txContext, callContext, anchorBlockHeader, async (call)=>{
86
- await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
87
- }, request.authWitnesses, request.capsules, HashedValuesCache.create(request.argsOfCalls), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.contractSyncService, jobId, 0, startSideEffectCounter, undefined, scopes, senderForTags, this.simulator);
75
+ const privateExecutionOracle = new PrivateExecutionOracle({
76
+ argsHash: request.firstCallArgsHash,
77
+ txContext: request.txContext,
78
+ callContext,
79
+ anchorBlockHeader,
80
+ utilityExecutor: async (call)=>{
81
+ await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
82
+ },
83
+ authWitnesses: request.authWitnesses,
84
+ capsules: request.capsules,
85
+ executionCache: HashedValuesCache.create(request.argsOfCalls),
86
+ noteCache,
87
+ taggingIndexCache,
88
+ contractStore: this.contractStore,
89
+ noteStore: this.noteStore,
90
+ keyStore: this.keyStore,
91
+ addressStore: this.addressStore,
92
+ aztecNode: this.aztecNode,
93
+ senderTaggingStore: this.senderTaggingStore,
94
+ recipientTaggingStore: this.recipientTaggingStore,
95
+ senderAddressBookStore: this.senderAddressBookStore,
96
+ capsuleStore: this.capsuleStore,
97
+ privateEventStore: this.privateEventStore,
98
+ contractSyncService: this.contractSyncService,
99
+ jobId,
100
+ totalPublicCalldataCount: 0,
101
+ sideEffectCounter: startSideEffectCounter,
102
+ scopes,
103
+ senderForTags,
104
+ simulator: this.simulator
105
+ });
88
106
  const setupTime = simulatorSetupTimer.ms();
89
107
  try {
90
108
  // Note: any nested private function calls are made recursively within this
@@ -131,7 +149,23 @@ import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
131
149
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
132
150
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
133
151
  }
134
- const oracle = new UtilityExecutionOracle(call.to, authwits, [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.aztecNode, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, jobId, undefined, scopes);
152
+ const oracle = new UtilityExecutionOracle({
153
+ contractAddress: call.to,
154
+ authWitnesses: authwits,
155
+ capsules: [],
156
+ anchorBlockHeader,
157
+ contractStore: this.contractStore,
158
+ noteStore: this.noteStore,
159
+ keyStore: this.keyStore,
160
+ addressStore: this.addressStore,
161
+ aztecNode: this.aztecNode,
162
+ recipientTaggingStore: this.recipientTaggingStore,
163
+ senderAddressBookStore: this.senderAddressBookStore,
164
+ capsuleStore: this.capsuleStore,
165
+ privateEventStore: this.privateEventStore,
166
+ jobId,
167
+ scopes
168
+ });
135
169
  try {
136
170
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
137
171
  contract: call.to,
@@ -187,18 +221,24 @@ class OrderedSideEffect {
187
221
  * (allowing state overrides) and is much faster, while still generating a valid
188
222
  * output that can be sent to the node for public simulation
189
223
  * @param privateExecutionResult - The result of the private execution.
190
- * @param contractStore - A provider for contract data in order to get function names and debug info.
224
+ * @param debugFunctionNameGetter - A provider for contract data in order to get function names and debug info.
225
+ * @param node - AztecNode for verifying settled read requests against the note hash and nullifier trees.
191
226
  * @param minRevertibleSideEffectCounterOverride - Optional override for the min revertible side effect counter.
192
227
  * Used by TXE to simulate account contract behavior (setting the counter before app execution).
193
228
  * @returns The simulated proving result.
194
- */ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, minRevertibleSideEffectCounterOverride) {
195
- const siloedNoteHashes = [];
196
- const nullifiers = [];
229
+ */ export async function generateSimulatedProvingResult(privateExecutionResult, debugFunctionNameGetter, node, minRevertibleSideEffectCounterOverride) {
197
230
  const taggedPrivateLogs = [];
198
231
  const l2ToL1Messages = [];
199
232
  const contractClassLogsHashes = [];
200
233
  const publicCallRequests = [];
201
234
  const executionSteps = [];
235
+ // Unsiloed scoped arrays — used for squashing, read request verification,
236
+ // and siloed at the end only for the surviving items
237
+ const scopedNoteHashes = [];
238
+ const scopedNullifiers = [];
239
+ // Read requests for verification
240
+ const noteHashReadRequests = [];
241
+ const nullifierReadRequests = [];
202
242
  let publicTeardownCallRequest;
203
243
  const executions = [
204
244
  privateExecutionResult.entrypoint
@@ -207,18 +247,17 @@ class OrderedSideEffect {
207
247
  const execution = executions.shift();
208
248
  executions.unshift(...execution.nestedExecutionResults);
209
249
  const { contractAddress } = execution.publicInputs.callContext;
210
- const noteHashesFromExecution = await Promise.all(execution.publicInputs.noteHashes.getActiveItems().filter((noteHash)=>!noteHash.isEmpty()).map(async (noteHash)=>new OrderedSideEffect(await siloNoteHash(contractAddress, noteHash.value), noteHash.counter)));
211
- const nullifiersFromExecution = await Promise.all(execution.publicInputs.nullifiers.getActiveItems().map(async (nullifier)=>new OrderedSideEffect(await siloNullifier(contractAddress, nullifier.value), nullifier.counter)));
212
- const privateLogsFromExecution = await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
250
+ scopedNoteHashes.push(...execution.publicInputs.noteHashes.getActiveItems().filter((nh)=>!nh.isEmpty()).map((nh)=>nh.scope(contractAddress)));
251
+ scopedNullifiers.push(...execution.publicInputs.nullifiers.getActiveItems().map((n)=>n.scope(contractAddress)));
252
+ taggedPrivateLogs.push(...await Promise.all(execution.publicInputs.privateLogs.getActiveItems().map(async (metadata)=>{
213
253
  metadata.log.fields[0] = await poseidon2HashWithSeparator([
214
254
  contractAddress,
215
255
  metadata.log.fields[0]
216
256
  ], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
217
- return new OrderedSideEffect(metadata.log, metadata.counter);
218
- }));
219
- siloedNoteHashes.push(...noteHashesFromExecution);
220
- taggedPrivateLogs.push(...privateLogsFromExecution);
221
- nullifiers.push(...nullifiersFromExecution);
257
+ return new OrderedSideEffect(metadata, metadata.counter);
258
+ })));
259
+ noteHashReadRequests.push(...execution.publicInputs.noteHashReadRequests.getActiveItems());
260
+ nullifierReadRequests.push(...execution.publicInputs.nullifierReadRequests.getActiveItems());
222
261
  l2ToL1Messages.push(...execution.publicInputs.l2ToL1Msgs.getActiveItems().map((message)=>new OrderedSideEffect(message.message.scope(contractAddress), message.counter)));
223
262
  contractClassLogsHashes.push(...execution.publicInputs.contractClassLogsHashes.getActiveItems().map((contractClassLogHash)=>new OrderedSideEffect(contractClassLogHash.logHash.scope(contractAddress), contractClassLogHash.counter)));
224
263
  publicCallRequests.push(...execution.publicInputs.publicCallRequests.getActiveItems().map((callRequest)=>new OrderedSideEffect(callRequest.inner, callRequest.counter)));
@@ -237,6 +276,14 @@ class OrderedSideEffect {
237
276
  witness: execution.partialWitness
238
277
  });
239
278
  }
279
+ const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(privateExecutionResult);
280
+ const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
281
+ const scopedNoteHashesCLA = new ClaimedLengthArray(padArrayEnd(scopedNoteHashes, ScopedNoteHash.empty(), MAX_NOTE_HASHES_PER_TX), scopedNoteHashes.length);
282
+ const scopedNullifiersCLA = new ClaimedLengthArray(padArrayEnd(scopedNullifiers, ScopedNullifier.empty(), MAX_NULLIFIERS_PER_TX), scopedNullifiers.length);
283
+ const { filteredNoteHashes, filteredNullifiers, filteredPrivateLogs } = squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
284
+ await verifyReadRequests(node, await privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.hash(), noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA);
285
+ const siloedNoteHashes = await Promise.all(filteredNoteHashes.sort((a, b)=>a.counter - b.counter).map(async (nh)=>new OrderedSideEffect(await siloNoteHash(nh.contractAddress, nh.value), nh.counter)));
286
+ const siloedNullifiers = await Promise.all(filteredNullifiers.sort((a, b)=>a.counter - b.counter).map(async (n)=>new OrderedSideEffect(await siloNullifier(n.contractAddress, n.value), n.counter)));
240
287
  const constantData = new TxConstantData(privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader, privateExecutionResult.entrypoint.publicInputs.txContext, getVKTreeRoot(), protocolContractsHash);
241
288
  const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
242
289
  let inputsForRollup;
@@ -245,8 +292,7 @@ class OrderedSideEffect {
245
292
  const sortByCounter = (a, b)=>a.counter - b.counter;
246
293
  const getEffect = (orderedSideEffect)=>orderedSideEffect.sideEffect;
247
294
  const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
248
- const minRevertibleSideEffectCounter = minRevertibleSideEffectCounterOverride ?? getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
249
- const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(nullifiers.sort(sortByCounter), minRevertibleSideEffectCounter);
295
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(siloedNullifiers, minRevertibleSideEffectCounter);
250
296
  const nonceGenerator = privateExecutionResult.firstNullifier;
251
297
  if (nonRevertibleNullifiers.length === 0) {
252
298
  nonRevertibleNullifiers.push(nonceGenerator);
@@ -256,30 +302,30 @@ class OrderedSideEffect {
256
302
  if (isPrivateOnlyTx) {
257
303
  // We must make the note hashes unique by using the
258
304
  // nonce generator and their index in the tx.
259
- const uniqueNoteHashes = await Promise.all(siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i)=>{
305
+ const uniqueNoteHashes = await Promise.all(siloedNoteHashes.map(async (orderedSideEffect, i)=>{
260
306
  const siloedNoteHash = orderedSideEffect.sideEffect;
261
307
  const nonce = await computeNoteHashNonce(nonceGenerator, i);
262
308
  const uniqueNoteHash = await computeUniqueNoteHash(nonce, siloedNoteHash);
263
309
  return uniqueNoteHash;
264
310
  }));
265
- const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(contractClassLogsHashes.sort(sortByCounter).map(getEffect), ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX));
266
- gasUsed = meterGasUsed(accumulatedDataForRollup);
311
+ const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(l2ToL1Messages.sort(sortByCounter).map(getEffect), ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(filteredPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(contractClassLogsHashes.sort(sortByCounter).map(getEffect), ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX));
312
+ gasUsed = meterGasUsed(accumulatedDataForRollup, isPrivateOnlyTx);
267
313
  inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
268
314
  } else {
269
- const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
315
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(siloedNoteHashes, minRevertibleSideEffectCounter);
270
316
  const nonRevertibleUniqueNoteHashes = await Promise.all(nonRevertibleNoteHashes.map(async (noteHash, i)=>{
271
317
  const nonce = await computeNoteHashNonce(nonceGenerator, i);
272
318
  return await computeUniqueNoteHash(nonce, noteHash);
273
319
  }));
274
320
  const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(l2ToL1Messages.sort(sortByCounter), minRevertibleSideEffectCounter);
275
- const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(taggedPrivateLogs, minRevertibleSideEffectCounter);
321
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(filteredPrivateLogs, minRevertibleSideEffectCounter);
276
322
  const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(contractClassLogsHashes.sort(sortByCounter), minRevertibleSideEffectCounter);
277
323
  const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(publicCallRequests.sort(sortByCounter), minRevertibleSideEffectCounter);
278
324
  const nonRevertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(nonRevertibleUniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
279
325
  const revertibleData = new PrivateToPublicAccumulatedData(padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX), padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX), padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX), padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX), padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX));
280
- gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
326
+ gasUsed = meterGasUsed(revertibleData, isPrivateOnlyTx).add(meterGasUsed(nonRevertibleData, isPrivateOnlyTx));
281
327
  if (publicTeardownCallRequest) {
282
- gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
328
+ gasUsed = gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
283
329
  }
284
330
  inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleData, revertibleData, publicTeardownCallRequest ?? PublicCallRequest.empty());
285
331
  }
@@ -293,6 +339,65 @@ class OrderedSideEffect {
293
339
  executionSteps
294
340
  };
295
341
  }
342
+ /**
343
+ * Squashes transient note hashes and nullifiers, mimicking the behavior
344
+ * of the reset kernels. Returns the filtered (surviving) scoped items and private logs.
345
+ */ function squashTransientSideEffects(taggedPrivateLogs, scopedNoteHashesCLA, scopedNullifiersCLA, noteHashNullifierCounterMap, minRevertibleSideEffectCounter) {
346
+ const { numTransientData, hints: transientDataHints } = buildTransientDataHints(scopedNoteHashesCLA, scopedNullifiersCLA, /*futureNoteHashReads=*/ [], /*futureNullifierReads=*/ [], noteHashNullifierCounterMap, minRevertibleSideEffectCounter);
347
+ const squashedNoteHashCounters = new Set();
348
+ const squashedNullifierCounters = new Set();
349
+ for(let i = 0; i < numTransientData; i++){
350
+ const hint = transientDataHints[i];
351
+ squashedNoteHashCounters.add(scopedNoteHashesCLA.array[hint.noteHashIndex].counter);
352
+ squashedNullifierCounters.add(scopedNullifiersCLA.array[hint.nullifierIndex].counter);
353
+ }
354
+ return {
355
+ filteredNoteHashes: scopedNoteHashesCLA.getActiveItems().filter((nh)=>!squashedNoteHashCounters.has(nh.counter)),
356
+ filteredNullifiers: scopedNullifiersCLA.getActiveItems().filter((n)=>!squashedNullifierCounters.has(n.counter)),
357
+ filteredPrivateLogs: taggedPrivateLogs.filter((item)=>!squashedNoteHashCounters.has(item.sideEffect.noteHashCounter)).map((item)=>new OrderedSideEffect(item.sideEffect.log, item.counter))
358
+ };
359
+ }
360
+ /**
361
+ * Verifies settled read requests by checking membership in the note hash and nullifier trees
362
+ * at the tx's anchor block, mimicking the behavior of the kernels
363
+ */ async function verifyReadRequests(node, anchorBlockHash, noteHashReadRequests, nullifierReadRequests, scopedNoteHashesCLA, scopedNullifiersCLA) {
364
+ const noteHashReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(noteHashReadRequests, ScopedReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_TX), noteHashReadRequests.length);
365
+ const nullifierReadRequestsCLA = new ClaimedLengthArray(padArrayEnd(nullifierReadRequests, ScopedReadRequest.empty(), MAX_NULLIFIER_READ_REQUESTS_PER_TX), nullifierReadRequests.length);
366
+ const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA, /*futureNoteHashes=*/ []);
367
+ const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA, /*futureNullifiers=*/ []);
368
+ const settledNoteHashReads = [];
369
+ for(let i = 0; i < noteHashResetActions.actions.length; i++){
370
+ if (noteHashResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
371
+ settledNoteHashReads.push({
372
+ index: i,
373
+ value: noteHashReadRequests[i].value
374
+ });
375
+ }
376
+ }
377
+ const settledNullifierReads = [];
378
+ for(let i = 0; i < nullifierResetActions.actions.length; i++){
379
+ if (nullifierResetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
380
+ settledNullifierReads.push({
381
+ index: i,
382
+ value: nullifierReadRequests[i].value
383
+ });
384
+ }
385
+ }
386
+ const [noteHashWitnesses, nullifierWitnesses] = await Promise.all([
387
+ Promise.all(settledNoteHashReads.map(({ value })=>node.getNoteHashMembershipWitness(anchorBlockHash, value))),
388
+ Promise.all(settledNullifierReads.map(({ value })=>node.getNullifierMembershipWitness(anchorBlockHash, value)))
389
+ ]);
390
+ for(let i = 0; i < settledNoteHashReads.length; i++){
391
+ if (!noteHashWitnesses[i]) {
392
+ throw new Error(`Note hash read request at index ${settledNoteHashReads[i].index} is reading an unknown note hash: ${settledNoteHashReads[i].value}`);
393
+ }
394
+ }
395
+ for(let i = 0; i < settledNullifierReads.length; i++){
396
+ if (!nullifierWitnesses[i]) {
397
+ throw new Error(`Nullifier read request at index ${settledNullifierReads[i].index} is reading an unknown nullifier: ${settledNullifierReads[i].value}`);
398
+ }
399
+ }
400
+ }
296
401
  function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
297
402
  const revertibleSideEffects = [];
298
403
  const nonRevertibleSideEffects = [];
@@ -308,18 +413,21 @@ function splitOrderedSideEffects(effects, minRevertibleSideEffectCounter) {
308
413
  revertibleSideEffects
309
414
  ];
310
415
  }
311
- function meterGasUsed(data) {
416
+ function meterGasUsed(data, isPrivateOnlyTx) {
312
417
  let meteredDAFields = 0;
313
418
  let meteredL2Gas = 0;
314
419
  const numNoteHashes = arrayNonEmptyLength(data.noteHashes, (hash)=>hash.isEmpty());
315
420
  meteredDAFields += numNoteHashes;
316
- meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
421
+ const noteHashBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NOTE_HASH : AVM_EMITNOTEHASH_BASE_L2_GAS;
422
+ meteredL2Gas += numNoteHashes * noteHashBaseGas;
317
423
  const numNullifiers = arrayNonEmptyLength(data.nullifiers, (nullifier)=>nullifier.isEmpty());
318
424
  meteredDAFields += numNullifiers;
319
- meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
425
+ const nullifierBaseGas = isPrivateOnlyTx ? L2_GAS_PER_NULLIFIER : AVM_EMITNULLIFIER_BASE_L2_GAS;
426
+ meteredL2Gas += numNullifiers * nullifierBaseGas;
320
427
  const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, (msg)=>msg.isEmpty());
321
428
  meteredDAFields += numL2toL1Messages;
322
- meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
429
+ const l2ToL1MessageBaseGas = isPrivateOnlyTx ? L2_GAS_PER_L2_TO_L1_MSG : AVM_SENDL2TOL1MSG_BASE_L2_GAS;
430
+ meteredL2Gas += numL2toL1Messages * l2ToL1MessageBaseGas;
323
431
  const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, (log)=>log.isEmpty());
324
432
  // Every private log emits its length as an additional field
325
433
  meteredDAFields += data.privateLogs.reduce((acc, log)=>!log.isEmpty() ? acc + log.emittedLength + 1 : acc, 0);