@aztec/simulator 0.59.0 → 0.61.0

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 (190) hide show
  1. package/dest/acvm/acvm.d.ts +1 -0
  2. package/dest/acvm/acvm.d.ts.map +1 -1
  3. package/dest/acvm/oracle/oracle.d.ts +5 -3
  4. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  5. package/dest/acvm/oracle/oracle.js +15 -7
  6. package/dest/acvm/oracle/typed_oracle.d.ts +7 -4
  7. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  8. package/dest/acvm/oracle/typed_oracle.js +10 -4
  9. package/dest/acvm/serialize.d.ts +1 -0
  10. package/dest/acvm/serialize.d.ts.map +1 -1
  11. package/dest/avm/avm_context.d.ts +1 -1
  12. package/dest/avm/avm_context.js +1 -1
  13. package/dest/avm/avm_execution_environment.d.ts +2 -5
  14. package/dest/avm/avm_execution_environment.d.ts.map +1 -1
  15. package/dest/avm/avm_execution_environment.js +7 -15
  16. package/dest/avm/avm_gas.d.ts.map +1 -1
  17. package/dest/avm/avm_gas.js +6 -10
  18. package/dest/avm/avm_machine_state.d.ts +2 -0
  19. package/dest/avm/avm_machine_state.d.ts.map +1 -1
  20. package/dest/avm/avm_machine_state.js +3 -1
  21. package/dest/avm/avm_memory_types.d.ts +1 -0
  22. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  23. package/dest/avm/avm_simulator.d.ts +16 -0
  24. package/dest/avm/avm_simulator.d.ts.map +1 -1
  25. package/dest/avm/avm_simulator.js +45 -4
  26. package/dest/avm/bytecode_utils.d.ts +1 -0
  27. package/dest/avm/bytecode_utils.d.ts.map +1 -1
  28. package/dest/avm/fixtures/index.d.ts +3 -0
  29. package/dest/avm/fixtures/index.d.ts.map +1 -1
  30. package/dest/avm/fixtures/index.js +8 -2
  31. package/dest/avm/journal/journal.d.ts +19 -19
  32. package/dest/avm/journal/journal.d.ts.map +1 -1
  33. package/dest/avm/journal/journal.js +73 -48
  34. package/dest/avm/journal/nullifiers.d.ts +9 -9
  35. package/dest/avm/journal/nullifiers.d.ts.map +1 -1
  36. package/dest/avm/journal/nullifiers.js +24 -24
  37. package/dest/avm/journal/public_storage.d.ts +10 -10
  38. package/dest/avm/journal/public_storage.d.ts.map +1 -1
  39. package/dest/avm/journal/public_storage.js +21 -21
  40. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  41. package/dest/avm/opcodes/accrued_substate.js +5 -5
  42. package/dest/avm/opcodes/contract.d.ts +8 -1
  43. package/dest/avm/opcodes/contract.d.ts.map +1 -1
  44. package/dest/avm/opcodes/contract.js +41 -21
  45. package/dest/avm/opcodes/conversion.d.ts +1 -1
  46. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  47. package/dest/avm/opcodes/conversion.js +12 -9
  48. package/dest/avm/opcodes/environment_getters.d.ts +13 -14
  49. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  50. package/dest/avm/opcodes/environment_getters.js +17 -16
  51. package/dest/avm/opcodes/external_calls.d.ts +3 -6
  52. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  53. package/dest/avm/opcodes/external_calls.js +23 -43
  54. package/dest/avm/opcodes/hashing.d.ts +2 -26
  55. package/dest/avm/opcodes/hashing.d.ts.map +1 -1
  56. package/dest/avm/opcodes/hashing.js +11 -95
  57. package/dest/avm/opcodes/index.d.ts +0 -1
  58. package/dest/avm/opcodes/index.d.ts.map +1 -1
  59. package/dest/avm/opcodes/index.js +1 -2
  60. package/dest/avm/opcodes/instruction.d.ts +1 -0
  61. package/dest/avm/opcodes/instruction.d.ts.map +1 -1
  62. package/dest/avm/opcodes/memory.d.ts +20 -0
  63. package/dest/avm/opcodes/memory.d.ts.map +1 -1
  64. package/dest/avm/opcodes/memory.js +59 -3
  65. package/dest/avm/opcodes/storage.js +3 -3
  66. package/dest/avm/serialization/buffer_cursor.d.ts +1 -0
  67. package/dest/avm/serialization/buffer_cursor.d.ts.map +1 -1
  68. package/dest/avm/serialization/bytecode_serialization.d.ts +1 -0
  69. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  70. package/dest/avm/serialization/bytecode_serialization.js +5 -7
  71. package/dest/avm/serialization/instruction_serialization.d.ts +34 -35
  72. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  73. package/dest/avm/serialization/instruction_serialization.js +34 -36
  74. package/dest/avm/test_utils.d.ts +3 -1
  75. package/dest/avm/test_utils.d.ts.map +1 -1
  76. package/dest/avm/test_utils.js +4 -1
  77. package/dest/client/client_execution_context.d.ts +9 -18
  78. package/dest/client/client_execution_context.d.ts.map +1 -1
  79. package/dest/client/client_execution_context.js +30 -50
  80. package/dest/client/db_oracle.d.ts +17 -1
  81. package/dest/client/db_oracle.d.ts.map +1 -1
  82. package/dest/client/db_oracle.js +1 -1
  83. package/dest/client/private_execution.d.ts.map +1 -1
  84. package/dest/client/private_execution.js +3 -4
  85. package/dest/client/simulator.d.ts.map +1 -1
  86. package/dest/client/simulator.js +3 -3
  87. package/dest/client/view_data_oracle.d.ts +17 -1
  88. package/dest/client/view_data_oracle.d.ts.map +1 -1
  89. package/dest/client/view_data_oracle.js +21 -1
  90. package/dest/common/index.d.ts +0 -1
  91. package/dest/common/index.d.ts.map +1 -1
  92. package/dest/common/index.js +1 -2
  93. package/dest/mocks/fixtures.js +2 -2
  94. package/dest/providers/acvm_native.d.ts +1 -0
  95. package/dest/providers/acvm_native.d.ts.map +1 -1
  96. package/dest/public/db_interfaces.d.ts +1 -0
  97. package/dest/public/db_interfaces.d.ts.map +1 -1
  98. package/dest/public/dual_side_effect_trace.d.ts +10 -11
  99. package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
  100. package/dest/public/dual_side_effect_trace.js +26 -22
  101. package/dest/public/enqueued_call_side_effect_trace.d.ts +11 -12
  102. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  103. package/dest/public/enqueued_call_side_effect_trace.js +33 -23
  104. package/dest/public/enqueued_call_simulator.d.ts +3 -3
  105. package/dest/public/enqueued_call_simulator.d.ts.map +1 -1
  106. package/dest/public/enqueued_call_simulator.js +30 -39
  107. package/dest/public/enqueued_calls_processor.d.ts +2 -3
  108. package/dest/public/enqueued_calls_processor.d.ts.map +1 -1
  109. package/dest/public/enqueued_calls_processor.js +19 -26
  110. package/dest/public/execution.d.ts +1 -0
  111. package/dest/public/execution.d.ts.map +1 -1
  112. package/dest/public/execution.js +2 -2
  113. package/dest/public/executor.d.ts.map +1 -1
  114. package/dest/public/executor.js +6 -5
  115. package/dest/public/public_db_sources.d.ts +1 -0
  116. package/dest/public/public_db_sources.d.ts.map +1 -1
  117. package/dest/public/public_kernel.d.ts +0 -1
  118. package/dest/public/public_kernel.d.ts.map +1 -1
  119. package/dest/public/public_kernel.js +5 -8
  120. package/dest/public/public_kernel_tail_simulator.d.ts +1 -5
  121. package/dest/public/public_kernel_tail_simulator.d.ts.map +1 -1
  122. package/dest/public/public_kernel_tail_simulator.js +6 -12
  123. package/dest/public/public_processor.js +4 -4
  124. package/dest/public/side_effect_trace.d.ts +11 -9
  125. package/dest/public/side_effect_trace.d.ts.map +1 -1
  126. package/dest/public/side_effect_trace.js +40 -30
  127. package/dest/public/side_effect_trace_interface.d.ts +10 -9
  128. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  129. package/package.json +9 -9
  130. package/src/acvm/oracle/oracle.ts +13 -6
  131. package/src/acvm/oracle/typed_oracle.ts +9 -3
  132. package/src/avm/avm_context.ts +1 -1
  133. package/src/avm/avm_execution_environment.ts +0 -15
  134. package/src/avm/avm_gas.ts +5 -9
  135. package/src/avm/avm_machine_state.ts +2 -0
  136. package/src/avm/avm_simulator.ts +69 -6
  137. package/src/avm/fixtures/index.ts +7 -2
  138. package/src/avm/journal/journal.ts +93 -50
  139. package/src/avm/journal/nullifiers.ts +23 -23
  140. package/src/avm/journal/public_storage.ts +20 -20
  141. package/src/avm/opcodes/accrued_substate.ts +4 -8
  142. package/src/avm/opcodes/contract.ts +45 -21
  143. package/src/avm/opcodes/conversion.ts +9 -6
  144. package/src/avm/opcodes/environment_getters.ts +7 -5
  145. package/src/avm/opcodes/external_calls.ts +21 -45
  146. package/src/avm/opcodes/hashing.ts +9 -122
  147. package/src/avm/opcodes/index.ts +0 -1
  148. package/src/avm/opcodes/memory.ts +69 -2
  149. package/src/avm/opcodes/storage.ts +2 -2
  150. package/src/avm/serialization/bytecode_serialization.ts +6 -9
  151. package/src/avm/serialization/instruction_serialization.ts +3 -5
  152. package/src/avm/test_utils.ts +5 -1
  153. package/src/client/client_execution_context.ts +21 -71
  154. package/src/client/db_oracle.ts +26 -0
  155. package/src/client/private_execution.ts +1 -9
  156. package/src/client/simulator.ts +0 -2
  157. package/src/client/view_data_oracle.ts +31 -1
  158. package/src/common/index.ts +0 -1
  159. package/src/mocks/fixtures.ts +1 -1
  160. package/src/public/dual_side_effect_trace.ts +38 -24
  161. package/src/public/enqueued_call_side_effect_trace.ts +60 -28
  162. package/src/public/enqueued_call_simulator.ts +52 -49
  163. package/src/public/enqueued_calls_processor.ts +27 -41
  164. package/src/public/execution.ts +1 -1
  165. package/src/public/executor.ts +11 -5
  166. package/src/public/public_kernel.ts +9 -12
  167. package/src/public/public_kernel_tail_simulator.ts +6 -15
  168. package/src/public/public_processor.ts +3 -3
  169. package/src/public/side_effect_trace.ts +73 -29
  170. package/src/public/side_effect_trace_interface.ts +15 -10
  171. package/dest/avm/opcodes/commitment.d.ts +0 -16
  172. package/dest/avm/opcodes/commitment.d.ts.map +0 -1
  173. package/dest/avm/opcodes/commitment.js +0 -51
  174. package/dest/client/test_utils.d.ts +0 -9
  175. package/dest/client/test_utils.d.ts.map +0 -1
  176. package/dest/client/test_utils.js +0 -27
  177. package/dest/common/side_effect_counter.d.ts +0 -10
  178. package/dest/common/side_effect_counter.d.ts.map +0 -1
  179. package/dest/common/side_effect_counter.js +0 -18
  180. package/dest/rollup/index.d.ts +0 -2
  181. package/dest/rollup/index.d.ts.map +0 -1
  182. package/dest/rollup/index.js +0 -2
  183. package/dest/rollup/rollup.d.ts +0 -101
  184. package/dest/rollup/rollup.d.ts.map +0 -1
  185. package/dest/rollup/rollup.js +0 -100
  186. package/src/avm/opcodes/commitment.ts +0 -65
  187. package/src/client/test_utils.ts +0 -57
  188. package/src/common/side_effect_counter.ts +0 -17
  189. package/src/rollup/index.ts +0 -1
  190. package/src/rollup/rollup.ts +0 -228
@@ -19,7 +19,6 @@ import {
19
19
  InternalReturn,
20
20
  Jump,
21
21
  JumpI,
22
- Keccak,
23
22
  KeccakF1600,
24
23
  L1ToL2MessageExists,
25
24
  Lt,
@@ -30,10 +29,10 @@ import {
30
29
  NoteHashExists,
31
30
  NullifierExists,
32
31
  Or,
33
- Pedersen,
34
- PedersenCommitment,
35
32
  Poseidon2,
36
33
  Return,
34
+ ReturndataCopy,
35
+ ReturndataSize,
37
36
  Revert,
38
37
  SLoad,
39
38
  SStore,
@@ -44,7 +43,7 @@ import {
44
43
  Shr,
45
44
  StaticCall,
46
45
  Sub,
47
- ToRadixLE,
46
+ ToRadixBE,
48
47
  Xor,
49
48
  } from '../opcodes/index.js';
50
49
  import { MultiScalarMul } from '../opcodes/multi_scalar_mul.js';
@@ -99,6 +98,8 @@ const INSTRUCTION_SET = () =>
99
98
  // Execution Environment
100
99
  [Opcode.GETENVVAR_16, GetEnvVar.as(GetEnvVar.wireFormat16).deserialize],
101
100
  [CalldataCopy.opcode, Instruction.deserialize.bind(CalldataCopy)],
101
+ [Opcode.RETURNDATASIZE, Instruction.deserialize.bind(ReturndataSize)],
102
+ [Opcode.RETURNDATACOPY, Instruction.deserialize.bind(ReturndataCopy)],
102
103
 
103
104
  // Machine State - Internal Control Flow
104
105
  [Jump.opcode, Instruction.deserialize.bind(Jump)],
@@ -131,7 +132,6 @@ const INSTRUCTION_SET = () =>
131
132
  // Control Flow - Contract Calls
132
133
  [Call.opcode, Instruction.deserialize.bind(Call)],
133
134
  [StaticCall.opcode, Instruction.deserialize.bind(StaticCall)],
134
- //[DelegateCall.opcode, Instruction.deserialize.bind(DelegateCall)],
135
135
  [Return.opcode, Instruction.deserialize.bind(Return)],
136
136
  [Opcode.REVERT_8, Revert.as(Revert.wireFormat8).deserialize],
137
137
  [Opcode.REVERT_16, Revert.as(Revert.wireFormat16).deserialize],
@@ -141,14 +141,11 @@ const INSTRUCTION_SET = () =>
141
141
 
142
142
  // Gadgets
143
143
  [EcAdd.opcode, Instruction.deserialize.bind(EcAdd)],
144
- [Keccak.opcode, Instruction.deserialize.bind(Keccak)],
145
144
  [Poseidon2.opcode, Instruction.deserialize.bind(Poseidon2)],
146
145
  [Sha256Compression.opcode, Instruction.deserialize.bind(Sha256Compression)],
147
- [Pedersen.opcode, Instruction.deserialize.bind(Pedersen)],
148
146
  [MultiScalarMul.opcode, Instruction.deserialize.bind(MultiScalarMul)],
149
- [PedersenCommitment.opcode, Instruction.deserialize.bind(PedersenCommitment)],
150
147
  // Conversions
151
- [ToRadixLE.opcode, Instruction.deserialize.bind(ToRadixLE)],
148
+ [ToRadixBE.opcode, Instruction.deserialize.bind(ToRadixBE)],
152
149
  // Future Gadgets -- pending changes in noir
153
150
  // SHA256COMPRESSION,
154
151
  [KeccakF1600.opcode, Instruction.deserialize.bind(KeccakF1600)],
@@ -41,6 +41,8 @@ export enum Opcode {
41
41
  // Execution environment
42
42
  GETENVVAR_16,
43
43
  CALLDATACOPY,
44
+ RETURNDATASIZE,
45
+ RETURNDATACOPY,
44
46
  // Control flow
45
47
  JUMP_16,
46
48
  JUMPI_16,
@@ -69,23 +71,19 @@ export enum Opcode {
69
71
  // External calls
70
72
  CALL,
71
73
  STATICCALL,
72
- DELEGATECALL,
73
74
  RETURN,
74
75
  REVERT_8,
75
76
  REVERT_16,
76
77
  // Misc
77
78
  DEBUGLOG,
78
79
  // Gadgets
79
- KECCAK,
80
80
  POSEIDON2,
81
81
  SHA256COMPRESSION,
82
82
  KECCAKF1600,
83
- PEDERSEN, // temp - may be removed, but alot of contracts rely on it
84
83
  ECADD,
85
84
  MSM,
86
- PEDERSENCOMMITMENT,
87
85
  // Conversion
88
- TORADIXLE,
86
+ TORADIXBE,
89
87
  }
90
88
 
91
89
  // Possible types for an instruction's operand in its wire format. (Keep in sync with CPP code.
@@ -1,4 +1,4 @@
1
- import { type ContractInstanceWithAddress, Fr } from '@aztec/circuits.js';
1
+ import { type ContractClassPublic, type ContractInstanceWithAddress, Fr } from '@aztec/circuits.js';
2
2
 
3
3
  import { type jest } from '@jest/globals';
4
4
  import { mock } from 'jest-mock-extended';
@@ -61,3 +61,7 @@ export function mockL1ToL2MessageExists(
61
61
  export function mockGetContractInstance(worldStateDB: WorldStateDB, contractInstance: ContractInstanceWithAddress) {
62
62
  (worldStateDB as jest.Mocked<WorldStateDB>).getContractInstance.mockResolvedValue(contractInstance);
63
63
  }
64
+
65
+ export function mockGetContractClass(worldStateDB: WorldStateDB, contractClass: ContractClassPublic) {
66
+ (worldStateDB as jest.Mocked<WorldStateDB>).getContractClass.mockResolvedValue(contractClass);
67
+ }
@@ -68,7 +68,6 @@ export class ClientExecutionContext extends ViewDataOracle {
68
68
  private publicTeardownFunctionCall: PublicExecutionRequest = PublicExecutionRequest.empty();
69
69
 
70
70
  constructor(
71
- contractAddress: AztecAddress,
72
71
  private readonly argsHash: Fr,
73
72
  private readonly txContext: TxContext,
74
73
  private readonly callContext: CallContext,
@@ -84,7 +83,7 @@ export class ClientExecutionContext extends ViewDataOracle {
84
83
  log = createDebugLogger('aztec:simulator:client_execution_context'),
85
84
  scopes?: AztecAddress[],
86
85
  ) {
87
- super(contractAddress, authWitnesses, db, node, log, scopes);
86
+ super(callContext.contractAddress, authWitnesses, db, node, log, scopes);
88
87
  }
89
88
 
90
89
  // We still need this function until we can get user-defined ordering of structs for fn arguments
@@ -240,10 +239,10 @@ export class ClientExecutionContext extends ViewDataOracle {
240
239
  status: NoteStatus,
241
240
  ): Promise<NoteData[]> {
242
241
  // Nullified pending notes are already removed from the list.
243
- const pendingNotes = this.noteCache.getNotes(this.callContext.storageContractAddress, storageSlot);
242
+ const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, storageSlot);
244
243
 
245
- const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.storageContractAddress);
246
- const dbNotes = await this.db.getNotes(this.callContext.storageContractAddress, storageSlot, status, this.scopes);
244
+ const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
245
+ const dbNotes = await this.db.getNotes(this.callContext.contractAddress, storageSlot, status, this.scopes);
247
246
  const dbNotesFiltered = dbNotes.filter(n => !pendingNullifiers.has((n.siloedNullifier as Fr).value));
248
247
 
249
248
  const notes = pickNotes<NoteData>([...dbNotesFiltered, ...pendingNotes], {
@@ -261,7 +260,7 @@ export class ClientExecutionContext extends ViewDataOracle {
261
260
  });
262
261
 
263
262
  this.log.debug(
264
- `Returning ${notes.length} notes for ${this.callContext.storageContractAddress} at ${storageSlot}: ${notes
263
+ `Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes
265
264
  .map(n => `${n.nonce.toString()}:[${n.note.items.map(i => i.toString()).join(',')}]`)
266
265
  .join(', ')}`,
267
266
  );
@@ -297,7 +296,7 @@ export class ClientExecutionContext extends ViewDataOracle {
297
296
  const note = new Note(noteItems);
298
297
  this.noteCache.addNewNote(
299
298
  {
300
- contractAddress: this.callContext.storageContractAddress,
299
+ contractAddress: this.callContext.contractAddress,
301
300
  storageSlot,
302
301
  nonce: Fr.ZERO, // Nonce cannot be known during private execution.
303
302
  note,
@@ -317,7 +316,7 @@ export class ClientExecutionContext extends ViewDataOracle {
317
316
  */
318
317
  public override notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
319
318
  const nullifiedNoteHashCounter = this.noteCache.nullifyNote(
320
- this.callContext.storageContractAddress,
319
+ this.callContext.contractAddress,
321
320
  innerNullifier,
322
321
  noteHash,
323
322
  );
@@ -391,11 +390,11 @@ export class ClientExecutionContext extends ViewDataOracle {
391
390
 
392
391
  #checkValidStaticCall(childExecutionResult: PrivateExecutionResult) {
393
392
  if (
394
- childExecutionResult.callStackItem.publicInputs.noteHashes.some(item => !item.isEmpty()) ||
395
- childExecutionResult.callStackItem.publicInputs.nullifiers.some(item => !item.isEmpty()) ||
396
- childExecutionResult.callStackItem.publicInputs.l2ToL1Msgs.some(item => !item.isEmpty()) ||
397
- childExecutionResult.callStackItem.publicInputs.encryptedLogsHashes.some(item => !item.isEmpty()) ||
398
- childExecutionResult.callStackItem.publicInputs.unencryptedLogsHashes.some(item => !item.isEmpty())
393
+ childExecutionResult.publicInputs.noteHashes.some(item => !item.isEmpty()) ||
394
+ childExecutionResult.publicInputs.nullifiers.some(item => !item.isEmpty()) ||
395
+ childExecutionResult.publicInputs.l2ToL1Msgs.some(item => !item.isEmpty()) ||
396
+ childExecutionResult.publicInputs.encryptedLogsHashes.some(item => !item.isEmpty()) ||
397
+ childExecutionResult.publicInputs.unencryptedLogsHashes.some(item => !item.isEmpty())
399
398
  ) {
400
399
  throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
401
400
  }
@@ -408,7 +407,6 @@ export class ClientExecutionContext extends ViewDataOracle {
408
407
  * @param argsHash - The packed arguments to pass to the function.
409
408
  * @param sideEffectCounter - The side effect counter at the start of the call.
410
409
  * @param isStaticCall - Whether the call is a static call.
411
- * @param isDelegateCall - Whether the call is a delegate call.
412
410
  * @returns The execution result.
413
411
  */
414
412
  override async callPrivateFunction(
@@ -417,10 +415,9 @@ export class ClientExecutionContext extends ViewDataOracle {
417
415
  argsHash: Fr,
418
416
  sideEffectCounter: number,
419
417
  isStaticCall: boolean,
420
- isDelegateCall: boolean,
421
418
  ) {
422
419
  this.log.debug(
423
- `Calling private function ${this.contractAddress}:${functionSelector} from ${this.callContext.storageContractAddress}`,
420
+ `Calling private function ${this.contractAddress}:${functionSelector} from ${this.callContext.contractAddress}`,
424
421
  );
425
422
 
426
423
  isStaticCall = isStaticCall || this.callContext.isStaticCall;
@@ -429,15 +426,9 @@ export class ClientExecutionContext extends ViewDataOracle {
429
426
 
430
427
  const derivedTxContext = this.txContext.clone();
431
428
 
432
- const derivedCallContext = this.deriveCallContext(
433
- targetContractAddress,
434
- targetArtifact,
435
- isDelegateCall,
436
- isStaticCall,
437
- );
429
+ const derivedCallContext = this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
438
430
 
439
431
  const context = new ClientExecutionContext(
440
- targetContractAddress,
441
432
  argsHash,
442
433
  derivedTxContext,
443
434
  derivedCallContext,
@@ -465,7 +456,7 @@ export class ClientExecutionContext extends ViewDataOracle {
465
456
 
466
457
  this.nestedExecutions.push(childExecutionResult);
467
458
 
468
- const publicInputs = childExecutionResult.callStackItem.publicInputs;
459
+ const publicInputs = childExecutionResult.publicInputs;
469
460
  return {
470
461
  endSideEffectCounter: publicInputs.endSideEffectCounter,
471
462
  returnsHash: publicInputs.returnsHash,
@@ -473,7 +464,7 @@ export class ClientExecutionContext extends ViewDataOracle {
473
464
  }
474
465
 
475
466
  /**
476
- * Creates a PublicCallStackItem object representing the request to call a public function.
467
+ * Creates a PublicExecutionRequest object representing the request to call a public function.
477
468
  * @param targetContractAddress - The address of the contract to call.
478
469
  * @param functionSelector - The function selector of the function to call.
479
470
  * @param argsHash - The packed arguments to pass to the function.
@@ -488,15 +479,9 @@ export class ClientExecutionContext extends ViewDataOracle {
488
479
  argsHash: Fr,
489
480
  sideEffectCounter: number,
490
481
  isStaticCall: boolean,
491
- isDelegateCall: boolean,
492
482
  ) {
493
483
  const targetArtifact = await this.db.getFunctionArtifact(targetContractAddress, functionSelector);
494
- const derivedCallContext = this.deriveCallContext(
495
- targetContractAddress,
496
- targetArtifact,
497
- isDelegateCall,
498
- isStaticCall,
499
- );
484
+ const derivedCallContext = this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
500
485
  const args = this.packedValuesCache.unpack(argsHash);
501
486
 
502
487
  this.log.verbose(
@@ -506,7 +491,6 @@ export class ClientExecutionContext extends ViewDataOracle {
506
491
  const request = PublicExecutionRequest.from({
507
492
  args,
508
493
  callContext: derivedCallContext,
509
- contractAddress: targetContractAddress,
510
494
  });
511
495
 
512
496
  if (callType === 'enqueued') {
@@ -517,7 +501,7 @@ export class ClientExecutionContext extends ViewDataOracle {
517
501
  }
518
502
 
519
503
  /**
520
- * Creates and enqueues a PublicCallStackItem object representing the request to call a public function. No function
504
+ * Creates and enqueues a PublicExecutionRequest object representing the request to call a public function. No function
521
505
  * is actually called, since that must happen on the sequencer side. All the fields related to the result
522
506
  * of the execution are empty.
523
507
  * @param targetContractAddress - The address of the contract to call.
@@ -533,7 +517,6 @@ export class ClientExecutionContext extends ViewDataOracle {
533
517
  argsHash: Fr,
534
518
  sideEffectCounter: number,
535
519
  isStaticCall: boolean,
536
- isDelegateCall: boolean,
537
520
  ): Promise<Fr> {
538
521
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
539
522
  // WARNING: This is insecure and should be temporary!
@@ -552,13 +535,12 @@ export class ClientExecutionContext extends ViewDataOracle {
552
535
  newArgsHash,
553
536
  sideEffectCounter,
554
537
  isStaticCall,
555
- isDelegateCall,
556
538
  );
557
539
  return newArgsHash;
558
540
  }
559
541
 
560
542
  /**
561
- * Creates a PublicCallStackItem and sets it as the public teardown function. No function
543
+ * Creates a PublicExecutionRequest and sets it as the public teardown function. No function
562
544
  * is actually called, since that must happen on the sequencer side. All the fields related to the result
563
545
  * of the execution are empty.
564
546
  * @param targetContractAddress - The address of the contract to call.
@@ -574,7 +556,6 @@ export class ClientExecutionContext extends ViewDataOracle {
574
556
  argsHash: Fr,
575
557
  sideEffectCounter: number,
576
558
  isStaticCall: boolean,
577
- isDelegateCall: boolean,
578
559
  ): Promise<Fr> {
579
560
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
580
561
  // WARNING: This is insecure and should be temporary!
@@ -593,7 +574,6 @@ export class ClientExecutionContext extends ViewDataOracle {
593
574
  newArgsHash,
594
575
  sideEffectCounter,
595
576
  isStaticCall,
596
- isDelegateCall,
597
577
  );
598
578
  return newArgsHash;
599
579
  }
@@ -606,52 +586,22 @@ export class ClientExecutionContext extends ViewDataOracle {
606
586
  * Derives the call context for a nested execution.
607
587
  * @param targetContractAddress - The address of the contract being called.
608
588
  * @param targetArtifact - The artifact of the function being called.
609
- * @param isDelegateCall - Whether the call is a delegate call.
610
589
  * @param isStaticCall - Whether the call is a static call.
611
590
  * @returns The derived call context.
612
591
  */
613
592
  private deriveCallContext(
614
593
  targetContractAddress: AztecAddress,
615
594
  targetArtifact: FunctionArtifact,
616
- isDelegateCall = false,
617
595
  isStaticCall = false,
618
596
  ) {
619
597
  return new CallContext(
620
- isDelegateCall ? this.callContext.msgSender : this.contractAddress,
621
- isDelegateCall ? this.contractAddress : targetContractAddress,
598
+ this.contractAddress,
599
+ targetContractAddress,
622
600
  FunctionSelector.fromNameAndParameters(targetArtifact.name, targetArtifact.parameters),
623
- isDelegateCall,
624
601
  isStaticCall,
625
602
  );
626
603
  }
627
604
 
628
- /**
629
- * Read the public storage data.
630
- * @param contractAddress - The address to read storage from.
631
- * @param startStorageSlot - The starting storage slot.
632
- * @param blockNumber - The block number to read storage at.
633
- * @param numberOfElements - Number of elements to read from the starting storage slot.
634
- */
635
- public override async storageRead(
636
- contractAddress: Fr,
637
- startStorageSlot: Fr,
638
- blockNumber: number,
639
- numberOfElements: number,
640
- ): Promise<Fr[]> {
641
- const values = [];
642
- for (let i = 0n; i < numberOfElements; i++) {
643
- const storageSlot = new Fr(startStorageSlot.value + i);
644
-
645
- const value = await this.aztecNode.getPublicStorageAt(contractAddress, storageSlot, blockNumber);
646
- this.log.debug(
647
- `Oracle storage read: slot=${storageSlot.toString()} address-${contractAddress.toString()} value=${value}`,
648
- );
649
-
650
- values.push(value);
651
- }
652
- return values;
653
- }
654
-
655
605
  public override debugLog(message: string, fields: Fr[]) {
656
606
  this.log.verbose(`debug_log ${applyStringFormatting(message, fields)}`);
657
607
  }
@@ -9,6 +9,7 @@ import {
9
9
  type CompleteAddress,
10
10
  type ContractInstance,
11
11
  type Header,
12
+ type IndexedTaggingSecret,
12
13
  type KeyValidationRequest,
13
14
  } from '@aztec/circuits.js';
14
15
  import { type FunctionArtifact, type FunctionSelector } from '@aztec/foundation/abi';
@@ -193,4 +194,29 @@ export interface DBOracle extends CommitmentsDB {
193
194
  * @returns The block number.
194
195
  */
195
196
  getBlockNumber(): Promise<number>;
197
+
198
+ /**
199
+ * Returns the tagging secret for a given sender and recipient pair. For this to work, the ivpsk_m of the sender must be known.
200
+ * Includes the last known index used for tagging with this secret.
201
+ * @param contractAddress - The contract address to silo the secret for
202
+ * @param sender - The address sending the note
203
+ * @param recipient - The address receiving the note
204
+ * @returns A tagging secret that can be used to tag notes.
205
+ */
206
+ getAppTaggingSecret(
207
+ contractAddress: AztecAddress,
208
+ sender: AztecAddress,
209
+ recipient: AztecAddress,
210
+ ): Promise<IndexedTaggingSecret>;
211
+
212
+ /**
213
+ * Returns the siloed tagging secrets for a given recipient and all the senders in the address book
214
+ * @param contractAddress - The contract address to silo the secret for
215
+ * @param recipient - The address receiving the notes
216
+ * @returns A list of siloed tagging secrets
217
+ */
218
+ getAppTaggingSecretsForSenders(
219
+ contractAddress: AztecAddress,
220
+ recipient: AztecAddress,
221
+ ): Promise<IndexedTaggingSecret[]>;
196
222
  }
@@ -2,10 +2,8 @@ import { PrivateExecutionResult } from '@aztec/circuit-types';
2
2
  import { type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
3
3
  import {
4
4
  Fr,
5
- FunctionData,
6
5
  PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH,
7
6
  PRIVATE_CONTEXT_INPUTS_LENGTH,
8
- PrivateCallStackItem,
9
7
  PrivateCircuitPublicInputs,
10
8
  } from '@aztec/circuits.js';
11
9
  import { type FunctionArtifact, type FunctionSelector, countArgumentsSize } from '@aztec/foundation/abi';
@@ -64,12 +62,6 @@ export async function executePrivateFunction(
64
62
  const encryptedLogs = context.getEncryptedLogs();
65
63
  const unencryptedLogs = context.getUnencryptedLogs();
66
64
 
67
- const callStackItem = new PrivateCallStackItem(
68
- contractAddress,
69
- new FunctionData(functionSelector, true),
70
- publicInputs,
71
- );
72
-
73
65
  const rawReturnValues = await context.unpackReturns(publicInputs.returnsHash);
74
66
 
75
67
  const noteHashLeafIndexMap = context.getNoteHashLeafIndexMap();
@@ -85,7 +77,7 @@ export async function executePrivateFunction(
85
77
  acir,
86
78
  Buffer.from(artifact.verificationKey!, 'hex'),
87
79
  partialWitness,
88
- callStackItem,
80
+ publicInputs,
89
81
  noteHashLeafIndexMap,
90
82
  newNotes,
91
83
  noteHashNullifierCounterMap,
@@ -66,14 +66,12 @@ export class AcirSimulator {
66
66
  msgSender,
67
67
  contractAddress,
68
68
  FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters),
69
- false,
70
69
  entryPointArtifact.isStatic,
71
70
  );
72
71
 
73
72
  const txHash = request.toTxRequest().hash();
74
73
 
75
74
  const context = new ClientExecutionContext(
76
- contractAddress,
77
75
  request.firstCallArgsHash,
78
76
  request.txContext,
79
77
  callContext,
@@ -7,7 +7,12 @@ import {
7
7
  type NullifierMembershipWitness,
8
8
  type PublicDataWitness,
9
9
  } from '@aztec/circuit-types';
10
- import { type ContractInstance, type Header, type KeyValidationRequest } from '@aztec/circuits.js';
10
+ import {
11
+ type ContractInstance,
12
+ type Header,
13
+ type IndexedTaggingSecret,
14
+ type KeyValidationRequest,
15
+ } from '@aztec/circuits.js';
11
16
  import { siloNullifier } from '@aztec/circuits.js/hash';
12
17
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
13
18
  import { Fr } from '@aztec/foundation/fields';
@@ -288,4 +293,29 @@ export class ViewDataOracle extends TypedOracle {
288
293
  const formattedStr = applyStringFormatting(message, fields);
289
294
  this.log.verbose(`debug_log ${formattedStr}`);
290
295
  }
296
+
297
+ /**
298
+ * Returns the tagging secret for a given sender and recipient pair, siloed to the current contract address.
299
+ * Includes the last known index used for tagging with this secret.
300
+ * For this to work, the ivpsk_m of the sender must be known.
301
+ * @param sender - The address sending the note
302
+ * @param recipient - The address receiving the note
303
+ * @returns A tagging secret that can be used to tag notes.
304
+ */
305
+ public override async getAppTaggingSecret(
306
+ sender: AztecAddress,
307
+ recipient: AztecAddress,
308
+ ): Promise<IndexedTaggingSecret> {
309
+ return await this.db.getAppTaggingSecret(this.contractAddress, sender, recipient);
310
+ }
311
+
312
+ /**
313
+ * Returns the siloed tagging secrets for a given recipient and all the senders in the address book
314
+ * @param contractAddress - The contract address to silo the secret for
315
+ * @param recipient - The address receiving the notes
316
+ * @returns A list of siloed tagging secrets
317
+ */
318
+ public override async getAppTaggingSecretsForSenders(recipient: AztecAddress): Promise<IndexedTaggingSecret[]> {
319
+ return await this.db.getAppTaggingSecretsForSenders(this.contractAddress, recipient);
320
+ }
291
321
  }
@@ -1,3 +1,2 @@
1
1
  export * from './packed_values_cache.js';
2
2
  export * from './errors.js';
3
- export * from './side_effect_counter.js';
@@ -79,7 +79,7 @@ export class PublicExecutionResultBuilder {
79
79
  revertReason?: SimulationError;
80
80
  }) {
81
81
  const builder = new PublicExecutionResultBuilder(
82
- new PublicExecutionRequest(tx.to, new CallContext(from, tx.to, tx.selector, false, false), tx.args),
82
+ new PublicExecutionRequest(new CallContext(from, tx.to, tx.selector, false), tx.args),
83
83
  );
84
84
 
85
85
  builder.withNestedExecutions(...nestedExecutions);
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  type CombinedConstantData,
3
- type ContractInstanceWithAddress,
3
+ type ContractClassIdPreimage,
4
4
  type Gas,
5
+ type SerializableContractInstance,
5
6
  type VMCircuitPublicInputs,
6
7
  } from '@aztec/circuits.js';
7
8
  import { type Fr } from '@aztec/foundation/fields';
@@ -15,8 +16,6 @@ import { type PublicExecutionResult } from './execution.js';
15
16
  import { type PublicSideEffectTrace } from './side_effect_trace.js';
16
17
  import { type PublicSideEffectTraceInterface } from './side_effect_trace_interface.js';
17
18
 
18
- export type TracedContractInstance = { exists: boolean } & ContractInstanceWithAddress;
19
-
20
19
  export class DualSideEffectTrace implements PublicSideEffectTraceInterface {
21
20
  constructor(
22
21
  public readonly innerCallTrace: PublicSideEffectTrace,
@@ -32,35 +31,35 @@ export class DualSideEffectTrace implements PublicSideEffectTraceInterface {
32
31
  return this.innerCallTrace.getCounter();
33
32
  }
34
33
 
35
- public tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr, exists: boolean, cached: boolean) {
36
- this.innerCallTrace.tracePublicStorageRead(storageAddress, slot, value, exists, cached);
37
- this.enqueuedCallTrace.tracePublicStorageRead(storageAddress, slot, value, exists, cached);
34
+ public tracePublicStorageRead(contractAddress: Fr, slot: Fr, value: Fr, exists: boolean, cached: boolean) {
35
+ this.innerCallTrace.tracePublicStorageRead(contractAddress, slot, value, exists, cached);
36
+ this.enqueuedCallTrace.tracePublicStorageRead(contractAddress, slot, value, exists, cached);
38
37
  }
39
38
 
40
- public tracePublicStorageWrite(storageAddress: Fr, slot: Fr, value: Fr) {
41
- this.innerCallTrace.tracePublicStorageWrite(storageAddress, slot, value);
42
- this.enqueuedCallTrace.tracePublicStorageWrite(storageAddress, slot, value);
39
+ public tracePublicStorageWrite(contractAddress: Fr, slot: Fr, value: Fr) {
40
+ this.innerCallTrace.tracePublicStorageWrite(contractAddress, slot, value);
41
+ this.enqueuedCallTrace.tracePublicStorageWrite(contractAddress, slot, value);
43
42
  }
44
43
 
45
44
  // TODO(8287): _exists can be removed once we have the vm properly handling the equality check
46
- public traceNoteHashCheck(_storageAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) {
47
- this.innerCallTrace.traceNoteHashCheck(_storageAddress, noteHash, leafIndex, exists);
48
- this.enqueuedCallTrace.traceNoteHashCheck(_storageAddress, noteHash, leafIndex, exists);
45
+ public traceNoteHashCheck(_contractAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) {
46
+ this.innerCallTrace.traceNoteHashCheck(_contractAddress, noteHash, leafIndex, exists);
47
+ this.enqueuedCallTrace.traceNoteHashCheck(_contractAddress, noteHash, leafIndex, exists);
49
48
  }
50
49
 
51
- public traceNewNoteHash(_storageAddress: Fr, noteHash: Fr) {
52
- this.innerCallTrace.traceNewNoteHash(_storageAddress, noteHash);
53
- this.enqueuedCallTrace.traceNewNoteHash(_storageAddress, noteHash);
50
+ public traceNewNoteHash(_contractAddress: Fr, noteHash: Fr) {
51
+ this.innerCallTrace.traceNewNoteHash(_contractAddress, noteHash);
52
+ this.enqueuedCallTrace.traceNewNoteHash(_contractAddress, noteHash);
54
53
  }
55
54
 
56
- public traceNullifierCheck(storageAddress: Fr, nullifier: Fr, leafIndex: Fr, exists: boolean, isPending: boolean) {
57
- this.innerCallTrace.traceNullifierCheck(storageAddress, nullifier, leafIndex, exists, isPending);
58
- this.enqueuedCallTrace.traceNullifierCheck(storageAddress, nullifier, leafIndex, exists, isPending);
55
+ public traceNullifierCheck(contractAddress: Fr, nullifier: Fr, leafIndex: Fr, exists: boolean, isPending: boolean) {
56
+ this.innerCallTrace.traceNullifierCheck(contractAddress, nullifier, leafIndex, exists, isPending);
57
+ this.enqueuedCallTrace.traceNullifierCheck(contractAddress, nullifier, leafIndex, exists, isPending);
59
58
  }
60
59
 
61
- public traceNewNullifier(storageAddress: Fr, nullifier: Fr) {
62
- this.innerCallTrace.traceNewNullifier(storageAddress, nullifier);
63
- this.enqueuedCallTrace.traceNewNullifier(storageAddress, nullifier);
60
+ public traceNewNullifier(contractAddress: Fr, nullifier: Fr) {
61
+ this.innerCallTrace.traceNewNullifier(contractAddress, nullifier);
62
+ this.enqueuedCallTrace.traceNewNullifier(contractAddress, nullifier);
64
63
  }
65
64
 
66
65
  public traceL1ToL2MessageCheck(contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) {
@@ -78,9 +77,24 @@ export class DualSideEffectTrace implements PublicSideEffectTraceInterface {
78
77
  this.enqueuedCallTrace.traceUnencryptedLog(contractAddress, log);
79
78
  }
80
79
 
81
- public traceGetContractInstance(instance: TracedContractInstance) {
82
- this.innerCallTrace.traceGetContractInstance(instance);
83
- this.enqueuedCallTrace.traceGetContractInstance(instance);
80
+ public traceGetContractInstance(
81
+ contractAddress: Fr,
82
+ exists: boolean,
83
+ instance: SerializableContractInstance | undefined,
84
+ ) {
85
+ this.innerCallTrace.traceGetContractInstance(contractAddress, exists, instance);
86
+ this.enqueuedCallTrace.traceGetContractInstance(contractAddress, exists, instance);
87
+ }
88
+
89
+ public traceGetBytecode(
90
+ contractAddress: Fr,
91
+ exists: boolean,
92
+ bytecode: Buffer,
93
+ contractInstance: SerializableContractInstance | undefined,
94
+ contractClass: ContractClassIdPreimage | undefined,
95
+ ) {
96
+ this.innerCallTrace.traceGetBytecode(contractAddress, exists, bytecode, contractInstance, contractClass);
97
+ this.enqueuedCallTrace.traceGetBytecode(contractAddress, exists, bytecode, contractInstance, contractClass);
84
98
  }
85
99
 
86
100
  /**