@aztec/simulator 0.62.0 → 0.63.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 (216) hide show
  1. package/dest/acvm/acvm.d.ts +2 -16
  2. package/dest/acvm/acvm.d.ts.map +1 -1
  3. package/dest/acvm/acvm.js +2 -70
  4. package/dest/acvm/oracle/oracle.d.ts +4 -4
  5. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/oracle.js +10 -11
  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 +8 -8
  10. package/dest/avm/avm_gas.d.ts.map +1 -1
  11. package/dest/avm/avm_gas.js +2 -1
  12. package/dest/avm/avm_machine_state.d.ts +27 -8
  13. package/dest/avm/avm_machine_state.d.ts.map +1 -1
  14. package/dest/avm/avm_machine_state.js +6 -10
  15. package/dest/avm/avm_memory_types.d.ts +8 -0
  16. package/dest/avm/avm_memory_types.d.ts.map +1 -1
  17. package/dest/avm/avm_memory_types.js +5 -1
  18. package/dest/avm/avm_simulator.d.ts +2 -19
  19. package/dest/avm/avm_simulator.d.ts.map +1 -1
  20. package/dest/avm/avm_simulator.js +12 -14
  21. package/dest/avm/avm_tree.d.ts +249 -0
  22. package/dest/avm/avm_tree.d.ts.map +1 -0
  23. package/dest/avm/avm_tree.js +637 -0
  24. package/dest/avm/errors.d.ts +4 -17
  25. package/dest/avm/errors.d.ts.map +1 -1
  26. package/dest/avm/errors.js +21 -50
  27. package/dest/avm/fixtures/index.d.ts +7 -2
  28. package/dest/avm/fixtures/index.d.ts.map +1 -1
  29. package/dest/avm/fixtures/index.js +12 -12
  30. package/dest/avm/index.d.ts +1 -0
  31. package/dest/avm/index.d.ts.map +1 -1
  32. package/dest/avm/index.js +2 -1
  33. package/dest/avm/journal/journal.d.ts +43 -24
  34. package/dest/avm/journal/journal.d.ts.map +1 -1
  35. package/dest/avm/journal/journal.js +172 -39
  36. package/dest/avm/journal/nullifiers.d.ts +5 -4
  37. package/dest/avm/journal/nullifiers.d.ts.map +1 -1
  38. package/dest/avm/journal/nullifiers.js +2 -3
  39. package/dest/avm/journal/public_storage.d.ts +6 -5
  40. package/dest/avm/journal/public_storage.d.ts.map +1 -1
  41. package/dest/avm/journal/public_storage.js +1 -1
  42. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  43. package/dest/avm/opcodes/accrued_substate.js +4 -10
  44. package/dest/avm/opcodes/arithmetic.d.ts +4 -1
  45. package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
  46. package/dest/avm/opcodes/arithmetic.js +18 -4
  47. package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
  48. package/dest/avm/opcodes/bitwise.js +1 -3
  49. package/dest/avm/opcodes/comparators.d.ts.map +1 -1
  50. package/dest/avm/opcodes/comparators.js +1 -2
  51. package/dest/avm/opcodes/contract.d.ts.map +1 -1
  52. package/dest/avm/opcodes/contract.js +2 -3
  53. package/dest/avm/opcodes/control_flow.d.ts +4 -0
  54. package/dest/avm/opcodes/control_flow.d.ts.map +1 -1
  55. package/dest/avm/opcodes/control_flow.js +21 -6
  56. package/dest/avm/opcodes/conversion.d.ts.map +1 -1
  57. package/dest/avm/opcodes/conversion.js +1 -2
  58. package/dest/avm/opcodes/ec_add.d.ts.map +1 -1
  59. package/dest/avm/opcodes/ec_add.js +5 -11
  60. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  61. package/dest/avm/opcodes/environment_getters.js +1 -2
  62. package/dest/avm/opcodes/external_calls.d.ts +4 -2
  63. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  64. package/dest/avm/opcodes/external_calls.js +38 -22
  65. package/dest/avm/opcodes/hashing.d.ts.map +1 -1
  66. package/dest/avm/opcodes/hashing.js +1 -4
  67. package/dest/avm/opcodes/instruction.d.ts +4 -0
  68. package/dest/avm/opcodes/instruction.d.ts.map +1 -1
  69. package/dest/avm/opcodes/instruction.js +7 -1
  70. package/dest/avm/opcodes/memory.d.ts.map +1 -1
  71. package/dest/avm/opcodes/memory.js +1 -7
  72. package/dest/avm/opcodes/misc.js +3 -3
  73. package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +1 -1
  74. package/dest/avm/opcodes/multi_scalar_mul.js +6 -5
  75. package/dest/avm/opcodes/storage.d.ts.map +1 -1
  76. package/dest/avm/opcodes/storage.js +2 -4
  77. package/dest/avm/serialization/bytecode_serialization.d.ts +1 -6
  78. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  79. package/dest/avm/serialization/bytecode_serialization.js +24 -20
  80. package/dest/client/client_execution_context.d.ts +7 -11
  81. package/dest/client/client_execution_context.d.ts.map +1 -1
  82. package/dest/client/client_execution_context.js +18 -20
  83. package/dest/client/db_oracle.d.ts +17 -10
  84. package/dest/client/db_oracle.d.ts.map +1 -1
  85. package/dest/client/db_oracle.js +1 -1
  86. package/dest/client/private_execution.d.ts.map +1 -1
  87. package/dest/client/private_execution.js +5 -4
  88. package/dest/client/unconstrained_execution.d.ts.map +1 -1
  89. package/dest/client/unconstrained_execution.js +3 -2
  90. package/dest/client/view_data_oracle.d.ts +6 -12
  91. package/dest/client/view_data_oracle.d.ts.map +1 -1
  92. package/dest/client/view_data_oracle.js +10 -12
  93. package/dest/common/errors.d.ts +15 -2
  94. package/dest/common/errors.d.ts.map +1 -1
  95. package/dest/common/errors.js +85 -4
  96. package/dest/mocks/fixtures.d.ts +9 -28
  97. package/dest/mocks/fixtures.d.ts.map +1 -1
  98. package/dest/mocks/fixtures.js +12 -57
  99. package/dest/public/dual_side_effect_trace.d.ts +34 -26
  100. package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
  101. package/dest/public/dual_side_effect_trace.js +48 -36
  102. package/dest/public/enqueued_call_side_effect_trace.d.ts +96 -33
  103. package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
  104. package/dest/public/enqueued_call_side_effect_trace.js +212 -138
  105. package/dest/public/execution.d.ts +50 -17
  106. package/dest/public/execution.d.ts.map +1 -1
  107. package/dest/public/execution.js +1 -29
  108. package/dest/public/executor.d.ts +28 -11
  109. package/dest/public/executor.d.ts.map +1 -1
  110. package/dest/public/executor.js +33 -33
  111. package/dest/public/index.d.ts +4 -5
  112. package/dest/public/index.d.ts.map +1 -1
  113. package/dest/public/index.js +4 -5
  114. package/dest/public/public_db_sources.d.ts +1 -0
  115. package/dest/public/public_db_sources.d.ts.map +1 -1
  116. package/dest/public/public_db_sources.js +12 -5
  117. package/dest/public/public_processor.d.ts +7 -11
  118. package/dest/public/public_processor.d.ts.map +1 -1
  119. package/dest/public/public_processor.js +60 -42
  120. package/dest/public/public_processor_metrics.d.ts +3 -3
  121. package/dest/public/public_processor_metrics.d.ts.map +1 -1
  122. package/dest/public/public_processor_metrics.js +1 -1
  123. package/dest/public/public_tx_context.d.ts +130 -0
  124. package/dest/public/public_tx_context.d.ts.map +1 -0
  125. package/dest/public/public_tx_context.js +293 -0
  126. package/dest/public/public_tx_simulator.d.ts +36 -0
  127. package/dest/public/public_tx_simulator.d.ts.map +1 -0
  128. package/dest/public/public_tx_simulator.js +148 -0
  129. package/dest/public/side_effect_trace.d.ts +30 -15
  130. package/dest/public/side_effect_trace.d.ts.map +1 -1
  131. package/dest/public/side_effect_trace.js +70 -16
  132. package/dest/public/side_effect_trace_interface.d.ts +43 -12
  133. package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
  134. package/dest/public/transitional_adapters.d.ts +9 -0
  135. package/dest/public/transitional_adapters.d.ts.map +1 -0
  136. package/dest/public/transitional_adapters.js +127 -0
  137. package/dest/public/utils.d.ts +5 -0
  138. package/dest/public/utils.d.ts.map +1 -0
  139. package/dest/public/utils.js +30 -0
  140. package/package.json +12 -9
  141. package/src/acvm/acvm.ts +3 -94
  142. package/src/acvm/oracle/oracle.ts +9 -14
  143. package/src/acvm/oracle/typed_oracle.ts +8 -8
  144. package/src/avm/avm_gas.ts +1 -0
  145. package/src/avm/avm_machine_state.ts +28 -12
  146. package/src/avm/avm_memory_types.ts +5 -0
  147. package/src/avm/avm_simulator.ts +13 -16
  148. package/src/avm/avm_tree.ts +785 -0
  149. package/src/avm/errors.ts +25 -48
  150. package/src/avm/fixtures/index.ts +16 -12
  151. package/src/avm/index.ts +1 -0
  152. package/src/avm/journal/journal.ts +291 -52
  153. package/src/avm/journal/nullifiers.ts +7 -7
  154. package/src/avm/journal/public_storage.ts +5 -5
  155. package/src/avm/opcodes/accrued_substate.ts +3 -9
  156. package/src/avm/opcodes/arithmetic.ts +26 -4
  157. package/src/avm/opcodes/bitwise.ts +0 -2
  158. package/src/avm/opcodes/comparators.ts +0 -1
  159. package/src/avm/opcodes/contract.ts +1 -2
  160. package/src/avm/opcodes/control_flow.ts +24 -5
  161. package/src/avm/opcodes/conversion.ts +0 -1
  162. package/src/avm/opcodes/ec_add.ts +6 -9
  163. package/src/avm/opcodes/environment_getters.ts +0 -1
  164. package/src/avm/opcodes/external_calls.ts +39 -21
  165. package/src/avm/opcodes/hashing.ts +0 -3
  166. package/src/avm/opcodes/instruction.ts +7 -0
  167. package/src/avm/opcodes/memory.ts +0 -6
  168. package/src/avm/opcodes/misc.ts +2 -2
  169. package/src/avm/opcodes/multi_scalar_mul.ts +5 -4
  170. package/src/avm/opcodes/storage.ts +1 -3
  171. package/src/avm/serialization/bytecode_serialization.ts +31 -22
  172. package/src/client/client_execution_context.ts +22 -23
  173. package/src/client/db_oracle.ts +22 -11
  174. package/src/client/private_execution.ts +5 -4
  175. package/src/client/unconstrained_execution.ts +2 -1
  176. package/src/client/view_data_oracle.ts +14 -13
  177. package/src/common/errors.ts +119 -3
  178. package/src/mocks/fixtures.ts +15 -106
  179. package/src/public/dual_side_effect_trace.ts +138 -50
  180. package/src/public/enqueued_call_side_effect_trace.ts +352 -212
  181. package/src/public/execution.ts +58 -42
  182. package/src/public/executor.ts +52 -67
  183. package/src/public/index.ts +7 -5
  184. package/src/public/public_db_sources.ts +12 -4
  185. package/src/public/public_processor.ts +111 -73
  186. package/src/public/public_processor_metrics.ts +3 -3
  187. package/src/public/public_tx_context.ts +411 -0
  188. package/src/public/public_tx_simulator.ts +232 -0
  189. package/src/public/side_effect_trace.ts +154 -28
  190. package/src/public/side_effect_trace_interface.ts +92 -14
  191. package/src/public/transitional_adapters.ts +347 -0
  192. package/src/public/utils.ts +32 -0
  193. package/dest/public/enqueued_call_simulator.d.ts +0 -43
  194. package/dest/public/enqueued_call_simulator.d.ts.map +0 -1
  195. package/dest/public/enqueued_call_simulator.js +0 -156
  196. package/dest/public/enqueued_calls_processor.d.ts +0 -43
  197. package/dest/public/enqueued_calls_processor.d.ts.map +0 -1
  198. package/dest/public/enqueued_calls_processor.js +0 -209
  199. package/dest/public/hints_builder.d.ts +0 -29
  200. package/dest/public/hints_builder.d.ts.map +0 -1
  201. package/dest/public/hints_builder.js +0 -75
  202. package/dest/public/public_kernel.d.ts +0 -30
  203. package/dest/public/public_kernel.d.ts.map +0 -1
  204. package/dest/public/public_kernel.js +0 -67
  205. package/dest/public/public_kernel_circuit_simulator.d.ts +0 -25
  206. package/dest/public/public_kernel_circuit_simulator.d.ts.map +0 -1
  207. package/dest/public/public_kernel_circuit_simulator.js +0 -2
  208. package/dest/public/public_kernel_tail_simulator.d.ts +0 -15
  209. package/dest/public/public_kernel_tail_simulator.d.ts.map +0 -1
  210. package/dest/public/public_kernel_tail_simulator.js +0 -39
  211. package/src/public/enqueued_call_simulator.ts +0 -360
  212. package/src/public/enqueued_calls_processor.ts +0 -372
  213. package/src/public/hints_builder.ts +0 -168
  214. package/src/public/public_kernel.ts +0 -100
  215. package/src/public/public_kernel_circuit_simulator.ts +0 -32
  216. package/src/public/public_kernel_tail_simulator.ts +0 -97
@@ -1,47 +1,47 @@
1
1
  import {
2
2
  type FailedTx,
3
+ MerkleTreeId,
3
4
  type MerkleTreeWriteOperations,
4
5
  NestedProcessReturnValues,
5
6
  type ProcessedTx,
6
7
  type ProcessedTxHandler,
7
8
  Tx,
9
+ TxExecutionPhase,
8
10
  type TxValidator,
9
- makeProcessedTx,
10
- validateProcessedTx,
11
+ makeProcessedTxFromPrivateOnlyTx,
12
+ makeProcessedTxFromTxWithPublicCalls,
11
13
  } from '@aztec/circuit-types';
12
14
  import {
15
+ type AztecAddress,
13
16
  ContractClassRegisteredEvent,
14
17
  type ContractDataSource,
18
+ Fr,
15
19
  type GlobalVariables,
16
20
  type Header,
17
- MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
18
- PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
19
- PublicDataUpdateRequest,
21
+ MAX_NOTE_HASHES_PER_TX,
22
+ MAX_NULLIFIERS_PER_TX,
23
+ MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
24
+ NULLIFIER_SUBTREE_HEIGHT,
25
+ PUBLIC_DATA_SUBTREE_HEIGHT,
26
+ PublicDataWrite,
20
27
  } from '@aztec/circuits.js';
21
- import { times } from '@aztec/foundation/collection';
28
+ import { padArrayEnd } from '@aztec/foundation/collection';
22
29
  import { createDebugLogger } from '@aztec/foundation/log';
23
30
  import { Timer } from '@aztec/foundation/timer';
24
31
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
25
32
  import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
26
33
 
27
- import { type SimulationProvider } from '../providers/index.js';
28
- import { EnqueuedCallsProcessor } from './enqueued_calls_processor.js';
29
34
  import { PublicExecutor } from './executor.js';
30
35
  import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from './fee_payment.js';
31
36
  import { WorldStateDB } from './public_db_sources.js';
32
- import { RealPublicKernelCircuitSimulator } from './public_kernel.js';
33
- import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
34
37
  import { PublicProcessorMetrics } from './public_processor_metrics.js';
38
+ import { PublicTxSimulator } from './public_tx_simulator.js';
35
39
 
36
40
  /**
37
41
  * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
38
42
  */
39
43
  export class PublicProcessorFactory {
40
- constructor(
41
- private contractDataSource: ContractDataSource,
42
- private simulator: SimulationProvider,
43
- private telemetryClient: TelemetryClient,
44
- ) {}
44
+ constructor(private contractDataSource: ContractDataSource, private telemetryClient: TelemetryClient) {}
45
45
 
46
46
  /**
47
47
  * Creates a new instance of a PublicProcessor.
@@ -59,12 +59,10 @@ export class PublicProcessorFactory {
59
59
 
60
60
  const worldStateDB = new WorldStateDB(merkleTree, this.contractDataSource);
61
61
  const publicExecutor = new PublicExecutor(worldStateDB, telemetryClient);
62
- const publicKernelSimulator = new RealPublicKernelCircuitSimulator(this.simulator);
63
62
 
64
63
  return PublicProcessor.create(
65
64
  merkleTree,
66
65
  publicExecutor,
67
- publicKernelSimulator,
68
66
  globalVariables,
69
67
  historicalHeader,
70
68
  worldStateDB,
@@ -81,12 +79,10 @@ export class PublicProcessor {
81
79
  private metrics: PublicProcessorMetrics;
82
80
  constructor(
83
81
  protected db: MerkleTreeWriteOperations,
84
- protected publicExecutor: PublicExecutor,
85
- protected publicKernel: PublicKernelCircuitSimulator,
86
82
  protected globalVariables: GlobalVariables,
87
83
  protected historicalHeader: Header,
88
84
  protected worldStateDB: WorldStateDB,
89
- protected enqueuedCallsProcessor: EnqueuedCallsProcessor,
85
+ protected publicTxSimulator: PublicTxSimulator,
90
86
  telemetryClient: TelemetryClient,
91
87
  private log = createDebugLogger('aztec:sequencer:public-processor'),
92
88
  ) {
@@ -96,31 +92,14 @@ export class PublicProcessor {
96
92
  static create(
97
93
  db: MerkleTreeWriteOperations,
98
94
  publicExecutor: PublicExecutor,
99
- publicKernelSimulator: PublicKernelCircuitSimulator,
100
95
  globalVariables: GlobalVariables,
101
96
  historicalHeader: Header,
102
97
  worldStateDB: WorldStateDB,
103
98
  telemetryClient: TelemetryClient,
104
99
  ) {
105
- const enqueuedCallsProcessor = EnqueuedCallsProcessor.create(
106
- db,
107
- publicExecutor,
108
- publicKernelSimulator,
109
- globalVariables,
110
- historicalHeader,
111
- worldStateDB,
112
- );
100
+ const publicTxSimulator = PublicTxSimulator.create(db, publicExecutor, globalVariables, worldStateDB);
113
101
 
114
- return new PublicProcessor(
115
- db,
116
- publicExecutor,
117
- publicKernelSimulator,
118
- globalVariables,
119
- historicalHeader,
120
- worldStateDB,
121
- enqueuedCallsProcessor,
122
- telemetryClient,
123
- );
102
+ return new PublicProcessor(db, globalVariables, historicalHeader, worldStateDB, publicTxSimulator, telemetryClient);
124
103
  }
125
104
 
126
105
  get tracer(): Tracer {
@@ -152,21 +131,17 @@ export class PublicProcessor {
152
131
  }
153
132
  try {
154
133
  const [processedTx, returnValues] = !tx.hasPublicCalls()
155
- ? [makeProcessedTx(tx, tx.data.toKernelCircuitPublicInputs())]
134
+ ? await this.processPrivateOnlyTx(tx)
156
135
  : await this.processTxWithPublicCalls(tx);
157
136
  this.log.debug(`Processed tx`, {
158
137
  txHash: processedTx.hash,
159
- historicalHeaderHash: processedTx.data.constants.historicalHeader.hash(),
160
- blockNumber: processedTx.data.constants.globalVariables.blockNumber,
161
- lastArchiveRoot: processedTx.data.constants.historicalHeader.lastArchive.root,
138
+ historicalHeaderHash: processedTx.constants.historicalHeader.hash(),
139
+ blockNumber: processedTx.constants.globalVariables.blockNumber,
140
+ lastArchiveRoot: processedTx.constants.historicalHeader.lastArchive.root,
162
141
  });
163
142
 
164
- // Set fee payment update request into the processed tx
165
- processedTx.finalPublicDataUpdateRequests = await this.createFinalDataUpdateRequests(processedTx);
166
-
167
143
  // Commit the state updates from this transaction
168
144
  await this.worldStateDB.commit();
169
- validateProcessedTx(processedTx);
170
145
 
171
146
  // Re-validate the transaction
172
147
  if (txValidator) {
@@ -183,6 +158,42 @@ export class PublicProcessor {
183
158
  if (processedTxHandler) {
184
159
  await processedTxHandler.addNewTx(processedTx);
185
160
  }
161
+ // Update the state so that the next tx in the loop has the correct .startState
162
+ // NB: before this change, all .startStates were actually incorrect, but the issue was never caught because we either:
163
+ // a) had only 1 tx with public calls per block, so this loop had len 1
164
+ // b) always had a txHandler with the same db passed to it as this.db, which updated the db in buildBaseRollupHints in this loop
165
+ // To see how this ^ happens, move back to one shared db in test_context and run orchestrator_multi_public_functions.test.ts
166
+ // The below is taken from buildBaseRollupHints:
167
+ await this.db.appendLeaves(
168
+ MerkleTreeId.NOTE_HASH_TREE,
169
+ padArrayEnd(processedTx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
170
+ );
171
+ try {
172
+ await this.db.batchInsert(
173
+ MerkleTreeId.NULLIFIER_TREE,
174
+ padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(n => n.toBuffer()),
175
+ NULLIFIER_SUBTREE_HEIGHT,
176
+ );
177
+ } catch (error) {
178
+ if (txValidator) {
179
+ // Ideally the validator has already caught this above, but just in case:
180
+ throw new Error(`Transaction ${processedTx.hash} invalid after processing public functions`);
181
+ } else {
182
+ // We have no validator and assume this call should blindly process txs with duplicates being caught later
183
+ this.log.warn(`Detected duplicate nullifier after public processing for: ${processedTx.hash}.`);
184
+ }
185
+ }
186
+
187
+ const allPublicDataWrites = padArrayEnd(
188
+ processedTx.txEffect.publicDataWrites,
189
+ PublicDataWrite.empty(),
190
+ MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
191
+ );
192
+ await this.db.batchInsert(
193
+ MerkleTreeId.PUBLIC_DATA_TREE,
194
+ allPublicDataWrites.map(x => x.toBuffer()),
195
+ PUBLIC_DATA_SUBTREE_HEIGHT,
196
+ );
186
197
  result.push(processedTx);
187
198
  returns = returns.concat(returnValues ?? []);
188
199
  } catch (err: any) {
@@ -206,32 +217,26 @@ export class PublicProcessor {
206
217
  * request for updating fee balance. It also updates the local public state db.
207
218
  * See build_or_patch_payment_update_request in base_rollup_inputs.nr for more details.
208
219
  */
209
- private async createFinalDataUpdateRequests(tx: ProcessedTx) {
210
- const finalPublicDataUpdateRequests = [
211
- ...tx.data.end.publicDataUpdateRequests,
212
- ...times(PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, () => PublicDataUpdateRequest.empty()),
213
- ];
214
-
215
- const feePayer = tx.data.feePayer;
220
+ private async getFeePaymentPublicDataWrite(
221
+ publicDataWrites: PublicDataWrite[],
222
+ txFee: Fr,
223
+ feePayer: AztecAddress,
224
+ ): Promise<PublicDataWrite | undefined> {
216
225
  if (feePayer.isZero()) {
217
- return finalPublicDataUpdateRequests;
226
+ return;
218
227
  }
219
228
 
220
229
  const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
221
230
  const balanceSlot = computeFeePayerBalanceStorageSlot(feePayer);
222
231
  const leafSlot = computeFeePayerBalanceLeafSlot(feePayer);
223
- const txFee = tx.data.getTransactionFee(this.globalVariables.gasFees);
224
232
 
225
233
  this.log.debug(`Deducting ${txFee} balance in Fee Juice for ${feePayer}`);
226
234
 
227
- const existingBalanceWriteIndex = finalPublicDataUpdateRequests.findIndex(request =>
228
- request.leafSlot.equals(leafSlot),
229
- );
235
+ const existingBalanceWrite = publicDataWrites.find(write => write.leafSlot.equals(leafSlot));
230
236
 
231
- const balance =
232
- existingBalanceWriteIndex > -1
233
- ? finalPublicDataUpdateRequests[existingBalanceWriteIndex].newValue
234
- : await this.worldStateDB.storageRead(feeJuiceAddress, balanceSlot);
237
+ const balance = existingBalanceWrite
238
+ ? existingBalanceWrite.value
239
+ : await this.worldStateDB.storageRead(feeJuiceAddress, balanceSlot);
235
240
 
236
241
  if (balance.lt(txFee)) {
237
242
  throw new Error(`Not enough balance for fee payer to pay for transaction (got ${balance} needs ${txFee})`);
@@ -240,11 +245,27 @@ export class PublicProcessor {
240
245
  const updatedBalance = balance.sub(txFee);
241
246
  await this.worldStateDB.storageWrite(feeJuiceAddress, balanceSlot, updatedBalance);
242
247
 
243
- finalPublicDataUpdateRequests[
244
- existingBalanceWriteIndex > -1 ? existingBalanceWriteIndex : MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
245
- ] = new PublicDataUpdateRequest(leafSlot, updatedBalance, 0);
248
+ return new PublicDataWrite(leafSlot, updatedBalance);
249
+ }
250
+
251
+ private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx]> {
252
+ const gasFees = this.globalVariables.gasFees;
253
+ const transactionFee = tx.data.gasUsed.computeFee(gasFees);
254
+
255
+ const accumulatedData = tx.data.forRollup!.end;
256
+ const feePaymentPublicDataWrite = await this.getFeePaymentPublicDataWrite(
257
+ accumulatedData.publicDataWrites,
258
+ transactionFee,
259
+ tx.data.feePayer,
260
+ );
246
261
 
247
- return finalPublicDataUpdateRequests;
262
+ const processedTx = makeProcessedTxFromPrivateOnlyTx(
263
+ tx,
264
+ transactionFee,
265
+ feePaymentPublicDataWrite,
266
+ this.globalVariables,
267
+ );
268
+ return [processedTx];
248
269
  }
249
270
 
250
271
  @trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
@@ -253,12 +274,12 @@ export class PublicProcessor {
253
274
  private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
254
275
  const timer = new Timer();
255
276
 
256
- const { avmProvingRequest, tailKernelOutput, returnValues, revertReason, gasUsed, processedPhases } =
257
- await this.enqueuedCallsProcessor.process(tx);
277
+ const { avmProvingRequest, gasUsed, revertCode, revertReason, processedPhases } =
278
+ await this.publicTxSimulator.simulate(tx);
258
279
 
259
- if (!tailKernelOutput) {
280
+ if (!avmProvingRequest) {
260
281
  this.metrics.recordFailedTx();
261
- throw new Error('Final public kernel was not executed.');
282
+ throw new Error('Avm proving result was not generated.');
262
283
  }
263
284
 
264
285
  processedPhases.forEach(phase => {
@@ -271,7 +292,7 @@ export class PublicProcessor {
271
292
 
272
293
  this.metrics.recordClassRegistration(
273
294
  ...ContractClassRegisteredEvent.fromLogs(
274
- tx.unencryptedLogs.unrollLogs(),
295
+ tx.contractClassLogs.unrollLogs(),
275
296
  ProtocolContractAddress.ContractClassRegisterer,
276
297
  ),
277
298
  );
@@ -279,7 +300,24 @@ export class PublicProcessor {
279
300
  const phaseCount = processedPhases.length;
280
301
  this.metrics.recordTx(phaseCount, timer.ms());
281
302
 
282
- const processedTx = makeProcessedTx(tx, tailKernelOutput, { avmProvingRequest, revertReason, gasUsed });
303
+ const data = avmProvingRequest.inputs.output;
304
+ const feePaymentPublicDataWrite = await this.getFeePaymentPublicDataWrite(
305
+ data.accumulatedData.publicDataWrites,
306
+ data.transactionFee,
307
+ tx.data.feePayer,
308
+ );
309
+
310
+ const processedTx = makeProcessedTxFromTxWithPublicCalls(
311
+ tx,
312
+ avmProvingRequest,
313
+ feePaymentPublicDataWrite,
314
+ gasUsed,
315
+ revertCode,
316
+ revertReason,
317
+ );
318
+
319
+ const returnValues = processedPhases.find(({ phase }) => phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
320
+
283
321
  return [processedTx, returnValues];
284
322
  }
285
323
  }
@@ -1,4 +1,4 @@
1
- import { type PublicKernelPhase } from '@aztec/circuit-types';
1
+ import { type TxExecutionPhase } from '@aztec/circuit-types';
2
2
  import { type ContractClassRegisteredEvent } from '@aztec/circuits.js';
3
3
  import {
4
4
  Attributes,
@@ -56,7 +56,7 @@ export class PublicProcessorMetrics {
56
56
  });
57
57
  }
58
58
 
59
- recordPhaseDuration(phaseName: PublicKernelPhase, durationMs: number) {
59
+ recordPhaseDuration(phaseName: TxExecutionPhase, durationMs: number) {
60
60
  this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: true });
61
61
  this.phaseDuration.record(Math.ceil(durationMs), { [Attributes.TX_PHASE_NAME]: phaseName });
62
62
  }
@@ -75,7 +75,7 @@ export class PublicProcessorMetrics {
75
75
  });
76
76
  }
77
77
 
78
- recordRevertedPhase(phaseName: PublicKernelPhase) {
78
+ recordRevertedPhase(phaseName: TxExecutionPhase) {
79
79
  this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: false });
80
80
  }
81
81