@aztec-labs/simulator 6.0.0-nightly.20260829
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/README.md +57 -0
- package/dest/client.d.ts +6 -0
- package/dest/client.d.ts.map +1 -0
- package/dest/client.js +3 -0
- package/dest/common/errors.d.ts +51 -0
- package/dest/common/errors.d.ts.map +1 -0
- package/dest/common/errors.js +154 -0
- package/dest/common/index.d.ts +3 -0
- package/dest/common/index.d.ts.map +1 -0
- package/dest/common/index.js +2 -0
- package/dest/common/stats/index.d.ts +2 -0
- package/dest/common/stats/index.d.ts.map +1 -0
- package/dest/common/stats/index.js +1 -0
- package/dest/common/stats/stats.d.ts +4 -0
- package/dest/common/stats/stats.d.ts.map +1 -0
- package/dest/common/stats/stats.js +10 -0
- package/dest/private/acvm/acvm.d.ts +43 -0
- package/dest/private/acvm/acvm.d.ts.map +1 -0
- package/dest/private/acvm/acvm.js +65 -0
- package/dest/private/acvm/acvm_types.d.ts +10 -0
- package/dest/private/acvm/acvm_types.d.ts.map +1 -0
- package/dest/private/acvm/acvm_types.js +3 -0
- package/dest/private/acvm/deserialize.d.ts +35 -0
- package/dest/private/acvm/deserialize.d.ts.map +1 -0
- package/dest/private/acvm/deserialize.js +50 -0
- package/dest/private/acvm/index.d.ts +5 -0
- package/dest/private/acvm/index.d.ts.map +1 -0
- package/dest/private/acvm/index.js +4 -0
- package/dest/private/acvm/serialize.d.ts +41 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -0
- package/dest/private/acvm/serialize.js +99 -0
- package/dest/private/acvm_native.d.ts +41 -0
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/acvm_native.js +147 -0
- package/dest/private/acvm_wasm.d.ts +16 -0
- package/dest/private/acvm_wasm.d.ts.map +1 -0
- package/dest/private/acvm_wasm.js +67 -0
- package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/acvm_wasm_with_blobs.js +35 -0
- package/dest/private/circuit_simulator.d.ts +35 -0
- package/dest/private/circuit_simulator.d.ts.map +1 -0
- package/dest/private/circuit_simulator.js +43 -0
- package/dest/private/factory.d.ts +12 -0
- package/dest/private/factory.d.ts.map +1 -0
- package/dest/private/factory.js +30 -0
- package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
- package/dest/public/avm/testing/base_avm_simulation_tester.d.ts +39 -0
- package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/testing/base_avm_simulation_tester.js +121 -0
- package/dest/public/avm/testing/utils.d.ts +32 -0
- package/dest/public/avm/testing/utils.d.ts.map +1 -0
- package/dest/public/avm/testing/utils.js +66 -0
- package/dest/public/avm_simulator.d.ts +28 -0
- package/dest/public/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm_simulator.js +4 -0
- package/dest/public/avm_simulator_pool.d.ts +84 -0
- package/dest/public/avm_simulator_pool.d.ts.map +1 -0
- package/dest/public/avm_simulator_pool.js +311 -0
- package/dest/public/cdb_ipc_server.d.ts +40 -0
- package/dest/public/cdb_ipc_server.d.ts.map +1 -0
- package/dest/public/cdb_ipc_server.js +153 -0
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +68 -0
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +3 -0
- package/dest/public/executor_metrics.d.ts +21 -0
- package/dest/public/executor_metrics.d.ts.map +1 -0
- package/dest/public/executor_metrics.js +64 -0
- package/dest/public/executor_metrics_interface.d.ts +10 -0
- package/dest/public/executor_metrics_interface.d.ts.map +1 -0
- package/dest/public/executor_metrics_interface.js +1 -0
- package/dest/public/fixtures/amm_test.d.ts +10 -0
- package/dest/public/fixtures/amm_test.d.ts.map +1 -0
- package/dest/public/fixtures/amm_test.js +213 -0
- package/dest/public/fixtures/bulk_test.d.ts +6 -0
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
- package/dest/public/fixtures/bulk_test.js +289 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +34 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +53 -0
- package/dest/public/fixtures/index.d.ts +10 -0
- package/dest/public/fixtures/index.d.ts.map +1 -0
- package/dest/public/fixtures/index.js +9 -0
- package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
- package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
- package/dest/public/fixtures/public_processor_test_env.js +73 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +77 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -0
- package/dest/public/fixtures/public_tx_simulation_tester.js +176 -0
- package/dest/public/fixtures/simple_contract_data_source.d.ts +36 -0
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/fixtures/simple_contract_data_source.js +95 -0
- package/dest/public/fixtures/token_test.d.ts +12 -0
- package/dest/public/fixtures/token_test.d.ts.map +1 -0
- package/dest/public/fixtures/token_test.js +96 -0
- package/dest/public/fixtures/utils.d.ts +26 -0
- package/dest/public/fixtures/utils.d.ts.map +1 -0
- package/dest/public/fixtures/utils.js +170 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +65 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +181 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_simulator_bin.js +108 -0
- package/dest/public/index.d.ts +10 -0
- package/dest/public/index.d.ts.map +1 -0
- package/dest/public/index.js +6 -0
- package/dest/public/public_db_sources.d.ts +83 -0
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +297 -0
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +52 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +116 -0
- package/dest/public/public_processor/public_processor.d.ts +71 -0
- package/dest/public/public_processor/public_processor.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor.js +858 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts +30 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor_metrics.js +116 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +17 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.js +39 -0
- package/dest/public/public_tx_simulator/factories.d.ts +14 -0
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/factories.js +28 -0
- package/dest/public/public_tx_simulator/index.d.ts +6 -0
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/index.js +3 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +53 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.js +127 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.js +31 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +32 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/side_effect_errors.d.ts +44 -0
- package/dest/public/side_effect_errors.d.ts.map +1 -0
- package/dest/public/side_effect_errors.js +75 -0
- package/dest/public/test_executor_metrics.d.ts +56 -0
- package/dest/public/test_executor_metrics.d.ts.map +1 -0
- package/dest/public/test_executor_metrics.js +305 -0
- package/dest/public/unique_class_ids.d.ts +37 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -0
- package/dest/public/unique_class_ids.js +61 -0
- package/dest/public/utils.d.ts +3 -0
- package/dest/public/utils.d.ts.map +1 -0
- package/dest/public/utils.js +18 -0
- package/dest/server.d.ts +7 -0
- package/dest/server.d.ts.map +1 -0
- package/dest/server.js +5 -0
- package/package.json +109 -0
- package/src/client.ts +5 -0
- package/src/common/errors.ts +219 -0
- package/src/common/index.ts +2 -0
- package/src/common/stats/index.ts +1 -0
- package/src/common/stats/stats.ts +20 -0
- package/src/private/acvm/acvm.ts +114 -0
- package/src/private/acvm/acvm_types.ts +11 -0
- package/src/private/acvm/deserialize.ts +58 -0
- package/src/private/acvm/index.ts +4 -0
- package/src/private/acvm/serialize.ts +123 -0
- package/src/private/acvm_native.ts +200 -0
- package/src/private/acvm_wasm.ts +80 -0
- package/src/private/acvm_wasm_with_blobs.ts +55 -0
- package/src/private/circuit_simulator.ts +91 -0
- package/src/private/factory.ts +40 -0
- package/src/public/avm/testing/account_proof.json +553 -0
- package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
- package/src/public/avm/testing/base_avm_simulation_tester.ts +162 -0
- package/src/public/avm/testing/utils.ts +114 -0
- package/src/public/avm_simulator.ts +29 -0
- package/src/public/avm_simulator_pool.ts +355 -0
- package/src/public/cdb_ipc_server.ts +198 -0
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +76 -0
- package/src/public/executor_metrics.ts +102 -0
- package/src/public/executor_metrics_interface.ts +20 -0
- package/src/public/fixtures/amm_test.ts +331 -0
- package/src/public/fixtures/bulk_test.ts +194 -0
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/index.ts +13 -0
- package/src/public/fixtures/public_processor_test_env.ts +88 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +315 -0
- package/src/public/fixtures/simple_contract_data_source.ts +122 -0
- package/src/public/fixtures/token_test.ts +148 -0
- package/src/public/fixtures/utils.ts +269 -0
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +302 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +156 -0
- package/src/public/index.ts +16 -0
- package/src/public/public_db_sources.ts +405 -0
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +161 -0
- package/src/public/public_processor/public_processor.ts +657 -0
- package/src/public/public_processor/public_processor_metrics.ts +138 -0
- package/src/public/public_tx_simulator/dumping_public_tx_simulator.ts +66 -0
- package/src/public/public_tx_simulator/factories.ts +61 -0
- package/src/public/public_tx_simulator/index.ts +8 -0
- package/src/public/public_tx_simulator/public_tx_simulator.ts +190 -0
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +33 -0
- package/src/public/side_effect_errors.ts +96 -0
- package/src/public/test_executor_metrics.ts +399 -0
- package/src/public/unique_class_ids.ts +79 -0
- package/src/public/utils.ts +16 -0
- package/src/server.ts +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side_effect_errors.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_errors.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;GAGG;AACH,8BAAsB,eAAgB,SAAQ,2BAA2B;IACvE,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,qBAAa,2BAA4B,SAAQ,eAAe;IAC9D,YAAY,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAGhD;CACF;AAED,qBAAa,qCAAsC,SAAQ,2BAA2B;IACpF,cAGC;CACF;AAED,qBAAa,0BAA2B,SAAQ,2BAA2B;IACzE,cAGC;CACF;AAED,qBAAa,yBAA0B,SAAQ,2BAA2B;IACxE,cAGC;CACF;AAED,qBAAa,8BAA+B,SAAQ,2BAA2B;IAC7E,cAGC;CACF;AAED,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;GAIG;AACH,8BAAsB,mBAAoB,SAAQ,KAAK;IACrD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;IAC3D,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAGrD;CACF;AAED,qBAAa,4BAA6B,SAAQ,oBAAoB;IACpE,YAAY,KAAK,EAAE,MAAM,EAGxB;CACF;AAED,qBAAa,iCAAkC,SAAQ,oBAAoB;IACzE,YAAY,KAAK,EAAE,MAAM,EAGxB;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { L1_TO_L2_MSG_TREE_LEAF_COUNT, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS, NOTE_HASH_TREE_LEAF_COUNT } from '@aztec-labs/constants';
|
|
2
|
+
import { CheckedPublicExecutionError } from './public_errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Any error that can be thrown during side effect insertion in public.
|
|
5
|
+
* Includes SideEffectLimitReachedError and NullifierCollisionError.
|
|
6
|
+
*/ export class SideEffectError extends CheckedPublicExecutionError {
|
|
7
|
+
constructor(message){
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'SideEffectInsertionError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class SideEffectLimitReachedError extends SideEffectError {
|
|
13
|
+
constructor(sideEffectType, limit){
|
|
14
|
+
super(`Reached the limit (${limit}) on number of '${sideEffectType}' per tx`);
|
|
15
|
+
this.name = 'SideEffectLimitReachedError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class MaxCallsToUniqueContractClassIdsError extends SideEffectLimitReachedError {
|
|
19
|
+
constructor(){
|
|
20
|
+
super('contract calls to unique class IDs', MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS);
|
|
21
|
+
this.name = 'MaxCallsToUniqueContractClassIdsError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class NullifierLimitReachedError extends SideEffectLimitReachedError {
|
|
25
|
+
constructor(){
|
|
26
|
+
super('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
27
|
+
this.name = 'NullifierLimitReachedError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class NoteHashLimitReachedError extends SideEffectLimitReachedError {
|
|
31
|
+
constructor(){
|
|
32
|
+
super('note hash', MAX_NOTE_HASHES_PER_TX);
|
|
33
|
+
this.name = 'NoteHashLimitReachedError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class L2ToL1MessageLimitReachedError extends SideEffectLimitReachedError {
|
|
37
|
+
constructor(){
|
|
38
|
+
super('l2 to l1 message', MAX_L2_TO_L1_MSGS_PER_TX);
|
|
39
|
+
this.name = 'L2ToL1MessageLimitReachedError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class NullifierCollisionError extends SideEffectError {
|
|
43
|
+
constructor(message){
|
|
44
|
+
super(`Nullifier collision: ${message}`);
|
|
45
|
+
this.name = 'NullifierCollisionError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Any error that can be thrown during side effect reads in public.
|
|
50
|
+
* Note: Thrown at state manager level and unknown by simulation, hence NOT considered
|
|
51
|
+
* CheckedPublicExecutionErrors. Currently only includes append-only tree reads.
|
|
52
|
+
*/ export class SideEffectReadError extends Error {
|
|
53
|
+
constructor(message){
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = 'SideEffectReadError';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class IndexOutOfRangeError extends SideEffectReadError {
|
|
59
|
+
constructor(tree, index, limit){
|
|
60
|
+
super(`Attempting to read index ${index} of ${tree} tree with maximum ${limit} leaves`);
|
|
61
|
+
this.name = 'IndexOutOfRangeError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class NoteHashIndexOutOfRangeError extends IndexOutOfRangeError {
|
|
65
|
+
constructor(index){
|
|
66
|
+
super('note hash', index, NOTE_HASH_TREE_LEAF_COUNT);
|
|
67
|
+
this.name = 'NoteHashIndexOutOfRangeError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class L1ToL2MessageIndexOutOfRangeError extends IndexOutOfRangeError {
|
|
71
|
+
constructor(index){
|
|
72
|
+
super('l1 to l2 message', index, L1_TO_L2_MSG_TREE_LEAF_COUNT);
|
|
73
|
+
this.name = 'L1ToL2MessageIndexOutOfRangeError';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LoggerBindings } from '@aztec-labs/foundation/log';
|
|
2
|
+
import type { RevertCode } from '@aztec-labs/stdlib/avm';
|
|
3
|
+
import type { GasUsed } from '@aztec-labs/stdlib/gas';
|
|
4
|
+
import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
|
|
5
|
+
export interface PublicEnqueuedCallMetrics {
|
|
6
|
+
fnName: string;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
manaUsed: number;
|
|
9
|
+
totalInstructionsExecuted: number;
|
|
10
|
+
reverted: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PublicTxMetrics {
|
|
13
|
+
totalDurationMs: number;
|
|
14
|
+
manaUsed: number | undefined;
|
|
15
|
+
totalInstructionsExecuted: number;
|
|
16
|
+
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
17
|
+
revertiblePrivateInsertionsUs: number | undefined;
|
|
18
|
+
enqueuedCalls: PublicEnqueuedCallMetrics[];
|
|
19
|
+
revertedCode: RevertCode | undefined;
|
|
20
|
+
proverSimulationStepMs: number | undefined;
|
|
21
|
+
proverProvingStepMs: number | undefined;
|
|
22
|
+
proverTraceGenerationStepMs: number | undefined;
|
|
23
|
+
traceGenerationInteractionsMs: number | undefined;
|
|
24
|
+
traceGenerationTracesMs: number | undefined;
|
|
25
|
+
provingSumcheckMs: number | undefined;
|
|
26
|
+
provingPcsMs: number | undefined;
|
|
27
|
+
provingLogDerivativeInverseMs: number | undefined;
|
|
28
|
+
provingLogDerivativeInverseCommitmentsMs: number | undefined;
|
|
29
|
+
provingWireCommitmentsMs: number | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare enum PublicTxMetricsFilter {
|
|
32
|
+
ALL = 0,
|
|
33
|
+
TOTALS = 1,
|
|
34
|
+
DURATIONS = 2,
|
|
35
|
+
INSTRUCTIONS = 3,
|
|
36
|
+
PROVING = 4
|
|
37
|
+
}
|
|
38
|
+
export declare class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
39
|
+
#private;
|
|
40
|
+
private logger;
|
|
41
|
+
private txMetrics;
|
|
42
|
+
private currentTxLabel;
|
|
43
|
+
private txTimer;
|
|
44
|
+
constructor(bindings?: LoggerBindings);
|
|
45
|
+
startRecordingTxSimulation(txLabel: string): void;
|
|
46
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode, stats?: Record<string, string>): void;
|
|
47
|
+
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
48
|
+
recordEnqueuedCallSimulationFailure(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
49
|
+
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible'): void;
|
|
50
|
+
recordProverMetrics(txLabel: string, metrics: Partial<PublicTxMetrics>): void;
|
|
51
|
+
prettyPrint(filter?: PublicTxMetricsFilter): void;
|
|
52
|
+
toPrettyString(filter?: PublicTxMetricsFilter): string;
|
|
53
|
+
toJSON(indent?: number): string;
|
|
54
|
+
toGithubActionBenchmarkJSON(indent?: number): string;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF9leGVjdXRvcl9tZXRyaWNzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGljL3Rlc3RfZXhlY3V0b3JfbWV0cmljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sNEJBQTRCLENBQUM7QUFFNUYsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHdEQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVoRixNQUFNLFdBQVcseUJBQXlCO0lBQ3hDLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZixVQUFVLEVBQUUsTUFBTSxDQUFDO0lBQ25CLFFBQVEsRUFBRSxNQUFNLENBQUM7SUFDakIseUJBQXlCLEVBQUUsTUFBTSxDQUFDO0lBQ2xDLFFBQVEsRUFBRSxPQUFPLENBQUM7Q0FDbkI7QUFFRCxNQUFNLFdBQVcsZUFBZTtJQUU5QixlQUFlLEVBQUUsTUFBTSxDQUFDO0lBQ3hCLFFBQVEsRUFBRSxNQUFNLEdBQUcsU0FBUyxDQUFDO0lBQzdCLHlCQUF5QixFQUFFLE1BQU0sQ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AA;IACH,MAAM,IAAA;IACN,SAAS,IAAA;IACT,YAAY,IAAA;IACZ,OAAO,IAAA;CACR;AA2BD,qBAAa,mBAAoB,YAAW,wBAAwB;;IAClE,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,OAAO,CAAoB;IAEnC,YAAY,QAAQ,CAAC,EAAE,cAAc,EAEpC;IAED,0BAA0B,CAAC,OAAO,EAAE,MAAM,QAMzC;IAED,yBAAyB,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,EACjB,YAAY,CAAC,EAAE,UAAU,EACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAgB/B;IAED,4BAA4B,CAC1B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,MAAM,QAGlC;IAED,mCAAmC,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,MAAM,QAGlC;IAoBD,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB,QAgBtF;IAED,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,QAUrE;IAED,WAAW,CAAC,MAAM,GAAE,qBAAiD,QAEpE;IAED,cAAc,CAAC,MAAM,GAAE,qBAAiD,UA+EvE;IA0BD,MAAM,CAAC,MAAM,SAAI,UAEhB;IAED,2BAA2B,CAAC,MAAM,SAAI,UA4FrC;CACF"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { createLogger } from '@aztec-labs/foundation/log';
|
|
2
|
+
import { Timer } from '@aztec-labs/foundation/timer';
|
|
3
|
+
import { strict as assert } from 'assert';
|
|
4
|
+
const NUM_SPACES = 4;
|
|
5
|
+
const H1 = '# ';
|
|
6
|
+
const H2 = '\n## ';
|
|
7
|
+
const INDENT = ' '.repeat(NUM_SPACES);
|
|
8
|
+
const INDENT0 = '- ';
|
|
9
|
+
const INDENT1 = INDENT + '- ';
|
|
10
|
+
const INDENT2 = INDENT + INDENT + '- ';
|
|
11
|
+
const H_LINE = '\n---------------------------------------------------------------------';
|
|
12
|
+
export var PublicTxMetricsFilter = /*#__PURE__*/ function(PublicTxMetricsFilter) {
|
|
13
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["ALL"] = 0] = "ALL";
|
|
14
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["TOTALS"] = 1] = "TOTALS";
|
|
15
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["DURATIONS"] = 2] = "DURATIONS";
|
|
16
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["INSTRUCTIONS"] = 3] = "INSTRUCTIONS";
|
|
17
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["PROVING"] = 4] = "PROVING";
|
|
18
|
+
return PublicTxMetricsFilter;
|
|
19
|
+
}({});
|
|
20
|
+
function createEmptyTxMetrics() {
|
|
21
|
+
return {
|
|
22
|
+
// TS simulation
|
|
23
|
+
totalDurationMs: 0,
|
|
24
|
+
manaUsed: 0,
|
|
25
|
+
totalInstructionsExecuted: 0,
|
|
26
|
+
nonRevertiblePrivateInsertionsUs: undefined,
|
|
27
|
+
revertiblePrivateInsertionsUs: undefined,
|
|
28
|
+
enqueuedCalls: [],
|
|
29
|
+
revertedCode: undefined,
|
|
30
|
+
// Proving
|
|
31
|
+
proverSimulationStepMs: undefined,
|
|
32
|
+
proverProvingStepMs: undefined,
|
|
33
|
+
proverTraceGenerationStepMs: undefined,
|
|
34
|
+
// Proving (detail)
|
|
35
|
+
traceGenerationInteractionsMs: undefined,
|
|
36
|
+
traceGenerationTracesMs: undefined,
|
|
37
|
+
provingSumcheckMs: undefined,
|
|
38
|
+
provingPcsMs: undefined,
|
|
39
|
+
provingLogDerivativeInverseMs: undefined,
|
|
40
|
+
provingLogDerivativeInverseCommitmentsMs: undefined,
|
|
41
|
+
provingWireCommitmentsMs: undefined
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export class TestExecutorMetrics {
|
|
45
|
+
logger;
|
|
46
|
+
// tx label -> tx metrics
|
|
47
|
+
txMetrics = new Map();
|
|
48
|
+
currentTxLabel;
|
|
49
|
+
txTimer;
|
|
50
|
+
constructor(bindings){
|
|
51
|
+
this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
|
|
52
|
+
}
|
|
53
|
+
startRecordingTxSimulation(txLabel) {
|
|
54
|
+
assert(!this.currentTxLabel, 'Cannot start recording tx simulation when another is live');
|
|
55
|
+
assert(!this.txMetrics.has(txLabel), 'Cannot start recording metrics for tx with duplicate label');
|
|
56
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
57
|
+
this.currentTxLabel = txLabel;
|
|
58
|
+
this.txTimer = new Timer();
|
|
59
|
+
}
|
|
60
|
+
stopRecordingTxSimulation(txLabel, gasUsed, revertedCode, stats) {
|
|
61
|
+
assert(this.currentTxLabel === txLabel, 'Cannot stop recording metrics for tx when another is live');
|
|
62
|
+
const txMetrics = this.txMetrics.get(txLabel);
|
|
63
|
+
// total duration of tx
|
|
64
|
+
txMetrics.totalDurationMs = this.txTimer.ms();
|
|
65
|
+
this.logger.debug(`Public TX simulation of ${txLabel} took ${txMetrics.totalDurationMs}ms`);
|
|
66
|
+
// manaUsed and totalInstructionsExecuted are tx-level totals reported by the simulator.
|
|
67
|
+
txMetrics.manaUsed = gasUsed?.publicGas.l2Gas;
|
|
68
|
+
txMetrics.totalInstructionsExecuted = Number(stats?.['total_instructions_executed'] ?? 0);
|
|
69
|
+
txMetrics.revertedCode = revertedCode;
|
|
70
|
+
this.currentTxLabel = undefined;
|
|
71
|
+
}
|
|
72
|
+
recordEnqueuedCallSimulation(fnName, durationMs, manaUsed, totalInstructionsExecuted) {
|
|
73
|
+
this.#recordEnqueuedCallSimulation(fnName, durationMs, manaUsed, totalInstructionsExecuted, false);
|
|
74
|
+
}
|
|
75
|
+
recordEnqueuedCallSimulationFailure(fnName, durationMs, manaUsed, totalInstructionsExecuted) {
|
|
76
|
+
this.#recordEnqueuedCallSimulation(fnName, durationMs, manaUsed, totalInstructionsExecuted, true);
|
|
77
|
+
}
|
|
78
|
+
#recordEnqueuedCallSimulation(fnName, durationMs, manaUsed, totalInstructionsExecuted, reverted) {
|
|
79
|
+
assert(this.currentTxLabel, 'Cannot record enqueued call simulation when no tx is live');
|
|
80
|
+
const txMetrics = this.txMetrics.get(this.currentTxLabel);
|
|
81
|
+
txMetrics.enqueuedCalls.push({
|
|
82
|
+
fnName,
|
|
83
|
+
durationMs,
|
|
84
|
+
manaUsed,
|
|
85
|
+
totalInstructionsExecuted: totalInstructionsExecuted,
|
|
86
|
+
reverted
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
recordPrivateEffectsInsertion(durationUs, type) {
|
|
90
|
+
assert(this.currentTxLabel, 'Cannot record private effects insertion when no tx is live');
|
|
91
|
+
const txMetrics = this.txMetrics.get(this.currentTxLabel);
|
|
92
|
+
if (type === 'revertible') {
|
|
93
|
+
assert(txMetrics.revertiblePrivateInsertionsUs === undefined, 'Cannot RE-record revertible insertions of private effects');
|
|
94
|
+
txMetrics.revertiblePrivateInsertionsUs = durationUs;
|
|
95
|
+
} else {
|
|
96
|
+
assert(txMetrics.nonRevertiblePrivateInsertionsUs === undefined, 'Cannot RE-record non-revertible insertions of private effects');
|
|
97
|
+
txMetrics.nonRevertiblePrivateInsertionsUs = durationUs;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
recordProverMetrics(txLabel, metrics) {
|
|
101
|
+
if (!this.txMetrics.has(txLabel)) {
|
|
102
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
103
|
+
}
|
|
104
|
+
const txMetrics = this.txMetrics.get(txLabel);
|
|
105
|
+
for (const [key, value] of Object.entries(metrics)){
|
|
106
|
+
if (key in txMetrics) {
|
|
107
|
+
txMetrics[key] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
prettyPrint(filter = 0) {
|
|
112
|
+
this.logger.info(this.toPrettyString(filter));
|
|
113
|
+
}
|
|
114
|
+
toPrettyString(filter = 0) {
|
|
115
|
+
let pretty = '';
|
|
116
|
+
//pretty += H_LINE + '\n';
|
|
117
|
+
pretty += `${H1}Public TX Simulation Metrics (${PublicTxMetricsFilter[filter]})\n`;
|
|
118
|
+
for (const [txLabel, txMetrics] of this.txMetrics.entries()){
|
|
119
|
+
//pretty += H_LINE + '\n';
|
|
120
|
+
pretty += `${H2}TX Label: ${txLabel}\n`;
|
|
121
|
+
if (filter == 2 || filter === 1 || filter === 0) {
|
|
122
|
+
pretty += `${INDENT0}Total duration: ${fmtNum(txMetrics.totalDurationMs, 'ms')}\n`;
|
|
123
|
+
}
|
|
124
|
+
if (filter === 1 || filter === 0) {
|
|
125
|
+
const manaUsed = txMetrics.manaUsed || 0;
|
|
126
|
+
pretty += `${INDENT0}Total mana used: ${fmtNum(manaUsed)}\n`;
|
|
127
|
+
const manaPerSecond = Math.round(manaUsed * 1000 / txMetrics.totalDurationMs);
|
|
128
|
+
pretty += `${INDENT0}Mana per second: ${fmtNum(manaPerSecond)}\n`;
|
|
129
|
+
}
|
|
130
|
+
if (filter === 3 || filter === 1 || filter === 0) {
|
|
131
|
+
pretty += `${INDENT0}Total instructions executed: ${fmtNum(txMetrics.totalInstructionsExecuted)}\n`;
|
|
132
|
+
}
|
|
133
|
+
if (filter === 2 || filter === 0) {
|
|
134
|
+
pretty += `${INDENT0}Private insertions:\n`;
|
|
135
|
+
pretty += `${INDENT1}Non-revertible: ${fmtNum(txMetrics.nonRevertiblePrivateInsertionsUs / 1_000, 'ms')}\n`;
|
|
136
|
+
pretty += `${INDENT1}Revertible: ${fmtNum(txMetrics.revertiblePrivateInsertionsUs / 1_000, 'ms')}\n`;
|
|
137
|
+
}
|
|
138
|
+
if (filter === 4 || filter === 0) {
|
|
139
|
+
let provingPretty = '';
|
|
140
|
+
if (txMetrics.proverSimulationStepMs !== undefined) {
|
|
141
|
+
provingPretty += `${INDENT1}Simulation (all): ${fmtNum(txMetrics.proverSimulationStepMs, 'ms')}\n`;
|
|
142
|
+
}
|
|
143
|
+
if (txMetrics.proverProvingStepMs !== undefined) {
|
|
144
|
+
provingPretty += `${INDENT1}Proving (all): ${fmtNum(txMetrics.proverProvingStepMs, 'ms')}\n`;
|
|
145
|
+
}
|
|
146
|
+
if (txMetrics.proverTraceGenerationStepMs !== undefined) {
|
|
147
|
+
provingPretty += `${INDENT1}Trace generation (all): ${fmtNum(txMetrics.proverTraceGenerationStepMs, 'ms')}\n`;
|
|
148
|
+
}
|
|
149
|
+
if (txMetrics.traceGenerationInteractionsMs !== undefined) {
|
|
150
|
+
provingPretty += `${INDENT1}Trace generation interactions: ${fmtNum(txMetrics.traceGenerationInteractionsMs, 'ms')}\n`;
|
|
151
|
+
}
|
|
152
|
+
if (txMetrics.traceGenerationTracesMs !== undefined) {
|
|
153
|
+
provingPretty += `${INDENT1}Trace generation traces: ${fmtNum(txMetrics.traceGenerationTracesMs, 'ms')}\n`;
|
|
154
|
+
}
|
|
155
|
+
if (txMetrics.provingSumcheckMs !== undefined) {
|
|
156
|
+
provingPretty += `${INDENT1}Sumcheck: ${fmtNum(txMetrics.provingSumcheckMs, 'ms')}\n`;
|
|
157
|
+
}
|
|
158
|
+
if (txMetrics.provingPcsMs !== undefined) {
|
|
159
|
+
provingPretty += `${INDENT1}PCS: ${fmtNum(txMetrics.provingPcsMs, 'ms')}\n`;
|
|
160
|
+
}
|
|
161
|
+
if (txMetrics.provingLogDerivativeInverseMs !== undefined) {
|
|
162
|
+
provingPretty += `${INDENT1}Log derivative inverse: ${fmtNum(txMetrics.provingLogDerivativeInverseMs, 'ms')}\n`;
|
|
163
|
+
}
|
|
164
|
+
if (txMetrics.provingLogDerivativeInverseCommitmentsMs !== undefined) {
|
|
165
|
+
provingPretty += `${INDENT1}Log derivative inverse commitments: ${fmtNum(txMetrics.provingLogDerivativeInverseCommitmentsMs, 'ms')}\n`;
|
|
166
|
+
}
|
|
167
|
+
if (txMetrics.provingWireCommitmentsMs !== undefined) {
|
|
168
|
+
provingPretty += `${INDENT1}Wire commitments: ${fmtNum(txMetrics.provingWireCommitmentsMs, 'ms')}\n`;
|
|
169
|
+
}
|
|
170
|
+
if (provingPretty.length > 0) {
|
|
171
|
+
pretty += `${INDENT0}Proving:\n${provingPretty}`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (filter !== 1) {
|
|
175
|
+
// totals exclude enqueued calls
|
|
176
|
+
pretty += this.#enqueuedCallsToPrettyString(txMetrics, filter);
|
|
177
|
+
}
|
|
178
|
+
if (txMetrics.revertedCode !== undefined && !txMetrics.revertedCode.isOK()) {
|
|
179
|
+
pretty += `${INDENT0}Reverted code: ${txMetrics.revertedCode?.getDescription()}\n`;
|
|
180
|
+
}
|
|
181
|
+
pretty += H_LINE + '\n';
|
|
182
|
+
}
|
|
183
|
+
return pretty;
|
|
184
|
+
}
|
|
185
|
+
#enqueuedCallsToPrettyString(txMetrics, filter) {
|
|
186
|
+
let pretty = '';
|
|
187
|
+
pretty += `${INDENT0}Enqueued public calls:\n`;
|
|
188
|
+
for (const enqueuedCall of txMetrics.enqueuedCalls){
|
|
189
|
+
pretty += `${INDENT1}**Fn: ${enqueuedCall.fnName}**\n`;
|
|
190
|
+
if (filter === 2 || filter === 0) {
|
|
191
|
+
pretty += `${INDENT2}Duration: ${fmtNum(enqueuedCall.durationMs, 'ms')}\n`;
|
|
192
|
+
}
|
|
193
|
+
if (filter === 0) {
|
|
194
|
+
pretty += `${INDENT2}Mana used: ${fmtNum(enqueuedCall.manaUsed)}\n`;
|
|
195
|
+
const manaPerSecond = Math.round(enqueuedCall.manaUsed * 1000 / enqueuedCall.durationMs);
|
|
196
|
+
pretty += `${INDENT2}Mana per second: ${fmtNum(manaPerSecond)}\n`;
|
|
197
|
+
}
|
|
198
|
+
if (filter === 3 || filter === 0) {
|
|
199
|
+
pretty += `${INDENT2}Instructions executed: ${fmtNum(enqueuedCall.totalInstructionsExecuted)}\n`;
|
|
200
|
+
}
|
|
201
|
+
if (enqueuedCall.reverted) {
|
|
202
|
+
pretty += `${INDENT2}Reverted!\n`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return pretty;
|
|
206
|
+
}
|
|
207
|
+
toJSON(indent = 2) {
|
|
208
|
+
return JSON.stringify(Object.fromEntries(this.txMetrics.entries()), null, indent);
|
|
209
|
+
}
|
|
210
|
+
toGithubActionBenchmarkJSON(indent = 2) {
|
|
211
|
+
const metricsInfo = {
|
|
212
|
+
totalInstructionsExecuted: {
|
|
213
|
+
name: 'totalInstructionsExecuted',
|
|
214
|
+
unit: '#instructions',
|
|
215
|
+
category: 3
|
|
216
|
+
},
|
|
217
|
+
totalDurationMs: {
|
|
218
|
+
name: 'totalDurationMs',
|
|
219
|
+
unit: 'ms',
|
|
220
|
+
category: 2
|
|
221
|
+
},
|
|
222
|
+
manaUsed: {
|
|
223
|
+
name: 'manaUsed',
|
|
224
|
+
unit: 'mana',
|
|
225
|
+
category: 1
|
|
226
|
+
},
|
|
227
|
+
nonRevertiblePrivateInsertionsUs: {
|
|
228
|
+
name: 'nonRevertiblePrivateInsertionsUs',
|
|
229
|
+
unit: 'us',
|
|
230
|
+
category: 2
|
|
231
|
+
},
|
|
232
|
+
revertiblePrivateInsertionsUs: {
|
|
233
|
+
name: 'revertiblePrivateInsertionsUs',
|
|
234
|
+
unit: 'us',
|
|
235
|
+
category: 2
|
|
236
|
+
},
|
|
237
|
+
proverSimulationStepMs: {
|
|
238
|
+
name: 'proverSimulationStepMs',
|
|
239
|
+
unit: 'ms',
|
|
240
|
+
category: 4
|
|
241
|
+
},
|
|
242
|
+
proverProvingStepMs: {
|
|
243
|
+
name: 'proverProvingStepMs',
|
|
244
|
+
unit: 'ms',
|
|
245
|
+
category: 4
|
|
246
|
+
},
|
|
247
|
+
proverTraceGenerationStepMs: {
|
|
248
|
+
name: 'proverTraceGenerationStepMs',
|
|
249
|
+
unit: 'ms',
|
|
250
|
+
category: 4
|
|
251
|
+
},
|
|
252
|
+
traceGenerationInteractionsMs: {
|
|
253
|
+
name: 'traceGenerationInteractionsMs',
|
|
254
|
+
unit: 'ms',
|
|
255
|
+
category: 4
|
|
256
|
+
},
|
|
257
|
+
traceGenerationTracesMs: {
|
|
258
|
+
name: 'traceGenerationTracesMs',
|
|
259
|
+
unit: 'ms',
|
|
260
|
+
category: 4
|
|
261
|
+
},
|
|
262
|
+
provingSumcheckMs: {
|
|
263
|
+
name: 'provingSumcheckMs',
|
|
264
|
+
unit: 'ms',
|
|
265
|
+
category: 4
|
|
266
|
+
},
|
|
267
|
+
provingPcsMs: {
|
|
268
|
+
name: 'provingPcsMs',
|
|
269
|
+
unit: 'ms',
|
|
270
|
+
category: 4
|
|
271
|
+
},
|
|
272
|
+
provingLogDerivativeInverseMs: {
|
|
273
|
+
name: 'provingLogDerivativeInverseMs',
|
|
274
|
+
unit: 'ms',
|
|
275
|
+
category: 4
|
|
276
|
+
},
|
|
277
|
+
provingLogDerivativeInverseCommitmentsMs: {
|
|
278
|
+
name: 'provingLogDerivativeInverseCommitmentsMs',
|
|
279
|
+
unit: 'ms',
|
|
280
|
+
category: 4
|
|
281
|
+
},
|
|
282
|
+
provingWireCommitmentsMs: {
|
|
283
|
+
name: 'provingWireCommitmentsMs',
|
|
284
|
+
unit: 'ms',
|
|
285
|
+
category: 4
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
const data = [];
|
|
289
|
+
for (const [txLabel, txMetrics] of this.txMetrics.entries()){
|
|
290
|
+
for (const [key, value] of Object.entries(txMetrics)){
|
|
291
|
+
if (value !== undefined && key in metricsInfo) {
|
|
292
|
+
data.push({
|
|
293
|
+
name: `${txLabel}/${metricsInfo[key].name}`,
|
|
294
|
+
value: value,
|
|
295
|
+
unit: metricsInfo[key].unit
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return JSON.stringify(data, null, indent);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function fmtNum(num, unit) {
|
|
304
|
+
return `\`${num.toLocaleString()}${unit ? ` ${unit}` : ''}\``;
|
|
305
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class manage a de-duplicated set of class IDs that errors if you try to add a duplicate.
|
|
3
|
+
* Useful for bytecode retrieval hints to avoid duplicates in parent trace & grandparent trace....
|
|
4
|
+
*/
|
|
5
|
+
export declare class UniqueClassIds {
|
|
6
|
+
private readonly parent?;
|
|
7
|
+
private readonly classIds;
|
|
8
|
+
constructor(parent?: UniqueClassIds | undefined);
|
|
9
|
+
/**
|
|
10
|
+
* Create a fork that references this one as its parent
|
|
11
|
+
*/
|
|
12
|
+
fork(): UniqueClassIds;
|
|
13
|
+
/**
|
|
14
|
+
* Check for a class ID here or in parent's (recursively).
|
|
15
|
+
*
|
|
16
|
+
* @param classId - the contract class ID (as a string) to check
|
|
17
|
+
* @returns boolean: whether the class ID is here
|
|
18
|
+
*/
|
|
19
|
+
has(classId: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get the total number of classIds
|
|
22
|
+
*/
|
|
23
|
+
size(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Add a class ID (if not already present) to the set.
|
|
26
|
+
*
|
|
27
|
+
* @param classId - the contract class ID (as a string)
|
|
28
|
+
*/
|
|
29
|
+
add(classId: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Merge in another set of unique class IDs into this one, but fail on duplicates.
|
|
32
|
+
*
|
|
33
|
+
* @param incoming: other unique class IDs
|
|
34
|
+
*/
|
|
35
|
+
acceptAndMerge(incoming: UniqueClassIds): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pcXVlX2NsYXNzX2lkcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpYy91bmlxdWVfY2xhc3NfaWRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBOzs7R0FHRztBQUNILHFCQUFhLGNBQWM7SUFHYixPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQztJQUZwQyxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsQ0FBMEI7SUFFbkQsWUFBNkIsTUFBTSxDQUFDLDRCQUFnQixFQUFJO0lBRXhEOztPQUVHO0lBQ0ksSUFBSSxtQkFFVjtJQUVEOzs7OztPQUtHO0lBQ0ksR0FBRyxDQUFDLE9BQU8sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQVNuQztJQUVEOztPQUVHO0lBQ0ksSUFBSSxJQUFJLE1BQU0sQ0FFcEI7SUFFRDs7OztPQUlHO0lBQ0ksR0FBRyxDQUFDLE9BQU8sRUFBRSxNQUFNLFFBU3pCO0lBRUQ7Ozs7T0FJRztJQUNJLGNBQWMsQ0FBQyxRQUFRLEVBQUUsY0FBYyxRQWE3QztDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unique_class_ids.d.ts","sourceRoot":"","sources":["../../src/public/unique_class_ids.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAFpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,YAA6B,MAAM,CAAC,4BAAgB,EAAI;IAExD;;OAEG;IACI,IAAI,mBAEV;IAED;;;;;OAKG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASnC;IAED;;OAEG;IACI,IAAI,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,QASzB;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,cAAc,QAa7C;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS } from '@aztec-labs/constants';
|
|
2
|
+
import { strict as assert } from 'assert';
|
|
3
|
+
/**
|
|
4
|
+
* A class manage a de-duplicated set of class IDs that errors if you try to add a duplicate.
|
|
5
|
+
* Useful for bytecode retrieval hints to avoid duplicates in parent trace & grandparent trace....
|
|
6
|
+
*/ export class UniqueClassIds {
|
|
7
|
+
parent;
|
|
8
|
+
classIds;
|
|
9
|
+
constructor(parent){
|
|
10
|
+
this.parent = parent;
|
|
11
|
+
this.classIds = new Set();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a fork that references this one as its parent
|
|
15
|
+
*/ fork() {
|
|
16
|
+
return new UniqueClassIds(/*parent=*/ this);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check for a class ID here or in parent's (recursively).
|
|
20
|
+
*
|
|
21
|
+
* @param classId - the contract class ID (as a string) to check
|
|
22
|
+
* @returns boolean: whether the class ID is here
|
|
23
|
+
*/ has(classId) {
|
|
24
|
+
// First try check this' classIds
|
|
25
|
+
let here = this.classIds.has(classId);
|
|
26
|
+
// Then try parent's
|
|
27
|
+
if (!here && this.parent) {
|
|
28
|
+
// Note: this will recurse to grandparent/etc until we reach top or find it
|
|
29
|
+
here = this.parent.has(classId);
|
|
30
|
+
}
|
|
31
|
+
return here;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the total number of classIds
|
|
35
|
+
*/ size() {
|
|
36
|
+
return this.classIds.size + (this.parent ? this.parent.size() : 0);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Add a class ID (if not already present) to the set.
|
|
40
|
+
*
|
|
41
|
+
* @param classId - the contract class ID (as a string)
|
|
42
|
+
*/ add(classId) {
|
|
43
|
+
assert(!this.has(classId), `Bug! Tried to add duplicate classId ${classId} to set of unique classIds.`);
|
|
44
|
+
if (!this.has(classId)) {
|
|
45
|
+
this.classIds.add(classId);
|
|
46
|
+
assert(this.size() <= MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS, `Bug! Surpassed limit (${MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS}) of unique contract class IDs used for bytecode retrievals.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Merge in another set of unique class IDs into this one, but fail on duplicates.
|
|
51
|
+
*
|
|
52
|
+
* @param incoming: other unique class IDs
|
|
53
|
+
*/ acceptAndMerge(incoming) {
|
|
54
|
+
for (const classId of incoming.classIds.keys()){
|
|
55
|
+
assert(!this.has(classId), `Bug! Cannot merge classId ${classId} into set of unique classIds as it already exists.`);
|
|
56
|
+
this.classIds.add(classId);
|
|
57
|
+
}
|
|
58
|
+
// since set() has an assertion, and size() always checks parent, this should be impossible
|
|
59
|
+
assert(this.size() <= MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS, `Bug! Merging unique class Ids should never exceed the limit of ${MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS}.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PublicCallRequestWithCalldata, type Tx, TxExecutionPhase } from '@aztec-labs/stdlib/tx';
|
|
2
|
+
export declare function getCallRequestsWithCalldataByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequestWithCalldata[];
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wdWJsaWMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLDZCQUE2QixFQUFFLEtBQUssRUFBRSxFQUFFLGdCQUFnQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFakcsd0JBQWdCLGtDQUFrQyxDQUFDLEVBQUUsRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLGdCQUFnQixHQUFHLDZCQUE2QixFQUFFLENBYW5IIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/public/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEjG,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB,GAAG,6BAA6B,EAAE,CAanH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TxExecutionPhase } from '@aztec-labs/stdlib/tx';
|
|
2
|
+
export function getCallRequestsWithCalldataByPhase(tx, phase) {
|
|
3
|
+
switch(phase){
|
|
4
|
+
case TxExecutionPhase.SETUP:
|
|
5
|
+
return tx.getNonRevertiblePublicCallRequestsWithCalldata();
|
|
6
|
+
case TxExecutionPhase.APP_LOGIC:
|
|
7
|
+
return tx.getRevertiblePublicCallRequestsWithCalldata();
|
|
8
|
+
case TxExecutionPhase.TEARDOWN:
|
|
9
|
+
{
|
|
10
|
+
const request = tx.getTeardownPublicCallRequestWithCalldata();
|
|
11
|
+
return request ? [
|
|
12
|
+
request
|
|
13
|
+
] : [];
|
|
14
|
+
}
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`Unknown phase: ${phase}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dest/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './public/index.js';
|
|
2
|
+
export * from './private/acvm/index.js';
|
|
3
|
+
export { WASMSimulatorWithBlobs } from './private/acvm_wasm_with_blobs.js';
|
|
4
|
+
export { NativeACVMSimulator } from './private/acvm_native.js';
|
|
5
|
+
export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
|
|
6
|
+
export * from './common/index.js';
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMzRSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUMvRCxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxLQUFLLFlBQVksRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQzFGLGNBQWMsbUJBQW1CLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC1F,cAAc,mBAAmB,CAAC"}
|
package/dest/server.js
ADDED