@aztec/bb-prover 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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 +13 -8
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +152 -107
- package/dest/bb/bb_js_backend.d.ts +196 -0
- package/dest/bb/bb_js_backend.d.ts.map +1 -0
- package/dest/bb/bb_js_backend.js +379 -0
- package/dest/bb/bb_js_debug.d.ts +52 -0
- package/dest/bb/bb_js_debug.d.ts.map +1 -0
- package/dest/bb/bb_js_debug.js +176 -0
- package/dest/bb/file_names.d.ts +4 -0
- package/dest/bb/file_names.d.ts.map +1 -0
- package/dest/bb/file_names.js +5 -0
- package/dest/config.d.ts +17 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/index.d.ts +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +12 -4
- package/dest/prover/client/bb_private_kernel_prover.d.ts +10 -2
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +43 -7
- package/dest/prover/proof_utils.d.ts +11 -1
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +24 -1
- package/dest/prover/server/bb_prover.d.ts +4 -5
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +208 -79
- package/dest/test/delay_values.js +1 -1
- package/dest/verification_key/verification_key_data.js +1 -1
- package/dest/verifier/batch_chonk_verifier.d.ts +56 -0
- package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/batch_chonk_verifier.js +384 -0
- package/dest/verifier/bb_verifier.d.ts +4 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +134 -45
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +2 -3
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
- package/dest/verifier/queued_chonk_verifier.js +8 -7
- package/package.json +19 -17
- package/src/avm_proving_tests/avm_proving_tester.ts +53 -122
- package/src/bb/bb_js_backend.ts +435 -0
- package/src/bb/bb_js_debug.ts +227 -0
- package/src/bb/file_names.ts +6 -0
- package/src/config.ts +16 -0
- package/src/index.ts +2 -1
- package/src/instrumentation.ts +12 -4
- package/src/prover/client/bb_private_kernel_prover.ts +118 -5
- package/src/prover/proof_utils.ts +41 -1
- package/src/prover/server/bb_prover.ts +133 -137
- package/src/test/delay_values.ts +1 -1
- package/src/verification_key/verification_key_data.ts +1 -1
- package/src/verifier/batch_chonk_verifier.ts +415 -0
- package/src/verifier/bb_verifier.ts +66 -76
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +8 -8
- package/dest/bb/execute.d.ts +0 -107
- package/dest/bb/execute.d.ts.map +0 -1
- package/dest/bb/execute.js +0 -647
- package/src/bb/execute.ts +0 -678
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
import type { BBConfig } from '../config.js';
|
|
5
4
|
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
5
|
private verifier;
|
|
7
6
|
private telemetry;
|
|
8
7
|
private logger;
|
|
9
8
|
private queue;
|
|
10
9
|
private metrics;
|
|
11
|
-
constructor(
|
|
10
|
+
constructor(verifier: ClientProtocolCircuitVerifier, concurrency: number, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
12
11
|
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
12
|
stop(): Promise<void>;
|
|
14
13
|
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWVkX2Nob25rX3ZlcmlmaWVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvcXVldWVkX2Nob25rX3ZlcmlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLDZCQUE2QixFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDM0MsT0FBTyxFQU1MLEtBQUssZUFBZSxFQUlyQixNQUFNLHlCQUF5QixDQUFDO0FBbUVqQyxxQkFBYSxpQkFBa0IsWUFBVyw2QkFBNkI7SUFLbkUsT0FBTyxDQUFDLFFBQVE7SUFFaEIsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLE1BQU07SUFQaEIsT0FBTyxDQUFDLEtBQUssQ0FBYztJQUMzQixPQUFPLENBQUMsT0FBTyxDQUFxQjtJQUVwQyxZQUNVLFFBQVEsRUFBRSw2QkFBNkIsRUFDL0MsV0FBVyxFQUFFLE1BQU0sRUFDWCxTQUFTLEdBQUUsZUFBc0MsRUFDakQsTUFBTSx5Q0FBa0QsRUFNakU7SUFFWSxXQUFXLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FJcEU7SUFFSyxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUcxQjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAmEjC,qBAAa,iBAAkB,YAAW,6BAA6B;IAKnE,OAAO,CAAC,QAAQ;IAEhB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;IAEpC,YACU,QAAQ,EAAE,6BAA6B,EAC/C,WAAW,EAAE,MAAM,EACX,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAkD,EAMjE;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAIpE;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1B;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
-
import { Attributes, Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
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;
|
|
@@ -19,7 +19,7 @@ class IVCVerifierMetrics {
|
|
|
19
19
|
const meter = client.getMeter(name);
|
|
20
20
|
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
|
|
21
21
|
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
22
|
-
this.ivcFailureCount = meter
|
|
22
|
+
this.ivcFailureCount = createUpDownCounterWithDefault(meter, Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
23
23
|
this.aggDurationMetrics = {
|
|
24
24
|
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
|
|
25
25
|
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
|
|
@@ -81,21 +81,22 @@ export class QueuedIVCVerifier {
|
|
|
81
81
|
logger;
|
|
82
82
|
queue;
|
|
83
83
|
metrics;
|
|
84
|
-
constructor(
|
|
84
|
+
constructor(verifier, concurrency, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
|
|
85
85
|
this.verifier = verifier;
|
|
86
86
|
this.telemetry = telemetry;
|
|
87
87
|
this.logger = logger;
|
|
88
88
|
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
89
89
|
this.queue = new SerialQueue();
|
|
90
|
-
this.logger.info(`Starting QueuedIVCVerifier with ${
|
|
91
|
-
this.queue.start(
|
|
90
|
+
this.logger.info(`Starting QueuedIVCVerifier with ${concurrency} concurrent verifiers`);
|
|
91
|
+
this.queue.start(concurrency);
|
|
92
92
|
}
|
|
93
93
|
async verifyProof(tx) {
|
|
94
94
|
const result = await this.queue.put(()=>this.verifier.verifyProof(tx));
|
|
95
95
|
this.metrics.recordIVCVerification(result);
|
|
96
96
|
return result;
|
|
97
97
|
}
|
|
98
|
-
stop() {
|
|
99
|
-
|
|
98
|
+
async stop() {
|
|
99
|
+
await this.queue.end();
|
|
100
|
+
await this.verifier.stop();
|
|
100
101
|
}
|
|
101
102
|
}
|
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.2f68f620",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"./client": "./dest/prover/client/bb_private_kernel_prover.js",
|
|
10
10
|
"./verifier": "./dest/verifier/index.js",
|
|
11
11
|
"./test": "./dest/test/index.js",
|
|
12
|
-
"./config": "./dest/config.js"
|
|
12
|
+
"./config": "./dest/config.js",
|
|
13
|
+
"./debug": "./dest/bb/bb_js_debug.js"
|
|
13
14
|
},
|
|
14
15
|
"bin": {
|
|
15
16
|
"bb-cli": "./dest/bb/index.js"
|
|
@@ -69,27 +70,28 @@
|
|
|
69
70
|
]
|
|
70
71
|
},
|
|
71
72
|
"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.
|
|
73
|
+
"@aztec/bb.js": "0.0.1-commit.2f68f620",
|
|
74
|
+
"@aztec/constants": "0.0.1-commit.2f68f620",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.2f68f620",
|
|
76
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.2f68f620",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.2f68f620",
|
|
78
|
+
"@aztec/noir-types": "0.0.1-commit.2f68f620",
|
|
79
|
+
"@aztec/simulator": "0.0.1-commit.2f68f620",
|
|
80
|
+
"@aztec/stdlib": "0.0.1-commit.2f68f620",
|
|
81
|
+
"@aztec/telemetry-client": "0.0.1-commit.2f68f620",
|
|
82
|
+
"@aztec/world-state": "0.0.1-commit.2f68f620",
|
|
82
83
|
"commander": "^12.1.0",
|
|
84
|
+
"msgpackr": "^1.11.2",
|
|
83
85
|
"pako": "^2.1.0",
|
|
84
86
|
"source-map-support": "^0.5.21",
|
|
85
87
|
"tslib": "^2.4.0"
|
|
86
88
|
},
|
|
87
89
|
"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.
|
|
90
|
+
"@aztec/ethereum": "0.0.1-commit.2f68f620",
|
|
91
|
+
"@aztec/kv-store": "0.0.1-commit.2f68f620",
|
|
92
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.2f68f620",
|
|
93
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.2f68f620",
|
|
94
|
+
"@aztec/protocol-contracts": "0.0.1-commit.2f68f620",
|
|
93
95
|
"@jest/globals": "^30.0.0",
|
|
94
96
|
"@types/jest": "^30.0.0",
|
|
95
97
|
"@types/node": "^22.15.17",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvmStat } from '@aztec/bb.js';
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
3
|
import {
|
|
4
4
|
PublicTxSimulationTester,
|
|
@@ -10,77 +10,17 @@ import {
|
|
|
10
10
|
import type { PublicTxResult } from '@aztec/simulator/server';
|
|
11
11
|
import { AvmCircuitInputs, AvmCircuitPublicInputs, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
12
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
+
import type { Gas } from '@aztec/stdlib/gas';
|
|
13
14
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
14
15
|
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
16
|
import { NativeWorldStateService } from '@aztec/world-state';
|
|
16
17
|
|
|
17
|
-
import fs from 'node:fs/promises';
|
|
18
|
-
import { tmpdir } from 'node:os';
|
|
19
18
|
import path from 'path';
|
|
20
19
|
|
|
21
|
-
import {
|
|
20
|
+
import { BBJsFactory } from '../bb/bb_js_backend.js';
|
|
22
21
|
|
|
23
22
|
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb-avm');
|
|
24
23
|
|
|
25
|
-
// An InterceptingLogger that records all log messages and forwards them to a wrapped logger.
|
|
26
|
-
class InterceptingLogger implements Logger {
|
|
27
|
-
public readonly logs: string[] = [];
|
|
28
|
-
public level: LogLevel;
|
|
29
|
-
public module: string;
|
|
30
|
-
|
|
31
|
-
private logger: Logger;
|
|
32
|
-
|
|
33
|
-
constructor(logger: Logger) {
|
|
34
|
-
this.logger = logger;
|
|
35
|
-
this.level = logger.level;
|
|
36
|
-
this.module = logger.module;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
isLevelEnabled(level: LogLevel): boolean {
|
|
40
|
-
return this.logger.isLevelEnabled(level);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
createChild(_childModule: string): Logger {
|
|
44
|
-
throw new Error('Not implemented');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private intercept(level: LogLevel, msg: string, ...args: any[]) {
|
|
48
|
-
this.logs.push(...msg.split('\n'));
|
|
49
|
-
// Forward to the wrapped logger
|
|
50
|
-
(this.logger[level] as LogFn)(msg, ...args);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Log methods for each level
|
|
54
|
-
silent(msg: string, ...args: any[]) {
|
|
55
|
-
this.intercept('silent', msg, ...args);
|
|
56
|
-
}
|
|
57
|
-
fatal(msg: string, ...args: any[]) {
|
|
58
|
-
this.intercept('fatal', msg, ...args);
|
|
59
|
-
}
|
|
60
|
-
warn(msg: string, ...args: any[]) {
|
|
61
|
-
this.intercept('warn', msg, ...args);
|
|
62
|
-
}
|
|
63
|
-
info(msg: string, ...args: any[]) {
|
|
64
|
-
this.intercept('info', msg, ...args);
|
|
65
|
-
}
|
|
66
|
-
verbose(msg: string, ...args: any[]) {
|
|
67
|
-
this.intercept('verbose', msg, ...args);
|
|
68
|
-
}
|
|
69
|
-
debug(msg: string, ...args: any[]) {
|
|
70
|
-
this.intercept('debug', msg, ...args);
|
|
71
|
-
}
|
|
72
|
-
trace(msg: string, ...args: any[]) {
|
|
73
|
-
this.intercept('trace', msg, ...args);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Error log function can be string or Error
|
|
77
|
-
error(err: Error | string, ...args: any[]) {
|
|
78
|
-
const msg = typeof err === 'string' ? err : err.message;
|
|
79
|
-
this.logs.push(msg);
|
|
80
|
-
this.logger.error(msg, err, ...args);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
24
|
// Config with collectHints enabled for proving tests
|
|
85
25
|
const provingConfig: PublicSimulatorConfig = PublicSimulatorConfig.from({
|
|
86
26
|
skipFeeEnforcement: false,
|
|
@@ -92,7 +32,7 @@ const provingConfig: PublicSimulatorConfig = PublicSimulatorConfig.from({
|
|
|
92
32
|
});
|
|
93
33
|
|
|
94
34
|
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
95
|
-
private
|
|
35
|
+
private readonly bbJsFactory = new BBJsFactory(BB_PATH);
|
|
96
36
|
|
|
97
37
|
constructor(
|
|
98
38
|
private checkCircuitOnly: boolean,
|
|
@@ -116,53 +56,57 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
116
56
|
return new AvmProvingTester(checkCircuitOnly, contractDataSource, merkleTrees, globals, metrics);
|
|
117
57
|
}
|
|
118
58
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Generate an AVM proof (or run check-circuit if configured). Records per-stage timings in the test metrics.
|
|
61
|
+
* Returns the in-memory proof fields on success; throws via jest expect() on failure.
|
|
62
|
+
*/
|
|
63
|
+
async prove(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx'): Promise<Uint8Array[]> {
|
|
64
|
+
const inputsBuffer = avmCircuitInputs.serializeWithMessagePack();
|
|
122
65
|
|
|
123
|
-
|
|
66
|
+
if (this.checkCircuitOnly) {
|
|
67
|
+
await using instance = await this.bbJsFactory.getInstance();
|
|
68
|
+
const { passed, stats } = await instance.checkAvmCircuit(inputsBuffer);
|
|
69
|
+
this.recordProverMetrics(stats, txLabel);
|
|
70
|
+
expect(passed).toBe(true);
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
124
73
|
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
74
|
+
await using instance = await this.bbJsFactory.getInstance();
|
|
75
|
+
const { proof, stats } = await instance.generateAvmProof(inputsBuffer);
|
|
76
|
+
this.recordProverMetrics(stats, txLabel);
|
|
77
|
+
return proof;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async verify(proof: Uint8Array[], publicInputs: AvmCircuitPublicInputs): Promise<void> {
|
|
81
|
+
if (this.checkCircuitOnly) {
|
|
82
|
+
// Check-circuit did not generate a proof; nothing to verify.
|
|
83
|
+
return;
|
|
135
84
|
}
|
|
136
|
-
|
|
85
|
+
const piBuffer = publicInputs.serializeWithMessagePack();
|
|
86
|
+
await using instance = await this.bbJsFactory.getInstance();
|
|
87
|
+
const { verified } = await instance.verifyAvmProof(proof, piBuffer);
|
|
88
|
+
expect(verified).toBe(true);
|
|
89
|
+
}
|
|
137
90
|
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// const match = log.match(/\b(\w+): (\d+) \(~2/);
|
|
143
|
-
// if (match) {
|
|
144
|
-
// traceSizes.push({
|
|
145
|
-
// name: match[1],
|
|
146
|
-
// size: parseInt(match[2]),
|
|
147
|
-
// });
|
|
148
|
-
// }
|
|
149
|
-
// });
|
|
150
|
-
const times: { [key: string]: number } = {};
|
|
151
|
-
logs.forEach(log => {
|
|
152
|
-
const match = log.match(/\b([\w/]+)_ms: (\d+)/);
|
|
153
|
-
if (match) {
|
|
154
|
-
times[match[1]] = parseInt(match[2]);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
91
|
+
public async proveVerify(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx') {
|
|
92
|
+
const proof = await this.prove(avmCircuitInputs, txLabel);
|
|
93
|
+
await this.verify(proof, avmCircuitInputs.publicInputs);
|
|
94
|
+
}
|
|
157
95
|
|
|
158
|
-
|
|
96
|
+
private recordProverMetrics(stats: AvmStat[], txLabel: string) {
|
|
97
|
+
// Build a lookup keyed on the stage name with the `_ms` suffix stripped, matching the legacy
|
|
98
|
+
// stdout-scraped shape. bb::avm2::Stats::time() stores keys with `_ms` appended.
|
|
99
|
+
const times: { [key: string]: number } = {};
|
|
100
|
+
for (const { name, valueMs } of stats) {
|
|
101
|
+
const key = name.endsWith('_ms') ? name.slice(0, -'_ms'.length) : name;
|
|
102
|
+
times[key] = valueMs;
|
|
103
|
+
}
|
|
159
104
|
if (Object.keys(times).length === 0) {
|
|
160
|
-
throw new Error('AVM
|
|
105
|
+
throw new Error('AVM response did not contain any proving-stage timings!');
|
|
161
106
|
}
|
|
162
|
-
|
|
163
107
|
// Hack to make labels match.
|
|
164
108
|
const txLabelWithCount = `${txLabel}/${this.txCount - 1}`;
|
|
165
|
-
//
|
|
109
|
+
// Cast because TS doesn't realize `metrics` is protected, not private on the parent class.
|
|
166
110
|
(this as any).metrics?.recordProverMetrics(txLabelWithCount, {
|
|
167
111
|
proverSimulationStepMs: times['simulation/all'],
|
|
168
112
|
proverProvingStepMs: times['proving/all'],
|
|
@@ -175,26 +119,6 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
175
119
|
provingLogDerivativeInverseCommitmentsMs: times['prove/log_derivative_inverse_commitments_round'],
|
|
176
120
|
provingWireCommitmentsMs: times['prove/wire_commitments_round'],
|
|
177
121
|
});
|
|
178
|
-
|
|
179
|
-
return proofRes as BBSuccess;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async verify(proofRes: BBSuccess, publicInputs: AvmCircuitPublicInputs): Promise<BBResult> {
|
|
183
|
-
if (this.checkCircuitOnly) {
|
|
184
|
-
// Skip verification if we are only checking the circuit.
|
|
185
|
-
// Check-circuit does not generate a proof to verify.
|
|
186
|
-
return proofRes;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return await verifyAvmProof(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath!, publicInputs, this.logger);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public async proveVerify(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx') {
|
|
193
|
-
const provingRes = await this.prove(avmCircuitInputs, txLabel);
|
|
194
|
-
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
195
|
-
|
|
196
|
-
const verificationRes = await this.verify(provingRes as BBSuccess, avmCircuitInputs.publicInputs);
|
|
197
|
-
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
198
122
|
}
|
|
199
123
|
|
|
200
124
|
public async simProveVerify(
|
|
@@ -207,6 +131,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
207
131
|
privateInsertions?: TestPrivateInsertions,
|
|
208
132
|
txLabel: string = 'unlabeledTx',
|
|
209
133
|
disableRevertCheck: boolean = false,
|
|
134
|
+
gasLimits?: Gas,
|
|
210
135
|
): Promise<PublicTxResult> {
|
|
211
136
|
const simTimer = new Timer();
|
|
212
137
|
const simRes = await this.simulateTx(
|
|
@@ -217,6 +142,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
217
142
|
feePayer,
|
|
218
143
|
privateInsertions,
|
|
219
144
|
txLabel,
|
|
145
|
+
gasLimits,
|
|
220
146
|
);
|
|
221
147
|
const simDuration = simTimer.ms();
|
|
222
148
|
this.logger.info(`Simulation took ${simDuration} ms for tx ${txLabel}`);
|
|
@@ -243,6 +169,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
243
169
|
teardownCall?: TestEnqueuedCall,
|
|
244
170
|
feePayer?: AztecAddress,
|
|
245
171
|
privateInsertions?: TestPrivateInsertions,
|
|
172
|
+
gasLimits?: Gas,
|
|
246
173
|
) {
|
|
247
174
|
return await this.simProveVerify(
|
|
248
175
|
sender,
|
|
@@ -254,6 +181,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
254
181
|
privateInsertions,
|
|
255
182
|
txLabel,
|
|
256
183
|
true,
|
|
184
|
+
gasLimits,
|
|
257
185
|
);
|
|
258
186
|
}
|
|
259
187
|
|
|
@@ -261,6 +189,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
261
189
|
appCall: TestEnqueuedCall,
|
|
262
190
|
expectRevert?: boolean,
|
|
263
191
|
txLabel: string = 'unlabeledTx',
|
|
192
|
+
gasLimits?: Gas,
|
|
264
193
|
) {
|
|
265
194
|
await this.simProveVerify(
|
|
266
195
|
/*sender=*/ AztecAddress.fromNumber(42),
|
|
@@ -271,6 +200,8 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
271
200
|
/*feePayer=*/ undefined,
|
|
272
201
|
/*privateInsertions=*/ undefined,
|
|
273
202
|
txLabel,
|
|
203
|
+
/*disableRevertCheck=*/ false,
|
|
204
|
+
gasLimits,
|
|
274
205
|
);
|
|
275
206
|
}
|
|
276
207
|
}
|