@aztec/simulator 0.71.0 → 0.72.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 (56) hide show
  1. package/dest/acvm/oracle/oracle.d.ts +0 -1
  2. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  3. package/dest/acvm/oracle/oracle.js +1 -5
  4. package/dest/acvm/oracle/typed_oracle.d.ts +0 -1
  5. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/typed_oracle.js +1 -4
  7. package/dest/avm/errors.d.ts +6 -0
  8. package/dest/avm/errors.d.ts.map +1 -1
  9. package/dest/avm/errors.js +10 -1
  10. package/dest/avm/journal/journal.d.ts +2 -3
  11. package/dest/avm/journal/journal.d.ts.map +1 -1
  12. package/dest/avm/journal/journal.js +5 -6
  13. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  14. package/dest/avm/opcodes/accrued_substate.js +3 -2
  15. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  16. package/dest/avm/opcodes/conversion.js +10 -7
  17. package/dest/avm/opcodes/ec_add.js +2 -2
  18. package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +1 -1
  19. package/dest/avm/opcodes/multi_scalar_mul.js +9 -7
  20. package/dest/client/client_execution_context.d.ts +1 -5
  21. package/dest/client/client_execution_context.d.ts.map +1 -1
  22. package/dest/client/client_execution_context.js +3 -9
  23. package/dest/public/enqueued_call_side_effect_trace.d.ts +7 -10
  24. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  25. package/dest/public/enqueued_call_side_effect_trace.js +21 -28
  26. package/dest/public/execution.d.ts +7 -25
  27. package/dest/public/execution.d.ts.map +1 -1
  28. package/dest/public/execution.js +1 -1
  29. package/dest/public/fixtures/index.d.ts +3 -3
  30. package/dest/public/fixtures/index.d.ts.map +1 -1
  31. package/dest/public/fixtures/index.js +38 -35
  32. package/dest/public/public_processor.d.ts +3 -4
  33. package/dest/public/public_processor.d.ts.map +1 -1
  34. package/dest/public/public_processor.js +11 -12
  35. package/dest/public/public_tx_context.js +2 -2
  36. package/dest/public/public_tx_simulator.d.ts.map +1 -1
  37. package/dest/public/public_tx_simulator.js +3 -6
  38. package/dest/public/side_effect_trace_interface.d.ts +3 -4
  39. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  40. package/package.json +10 -10
  41. package/src/acvm/oracle/oracle.ts +0 -5
  42. package/src/acvm/oracle/typed_oracle.ts +0 -4
  43. package/src/avm/errors.ts +10 -0
  44. package/src/avm/journal/journal.ts +4 -5
  45. package/src/avm/opcodes/accrued_substate.ts +2 -1
  46. package/src/avm/opcodes/conversion.ts +15 -6
  47. package/src/avm/opcodes/ec_add.ts +1 -1
  48. package/src/avm/opcodes/multi_scalar_mul.ts +8 -6
  49. package/src/client/client_execution_context.ts +2 -9
  50. package/src/public/enqueued_call_side_effect_trace.ts +22 -34
  51. package/src/public/execution.ts +7 -31
  52. package/src/public/fixtures/index.ts +52 -46
  53. package/src/public/public_processor.ts +8 -13
  54. package/src/public/public_tx_context.ts +1 -1
  55. package/src/public/public_tx_simulator.ts +1 -8
  56. package/src/public/side_effect_trace_interface.ts +3 -3
@@ -95,7 +95,7 @@ export class ClientExecutionContext extends ViewDataOracle {
95
95
  const args = this.executionCache.getPreimage(this.argsHash);
96
96
 
97
97
  if (args.length !== argumentsSize) {
98
- throw new Error('Invalid arguments size');
98
+ throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args.length}`);
99
99
  }
100
100
 
101
101
  const privateContextInputs = new PrivateContextInputs(
@@ -160,14 +160,6 @@ export class ClientExecutionContext extends ViewDataOracle {
160
160
  return this.publicTeardownFunctionCall;
161
161
  }
162
162
 
163
- /**
164
- * Store values in the execution cache.
165
- * @param values - Values to store.
166
- */
167
- public override storeArrayInExecutionCache(args: Fr[]): Promise<Fr> {
168
- return Promise.resolve(this.executionCache.store(args));
169
- }
170
-
171
163
  /**
172
164
  * Store values in the execution cache.
173
165
  * @param values - Values to store.
@@ -327,6 +319,7 @@ export class ClientExecutionContext extends ViewDataOracle {
327
319
  * This fn exists because sha hashing the preimage
328
320
  * is too large to compile (16,200 fields, 518,400 bytes) => the oracle hashes it.
329
321
  * See private_context.nr
322
+ * TODO(#8945): Contract class logs are currently sha hashes. When these are fields, delete this.
330
323
  * @param log - The unencrypted log to be emitted.
331
324
  */
332
325
  public override emitContractClassLog(log: UnencryptedL2Log, counter: number) {
@@ -1,4 +1,3 @@
1
- import { UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types';
2
1
  import {
3
2
  AvmAccumulatedData,
4
3
  AvmAppendTreeHint,
@@ -19,15 +18,14 @@ import {
19
18
  type GlobalVariables,
20
19
  L1_TO_L2_MSG_TREE_HEIGHT,
21
20
  L2ToL1Message,
22
- LogHash,
23
21
  MAX_ENQUEUED_CALLS_PER_TX,
24
22
  MAX_L2_TO_L1_MSGS_PER_TX,
25
23
  MAX_NOTE_HASHES_PER_TX,
26
24
  MAX_NULLIFIERS_PER_TX,
27
25
  MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS,
28
26
  MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
27
+ MAX_PUBLIC_LOGS_PER_TX,
29
28
  MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
30
- MAX_UNENCRYPTED_LOGS_PER_TX,
31
29
  NOTE_HASH_TREE_HEIGHT,
32
30
  NULLIFIER_TREE_HEIGHT,
33
31
  NoteHash,
@@ -35,14 +33,15 @@ import {
35
33
  NullifierLeafPreimage,
36
34
  PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
37
35
  PUBLIC_DATA_TREE_HEIGHT,
36
+ PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
38
37
  PrivateToAvmAccumulatedData,
39
38
  PrivateToAvmAccumulatedDataArrayLengths,
40
39
  PublicCallRequest,
41
40
  PublicDataTreeLeafPreimage,
42
41
  PublicDataUpdateRequest,
43
42
  PublicDataWrite,
43
+ PublicLog,
44
44
  ScopedL2ToL1Message,
45
- ScopedLogHash,
46
45
  SerializableContractInstance,
47
46
  type TreeSnapshots,
48
47
  } from '@aztec/circuits.js';
@@ -79,8 +78,7 @@ export type SideEffects = {
79
78
  nullifiers: Nullifier[];
80
79
  l2ToL1Msgs: ScopedL2ToL1Message[];
81
80
 
82
- unencryptedLogs: UnencryptedL2Log[];
83
- unencryptedLogsHashes: ScopedLogHash[];
81
+ publicLogs: PublicLog[];
84
82
  };
85
83
 
86
84
  export class SideEffectArrayLengths {
@@ -90,7 +88,7 @@ export class SideEffectArrayLengths {
90
88
  public readonly noteHashes: number,
91
89
  public readonly nullifiers: number,
92
90
  public readonly l2ToL1Msgs: number,
93
- public readonly unencryptedLogs: number,
91
+ public readonly publicLogs: number,
94
92
  ) {}
95
93
 
96
94
  static empty() {
@@ -115,8 +113,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
115
113
  private noteHashes: NoteHash[] = [];
116
114
  private nullifiers: Nullifier[] = [];
117
115
  private l2ToL1Messages: ScopedL2ToL1Message[] = [];
118
- private unencryptedLogs: UnencryptedL2Log[] = [];
119
- private unencryptedLogsHashes: ScopedLogHash[] = [];
116
+ private publicLogs: PublicLog[] = [];
120
117
 
121
118
  private avmCircuitHints: AvmExecutionHints;
122
119
 
@@ -147,7 +144,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
147
144
  this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length,
148
145
  this.previousSideEffectArrayLengths.nullifiers + this.nullifiers.length,
149
146
  this.previousSideEffectArrayLengths.l2ToL1Msgs + this.l2ToL1Messages.length,
150
- this.previousSideEffectArrayLengths.unencryptedLogs + this.unencryptedLogs.length,
147
+ this.previousSideEffectArrayLengths.publicLogs + this.publicLogs.length,
151
148
  ),
152
149
  this.gotBytecodeFromClassIds.fork(),
153
150
  );
@@ -169,8 +166,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
169
166
  this.noteHashes.push(...forkedTrace.noteHashes);
170
167
  this.nullifiers.push(...forkedTrace.nullifiers);
171
168
  this.l2ToL1Messages.push(...forkedTrace.l2ToL1Messages);
172
- this.unencryptedLogs.push(...forkedTrace.unencryptedLogs);
173
- this.unencryptedLogsHashes.push(...forkedTrace.unencryptedLogsHashes);
169
+ this.publicLogs.push(...forkedTrace.publicLogs);
174
170
  }
175
171
  this.mergeHints(forkedTrace);
176
172
  }
@@ -359,23 +355,17 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
359
355
  this.incrementSideEffectCounter();
360
356
  }
361
357
 
362
- public traceUnencryptedLog(contractAddress: AztecAddress, log: Fr[]) {
363
- if (
364
- this.unencryptedLogs.length + this.previousSideEffectArrayLengths.unencryptedLogs >=
365
- MAX_UNENCRYPTED_LOGS_PER_TX
366
- ) {
367
- throw new SideEffectLimitReachedError('unencrypted log', MAX_UNENCRYPTED_LOGS_PER_TX);
358
+ public tracePublicLog(contractAddress: AztecAddress, log: Fr[]) {
359
+ if (this.publicLogs.length + this.previousSideEffectArrayLengths.publicLogs >= MAX_PUBLIC_LOGS_PER_TX) {
360
+ throw new SideEffectLimitReachedError('public log', MAX_PUBLIC_LOGS_PER_TX);
368
361
  }
369
362
 
370
- const ulog = new UnencryptedL2Log(contractAddress, Buffer.concat(log.map(f => f.toBuffer())));
371
- const basicLogHash = Fr.fromBuffer(ulog.hash());
372
- this.unencryptedLogs.push(ulog);
373
- // This length is for charging DA and is checked on-chain - has to be length of log preimage + 4 bytes.
374
- // The .length call also has a +4 but that is unrelated
375
- this.unencryptedLogsHashes.push(
376
- new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length + 4)).scope(contractAddress),
377
- );
378
- this.log.debug(`NEW_UNENCRYPTED_LOG cnt: ${this.sideEffectCounter}`);
363
+ if (log.length > PUBLIC_LOG_DATA_SIZE_IN_FIELDS) {
364
+ throw new Error(`Emitted public log is too large, max: ${PUBLIC_LOG_DATA_SIZE_IN_FIELDS}, passed: ${log.length}`);
365
+ }
366
+ const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO, PUBLIC_LOG_DATA_SIZE_IN_FIELDS));
367
+ this.publicLogs.push(publicLog);
368
+ this.log.debug(`NEW_PUBLIC_LOG cnt: ${this.sideEffectCounter}`);
379
369
  this.incrementSideEffectCounter();
380
370
  }
381
371
 
@@ -518,8 +508,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
518
508
  noteHashes: this.noteHashes,
519
509
  nullifiers: this.nullifiers,
520
510
  l2ToL1Msgs: this.l2ToL1Messages,
521
- unencryptedLogs: this.unencryptedLogs,
522
- unencryptedLogsHashes: this.unencryptedLogsHashes,
511
+ publicLogs: this.publicLogs,
523
512
  };
524
513
  }
525
514
 
@@ -541,8 +530,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
541
530
  noteHashes: this.noteHashes,
542
531
  nullifiers: this.nullifiers,
543
532
  l2ToL1Messages: this.l2ToL1Messages,
544
- unencryptedLogsHashes: this.unencryptedLogsHashes, // Scoped?
545
- unencryptedLogs: new UnencryptedFunctionL2Logs(this.unencryptedLogs),
533
+ publicLogs: this.publicLogs,
546
534
  },
547
535
  };
548
536
  }
@@ -612,8 +600,8 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
612
600
  throw new Error('Not implemented');
613
601
  }
614
602
 
615
- public getUnencryptedLogs() {
616
- return this.unencryptedLogs;
603
+ public getPublicLogs() {
604
+ return this.publicLogs;
617
605
  }
618
606
 
619
607
  public getAvmCircuitHints() {
@@ -633,7 +621,7 @@ export class PublicEnqueuedCallSideEffectTrace implements PublicSideEffectTraceI
633
621
  MAX_NULLIFIERS_PER_TX,
634
622
  ),
635
623
  padArrayEnd(this.l2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
636
- padArrayEnd(this.unencryptedLogsHashes, ScopedLogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_TX),
624
+ padArrayEnd(this.publicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_TX),
637
625
  padArrayEnd(
638
626
  this.publicDataWrites.map(w => new PublicDataWrite(w.leafSlot, w.newValue)),
639
627
  PublicDataWrite.empty(),
@@ -1,8 +1,4 @@
1
- import {
2
- type PublicExecutionRequest,
3
- type SimulationError,
4
- type UnencryptedFunctionL2Logs,
5
- } from '@aztec/circuit-types';
1
+ import { type PublicExecutionRequest, type SimulationError } from '@aztec/circuit-types';
6
2
  import {
7
3
  type AvmExecutionHints,
8
4
  type ContractStorageRead,
@@ -10,16 +6,15 @@ import {
10
6
  type Fr,
11
7
  Gas,
12
8
  type L2ToL1Message,
13
- type LogHash,
14
9
  type NoteHash,
15
10
  type Nullifier,
16
11
  PublicCallStackItemCompressed,
17
12
  type PublicDataUpdateRequest,
18
13
  PublicInnerCallRequest,
14
+ type PublicLog,
19
15
  type ReadRequest,
20
16
  RevertCode,
21
17
  type ScopedL2ToL1Message,
22
- type ScopedLogHash,
23
18
  type TreeLeafReadRequest,
24
19
  } from '@aztec/circuits.js';
25
20
  import { computeVarArgsHash } from '@aztec/circuits.js/hash';
@@ -33,16 +28,8 @@ export interface PublicSideEffects {
33
28
  nullifiers: Nullifier[];
34
29
  /** The new l2 to l1 messages generated to be inserted into the messages tree. */
35
30
  l2ToL1Messages: ScopedL2ToL1Message[];
36
- /**
37
- * The hashed logs with side effect counter.
38
- * Note: required as we don't track the counter anywhere else.
39
- */
40
- unencryptedLogsHashes: ScopedLogHash[];
41
- /**
42
- * Unencrypted logs emitted during execution.
43
- * Note: These are preimages to `unencryptedLogsHashes`.
44
- */
45
- unencryptedLogs: UnencryptedFunctionL2Logs;
31
+ /** Public logs emitted during execution. */
32
+ publicLogs: PublicLog[];
46
33
  }
47
34
 
48
35
  export interface EnqueuedPublicCallExecutionResult {
@@ -124,21 +111,10 @@ export interface PublicFunctionCallResult {
124
111
  /** L1 to L2 message read requests emitted in this call. */
125
112
  l1ToL2MsgReadRequests: TreeLeafReadRequest[];
126
113
  /**
127
- * The hashed logs with side effect counter.
128
- * Note: required as we don't track the counter anywhere else.
114
+ * The public logs emitted in this call.
115
+ * Note: PublicLog has no counter - unsure if this is needed bc this struct is unused
129
116
  */
130
- unencryptedLogsHashes: LogHash[];
131
- /**
132
- * Unencrypted logs emitted during execution of this function call.
133
- * Note: These are preimages to `unencryptedLogsHashes`.
134
- */
135
- unencryptedLogs: UnencryptedFunctionL2Logs;
136
- /**
137
- * Unencrypted logs emitted during this call AND any nested calls.
138
- * Useful for maintaining correct ordering in ts.
139
- */
140
- allUnencryptedLogs: UnencryptedFunctionL2Logs;
141
-
117
+ publicLogs: PublicLog[];
142
118
  /** The requests to call public functions made by this call. */
143
119
  publicCallRequests: PublicInnerCallRequest[];
144
120
  /** The results of nested calls. */
@@ -52,19 +52,22 @@ export async function simulateAvmTestContractGenerateCircuitInputs(
52
52
  teardownFunctionName?: string,
53
53
  teardownArgs: Fr[] = [],
54
54
  expectRevert: boolean = false,
55
- contractDataSource = new MockedAvmTestContractDataSource(),
55
+ contractDataSource?: MockedAvmTestContractDataSource,
56
56
  assertionErrString?: string,
57
57
  ): Promise<AvmCircuitInputs> {
58
58
  const globals = GlobalVariables.empty();
59
59
  globals.timestamp = TIMESTAMP;
60
60
 
61
61
  const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
62
+ if (!contractDataSource) {
63
+ contractDataSource = await MockedAvmTestContractDataSource.create();
64
+ }
62
65
  await contractDataSource.deployContracts(merkleTrees);
63
66
  const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
64
67
 
65
68
  const simulator = new PublicTxSimulator(merkleTrees, worldStateDB, globals, /*doMerkleOperations=*/ true);
66
69
 
67
- const sender = AztecAddress.random();
70
+ const sender = await AztecAddress.random();
68
71
  const callContext = new CallContext(
69
72
  sender,
70
73
  contractDataSource.firstContractInstance.address,
@@ -93,7 +96,12 @@ export async function simulateAvmTestContractGenerateCircuitInputs(
93
96
  teardownExecutionRequest = new PublicExecutionRequest(callContext, fnArgs);
94
97
  }
95
98
 
96
- const tx: Tx = createTxForPublicCalls(setupExecutionRequests, appExecutionRequests, teardownExecutionRequest);
99
+ const tx: Tx = createTxForPublicCalls(
100
+ setupExecutionRequests,
101
+ appExecutionRequests,
102
+ Fr.random(),
103
+ teardownExecutionRequest,
104
+ );
97
105
 
98
106
  const avmResult = await simulator.simulate(tx);
99
107
 
@@ -116,11 +124,15 @@ export async function simulateAvmTestContractCall(
116
124
  functionName: string,
117
125
  args: Fr[] = [],
118
126
  expectRevert: boolean = false,
119
- contractDataSource = new MockedAvmTestContractDataSource(),
127
+ contractDataSource?: MockedAvmTestContractDataSource,
120
128
  ) {
121
129
  const globals = GlobalVariables.empty();
122
130
  globals.timestamp = TIMESTAMP;
123
131
 
132
+ if (!contractDataSource) {
133
+ contractDataSource = await MockedAvmTestContractDataSource.create();
134
+ }
135
+
124
136
  const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
125
137
  await contractDataSource.deployContracts(merkleTrees);
126
138
  const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
@@ -134,7 +146,7 @@ export async function simulateAvmTestContractCall(
134
146
  doMerkleOperations: true,
135
147
  });
136
148
 
137
- const sender = AztecAddress.random();
149
+ const sender = await AztecAddress.random();
138
150
  const functionSelector = getAvmTestContractFunctionSelector(functionName);
139
151
  args = [functionSelector.toField(), ...args];
140
152
  const environment = initExecutionEnvironment({
@@ -158,6 +170,7 @@ export async function simulateAvmTestContractCall(
158
170
  export function createTxForPublicCalls(
159
171
  setupExecutionRequests: PublicExecutionRequest[],
160
172
  appExecutionRequests: PublicExecutionRequest[],
173
+ firstNullifier: Fr,
161
174
  teardownExecutionRequest?: PublicExecutionRequest,
162
175
  gasUsedByPrivate: Gas = Gas.empty(),
163
176
  ): Tx {
@@ -172,7 +185,7 @@ export function createTxForPublicCalls(
172
185
 
173
186
  const forPublic = PartialPrivateTailPublicInputsForPublic.empty();
174
187
  // TODO(#9269): Remove this fake nullifier method as we move away from 1st nullifier as hash.
175
- forPublic.nonRevertibleAccumulatedData.nullifiers[0] = Fr.random(); // fake tx nullifier
188
+ forPublic.nonRevertibleAccumulatedData.nullifiers[0] = firstNullifier; // fake tx nullifier
176
189
 
177
190
  // We reverse order because the simulator expects it to be like a "stack" of calls to pop from
178
191
  for (let i = setupCallRequests.length - 1; i >= 0; i--) {
@@ -228,45 +241,13 @@ export class MockedAvmTestContractDataSource implements ContractDataSource {
228
241
  );
229
242
  public instanceSameClassAsFirstContract: ContractInstanceWithAddress =
230
243
  SerializableContractInstance.default().withAddress(AztecAddress.fromNumber(0));
231
- public otherContractInstance: ContractInstanceWithAddress;
244
+ public otherContractInstance!: ContractInstanceWithAddress;
232
245
 
233
- constructor(private skipContractDeployments: boolean = false) {
246
+ private constructor(private skipContractDeployments: boolean) {
234
247
  this.bytecode = getAvmTestContractBytecode(this.fnName);
235
248
  this.fnSelector = getAvmTestContractFunctionSelector(this.fnName);
236
249
  this.publicFn = { bytecode: this.bytecode, selector: this.fnSelector };
237
250
  this.bytecodeCommitment = computePublicBytecodeCommitment(this.bytecode);
238
-
239
- // create enough unique classes to hit the limit (plus two extra)
240
- for (let i = 0; i < MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS + 1; i++) {
241
- const contractClass = makeContractClassPublic(/*seed=*/ i, this.publicFn);
242
- const contractInstance = makeContractInstanceFromClassId(contractClass.id, /*seed=*/ i);
243
- this.contractClasses.set(contractClass.id.toString(), contractClass);
244
- this.contractInstances.set(contractInstance.address.toString(), contractInstance);
245
- if (i === 0) {
246
- this.firstContractInstance = contractInstance;
247
- }
248
- }
249
- // a contract with the same class but different instance/address as the first contract
250
- this.instanceSameClassAsFirstContract = makeContractInstanceFromClassId(
251
- this.firstContractInstance.contractClassId,
252
- /*seed=*/ 1000,
253
- );
254
-
255
- // The values here should match those in `avm_simulator.test.ts`
256
- // Used for GETCONTRACTINSTANCE test
257
- this.otherContractInstance = new SerializableContractInstance({
258
- version: 1,
259
- salt: new Fr(0x123),
260
- deployer: new AztecAddress(new Fr(0x456)),
261
- contractClassId: new Fr(0x789),
262
- initializationHash: new Fr(0x101112),
263
- publicKeys: new PublicKeys(
264
- new Point(new Fr(0x131415), new Fr(0x161718), false),
265
- new Point(new Fr(0x192021), new Fr(0x222324), false),
266
- new Point(new Fr(0x252627), new Fr(0x282930), false),
267
- new Point(new Fr(0x313233), new Fr(0x343536), false),
268
- ),
269
- }).withAddress(AztecAddress.fromNumber(0x4444));
270
251
  }
271
252
 
272
253
  async deployContracts(merkleTrees: MerkleTreeWriteOperations) {
@@ -298,14 +279,39 @@ export class MockedAvmTestContractDataSource implements ContractDataSource {
298
279
  }
299
280
  }
300
281
 
301
- public static async create(
302
- merkleTrees: MerkleTreeWriteOperations,
303
- skipContractDeployments: boolean = false,
304
- ): Promise<MockedAvmTestContractDataSource> {
282
+ public static async create(skipContractDeployments: boolean = false): Promise<MockedAvmTestContractDataSource> {
305
283
  const dataSource = new MockedAvmTestContractDataSource(skipContractDeployments);
306
- if (!skipContractDeployments) {
307
- await dataSource.deployContracts(merkleTrees);
284
+ // create enough unique classes to hit the limit (plus two extra)
285
+ for (let i = 0; i < MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS + 1; i++) {
286
+ const contractClass = makeContractClassPublic(/*seed=*/ i, dataSource.publicFn);
287
+ const contractInstance = await makeContractInstanceFromClassId(contractClass.id, /*seed=*/ i);
288
+ dataSource.contractClasses.set(contractClass.id.toString(), contractClass);
289
+ dataSource.contractInstances.set(contractInstance.address.toString(), contractInstance);
290
+ if (i === 0) {
291
+ dataSource.firstContractInstance = contractInstance;
292
+ }
308
293
  }
294
+ // a contract with the same class but different instance/address as the first contract
295
+ dataSource.instanceSameClassAsFirstContract = await makeContractInstanceFromClassId(
296
+ dataSource.firstContractInstance.contractClassId,
297
+ /*seed=*/ 1000,
298
+ );
299
+
300
+ // The values here should match those in `avm_simulator.test.ts`
301
+ // Used for GETCONTRACTINSTANCE test
302
+ dataSource.otherContractInstance = new SerializableContractInstance({
303
+ version: 1,
304
+ salt: new Fr(0x123),
305
+ deployer: new AztecAddress(new Fr(0x456)),
306
+ contractClassId: new Fr(0x789),
307
+ initializationHash: new Fr(0x101112),
308
+ publicKeys: new PublicKeys(
309
+ new Point(new Fr(0x131415), new Fr(0x161718), false),
310
+ new Point(new Fr(0x192021), new Fr(0x222324), false),
311
+ new Point(new Fr(0x252627), new Fr(0x282930), false),
312
+ new Point(new Fr(0x313233), new Fr(0x343536), false),
313
+ ),
314
+ }).withAddress(AztecAddress.fromNumber(0x4444));
309
315
  return dataSource;
310
316
  }
311
317
 
@@ -12,7 +12,6 @@ import {
12
12
  } from '@aztec/circuit-types';
13
13
  import {
14
14
  type AztecAddress,
15
- type BlockHeader,
16
15
  type ContractDataSource,
17
16
  Fr,
18
17
  Gas,
@@ -60,12 +59,9 @@ export class PublicProcessorFactory {
60
59
  */
61
60
  public create(
62
61
  merkleTree: MerkleTreeWriteOperations,
63
- maybeHistoricalHeader: BlockHeader | undefined,
64
62
  globalVariables: GlobalVariables,
65
63
  enforceFeePayment: boolean,
66
64
  ): PublicProcessor {
67
- const historicalHeader = maybeHistoricalHeader ?? merkleTree.getInitialHeader();
68
-
69
65
  const worldStateDB = new WorldStateDB(merkleTree, this.contractDataSource);
70
66
  const publicTxSimulator = this.createPublicTxSimulator(
71
67
  merkleTree,
@@ -79,7 +75,6 @@ export class PublicProcessorFactory {
79
75
  return new PublicProcessor(
80
76
  merkleTree,
81
77
  globalVariables,
82
- historicalHeader,
83
78
  worldStateDB,
84
79
  publicTxSimulator,
85
80
  this.dateProvider,
@@ -122,7 +117,6 @@ export class PublicProcessor implements Traceable {
122
117
  constructor(
123
118
  protected db: MerkleTreeWriteOperations,
124
119
  protected globalVariables: GlobalVariables,
125
- protected historicalHeader: BlockHeader,
126
120
  protected worldStateDB: WorldStateDB,
127
121
  protected publicTxSimulator: PublicTxSimulator,
128
122
  private dateProvider: DateProvider,
@@ -286,7 +280,7 @@ export class PublicProcessor implements Traceable {
286
280
  const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
287
281
  this.metrics.recordAllTxs(totalPublicGas, rate);
288
282
 
289
- this.log.info(`Processed ${result.length} succesful txs and ${failed.length} txs in ${duration}ms`, {
283
+ this.log.info(`Processed ${result.length} successful txs and ${failed.length} txs in ${duration}s`, {
290
284
  duration,
291
285
  rate,
292
286
  totalPublicGas,
@@ -315,7 +309,7 @@ export class PublicProcessor implements Traceable {
315
309
  nullifierCount: processedTx.txEffect.nullifiers.length,
316
310
  noteHashCount: processedTx.txEffect.noteHashes.length,
317
311
  contractClassLogCount: processedTx.txEffect.contractClassLogs.getTotalLogCount(),
318
- unencryptedLogCount: processedTx.txEffect.unencryptedLogs.getTotalLogCount(),
312
+ publicLogCount: processedTx.txEffect.publicLogs.length,
319
313
  privateLogCount: processedTx.txEffect.privateLogs.length,
320
314
  l2ToL1MessageCount: processedTx.txEffect.l2ToL1Msgs.length,
321
315
  durationMs: time,
@@ -378,17 +372,18 @@ export class PublicProcessor implements Traceable {
378
372
  return await processFn();
379
373
  }
380
374
 
375
+ const txHash = tx.getTxHash().toString();
381
376
  const timeout = +deadline - this.dateProvider.now();
377
+ if (timeout <= 0) {
378
+ throw new PublicProcessorTimeoutError();
379
+ }
380
+
382
381
  this.log.debug(`Processing tx ${tx.getTxHash().toString()} within ${timeout}ms`, {
383
382
  deadline: deadline.toISOString(),
384
383
  now: new Date(this.dateProvider.now()).toISOString(),
385
- txHash: tx.getTxHash().toString(),
384
+ txHash,
386
385
  });
387
386
 
388
- if (timeout < 0) {
389
- throw new PublicProcessorTimeoutError();
390
- }
391
-
392
387
  return await executeTimeout(
393
388
  () => processFn(),
394
389
  timeout,
@@ -97,7 +97,7 @@ export class PublicTxContext {
97
97
  /*noteHashes*/ 0,
98
98
  /*nullifiers=*/ 0,
99
99
  countAccumulatedItems(nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs),
100
- /*unencryptedLogsHashes*/ 0,
100
+ /*publicLogs*/ 0,
101
101
  );
102
102
  const enqueuedCallTrace = new PublicEnqueuedCallSideEffectTrace(
103
103
  /*startSideEffectCounter=*/ 0,
@@ -7,7 +7,6 @@ import {
7
7
  type SimulationError,
8
8
  type Tx,
9
9
  TxExecutionPhase,
10
- UnencryptedFunctionL2Logs,
11
10
  } from '@aztec/circuit-types';
12
11
  import { type AvmSimulationStats } from '@aztec/circuit-types/stats';
13
12
  import { type Fr, type Gas, type GlobalVariables, type PublicCallRequest, type RevertCode } from '@aztec/circuits.js';
@@ -121,7 +120,6 @@ export class PublicTxSimulator {
121
120
  const endStateReference = await this.db.getStateReference();
122
121
 
123
122
  const avmProvingRequest = context.generateProvingRequest(endStateReference);
124
- const avmCircuitPublicInputs = avmProvingRequest.inputs.output!;
125
123
 
126
124
  const revertCode = context.getFinalRevertCode();
127
125
  if (!revertCode.isOK()) {
@@ -131,13 +129,8 @@ export class PublicTxSimulator {
131
129
  // FIXME: we shouldn't need to directly modify worldStateDb here!
132
130
  await this.worldStateDB.removeNewContracts(tx);
133
131
  // FIXME(dbanks12): should not be changing immutable tx
134
- tx.filterRevertedLogs(
135
- tx.data.forPublic!.nonRevertibleAccumulatedData,
136
- avmCircuitPublicInputs.accumulatedData.unencryptedLogsHashes,
137
- );
132
+ tx.filterRevertedLogs(tx.data.forPublic!.nonRevertibleAccumulatedData);
138
133
  }
139
- // FIXME(dbanks12): should not be changing immutable tx
140
- tx.unencryptedLogs.addFunctionLogs([new UnencryptedFunctionL2Logs(context.trace.getUnencryptedLogs())]);
141
134
 
142
135
  return {
143
136
  avmProvingRequest,
@@ -1,10 +1,10 @@
1
- import { type UnencryptedL2Log } from '@aztec/circuit-types';
2
1
  import {
3
2
  type ContractClassIdPreimage,
4
3
  type Gas,
5
4
  type NullifierLeafPreimage,
6
5
  type PublicCallRequest,
7
6
  type PublicDataTreeLeafPreimage,
7
+ type PublicLog,
8
8
  type SerializableContractInstance,
9
9
  } from '@aztec/circuits.js';
10
10
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
@@ -63,7 +63,7 @@ export interface PublicSideEffectTraceInterface {
63
63
  path?: Fr[],
64
64
  ): void;
65
65
  traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
66
- traceUnencryptedLog(contractAddress: AztecAddress, log: Fr[]): void;
66
+ tracePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
67
67
  traceGetContractInstance(
68
68
  contractAddress: AztecAddress,
69
69
  exists: boolean,
@@ -106,5 +106,5 @@ export interface PublicSideEffectTraceInterface {
106
106
  /** Function name for logging */
107
107
  functionName: string,
108
108
  ): PublicFunctionCallResult;
109
- getUnencryptedLogs(): UnencryptedL2Log[];
109
+ getPublicLogs(): PublicLog[];
110
110
  }