@aztec/simulator 0.76.2 → 0.76.3

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.
@@ -319,35 +319,40 @@ export class ViewDataOracle extends TypedOracle {
319
319
  await this.db.deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient);
320
320
  }
321
321
 
322
- public override dbStore(contractAddress: AztecAddress, slot: Fr, values: Fr[]): Promise<void> {
322
+ public override storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
323
323
  if (!contractAddress.equals(this.contractAddress)) {
324
324
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
325
325
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
326
326
  }
327
- return this.db.dbStore(this.contractAddress, slot, values);
327
+ return this.db.storeCapsule(this.contractAddress, slot, capsule);
328
328
  }
329
329
 
330
- public override dbLoad(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
330
+ public override loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
331
331
  if (!contractAddress.equals(this.contractAddress)) {
332
332
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
333
333
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
334
334
  }
335
- return this.db.dbLoad(this.contractAddress, slot);
335
+ return this.db.loadCapsule(this.contractAddress, slot);
336
336
  }
337
337
 
338
- public override dbDelete(contractAddress: AztecAddress, slot: Fr): Promise<void> {
338
+ public override deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
339
339
  if (!contractAddress.equals(this.contractAddress)) {
340
340
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
341
341
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
342
342
  }
343
- return this.db.dbDelete(this.contractAddress, slot);
343
+ return this.db.deleteCapsule(this.contractAddress, slot);
344
344
  }
345
345
 
346
- public override dbCopy(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
346
+ public override copyCapsule(
347
+ contractAddress: AztecAddress,
348
+ srcSlot: Fr,
349
+ dstSlot: Fr,
350
+ numEntries: number,
351
+ ): Promise<void> {
347
352
  if (!contractAddress.equals(this.contractAddress)) {
348
353
  // TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
349
354
  throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
350
355
  }
351
- return this.db.dbCopy(this.contractAddress, srcSlot, dstSlot, numEntries);
356
+ return this.db.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries);
352
357
  }
353
358
  }
@@ -162,7 +162,7 @@ export class PublicTxContext {
162
162
  * NOTE: this does not "halt" the entire transaction execution.
163
163
  */
164
164
  revert(phase: TxExecutionPhase, revertReason: SimulationError | undefined = undefined, culprit = '') {
165
- this.log.debug(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason}`);
165
+ this.log.warn(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason}`);
166
166
 
167
167
  if (revertReason && !this.revertReason) {
168
168
  // don't override revertReason
@@ -170,7 +170,7 @@ export class PublicTxContext {
170
170
  this.revertReason = revertReason;
171
171
  }
172
172
  if (phase === TxExecutionPhase.SETUP) {
173
- this.log.debug(`Setup phase reverted! The transaction will be thrown out.`);
173
+ this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
174
174
  if (revertReason) {
175
175
  throw revertReason;
176
176
  } else {
@@ -127,7 +127,6 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
127
127
  /** We need to track the set of class IDs used for bytecode retrieval to deduplicate and enforce limits. */
128
128
  private gotBytecodeFromClassIds: UniqueClassIds = new UniqueClassIds(),
129
129
  ) {
130
- this.log.debug(`Creating trace instance with startSideEffectCounter: ${startSideEffectCounter}`);
131
130
  this.sideEffectCounter = startSideEffectCounter;
132
131
  this.avmCircuitHints = AvmExecutionHints.empty();
133
132
  }
@@ -215,7 +214,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
215
214
  path: Fr[] = emptyPublicDataPath(),
216
215
  ) {
217
216
  this.avmCircuitHints.publicDataReads.items.push(new AvmPublicDataReadTreeHint(leafPreimage, leafIndex, path));
218
- this.log.debug(
217
+ this.log.trace(
219
218
  `Tracing storage read (address=${contractAddress}, slot=${slot}): value=${value} (counter=${this.sideEffectCounter})`,
220
219
  );
221
220
  this.incrementSideEffectCounter();
@@ -265,7 +264,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
265
264
  new AvmPublicDataWriteTreeHint(readHint, newLeafPreimage, insertionPath),
266
265
  );
267
266
 
268
- this.log.debug(
267
+ this.log.trace(
269
268
  `Traced public data write (address=${contractAddress}, slot=${slot}): value=${value} (counter=${this.sideEffectCounter}, isProtocol:${protocolWrite})`,
270
269
  );
271
270
  this.incrementSideEffectCounter();
@@ -282,6 +281,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
282
281
  // New Hinting
283
282
  this.avmCircuitHints.noteHashReads.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path));
284
283
  // NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes)
284
+ this.log.trace(`Tracing note hash check (counter=${this.sideEffectCounter})`);
285
285
  }
286
286
 
287
287
  public traceNewNoteHash(noteHash: Fr, leafIndex: Fr = Fr.zero(), path: Fr[] = emptyNoteHashPath()) {
@@ -290,8 +290,8 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
290
290
  }
291
291
 
292
292
  this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
293
- this.log.debug(`NEW_NOTE_HASH cnt: ${this.sideEffectCounter}`);
294
293
  this.avmCircuitHints.noteHashWrites.items.push(new AvmAppendTreeHint(leafIndex, noteHash, path));
294
+ this.log.trace(`Tracing new note hash (counter=${this.sideEffectCounter})`);
295
295
  this.incrementSideEffectCounter();
296
296
  }
297
297
 
@@ -305,7 +305,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
305
305
  this.avmCircuitHints.nullifierReads.items.push(
306
306
  new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath),
307
307
  );
308
- this.log.debug(`NULLIFIER_EXISTS cnt: ${this.sideEffectCounter}`);
308
+ this.log.trace(`Tracing nullifier check (counter=${this.sideEffectCounter})`);
309
309
  this.incrementSideEffectCounter();
310
310
  }
311
311
 
@@ -324,7 +324,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
324
324
 
325
325
  const lowLeafReadHint = new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath);
326
326
  this.avmCircuitHints.nullifierWrites.items.push(new AvmNullifierWriteTreeHint(lowLeafReadHint, insertionPath));
327
- this.log.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`);
327
+ this.log.trace(`Tracing new nullifier (counter=${this.sideEffectCounter})`);
328
328
  this.incrementSideEffectCounter();
329
329
  }
330
330
 
@@ -337,6 +337,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
337
337
  path: Fr[] = emptyL1ToL2MessagePath(),
338
338
  ) {
339
339
  this.avmCircuitHints.l1ToL2MessageReads.items.push(new AvmAppendTreeHint(msgLeafIndex, msgHash, path));
340
+ this.log.trace(`Tracing l1 to l2 message check (counter=${this.sideEffectCounter})`);
340
341
  }
341
342
 
342
343
  public traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) {
@@ -348,7 +349,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
348
349
  this.l2ToL1Messages.push(
349
350
  new L2ToL1Message(recipientAddress, content, this.sideEffectCounter).scope(contractAddress),
350
351
  );
351
- this.log.debug(`NEW_L2_TO_L1_MSG cnt: ${this.sideEffectCounter}`);
352
+ this.log.trace(`Tracing new l2 to l1 message (counter=${this.sideEffectCounter})`);
352
353
  this.incrementSideEffectCounter();
353
354
  }
354
355
 
@@ -362,7 +363,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
362
363
  }
363
364
  const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO, PUBLIC_LOG_DATA_SIZE_IN_FIELDS));
364
365
  this.publicLogs.push(publicLog);
365
- this.log.debug(`NEW_PUBLIC_LOG cnt: ${this.sideEffectCounter}`);
366
+ this.log.trace(`Tracing new public log (counter=${this.sideEffectCounter})`);
366
367
  this.incrementSideEffectCounter();
367
368
  }
368
369
 
@@ -387,7 +388,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
387
388
  membershipHint,
388
389
  ),
389
390
  );
390
- this.log.debug(`CONTRACT_INSTANCE cnt: ${this.sideEffectCounter}`);
391
+ this.log.trace(`Tracing contract instance retrieval (counter=${this.sideEffectCounter})`);
391
392
  this.incrementSideEffectCounter();
392
393
  }
393
394
 
@@ -432,7 +433,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
432
433
  // Since the bytecode hints are keyed by class ID, we need to hint the instance separately
433
434
  // since there might be multiple instances hinted for the same class ID.
434
435
  this.avmCircuitHints.contractInstances.items.push(instance);
435
- this.log.debug(
436
+ this.log.trace(
436
437
  `Tracing contract instance for bytecode retrieval: exists=${exists}, instance=${jsonStringify(contractInstance)}`,
437
438
  );
438
439
 
@@ -447,7 +448,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
447
448
  // To do so, the circuit needs to know the class ID in the
448
449
  if (this.gotBytecodeFromClassIds.has(contractInstance.contractClassId.toString())) {
449
450
  // this ensures there are no duplicates
450
- this.log.debug(
451
+ this.log.trace(
451
452
  `Contract class id ${contractInstance.contractClassId.toString()} already exists in previous hints`,
452
453
  );
453
454
  return;
@@ -470,7 +471,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
470
471
  );
471
472
  }
472
473
 
473
- this.log.debug(`Tracing bytecode & contract class for bytecode retrieval: class=${jsonStringify(contractClass)}`);
474
+ this.log.trace(`Tracing bytecode & contract class for bytecode retrieval: class=${jsonStringify(contractClass)}`);
474
475
  this.avmCircuitHints.contractBytecodeHints.set(
475
476
  contractInstance.contractClassId.toString(),
476
477
  new AvmContractBytecodeHints(bytecode, instance, contractClass),
@@ -492,7 +493,6 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
492
493
  /** Did the call revert? */
493
494
  _reverted: boolean,
494
495
  ) {
495
- this.log.debug(`Tracing enqueued call`);
496
496
  // TODO(4805): check if some threshold is reached for max enqueued or nested calls (to unique contracts?)
497
497
  this.enqueuedCalls.push(publicCallRequest);
498
498
  this.avmCircuitHints.enqueuedCalls.items.push(new AvmEnqueuedCallHint(publicCallRequest.contractAddress, calldata));