@aztec/bb-prover 1.0.0-nightly.20250708 → 1.0.0-staging.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.
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
3
|
import type { BBConfig } from '../config.js';
|
|
5
4
|
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
5
|
private verifier;
|
|
7
|
-
private telemetry;
|
|
8
6
|
private logger;
|
|
9
7
|
private queue;
|
|
10
|
-
|
|
11
|
-
constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
8
|
+
constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, logger?: import("@aztec/foundation/log").Logger);
|
|
12
9
|
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
10
|
stop(): Promise<void>;
|
|
14
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queued_ivc_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_ivc_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"queued_ivc_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_ivc_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAKnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,KAAK,CAAc;gBAGzB,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,MAAM,yCAAgD;IAOzD,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAI/D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtB"}
|
|
@@ -1,127 +1,18 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
-
import { Attributes, Metrics, ValueType, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
import { createHistogram } from 'node:perf_hooks';
|
|
5
|
-
class IVCVerifierMetrics {
|
|
6
|
-
ivcVerificationHistogram;
|
|
7
|
-
ivcTotalVerificationHistogram;
|
|
8
|
-
ivcFailureCount;
|
|
9
|
-
localHistogramOk = createHistogram({
|
|
10
|
-
min: 1,
|
|
11
|
-
max: 5 * 60 * 1000
|
|
12
|
-
});
|
|
13
|
-
localHistogramFails = createHistogram({
|
|
14
|
-
min: 1,
|
|
15
|
-
max: 5 * 60 * 1000
|
|
16
|
-
});
|
|
17
|
-
aggDurationMetrics;
|
|
18
|
-
constructor(client, name = 'QueuedIVCVerifier'){
|
|
19
|
-
const meter = client.getMeter(name);
|
|
20
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
|
|
21
|
-
unit: 'ms',
|
|
22
|
-
description: 'Duration to verify client IVC proofs',
|
|
23
|
-
valueType: ValueType.INT
|
|
24
|
-
});
|
|
25
|
-
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
26
|
-
unit: 'ms',
|
|
27
|
-
description: 'Total duration to verify client IVC proofs, including serde',
|
|
28
|
-
valueType: ValueType.INT
|
|
29
|
-
});
|
|
30
|
-
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
|
|
31
|
-
description: 'Count of failed IVC proof verifications',
|
|
32
|
-
valueType: ValueType.INT
|
|
33
|
-
});
|
|
34
|
-
this.aggDurationMetrics = {
|
|
35
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG, {
|
|
36
|
-
valueType: ValueType.DOUBLE,
|
|
37
|
-
description: 'AVG ivc verification',
|
|
38
|
-
unit: 'ms'
|
|
39
|
-
}),
|
|
40
|
-
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
|
|
41
|
-
valueType: ValueType.DOUBLE,
|
|
42
|
-
description: 'MAX ivc verification',
|
|
43
|
-
unit: 'ms'
|
|
44
|
-
}),
|
|
45
|
-
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
|
|
46
|
-
valueType: ValueType.DOUBLE,
|
|
47
|
-
description: 'MIN ivc verification',
|
|
48
|
-
unit: 'ms'
|
|
49
|
-
}),
|
|
50
|
-
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
|
|
51
|
-
valueType: ValueType.DOUBLE,
|
|
52
|
-
description: 'P50 ivc verification',
|
|
53
|
-
unit: 'ms'
|
|
54
|
-
}),
|
|
55
|
-
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
|
|
56
|
-
valueType: ValueType.DOUBLE,
|
|
57
|
-
description: 'P90 ivc verification',
|
|
58
|
-
unit: 'ms'
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
62
|
-
}
|
|
63
|
-
recordIVCVerification(result) {
|
|
64
|
-
this.ivcVerificationHistogram.record(Math.ceil(result.durationMs), {
|
|
65
|
-
[Attributes.OK]: result.valid
|
|
66
|
-
});
|
|
67
|
-
this.ivcTotalVerificationHistogram.record(Math.ceil(result.totalDurationMs), {
|
|
68
|
-
[Attributes.OK]: result.valid
|
|
69
|
-
});
|
|
70
|
-
if (!result.valid) {
|
|
71
|
-
this.ivcFailureCount.add(1);
|
|
72
|
-
this.localHistogramFails.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
73
|
-
} else {
|
|
74
|
-
this.localHistogramOk.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
aggregate = (res)=>{
|
|
78
|
-
for (const [histogram, ok] of [
|
|
79
|
-
[
|
|
80
|
-
this.localHistogramOk,
|
|
81
|
-
true
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
this.localHistogramFails,
|
|
85
|
-
false
|
|
86
|
-
]
|
|
87
|
-
]){
|
|
88
|
-
res.observe(this.aggDurationMetrics.avg, histogram.mean, {
|
|
89
|
-
[Attributes.OK]: ok
|
|
90
|
-
});
|
|
91
|
-
res.observe(this.aggDurationMetrics.max, histogram.max, {
|
|
92
|
-
[Attributes.OK]: ok
|
|
93
|
-
});
|
|
94
|
-
res.observe(this.aggDurationMetrics.min, histogram.min, {
|
|
95
|
-
[Attributes.OK]: ok
|
|
96
|
-
});
|
|
97
|
-
res.observe(this.aggDurationMetrics.p50, histogram.percentile(50), {
|
|
98
|
-
[Attributes.OK]: ok
|
|
99
|
-
});
|
|
100
|
-
res.observe(this.aggDurationMetrics.p90, histogram.percentile(90), {
|
|
101
|
-
[Attributes.OK]: ok
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
3
|
export class QueuedIVCVerifier {
|
|
107
4
|
verifier;
|
|
108
|
-
telemetry;
|
|
109
5
|
logger;
|
|
110
6
|
queue;
|
|
111
|
-
|
|
112
|
-
constructor(config, verifier, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_ivc_verifier')){
|
|
7
|
+
constructor(config, verifier, logger = createLogger('bb-prover:queued_ivc_verifier')){
|
|
113
8
|
this.verifier = verifier;
|
|
114
|
-
this.telemetry = telemetry;
|
|
115
9
|
this.logger = logger;
|
|
116
|
-
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
117
10
|
this.queue = new SerialQueue();
|
|
118
11
|
this.logger.info(`Starting QueuedIVCVerifier with ${config.numConcurrentIVCVerifiers} concurrent verifiers`);
|
|
119
12
|
this.queue.start(config.numConcurrentIVCVerifiers);
|
|
120
13
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.metrics.recordIVCVerification(result);
|
|
124
|
-
return result;
|
|
14
|
+
verifyProof(tx) {
|
|
15
|
+
return this.queue.put(()=>this.verifier.verifyProof(tx));
|
|
125
16
|
}
|
|
126
17
|
stop() {
|
|
127
18
|
return this.queue.end();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-staging.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -70,27 +70,27 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@aztec/bb.js": "1.0.0-
|
|
74
|
-
"@aztec/constants": "1.0.0-
|
|
75
|
-
"@aztec/foundation": "1.0.0-
|
|
76
|
-
"@aztec/noir-noirc_abi": "1.0.0-
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0-
|
|
78
|
-
"@aztec/noir-types": "1.0.0-
|
|
79
|
-
"@aztec/simulator": "1.0.0-
|
|
80
|
-
"@aztec/stdlib": "1.0.0-
|
|
81
|
-
"@aztec/telemetry-client": "1.0.0-
|
|
82
|
-
"@aztec/world-state": "1.0.0-
|
|
73
|
+
"@aztec/bb.js": "1.0.0-staging.1",
|
|
74
|
+
"@aztec/constants": "1.0.0-staging.1",
|
|
75
|
+
"@aztec/foundation": "1.0.0-staging.1",
|
|
76
|
+
"@aztec/noir-noirc_abi": "1.0.0-staging.1",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-staging.1",
|
|
78
|
+
"@aztec/noir-types": "1.0.0-staging.1",
|
|
79
|
+
"@aztec/simulator": "1.0.0-staging.1",
|
|
80
|
+
"@aztec/stdlib": "1.0.0-staging.1",
|
|
81
|
+
"@aztec/telemetry-client": "1.0.0-staging.1",
|
|
82
|
+
"@aztec/world-state": "1.0.0-staging.1",
|
|
83
83
|
"commander": "^12.1.0",
|
|
84
84
|
"pako": "^2.1.0",
|
|
85
85
|
"source-map-support": "^0.5.21",
|
|
86
86
|
"tslib": "^2.4.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@aztec/ethereum": "1.0.0-
|
|
90
|
-
"@aztec/kv-store": "1.0.0-
|
|
91
|
-
"@aztec/noir-contracts.js": "1.0.0-
|
|
92
|
-
"@aztec/noir-test-contracts.js": "1.0.0-
|
|
93
|
-
"@aztec/protocol-contracts": "1.0.0-
|
|
89
|
+
"@aztec/ethereum": "1.0.0-staging.1",
|
|
90
|
+
"@aztec/kv-store": "1.0.0-staging.1",
|
|
91
|
+
"@aztec/noir-contracts.js": "1.0.0-staging.1",
|
|
92
|
+
"@aztec/noir-test-contracts.js": "1.0.0-staging.1",
|
|
93
|
+
"@aztec/protocol-contracts": "1.0.0-staging.1",
|
|
94
94
|
"@jest/globals": "^30.0.0",
|
|
95
95
|
"@types/jest": "^30.0.0",
|
|
96
96
|
"@types/node": "^22.15.17",
|
|
@@ -2,133 +2,24 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
3
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
|
-
import {
|
|
6
|
-
Attributes,
|
|
7
|
-
type BatchObservableResult,
|
|
8
|
-
type Histogram,
|
|
9
|
-
Metrics,
|
|
10
|
-
type ObservableGauge,
|
|
11
|
-
type TelemetryClient,
|
|
12
|
-
type UpDownCounter,
|
|
13
|
-
ValueType,
|
|
14
|
-
getTelemetryClient,
|
|
15
|
-
} from '@aztec/telemetry-client';
|
|
16
|
-
|
|
17
|
-
import { createHistogram } from 'node:perf_hooks';
|
|
18
5
|
|
|
19
6
|
import type { BBConfig } from '../config.js';
|
|
20
7
|
|
|
21
|
-
class IVCVerifierMetrics {
|
|
22
|
-
private ivcVerificationHistogram: Histogram;
|
|
23
|
-
private ivcTotalVerificationHistogram: Histogram;
|
|
24
|
-
private ivcFailureCount: UpDownCounter;
|
|
25
|
-
private localHistogramOk = createHistogram({
|
|
26
|
-
min: 1,
|
|
27
|
-
max: 5 * 60 * 1000, // 5 min
|
|
28
|
-
});
|
|
29
|
-
private localHistogramFails = createHistogram({
|
|
30
|
-
min: 1,
|
|
31
|
-
max: 5 * 60 * 1000, // 5 min
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
private aggDurationMetrics: Record<'min' | 'max' | 'p50' | 'p90' | 'avg', ObservableGauge>;
|
|
35
|
-
|
|
36
|
-
constructor(client: TelemetryClient, name = 'QueuedIVCVerifier') {
|
|
37
|
-
const meter = client.getMeter(name);
|
|
38
|
-
|
|
39
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
|
|
40
|
-
unit: 'ms',
|
|
41
|
-
description: 'Duration to verify client IVC proofs',
|
|
42
|
-
valueType: ValueType.INT,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
46
|
-
unit: 'ms',
|
|
47
|
-
description: 'Total duration to verify client IVC proofs, including serde',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
|
|
52
|
-
description: 'Count of failed IVC proof verifications',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
this.aggDurationMetrics = {
|
|
57
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG, {
|
|
58
|
-
valueType: ValueType.DOUBLE,
|
|
59
|
-
description: 'AVG ivc verification',
|
|
60
|
-
unit: 'ms',
|
|
61
|
-
}),
|
|
62
|
-
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
|
|
63
|
-
valueType: ValueType.DOUBLE,
|
|
64
|
-
description: 'MAX ivc verification',
|
|
65
|
-
unit: 'ms',
|
|
66
|
-
}),
|
|
67
|
-
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
|
|
68
|
-
valueType: ValueType.DOUBLE,
|
|
69
|
-
description: 'MIN ivc verification',
|
|
70
|
-
unit: 'ms',
|
|
71
|
-
}),
|
|
72
|
-
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
|
|
73
|
-
valueType: ValueType.DOUBLE,
|
|
74
|
-
description: 'P50 ivc verification',
|
|
75
|
-
unit: 'ms',
|
|
76
|
-
}),
|
|
77
|
-
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
|
|
78
|
-
valueType: ValueType.DOUBLE,
|
|
79
|
-
description: 'P90 ivc verification',
|
|
80
|
-
unit: 'ms',
|
|
81
|
-
}),
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
recordIVCVerification(result: IVCProofVerificationResult) {
|
|
88
|
-
this.ivcVerificationHistogram.record(Math.ceil(result.durationMs), { [Attributes.OK]: result.valid });
|
|
89
|
-
this.ivcTotalVerificationHistogram.record(Math.ceil(result.totalDurationMs), { [Attributes.OK]: result.valid });
|
|
90
|
-
if (!result.valid) {
|
|
91
|
-
this.ivcFailureCount.add(1);
|
|
92
|
-
this.localHistogramFails.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
93
|
-
} else {
|
|
94
|
-
this.localHistogramOk.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private aggregate = (res: BatchObservableResult) => {
|
|
99
|
-
for (const [histogram, ok] of [
|
|
100
|
-
[this.localHistogramOk, true],
|
|
101
|
-
[this.localHistogramFails, false],
|
|
102
|
-
] as const) {
|
|
103
|
-
res.observe(this.aggDurationMetrics.avg, histogram.mean, { [Attributes.OK]: ok });
|
|
104
|
-
res.observe(this.aggDurationMetrics.max, histogram.max, { [Attributes.OK]: ok });
|
|
105
|
-
res.observe(this.aggDurationMetrics.min, histogram.min, { [Attributes.OK]: ok });
|
|
106
|
-
res.observe(this.aggDurationMetrics.p50, histogram.percentile(50), { [Attributes.OK]: ok });
|
|
107
|
-
res.observe(this.aggDurationMetrics.p90, histogram.percentile(90), { [Attributes.OK]: ok });
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
8
|
export class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
113
9
|
private queue: SerialQueue;
|
|
114
|
-
private metrics: IVCVerifierMetrics;
|
|
115
10
|
|
|
116
11
|
public constructor(
|
|
117
12
|
config: BBConfig,
|
|
118
13
|
private verifier: ClientProtocolCircuitVerifier,
|
|
119
|
-
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
120
14
|
private logger = createLogger('bb-prover:queued_ivc_verifier'),
|
|
121
15
|
) {
|
|
122
|
-
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
123
16
|
this.queue = new SerialQueue();
|
|
124
17
|
this.logger.info(`Starting QueuedIVCVerifier with ${config.numConcurrentIVCVerifiers} concurrent verifiers`);
|
|
125
18
|
this.queue.start(config.numConcurrentIVCVerifiers);
|
|
126
19
|
}
|
|
127
20
|
|
|
128
|
-
public
|
|
129
|
-
|
|
130
|
-
this.metrics.recordIVCVerification(result);
|
|
131
|
-
return result;
|
|
21
|
+
public verifyProof(tx: Tx): Promise<IVCProofVerificationResult> {
|
|
22
|
+
return this.queue.put(() => this.verifier.verifyProof(tx));
|
|
132
23
|
}
|
|
133
24
|
|
|
134
25
|
stop(): Promise<void> {
|