@aztec/simulator 0.66.0 → 0.67.1-devnet

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 (158) hide show
  1. package/dest/acvm/acvm.js +3 -3
  2. package/dest/acvm/oracle/oracle.d.ts +2 -2
  3. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  4. package/dest/acvm/oracle/oracle.js +5 -5
  5. package/dest/acvm/oracle/typed_oracle.d.ts +3 -3
  6. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  7. package/dest/acvm/oracle/typed_oracle.js +5 -5
  8. package/dest/acvm/serialize.js +2 -2
  9. package/dest/avm/avm_context.d.ts +2 -2
  10. package/dest/avm/avm_context.d.ts.map +1 -1
  11. package/dest/avm/avm_context.js +3 -4
  12. package/dest/avm/avm_execution_environment.d.ts +4 -6
  13. package/dest/avm/avm_execution_environment.d.ts.map +1 -1
  14. package/dest/avm/avm_execution_environment.js +8 -13
  15. package/dest/avm/avm_memory_types.d.ts +3 -3
  16. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  17. package/dest/avm/avm_memory_types.js +29 -29
  18. package/dest/avm/avm_simulator.d.ts +3 -3
  19. package/dest/avm/avm_simulator.d.ts.map +1 -1
  20. package/dest/avm/avm_simulator.js +27 -15
  21. package/dest/avm/avm_tree.d.ts +2 -1
  22. package/dest/avm/avm_tree.d.ts.map +1 -1
  23. package/dest/avm/avm_tree.js +6 -2
  24. package/dest/avm/errors.d.ts +3 -3
  25. package/dest/avm/errors.d.ts.map +1 -1
  26. package/dest/avm/errors.js +8 -15
  27. package/dest/avm/fixtures/index.d.ts +2 -0
  28. package/dest/avm/fixtures/index.d.ts.map +1 -1
  29. package/dest/avm/fixtures/index.js +7 -7
  30. package/dest/avm/journal/journal.d.ts +31 -8
  31. package/dest/avm/journal/journal.d.ts.map +1 -1
  32. package/dest/avm/journal/journal.js +139 -42
  33. package/dest/avm/opcodes/conversion.d.ts +4 -4
  34. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  35. package/dest/avm/opcodes/conversion.js +22 -18
  36. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  37. package/dest/avm/opcodes/external_calls.js +4 -11
  38. package/dest/avm/opcodes/misc.d.ts.map +1 -1
  39. package/dest/avm/opcodes/misc.js +3 -3
  40. package/dest/avm/test_utils.d.ts +1 -0
  41. package/dest/avm/test_utils.d.ts.map +1 -1
  42. package/dest/avm/test_utils.js +4 -1
  43. package/dest/client/client_execution_context.d.ts +3 -3
  44. package/dest/client/client_execution_context.d.ts.map +1 -1
  45. package/dest/client/client_execution_context.js +15 -8
  46. package/dest/client/db_oracle.d.ts +9 -5
  47. package/dest/client/db_oracle.d.ts.map +1 -1
  48. package/dest/client/execution_note_cache.d.ts +9 -1
  49. package/dest/client/execution_note_cache.d.ts.map +1 -1
  50. package/dest/client/execution_note_cache.js +10 -3
  51. package/dest/client/index.d.ts +1 -0
  52. package/dest/client/index.d.ts.map +1 -1
  53. package/dest/client/index.js +2 -1
  54. package/dest/client/private_execution.d.ts.map +1 -1
  55. package/dest/client/private_execution.js +4 -4
  56. package/dest/client/simulator.d.ts.map +1 -1
  57. package/dest/client/simulator.js +4 -4
  58. package/dest/client/unconstrained_execution.d.ts.map +1 -1
  59. package/dest/client/unconstrained_execution.js +3 -3
  60. package/dest/client/view_data_oracle.d.ts +4 -4
  61. package/dest/client/view_data_oracle.d.ts.map +1 -1
  62. package/dest/client/view_data_oracle.js +9 -9
  63. package/dest/common/debug_fn_name.d.ts +2 -2
  64. package/dest/common/debug_fn_name.d.ts.map +1 -1
  65. package/dest/common/debug_fn_name.js +8 -14
  66. package/dest/providers/acvm_native.js +4 -4
  67. package/dest/providers/acvm_wasm.js +2 -2
  68. package/dest/providers/factory.d.ts +2 -2
  69. package/dest/providers/factory.d.ts.map +1 -1
  70. package/dest/providers/factory.js +4 -4
  71. package/dest/providers/index.d.ts +0 -1
  72. package/dest/providers/index.d.ts.map +1 -1
  73. package/dest/providers/index.js +1 -2
  74. package/dest/public/enqueued_call_side_effect_trace.d.ts +15 -26
  75. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  76. package/dest/public/enqueued_call_side_effect_trace.js +42 -62
  77. package/dest/public/execution.d.ts +2 -2
  78. package/dest/public/execution.d.ts.map +1 -1
  79. package/dest/public/execution.js +1 -1
  80. package/dest/public/executor_metrics.d.ts.map +1 -1
  81. package/dest/public/executor_metrics.js +2 -5
  82. package/dest/public/fee_payment.d.ts.map +1 -1
  83. package/dest/public/fee_payment.js +4 -3
  84. package/dest/public/fixtures/index.d.ts +24 -1
  85. package/dest/public/fixtures/index.d.ts.map +1 -1
  86. package/dest/public/fixtures/index.js +17 -11
  87. package/dest/public/index.d.ts +0 -1
  88. package/dest/public/index.d.ts.map +1 -1
  89. package/dest/public/index.js +1 -2
  90. package/dest/public/public_db_sources.d.ts.map +1 -1
  91. package/dest/public/public_db_sources.js +10 -9
  92. package/dest/public/public_processor.d.ts +12 -12
  93. package/dest/public/public_processor.d.ts.map +1 -1
  94. package/dest/public/public_processor.js +80 -68
  95. package/dest/public/public_processor_metrics.d.ts +1 -1
  96. package/dest/public/public_processor_metrics.d.ts.map +1 -1
  97. package/dest/public/public_tx_context.d.ts +13 -10
  98. package/dest/public/public_tx_context.d.ts.map +1 -1
  99. package/dest/public/public_tx_context.js +72 -45
  100. package/dest/public/public_tx_simulator.d.ts +2 -2
  101. package/dest/public/public_tx_simulator.d.ts.map +1 -1
  102. package/dest/public/public_tx_simulator.js +54 -23
  103. package/dest/public/side_effect_trace_interface.d.ts +6 -18
  104. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  105. package/dest/public/transitional_adapters.d.ts +2 -2
  106. package/dest/public/transitional_adapters.d.ts.map +1 -1
  107. package/dest/public/transitional_adapters.js +10 -39
  108. package/package.json +16 -9
  109. package/src/acvm/acvm.ts +2 -2
  110. package/src/acvm/oracle/oracle.ts +4 -4
  111. package/src/acvm/oracle/typed_oracle.ts +5 -5
  112. package/src/acvm/serialize.ts +1 -1
  113. package/src/avm/avm_context.ts +2 -3
  114. package/src/avm/avm_execution_environment.ts +6 -31
  115. package/src/avm/avm_memory_types.ts +31 -29
  116. package/src/avm/avm_simulator.ts +28 -22
  117. package/src/avm/avm_tree.ts +6 -1
  118. package/src/avm/errors.ts +12 -14
  119. package/src/avm/fixtures/index.ts +6 -5
  120. package/src/avm/journal/journal.ts +230 -71
  121. package/src/avm/opcodes/conversion.ts +21 -16
  122. package/src/avm/opcodes/external_calls.ts +3 -19
  123. package/src/avm/opcodes/misc.ts +2 -2
  124. package/src/avm/test_utils.ts +4 -0
  125. package/src/client/client_execution_context.ts +19 -9
  126. package/src/client/db_oracle.ts +10 -5
  127. package/src/client/execution_note_cache.ts +13 -3
  128. package/src/client/index.ts +1 -0
  129. package/src/client/private_execution.ts +3 -3
  130. package/src/client/simulator.ts +4 -4
  131. package/src/client/unconstrained_execution.ts +2 -2
  132. package/src/client/view_data_oracle.ts +11 -9
  133. package/src/common/debug_fn_name.ts +7 -13
  134. package/src/providers/acvm_native.ts +3 -3
  135. package/src/providers/acvm_wasm.ts +2 -2
  136. package/src/providers/factory.ts +3 -3
  137. package/src/providers/index.ts +0 -1
  138. package/src/public/enqueued_call_side_effect_trace.ts +62 -86
  139. package/src/public/execution.ts +1 -2
  140. package/src/public/executor_metrics.ts +0 -4
  141. package/src/public/fee_payment.ts +3 -2
  142. package/src/public/fixtures/index.ts +25 -12
  143. package/src/public/index.ts +0 -1
  144. package/src/public/public_db_sources.ts +9 -8
  145. package/src/public/public_processor.ts +109 -105
  146. package/src/public/public_processor_metrics.ts +1 -1
  147. package/src/public/public_tx_context.ts +97 -50
  148. package/src/public/public_tx_simulator.ts +69 -38
  149. package/src/public/side_effect_trace_interface.ts +10 -16
  150. package/src/public/transitional_adapters.ts +12 -48
  151. package/dest/public/dual_side_effect_trace.d.ts +0 -77
  152. package/dest/public/dual_side_effect_trace.d.ts.map +0 -1
  153. package/dest/public/dual_side_effect_trace.js +0 -119
  154. package/dest/public/side_effect_trace.d.ts +0 -96
  155. package/dest/public/side_effect_trace.d.ts.map +0 -1
  156. package/dest/public/side_effect_trace.js +0 -309
  157. package/src/public/dual_side_effect_trace.ts +0 -242
  158. package/src/public/side_effect_trace.ts +0 -536
@@ -1,4 +1,4 @@
1
- import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
1
+ import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { type AvmContext } from '../avm_context.js';
4
4
  import { TypeTag } from '../avm_memory_types.js';
@@ -9,7 +9,7 @@ import { Instruction } from './instruction.js';
9
9
  export class DebugLog extends Instruction {
10
10
  static type: string = 'DEBUGLOG';
11
11
  static readonly opcode: Opcode = Opcode.DEBUGLOG;
12
- static readonly logger = createDebugLogger('aztec:avm_simulator:debug_log');
12
+ static readonly logger = createLogger('simulator:avm:debug_log');
13
13
 
14
14
  // Informs (de)serialization. See Instruction.deserialize.
15
15
  static readonly wireFormat: OperandType[] = [
@@ -28,6 +28,10 @@ export function mockStorageRead(worldStateDB: WorldStateDB, value: Fr) {
28
28
  (worldStateDB as jest.Mocked<WorldStateDB>).storageRead.mockResolvedValue(value);
29
29
  }
30
30
 
31
+ export function mockNoteHashCount(mockedTrace: PublicSideEffectTraceInterface, count: number) {
32
+ (mockedTrace as jest.Mocked<PublicSideEffectTraceInterface>).getNoteHashCount.mockReturnValue(count);
33
+ }
34
+
31
35
  export function mockStorageReadWithMap(worldStateDB: WorldStateDB, mockedStorage: Map<bigint, Fr>) {
32
36
  (worldStateDB as jest.Mocked<WorldStateDB>).storageRead.mockImplementation((_address, slot) =>
33
37
  Promise.resolve(mockedStorage.get(slot.toBigInt()) ?? Fr.ZERO),
@@ -11,9 +11,9 @@ import {
11
11
  type UnencryptedL2Log,
12
12
  } from '@aztec/circuit-types';
13
13
  import {
14
+ type BlockHeader,
14
15
  CallContext,
15
16
  FunctionSelector,
16
- type Header,
17
17
  PRIVATE_CONTEXT_INPUTS_LENGTH,
18
18
  PUBLIC_DISPATCH_SELECTOR,
19
19
  PrivateContextInputs,
@@ -23,7 +23,7 @@ import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash';
23
23
  import { type FunctionAbi, type FunctionArtifact, type NoteSelector, countArgumentsSize } from '@aztec/foundation/abi';
24
24
  import { AztecAddress } from '@aztec/foundation/aztec-address';
25
25
  import { Fr } from '@aztec/foundation/fields';
26
- import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
26
+ import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
27
27
 
28
28
  import { type NoteData, toACVMWitness } from '../acvm/index.js';
29
29
  import { type PackedValuesCache } from '../common/packed_values_cache.js';
@@ -66,7 +66,7 @@ export class ClientExecutionContext extends ViewDataOracle {
66
66
  private readonly txContext: TxContext,
67
67
  private readonly callContext: CallContext,
68
68
  /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
69
- protected readonly historicalHeader: Header,
69
+ protected readonly historicalHeader: BlockHeader,
70
70
  /** List of transient auth witnesses to be used during this simulation */
71
71
  authWitnesses: AuthWitness[],
72
72
  private readonly packedValuesCache: PackedValuesCache,
@@ -74,7 +74,7 @@ export class ClientExecutionContext extends ViewDataOracle {
74
74
  db: DBOracle,
75
75
  private node: AztecNode,
76
76
  protected sideEffectCounter: number = 0,
77
- log = createDebugLogger('aztec:simulator:client_execution_context'),
77
+ log = createLogger('simulator:client_execution_context'),
78
78
  scopes?: AztecAddress[],
79
79
  ) {
80
80
  super(callContext.contractAddress, authWitnesses, db, node, log, scopes);
@@ -247,9 +247,10 @@ export class ClientExecutionContext extends ViewDataOracle {
247
247
 
248
248
  notes.forEach(n => {
249
249
  if (n.index !== undefined) {
250
- const uniqueNoteHash = computeUniqueNoteHash(n.nonce, n.noteHash);
251
- const siloedNoteHash = siloNoteHash(n.contractAddress, uniqueNoteHash);
252
- this.noteHashLeafIndexMap.set(siloedNoteHash.toBigInt(), n.index);
250
+ const siloedNoteHash = siloNoteHash(n.contractAddress, n.noteHash);
251
+ const uniqueNoteHash = computeUniqueNoteHash(n.nonce, siloedNoteHash);
252
+
253
+ this.noteHashLeafIndexMap.set(uniqueNoteHash.toBigInt(), n.index);
253
254
  }
254
255
  });
255
256
 
@@ -419,7 +420,14 @@ export class ClientExecutionContext extends ViewDataOracle {
419
420
  const args = this.packedValuesCache.unpack(argsHash);
420
421
 
421
422
  this.log.verbose(
422
- `Created PublicExecutionRequest to ${targetArtifact.name}@${targetContractAddress}, of type [${callType}], side-effect counter [${sideEffectCounter}]`,
423
+ `Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`,
424
+ {
425
+ sideEffectCounter,
426
+ isStaticCall,
427
+ functionSelector,
428
+ targetContractAddress,
429
+ callType,
430
+ },
423
431
  );
424
432
 
425
433
  const request = PublicExecutionRequest.from({
@@ -537,7 +545,7 @@ export class ClientExecutionContext extends ViewDataOracle {
537
545
  }
538
546
 
539
547
  public override debugLog(message: string, fields: Fr[]) {
540
- this.log.verbose(`debug_log ${applyStringFormatting(message, fields)}`);
548
+ this.log.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` });
541
549
  }
542
550
 
543
551
  public getDebugFunctionName() {
@@ -557,5 +565,7 @@ export class ClientExecutionContext extends ViewDataOracle {
557
565
  for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
558
566
  await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
559
567
  }
568
+
569
+ await this.db.removeNullifiedNotes(this.contractAddress);
560
570
  }
561
571
  }
@@ -8,9 +8,9 @@ import {
8
8
  type TxScopedL2Log,
9
9
  } from '@aztec/circuit-types';
10
10
  import {
11
+ type BlockHeader,
11
12
  type CompleteAddress,
12
13
  type ContractInstance,
13
- type Header,
14
14
  type IndexedTaggingSecret,
15
15
  type KeyValidationRequest,
16
16
  } from '@aztec/circuits.js';
@@ -138,7 +138,7 @@ export interface DBOracle extends CommitmentsDB {
138
138
  *
139
139
  * @returns A Promise that resolves to a Header object.
140
140
  */
141
- getHeader(): Promise<Header>;
141
+ getBlockHeader(): Promise<BlockHeader>;
142
142
 
143
143
  /**
144
144
  * Fetch the index of the leaf in the respective tree
@@ -198,21 +198,21 @@ export interface DBOracle extends CommitmentsDB {
198
198
  getBlockNumber(): Promise<number>;
199
199
 
200
200
  /**
201
- * Returns the tagging secret for a given sender and recipient pair. For this to work, the ivpsk_m of the sender must be known.
201
+ * Returns the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
202
202
  * Includes the next index to be used used for tagging with this secret.
203
203
  * @param contractAddress - The contract address to silo the secret for
204
204
  * @param sender - The address sending the note
205
205
  * @param recipient - The address receiving the note
206
206
  * @returns A tagging secret that can be used to tag notes.
207
207
  */
208
- getAppTaggingSecretAsSender(
208
+ getIndexedTaggingSecretAsSender(
209
209
  contractAddress: AztecAddress,
210
210
  sender: AztecAddress,
211
211
  recipient: AztecAddress,
212
212
  ): Promise<IndexedTaggingSecret>;
213
213
 
214
214
  /**
215
- * Increments the tagging secret for a given sender and recipient pair. For this to work, the ivpsk_m of the sender must be known.
215
+ * Increments the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
216
216
  * @param contractAddress - The contract address to silo the secret for
217
217
  * @param sender - The address sending the note
218
218
  * @param recipient - The address receiving the note
@@ -242,4 +242,9 @@ export interface DBOracle extends CommitmentsDB {
242
242
  * @param recipient - The recipient of the logs.
243
243
  */
244
244
  processTaggedLogs(logs: TxScopedL2Log[], recipient: AztecAddress): Promise<void>;
245
+
246
+ /**
247
+ * Removes all of a contract's notes that have been nullified from the note database.
248
+ */
249
+ removeNullifiedNotes(contractAddress: AztecAddress): Promise<void>;
245
250
  }
@@ -1,6 +1,6 @@
1
1
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/circuits.js/hash';
2
2
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
3
- import { type Fr } from '@aztec/foundation/fields';
3
+ import { Fr } from '@aztec/foundation/fields';
4
4
 
5
5
  import { type NoteData } from '../acvm/index.js';
6
6
 
@@ -51,11 +51,11 @@ export class ExecutionNoteCache {
51
51
  // The nonces will be used to create the "complete" nullifier.
52
52
  const updatedNotes = this.notes.map(({ note, counter }, i) => {
53
53
  const nonce = computeNoteHashNonce(this.txHash, i);
54
- const uniqueNoteHash = computeUniqueNoteHash(nonce, note.noteHash);
54
+ const uniqueNoteHash = computeUniqueNoteHash(nonce, siloNoteHash(note.contractAddress, note.noteHash));
55
55
  return {
56
56
  counter,
57
57
  note: { ...note, nonce },
58
- noteHashForConsumption: siloNoteHash(note.contractAddress, uniqueNoteHash),
58
+ noteHashForConsumption: uniqueNoteHash,
59
59
  };
60
60
  });
61
61
  // Rebuild the data.
@@ -146,4 +146,14 @@ export class ExecutionNoteCache {
146
146
  notes.push(note);
147
147
  this.noteMap.set(note.note.contractAddress.toBigInt(), notes);
148
148
  }
149
+
150
+ getAllNotes(): PendingNote[] {
151
+ return this.notes;
152
+ }
153
+
154
+ getAllNullifiers(): Fr[] {
155
+ return [...this.nullifierMap.values()].flatMap(nullifierArray =>
156
+ [...nullifierArray.values()].map(val => new Fr(val)),
157
+ );
158
+ }
149
159
  }
@@ -3,3 +3,4 @@ export * from './db_oracle.js';
3
3
  export * from './pick_notes.js';
4
4
  export * from './execution_note_cache.js';
5
5
  export { extractPrivateCircuitPublicInputs } from './private_execution.js';
6
+ export { WASMSimulator } from '../providers/acvm_wasm.js';
@@ -8,7 +8,7 @@ import {
8
8
  } from '@aztec/circuits.js';
9
9
  import { type FunctionArtifact, type FunctionSelector, countArgumentsSize } from '@aztec/foundation/abi';
10
10
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
11
- import { createDebugLogger } from '@aztec/foundation/log';
11
+ import { createLogger } from '@aztec/foundation/log';
12
12
  import { Timer } from '@aztec/foundation/timer';
13
13
 
14
14
  import { fromACVMField, witnessMapToFields } from '../acvm/deserialize.js';
@@ -24,10 +24,10 @@ export async function executePrivateFunction(
24
24
  artifact: FunctionArtifact,
25
25
  contractAddress: AztecAddress,
26
26
  functionSelector: FunctionSelector,
27
- log = createDebugLogger('aztec:simulator:private_execution'),
27
+ log = createLogger('simulator:private_execution'),
28
28
  ): Promise<PrivateExecutionResult> {
29
29
  const functionName = await context.getDebugFunctionName();
30
- log.verbose(`Executing external function ${functionName}@${contractAddress}`);
30
+ log.verbose(`Executing private function ${functionName}@${contractAddress}`);
31
31
  const acir = artifact.bytecode;
32
32
  const initialWitness = context.getInitialWitness(artifact);
33
33
  const acvmCallback = new Oracle(context);
@@ -10,7 +10,7 @@ import {
10
10
  } from '@aztec/foundation/abi';
11
11
  import { AztecAddress } from '@aztec/foundation/aztec-address';
12
12
  import { Fr } from '@aztec/foundation/fields';
13
- import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
13
+ import { type Logger, createLogger } from '@aztec/foundation/log';
14
14
 
15
15
  import { createSimulationError } from '../common/errors.js';
16
16
  import { PackedValuesCache } from '../common/packed_values_cache.js';
@@ -25,10 +25,10 @@ import { ViewDataOracle } from './view_data_oracle.js';
25
25
  * The ACIR simulator.
26
26
  */
27
27
  export class AcirSimulator {
28
- private log: DebugLogger;
28
+ private log: Logger;
29
29
 
30
30
  constructor(private db: DBOracle, private node: AztecNode) {
31
- this.log = createDebugLogger('aztec:simulator');
31
+ this.log = createLogger('simulator');
32
32
  }
33
33
 
34
34
  /**
@@ -57,7 +57,7 @@ export class AcirSimulator {
57
57
  );
58
58
  }
59
59
 
60
- const header = await this.db.getHeader();
60
+ const header = await this.db.getBlockHeader();
61
61
 
62
62
  // reserve the first side effect for the tx hash (inserted by the private kernel)
63
63
  const startSideEffectCounter = 1;
@@ -1,7 +1,7 @@
1
1
  import { type AbiDecoded, type FunctionArtifact, type FunctionSelector, decodeFromAbi } from '@aztec/foundation/abi';
2
2
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
3
3
  import { type Fr } from '@aztec/foundation/fields';
4
- import { createDebugLogger } from '@aztec/foundation/log';
4
+ import { createLogger } from '@aztec/foundation/log';
5
5
 
6
6
  import { witnessMapToFields } from '../acvm/deserialize.js';
7
7
  import { Oracle, acvm, extractCallStack, toACVMWitness } from '../acvm/index.js';
@@ -18,7 +18,7 @@ export async function executeUnconstrainedFunction(
18
18
  contractAddress: AztecAddress,
19
19
  functionSelector: FunctionSelector,
20
20
  args: Fr[],
21
- log = createDebugLogger('aztec:simulator:unconstrained_execution'),
21
+ log = createLogger('simulator:unconstrained_execution'),
22
22
  ): Promise<AbiDecoded> {
23
23
  log.verbose(`Executing unconstrained function ${contractAddress}:${functionSelector}(${artifact.name})`);
24
24
 
@@ -8,15 +8,15 @@ import {
8
8
  type PublicDataWitness,
9
9
  } from '@aztec/circuit-types';
10
10
  import {
11
+ type BlockHeader,
11
12
  type ContractInstance,
12
- type Header,
13
13
  type IndexedTaggingSecret,
14
14
  type KeyValidationRequest,
15
15
  } from '@aztec/circuits.js';
16
16
  import { siloNullifier } from '@aztec/circuits.js/hash';
17
17
  import { AztecAddress } from '@aztec/foundation/aztec-address';
18
18
  import { Fr } from '@aztec/foundation/fields';
19
- import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
19
+ import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
20
20
 
21
21
  import { type NoteData, TypedOracle } from '../acvm/index.js';
22
22
  import { type DBOracle } from './db_oracle.js';
@@ -33,7 +33,7 @@ export class ViewDataOracle extends TypedOracle {
33
33
  protected readonly authWitnesses: AuthWitness[],
34
34
  protected readonly db: DBOracle,
35
35
  protected readonly aztecNode: AztecNode,
36
- protected log = createDebugLogger('aztec:simulator:client_view_context'),
36
+ protected log = createLogger('simulator:client_view_context'),
37
37
  protected readonly scopes?: AztecAddress[],
38
38
  ) {
39
39
  super();
@@ -139,7 +139,7 @@ export class ViewDataOracle extends TypedOracle {
139
139
  * @param blockNumber - The number of a block of which to get the block header.
140
140
  * @returns Block extracted from a block with block number `blockNumber`.
141
141
  */
142
- public override async getHeader(blockNumber: number): Promise<Header | undefined> {
142
+ public override async getBlockHeader(blockNumber: number): Promise<BlockHeader | undefined> {
143
143
  const block = await this.db.getBlock(blockNumber);
144
144
  if (!block) {
145
145
  return undefined;
@@ -290,23 +290,22 @@ export class ViewDataOracle extends TypedOracle {
290
290
  }
291
291
 
292
292
  public override debugLog(message: string, fields: Fr[]): void {
293
- const formattedStr = applyStringFormatting(message, fields);
294
- this.log.verbose(`debug_log ${formattedStr}`);
293
+ this.log.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` });
295
294
  }
296
295
 
297
296
  /**
298
297
  * Returns the tagging secret for a given sender and recipient pair, siloed to the current contract address.
299
298
  * Includes the next index to be used used for tagging with this secret.
300
- * For this to work, the ivpsk_m of the sender must be known.
299
+ * For this to work, the ivsk_m of the sender must be known.
301
300
  * @param sender - The address sending the note
302
301
  * @param recipient - The address receiving the note
303
302
  * @returns A tagging secret that can be used to tag notes.
304
303
  */
305
- public override async getAppTaggingSecretAsSender(
304
+ public override async getIndexedTaggingSecretAsSender(
306
305
  sender: AztecAddress,
307
306
  recipient: AztecAddress,
308
307
  ): Promise<IndexedTaggingSecret> {
309
- return await this.db.getAppTaggingSecretAsSender(this.contractAddress, sender, recipient);
308
+ return await this.db.getIndexedTaggingSecretAsSender(this.contractAddress, sender, recipient);
310
309
  }
311
310
 
312
311
  public override async syncNotes() {
@@ -315,8 +314,11 @@ export class ViewDataOracle extends TypedOracle {
315
314
  await this.aztecNode.getBlockNumber(),
316
315
  this.scopes,
317
316
  );
317
+
318
318
  for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
319
319
  await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
320
320
  }
321
+
322
+ await this.db.removeNullifiedNotes(this.contractAddress);
321
323
  }
322
324
  }
@@ -1,22 +1,16 @@
1
- import { type AztecAddress, Fr, FunctionSelector, PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js';
1
+ import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js';
2
2
 
3
3
  import { type WorldStateDB } from '../public/public_db_sources.js';
4
4
 
5
5
  export async function getPublicFunctionDebugName(
6
6
  db: WorldStateDB,
7
7
  contractAddress: AztecAddress,
8
- fn: FunctionSelector,
9
8
  calldata: Fr[],
10
9
  ): Promise<string> {
11
- if (fn.equals(FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)))) {
12
- // If the function is a dispatch, we need to look up the target function which
13
- // is expected to be the first argument.
14
- const targetFunction =
15
- calldata[0] !== undefined
16
- ? await db.getDebugFunctionName(contractAddress, FunctionSelector.fromField(calldata[0]))
17
- : `<calldata[0] undefined>`;
18
- return `${targetFunction} (via dispatch)`;
19
- } else {
20
- return (await db.getDebugFunctionName(contractAddress, fn)) ?? `${contractAddress}:${fn}`;
21
- }
10
+ // Public function is dispatched and therefore the target function is passed in the first argument.
11
+ const targetFunction =
12
+ calldata[0] !== undefined
13
+ ? await db.getDebugFunctionName(contractAddress, FunctionSelector.fromField(calldata[0]))
14
+ : `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
15
+ return `${targetFunction}`;
22
16
  }
@@ -1,15 +1,15 @@
1
1
  import { runInDirectory } from '@aztec/foundation/fs';
2
- import { createDebugLogger } from '@aztec/foundation/log';
2
+ import { createLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import { type NoirCompiledCircuit } from '@aztec/types/noir';
5
5
 
6
6
  import { type WitnessMap } from '@noir-lang/types';
7
7
  import * as proc from 'child_process';
8
- import fs from 'fs/promises';
8
+ import { promises as fs } from 'fs';
9
9
 
10
10
  import { type SimulationProvider } from './simulation_provider.js';
11
11
 
12
- const logger = createDebugLogger('aztec:acvm-native');
12
+ const logger = createLogger('simulator:acvm-native');
13
13
 
14
14
  export enum ACVM_RESULT {
15
15
  SUCCESS,
@@ -1,4 +1,4 @@
1
- import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types';
1
+ import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
2
2
  import { type NoirCompiledCircuit } from '@aztec/types/noir';
3
3
 
4
4
  import { executeCircuit } from '@noir-lang/acvm_js';
@@ -17,7 +17,7 @@ export class WASMSimulator implements SimulationProvider {
17
17
  const _witnessMap = await executeCircuit(
18
18
  decodedBytecode,
19
19
  input,
20
- foreignCallHandler, // handle calls to debug_log
20
+ foreignCallHandler, // handle calls to debug_log and evaluate_blobs mock
21
21
  );
22
22
 
23
23
  return _witnessMap;
@@ -1,6 +1,6 @@
1
- import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
2
 
3
- import * as fs from 'fs/promises';
3
+ import { promises as fs } from 'fs';
4
4
 
5
5
  import { NativeACVMSimulator } from './acvm_native.js';
6
6
  import { WASMSimulator } from './acvm_wasm.js';
@@ -21,7 +21,7 @@ export function getSimulationProviderConfigFromEnv() {
21
21
 
22
22
  export async function createSimulationProvider(
23
23
  config: SimulationProviderConfig,
24
- logger: DebugLogger = createDebugLogger('aztec:simulator'),
24
+ logger: Logger = createLogger('simulator'),
25
25
  ): Promise<SimulationProvider> {
26
26
  if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
27
27
  try {
@@ -1,4 +1,3 @@
1
1
  export * from './acvm_native.js';
2
- export * from './acvm_wasm.js';
3
2
  export * from './simulation_provider.js';
4
3
  export * from './factory.js';