@aztec/simulator 0.82.0 → 0.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dest/common/debug_fn_name.js +5 -2
  2. package/dest/private/acvm/oracle/oracle.d.ts +3 -3
  3. package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
  4. package/dest/private/acvm/oracle/oracle.js +9 -15
  5. package/dest/private/acvm/oracle/typed_oracle.d.ts +3 -3
  6. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
  7. package/dest/private/acvm/oracle/typed_oracle.js +6 -6
  8. package/dest/private/hashed_values_cache.d.ts +2 -2
  9. package/dest/private/hashed_values_cache.d.ts.map +1 -1
  10. package/dest/private/hashed_values_cache.js +5 -15
  11. package/dest/private/private_execution.d.ts.map +1 -1
  12. package/dest/private/private_execution.js +1 -3
  13. package/dest/private/private_execution_oracle.d.ts +9 -37
  14. package/dest/private/private_execution_oracle.d.ts.map +1 -1
  15. package/dest/private/private_execution_oracle.js +32 -92
  16. package/dest/private/simulator.d.ts.map +1 -1
  17. package/dest/private/simulator.js +12 -2
  18. package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -2
  19. package/dest/public/avm/fixtures/index.d.ts +2 -1
  20. package/dest/public/avm/fixtures/index.d.ts.map +1 -1
  21. package/dest/public/avm/fixtures/index.js +7 -12
  22. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +2 -2
  23. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
  24. package/dest/public/avm/fixtures/simple_contract_data_source.js +1 -1
  25. package/dest/public/avm/journal/journal.d.ts +2 -2
  26. package/dest/public/avm/journal/journal.d.ts.map +1 -1
  27. package/dest/public/avm/journal/journal.js +3 -3
  28. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +2 -2
  29. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  30. package/dest/public/fixtures/public_tx_simulation_tester.js +27 -47
  31. package/dest/public/fixtures/utils.d.ts +2 -2
  32. package/dest/public/fixtures/utils.d.ts.map +1 -1
  33. package/dest/public/fixtures/utils.js +18 -22
  34. package/dest/public/index.d.ts +1 -2
  35. package/dest/public/index.d.ts.map +1 -1
  36. package/dest/public/index.js +1 -1
  37. package/dest/public/public_db_sources.js +1 -1
  38. package/dest/public/public_processor/public_processor.js +1 -1
  39. package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -10
  40. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  41. package/dest/public/public_tx_simulator/public_tx_context.js +4 -22
  42. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +2 -3
  43. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  44. package/dest/public/public_tx_simulator/public_tx_simulator.js +20 -24
  45. package/dest/public/utils.d.ts +2 -4
  46. package/dest/public/utils.d.ts.map +1 -1
  47. package/dest/public/utils.js +4 -21
  48. package/package.json +14 -14
  49. package/src/common/debug_fn_name.ts +5 -5
  50. package/src/private/acvm/oracle/oracle.ts +13 -17
  51. package/src/private/acvm/oracle/typed_oracle.ts +10 -12
  52. package/src/private/hashed_values_cache.ts +6 -14
  53. package/src/private/private_execution.ts +0 -4
  54. package/src/private/private_execution_oracle.ts +39 -138
  55. package/src/private/simulator.ts +14 -2
  56. package/src/public/avm/fixtures/avm_simulation_tester.ts +2 -2
  57. package/src/public/avm/fixtures/index.ts +15 -17
  58. package/src/public/avm/fixtures/simple_contract_data_source.ts +2 -2
  59. package/src/public/avm/journal/journal.ts +6 -6
  60. package/src/public/fixtures/public_tx_simulation_tester.ts +31 -88
  61. package/src/public/fixtures/utils.ts +28 -26
  62. package/src/public/index.ts +1 -2
  63. package/src/public/public_db_sources.ts +1 -1
  64. package/src/public/public_processor/public_processor.ts +1 -1
  65. package/src/public/public_tx_simulator/public_tx_context.ts +12 -32
  66. package/src/public/public_tx_simulator/public_tx_simulator.ts +24 -30
  67. package/src/public/utils.ts +5 -21
  68. package/dest/public/execution.d.ts +0 -108
  69. package/dest/public/execution.d.ts.map +0 -1
  70. package/dest/public/execution.js +0 -9
  71. package/src/public/execution.ts +0 -140
@@ -1,9 +1,8 @@
1
1
  export * from '../common/db_interfaces.js';
2
2
  export * from './public_tx_simulator/public_tx_simulator.js';
3
- export { type EnqueuedPublicCallExecutionResult, type PublicFunctionCallResult } from './execution.js';
4
3
  export * from './public_db_sources.js';
5
4
  export { PublicProcessor, PublicProcessorFactory } from './public_processor/public_processor.js';
6
5
  export { SideEffectTrace } from './side_effect_trace.js';
7
- export { getExecutionRequestsByPhase } from './utils.js';
8
6
  export { PublicTxSimulationTester } from './fixtures/index.js';
9
7
  export * from './avm/index.js';
8
+ export { getCallRequestsWithCalldataByPhase } from './utils.js';
@@ -271,7 +271,7 @@ export class PublicContractsDB implements PublicContractsDBInterface {
271
271
  }
272
272
 
273
273
  public async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
274
- return await this.dataSource.getContractFunctionName(address, selector);
274
+ return await this.dataSource.getDebugFunctionName(address, selector);
275
275
  }
276
276
  }
277
277
 
@@ -321,7 +321,7 @@ export class PublicProcessor implements Traceable {
321
321
  this.log.verbose(
322
322
  !tx.hasPublicCalls()
323
323
  ? `Processed tx ${processedTx.hash} with no public calls in ${time}ms`
324
- : `Processed tx ${processedTx.hash} with ${tx.enqueuedPublicFunctionCalls.length} public calls in ${time}ms`,
324
+ : `Processed tx ${processedTx.hash} with ${tx.numberOfPublicCalls()} public calls in ${time}ms`,
325
325
  {
326
326
  txHash: processedTx.hash,
327
327
  txFee: processedTx.txEffect.transactionFee.toBigInt(),
@@ -26,7 +26,7 @@ import {
26
26
  import { MerkleTreeId } from '@aztec/stdlib/trees';
27
27
  import {
28
28
  type GlobalVariables,
29
- type PublicExecutionRequest,
29
+ PublicCallRequestWithCalldata,
30
30
  type StateReference,
31
31
  TreeSnapshots,
32
32
  type Tx,
@@ -42,7 +42,7 @@ import { AvmPersistableStateManager } from '../avm/index.js';
42
42
  import { HintingPublicContractsDB } from '../hinting_db_sources.js';
43
43
  import type { PublicTreesDB } from '../public_db_sources.js';
44
44
  import { SideEffectArrayLengths, SideEffectTrace } from '../side_effect_trace.js';
45
- import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js';
45
+ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
46
46
 
47
47
  /**
48
48
  * The transaction-level context for public execution.
@@ -70,12 +70,9 @@ export class PublicTxContext {
70
70
  private readonly gasSettings: GasSettings,
71
71
  private readonly gasUsedByPrivate: Gas,
72
72
  private readonly gasAllocatedToPublic: Gas,
73
- private readonly setupCallRequests: PublicCallRequest[],
74
- private readonly appLogicCallRequests: PublicCallRequest[],
75
- private readonly teardownCallRequests: PublicCallRequest[],
76
- private readonly setupExecutionRequests: PublicExecutionRequest[],
77
- private readonly appLogicExecutionRequests: PublicExecutionRequest[],
78
- private readonly teardownExecutionRequests: PublicExecutionRequest[],
73
+ private readonly setupCallRequests: PublicCallRequestWithCalldata[],
74
+ private readonly appLogicCallRequests: PublicCallRequestWithCalldata[],
75
+ private readonly teardownCallRequests: PublicCallRequestWithCalldata[],
79
76
  public readonly nonRevertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
80
77
  public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
81
78
  public readonly feePayer: AztecAddress,
@@ -135,12 +132,9 @@ export class PublicTxContext {
135
132
  gasSettings,
136
133
  gasUsedByPrivate,
137
134
  gasAllocatedToPublic,
138
- getCallRequestsByPhase(tx, TxExecutionPhase.SETUP),
139
- getCallRequestsByPhase(tx, TxExecutionPhase.APP_LOGIC),
140
- getCallRequestsByPhase(tx, TxExecutionPhase.TEARDOWN),
141
- getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP),
142
- getExecutionRequestsByPhase(tx, TxExecutionPhase.APP_LOGIC),
143
- getExecutionRequestsByPhase(tx, TxExecutionPhase.TEARDOWN),
135
+ getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP),
136
+ getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC),
137
+ getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN),
144
138
  tx.data.forPublic!.nonRevertibleAccumulatedData,
145
139
  tx.data.forPublic!.revertibleAccumulatedData,
146
140
  tx.data.feePayer,
@@ -218,7 +212,7 @@ export class PublicTxContext {
218
212
  /**
219
213
  * Get the call requests for the specified phase (including args hashes).
220
214
  */
221
- getCallRequestsForPhase(phase: TxExecutionPhase): PublicCallRequest[] {
215
+ getCallRequestsForPhase(phase: TxExecutionPhase): PublicCallRequestWithCalldata[] {
222
216
  switch (phase) {
223
217
  case TxExecutionPhase.SETUP:
224
218
  return this.setupCallRequests;
@@ -229,20 +223,6 @@ export class PublicTxContext {
229
223
  }
230
224
  }
231
225
 
232
- /**
233
- * Get the call requests for the specified phase (including actual args).
234
- */
235
- getExecutionRequestsForPhase(phase: TxExecutionPhase): PublicExecutionRequest[] {
236
- switch (phase) {
237
- case TxExecutionPhase.SETUP:
238
- return this.setupExecutionRequests;
239
- case TxExecutionPhase.APP_LOGIC:
240
- return this.appLogicExecutionRequests;
241
- case TxExecutionPhase.TEARDOWN:
242
- return this.teardownExecutionRequests;
243
- }
244
- }
245
-
246
226
  /**
247
227
  * How much gas is left as of the specified phase?
248
228
  */
@@ -353,10 +333,10 @@ export class PublicTxContext {
353
333
  /*startGasUsed=*/ this.gasUsedByPrivate,
354
334
  this.gasSettings,
355
335
  this.feePayer,
356
- this.setupCallRequests,
357
- this.appLogicCallRequests,
336
+ this.setupCallRequests.map(r => r.request),
337
+ this.appLogicCallRequests.map(r => r.request),
358
338
  /*teardownCallRequest=*/ this.teardownCallRequests.length
359
- ? this.teardownCallRequests[0]
339
+ ? this.teardownCallRequests[0].request
360
340
  : PublicCallRequest.empty(),
361
341
  endTreeSnapshots,
362
342
  /*endGasUsed=*/ this.getTotalGasUsed(),
@@ -13,13 +13,12 @@ import {
13
13
  } from '@aztec/stdlib/avm';
14
14
  import { SimulationError } from '@aztec/stdlib/errors';
15
15
  import type { Gas, GasUsed } from '@aztec/stdlib/gas';
16
- import type { PublicCallRequest } from '@aztec/stdlib/kernel';
17
16
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
18
17
  import type { AvmSimulationStats } from '@aztec/stdlib/stats';
19
18
  import {
20
19
  type GlobalVariables,
21
20
  NestedProcessReturnValues,
22
- PublicExecutionRequest,
21
+ PublicCallRequestWithCalldata,
23
22
  Tx,
24
23
  TxExecutionPhase,
25
24
  } from '@aztec/stdlib/tx';
@@ -83,7 +82,7 @@ export class PublicTxSimulator {
83
82
  const startTime = process.hrtime.bigint();
84
83
 
85
84
  const txHash = await tx.getTxHash();
86
- this.log.debug(`Simulating ${tx.enqueuedPublicFunctionCalls.length} public calls for tx ${txHash}`, { txHash });
85
+ this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, { txHash });
87
86
 
88
87
  const context = await PublicTxContext.create(
89
88
  this.treesDB,
@@ -232,13 +231,11 @@ export class PublicTxSimulator {
232
231
  */
233
232
  private async simulatePhase(phase: TxExecutionPhase, context: PublicTxContext): Promise<ProcessedPhase> {
234
233
  const callRequests = context.getCallRequestsForPhase(phase);
235
- const executionRequests = context.getExecutionRequestsForPhase(phase);
236
234
 
237
235
  this.log.debug(`Processing phase ${TxExecutionPhase[phase]} for tx ${context.txHash}`, {
238
236
  txHash: context.txHash.toString(),
239
237
  phase: TxExecutionPhase[phase],
240
238
  callRequests: callRequests.length,
241
- executionRequests: executionRequests.length,
242
239
  });
243
240
 
244
241
  const returnValues: NestedProcessReturnValues[] = [];
@@ -251,9 +248,8 @@ export class PublicTxSimulator {
251
248
  }
252
249
 
253
250
  const callRequest = callRequests[i];
254
- const executionRequest = executionRequests[i];
255
251
 
256
- const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest, executionRequest);
252
+ const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
257
253
 
258
254
  returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
259
255
 
@@ -276,44 +272,42 @@ export class PublicTxSimulator {
276
272
  * Simulate an enqueued public call.
277
273
  * @param phase - The current phase of public execution
278
274
  * @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
279
- * @param callRequest - The enqueued call to execute
280
- * @param executionRequest - The execution request (includes args)
275
+ * @param callRequest - The public function call request, including the calldata.
281
276
  * @returns The result of execution.
282
277
  */
283
- @trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, _callRequest, executionRequest) => ({
278
+ @trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, callRequest) => ({
284
279
  [Attributes.TX_HASH]: context.txHash.toString(),
285
- [Attributes.TARGET_ADDRESS]: executionRequest.callContext.contractAddress.toString(),
286
- [Attributes.SENDER_ADDRESS]: executionRequest.callContext.msgSender.toString(),
280
+ [Attributes.TARGET_ADDRESS]: callRequest.request.contractAddress.toString(),
281
+ [Attributes.SENDER_ADDRESS]: callRequest.request.msgSender.toString(),
287
282
  [Attributes.SIMULATOR_PHASE]: TxExecutionPhase[phase].toString(),
288
283
  }))
289
284
  private async simulateEnqueuedCall(
290
285
  phase: TxExecutionPhase,
291
286
  context: PublicTxContext,
292
- callRequest: PublicCallRequest,
293
- executionRequest: PublicExecutionRequest,
287
+ callRequest: PublicCallRequestWithCalldata,
294
288
  ): Promise<AvmFinalizedCallResult> {
295
289
  const stateManager = context.state.getActiveStateManager();
296
- const address = executionRequest.callContext.contractAddress;
297
- const fnName = await getPublicFunctionDebugName(this.contractsDB, address, executionRequest.args);
290
+ const contractAddress = callRequest.request.contractAddress;
291
+ const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
298
292
 
299
293
  const allocatedGas = context.getGasLeftAtPhase(phase);
300
294
 
301
295
  // The reason we need enqueued hints at all (and cannot just use the public inputs) is
302
296
  // because they don't have the actual calldata, just the hash of it.
303
297
  // If/when we pass the whole TX to C++, we can remove this class of hints.
304
- stateManager.traceEnqueuedCall(callRequest);
298
+ stateManager.traceEnqueuedCall(callRequest.request);
305
299
  context.hints.enqueuedCalls.push(
306
300
  new AvmEnqueuedCallHint(
307
- executionRequest.callContext.msgSender,
308
- executionRequest.callContext.contractAddress,
309
- executionRequest.args,
310
- executionRequest.callContext.isStaticCall,
301
+ callRequest.request.msgSender,
302
+ contractAddress,
303
+ callRequest.calldata,
304
+ callRequest.request.isStaticCall,
311
305
  ),
312
306
  );
313
307
 
314
308
  const result = await this.simulateEnqueuedCallInternal(
315
309
  context.state.getActiveStateManager(),
316
- executionRequest,
310
+ callRequest,
317
311
  allocatedGas,
318
312
  /*transactionFee=*/ context.getTransactionFee(phase),
319
313
  fnName,
@@ -326,7 +320,7 @@ export class PublicTxSimulator {
326
320
  );
327
321
 
328
322
  if (result.reverted) {
329
- const culprit = `${executionRequest.callContext.contractAddress}:${executionRequest.callContext.functionSelector}`;
323
+ const culprit = `${contractAddress}:${callRequest.functionSelector}`;
330
324
  context.revert(phase, result.revertReason, culprit); // throws if in setup (non-revertible) phase
331
325
  }
332
326
 
@@ -342,26 +336,26 @@ export class PublicTxSimulator {
342
336
  *
343
337
  * @param stateManager - The state manager for AvmSimulation
344
338
  * @param context - The context of the currently executing public transaction portion
345
- * @param executionRequest - The execution request (includes args)
339
+ * @param callRequest - The public function call request, including the calldata.
346
340
  * @param allocatedGas - The gas allocated to the enqueued call
347
341
  * @param fnName - The name of the function
348
342
  * @returns The result of execution.
349
343
  */
350
344
  @trackSpan(
351
345
  'PublicTxSimulator.simulateEnqueuedCallInternal',
352
- (_stateManager, _executionRequest, _allocatedGas, _transactionFee, fnName) => ({
346
+ (_stateManager, _callRequest, _allocatedGas, _transactionFee, fnName) => ({
353
347
  [Attributes.APP_CIRCUIT_NAME]: fnName,
354
348
  }),
355
349
  )
356
350
  private async simulateEnqueuedCallInternal(
357
351
  stateManager: AvmPersistableStateManager,
358
- executionRequest: PublicExecutionRequest,
352
+ { request, calldata }: PublicCallRequestWithCalldata,
359
353
  allocatedGas: Gas,
360
354
  transactionFee: Fr,
361
355
  fnName: string,
362
356
  ): Promise<AvmFinalizedCallResult> {
363
- const address = executionRequest.callContext.contractAddress;
364
- const sender = executionRequest.callContext.msgSender;
357
+ const address = request.contractAddress;
358
+ const sender = request.msgSender;
365
359
 
366
360
  this.log.debug(
367
361
  `Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`,
@@ -374,8 +368,8 @@ export class PublicTxSimulator {
374
368
  sender,
375
369
  transactionFee,
376
370
  this.globalVariables,
377
- executionRequest.callContext.isStaticCall,
378
- executionRequest.args,
371
+ request.isStaticCall,
372
+ calldata,
379
373
  allocatedGas,
380
374
  );
381
375
  const avmCallResult = await simulator.execute();
@@ -1,29 +1,13 @@
1
- import type { PublicCallRequest } from '@aztec/stdlib/kernel';
2
- import { type PublicExecutionRequest, type Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
1
+ import { PublicCallRequestWithCalldata, type Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
3
2
 
4
- export function getExecutionRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicExecutionRequest[] {
3
+ export function getCallRequestsWithCalldataByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequestWithCalldata[] {
5
4
  switch (phase) {
6
5
  case TxExecutionPhase.SETUP:
7
- return tx.getNonRevertiblePublicExecutionRequests();
6
+ return tx.getNonRevertiblePublicCallRequestsWithCalldata();
8
7
  case TxExecutionPhase.APP_LOGIC:
9
- return tx.getRevertiblePublicExecutionRequests();
8
+ return tx.getRevertiblePublicCallRequestsWithCalldata();
10
9
  case TxExecutionPhase.TEARDOWN: {
11
- const request = tx.getPublicTeardownExecutionRequest();
12
- return request ? [request] : [];
13
- }
14
- default:
15
- throw new Error(`Unknown phase: ${phase}`);
16
- }
17
- }
18
-
19
- export function getCallRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequest[] {
20
- switch (phase) {
21
- case TxExecutionPhase.SETUP:
22
- return tx.data.getNonRevertiblePublicCallRequests();
23
- case TxExecutionPhase.APP_LOGIC:
24
- return tx.data.getRevertiblePublicCallRequests();
25
- case TxExecutionPhase.TEARDOWN: {
26
- const request = tx.data.getTeardownPublicCallRequest();
10
+ const request = tx.getTeardownPublicCallRequestWithCalldata();
27
11
  return request ? [request] : [];
28
12
  }
29
13
  default:
@@ -1,108 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import type { Fr } from '@aztec/foundation/fields';
4
- import { type AvmExecutionHints, type ContractStorageRead, type ContractStorageUpdateRequest, type PublicDataUpdateRequest, PublicInnerCallRequest } from '@aztec/stdlib/avm';
5
- import type { SimulationError } from '@aztec/stdlib/errors';
6
- import { Gas } from '@aztec/stdlib/gas';
7
- import type { NoteHash, Nullifier, ReadRequest, TreeLeafReadRequest } from '@aztec/stdlib/kernel';
8
- import type { PublicLog } from '@aztec/stdlib/logs';
9
- import type { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
10
- import type { PublicExecutionRequest } from '@aztec/stdlib/tx';
11
- export interface PublicSideEffects {
12
- /** The contract storage update requests performed. */
13
- publicDataWrites: PublicDataUpdateRequest[];
14
- /** The new note hashes to be inserted into the note hashes tree. */
15
- noteHashes: NoteHash[];
16
- /** The new nullifiers to be inserted into the nullifier tree. */
17
- nullifiers: Nullifier[];
18
- /** The new l2 to l1 messages generated to be inserted into the messages tree. */
19
- l2ToL1Messages: ScopedL2ToL1Message[];
20
- /** Public logs emitted during execution. */
21
- publicLogs: PublicLog[];
22
- }
23
- export interface EnqueuedPublicCallExecutionResult {
24
- /** How much gas was left after this public execution. */
25
- endGasLeft: Gas;
26
- /** The side effect counter after execution */
27
- endSideEffectCounter: Fr;
28
- /** The return values of the function. */
29
- returnValues: Fr[];
30
- /** Whether the execution reverted. */
31
- reverted: boolean;
32
- /** The revert reason if the execution reverted. */
33
- revertReason?: SimulationError;
34
- }
35
- export interface EnqueuedPublicCallExecutionResultWithSideEffects {
36
- /** How much gas was left after this public execution. */
37
- endGasLeft: Gas;
38
- /** The side effect counter after execution */
39
- endSideEffectCounter: Fr;
40
- /** The return values of the function. */
41
- returnValues: Fr[];
42
- /** Whether the execution reverted. */
43
- reverted: boolean;
44
- /** The revert reason if the execution reverted. */
45
- revertReason?: SimulationError;
46
- /** The public side effects of the function. */
47
- sideEffects: PublicSideEffects;
48
- }
49
- /**
50
- * The public function execution result.
51
- */
52
- export interface PublicFunctionCallResult {
53
- /** The execution request that triggered this result. */
54
- executionRequest: PublicExecutionRequest;
55
- /** The side effect counter at the start of the function call. */
56
- startSideEffectCounter: Fr;
57
- /** The side effect counter after executing this function call */
58
- endSideEffectCounter: Fr;
59
- /** How much gas was available for this public execution. */
60
- startGasLeft: Gas;
61
- /** How much gas was left after this public execution. */
62
- endGasLeft: Gas;
63
- /** Transaction fee set for this tx. */
64
- transactionFee: Fr;
65
- /** Bytecode used for this execution. */
66
- bytecode?: Buffer;
67
- /** Calldata used for this execution. */
68
- calldata: Fr[];
69
- /** The return values of the function. */
70
- returnValues: Fr[];
71
- /** Whether the execution reverted. */
72
- reverted: boolean;
73
- /** The revert reason if the execution reverted. */
74
- revertReason?: SimulationError;
75
- /** The contract storage reads performed by the function. */
76
- contractStorageReads: ContractStorageRead[];
77
- /** The contract storage update requests performed by the function. */
78
- contractStorageUpdateRequests: ContractStorageUpdateRequest[];
79
- /** The new note hashes to be inserted into the note hashes tree. */
80
- noteHashes: NoteHash[];
81
- /** The new l2 to l1 messages generated in this call. */
82
- l2ToL1Messages: L2ToL1Message[];
83
- /** The new nullifiers to be inserted into the nullifier tree. */
84
- nullifiers: Nullifier[];
85
- /** The note hash read requests emitted in this call. */
86
- noteHashReadRequests: TreeLeafReadRequest[];
87
- /** The nullifier read requests emitted in this call. */
88
- nullifierReadRequests: ReadRequest[];
89
- /** The nullifier non existent read requests emitted in this call. */
90
- nullifierNonExistentReadRequests: ReadRequest[];
91
- /** L1 to L2 message read requests emitted in this call. */
92
- l1ToL2MsgReadRequests: TreeLeafReadRequest[];
93
- /**
94
- * The public logs emitted in this call.
95
- * Note: PublicLog has no counter - unsure if this is needed bc this struct is unused
96
- */
97
- publicLogs: PublicLog[];
98
- /** The requests to call public functions made by this call. */
99
- publicCallRequests: PublicInnerCallRequest[];
100
- /** The results of nested calls. */
101
- nestedExecutions: this[];
102
- /** Hints for proving AVM execution. */
103
- avmCircuitHints: AvmExecutionHints;
104
- /** The name of the function that was executed. Only used for logging. */
105
- functionName: string;
106
- }
107
- export declare function resultToPublicCallRequest(result: PublicFunctionCallResult): Promise<PublicInnerCallRequest>;
108
- //# sourceMappingURL=execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/public/execution.ts"],"names":[],"mappings":"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"}
@@ -1,9 +0,0 @@
1
- import { PublicCallStackItemCompressed, PublicInnerCallRequest, RevertCode } from '@aztec/stdlib/avm';
2
- import { Gas } from '@aztec/stdlib/gas';
3
- import { computeVarArgsHash } from '@aztec/stdlib/hash';
4
- export async function resultToPublicCallRequest(result) {
5
- const request = result.executionRequest;
6
- const item = new PublicCallStackItemCompressed(request.callContext.contractAddress, request.callContext, await computeVarArgsHash(request.args), await computeVarArgsHash(result.returnValues), // TODO(@just-mitch): need better mapping from simulator to revert code.
7
- result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK, Gas.from(result.startGasLeft), Gas.from(result.endGasLeft));
8
- return new PublicInnerCallRequest(item, result.startSideEffectCounter.toNumber());
9
- }
@@ -1,140 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import {
3
- type AvmExecutionHints,
4
- type ContractStorageRead,
5
- type ContractStorageUpdateRequest,
6
- PublicCallStackItemCompressed,
7
- type PublicDataUpdateRequest,
8
- PublicInnerCallRequest,
9
- RevertCode,
10
- } from '@aztec/stdlib/avm';
11
- import type { SimulationError } from '@aztec/stdlib/errors';
12
- import { Gas } from '@aztec/stdlib/gas';
13
- import { computeVarArgsHash } from '@aztec/stdlib/hash';
14
- import type { NoteHash, Nullifier, ReadRequest, TreeLeafReadRequest } from '@aztec/stdlib/kernel';
15
- import type { PublicLog } from '@aztec/stdlib/logs';
16
- import type { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
- import type { PublicExecutionRequest } from '@aztec/stdlib/tx';
18
-
19
- export interface PublicSideEffects {
20
- /** The contract storage update requests performed. */
21
- publicDataWrites: PublicDataUpdateRequest[];
22
- /** The new note hashes to be inserted into the note hashes tree. */
23
- noteHashes: NoteHash[];
24
- /** The new nullifiers to be inserted into the nullifier tree. */
25
- nullifiers: Nullifier[];
26
- /** The new l2 to l1 messages generated to be inserted into the messages tree. */
27
- l2ToL1Messages: ScopedL2ToL1Message[];
28
- /** Public logs emitted during execution. */
29
- publicLogs: PublicLog[];
30
- }
31
-
32
- export interface EnqueuedPublicCallExecutionResult {
33
- /** How much gas was left after this public execution. */
34
- endGasLeft: Gas;
35
- /** The side effect counter after execution */
36
- endSideEffectCounter: Fr;
37
-
38
- /** The return values of the function. */
39
- returnValues: Fr[];
40
- /** Whether the execution reverted. */
41
- reverted: boolean;
42
- /** The revert reason if the execution reverted. */
43
- revertReason?: SimulationError;
44
- }
45
-
46
- export interface EnqueuedPublicCallExecutionResultWithSideEffects {
47
- /** How much gas was left after this public execution. */
48
- endGasLeft: Gas;
49
- /** The side effect counter after execution */
50
- endSideEffectCounter: Fr;
51
-
52
- /** The return values of the function. */
53
- returnValues: Fr[];
54
- /** Whether the execution reverted. */
55
- reverted: boolean;
56
- /** The revert reason if the execution reverted. */
57
- revertReason?: SimulationError;
58
-
59
- /** The public side effects of the function. */
60
- sideEffects: PublicSideEffects;
61
- }
62
-
63
- /**
64
- * The public function execution result.
65
- */
66
- export interface PublicFunctionCallResult {
67
- /** The execution request that triggered this result. */
68
- executionRequest: PublicExecutionRequest;
69
-
70
- /** The side effect counter at the start of the function call. */
71
- startSideEffectCounter: Fr;
72
- /** The side effect counter after executing this function call */
73
- endSideEffectCounter: Fr;
74
- /** How much gas was available for this public execution. */
75
- startGasLeft: Gas;
76
- /** How much gas was left after this public execution. */
77
- endGasLeft: Gas;
78
- /** Transaction fee set for this tx. */
79
- transactionFee: Fr;
80
-
81
- /** Bytecode used for this execution. */
82
- bytecode?: Buffer;
83
- /** Calldata used for this execution. */
84
- calldata: Fr[];
85
- /** The return values of the function. */
86
- returnValues: Fr[];
87
- /** Whether the execution reverted. */
88
- reverted: boolean;
89
- /** The revert reason if the execution reverted. */
90
- revertReason?: SimulationError;
91
-
92
- /** The contract storage reads performed by the function. */
93
- contractStorageReads: ContractStorageRead[];
94
- /** The contract storage update requests performed by the function. */
95
- contractStorageUpdateRequests: ContractStorageUpdateRequest[];
96
- /** The new note hashes to be inserted into the note hashes tree. */
97
- noteHashes: NoteHash[];
98
- /** The new l2 to l1 messages generated in this call. */
99
- l2ToL1Messages: L2ToL1Message[];
100
- /** The new nullifiers to be inserted into the nullifier tree. */
101
- nullifiers: Nullifier[];
102
- /** The note hash read requests emitted in this call. */
103
- noteHashReadRequests: TreeLeafReadRequest[];
104
- /** The nullifier read requests emitted in this call. */
105
- nullifierReadRequests: ReadRequest[];
106
- /** The nullifier non existent read requests emitted in this call. */
107
- nullifierNonExistentReadRequests: ReadRequest[];
108
- /** L1 to L2 message read requests emitted in this call. */
109
- l1ToL2MsgReadRequests: TreeLeafReadRequest[];
110
- /**
111
- * The public logs emitted in this call.
112
- * Note: PublicLog has no counter - unsure if this is needed bc this struct is unused
113
- */
114
- publicLogs: PublicLog[];
115
- /** The requests to call public functions made by this call. */
116
- publicCallRequests: PublicInnerCallRequest[];
117
- /** The results of nested calls. */
118
- nestedExecutions: this[];
119
-
120
- /** Hints for proving AVM execution. */
121
- avmCircuitHints: AvmExecutionHints;
122
-
123
- /** The name of the function that was executed. Only used for logging. */
124
- functionName: string;
125
- }
126
-
127
- export async function resultToPublicCallRequest(result: PublicFunctionCallResult) {
128
- const request = result.executionRequest;
129
- const item = new PublicCallStackItemCompressed(
130
- request.callContext.contractAddress,
131
- request.callContext,
132
- await computeVarArgsHash(request.args),
133
- await computeVarArgsHash(result.returnValues),
134
- // TODO(@just-mitch): need better mapping from simulator to revert code.
135
- result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
136
- Gas.from(result.startGasLeft),
137
- Gas.from(result.endGasLeft),
138
- );
139
- return new PublicInnerCallRequest(item, result.startSideEffectCounter.toNumber());
140
- }