@aztec/simulator 1.2.1 → 2.0.0-nightly.20250813
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/private/circuit_recording/circuit_recorder.js +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +2 -2
- package/dest/public/avm/fixtures/utils.js +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +5 -3
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/misc.js +1 -1
- package/dest/public/avm/test_utils.d.ts +2 -2
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +2 -2
- package/dest/public/executor_metrics.d.ts +0 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +0 -3
- package/dest/public/executor_metrics_interface.d.ts +0 -1
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/index.d.ts +1 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +2 -1
- package/dest/public/fixtures/utils.d.ts +5 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +37 -13
- package/dest/public/public_db_sources.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +3 -2
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +30 -19
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +1 -1
- package/dest/public/public_tx_simulator/apps_tests/amm_test.js +4 -4
- package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts +1 -1
- package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/apps_tests/token_test.js +2 -2
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -6
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +6 -12
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +1 -20
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +49 -81
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +17 -11
- package/dest/public/state_manager/state_manager.d.ts +1 -1
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +16 -16
- package/dest/public/test_executor_metrics.d.ts +13 -3
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +159 -47
- package/package.json +15 -15
- package/src/private/circuit_recording/circuit_recorder.ts +2 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +2 -2
- package/src/public/avm/fixtures/utils.ts +2 -2
- package/src/public/avm/opcodes/accrued_substate.ts +6 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/environment_getters.ts +8 -8
- package/src/public/avm/opcodes/misc.ts +1 -1
- package/src/public/avm/test_utils.ts +4 -4
- package/src/public/executor_metrics.ts +0 -4
- package/src/public/executor_metrics_interface.ts +0 -1
- package/src/public/fixtures/index.ts +1 -0
- package/src/public/fixtures/minimal_public_tx.ts +2 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +3 -2
- package/src/public/fixtures/utils.ts +45 -16
- package/src/public/public_db_sources.ts +7 -7
- package/src/public/public_processor/public_processor.ts +38 -29
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/apps_tests/amm_test.ts +4 -4
- package/src/public/public_tx_simulator/apps_tests/token_test.ts +2 -2
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -7
- package/src/public/public_tx_simulator/public_tx_context.ts +13 -19
- package/src/public/public_tx_simulator/public_tx_simulator.ts +63 -105
- package/src/public/side_effect_trace.ts +29 -23
- package/src/public/state_manager/state_manager.ts +23 -21
- package/src/public/test_executor_metrics.ts +172 -46
|
@@ -16,14 +16,26 @@ export interface PublicEnqueuedCallMetrics {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface PublicTxMetrics {
|
|
19
|
+
// TS simulation
|
|
19
20
|
totalDurationMs: number;
|
|
20
21
|
manaUsed: number;
|
|
21
22
|
totalInstructionsExecuted: number;
|
|
22
|
-
txHashMs: number | undefined;
|
|
23
23
|
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
24
24
|
revertiblePrivateInsertionsUs: number | undefined;
|
|
25
25
|
enqueuedCalls: PublicEnqueuedCallMetrics[];
|
|
26
26
|
revertedCode: RevertCode | undefined;
|
|
27
|
+
// Proving
|
|
28
|
+
proverSimulationStepMs: number | undefined;
|
|
29
|
+
proverProvingStepMs: number | undefined;
|
|
30
|
+
proverTraceGenerationStepMs: number | undefined;
|
|
31
|
+
// Proving (detail)
|
|
32
|
+
traceGenerationInteractionsMs: number | undefined;
|
|
33
|
+
traceGenerationTracesMs: number | undefined;
|
|
34
|
+
provingSumcheckMs: number | undefined;
|
|
35
|
+
provingPcsMs: number | undefined;
|
|
36
|
+
provingLogDerivativeInverseMs: number | undefined;
|
|
37
|
+
provingLogDerivativeInverseCommitmentsMs: number | undefined;
|
|
38
|
+
provingWireCommitmentsMs: number | undefined;
|
|
27
39
|
}
|
|
28
40
|
|
|
29
41
|
const NUM_SPACES = 4;
|
|
@@ -40,6 +52,32 @@ export enum PublicTxMetricsFilter {
|
|
|
40
52
|
TOTALS,
|
|
41
53
|
DURATIONS,
|
|
42
54
|
INSTRUCTIONS,
|
|
55
|
+
PROVING,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function createEmptyTxMetrics(): PublicTxMetrics {
|
|
59
|
+
return {
|
|
60
|
+
// TS simulation
|
|
61
|
+
totalDurationMs: 0,
|
|
62
|
+
manaUsed: 0,
|
|
63
|
+
totalInstructionsExecuted: 0,
|
|
64
|
+
nonRevertiblePrivateInsertionsUs: undefined,
|
|
65
|
+
revertiblePrivateInsertionsUs: undefined,
|
|
66
|
+
enqueuedCalls: [],
|
|
67
|
+
revertedCode: undefined,
|
|
68
|
+
// Proving
|
|
69
|
+
proverSimulationStepMs: undefined,
|
|
70
|
+
proverProvingStepMs: undefined,
|
|
71
|
+
proverTraceGenerationStepMs: undefined,
|
|
72
|
+
// Proving (detail)
|
|
73
|
+
traceGenerationInteractionsMs: undefined,
|
|
74
|
+
traceGenerationTracesMs: undefined,
|
|
75
|
+
provingSumcheckMs: undefined,
|
|
76
|
+
provingPcsMs: undefined,
|
|
77
|
+
provingLogDerivativeInverseMs: undefined,
|
|
78
|
+
provingLogDerivativeInverseCommitmentsMs: undefined,
|
|
79
|
+
provingWireCommitmentsMs: undefined,
|
|
80
|
+
};
|
|
43
81
|
}
|
|
44
82
|
|
|
45
83
|
export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
@@ -56,16 +94,7 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
56
94
|
startRecordingTxSimulation(txLabel: string) {
|
|
57
95
|
assert(!this.currentTxLabel, 'Cannot start recording tx simulation when another is live');
|
|
58
96
|
assert(!this.txMetrics.has(txLabel), 'Cannot start recording metrics for tx with duplicate label');
|
|
59
|
-
this.txMetrics.set(txLabel,
|
|
60
|
-
totalDurationMs: 0,
|
|
61
|
-
manaUsed: 0,
|
|
62
|
-
totalInstructionsExecuted: 0,
|
|
63
|
-
txHashMs: undefined,
|
|
64
|
-
nonRevertiblePrivateInsertionsUs: undefined,
|
|
65
|
-
revertiblePrivateInsertionsUs: undefined,
|
|
66
|
-
enqueuedCalls: [],
|
|
67
|
-
revertedCode: undefined,
|
|
68
|
-
});
|
|
97
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
69
98
|
this.currentTxLabel = txLabel;
|
|
70
99
|
this.txTimer = new Timer();
|
|
71
100
|
}
|
|
@@ -124,13 +153,6 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
124
153
|
});
|
|
125
154
|
}
|
|
126
155
|
|
|
127
|
-
recordTxHashComputation(durationMs: number) {
|
|
128
|
-
assert(this.currentTxLabel, 'Cannot record tx hash computation time when no tx is live');
|
|
129
|
-
const txMetrics = this.txMetrics.get(this.currentTxLabel)!;
|
|
130
|
-
assert(txMetrics.txHashMs === undefined, 'Cannot RE-record tx hash computation time');
|
|
131
|
-
txMetrics.txHashMs = durationMs;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
156
|
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible') {
|
|
135
157
|
assert(this.currentTxLabel, 'Cannot record private effects insertion when no tx is live');
|
|
136
158
|
const txMetrics = this.txMetrics.get(this.currentTxLabel)!;
|
|
@@ -149,6 +171,18 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
149
171
|
}
|
|
150
172
|
}
|
|
151
173
|
|
|
174
|
+
recordProverMetrics(txLabel: string, metrics: Partial<PublicTxMetrics>) {
|
|
175
|
+
if (!this.txMetrics.has(txLabel)) {
|
|
176
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
177
|
+
}
|
|
178
|
+
const txMetrics = this.txMetrics.get(txLabel)!;
|
|
179
|
+
for (const [key, value] of Object.entries(metrics)) {
|
|
180
|
+
if (key in txMetrics) {
|
|
181
|
+
txMetrics[key as keyof PublicTxMetrics] = value as any;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
152
186
|
prettyPrint(filter: PublicTxMetricsFilter = PublicTxMetricsFilter.ALL) {
|
|
153
187
|
this.logger.info(this.toPrettyString(filter));
|
|
154
188
|
}
|
|
@@ -181,11 +215,46 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
181
215
|
pretty += `${INDENT0}Total instructions executed: ${fmtNum(txMetrics.totalInstructionsExecuted)}\n`;
|
|
182
216
|
}
|
|
183
217
|
if (filter === PublicTxMetricsFilter.DURATIONS || filter === PublicTxMetricsFilter.ALL) {
|
|
184
|
-
pretty += `${INDENT0}Tx hash computation: ${fmtNum(txMetrics.txHashMs!, 'ms')}\n`;
|
|
185
218
|
pretty += `${INDENT0}Private insertions:\n`;
|
|
186
219
|
pretty += `${INDENT1}Non-revertible: ${fmtNum(txMetrics.nonRevertiblePrivateInsertionsUs! / 1_000, 'ms')}\n`;
|
|
187
220
|
pretty += `${INDENT1}Revertible: ${fmtNum(txMetrics.revertiblePrivateInsertionsUs! / 1_000, 'ms')}\n`;
|
|
188
221
|
}
|
|
222
|
+
if (filter === PublicTxMetricsFilter.PROVING || filter === PublicTxMetricsFilter.ALL) {
|
|
223
|
+
let provingPretty = '';
|
|
224
|
+
if (txMetrics.proverSimulationStepMs !== undefined) {
|
|
225
|
+
provingPretty += `${INDENT1}Simulation (all): ${fmtNum(txMetrics.proverSimulationStepMs, 'ms')}\n`;
|
|
226
|
+
}
|
|
227
|
+
if (txMetrics.proverProvingStepMs !== undefined) {
|
|
228
|
+
provingPretty += `${INDENT1}Proving (all): ${fmtNum(txMetrics.proverProvingStepMs, 'ms')}\n`;
|
|
229
|
+
}
|
|
230
|
+
if (txMetrics.proverTraceGenerationStepMs !== undefined) {
|
|
231
|
+
provingPretty += `${INDENT1}Trace generation (all): ${fmtNum(txMetrics.proverTraceGenerationStepMs, 'ms')}\n`;
|
|
232
|
+
}
|
|
233
|
+
if (txMetrics.traceGenerationInteractionsMs !== undefined) {
|
|
234
|
+
provingPretty += `${INDENT1}Trace generation interactions: ${fmtNum(txMetrics.traceGenerationInteractionsMs, 'ms')}\n`;
|
|
235
|
+
}
|
|
236
|
+
if (txMetrics.traceGenerationTracesMs !== undefined) {
|
|
237
|
+
provingPretty += `${INDENT1}Trace generation traces: ${fmtNum(txMetrics.traceGenerationTracesMs, 'ms')}\n`;
|
|
238
|
+
}
|
|
239
|
+
if (txMetrics.provingSumcheckMs !== undefined) {
|
|
240
|
+
provingPretty += `${INDENT1}Sumcheck: ${fmtNum(txMetrics.provingSumcheckMs, 'ms')}\n`;
|
|
241
|
+
}
|
|
242
|
+
if (txMetrics.provingPcsMs !== undefined) {
|
|
243
|
+
provingPretty += `${INDENT1}PCS: ${fmtNum(txMetrics.provingPcsMs, 'ms')}\n`;
|
|
244
|
+
}
|
|
245
|
+
if (txMetrics.provingLogDerivativeInverseMs !== undefined) {
|
|
246
|
+
provingPretty += `${INDENT1}Log derivative inverse: ${fmtNum(txMetrics.provingLogDerivativeInverseMs, 'ms')}\n`;
|
|
247
|
+
}
|
|
248
|
+
if (txMetrics.provingLogDerivativeInverseCommitmentsMs !== undefined) {
|
|
249
|
+
provingPretty += `${INDENT1}Log derivative inverse commitments: ${fmtNum(txMetrics.provingLogDerivativeInverseCommitmentsMs, 'ms')}\n`;
|
|
250
|
+
}
|
|
251
|
+
if (txMetrics.provingWireCommitmentsMs !== undefined) {
|
|
252
|
+
provingPretty += `${INDENT1}Wire commitments: ${fmtNum(txMetrics.provingWireCommitmentsMs, 'ms')}\n`;
|
|
253
|
+
}
|
|
254
|
+
if (provingPretty.length > 0) {
|
|
255
|
+
pretty += `${INDENT0}Proving:\n${provingPretty}`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
189
258
|
if (filter !== PublicTxMetricsFilter.TOTALS) {
|
|
190
259
|
// totals exclude enqueued calls
|
|
191
260
|
pretty += this.#enqueuedCallsToPrettyString(txMetrics, filter);
|
|
@@ -227,38 +296,95 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
227
296
|
}
|
|
228
297
|
|
|
229
298
|
toGithubActionBenchmarkJSON(indent = 2) {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
name: `${txLabel}/totalInstructionsExecuted`,
|
|
234
|
-
value: txMetrics.totalInstructionsExecuted,
|
|
299
|
+
const metricsInfo = {
|
|
300
|
+
totalInstructionsExecuted: {
|
|
301
|
+
name: 'totalInstructionsExecuted',
|
|
235
302
|
unit: '#instructions',
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
303
|
+
category: PublicTxMetricsFilter.INSTRUCTIONS,
|
|
304
|
+
},
|
|
305
|
+
totalDurationMs: {
|
|
306
|
+
name: 'totalDurationMs',
|
|
240
307
|
unit: 'ms',
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
308
|
+
category: PublicTxMetricsFilter.DURATIONS,
|
|
309
|
+
},
|
|
310
|
+
manaUsed: {
|
|
311
|
+
name: 'manaUsed',
|
|
245
312
|
unit: 'mana',
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
unit: 'ms',
|
|
251
|
-
});
|
|
252
|
-
data.push({
|
|
253
|
-
name: `${txLabel}/nonRevertiblePrivateInsertionsUs`,
|
|
254
|
-
value: txMetrics.nonRevertiblePrivateInsertionsUs,
|
|
313
|
+
category: PublicTxMetricsFilter.TOTALS,
|
|
314
|
+
},
|
|
315
|
+
nonRevertiblePrivateInsertionsUs: {
|
|
316
|
+
name: 'nonRevertiblePrivateInsertionsUs',
|
|
255
317
|
unit: 'us',
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
318
|
+
category: PublicTxMetricsFilter.DURATIONS,
|
|
319
|
+
},
|
|
320
|
+
revertiblePrivateInsertionsUs: {
|
|
321
|
+
name: 'revertiblePrivateInsertionsUs',
|
|
260
322
|
unit: 'us',
|
|
261
|
-
|
|
323
|
+
category: PublicTxMetricsFilter.DURATIONS,
|
|
324
|
+
},
|
|
325
|
+
proverSimulationStepMs: {
|
|
326
|
+
name: 'proverSimulationStepMs',
|
|
327
|
+
unit: 'ms',
|
|
328
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
329
|
+
},
|
|
330
|
+
proverProvingStepMs: {
|
|
331
|
+
name: 'proverProvingStepMs',
|
|
332
|
+
unit: 'ms',
|
|
333
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
334
|
+
},
|
|
335
|
+
proverTraceGenerationStepMs: {
|
|
336
|
+
name: 'proverTraceGenerationStepMs',
|
|
337
|
+
unit: 'ms',
|
|
338
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
339
|
+
},
|
|
340
|
+
traceGenerationInteractionsMs: {
|
|
341
|
+
name: 'traceGenerationInteractionsMs',
|
|
342
|
+
unit: 'ms',
|
|
343
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
344
|
+
},
|
|
345
|
+
traceGenerationTracesMs: {
|
|
346
|
+
name: 'traceGenerationTracesMs',
|
|
347
|
+
unit: 'ms',
|
|
348
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
349
|
+
},
|
|
350
|
+
provingSumcheckMs: {
|
|
351
|
+
name: 'provingSumcheckMs',
|
|
352
|
+
unit: 'ms',
|
|
353
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
354
|
+
},
|
|
355
|
+
provingPcsMs: {
|
|
356
|
+
name: 'provingPcsMs',
|
|
357
|
+
unit: 'ms',
|
|
358
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
359
|
+
},
|
|
360
|
+
provingLogDerivativeInverseMs: {
|
|
361
|
+
name: 'provingLogDerivativeInverseMs',
|
|
362
|
+
unit: 'ms',
|
|
363
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
364
|
+
},
|
|
365
|
+
provingLogDerivativeInverseCommitmentsMs: {
|
|
366
|
+
name: 'provingLogDerivativeInverseCommitmentsMs',
|
|
367
|
+
unit: 'ms',
|
|
368
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
369
|
+
},
|
|
370
|
+
provingWireCommitmentsMs: {
|
|
371
|
+
name: 'provingWireCommitmentsMs',
|
|
372
|
+
unit: 'ms',
|
|
373
|
+
category: PublicTxMetricsFilter.PROVING,
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const data = [];
|
|
378
|
+
for (const [txLabel, txMetrics] of this.txMetrics.entries()) {
|
|
379
|
+
for (const [key, value] of Object.entries(txMetrics)) {
|
|
380
|
+
if (value !== undefined && key in metricsInfo) {
|
|
381
|
+
data.push({
|
|
382
|
+
name: `${txLabel}/${metricsInfo[key as keyof typeof metricsInfo].name}`,
|
|
383
|
+
value: value,
|
|
384
|
+
unit: metricsInfo[key as keyof typeof metricsInfo].unit,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
262
388
|
}
|
|
263
389
|
return JSON.stringify(data, null, indent);
|
|
264
390
|
}
|