@aztec/simulator 0.81.0 → 0.82.1-alpha-testnet.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 (138) hide show
  1. package/dest/common/db_interfaces.d.ts +6 -12
  2. package/dest/common/db_interfaces.d.ts.map +1 -1
  3. package/dest/common/db_interfaces.js +1 -1
  4. package/dest/common/debug_fn_name.js +5 -2
  5. package/dest/common/message_load_oracle_inputs.d.ts +4 -0
  6. package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
  7. package/dest/common/message_load_oracle_inputs.js +9 -0
  8. package/dest/private/acvm/acvm.d.ts +6 -1
  9. package/dest/private/acvm/acvm.d.ts.map +1 -1
  10. package/dest/private/acvm/acvm.js +7 -13
  11. package/dest/private/acvm/deserialize.d.ts +0 -18
  12. package/dest/private/acvm/deserialize.d.ts.map +1 -1
  13. package/dest/private/acvm/deserialize.js +3 -24
  14. package/dest/private/acvm/oracle/oracle.d.ts +34 -34
  15. package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
  16. package/dest/private/acvm/oracle/oracle.js +116 -82
  17. package/dest/private/acvm/oracle/typed_oracle.d.ts +4 -4
  18. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
  19. package/dest/private/acvm/oracle/typed_oracle.js +8 -8
  20. package/dest/private/execution_data_provider.d.ts +3 -9
  21. package/dest/private/execution_data_provider.d.ts.map +1 -1
  22. package/dest/private/hashed_values_cache.d.ts +2 -2
  23. package/dest/private/hashed_values_cache.d.ts.map +1 -1
  24. package/dest/private/hashed_values_cache.js +5 -15
  25. package/dest/private/private_execution.d.ts +2 -2
  26. package/dest/private/private_execution.d.ts.map +1 -1
  27. package/dest/private/private_execution.js +4 -7
  28. package/dest/private/private_execution_oracle.d.ts +9 -37
  29. package/dest/private/private_execution_oracle.d.ts.map +1 -1
  30. package/dest/private/private_execution_oracle.js +32 -92
  31. package/dest/private/providers/acvm_native.d.ts +6 -4
  32. package/dest/private/providers/acvm_native.d.ts.map +1 -1
  33. package/dest/private/providers/acvm_native.js +6 -3
  34. package/dest/private/providers/acvm_wasm.d.ts +6 -7
  35. package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
  36. package/dest/private/providers/acvm_wasm.js +13 -15
  37. package/dest/private/providers/acvm_wasm_with_blobs.d.ts +5 -5
  38. package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
  39. package/dest/private/providers/acvm_wasm_with_blobs.js +7 -9
  40. package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +90 -0
  41. package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -0
  42. package/dest/private/providers/circuit_recording/circuit_recorder.js +246 -0
  43. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +18 -0
  44. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -0
  45. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +39 -0
  46. package/dest/private/providers/simulation_provider.d.ts +21 -7
  47. package/dest/private/providers/simulation_provider.d.ts.map +1 -1
  48. package/dest/private/simulator.d.ts +3 -2
  49. package/dest/private/simulator.d.ts.map +1 -1
  50. package/dest/private/simulator.js +14 -4
  51. package/dest/private/unconstrained_execution.d.ts +2 -2
  52. package/dest/private/unconstrained_execution.d.ts.map +1 -1
  53. package/dest/private/unconstrained_execution.js +1 -2
  54. package/dest/private/unconstrained_execution_oracle.d.ts +1 -1
  55. package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
  56. package/dest/private/unconstrained_execution_oracle.js +3 -3
  57. package/dest/public/avm/avm_simulator.d.ts.map +1 -1
  58. package/dest/public/avm/avm_simulator.js +0 -2
  59. package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -2
  60. package/dest/public/avm/fixtures/index.d.ts +2 -1
  61. package/dest/public/avm/fixtures/index.d.ts.map +1 -1
  62. package/dest/public/avm/fixtures/index.js +7 -12
  63. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +2 -2
  64. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
  65. package/dest/public/avm/fixtures/simple_contract_data_source.js +1 -1
  66. package/dest/public/avm/journal/journal.d.ts +2 -2
  67. package/dest/public/avm/journal/journal.d.ts.map +1 -1
  68. package/dest/public/avm/journal/journal.js +4 -4
  69. package/dest/public/avm/test_utils.js +1 -1
  70. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +2 -2
  71. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  72. package/dest/public/fixtures/public_tx_simulation_tester.js +27 -47
  73. package/dest/public/fixtures/utils.d.ts +2 -2
  74. package/dest/public/fixtures/utils.d.ts.map +1 -1
  75. package/dest/public/fixtures/utils.js +18 -22
  76. package/dest/public/index.d.ts +1 -2
  77. package/dest/public/index.d.ts.map +1 -1
  78. package/dest/public/index.js +1 -1
  79. package/dest/public/public_db_sources.d.ts +1 -1
  80. package/dest/public/public_db_sources.d.ts.map +1 -1
  81. package/dest/public/public_db_sources.js +4 -4
  82. package/dest/public/public_processor/public_processor.js +1 -1
  83. package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -10
  84. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  85. package/dest/public/public_tx_simulator/public_tx_context.js +4 -22
  86. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +2 -3
  87. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  88. package/dest/public/public_tx_simulator/public_tx_simulator.js +20 -24
  89. package/dest/public/utils.d.ts +2 -4
  90. package/dest/public/utils.d.ts.map +1 -1
  91. package/dest/public/utils.js +4 -21
  92. package/dest/testing.d.ts +2 -0
  93. package/dest/testing.d.ts.map +1 -0
  94. package/dest/testing.js +1 -0
  95. package/package.json +15 -14
  96. package/src/common/db_interfaces.ts +6 -13
  97. package/src/common/debug_fn_name.ts +5 -5
  98. package/src/common/message_load_oracle_inputs.ts +8 -0
  99. package/src/private/acvm/acvm.ts +8 -24
  100. package/src/private/acvm/deserialize.ts +3 -30
  101. package/src/private/acvm/oracle/oracle.ts +148 -144
  102. package/src/private/acvm/oracle/typed_oracle.ts +12 -14
  103. package/src/private/execution_data_provider.ts +6 -10
  104. package/src/private/hashed_values_cache.ts +6 -14
  105. package/src/private/private_execution.ts +11 -11
  106. package/src/private/private_execution_oracle.ts +39 -138
  107. package/src/private/providers/acvm_native.ts +17 -6
  108. package/src/private/providers/acvm_wasm.ts +27 -20
  109. package/src/private/providers/acvm_wasm_with_blobs.ts +15 -12
  110. package/src/private/providers/circuit_recording/circuit_recorder.ts +283 -0
  111. package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +82 -0
  112. package/src/private/providers/simulation_provider.ts +30 -5
  113. package/src/private/simulator.ts +19 -5
  114. package/src/private/unconstrained_execution.ts +8 -4
  115. package/src/private/unconstrained_execution_oracle.ts +3 -6
  116. package/src/public/avm/avm_simulator.ts +0 -2
  117. package/src/public/avm/fixtures/avm_simulation_tester.ts +2 -2
  118. package/src/public/avm/fixtures/index.ts +15 -17
  119. package/src/public/avm/fixtures/simple_contract_data_source.ts +2 -2
  120. package/src/public/avm/journal/journal.ts +7 -7
  121. package/src/public/avm/test_utils.ts +1 -1
  122. package/src/public/fixtures/public_tx_simulation_tester.ts +31 -88
  123. package/src/public/fixtures/utils.ts +28 -26
  124. package/src/public/index.ts +1 -2
  125. package/src/public/public_db_sources.ts +4 -4
  126. package/src/public/public_processor/public_processor.ts +1 -1
  127. package/src/public/public_tx_simulator/public_tx_context.ts +12 -32
  128. package/src/public/public_tx_simulator/public_tx_simulator.ts +24 -30
  129. package/src/public/utils.ts +5 -21
  130. package/src/testing.ts +1 -0
  131. package/dest/public/avm/bytecode_utils.d.ts +0 -5
  132. package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
  133. package/dest/public/avm/bytecode_utils.js +0 -17
  134. package/dest/public/execution.d.ts +0 -108
  135. package/dest/public/execution.d.ts.map +0 -1
  136. package/dest/public/execution.js +0 -9
  137. package/src/public/avm/bytecode_utils.ts +0 -17
  138. package/src/public/execution.ts +0 -140
@@ -8,7 +8,7 @@ import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
8
8
  import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
9
9
  import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
10
10
  import { ExecutionError, resolveAssertionMessageFromError } from '../common/errors.js';
11
- import { fromACVMField, witnessMapToFields } from './acvm/deserialize.js';
11
+ import { witnessMapToFields } from './acvm/deserialize.js';
12
12
  import { Oracle, extractCallStack } from './acvm/index.js';
13
13
  /**
14
14
  * Execute a private function and return the execution result.
@@ -17,11 +17,10 @@ import { Oracle, extractCallStack } from './acvm/index.js';
17
17
  log.verbose(`Executing private function ${functionName}`, {
18
18
  contract: contractAddress
19
19
  });
20
- const acir = artifact.bytecode;
21
20
  const initialWitness = privateExecutionOracle.getInitialWitness(artifact);
22
21
  const acvmCallback = new Oracle(privateExecutionOracle);
23
22
  const timer = new Timer();
24
- const acirExecutionResult = await simulator.executeUserCircuit(acir, initialWitness, acvmCallback).catch((err)=>{
23
+ const acirExecutionResult = await simulator.executeUserCircuit(initialWitness, artifact, acvmCallback).catch((err)=>{
25
24
  err.message = resolveAssertionMessageFromError(err, artifact);
26
25
  throw new ExecutionError(err.message, {
27
26
  contractAddress,
@@ -49,10 +48,8 @@ import { Oracle, extractCallStack } from './acvm/index.js';
49
48
  const newNotes = privateExecutionOracle.getNewNotes();
50
49
  const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
51
50
  const nestedExecutions = privateExecutionOracle.getNestedExecutions();
52
- const enqueuedPublicFunctionCalls = privateExecutionOracle.getEnqueuedPublicFunctionCalls();
53
- const publicTeardownFunctionCall = privateExecutionOracle.getPublicTeardownFunctionCall();
54
51
  log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
55
- return new PrivateCallExecutionResult(acir, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, noteHashLeafIndexMap, newNotes, noteHashNullifierCounterMap, rawReturnValues, nestedExecutions, enqueuedPublicFunctionCalls, publicTeardownFunctionCall, contractClassLogs);
52
+ return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, noteHashLeafIndexMap, newNotes, noteHashNullifierCounterMap, rawReturnValues, nestedExecutions, contractClassLogs);
56
53
  }
57
54
  /**
58
55
  * Get the private circuit public inputs from the partial witness.
@@ -69,7 +66,7 @@ import { Oracle, extractCallStack } from './acvm/index.js';
69
66
  if (returnedField === undefined) {
70
67
  throw new Error(`Missing return value for index ${i}`);
71
68
  }
72
- returnData.push(fromACVMField(returnedField));
69
+ returnData.push(Fr.fromString(returnedField));
73
70
  }
74
71
  return PrivateCircuitPublicInputs.fromFields(returnData);
75
72
  }
@@ -4,7 +4,7 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { ContractClassLog } from '@aztec/stdlib/logs';
6
6
  import { type NoteStatus } from '@aztec/stdlib/note';
7
- import { type BlockHeader, CallContext, Capsule, CountedContractClassLog, CountedPublicExecutionRequest, NoteAndSlot, PrivateCallExecutionResult, PublicExecutionRequest, type TxContext } from '@aztec/stdlib/tx';
7
+ import { type BlockHeader, CallContext, Capsule, CountedContractClassLog, NoteAndSlot, PrivateCallExecutionResult, type TxContext } from '@aztec/stdlib/tx';
8
8
  import { type NoteData } from './acvm/index.js';
9
9
  import type { ExecutionDataProvider } from './execution_data_provider.js';
10
10
  import type { ExecutionNoteCache } from './execution_note_cache.js';
@@ -24,7 +24,7 @@ export declare class PrivateExecutionOracle extends UnconstrainedExecutionOracle
24
24
  private readonly executionCache;
25
25
  private readonly noteCache;
26
26
  private provider;
27
- private totalPublicArgsCount;
27
+ private totalPublicCalldataCount;
28
28
  protected sideEffectCounter: number;
29
29
  /**
30
30
  * New notes created during this execution.
@@ -47,13 +47,11 @@ export declare class PrivateExecutionOracle extends UnconstrainedExecutionOracle
47
47
  private noteHashNullifierCounterMap;
48
48
  private contractClassLogs;
49
49
  private nestedExecutions;
50
- private enqueuedPublicFunctionCalls;
51
- private publicTeardownFunctionCall;
52
50
  constructor(argsHash: Fr, txContext: TxContext, callContext: CallContext,
53
51
  /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
54
52
  historicalHeader: BlockHeader,
55
53
  /** List of transient auth witnesses to be used during this simulation */
56
- authWitnesses: AuthWitness[], capsules: Capsule[], executionCache: HashedValuesCache, noteCache: ExecutionNoteCache, executionDataProvider: ExecutionDataProvider, provider: SimulationProvider, totalPublicArgsCount: number, sideEffectCounter?: number, log?: import("@aztec/foundation/log").Logger, scopes?: AztecAddress[]);
54
+ authWitnesses: AuthWitness[], capsules: Capsule[], executionCache: HashedValuesCache, noteCache: ExecutionNoteCache, executionDataProvider: ExecutionDataProvider, provider: SimulationProvider, totalPublicCalldataCount: number, sideEffectCounter?: number, log?: import("@aztec/foundation/log").Logger, scopes?: AztecAddress[]);
57
55
  /**
58
56
  * Writes the function inputs to the initial witness.
59
57
  * @param abi - The function ABI.
@@ -78,20 +76,12 @@ export declare class PrivateExecutionOracle extends UnconstrainedExecutionOracle
78
76
  * Return the nested execution results during this execution.
79
77
  */
80
78
  getNestedExecutions(): PrivateCallExecutionResult[];
81
- /**
82
- * Return the enqueued public function calls during this execution.
83
- */
84
- getEnqueuedPublicFunctionCalls(): CountedPublicExecutionRequest[];
85
- /**
86
- * Return the public teardown function call set during this execution.
87
- */
88
- getPublicTeardownFunctionCall(): PublicExecutionRequest;
89
79
  /**
90
80
  * Store values in the execution cache.
91
81
  * @param values - Values to store.
92
82
  * @returns The hash of the values.
93
83
  */
94
- storeInExecutionCache(values: Fr[]): Promise<Fr>;
84
+ storeInExecutionCache(values: Fr[], hash: Fr): void;
95
85
  /**
96
86
  * Gets values from the execution cache.
97
87
  * @param hash - Hash of the values.
@@ -166,39 +156,21 @@ export declare class PrivateExecutionOracle extends UnconstrainedExecutionOracle
166
156
  returnsHash: Fr;
167
157
  }>;
168
158
  /**
169
- * Creates a PublicExecutionRequest object representing the request to call a public function.
170
- * @param targetContractAddress - The address of the contract to call.
171
- * @param functionSelector - The function selector of the function to call.
172
- * @param argsHash - The arguments hash to pass to the function.
173
- * @param sideEffectCounter - The side effect counter at the start of the call.
174
- * @param isStaticCall - Whether the call is a static call.
175
- * @returns The public call stack item with the request information.
176
- */
177
- protected createPublicExecutionRequest(callType: 'enqueued' | 'teardown', targetContractAddress: AztecAddress, functionSelector: FunctionSelector, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<void>;
178
- /**
179
- * Creates and enqueues a PublicExecutionRequest object representing the request to call a public function. No function
180
- * is actually called, since that must happen on the sequencer side. All the fields related to the result
181
- * of the execution are empty.
159
+ * Verify relevant information when a public function is enqueued.
182
160
  * @param targetContractAddress - The address of the contract to call.
183
- * @param functionSelector - The function selector of the function to call.
184
- * @param argsHash - The arguments hash to pass to the function.
161
+ * @param calldataHash - The hash of the function selector and arguments.
185
162
  * @param sideEffectCounter - The side effect counter at the start of the call.
186
163
  * @param isStaticCall - Whether the call is a static call.
187
- * @returns The public call stack item with the request information.
188
164
  */
189
- enqueuePublicFunctionCall(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<Fr>;
165
+ notifyEnqueuedPublicFunctionCall(_targetContractAddress: AztecAddress, calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
190
166
  /**
191
- * Creates a PublicExecutionRequest and sets it as the public teardown function. No function
192
- * is actually called, since that must happen on the sequencer side. All the fields related to the result
193
- * of the execution are empty.
167
+ * Verify relevant information when a public teardown function is set.
194
168
  * @param targetContractAddress - The address of the contract to call.
195
- * @param functionSelector - The function selector of the function to call.
196
169
  * @param argsHash - The arguments hash to pass to the function.
197
170
  * @param sideEffectCounter - The side effect counter at the start of the call.
198
171
  * @param isStaticCall - Whether the call is a static call.
199
- * @returns The public call stack item with the request information.
200
172
  */
201
- setPublicTeardownFunctionCall(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<Fr>;
173
+ notifySetPublicTeardownFunctionCall(_targetContractAddress: AztecAddress, calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
202
174
  notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
203
175
  /**
204
176
  * Derives the call context for a nested execution.
@@ -1 +1 @@
1
- {"version":3,"file":"private_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/private_execution_oracle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,KAAK,WAAW,EAEhB,gBAAgB,EAChB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,WAAW,EAChB,WAAW,EACX,OAAO,EACP,uBAAuB,EACvB,6BAA6B,EAC7B,WAAW,EACX,0BAA0B,EAC1B,sBAAsB,EACtB,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,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;;;;;OAMG;IACa,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM;IAoBpF;;;;;;;;OAQG;IACY,mBAAmB,CAChC,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO;;;;IA6DvB;;;;;;;;OAQG;cACa,4BAA4B,CAC1C,QAAQ,EAAE,UAAU,GAAG,UAAU,EACjC,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO;IAgCvB;;;;;;;;;;OAUG;IACmB,yBAAyB,CAC7C,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,EAAE,CAAC;IAwBd;;;;;;;;;;OAUG;IACmB,6BAA6B,CACjD,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,EAAE,EACZ,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,EAAE,CAAC;IAsBE,uCAAuC,CAAC,8BAA8B,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9G;;;;;;OAMG;YACW,iBAAiB;IAaxB,oBAAoB;IAIL,sCAAsC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY;IAIpF,SAAS;CAgBhC"}
1
+ {"version":3,"file":"private_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/private_execution_oracle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,KAAK,WAAW,EAEhB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;CAgBhC"}
@@ -1,4 +1,4 @@
1
- import { MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH, PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
1
+ import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
@@ -6,7 +6,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import { computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
7
7
  import { PrivateContextInputs } from '@aztec/stdlib/kernel';
8
8
  import { Note } from '@aztec/stdlib/note';
9
- import { CallContext, CountedContractClassLog, CountedPublicExecutionRequest, NoteAndSlot, PublicExecutionRequest } from '@aztec/stdlib/tx';
9
+ import { CallContext, CountedContractClassLog, NoteAndSlot } from '@aztec/stdlib/tx';
10
10
  import { toACVMWitness } from './acvm/index.js';
11
11
  import { pickNotes } from './pick_notes.js';
12
12
  import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
@@ -21,7 +21,7 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
21
21
  executionCache;
22
22
  noteCache;
23
23
  provider;
24
- totalPublicArgsCount;
24
+ totalPublicCalldataCount;
25
25
  sideEffectCounter;
26
26
  /**
27
27
  * New notes created during this execution.
@@ -42,10 +42,8 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
42
42
  noteHashNullifierCounterMap;
43
43
  contractClassLogs;
44
44
  nestedExecutions;
45
- enqueuedPublicFunctionCalls;
46
- publicTeardownFunctionCall;
47
- constructor(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ historicalHeader, /** List of transient auth witnesses to be used during this simulation */ authWitnesses, capsules, executionCache, noteCache, executionDataProvider, provider, totalPublicArgsCount, sideEffectCounter = 0, log = createLogger('simulator:client_execution_context'), scopes){
48
- super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes), this.argsHash = argsHash, this.txContext = txContext, this.callContext = callContext, this.historicalHeader = historicalHeader, this.executionCache = executionCache, this.noteCache = noteCache, this.provider = provider, this.totalPublicArgsCount = totalPublicArgsCount, this.sideEffectCounter = sideEffectCounter, this.newNotes = [], this.noteHashLeafIndexMap = new Map(), this.noteHashNullifierCounterMap = new Map(), this.contractClassLogs = [], this.nestedExecutions = [], this.enqueuedPublicFunctionCalls = [], this.publicTeardownFunctionCall = PublicExecutionRequest.empty();
45
+ constructor(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ historicalHeader, /** List of transient auth witnesses to be used during this simulation */ authWitnesses, capsules, executionCache, noteCache, executionDataProvider, provider, totalPublicCalldataCount, sideEffectCounter = 0, log = createLogger('simulator:client_execution_context'), scopes){
46
+ super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes), this.argsHash = argsHash, this.txContext = txContext, this.callContext = callContext, this.historicalHeader = historicalHeader, this.executionCache = executionCache, this.noteCache = noteCache, this.provider = provider, this.totalPublicCalldataCount = totalPublicCalldataCount, this.sideEffectCounter = sideEffectCounter, this.newNotes = [], this.noteHashLeafIndexMap = new Map(), this.noteHashNullifierCounterMap = new Map(), this.contractClassLogs = [], this.nestedExecutions = [];
49
47
  }
50
48
  // We still need this function until we can get user-defined ordering of structs for fn arguments
51
49
  // TODO When that is sorted out on noir side, we can use instead the utilities in serialize.ts
@@ -56,8 +54,8 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
56
54
  */ getInitialWitness(abi) {
57
55
  const argumentsSize = countArgumentsSize(abi);
58
56
  const args = this.executionCache.getPreimage(this.argsHash);
59
- if (args.length !== argumentsSize) {
60
- throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args.length}`);
57
+ if (args?.length !== argumentsSize) {
58
+ throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args?.length}`);
61
59
  }
62
60
  const privateContextInputs = new PrivateContextInputs(this.callContext, this.historicalHeader, this.txContext, this.sideEffectCounter);
63
61
  const privateContextInputsAsFields = privateContextInputs.toFields();
@@ -95,28 +93,22 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
95
93
  return this.nestedExecutions;
96
94
  }
97
95
  /**
98
- * Return the enqueued public function calls during this execution.
99
- */ getEnqueuedPublicFunctionCalls() {
100
- return this.enqueuedPublicFunctionCalls;
101
- }
102
- /**
103
- * Return the public teardown function call set during this execution.
104
- */ getPublicTeardownFunctionCall() {
105
- return this.publicTeardownFunctionCall;
106
- }
107
- /**
108
96
  * Store values in the execution cache.
109
97
  * @param values - Values to store.
110
98
  * @returns The hash of the values.
111
- */ storeInExecutionCache(values) {
112
- return this.executionCache.store(values);
99
+ */ storeInExecutionCache(values, hash) {
100
+ return this.executionCache.store(values, hash);
113
101
  }
114
102
  /**
115
103
  * Gets values from the execution cache.
116
104
  * @param hash - Hash of the values.
117
105
  * @returns The values.
118
106
  */ loadFromExecutionCache(hash) {
119
- return Promise.resolve(this.executionCache.getPreimage(hash));
107
+ const preimage = this.executionCache.getPreimage(hash);
108
+ if (!preimage) {
109
+ throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
110
+ }
111
+ return Promise.resolve(preimage);
120
112
  }
121
113
  /**
122
114
  * Gets some notes for a storage slot.
@@ -260,7 +252,7 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
260
252
  const targetArtifact = await this.executionDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
261
253
  const derivedTxContext = this.txContext.clone();
262
254
  const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
263
- const context = new PrivateExecutionOracle(argsHash, derivedTxContext, derivedCallContext, this.historicalHeader, this.authWitnesses, this.capsules, this.executionCache, this.noteCache, this.executionDataProvider, this.provider, this.totalPublicArgsCount, sideEffectCounter, this.log, this.scopes);
255
+ const context = new PrivateExecutionOracle(argsHash, derivedTxContext, derivedCallContext, this.historicalHeader, this.authWitnesses, this.capsules, this.executionCache, this.noteCache, this.executionDataProvider, this.provider, this.totalPublicCalldataCount, sideEffectCounter, this.log, this.scopes);
264
256
  const childExecutionResult = await executePrivateFunction(this.provider, context, targetArtifact, targetContractAddress, functionSelector);
265
257
  if (isStaticCall) {
266
258
  this.#checkValidStaticCall(childExecutionResult);
@@ -272,87 +264,35 @@ import { UnconstrainedExecutionOracle } from './unconstrained_execution_oracle.j
272
264
  returnsHash: publicInputs.returnsHash
273
265
  };
274
266
  }
275
- /**
276
- * Creates a PublicExecutionRequest object representing the request to call a public function.
277
- * @param targetContractAddress - The address of the contract to call.
278
- * @param functionSelector - The function selector of the function to call.
279
- * @param argsHash - The arguments hash to pass to the function.
280
- * @param sideEffectCounter - The side effect counter at the start of the call.
281
- * @param isStaticCall - Whether the call is a static call.
282
- * @returns The public call stack item with the request information.
283
- */ async createPublicExecutionRequest(callType, targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
284
- const targetArtifact = await this.executionDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
285
- const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
286
- const args = this.executionCache.getPreimage(argsHash);
287
- this.log.verbose(`Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`, {
288
- sideEffectCounter,
289
- isStaticCall,
290
- functionSelector,
291
- targetContractAddress,
292
- callType
293
- });
294
- const request = PublicExecutionRequest.from({
295
- args,
296
- callContext: derivedCallContext
297
- });
298
- if (callType === 'enqueued') {
299
- this.enqueuedPublicFunctionCalls.push(new CountedPublicExecutionRequest(request, sideEffectCounter));
300
- } else {
301
- this.publicTeardownFunctionCall = request;
267
+ #onNewPublicFunctionCall(calldataHash) {
268
+ const calldata = this.executionCache.getPreimage(calldataHash);
269
+ if (!calldata) {
270
+ throw new Error('Calldata for public call not found in cache');
271
+ }
272
+ this.totalPublicCalldataCount += calldata.length;
273
+ if (this.totalPublicCalldataCount > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
274
+ throw new Error(`Too many total args to all enqueued public calls! (> ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS})`);
302
275
  }
303
276
  }
304
277
  /**
305
- * Creates and enqueues a PublicExecutionRequest object representing the request to call a public function. No function
306
- * is actually called, since that must happen on the sequencer side. All the fields related to the result
307
- * of the execution are empty.
278
+ * Verify relevant information when a public function is enqueued.
308
279
  * @param targetContractAddress - The address of the contract to call.
309
- * @param functionSelector - The function selector of the function to call.
310
- * @param argsHash - The arguments hash to pass to the function.
280
+ * @param calldataHash - The hash of the function selector and arguments.
311
281
  * @param sideEffectCounter - The side effect counter at the start of the call.
312
282
  * @param isStaticCall - Whether the call is a static call.
313
- * @returns The public call stack item with the request information.
314
- */ async enqueuePublicFunctionCall(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
315
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
316
- // WARNING: This is insecure and should be temporary!
317
- // The oracle re-hashes the arguments and returns a new args_hash.
318
- // new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
319
- // We don't validate or compute it in the circuit because a) it's harder to do with slices, and
320
- // b) this is only temporary.
321
- const newArgs = [
322
- functionSelector.toField(),
323
- ...this.executionCache.getPreimage(argsHash)
324
- ];
325
- const newArgsHash = await this.executionCache.store(newArgs);
326
- await this.createPublicExecutionRequest('enqueued', targetContractAddress, FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)), newArgsHash, sideEffectCounter, isStaticCall);
327
- this.totalPublicArgsCount += newArgs.length;
328
- if (this.totalPublicArgsCount > MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS) {
329
- throw new Error(`Too many total args to all enqueued public calls! (> ${MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS})`);
330
- }
331
- return newArgsHash;
283
+ */ notifyEnqueuedPublicFunctionCall(_targetContractAddress, calldataHash, _sideEffectCounter, _isStaticCall) {
284
+ this.#onNewPublicFunctionCall(calldataHash);
285
+ return Promise.resolve();
332
286
  }
333
287
  /**
334
- * Creates a PublicExecutionRequest and sets it as the public teardown function. No function
335
- * is actually called, since that must happen on the sequencer side. All the fields related to the result
336
- * of the execution are empty.
288
+ * Verify relevant information when a public teardown function is set.
337
289
  * @param targetContractAddress - The address of the contract to call.
338
- * @param functionSelector - The function selector of the function to call.
339
290
  * @param argsHash - The arguments hash to pass to the function.
340
291
  * @param sideEffectCounter - The side effect counter at the start of the call.
341
292
  * @param isStaticCall - Whether the call is a static call.
342
- * @returns The public call stack item with the request information.
343
- */ async setPublicTeardownFunctionCall(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
344
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Fix this.
345
- // WARNING: This is insecure and should be temporary!
346
- // The oracle rehashes the arguments and returns a new args_hash.
347
- // new_args = [selector, ...old_args], so as to make it suitable to call the public dispatch function.
348
- // We don't validate or compute it in the circuit because a) it's harder to do with slices, and
349
- // b) this is only temporary.
350
- const newArgsHash = await this.executionCache.store([
351
- functionSelector.toField(),
352
- ...this.executionCache.getPreimage(argsHash)
353
- ]);
354
- await this.createPublicExecutionRequest('teardown', targetContractAddress, FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)), newArgsHash, sideEffectCounter, isStaticCall);
355
- return newArgsHash;
293
+ */ notifySetPublicTeardownFunctionCall(_targetContractAddress, calldataHash, _sideEffectCounter, _isStaticCall) {
294
+ this.#onNewPublicFunctionCall(calldataHash);
295
+ return Promise.resolve();
356
296
  }
357
297
  notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter) {
358
298
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { WitnessMap } from '@aztec/noir-types';
4
- import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
3
+ import type { WitnessMap } from '@aztec/noir-acvm_js';
4
+ import type { ForeignCallHandler } from '@aztec/noir-protocol-circuits-types/types';
5
+ import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
6
+ import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
5
7
  import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
6
8
  import type { ACVMWitness } from '../acvm/acvm_types.js';
7
9
  import type { SimulationProvider } from './simulation_provider.js';
@@ -34,7 +36,7 @@ export declare class NativeACVMSimulator implements SimulationProvider {
34
36
  private pathToAcvm;
35
37
  private witnessFilename?;
36
38
  constructor(workingDirectory: string, pathToAcvm: string, witnessFilename?: string | undefined);
37
- executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
38
- executeUserCircuit(_acir: Buffer, _initialWitness: ACVMWitness, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
39
+ executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMWitness>;
40
+ executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
39
41
  }
40
42
  //# sourceMappingURL=acvm_native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acvm_native.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_native.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uB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AAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC;IA6BvB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
@@ -119,11 +119,14 @@ export class NativeACVMSimulator {
119
119
  this.pathToAcvm = pathToAcvm;
120
120
  this.witnessFilename = witnessFilename;
121
121
  }
122
- async executeProtocolCircuit(input, compiledCircuit) {
122
+ async executeProtocolCircuit(input, artifact, callback) {
123
123
  // Execute the circuit on those initial witness values
124
+ if (callback) {
125
+ throw new Error('Native ACVM simulator does not support foreign calls. Ignoring callback.');
126
+ }
124
127
  const operation = async (directory)=>{
125
128
  // Decode the bytecode from base64 since the acvm does not know about base64 encoding
126
- const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
129
+ const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
127
130
  // Execute the circuit
128
131
  const result = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm, this.witnessFilename);
129
132
  if (result.status == 1) {
@@ -133,7 +136,7 @@ export class NativeACVMSimulator {
133
136
  };
134
137
  return await runInDirectory(this.workingDirectory, operation, false, logger);
135
138
  }
136
- executeUserCircuit(_acir, _initialWitness, _callback) {
139
+ executeUserCircuit(_input, _artifact, _callback) {
137
140
  throw new Error('Not implemented');
138
141
  }
139
142
  }
@@ -1,15 +1,14 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import type { WitnessMap } from '@aztec/noir-types';
4
- import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
5
- import { type ACIRCallback } from '../acvm/acvm.js';
1
+ import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
2
+ import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
3
+ import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
4
+ import { type ACIRCallback, type ACIRExecutionResult } from '../acvm/acvm.js';
6
5
  import type { ACVMWitness } from '../acvm/acvm_types.js';
7
6
  import { type SimulationProvider } from './simulation_provider.js';
8
7
  export declare class WASMSimulator implements SimulationProvider {
9
8
  protected log: import("@aztec/foundation/log").Logger;
10
9
  constructor(log?: import("@aztec/foundation/log").Logger);
11
10
  init(): Promise<void>;
12
- executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
13
- executeUserCircuit(acir: Buffer, initialWitness: ACVMWitness, callback: ACIRCallback): Promise<import("../acvm/acvm.js").ACIRExecutionResult>;
11
+ executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<ACVMWitness>;
12
+ executeUserCircuit(input: ACVMWitness, artifact: FunctionArtifactWithContractName, callback: ACIRCallback): Promise<ACIRExecutionResult>;
14
13
  }
15
14
  //# sourceMappingURL=acvm_wasm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF,qBAAa,aAAc,YAAW,kBAAkB;IAC1C,SAAS,CAAC,GAAG;gBAAH,GAAG,yCAAiC;IAEpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAiCpG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY;CAI3F"}
1
+ {"version":3,"file":"acvm_wasm.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm.ts"],"names":[],"mappings":"AACA,OAAiB,EAAuB,KAAK,kBAAkB,EAAkB,MAAM,qBAAqB,CAAC;AAE7G,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAQ,MAAM,iBAAiB,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF,qBAAa,aAAc,YAAW,kBAAkB;IAC1C,SAAS,CAAC,GAAG;gBAAH,GAAG,yCAAiC;IAEpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,sBAAsB,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAiCjB,kBAAkB,CACtB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC;CAIhC"}
@@ -1,7 +1,6 @@
1
1
  import { createLogger } from '@aztec/foundation/log';
2
2
  import initACVM, { executeCircuit } from '@aztec/noir-acvm_js';
3
3
  import initAbi from '@aztec/noir-noirc_abi';
4
- import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
5
4
  import { acvm } from '../acvm/acvm.js';
6
5
  import { enrichNoirError } from './simulation_provider.js';
7
6
  export class WASMSimulator {
@@ -20,43 +19,42 @@ export class WASMSimulator {
20
19
  ]);
21
20
  }
22
21
  }
23
- async executeProtocolCircuit(input, compiledCircuit) {
22
+ async executeProtocolCircuit(input, artifact, callback) {
24
23
  this.log.debug('init', {
25
- hash: compiledCircuit.hash
24
+ hash: artifact.hash
26
25
  });
27
26
  await this.init();
28
- // Execute the circuit on those initial witness values
29
- //
30
27
  // Decode the bytecode from base64 since the acvm does not know about base64 encoding
31
- const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
28
+ const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
32
29
  //
33
30
  // Execute the circuit
34
31
  try {
35
- const _witnessMap = await executeCircuit(decodedBytecode, input, foreignCallHandler);
32
+ const result = await executeCircuit(decodedBytecode, input, callback);
36
33
  this.log.debug('execution successful', {
37
- hash: compiledCircuit.hash
34
+ hash: artifact.hash
38
35
  });
39
- return _witnessMap;
36
+ return result;
40
37
  } catch (err) {
41
- // Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
38
+ // Typescript types caught errors as unknown or any, so we need to narrow its type to check if it has raw
39
+ // assertion payload.
42
40
  if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
43
- const parsed = enrichNoirError(compiledCircuit, err);
41
+ const parsed = enrichNoirError(artifact, err);
44
42
  this.log.debug('execution failed', {
45
- hash: compiledCircuit.hash,
43
+ hash: artifact.hash,
46
44
  error: parsed,
47
45
  message: parsed.message
48
46
  });
49
47
  throw parsed;
50
48
  }
51
49
  this.log.debug('execution failed', {
52
- hash: compiledCircuit.hash,
50
+ hash: artifact.hash,
53
51
  error: err
54
52
  });
55
53
  throw new Error(`Circuit execution failed: ${err}`);
56
54
  }
57
55
  }
58
- async executeUserCircuit(acir, initialWitness, callback) {
56
+ async executeUserCircuit(input, artifact, callback) {
59
57
  await this.init();
60
- return acvm(acir, initialWitness, callback);
58
+ return acvm(artifact.bytecode, input, callback);
61
59
  }
62
60
  }
@@ -1,7 +1,7 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ import { type ForeignCallHandler } from '@aztec/noir-acvm_js';
3
2
  import type { WitnessMap } from '@aztec/noir-types';
4
- import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
3
+ import type { FunctionArtifactWithContractName } from '@aztec/stdlib/abi';
4
+ import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
5
5
  import type { ACIRCallback, ACIRExecutionResult } from '../acvm/acvm.js';
6
6
  import type { ACVMWitness } from '../acvm/acvm_types.js';
7
7
  import { type SimulationProvider } from './simulation_provider.js';
@@ -13,7 +13,7 @@ import { type SimulationProvider } from './simulation_provider.js';
13
13
  * It is only used in the context of server-side code executing simulated protocol circuits.
14
14
  */
15
15
  export declare class WASMSimulatorWithBlobs implements SimulationProvider {
16
- executeProtocolCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap>;
17
- executeUserCircuit(_acir: Buffer, _initialWitness: ACVMWitness, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
16
+ executeProtocolCircuit(input: WitnessMap, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler): Promise<WitnessMap>;
17
+ executeUserCircuit(_input: ACVMWitness, _artifact: FunctionArtifactWithContractName, _callback: ACIRCallback): Promise<ACIRExecutionResult>;
18
18
  }
19
19
  //# sourceMappingURL=acvm_wasm_with_blobs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm_with_blobs.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;IACzD,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwB1G,kBAAkB,CAChB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
1
+ {"version":3,"file":"acvm_wasm_with_blobs.d.ts","sourceRoot":"","sources":["../../../src/private/providers/acvm_wasm_with_blobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,kBAAkB,EAAkB,MAAM,qBAAqB,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,0BAA0B,CAAC;AAEpF;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;IACzD,sBAAsB,CAC1B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,CAAC;IAuBtB,kBAAkB,CAChB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,gCAAgC,EAC3C,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,mBAAmB,CAAC;CAGhC"}
@@ -1,5 +1,4 @@
1
1
  import { executeCircuit } from '@aztec/noir-acvm_js';
2
- import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/server';
3
2
  import { enrichNoirError } from './simulation_provider.js';
4
3
  /**
5
4
  * A simulation provider that uses the WASM simulator with the ability to handle blobs via the foreign call handler.
@@ -8,25 +7,24 @@ import { enrichNoirError } from './simulation_provider.js';
8
7
  *
9
8
  * It is only used in the context of server-side code executing simulated protocol circuits.
10
9
  */ export class WASMSimulatorWithBlobs {
11
- async executeProtocolCircuit(input, compiledCircuit) {
12
- // Execute the circuit on those initial witness values
13
- //
10
+ async executeProtocolCircuit(input, artifact, callback) {
14
11
  // Decode the bytecode from base64 since the acvm does not know about base64 encoding
15
- const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
12
+ const decodedBytecode = Buffer.from(artifact.bytecode, 'base64');
16
13
  //
17
14
  // Execute the circuit
18
15
  try {
19
- const _witnessMap = await executeCircuit(decodedBytecode, input, foreignCallHandler);
16
+ const _witnessMap = await executeCircuit(decodedBytecode, input, callback);
20
17
  return _witnessMap;
21
18
  } catch (err) {
22
- // Typescript types catched errors as unknown or any, so we need to narrow its type to check if it has raw assertion payload.
19
+ // Typescript types caught errors as unknown or any, so we need to narrow its type to check if it has raw
20
+ // assertion payload.
23
21
  if (typeof err === 'object' && err !== null && 'rawAssertionPayload' in err) {
24
- throw enrichNoirError(compiledCircuit, err);
22
+ throw enrichNoirError(artifact, err);
25
23
  }
26
24
  throw new Error(`Circuit execution failed: ${err}`);
27
25
  }
28
26
  }
29
- executeUserCircuit(_acir, _initialWitness, _callback) {
27
+ executeUserCircuit(_input, _artifact, _callback) {
30
28
  throw new Error('Not implemented');
31
29
  }
32
30
  }