@aztec/bb-prover 0.0.1-commit.d3ec352c → 0.0.1-commit.e3c1de76
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/avm_proving_tests/avm_proving_tester.d.ts +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +9 -2
- package/dest/bb/execute.d.ts +6 -6
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +47 -76
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +9 -39
- package/dest/prover/client/bb_private_kernel_prover.d.ts +9 -3
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +14 -4
- package/dest/prover/client/bundle.d.ts +3 -3
- package/dest/prover/client/bundle.d.ts.map +1 -1
- package/dest/prover/client/bundle.js +2 -3
- package/dest/prover/client/lazy.d.ts +3 -3
- package/dest/prover/client/lazy.d.ts.map +1 -1
- package/dest/prover/client/lazy.js +2 -3
- package/dest/prover/proof_utils.js +1 -1
- package/dest/prover/server/bb_prover.d.ts +6 -9
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +416 -43
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +28 -26
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/test_circuit_prover.d.ts +4 -4
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +462 -59
- package/dest/verification_key/verification_key_data.d.ts +1 -8
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +1 -20
- package/dest/verifier/bb_verifier.d.ts +1 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +1 -4
- package/dest/verifier/queued_chonk_verifier.d.ts +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
- package/dest/verifier/queued_chonk_verifier.js +9 -40
- package/package.json +17 -17
- package/src/avm_proving_tests/avm_proving_tester.ts +12 -18
- package/src/bb/execute.ts +32 -60
- package/src/instrumentation.ts +8 -39
- package/src/prover/client/bb_private_kernel_prover.ts +19 -6
- package/src/prover/client/bundle.ts +3 -4
- package/src/prover/client/lazy.ts +3 -4
- package/src/prover/proof_utils.ts +1 -1
- package/src/prover/server/bb_prover.ts +23 -38
- package/src/test/delay_values.ts +30 -26
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +10 -13
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/bb_verifier.ts +1 -5
- package/src/verifier/queued_chonk_verifier.ts +9 -40
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
-
import { Attributes, Metrics,
|
|
3
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import { createHistogram } from 'node:perf_hooks';
|
|
5
5
|
class IVCVerifierMetrics {
|
|
6
6
|
ivcVerificationHistogram;
|
|
@@ -17,46 +17,15 @@ class IVCVerifierMetrics {
|
|
|
17
17
|
aggDurationMetrics;
|
|
18
18
|
constructor(client, name = 'QueuedIVCVerifier'){
|
|
19
19
|
const meter = client.getMeter(name);
|
|
20
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
valueType: ValueType.INT
|
|
24
|
-
});
|
|
25
|
-
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
26
|
-
unit: 'ms',
|
|
27
|
-
description: 'Total duration to verify chonk 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
|
-
});
|
|
20
|
+
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
|
|
21
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
22
|
+
this.ivcFailureCount = createUpDownCounterWithDefault(meter, Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
34
23
|
this.aggDurationMetrics = {
|
|
35
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
})
|
|
24
|
+
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
|
|
25
|
+
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
|
|
26
|
+
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN),
|
|
27
|
+
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50),
|
|
28
|
+
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90)
|
|
60
29
|
};
|
|
61
30
|
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
62
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e3c1de76",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -69,32 +69,32 @@
|
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/constants": "0.0.1-commit.
|
|
74
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
81
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.e3c1de76",
|
|
73
|
+
"@aztec/constants": "0.0.1-commit.e3c1de76",
|
|
74
|
+
"@aztec/foundation": "0.0.1-commit.e3c1de76",
|
|
75
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.e3c1de76",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.e3c1de76",
|
|
77
|
+
"@aztec/noir-types": "0.0.1-commit.e3c1de76",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.e3c1de76",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.e3c1de76",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.e3c1de76",
|
|
81
|
+
"@aztec/world-state": "0.0.1-commit.e3c1de76",
|
|
82
82
|
"commander": "^12.1.0",
|
|
83
83
|
"pako": "^2.1.0",
|
|
84
84
|
"source-map-support": "^0.5.21",
|
|
85
85
|
"tslib": "^2.4.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
89
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
90
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
91
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
92
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
88
|
+
"@aztec/ethereum": "0.0.1-commit.e3c1de76",
|
|
89
|
+
"@aztec/kv-store": "0.0.1-commit.e3c1de76",
|
|
90
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e3c1de76",
|
|
91
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.e3c1de76",
|
|
92
|
+
"@aztec/protocol-contracts": "0.0.1-commit.e3c1de76",
|
|
93
93
|
"@jest/globals": "^30.0.0",
|
|
94
94
|
"@types/jest": "^30.0.0",
|
|
95
95
|
"@types/node": "^22.15.17",
|
|
96
96
|
"@types/source-map-support": "^0.5.10",
|
|
97
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
97
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
98
98
|
"jest": "^30.0.0",
|
|
99
99
|
"jest-mock-extended": "^4.0.0",
|
|
100
100
|
"ts-node": "^10.9.1",
|
|
@@ -18,14 +18,7 @@ import fs from 'node:fs/promises';
|
|
|
18
18
|
import { tmpdir } from 'node:os';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
type BBResult,
|
|
23
|
-
type BBSuccess,
|
|
24
|
-
BB_RESULT,
|
|
25
|
-
VK_FILENAME,
|
|
26
|
-
generateAvmProof,
|
|
27
|
-
verifyAvmProof,
|
|
28
|
-
} from '../bb/execute.js';
|
|
21
|
+
import { type BBResult, type BBSuccess, BB_RESULT, generateAvmProof, verifyAvmProof } from '../bb/execute.js';
|
|
29
22
|
|
|
30
23
|
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb-avm');
|
|
31
24
|
|
|
@@ -51,6 +44,10 @@ class InterceptingLogger implements Logger {
|
|
|
51
44
|
throw new Error('Not implemented');
|
|
52
45
|
}
|
|
53
46
|
|
|
47
|
+
getBindings() {
|
|
48
|
+
return this.logger.getBindings();
|
|
49
|
+
}
|
|
50
|
+
|
|
54
51
|
private intercept(level: LogLevel, msg: string, ...args: any[]) {
|
|
55
52
|
this.logs.push(...msg.split('\n'));
|
|
56
53
|
// Forward to the wrapped logger
|
|
@@ -91,9 +88,10 @@ class InterceptingLogger implements Logger {
|
|
|
91
88
|
// Config with collectHints enabled for proving tests
|
|
92
89
|
const provingConfig: PublicSimulatorConfig = PublicSimulatorConfig.from({
|
|
93
90
|
skipFeeEnforcement: false,
|
|
94
|
-
collectCallMetadata: true,
|
|
91
|
+
collectCallMetadata: true, // For results.
|
|
95
92
|
collectDebugLogs: false,
|
|
96
93
|
collectHints: true, // Required for proving!
|
|
94
|
+
collectPublicInputs: true, // Required for proving!
|
|
97
95
|
collectStatistics: false,
|
|
98
96
|
});
|
|
99
97
|
|
|
@@ -192,14 +190,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
192
190
|
return proofRes;
|
|
193
191
|
}
|
|
194
192
|
|
|
195
|
-
return await verifyAvmProof(
|
|
196
|
-
BB_PATH,
|
|
197
|
-
this.bbWorkingDirectory,
|
|
198
|
-
proofRes.proofPath!,
|
|
199
|
-
publicInputs,
|
|
200
|
-
path.join(proofRes.vkDirectoryPath!, VK_FILENAME),
|
|
201
|
-
this.logger,
|
|
202
|
-
);
|
|
193
|
+
return await verifyAvmProof(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath!, publicInputs, this.logger);
|
|
203
194
|
}
|
|
204
195
|
|
|
205
196
|
public async proveVerify(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx') {
|
|
@@ -221,6 +212,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
221
212
|
txLabel: string = 'unlabeledTx',
|
|
222
213
|
disableRevertCheck: boolean = false,
|
|
223
214
|
): Promise<PublicTxResult> {
|
|
215
|
+
const simTimer = new Timer();
|
|
224
216
|
const simRes = await this.simulateTx(
|
|
225
217
|
sender,
|
|
226
218
|
setupCalls,
|
|
@@ -230,6 +222,8 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
230
222
|
privateInsertions,
|
|
231
223
|
txLabel,
|
|
232
224
|
);
|
|
225
|
+
const simDuration = simTimer.ms();
|
|
226
|
+
this.logger.info(`Simulation took ${simDuration} ms for tx ${txLabel}`);
|
|
233
227
|
|
|
234
228
|
if (!disableRevertCheck) {
|
|
235
229
|
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
@@ -237,7 +231,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
237
231
|
|
|
238
232
|
const opString = this.checkCircuitOnly ? 'Check circuit' : 'Proving and verification';
|
|
239
233
|
|
|
240
|
-
const avmCircuitInputs = new AvmCircuitInputs(simRes.hints!, simRes.publicInputs);
|
|
234
|
+
const avmCircuitInputs = new AvmCircuitInputs(simRes.hints!, simRes.publicInputs!);
|
|
241
235
|
const timer = new Timer();
|
|
242
236
|
await this.proveVerify(avmCircuitInputs, txLabel);
|
|
243
237
|
this.logger.info(`${opString} took ${timer.ms()} ms for tx ${txLabel}`);
|
package/src/bb/execute.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sha256 } from '@aztec/foundation/crypto';
|
|
1
|
+
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
2
2
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
@@ -353,7 +353,7 @@ export async function generateAvmProof(
|
|
|
353
353
|
durationMs: duration,
|
|
354
354
|
proofPath: join(outputPath, PROOF_FILENAME),
|
|
355
355
|
pkPath: undefined,
|
|
356
|
-
vkDirectoryPath:
|
|
356
|
+
vkDirectoryPath: undefined, // AVM VK is fixed in the binary.
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
359
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -372,7 +372,7 @@ export async function generateAvmProof(
|
|
|
372
372
|
* @param pathToBB - The full path to the bb binary
|
|
373
373
|
* @param proofFullPath - The full path to the proof to be verified
|
|
374
374
|
* @param verificationKeyPath - The full path to the circuit verification key
|
|
375
|
-
* @param
|
|
375
|
+
* @param logger - A logger
|
|
376
376
|
* @returns An object containing a result indication and duration taken
|
|
377
377
|
*/
|
|
378
378
|
export async function verifyProof(
|
|
@@ -380,16 +380,25 @@ export async function verifyProof(
|
|
|
380
380
|
proofFullPath: string,
|
|
381
381
|
verificationKeyPath: string,
|
|
382
382
|
ultraHonkFlavor: UltraHonkFlavor,
|
|
383
|
-
|
|
383
|
+
logger: Logger,
|
|
384
384
|
): Promise<BBFailure | BBSuccess> {
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
// Specify the public inputs path in the case of UH verification.
|
|
386
|
+
// Take proofFullPath and remove the suffix past the / to get the directory.
|
|
387
|
+
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
388
|
+
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
389
|
+
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
390
|
+
|
|
391
|
+
const args = [
|
|
392
|
+
'-p',
|
|
387
393
|
proofFullPath,
|
|
394
|
+
'-k',
|
|
388
395
|
verificationKeyPath,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
396
|
+
'-i',
|
|
397
|
+
publicInputsFullPath,
|
|
398
|
+
'--disable_zk',
|
|
399
|
+
...getArgs(ultraHonkFlavor),
|
|
400
|
+
];
|
|
401
|
+
return await verifyProofInternal(pathToBB, `verify`, args, logger);
|
|
393
402
|
}
|
|
394
403
|
|
|
395
404
|
export async function verifyAvmProof(
|
|
@@ -397,7 +406,6 @@ export async function verifyAvmProof(
|
|
|
397
406
|
workingDirectory: string,
|
|
398
407
|
proofFullPath: string,
|
|
399
408
|
publicInputs: AvmCircuitPublicInputs,
|
|
400
|
-
verificationKeyPath: string,
|
|
401
409
|
logger: Logger,
|
|
402
410
|
): Promise<BBFailure | BBSuccess> {
|
|
403
411
|
const inputsBuffer = publicInputs.serializeWithMessagePack();
|
|
@@ -414,10 +422,8 @@ export async function verifyAvmProof(
|
|
|
414
422
|
return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` };
|
|
415
423
|
}
|
|
416
424
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
avmInputsPath,
|
|
420
|
-
]);
|
|
425
|
+
const args = ['-p', proofFullPath, '--avm-public-inputs', avmInputsPath];
|
|
426
|
+
return await verifyProofInternal(pathToBB, 'avm_verify', args, logger);
|
|
421
427
|
}
|
|
422
428
|
|
|
423
429
|
/**
|
|
@@ -425,7 +431,7 @@ export async function verifyAvmProof(
|
|
|
425
431
|
* TODO(#7370) The verification keys should be supplied separately
|
|
426
432
|
* @param pathToBB - The full path to the bb binary
|
|
427
433
|
* @param targetPath - The path to the folder with the proof, accumulator, and verification keys
|
|
428
|
-
* @param
|
|
434
|
+
* @param logger - A logger
|
|
429
435
|
* @param concurrency - The number of threads to use for the verification
|
|
430
436
|
* @returns An object containing a result indication and duration taken
|
|
431
437
|
*/
|
|
@@ -433,7 +439,7 @@ export async function verifyChonkProof(
|
|
|
433
439
|
pathToBB: string,
|
|
434
440
|
proofPath: string,
|
|
435
441
|
keyPath: string,
|
|
436
|
-
|
|
442
|
+
logger: Logger,
|
|
437
443
|
concurrency = 1,
|
|
438
444
|
): Promise<BBFailure | BBSuccess> {
|
|
439
445
|
const binaryPresent = await fs
|
|
@@ -444,43 +450,25 @@ export async function verifyChonkProof(
|
|
|
444
450
|
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
445
451
|
}
|
|
446
452
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const timer = new Timer();
|
|
450
|
-
const command = 'verify';
|
|
451
|
-
|
|
452
|
-
const result = await executeBB(pathToBB, command, args, log, concurrency);
|
|
453
|
-
const duration = timer.ms();
|
|
454
|
-
if (result.status == BB_RESULT.SUCCESS) {
|
|
455
|
-
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
|
456
|
-
}
|
|
457
|
-
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
458
|
-
return {
|
|
459
|
-
status: BB_RESULT.FAILURE,
|
|
460
|
-
reason: `Failed to verify proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
|
|
461
|
-
retry: !!result.signal,
|
|
462
|
-
};
|
|
463
|
-
} catch (error) {
|
|
464
|
-
return { status: BB_RESULT.FAILURE, reason: `${error}` };
|
|
465
|
-
}
|
|
453
|
+
const args = ['--scheme', 'chonk', '-p', proofPath, '-k', keyPath, '-v'];
|
|
454
|
+
return await verifyProofInternal(pathToBB, 'verify', args, logger, concurrency);
|
|
466
455
|
}
|
|
467
456
|
|
|
468
457
|
/**
|
|
469
458
|
* Used for verifying proofs with BB
|
|
470
459
|
* @param pathToBB - The full path to the bb binary
|
|
471
|
-
* @param proofFullPath - The full path to the proof to be verified
|
|
472
|
-
* @param verificationKeyPath - The full path to the circuit verification key
|
|
473
460
|
* @param command - The BB command to execute (verify/avm_verify)
|
|
474
|
-
* @param
|
|
461
|
+
* @param args - The arguments to pass to the command
|
|
462
|
+
* @param logger - A logger
|
|
463
|
+
* @param concurrency - The number of threads to use for the verification
|
|
475
464
|
* @returns An object containing a result indication and duration taken
|
|
476
465
|
*/
|
|
477
466
|
async function verifyProofInternal(
|
|
478
467
|
pathToBB: string,
|
|
479
|
-
proofFullPath: string,
|
|
480
|
-
verificationKeyPath: string,
|
|
481
468
|
command: 'verify' | 'avm_verify',
|
|
469
|
+
args: string[],
|
|
482
470
|
logger: Logger,
|
|
483
|
-
|
|
471
|
+
concurrency?: number,
|
|
484
472
|
): Promise<BBFailure | BBSuccess> {
|
|
485
473
|
const binaryPresent = await fs
|
|
486
474
|
.access(pathToBB, fs.constants.R_OK)
|
|
@@ -495,28 +483,12 @@ async function verifyProofInternal(
|
|
|
495
483
|
};
|
|
496
484
|
|
|
497
485
|
try {
|
|
498
|
-
let args;
|
|
499
|
-
|
|
500
|
-
if (command == 'verify') {
|
|
501
|
-
// Specify the public inputs path in the case of UH verification.
|
|
502
|
-
// Take proofFullPath and remove the suffix past the / to get the directory.
|
|
503
|
-
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
504
|
-
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
505
|
-
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
506
|
-
|
|
507
|
-
args = ['-p', proofFullPath, '-k', verificationKeyPath, '-i', publicInputsFullPath, '--disable_zk', ...extraArgs];
|
|
508
|
-
} else {
|
|
509
|
-
args = ['-p', proofFullPath, '-k', verificationKeyPath, ...extraArgs];
|
|
510
|
-
}
|
|
511
|
-
|
|
512
486
|
const loggingArg =
|
|
513
487
|
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
|
|
514
|
-
|
|
515
|
-
args.push(loggingArg);
|
|
516
|
-
}
|
|
488
|
+
const finalArgs = loggingArg !== '' ? [...args, loggingArg] : args;
|
|
517
489
|
|
|
518
490
|
const timer = new Timer();
|
|
519
|
-
const result = await executeBB(pathToBB, command,
|
|
491
|
+
const result = await executeBB(pathToBB, command, finalArgs, logFunction, concurrency);
|
|
520
492
|
const duration = timer.ms();
|
|
521
493
|
if (result.status == BB_RESULT.SUCCESS) {
|
|
522
494
|
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
package/src/instrumentation.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type Tracer,
|
|
10
|
-
ValueType,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -31,51 +30,21 @@ export class ProverInstrumentation {
|
|
|
31
30
|
this.tracer = telemetry.getTracer(name);
|
|
32
31
|
const meter = telemetry.getMeter(name);
|
|
33
32
|
|
|
34
|
-
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION
|
|
35
|
-
description: 'Records how long it takes to simulate a circuit',
|
|
36
|
-
unit: 'ms',
|
|
37
|
-
valueType: ValueType.INT,
|
|
38
|
-
});
|
|
33
|
+
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION);
|
|
39
34
|
|
|
40
|
-
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION
|
|
41
|
-
description: 'Records how long it takes to generate the partial witness for a circuit',
|
|
42
|
-
unit: 's',
|
|
43
|
-
valueType: ValueType.DOUBLE,
|
|
44
|
-
});
|
|
35
|
+
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION);
|
|
45
36
|
|
|
46
|
-
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION
|
|
47
|
-
unit: 's',
|
|
48
|
-
description: 'Records how long it takes to prove a circuit',
|
|
49
|
-
valueType: ValueType.DOUBLE,
|
|
50
|
-
});
|
|
37
|
+
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION);
|
|
51
38
|
|
|
52
|
-
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE
|
|
53
|
-
unit: 'By',
|
|
54
|
-
description: 'Records the size of the input to the witness generation',
|
|
55
|
-
valueType: ValueType.INT,
|
|
56
|
-
});
|
|
39
|
+
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE);
|
|
57
40
|
|
|
58
|
-
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE
|
|
59
|
-
unit: 'By',
|
|
60
|
-
description: 'Records the size of the output of the witness generation',
|
|
61
|
-
valueType: ValueType.INT,
|
|
62
|
-
});
|
|
41
|
+
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE);
|
|
63
42
|
|
|
64
|
-
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE
|
|
65
|
-
unit: 'By',
|
|
66
|
-
description: 'Records the size of the proof generated for a circuit',
|
|
67
|
-
valueType: ValueType.INT,
|
|
68
|
-
});
|
|
43
|
+
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE);
|
|
69
44
|
|
|
70
|
-
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT
|
|
71
|
-
description: 'Records the number of public inputs in a circuit',
|
|
72
|
-
valueType: ValueType.INT,
|
|
73
|
-
});
|
|
45
|
+
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT);
|
|
74
46
|
|
|
75
|
-
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE
|
|
76
|
-
description: 'Records the size of the circuit in gates',
|
|
77
|
-
valueType: ValueType.INT,
|
|
78
|
-
});
|
|
47
|
+
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE);
|
|
79
48
|
}
|
|
80
49
|
|
|
81
50
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AztecClientBackend, Barretenberg } from '@aztec/bb.js';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { AztecClientBackend, type BackendOptions, Barretenberg } from '@aztec/bb.js';
|
|
2
|
+
import { type LogLevel, type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
5
|
import {
|
|
@@ -45,12 +45,17 @@ import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@azt
|
|
|
45
45
|
|
|
46
46
|
import { ungzip } from 'pako';
|
|
47
47
|
|
|
48
|
+
export type BBPrivateKernelProverOptions = Omit<BackendOptions, 'logger'> & { logger?: Logger };
|
|
48
49
|
export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
50
|
+
private log: Logger;
|
|
51
|
+
|
|
49
52
|
constructor(
|
|
50
53
|
protected artifactProvider: ArtifactProvider,
|
|
51
54
|
protected simulator: CircuitSimulator,
|
|
52
|
-
protected
|
|
53
|
-
) {
|
|
55
|
+
protected options: BBPrivateKernelProverOptions = {},
|
|
56
|
+
) {
|
|
57
|
+
this.log = options.logger || createLogger('bb-prover:private-kernel');
|
|
58
|
+
}
|
|
54
59
|
|
|
55
60
|
public async generateInitOutput(
|
|
56
61
|
inputs: PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -271,9 +276,13 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
271
276
|
public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
|
|
272
277
|
const timer = new Timer();
|
|
273
278
|
this.log.info(`Generating ClientIVC proof...`);
|
|
279
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
280
|
+
...this.options,
|
|
281
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
282
|
+
});
|
|
274
283
|
const backend = new AztecClientBackend(
|
|
275
284
|
executionSteps.map(step => ungzip(step.bytecode)),
|
|
276
|
-
|
|
285
|
+
barretenberg,
|
|
277
286
|
);
|
|
278
287
|
|
|
279
288
|
const [proof] = await backend.prove(
|
|
@@ -290,7 +299,11 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
290
299
|
|
|
291
300
|
public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
292
301
|
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
293
|
-
const
|
|
302
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
303
|
+
...this.options,
|
|
304
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
305
|
+
});
|
|
306
|
+
const backend = new AztecClientBackend([ungzip(_bytecode)], barretenberg);
|
|
294
307
|
const gateCount = await backend.gates();
|
|
295
308
|
return gateCount[0];
|
|
296
309
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
1
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
3
2
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
4
3
|
|
|
5
|
-
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
6
5
|
|
|
7
6
|
export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
|
|
8
|
-
constructor(simulator: CircuitSimulator,
|
|
9
|
-
super(new BundleArtifactProvider(), simulator,
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new BundleArtifactProvider(), simulator, options);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
1
|
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
3
2
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
4
3
|
|
|
5
|
-
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
6
5
|
|
|
7
6
|
export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
|
|
8
|
-
constructor(simulator: CircuitSimulator,
|
|
9
|
-
super(new LazyArtifactProvider(), simulator,
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new LazyArtifactProvider(), simulator, options);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
PAIRING_POINTS_SIZE,
|
|
8
8
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
9
9
|
} from '@aztec/constants';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
12
|
import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
13
13
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|