@aztec/simulator 0.37.0 → 0.39.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 (181) hide show
  1. package/dest/acvm/acvm.d.ts +1 -1
  2. package/dest/acvm/acvm.d.ts.map +1 -1
  3. package/dest/acvm/acvm.js +2 -2
  4. package/dest/acvm/oracle/oracle.d.ts +6 -5
  5. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/oracle.js +26 -30
  7. package/dest/acvm/oracle/typed_oracle.d.ts +5 -5
  8. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  9. package/dest/acvm/oracle/typed_oracle.js +9 -9
  10. package/dest/avm/avm_execution_environment.d.ts +4 -3
  11. package/dest/avm/avm_execution_environment.d.ts.map +1 -1
  12. package/dest/avm/avm_execution_environment.js +17 -11
  13. package/dest/avm/avm_gas.d.ts.map +1 -1
  14. package/dest/avm/avm_gas.js +4 -1
  15. package/dest/avm/avm_machine_state.d.ts +5 -8
  16. package/dest/avm/avm_machine_state.d.ts.map +1 -1
  17. package/dest/avm/avm_machine_state.js +10 -22
  18. package/dest/avm/avm_memory_types.d.ts +1 -1
  19. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  20. package/dest/avm/avm_message_call_result.d.ts +5 -8
  21. package/dest/avm/avm_message_call_result.d.ts.map +1 -1
  22. package/dest/avm/avm_message_call_result.js +1 -4
  23. package/dest/avm/avm_simulator.d.ts.map +1 -1
  24. package/dest/avm/avm_simulator.js +19 -13
  25. package/dest/avm/errors.d.ts +43 -2
  26. package/dest/avm/errors.d.ts.map +1 -1
  27. package/dest/avm/errors.js +86 -4
  28. package/dest/avm/journal/journal.d.ts +20 -1
  29. package/dest/avm/journal/journal.d.ts.map +1 -1
  30. package/dest/avm/journal/journal.js +70 -9
  31. package/dest/avm/journal/nullifiers.d.ts +3 -1
  32. package/dest/avm/journal/nullifiers.d.ts.map +1 -1
  33. package/dest/avm/journal/nullifiers.js +14 -6
  34. package/dest/avm/journal/public_storage.d.ts +10 -1
  35. package/dest/avm/journal/public_storage.d.ts.map +1 -1
  36. package/dest/avm/journal/public_storage.js +17 -2
  37. package/dest/avm/journal/trace.d.ts +1 -4
  38. package/dest/avm/journal/trace.d.ts.map +1 -1
  39. package/dest/avm/journal/trace.js +4 -5
  40. package/dest/avm/journal/trace_types.d.ts +1 -0
  41. package/dest/avm/journal/trace_types.d.ts.map +1 -1
  42. package/dest/avm/journal/trace_types.js +1 -1
  43. package/dest/avm/opcodes/bitwise.d.ts +4 -1
  44. package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
  45. package/dest/avm/opcodes/bitwise.js +14 -2
  46. package/dest/avm/opcodes/conversion.d.ts +16 -0
  47. package/dest/avm/opcodes/conversion.d.ts.map +1 -0
  48. package/dest/avm/opcodes/conversion.js +48 -0
  49. package/dest/avm/opcodes/environment_getters.d.ts +16 -12
  50. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  51. package/dest/avm/opcodes/environment_getters.js +19 -48
  52. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  53. package/dest/avm/opcodes/external_calls.js +24 -13
  54. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  55. package/dest/avm/serialization/bytecode_serialization.js +6 -2
  56. package/dest/avm/serialization/instruction_serialization.d.ts +40 -38
  57. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  58. package/dest/avm/serialization/instruction_serialization.js +42 -39
  59. package/dest/client/client_execution_context.d.ts +59 -19
  60. package/dest/client/client_execution_context.d.ts.map +1 -1
  61. package/dest/client/client_execution_context.js +97 -45
  62. package/dest/client/db_oracle.d.ts +4 -11
  63. package/dest/client/db_oracle.d.ts.map +1 -1
  64. package/dest/client/execution_result.d.ts +22 -15
  65. package/dest/client/execution_result.d.ts.map +1 -1
  66. package/dest/client/execution_result.js +59 -13
  67. package/dest/client/logs_cache.d.ts +33 -0
  68. package/dest/client/logs_cache.d.ts.map +1 -0
  69. package/dest/client/logs_cache.js +59 -0
  70. package/dest/client/private_execution.d.ts +2 -2
  71. package/dest/client/private_execution.d.ts.map +1 -1
  72. package/dest/client/private_execution.js +5 -7
  73. package/dest/client/simulator.d.ts +4 -34
  74. package/dest/client/simulator.d.ts.map +1 -1
  75. package/dest/client/simulator.js +5 -43
  76. package/dest/client/unconstrained_execution.d.ts +2 -2
  77. package/dest/client/unconstrained_execution.d.ts.map +1 -1
  78. package/dest/client/unconstrained_execution.js +1 -1
  79. package/dest/client/view_data_oracle.d.ts +0 -7
  80. package/dest/client/view_data_oracle.d.ts.map +1 -1
  81. package/dest/client/view_data_oracle.js +1 -10
  82. package/dest/common/errors.d.ts +5 -0
  83. package/dest/common/errors.d.ts.map +1 -1
  84. package/dest/common/errors.js +6 -1
  85. package/dest/index.d.ts +1 -0
  86. package/dest/index.d.ts.map +1 -1
  87. package/dest/index.js +2 -1
  88. package/dest/mocks/fixtures.d.ts.map +1 -1
  89. package/dest/mocks/fixtures.js +3 -1
  90. package/dest/public/abstract_phase_manager.d.ts +10 -4
  91. package/dest/public/abstract_phase_manager.d.ts.map +1 -1
  92. package/dest/public/abstract_phase_manager.js +50 -19
  93. package/dest/public/app_logic_phase_manager.d.ts +1 -0
  94. package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
  95. package/dest/public/app_logic_phase_manager.js +3 -3
  96. package/dest/public/execution.d.ts +9 -0
  97. package/dest/public/execution.d.ts.map +1 -1
  98. package/dest/public/execution.js +1 -1
  99. package/dest/public/executor.d.ts +2 -2
  100. package/dest/public/executor.d.ts.map +1 -1
  101. package/dest/public/executor.js +34 -17
  102. package/dest/public/hints_builder.d.ts +3 -3
  103. package/dest/public/hints_builder.d.ts.map +1 -1
  104. package/dest/public/hints_builder.js +3 -3
  105. package/dest/public/public_execution_context.d.ts +10 -4
  106. package/dest/public/public_execution_context.d.ts.map +1 -1
  107. package/dest/public/public_execution_context.js +19 -6
  108. package/dest/public/public_processor.d.ts.map +1 -1
  109. package/dest/public/public_processor.js +5 -3
  110. package/dest/public/setup_phase_manager.d.ts +1 -0
  111. package/dest/public/setup_phase_manager.d.ts.map +1 -1
  112. package/dest/public/setup_phase_manager.js +3 -2
  113. package/dest/public/tail_phase_manager.d.ts +1 -1
  114. package/dest/public/tail_phase_manager.d.ts.map +1 -1
  115. package/dest/public/tail_phase_manager.js +4 -26
  116. package/dest/public/teardown_phase_manager.d.ts +1 -0
  117. package/dest/public/teardown_phase_manager.d.ts.map +1 -1
  118. package/dest/public/teardown_phase_manager.js +3 -2
  119. package/dest/public/transitional_adaptors.d.ts +4 -17
  120. package/dest/public/transitional_adaptors.d.ts.map +1 -1
  121. package/dest/public/transitional_adaptors.js +27 -119
  122. package/dest/rollup/index.d.ts +2 -0
  123. package/dest/rollup/index.d.ts.map +1 -0
  124. package/dest/rollup/index.js +2 -0
  125. package/dest/rollup/rollup.d.ts +77 -0
  126. package/dest/rollup/rollup.d.ts.map +1 -0
  127. package/dest/rollup/rollup.js +78 -0
  128. package/dest/stats/index.d.ts +2 -0
  129. package/dest/stats/index.d.ts.map +1 -0
  130. package/dest/stats/index.js +2 -0
  131. package/dest/stats/stats.d.ts +4 -0
  132. package/dest/stats/stats.d.ts.map +1 -0
  133. package/dest/stats/stats.js +11 -0
  134. package/package.json +8 -8
  135. package/src/acvm/acvm.ts +2 -2
  136. package/src/acvm/oracle/oracle.ts +62 -36
  137. package/src/acvm/oracle/typed_oracle.ts +19 -11
  138. package/src/avm/avm_execution_environment.ts +34 -42
  139. package/src/avm/avm_gas.ts +3 -0
  140. package/src/avm/avm_machine_state.ts +14 -25
  141. package/src/avm/avm_memory_types.ts +1 -1
  142. package/src/avm/avm_message_call_result.ts +3 -14
  143. package/src/avm/avm_simulator.ts +24 -12
  144. package/src/avm/errors.ts +94 -4
  145. package/src/avm/journal/journal.ts +134 -9
  146. package/src/avm/journal/nullifiers.ts +19 -8
  147. package/src/avm/journal/public_storage.ts +23 -2
  148. package/src/avm/journal/trace.ts +3 -4
  149. package/src/avm/journal/trace_types.ts +1 -0
  150. package/src/avm/opcodes/bitwise.ts +18 -7
  151. package/src/avm/opcodes/conversion.ts +59 -0
  152. package/src/avm/opcodes/environment_getters.ts +21 -65
  153. package/src/avm/opcodes/external_calls.ts +32 -16
  154. package/src/avm/serialization/bytecode_serialization.ts +5 -0
  155. package/src/avm/serialization/instruction_serialization.ts +3 -0
  156. package/src/client/client_execution_context.ts +142 -46
  157. package/src/client/db_oracle.ts +4 -18
  158. package/src/client/execution_result.ts +75 -25
  159. package/src/client/logs_cache.ts +65 -0
  160. package/src/client/private_execution.ts +6 -10
  161. package/src/client/simulator.ts +8 -84
  162. package/src/client/unconstrained_execution.ts +2 -2
  163. package/src/client/view_data_oracle.ts +0 -10
  164. package/src/common/errors.ts +5 -0
  165. package/src/index.ts +1 -0
  166. package/src/mocks/fixtures.ts +2 -0
  167. package/src/public/abstract_phase_manager.ts +59 -23
  168. package/src/public/app_logic_phase_manager.ts +2 -1
  169. package/src/public/execution.ts +9 -0
  170. package/src/public/executor.ts +47 -14
  171. package/src/public/hints_builder.ts +5 -5
  172. package/src/public/public_execution_context.ts +18 -4
  173. package/src/public/public_processor.ts +8 -2
  174. package/src/public/setup_phase_manager.ts +16 -8
  175. package/src/public/tail_phase_manager.ts +8 -35
  176. package/src/public/teardown_phase_manager.ts +16 -8
  177. package/src/public/transitional_adaptors.ts +39 -177
  178. package/src/rollup/index.ts +1 -0
  179. package/src/rollup/rollup.ts +160 -0
  180. package/src/stats/index.ts +1 -0
  181. package/src/stats/stats.ts +20 -0
@@ -1,9 +1,11 @@
1
- import { type EncryptedFunctionL2Logs, type Note, type UnencryptedFunctionL2Logs } from '@aztec/circuit-types';
2
1
  import {
3
- type NoteHashReadRequestMembershipWitness,
4
- type PrivateCallStackItem,
5
- type PublicCallRequest,
6
- } from '@aztec/circuits.js';
2
+ EncryptedFunctionL2Logs,
3
+ type EncryptedL2Log,
4
+ type Note,
5
+ UnencryptedFunctionL2Logs,
6
+ type UnencryptedL2Log,
7
+ } from '@aztec/circuit-types';
8
+ import { type IsEmpty, type PrivateCallStackItem, PublicCallRequest, sortByCounter } from '@aztec/circuits.js';
7
9
  import { type Fr } from '@aztec/foundation/fields';
8
10
 
9
11
  import { type ACVMField } from '../acvm/index.js';
@@ -20,9 +22,12 @@ export interface NoteAndSlot {
20
22
  noteTypeId: Fr;
21
23
  }
22
24
 
23
- export interface NullifiedNoteHashCounter {
24
- noteHashCounter: number;
25
- nullifierCounter: number;
25
+ export class CountedLog<TLog extends UnencryptedL2Log | EncryptedL2Log> implements IsEmpty {
26
+ constructor(public log: TLog, public counter: number) {}
27
+
28
+ isEmpty(): boolean {
29
+ return !this.log.data.length && !this.counter;
30
+ }
26
31
  }
27
32
 
28
33
  /**
@@ -39,34 +44,42 @@ export interface ExecutionResult {
39
44
  // Needed for the verifier (kernel)
40
45
  /** The call stack item. */
41
46
  callStackItem: PrivateCallStackItem;
42
- /** The partially filled-in read request membership witnesses for commitments being read. */
43
- noteHashReadRequestPartialWitnesses: NoteHashReadRequestMembershipWitness[];
47
+ /** Mapping of note hash to its index in the note hash tree. Used for building hints for note hash read requests. */
48
+ noteHashLeafIndexMap: Map<bigint, bigint>;
44
49
  /** The notes created in the executed function. */
45
50
  newNotes: NoteAndSlot[];
46
- nullifiedNoteHashCounters: NullifiedNoteHashCounter[];
51
+ /** Mapping of note hash counter to the counter of its nullifier. */
52
+ nullifiedNoteHashCounters: Map<number, number>;
47
53
  /** The raw return values of the executed function. */
48
54
  returnValues: Fr[];
49
55
  /** The nested executions. */
50
56
  nestedExecutions: this[];
51
57
  /** Enqueued public function execution requests to be picked up by the sequencer. */
52
58
  enqueuedPublicFunctionCalls: PublicCallRequest[];
59
+ /** Public function execution requested for teardown */
60
+ publicTeardownFunctionCall: PublicCallRequest;
53
61
  /**
54
62
  * Encrypted logs emitted during execution of this function call.
55
63
  * Note: These are preimages to `encryptedLogsHashes`.
56
64
  */
57
- encryptedLogs: EncryptedFunctionL2Logs;
65
+ encryptedLogs: CountedLog<EncryptedL2Log>[];
58
66
  /**
59
67
  * Unencrypted logs emitted during execution of this function call.
60
68
  * Note: These are preimages to `unencryptedLogsHashes`.
61
69
  */
62
- unencryptedLogs: UnencryptedFunctionL2Logs;
70
+ unencryptedLogs: CountedLog<UnencryptedL2Log>[];
63
71
  }
64
72
 
65
- export function collectNullifiedNoteHashCounters(execResult: ExecutionResult): NullifiedNoteHashCounter[] {
66
- return [
67
- execResult.nullifiedNoteHashCounters,
68
- ...execResult.nestedExecutions.flatMap(collectNullifiedNoteHashCounters),
69
- ].flat();
73
+ export function collectNoteHashLeafIndexMap(execResult: ExecutionResult, accum: Map<bigint, bigint> = new Map()) {
74
+ execResult.noteHashLeafIndexMap.forEach((value, key) => accum.set(key, value));
75
+ execResult.nestedExecutions.forEach(nested => collectNoteHashLeafIndexMap(nested, accum));
76
+ return accum;
77
+ }
78
+
79
+ export function collectNullifiedNoteHashCounters(execResult: ExecutionResult, accum: Map<number, number> = new Map()) {
80
+ execResult.nullifiedNoteHashCounters.forEach((value, key) => accum.set(key, value));
81
+ execResult.nestedExecutions.forEach(nested => collectNullifiedNoteHashCounters(nested, accum));
82
+ return accum;
70
83
  }
71
84
 
72
85
  /**
@@ -74,9 +87,19 @@ export function collectNullifiedNoteHashCounters(execResult: ExecutionResult): N
74
87
  * @param execResult - The topmost execution result.
75
88
  * @returns All encrypted logs.
76
89
  */
77
- export function collectEncryptedLogs(execResult: ExecutionResult): EncryptedFunctionL2Logs[] {
78
- // without the .reverse(), the logs will be in a queue like fashion which is wrong as the kernel processes it like a stack.
79
- return [execResult.encryptedLogs, ...[...execResult.nestedExecutions].reverse().flatMap(collectEncryptedLogs)];
90
+ function collectEncryptedLogs(execResult: ExecutionResult): CountedLog<EncryptedL2Log>[] {
91
+ return [execResult.encryptedLogs, ...[...execResult.nestedExecutions].flatMap(collectEncryptedLogs)].flat();
92
+ }
93
+
94
+ /**
95
+ * Collect all encrypted logs across all nested executions and sorts by counter.
96
+ * @param execResult - The topmost execution result.
97
+ * @returns All encrypted logs.
98
+ */
99
+ export function collectSortedEncryptedLogs(execResult: ExecutionResult): EncryptedFunctionL2Logs {
100
+ const allLogs = collectEncryptedLogs(execResult);
101
+ const sortedLogs = sortByCounter(allLogs);
102
+ return new EncryptedFunctionL2Logs(sortedLogs.map(l => l.log));
80
103
  }
81
104
 
82
105
  /**
@@ -84,9 +107,19 @@ export function collectEncryptedLogs(execResult: ExecutionResult): EncryptedFunc
84
107
  * @param execResult - The topmost execution result.
85
108
  * @returns All unencrypted logs.
86
109
  */
87
- export function collectUnencryptedLogs(execResult: ExecutionResult): UnencryptedFunctionL2Logs[] {
88
- // without the .reverse(), the logs will be in a queue like fashion which is wrong as the kernel processes it like a stack.
89
- return [execResult.unencryptedLogs, ...[...execResult.nestedExecutions].reverse().flatMap(collectUnencryptedLogs)];
110
+ function collectUnencryptedLogs(execResult: ExecutionResult): CountedLog<UnencryptedL2Log>[] {
111
+ return [execResult.unencryptedLogs, ...[...execResult.nestedExecutions].flatMap(collectUnencryptedLogs)].flat();
112
+ }
113
+
114
+ /**
115
+ * Collect all unencrypted logs across all nested executions and sorts by counter.
116
+ * @param execResult - The topmost execution result.
117
+ * @returns All unencrypted logs.
118
+ */
119
+ export function collectSortedUnencryptedLogs(execResult: ExecutionResult): UnencryptedFunctionL2Logs {
120
+ const allLogs = collectUnencryptedLogs(execResult);
121
+ const sortedLogs = sortByCounter(allLogs);
122
+ return new UnencryptedFunctionL2Logs(sortedLogs.map(l => l.log));
90
123
  }
91
124
 
92
125
  /**
@@ -99,6 +132,23 @@ export function collectEnqueuedPublicFunctionCalls(execResult: ExecutionResult):
99
132
  // as the kernel processes it like a stack, popping items off and pushing them to output
100
133
  return [
101
134
  ...execResult.enqueuedPublicFunctionCalls,
102
- ...[...execResult.nestedExecutions].flatMap(collectEnqueuedPublicFunctionCalls),
135
+ ...execResult.nestedExecutions.flatMap(collectEnqueuedPublicFunctionCalls),
103
136
  ].sort((a, b) => b.callContext.sideEffectCounter - a.callContext.sideEffectCounter);
104
137
  }
138
+
139
+ export function collectPublicTeardownFunctionCall(execResult: ExecutionResult): PublicCallRequest {
140
+ const teardownCalls = [
141
+ execResult.publicTeardownFunctionCall,
142
+ ...execResult.nestedExecutions.flatMap(collectPublicTeardownFunctionCall),
143
+ ].filter(call => !call.isEmpty());
144
+
145
+ if (teardownCalls.length === 1) {
146
+ return teardownCalls[0];
147
+ }
148
+
149
+ if (teardownCalls.length > 1) {
150
+ throw new Error('Multiple public teardown calls detected');
151
+ }
152
+
153
+ return PublicCallRequest.empty();
154
+ }
@@ -0,0 +1,65 @@
1
+ import { type EncryptedL2Log, type UnencryptedL2Log } from '@aztec/circuit-types';
2
+
3
+ /**
4
+ * Log data that's accessible by all the function calls in an execution.
5
+ * This class exists to:
6
+ * 1. Keep track of logs emitted through nested calls in the correct order.
7
+ * 2. TODO(1641): Remove encrypted logs based on notes nullified in the same scope.
8
+ */
9
+ export class LogsCache {
10
+ /**
11
+ * Logs notes created in this transaction.
12
+ */
13
+ private encryptedLogs: EncryptedL2Log[] = [];
14
+ private unencryptedLogs: UnencryptedL2Log[] = [];
15
+
16
+ // TODO Separate encrypted logs linked to note hashes and arbitrary logs:
17
+
18
+ // Maps from note hash to encrypted log - useful for removing transient logs
19
+ // private encryptedLogsLinkedToNotes: Map<bigint, EncryptedL2Log> = new Map();
20
+
21
+ // /**
22
+ // * Remove the encrypted log for a nullified note.
23
+ // * This fn should only be called if the note's innerNoteHash != 0.
24
+ // * @param noteHashCounter - Side effect counter of the note.
25
+ // */
26
+ // public nullifyNote(noteHashCounter: Fr) {
27
+ // // Find and remove the matching new note if the emitted innerNoteHash is not empty.
28
+ // const log = this.encryptedLogsLinkedToNotes.get(noteHashCounter.toBigInt()) ?? false;
29
+ // // TODO: throw here? Will the log always be here?
30
+ // if (!log) {
31
+ // throw new Error('Attempt to remove a pending note log that does not exist.');
32
+ // }
33
+ // this.encryptedLogsLinkedToNotes.delete(noteHashCounter.toBigInt());
34
+ // }
35
+
36
+ /**
37
+ * Add a new encrypted log to cache.
38
+ * @param log - New log created during execution.
39
+ */
40
+ public addEncryptedLog(log: EncryptedL2Log) {
41
+ this.encryptedLogs.push(log);
42
+ }
43
+
44
+ /**
45
+ * Add a new unencrypted log to cache.
46
+ * @param log - New log created during execution.
47
+ */
48
+ public addUnencryptedLog(log: UnencryptedL2Log) {
49
+ this.unencryptedLogs.push(log);
50
+ }
51
+
52
+ /**
53
+ * Return the encrypted logs.
54
+ */
55
+ public getEncryptedLogs() {
56
+ return this.encryptedLogs;
57
+ }
58
+
59
+ /**
60
+ * Return the encrypted logs.
61
+ */
62
+ public getUnencryptedLogs() {
63
+ return this.unencryptedLogs;
64
+ }
65
+ }
@@ -1,7 +1,6 @@
1
1
  import { type FunctionData, PrivateCallStackItem, PrivateCircuitPublicInputs } from '@aztec/circuits.js';
2
- import { type FunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi';
2
+ import { type FunctionArtifact } from '@aztec/foundation/abi';
3
3
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
4
- import { Fr } from '@aztec/foundation/fields';
5
4
  import { createDebugLogger } from '@aztec/foundation/log';
6
5
 
7
6
  import { witnessMapToFields } from '../acvm/deserialize.js';
@@ -16,7 +15,7 @@ import { AcirSimulator } from './simulator.js';
16
15
  */
17
16
  export async function executePrivateFunction(
18
17
  context: ClientExecutionContext,
19
- artifact: FunctionArtifactWithDebugMetadata,
18
+ artifact: FunctionArtifact,
20
19
  contractAddress: AztecAddress,
21
20
  functionData: FunctionData,
22
21
  log = createDebugLogger('aztec:simulator:secret_execution'),
@@ -45,21 +44,17 @@ export async function executePrivateFunction(
45
44
 
46
45
  const encryptedLogs = context.getEncryptedLogs();
47
46
  const unencryptedLogs = context.getUnencryptedLogs();
48
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) --> set this in Noir
49
- publicInputs.encryptedLogPreimagesLength = new Fr(encryptedLogs.getSerializedLength());
50
- publicInputs.unencryptedLogPreimagesLength = new Fr(unencryptedLogs.getSerializedLength());
51
47
 
52
48
  const callStackItem = new PrivateCallStackItem(contractAddress, functionData, publicInputs);
53
49
 
54
50
  const rawReturnValues = await context.unpackReturns(publicInputs.returnsHash);
55
51
 
56
- const noteHashReadRequestPartialWitnesses = context.getNoteHashReadRequestPartialWitnesses(
57
- publicInputs.noteHashReadRequests,
58
- );
52
+ const noteHashLeafIndexMap = context.getNoteHashLeafIndexMap();
59
53
  const newNotes = context.getNewNotes();
60
54
  const nullifiedNoteHashCounters = context.getNullifiedNoteHashCounters();
61
55
  const nestedExecutions = context.getNestedExecutions();
62
56
  const enqueuedPublicFunctionCalls = context.getEnqueuedPublicFunctionCalls();
57
+ const publicTeardownFunctionCall = context.getPublicTeardownFunctionCall();
63
58
 
64
59
  log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
65
60
 
@@ -68,12 +63,13 @@ export async function executePrivateFunction(
68
63
  partialWitness,
69
64
  callStackItem,
70
65
  returnValues: rawReturnValues,
71
- noteHashReadRequestPartialWitnesses,
66
+ noteHashLeafIndexMap,
72
67
  newNotes,
73
68
  nullifiedNoteHashCounters,
74
69
  vk: Buffer.from(artifact.verificationKey!, 'hex'),
75
70
  nestedExecutions,
76
71
  enqueuedPublicFunctionCalls,
72
+ publicTeardownFunctionCall,
77
73
  encryptedLogs,
78
74
  unencryptedLogs,
79
75
  };
@@ -2,7 +2,7 @@ import { type AztecNode, type FunctionCall, type Note, type TxExecutionRequest }
2
2
  import { CallContext, FunctionData } from '@aztec/circuits.js';
3
3
  import {
4
4
  type ArrayType,
5
- type FunctionArtifactWithDebugMetadata,
5
+ type FunctionArtifact,
6
6
  FunctionSelector,
7
7
  FunctionType,
8
8
  encodeArguments,
@@ -19,6 +19,7 @@ import { ClientExecutionContext } from './client_execution_context.js';
19
19
  import { type DBOracle } from './db_oracle.js';
20
20
  import { ExecutionNoteCache } from './execution_note_cache.js';
21
21
  import { type ExecutionResult } from './execution_result.js';
22
+ import { LogsCache } from './logs_cache.js';
22
23
  import { executePrivateFunction } from './private_execution.js';
23
24
  import { executeUnconstrainedFunction } from './unconstrained_execution.js';
24
25
  import { ViewDataOracle } from './view_data_oracle.js';
@@ -64,7 +65,7 @@ export class AcirSimulator {
64
65
  */
65
66
  public async run(
66
67
  request: TxExecutionRequest,
67
- entryPointArtifact: FunctionArtifactWithDebugMetadata,
68
+ entryPointArtifact: FunctionArtifact,
68
69
  contractAddress: AztecAddress,
69
70
  msgSender = AztecAddress.ZERO,
70
71
  ): Promise<ExecutionResult> {
@@ -100,6 +101,7 @@ export class AcirSimulator {
100
101
  request.authWitnesses,
101
102
  PackedValuesCache.create(request.argsOfCalls),
102
103
  new ExecutionNoteCache(),
104
+ new LogsCache(),
103
105
  this.db,
104
106
  this.node,
105
107
  startSideEffectCounter,
@@ -127,7 +129,7 @@ export class AcirSimulator {
127
129
  */
128
130
  public async runUnconstrained(
129
131
  request: FunctionCall,
130
- entryPointArtifact: FunctionArtifactWithDebugMetadata,
132
+ entryPointArtifact: FunctionArtifact,
131
133
  contractAddress: AztecAddress,
132
134
  ) {
133
135
  if (entryPointArtifact.functionType !== FunctionType.UNCONSTRAINED) {
@@ -165,7 +167,7 @@ export class AcirSimulator {
165
167
  noteTypeId: Fr,
166
168
  note: Note,
167
169
  ) {
168
- const artifact: FunctionArtifactWithDebugMetadata | undefined = await this.db.getFunctionArtifactByName(
170
+ const artifact: FunctionArtifact | undefined = await this.db.getFunctionArtifactByName(
169
171
  contractAddress,
170
172
  'compute_note_hash_and_nullifier',
171
173
  );
@@ -198,7 +200,7 @@ export class AcirSimulator {
198
200
  args: encodeArguments(artifact, [contractAddress, nonce, storageSlot, noteTypeId, extendedNoteItems]),
199
201
  };
200
202
 
201
- const [innerNoteHash, siloedNoteHash, uniqueSiloedNoteHash, innerNullifier] = (await this.runUnconstrained(
203
+ const [innerNoteHash, uniqueNoteHash, siloedNoteHash, innerNullifier] = (await this.runUnconstrained(
202
204
  execRequest,
203
205
  artifact,
204
206
  contractAddress,
@@ -206,8 +208,8 @@ export class AcirSimulator {
206
208
 
207
209
  return {
208
210
  innerNoteHash: new Fr(innerNoteHash),
211
+ uniqueNoteHash: new Fr(uniqueNoteHash),
209
212
  siloedNoteHash: new Fr(siloedNoteHash),
210
- uniqueSiloedNoteHash: new Fr(uniqueSiloedNoteHash),
211
213
  innerNullifier: new Fr(innerNullifier),
212
214
  };
213
215
  }
@@ -230,82 +232,4 @@ export class AcirSimulator {
230
232
  );
231
233
  return innerNoteHash;
232
234
  }
233
-
234
- /**
235
- * Computes the unique note hash of a note.
236
- * @param contractAddress - The address of the contract.
237
- * @param nonce - The nonce of the note hash.
238
- * @param storageSlot - The storage slot.
239
- * @param noteTypeId - The note type identifier.
240
- * @param note - The note.
241
- * @returns The note hash.
242
- */
243
- public async computeUniqueSiloedNoteHash(
244
- contractAddress: AztecAddress,
245
- nonce: Fr,
246
- storageSlot: Fr,
247
- noteTypeId: Fr,
248
- note: Note,
249
- ) {
250
- const { uniqueSiloedNoteHash } = await this.computeNoteHashAndNullifier(
251
- contractAddress,
252
- nonce,
253
- storageSlot,
254
- noteTypeId,
255
- note,
256
- );
257
- return uniqueSiloedNoteHash;
258
- }
259
-
260
- /**
261
- * Computes the siloed note hash of a note.
262
- * @param contractAddress - The address of the contract.
263
- * @param nonce - The nonce of the note hash.
264
- * @param storageSlot - The storage slot.
265
- * @param noteTypeId - The note type identifier.
266
- * @param note - The note.
267
- * @returns The note hash.
268
- */
269
- public async computeSiloedNoteHash(
270
- contractAddress: AztecAddress,
271
- nonce: Fr,
272
- storageSlot: Fr,
273
- noteTypeId: Fr,
274
- note: Note,
275
- ) {
276
- const { siloedNoteHash } = await this.computeNoteHashAndNullifier(
277
- contractAddress,
278
- nonce,
279
- storageSlot,
280
- noteTypeId,
281
- note,
282
- );
283
- return siloedNoteHash;
284
- }
285
-
286
- /**
287
- * Computes the inner note hash of a note, which contains storage slot and the custom note hash.
288
- * @param contractAddress - The address of the contract.
289
- * @param nonce - The nonce of the unique note hash.
290
- * @param storageSlot - The storage slot.
291
- * @param noteTypeId - The note type identifier.
292
- * @param note - The note.
293
- * @returns The note hash.
294
- */
295
- public async computeInnerNullifier(
296
- contractAddress: AztecAddress,
297
- nonce: Fr,
298
- storageSlot: Fr,
299
- noteTypeId: Fr,
300
- note: Note,
301
- ) {
302
- const { innerNullifier } = await this.computeNoteHashAndNullifier(
303
- contractAddress,
304
- nonce,
305
- storageSlot,
306
- noteTypeId,
307
- note,
308
- );
309
- return innerNullifier;
310
- }
311
235
  }
@@ -1,5 +1,5 @@
1
1
  import { type FunctionData } from '@aztec/circuits.js';
2
- import { type DecodedReturn, type FunctionArtifactWithDebugMetadata, decodeReturnValues } from '@aztec/foundation/abi';
2
+ import { type DecodedReturn, type FunctionArtifact, decodeReturnValues } from '@aztec/foundation/abi';
3
3
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
4
4
  import { type Fr } from '@aztec/foundation/fields';
5
5
  import { createDebugLogger } from '@aztec/foundation/log';
@@ -16,7 +16,7 @@ import { type ViewDataOracle } from './view_data_oracle.js';
16
16
  */
17
17
  export async function executeUnconstrainedFunction(
18
18
  oracle: ViewDataOracle,
19
- artifact: FunctionArtifactWithDebugMetadata,
19
+ artifact: FunctionArtifact,
20
20
  contractAddress: AztecAddress,
21
21
  functionData: FunctionData,
22
22
  args: Fr[],
@@ -166,16 +166,6 @@ export class ViewDataOracle extends TypedOracle {
166
166
  return this.db.popCapsule();
167
167
  }
168
168
 
169
- /**
170
- * Gets public keys for an address.
171
- * @param The address to look up
172
- * @returns The public keys for a specific address
173
- * TODO(#5834): Replace with `getCompleteAddress`.
174
- */
175
- public override getPublicKeysForAddress(address: AztecAddress) {
176
- return this.db.getPublicKeysForAddress(address);
177
- }
178
-
179
169
  /**
180
170
  * Gets some notes for a contract address and storage slot.
181
171
  * Returns a flattened array containing filtered notes.
@@ -2,6 +2,11 @@ import { type FailingFunction, type NoirCallStack, SimulationError } from '@azte
2
2
 
3
3
  /**
4
4
  * An error that occurred during the execution of a function.
5
+ * @param message - the error message
6
+ * @param failingFunction - the Aztec function that failed
7
+ * @param noirCallStack - the internal call stack of the function that failed (within the failing Aztec function)
8
+ * @param options - additional error options (an optional "cause" entry allows for a recursive error stack where
9
+ * an error's cause may be an ExecutionError itself)
5
10
  */
6
11
  export class ExecutionError extends Error {
7
12
  constructor(
package/src/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from './common/index.js';
4
4
  export * from './public/index.js';
5
5
  export * from './simulator/index.js';
6
6
  export * from './mocks/index.js';
7
+ export * from './stats/index.js';
@@ -116,6 +116,8 @@ export class PublicExecutionResultBuilder {
116
116
  contractStorageReads: [],
117
117
  unencryptedLogsHashes: [],
118
118
  unencryptedLogs: UnencryptedFunctionL2Logs.empty(),
119
+ unencryptedLogPreimagesLength: new Fr(4n), // empty logs have len 4
120
+ allUnencryptedLogs: UnencryptedFunctionL2Logs.empty(),
119
121
  startSideEffectCounter: Fr.ZERO,
120
122
  endSideEffectCounter: Fr.ZERO,
121
123
  reverted: this._reverted,