@aztec/simulator 0.43.0 → 0.45.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 (155) hide show
  1. package/dest/acvm/oracle/oracle.d.ts +3 -1
  2. package/dest/acvm/oracle/oracle.d.ts.map +1 -1
  3. package/dest/acvm/oracle/oracle.js +12 -6
  4. package/dest/acvm/oracle/typed_oracle.d.ts +6 -4
  5. package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
  6. package/dest/acvm/oracle/typed_oracle.js +8 -2
  7. package/dest/avm/avm_context.d.ts +1 -1
  8. package/dest/avm/avm_context.d.ts.map +1 -1
  9. package/dest/avm/avm_context.js +3 -3
  10. package/dest/avm/{avm_message_call_result.d.ts → avm_contract_call_result.d.ts} +2 -2
  11. package/dest/avm/avm_contract_call_result.d.ts.map +1 -0
  12. package/dest/avm/avm_contract_call_result.js +18 -0
  13. package/dest/avm/avm_execution_environment.d.ts +8 -10
  14. package/dest/avm/avm_execution_environment.d.ts.map +1 -1
  15. package/dest/avm/avm_execution_environment.js +15 -19
  16. package/dest/avm/avm_gas.js +2 -2
  17. package/dest/avm/avm_simulator.d.ts +4 -4
  18. package/dest/avm/avm_simulator.d.ts.map +1 -1
  19. package/dest/avm/avm_simulator.js +7 -8
  20. package/dest/avm/bytecode_utils.d.ts +5 -0
  21. package/dest/avm/bytecode_utils.d.ts.map +1 -0
  22. package/dest/avm/bytecode_utils.js +29 -0
  23. package/dest/avm/errors.js +2 -2
  24. package/dest/avm/fixtures/index.d.ts +10 -6
  25. package/dest/avm/fixtures/index.d.ts.map +1 -1
  26. package/dest/avm/fixtures/index.js +10 -17
  27. package/dest/avm/journal/journal.d.ts +56 -65
  28. package/dest/avm/journal/journal.d.ts.map +1 -1
  29. package/dest/avm/journal/journal.js +80 -117
  30. package/dest/avm/journal/nullifiers.d.ts +21 -8
  31. package/dest/avm/journal/nullifiers.d.ts.map +1 -1
  32. package/dest/avm/journal/nullifiers.js +26 -8
  33. package/dest/avm/journal/public_storage.d.ts +5 -1
  34. package/dest/avm/journal/public_storage.d.ts.map +1 -1
  35. package/dest/avm/journal/public_storage.js +11 -2
  36. package/dest/avm/opcodes/accrued_substate.d.ts +1 -2
  37. package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
  38. package/dest/avm/opcodes/accrued_substate.js +8 -17
  39. package/dest/avm/opcodes/environment_getters.d.ts +13 -8
  40. package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
  41. package/dest/avm/opcodes/environment_getters.js +20 -13
  42. package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
  43. package/dest/avm/opcodes/external_calls.js +11 -27
  44. package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
  45. package/dest/avm/serialization/bytecode_serialization.js +5 -5
  46. package/dest/avm/serialization/instruction_serialization.d.ts +9 -9
  47. package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
  48. package/dest/avm/serialization/instruction_serialization.js +10 -10
  49. package/dest/avm/test_utils.d.ts +14 -0
  50. package/dest/avm/test_utils.d.ts.map +1 -0
  51. package/dest/avm/test_utils.js +36 -0
  52. package/dest/client/client_execution_context.d.ts +6 -4
  53. package/dest/client/client_execution_context.d.ts.map +1 -1
  54. package/dest/client/client_execution_context.js +8 -6
  55. package/dest/client/execution_note_cache.d.ts.map +1 -1
  56. package/dest/client/execution_note_cache.js +1 -1
  57. package/dest/client/execution_result.d.ts +2 -1
  58. package/dest/client/execution_result.d.ts.map +1 -1
  59. package/dest/client/execution_result.js +1 -1
  60. package/dest/client/index.d.ts +2 -0
  61. package/dest/client/index.d.ts.map +1 -1
  62. package/dest/client/index.js +3 -1
  63. package/dest/client/simulator.d.ts +3 -3
  64. package/dest/client/simulator.d.ts.map +1 -1
  65. package/dest/client/simulator.js +1 -1
  66. package/dest/client/view_data_oracle.d.ts +5 -1
  67. package/dest/client/view_data_oracle.d.ts.map +1 -1
  68. package/dest/client/view_data_oracle.js +12 -4
  69. package/dest/mocks/fixtures.d.ts +3 -3
  70. package/dest/mocks/fixtures.d.ts.map +1 -1
  71. package/dest/mocks/fixtures.js +6 -5
  72. package/dest/public/abstract_phase_manager.d.ts +1 -0
  73. package/dest/public/abstract_phase_manager.d.ts.map +1 -1
  74. package/dest/public/abstract_phase_manager.js +17 -14
  75. package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
  76. package/dest/public/app_logic_phase_manager.js +2 -1
  77. package/dest/public/execution.d.ts +33 -30
  78. package/dest/public/execution.d.ts.map +1 -1
  79. package/dest/public/execution.js +2 -2
  80. package/dest/public/executor.d.ts +12 -7
  81. package/dest/public/executor.d.ts.map +1 -1
  82. package/dest/public/executor.js +42 -33
  83. package/dest/public/hints_builder.d.ts +1 -1
  84. package/dest/public/index.d.ts +1 -1
  85. package/dest/public/index.d.ts.map +1 -1
  86. package/dest/public/index.js +1 -1
  87. package/dest/public/public_kernel.d.ts +1 -1
  88. package/dest/public/public_kernel.d.ts.map +1 -1
  89. package/dest/public/public_kernel.js +2 -2
  90. package/dest/public/public_processor.d.ts +5 -2
  91. package/dest/public/public_processor.d.ts.map +1 -1
  92. package/dest/public/public_processor.js +142 -123
  93. package/dest/public/side_effect_trace.d.ts +87 -0
  94. package/dest/public/side_effect_trace.d.ts.map +1 -0
  95. package/dest/public/side_effect_trace.js +236 -0
  96. package/dest/public/side_effect_trace_interface.d.ts +36 -0
  97. package/dest/public/side_effect_trace_interface.d.ts.map +1 -0
  98. package/dest/public/side_effect_trace_interface.js +2 -0
  99. package/dest/public/teardown_phase_manager.d.ts.map +1 -1
  100. package/dest/public/teardown_phase_manager.js +2 -1
  101. package/dest/rollup/rollup.d.ts +1 -1
  102. package/dest/rollup/rollup.d.ts.map +1 -1
  103. package/dest/rollup/rollup.js +2 -2
  104. package/package.json +18 -9
  105. package/src/acvm/oracle/oracle.ts +23 -5
  106. package/src/acvm/oracle/typed_oracle.ts +23 -4
  107. package/src/avm/avm_context.ts +2 -2
  108. package/src/avm/{avm_message_call_result.ts → avm_contract_call_result.ts} +1 -1
  109. package/src/avm/avm_execution_environment.ts +16 -26
  110. package/src/avm/avm_gas.ts +1 -1
  111. package/src/avm/avm_simulator.ts +10 -13
  112. package/src/avm/bytecode_utils.ts +32 -0
  113. package/src/avm/errors.ts +1 -1
  114. package/src/avm/fixtures/index.ts +21 -23
  115. package/src/avm/journal/journal.ts +118 -224
  116. package/src/avm/journal/nullifiers.ts +30 -13
  117. package/src/avm/journal/public_storage.ts +12 -2
  118. package/src/avm/opcodes/accrued_substate.ts +12 -21
  119. package/src/avm/opcodes/environment_getters.ts +23 -14
  120. package/src/avm/opcodes/external_calls.ts +13 -36
  121. package/src/avm/serialization/bytecode_serialization.ts +4 -3
  122. package/src/avm/serialization/instruction_serialization.ts +3 -3
  123. package/src/avm/test_utils.ts +53 -0
  124. package/src/client/client_execution_context.ts +22 -7
  125. package/src/client/execution_note_cache.ts +0 -1
  126. package/src/client/execution_result.ts +2 -1
  127. package/src/client/index.ts +2 -0
  128. package/src/client/simulator.ts +8 -2
  129. package/src/client/view_data_oracle.ts +20 -3
  130. package/src/mocks/fixtures.ts +7 -6
  131. package/src/public/abstract_phase_manager.ts +32 -21
  132. package/src/public/app_logic_phase_manager.ts +1 -0
  133. package/src/public/execution.ts +45 -31
  134. package/src/public/executor.ts +71 -49
  135. package/src/public/index.ts +1 -1
  136. package/src/public/public_kernel.ts +2 -1
  137. package/src/public/public_processor.ts +11 -2
  138. package/src/public/side_effect_trace.ts +341 -0
  139. package/src/public/side_effect_trace_interface.ts +41 -0
  140. package/src/public/teardown_phase_manager.ts +1 -0
  141. package/src/rollup/rollup.ts +3 -1
  142. package/dest/avm/avm_message_call_result.d.ts.map +0 -1
  143. package/dest/avm/avm_message_call_result.js +0 -18
  144. package/dest/avm/journal/trace.d.ts +0 -33
  145. package/dest/avm/journal/trace.d.ts.map +0 -1
  146. package/dest/avm/journal/trace.js +0 -152
  147. package/dest/avm/journal/trace_types.d.ts +0 -55
  148. package/dest/avm/journal/trace_types.d.ts.map +0 -1
  149. package/dest/avm/journal/trace_types.js +0 -2
  150. package/dest/public/transitional_adaptors.d.ts +0 -21
  151. package/dest/public/transitional_adaptors.d.ts.map +0 -1
  152. package/dest/public/transitional_adaptors.js +0 -90
  153. package/src/avm/journal/trace.ts +0 -181
  154. package/src/avm/journal/trace_types.ts +0 -91
  155. package/src/public/transitional_adaptors.ts +0 -168
@@ -18,18 +18,39 @@ import { type Gas } from '../avm/avm_gas.js';
18
18
  * The public function execution result.
19
19
  */
20
20
  export interface PublicExecutionResult {
21
- /** The execution that triggered this result. */
22
- execution: PublicExecution;
21
+ /** The execution request that triggered this result. */
22
+ executionRequest: PublicExecutionRequest;
23
+
24
+ /** The side effect counter at the start of the function call. */
25
+ startSideEffectCounter: Fr;
26
+ /** The side effect counter after executing this function call */
27
+ endSideEffectCounter: Fr;
28
+ /** How much gas was available for this public execution. */
29
+ startGasLeft: Gas;
30
+ /** How much gas was left after this public execution. */
31
+ endGasLeft: Gas;
32
+ /** Transaction fee set for this tx. */
33
+ transactionFee: Fr;
34
+
35
+ /** Bytecode used for this execution. */
36
+ bytecode?: Buffer;
37
+ /** Calldata used for this execution. */
38
+ calldata: Fr[];
23
39
  /** The return values of the function. */
24
40
  returnValues: Fr[];
41
+ /** Whether the execution reverted. */
42
+ reverted: boolean;
43
+ /** The revert reason if the execution reverted. */
44
+ revertReason?: SimulationError;
45
+
46
+ /** The contract storage reads performed by the function. */
47
+ contractStorageReads: ContractStorageRead[];
48
+ /** The contract storage update requests performed by the function. */
49
+ contractStorageUpdateRequests: ContractStorageUpdateRequest[];
25
50
  /** The new note hashes to be inserted into the note hashes tree. */
26
51
  newNoteHashes: NoteHash[];
27
52
  /** The new l2 to l1 messages generated in this call. */
28
53
  newL2ToL1Messages: L2ToL1Message[];
29
- /** The side effect counter at the start of the function call. */
30
- startSideEffectCounter: Fr;
31
- /** The side effect counter after executing this function call */
32
- endSideEffectCounter: Fr;
33
54
  /** The new nullifiers to be inserted into the nullifier tree. */
34
55
  newNullifiers: Nullifier[];
35
56
  /** The note hash read requests emitted in this call. */
@@ -40,12 +61,6 @@ export interface PublicExecutionResult {
40
61
  nullifierNonExistentReadRequests: ReadRequest[];
41
62
  /** L1 to L2 message read requests emitted in this call. */
42
63
  l1ToL2MsgReadRequests: ReadRequest[];
43
- /** The contract storage reads performed by the function. */
44
- contractStorageReads: ContractStorageRead[];
45
- /** The contract storage update requests performed by the function. */
46
- contractStorageUpdateRequests: ContractStorageUpdateRequest[];
47
- /** The results of nested calls. */
48
- nestedExecutions: this[];
49
64
  /**
50
65
  * The hashed logs with side effect counter.
51
66
  * Note: required as we don't track the counter anywhere else.
@@ -61,28 +76,27 @@ export interface PublicExecutionResult {
61
76
  * Useful for maintaining correct ordering in ts.
62
77
  */
63
78
  allUnencryptedLogs: UnencryptedFunctionL2Logs;
64
- /** Whether the execution reverted. */
65
- reverted: boolean;
66
- /** The revert reason if the execution reverted. */
67
- revertReason?: SimulationError;
68
- /** How much gas was available for this public execution. */
69
- startGasLeft: Gas;
70
- /** How much gas was left after this public execution. */
71
- endGasLeft: Gas;
72
- /** Transaction fee set for this tx. */
73
- transactionFee: Fr;
74
- /** Bytecode used for this execution. */
75
- bytecode?: Buffer;
76
- /** Calldata used for this execution. */
77
- calldata: Fr[];
79
+
80
+ // TODO(dbanks12): add contract instance read requests
81
+
82
+ /** The results of nested calls. */
83
+ nestedExecutions: this[];
84
+
78
85
  /** Hints for proving AVM execution. */
79
- avmHints: AvmExecutionHints;
86
+ avmCircuitHints: AvmExecutionHints;
87
+
88
+ /** The name of the function that was executed. Only used for logging. */
89
+ functionName: string;
80
90
  }
81
91
 
82
92
  /**
83
- * The execution of a public function.
93
+ * The execution request of a public function.
94
+ * A subset of PublicCallRequest
84
95
  */
85
- export type PublicExecution = Pick<PublicCallRequest, 'contractAddress' | 'functionSelector' | 'callContext' | 'args'>;
96
+ export type PublicExecutionRequest = Pick<
97
+ PublicCallRequest,
98
+ 'contractAddress' | 'functionSelector' | 'callContext' | 'args'
99
+ >;
86
100
 
87
101
  /**
88
102
  * Returns if the input is a public execution result and not just a public execution.
@@ -90,9 +104,9 @@ export type PublicExecution = Pick<PublicCallRequest, 'contractAddress' | 'funct
90
104
  * @returns Whether the input is a public execution result and not just a public execution.
91
105
  */
92
106
  export function isPublicExecutionResult(
93
- input: PublicExecution | PublicExecutionResult,
107
+ input: PublicExecutionRequest | PublicExecutionResult,
94
108
  ): input is PublicExecutionResult {
95
- return 'execution' in input && input.execution !== undefined;
109
+ return 'executionRequest' in input && input.executionRequest !== undefined;
96
110
  }
97
111
 
98
112
  /**
@@ -1,23 +1,24 @@
1
1
  import { type AvmSimulationStats } from '@aztec/circuit-types/stats';
2
- import { Fr, type Gas, type GlobalVariables, type Header, type Nullifier, type TxContext } from '@aztec/circuits.js';
2
+ import { Fr, Gas, type GlobalVariables, type Header, type Nullifier, type TxContext } from '@aztec/circuits.js';
3
3
  import { createDebugLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
5
 
6
6
  import { AvmContext } from '../avm/avm_context.js';
7
+ import { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
7
8
  import { AvmMachineState } from '../avm/avm_machine_state.js';
8
9
  import { AvmSimulator } from '../avm/avm_simulator.js';
9
10
  import { HostStorage } from '../avm/journal/host_storage.js';
10
11
  import { AvmPersistableStateManager } from '../avm/journal/index.js';
11
12
  import { type CommitmentsDB, type PublicContractsDB, type PublicStateDB } from './db_interfaces.js';
12
- import { type PublicExecution, type PublicExecutionResult, checkValidStaticCall } from './execution.js';
13
- import { convertAvmResultsToPxResult, createAvmExecutionEnvironment } from './transitional_adaptors.js';
13
+ import { type PublicExecutionRequest, type PublicExecutionResult } from './execution.js';
14
+ import { PublicSideEffectTrace } from './side_effect_trace.js';
14
15
 
15
16
  /**
16
17
  * Handles execution of public functions.
17
18
  */
18
19
  export class PublicExecutor {
19
20
  constructor(
20
- private readonly stateDb: PublicStateDB,
21
+ private readonly publicStorageDB: PublicStateDB,
21
22
  private readonly contractsDb: PublicContractsDB,
22
23
  private readonly commitmentsDb: CommitmentsDB,
23
24
  private readonly header: Header,
@@ -27,54 +28,56 @@ export class PublicExecutor {
27
28
 
28
29
  /**
29
30
  * Executes a public execution request.
30
- * @param execution - The execution to run.
31
+ * @param executionRequest - The execution to run.
31
32
  * @param globalVariables - The global variables to use.
32
- * @returns The result of the run plus all nested runs.
33
+ * @param availableGas - The gas available at the start of this enqueued call.
34
+ * @param txContext - Transaction context.
35
+ * @param pendingSiloedNullifiers - The pending nullifier set from earlier parts of this TX.
36
+ * @param transactionFee - Fee offered for this TX.
37
+ * @param startSideEffectCounter - The counter of the first side-effect generated by this simulation.
38
+ * @returns The result of execution, including the results of all nested calls.
33
39
  */
34
40
  public async simulate(
35
- execution: PublicExecution,
41
+ executionRequest: PublicExecutionRequest,
36
42
  globalVariables: GlobalVariables,
37
43
  availableGas: Gas,
38
- txContext: TxContext,
39
- pendingNullifiers: Nullifier[],
44
+ _txContext: TxContext,
45
+ pendingSiloedNullifiers: Nullifier[],
40
46
  transactionFee: Fr = Fr.ZERO,
41
47
  startSideEffectCounter: number = 0,
42
48
  ): Promise<PublicExecutionResult> {
43
- const address = execution.contractAddress;
44
- const selector = execution.functionSelector;
45
- const startGas = availableGas;
46
- const fnName = await this.contractsDb.getDebugFunctionName(address, selector);
49
+ const address = executionRequest.contractAddress;
50
+ const selector = executionRequest.functionSelector;
51
+ const fnName = (await this.contractsDb.getDebugFunctionName(address, selector)) ?? `${address}:${selector}`;
47
52
 
48
53
  PublicExecutor.log.verbose(`[AVM] Executing public external function ${fnName}.`);
49
54
  const timer = new Timer();
50
55
 
51
- // Temporary code to construct the AVM context
52
- // These data structures will permeate across the simulator when the public executor is phased out
53
- const hostStorage = new HostStorage(this.stateDb, this.contractsDb, this.commitmentsDb);
54
-
55
- const worldStateJournal = new AvmPersistableStateManager(hostStorage);
56
- for (const nullifier of pendingNullifiers) {
57
- worldStateJournal.nullifiers.cache.appendSiloed(nullifier.value);
58
- }
59
- worldStateJournal.trace.accessCounter = startSideEffectCounter;
56
+ const hostStorage = new HostStorage(this.publicStorageDB, this.contractsDb, this.commitmentsDb);
57
+ const trace = new PublicSideEffectTrace(startSideEffectCounter);
58
+ const avmPersistableState = AvmPersistableStateManager.newWithPendingSiloedNullifiers(
59
+ hostStorage,
60
+ trace,
61
+ pendingSiloedNullifiers.map(n => n.value),
62
+ );
60
63
 
61
- const executionEnv = createAvmExecutionEnvironment(
62
- execution,
64
+ const avmExecutionEnv = createAvmExecutionEnvironment(
65
+ executionRequest,
63
66
  this.header,
64
67
  globalVariables,
65
- txContext.gasSettings,
66
68
  transactionFee,
67
69
  );
68
70
 
69
- const machineState = new AvmMachineState(startGas);
70
- const avmContext = new AvmContext(worldStateJournal, executionEnv, machineState);
71
+ const avmMachineState = new AvmMachineState(availableGas);
72
+ const avmContext = new AvmContext(avmPersistableState, avmExecutionEnv, avmMachineState);
71
73
  const simulator = new AvmSimulator(avmContext);
72
74
  const avmResult = await simulator.execute();
73
- const bytecode = simulator.getBytecode();
75
+ const bytecode = simulator.getBytecode()!;
74
76
 
75
- // Commit the journals state to the DBs since this is a top-level execution.
77
+ // Commit the public storage state to the DBs since this is a top-level execution.
76
78
  // Observe that this will write all the state changes to the DBs, not only the latest for each slot.
77
79
  // However, the underlying DB keep a cache and will only write the latest state to disk.
80
+ // TODO(dbanks12): this should be unnecessary here or should be exposed by state manager
78
81
  await avmContext.persistableState.publicStorage.commitToDB();
79
82
 
80
83
  PublicExecutor.log.verbose(
@@ -83,33 +86,52 @@ export class PublicExecutor {
83
86
  }.`,
84
87
  {
85
88
  eventName: 'avm-simulation',
86
- appCircuitName: fnName ?? 'unknown',
89
+ appCircuitName: fnName,
87
90
  duration: timer.ms(),
88
91
  bytecodeSize: bytecode!.length,
89
92
  } satisfies AvmSimulationStats,
90
93
  );
91
94
 
92
- const executionResult = convertAvmResultsToPxResult(
93
- avmResult,
94
- startSideEffectCounter,
95
- execution,
96
- startGas,
97
- avmContext,
95
+ const publicExecutionResult = trace.toPublicExecutionResult(
96
+ avmExecutionEnv,
97
+ /*startGasLeft=*/ availableGas,
98
+ /*endGasLeft=*/ Gas.from(avmContext.machineState.gasLeft),
98
99
  bytecode,
100
+ avmResult,
101
+ fnName,
102
+ /*requestSideEffectCounter=*/ executionRequest.callContext.sideEffectCounter,
103
+ // NOTE: startSideEffectCounter is not the same as the executionRequest's sideEffectCounter
104
+ // (which counts the request itself)
99
105
  );
100
106
 
101
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): is this really needed?
102
- // should already be handled in simulation.
103
- if (execution.callContext.isStaticCall) {
104
- checkValidStaticCall(
105
- executionResult.newNoteHashes,
106
- executionResult.newNullifiers,
107
- executionResult.contractStorageUpdateRequests,
108
- executionResult.newL2ToL1Messages,
109
- executionResult.unencryptedLogs,
110
- );
111
- }
112
-
113
- return executionResult;
107
+ return publicExecutionResult;
114
108
  }
115
109
  }
110
+
111
+ /**
112
+ * Convert a PublicExecutionRequest object to an AvmExecutionEnvironment
113
+ *
114
+ * @param executionRequest
115
+ * @param globalVariables
116
+ * @returns
117
+ */
118
+ function createAvmExecutionEnvironment(
119
+ executionRequest: PublicExecutionRequest,
120
+ header: Header,
121
+ globalVariables: GlobalVariables,
122
+ transactionFee: Fr,
123
+ ): AvmExecutionEnvironment {
124
+ return new AvmExecutionEnvironment(
125
+ executionRequest.contractAddress,
126
+ executionRequest.callContext.storageContractAddress,
127
+ executionRequest.callContext.msgSender,
128
+ executionRequest.functionSelector,
129
+ /*contractCallDepth=*/ Fr.zero(),
130
+ transactionFee,
131
+ header,
132
+ globalVariables,
133
+ executionRequest.callContext.isStaticCall,
134
+ executionRequest.callContext.isDelegateCall,
135
+ executionRequest.args,
136
+ );
137
+ }
@@ -1,6 +1,6 @@
1
1
  export * from './abstract_phase_manager.js';
2
2
  export * from './db_interfaces.js';
3
- export { isPublicExecutionResult, type PublicExecution, type PublicExecutionResult } from './execution.js';
3
+ export { isPublicExecutionResult, type PublicExecutionRequest, type PublicExecutionResult } from './execution.js';
4
4
  export { PublicExecutor } from './executor.js';
5
5
  export * from './fee_payment.js';
6
6
  export { HintsBuilder } from './hints_builder.js';
@@ -21,8 +21,9 @@ import {
21
21
  convertSimulatedPublicTeardownInputsToWitnessMap,
22
22
  convertSimulatedPublicTeardownOutputFromWitnessMap,
23
23
  } from '@aztec/noir-protocol-circuits-types';
24
- import { type SimulationProvider, WASMSimulator } from '@aztec/simulator';
25
24
 
25
+ import { WASMSimulator } from '../providers/acvm_wasm.js';
26
+ import { type SimulationProvider } from '../providers/simulation_provider.js';
26
27
  import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
27
28
 
28
29
  /**
@@ -30,6 +30,7 @@ import {
30
30
  computeFeePayerBalanceLeafSlot,
31
31
  computeFeePayerBalanceStorageSlot,
32
32
  } from '@aztec/simulator';
33
+ import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
33
34
  import { type ContractDataSource } from '@aztec/types/contracts';
34
35
  import { type MerkleTreeOperations } from '@aztec/world-state';
35
36
 
@@ -47,6 +48,7 @@ export class PublicProcessorFactory {
47
48
  private merkleTree: MerkleTreeOperations,
48
49
  private contractDataSource: ContractDataSource,
49
50
  private simulator: SimulationProvider,
51
+ private telemetryClient: TelemetryClient,
50
52
  ) {}
51
53
 
52
54
  /**
@@ -74,6 +76,7 @@ export class PublicProcessorFactory {
74
76
  historicalHeader,
75
77
  publicContractsDB,
76
78
  worldStatePublicDB,
79
+ this.telemetryClient,
77
80
  );
78
81
  }
79
82
  }
@@ -83,6 +86,7 @@ export class PublicProcessorFactory {
83
86
  * any public function calls in them. Txs with private calls only are unaffected.
84
87
  */
85
88
  export class PublicProcessor {
89
+ public readonly tracer: Tracer;
86
90
  constructor(
87
91
  protected db: MerkleTreeOperations,
88
92
  protected publicExecutor: PublicExecutor,
@@ -91,9 +95,11 @@ export class PublicProcessor {
91
95
  protected historicalHeader: Header,
92
96
  protected publicContractsDB: ContractsDataSourcePublicDB,
93
97
  protected publicStateDB: PublicStateDB,
94
-
98
+ telemetryClient: TelemetryClient,
95
99
  private log = createDebugLogger('aztec:sequencer:public-processor'),
96
- ) {}
100
+ ) {
101
+ this.tracer = telemetryClient.getTracer('PublicProcessor');
102
+ }
97
103
 
98
104
  /**
99
105
  * Run each tx through the public circuit and the public kernel circuit if needed.
@@ -208,6 +214,9 @@ export class PublicProcessor {
208
214
  return finalPublicDataUpdateRequests;
209
215
  }
210
216
 
217
+ @trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
218
+ [Attributes.TX_HASH]: tx.getTxHash().toString(),
219
+ }))
211
220
  private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
212
221
  let returnValues: NestedProcessReturnValues[] = [];
213
222
  const publicProvingRequests: PublicProvingRequest[] = [];