@aztec/simulator 0.87.2 → 0.87.3
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.
- package/dest/client.d.ts +2 -0
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +2 -0
- package/dest/private/acvm/acvm.d.ts +4 -0
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.d.ts +1 -1
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +2 -2
- package/dest/private/acvm/oracle/typed_oracle.d.ts +1 -1
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +2 -2
- package/dest/private/private_execution.d.ts.map +1 -1
- package/dest/private/private_execution.js +2 -1
- package/dest/private/private_execution_oracle.d.ts +1 -1
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +1 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +39 -19
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.js +90 -126
- package/dest/private/providers/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/providers/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +3 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +16 -11
- package/dest/private/utility_execution_oracle.d.ts +1 -1
- package/dest/private/utility_execution_oracle.d.ts.map +1 -1
- package/dest/private/utility_execution_oracle.js +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +1 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +6 -0
- package/dest/public/public_tx_simulator/apps_tests/amm_test.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/apps_tests/amm_test.js +27 -55
- package/dest/server.d.ts +2 -0
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +2 -0
- package/dest/testing.d.ts +1 -1
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +1 -1
- package/package.json +15 -15
- package/src/client.ts +2 -0
- package/src/private/acvm/acvm.ts +3 -0
- package/src/private/acvm/oracle/oracle.ts +2 -2
- package/src/private/acvm/oracle/typed_oracle.ts +2 -2
- package/src/private/private_execution.ts +1 -0
- package/src/private/private_execution_oracle.ts +1 -1
- package/src/private/providers/circuit_recording/circuit_recorder.ts +114 -136
- package/src/private/providers/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/providers/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +22 -14
- package/src/private/utility_execution_oracle.ts +1 -1
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +5 -0
- package/src/public/public_tx_simulator/apps_tests/amm_test.ts +49 -44
- package/src/server.ts +2 -0
- package/src/testing.ts +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
1
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
5
|
import { AMMContractArtifact } from '@aztec/noir-contracts.js/AMM';
|
|
@@ -137,6 +139,24 @@ async function addLiquidity(
|
|
|
137
139
|
const liquidityPartialNote = {
|
|
138
140
|
commitment: new Fr(99),
|
|
139
141
|
};
|
|
142
|
+
const refundToken0PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
143
|
+
refundToken0PartialNote,
|
|
144
|
+
amm.address,
|
|
145
|
+
);
|
|
146
|
+
const refundToken1PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
147
|
+
refundToken1PartialNote,
|
|
148
|
+
amm.address,
|
|
149
|
+
);
|
|
150
|
+
const liquidityPartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
151
|
+
liquidityPartialNote,
|
|
152
|
+
amm.address,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// We need to inject the validity commitments into the nullifier tree as that would be performed by the private token
|
|
156
|
+
// functions that are not invoked in this test.
|
|
157
|
+
await tester.insertNullifier(token0.address, refundToken0PartialNoteValidityCommitment);
|
|
158
|
+
await tester.insertNullifier(token1.address, refundToken1PartialNoteValidityCommitment);
|
|
159
|
+
await tester.insertNullifier(liquidityToken.address, liquidityPartialNoteValidityCommitment);
|
|
140
160
|
|
|
141
161
|
return await tester.simulateTxWithLabel(
|
|
142
162
|
/*txLabel=*/ 'AMM/add_liquidity',
|
|
@@ -150,13 +170,6 @@ async function addLiquidity(
|
|
|
150
170
|
args: [/*to=*/ amm.address, /*amount=*/ amount0Max],
|
|
151
171
|
address: token0.address,
|
|
152
172
|
},
|
|
153
|
-
// token0.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
154
|
-
{
|
|
155
|
-
sender: token0.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
156
|
-
fnName: '_store_balances_set_partial_note',
|
|
157
|
-
args: [refundToken0PartialNote],
|
|
158
|
-
address: token0.address,
|
|
159
|
-
},
|
|
160
173
|
// token1.transfer_to_public enqueues a call to _increase_public_balance
|
|
161
174
|
{
|
|
162
175
|
sender: token1.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
@@ -164,20 +177,6 @@ async function addLiquidity(
|
|
|
164
177
|
args: [/*to=*/ amm.address, /*amount=*/ amount1Max],
|
|
165
178
|
address: token1.address,
|
|
166
179
|
},
|
|
167
|
-
// token1.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
168
|
-
{
|
|
169
|
-
sender: token1.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
170
|
-
fnName: '_store_balances_set_partial_note',
|
|
171
|
-
args: [refundToken1PartialNote],
|
|
172
|
-
address: token1.address,
|
|
173
|
-
},
|
|
174
|
-
// liquidityToken.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
175
|
-
{
|
|
176
|
-
sender: liquidityToken.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
177
|
-
fnName: '_store_balances_set_partial_note',
|
|
178
|
-
args: [liquidityPartialNote],
|
|
179
|
-
address: liquidityToken.address,
|
|
180
|
-
},
|
|
181
180
|
// amm.add_liquidity enqueues a call to _add_liquidity
|
|
182
181
|
{
|
|
183
182
|
sender: amm.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
@@ -214,8 +213,16 @@ async function swapExactTokensForTokens(
|
|
|
214
213
|
_nonce?: bigint,
|
|
215
214
|
) {
|
|
216
215
|
const tokenOutPartialNote = {
|
|
217
|
-
commitment: new Fr(
|
|
216
|
+
commitment: new Fr(166),
|
|
218
217
|
};
|
|
218
|
+
const tokenOutPartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
219
|
+
tokenOutPartialNote,
|
|
220
|
+
amm.address,
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// We need to inject the validity commitment into the nullifier tree as that would be performed by the private token
|
|
224
|
+
// function that is not invoked in this test.
|
|
225
|
+
await tester.insertNullifier(tokenOut.address, tokenOutPartialNoteValidityCommitment);
|
|
219
226
|
|
|
220
227
|
return await tester.simulateTxWithLabel(
|
|
221
228
|
/*txLabel=*/ 'AMM/swap_exact_tokens_for_tokens',
|
|
@@ -229,14 +236,6 @@ async function swapExactTokensForTokens(
|
|
|
229
236
|
args: [/*to=*/ amm.address, /*amount=*/ amountIn],
|
|
230
237
|
address: tokenIn.address,
|
|
231
238
|
},
|
|
232
|
-
// tokenOut.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
233
|
-
{
|
|
234
|
-
sender: tokenOut.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
235
|
-
fnName: '_store_balances_set_partial_note',
|
|
236
|
-
args: [tokenOutPartialNote],
|
|
237
|
-
address: tokenOut.address,
|
|
238
|
-
},
|
|
239
|
-
|
|
240
239
|
{
|
|
241
240
|
sender: amm.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
242
241
|
fnName: '_swap_exact_tokens_for_tokens',
|
|
@@ -265,6 +264,19 @@ async function removeLiquidity(
|
|
|
265
264
|
const token1PartialNote = {
|
|
266
265
|
commitment: new Fr(222),
|
|
267
266
|
};
|
|
267
|
+
const token0PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
268
|
+
token0PartialNote,
|
|
269
|
+
amm.address,
|
|
270
|
+
);
|
|
271
|
+
const token1PartialNoteValidityCommitment = await computePartialNoteValidityCommitment(
|
|
272
|
+
token1PartialNote,
|
|
273
|
+
amm.address,
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// We need to inject the validity commitments into the nullifier tree as that would be performed by the private token
|
|
277
|
+
// functions that are not invoked in this test.
|
|
278
|
+
await tester.insertNullifier(token0.address, token0PartialNoteValidityCommitment);
|
|
279
|
+
await tester.insertNullifier(token1.address, token1PartialNoteValidityCommitment);
|
|
268
280
|
|
|
269
281
|
return await tester.simulateTxWithLabel(
|
|
270
282
|
/*txLabel=*/ 'AMM/remove_liquidity',
|
|
@@ -278,20 +290,6 @@ async function removeLiquidity(
|
|
|
278
290
|
args: [/*to=*/ amm.address, /*amount=*/ liquidity],
|
|
279
291
|
address: liquidityToken.address,
|
|
280
292
|
},
|
|
281
|
-
// token0.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
282
|
-
{
|
|
283
|
-
sender: token0.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
284
|
-
fnName: '_store_balances_set_partial_note',
|
|
285
|
-
args: [token0PartialNote],
|
|
286
|
-
address: token0.address,
|
|
287
|
-
},
|
|
288
|
-
// token1.prepare_private_balance_increase enqueues a call to _store_balances_set_partial_note
|
|
289
|
-
{
|
|
290
|
-
sender: token1.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
291
|
-
fnName: '_store_balances_set_partial_note',
|
|
292
|
-
args: [token1PartialNote],
|
|
293
|
-
address: token1.address,
|
|
294
|
-
},
|
|
295
293
|
// amm.remove_liquidity enqueues a call to _remove_liquidity
|
|
296
294
|
{
|
|
297
295
|
sender: amm.address, // INTERNAL FUNCTION! Sender must be 'this'.
|
|
@@ -314,3 +312,10 @@ async function removeLiquidity(
|
|
|
314
312
|
],
|
|
315
313
|
);
|
|
316
314
|
}
|
|
315
|
+
|
|
316
|
+
async function computePartialNoteValidityCommitment(partialNote: { commitment: Fr }, completer: AztecAddress) {
|
|
317
|
+
return await poseidon2HashWithSeparator(
|
|
318
|
+
[partialNote.commitment, completer],
|
|
319
|
+
GeneratorIndex.PARTIAL_NOTE_VALIDITY_COMMITMENT,
|
|
320
|
+
);
|
|
321
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './public/index.js';
|
|
2
2
|
export { WASMSimulatorWithBlobs } from './private/providers/acvm_wasm_with_blobs.js';
|
|
3
3
|
export { NativeACVMSimulator } from './private/providers/acvm_native.js';
|
|
4
|
+
export { SimulationProviderRecorderWrapper } from './private/providers/circuit_recording/simulation_provider_recorder_wrapper.js';
|
|
5
|
+
export { MemoryCircuitRecorder } from './private/providers/circuit_recording/memory_circuit_recorder.js';
|
|
4
6
|
export { type SimulationProvider } from './private/providers/simulation_provider.js';
|
|
5
7
|
export * from './common/index.js';
|
package/src/testing.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { FileCircuitRecorder } from './private/providers/circuit_recording/file_circuit_recorder.js';
|