@aztec/bb-prover 0.0.0-test.1 → 0.0.1-commit.017a351
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 +21 -20
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +196 -87
- 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/cli.d.ts +1 -1
- 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/bb/index.d.ts +1 -1
- package/dest/config.d.ts +19 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +3 -3
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +3 -2
- package/dest/index.d.ts +4 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -1
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +22 -46
- package/dest/prover/client/bb_private_kernel_prover.d.ts +46 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/client/bb_private_kernel_prover.js +177 -0
- package/dest/prover/client/bundle.d.ts +6 -0
- package/dest/prover/client/bundle.d.ts.map +1 -0
- package/dest/prover/client/bundle.js +7 -0
- package/dest/prover/client/lazy.d.ts +6 -0
- package/dest/prover/client/lazy.d.ts.map +1 -0
- package/dest/prover/client/lazy.js +7 -0
- package/dest/prover/index.d.ts +3 -4
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- package/dest/prover/proof_utils.d.ts +29 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +95 -0
- package/dest/prover/server/bb_prover.d.ts +96 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +841 -0
- 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 +37 -23
- 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 +27 -36
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +517 -88
- package/dest/test/test_verifier.d.ts +6 -3
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +23 -1
- package/dest/verification_key/verification_key_data.d.ts +1 -2
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +9 -34
- 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 +9 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +156 -49
- package/dest/verifier/index.d.ts +3 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +2 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +14 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/queued_chonk_verifier.js +102 -0
- package/package.json +38 -34
- package/src/avm_proving_tests/avm_proving_tester.ts +163 -126
- 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 +18 -0
- package/src/honk.ts +3 -2
- package/src/index.ts +3 -1
- package/src/instrumentation.ts +22 -47
- package/src/prover/client/bb_private_kernel_prover.ts +423 -0
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +155 -0
- package/src/prover/server/bb_prover.ts +713 -0
- package/src/test/delay_values.ts +38 -22
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +264 -154
- package/src/test/test_verifier.ts +15 -3
- package/src/verification_key/verification_key_data.ts +11 -31
- package/src/verifier/batch_chonk_verifier.ts +415 -0
- package/src/verifier/bb_verifier.ts +93 -76
- package/src/verifier/index.ts +2 -0
- package/src/verifier/queued_chonk_verifier.ts +108 -0
- package/dest/bb/execute.d.ts +0 -140
- package/dest/bb/execute.d.ts.map +0 -1
- package/dest/bb/execute.js +0 -780
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_native_private_kernel_prover.js +0 -69
- package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_private_kernel_prover.js +0 -109
- package/dest/prover/bb_prover.d.ts +0 -120
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.js +0 -423
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/stats.d.ts +0 -5
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -62
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/bundle.js +0 -8
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/dest/wasm/lazy.js +0 -8
- package/src/bb/execute.ts +0 -853
- package/src/prover/bb_native_private_kernel_prover.ts +0 -119
- package/src/prover/bb_private_kernel_prover.ts +0 -249
- package/src/prover/bb_prover.ts +0 -781
- package/src/prover/client_ivc_proof_utils.ts +0 -42
- package/src/stats.ts +0 -64
- package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
- package/src/wasm/bundle.ts +0 -11
- package/src/wasm/lazy.ts +0 -11
|
@@ -1,86 +1,193 @@
|
|
|
1
|
-
|
|
1
|
+
function _ts_add_disposable_resource(env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() {
|
|
16
|
+
try {
|
|
17
|
+
inner.call(this);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return Promise.reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
env.stack.push({
|
|
23
|
+
value: value,
|
|
24
|
+
dispose: dispose,
|
|
25
|
+
async: async
|
|
26
|
+
});
|
|
27
|
+
} else if (async) {
|
|
28
|
+
env.stack.push({
|
|
29
|
+
async: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function _ts_dispose_resources(env) {
|
|
35
|
+
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
36
|
+
var e = new Error(message);
|
|
37
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
|
+
};
|
|
39
|
+
return (_ts_dispose_resources = function _ts_dispose_resources(env) {
|
|
40
|
+
function fail(e) {
|
|
41
|
+
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
42
|
+
env.hasError = true;
|
|
43
|
+
}
|
|
44
|
+
var r, s = 0;
|
|
45
|
+
function next() {
|
|
46
|
+
while(r = env.stack.pop()){
|
|
47
|
+
try {
|
|
48
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
49
|
+
if (r.dispose) {
|
|
50
|
+
var result = r.dispose.call(r.value);
|
|
51
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
52
|
+
fail(e);
|
|
53
|
+
return next();
|
|
54
|
+
});
|
|
55
|
+
} else s |= 1;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
fail(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
61
|
+
if (env.hasError) throw env.error;
|
|
62
|
+
}
|
|
63
|
+
return next();
|
|
64
|
+
})(env);
|
|
65
|
+
}
|
|
2
66
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
67
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
68
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
69
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
5
70
|
import { promises as fs } from 'fs';
|
|
6
|
-
import
|
|
7
|
-
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
71
|
+
import { BBJsFactory } from '../bb/bb_js_backend.js';
|
|
8
72
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
9
|
-
import { writeToOutputDirectory } from '../prover/client_ivc_proof_utils.js';
|
|
10
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
11
73
|
export class BBCircuitVerifier {
|
|
12
74
|
config;
|
|
13
75
|
logger;
|
|
76
|
+
bbJsFactory;
|
|
14
77
|
constructor(config, logger){
|
|
15
78
|
this.config = config;
|
|
16
79
|
this.logger = logger;
|
|
80
|
+
// BB_NUM_IVC_VERIFIERS bounds the number of long-lived bb processes the pool keeps alive.
|
|
81
|
+
// If 0, fall back to spawning a fresh bb per verification.
|
|
82
|
+
this.bbJsFactory = new BBJsFactory(config.bbBinaryPath, {
|
|
83
|
+
poolSize: config.numConcurrentIVCVerifiers > 0 ? config.numConcurrentIVCVerifiers : undefined,
|
|
84
|
+
logger,
|
|
85
|
+
debugDir: config.bbDebugOutputDir
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
stop() {
|
|
89
|
+
return this.bbJsFactory.destroy();
|
|
17
90
|
}
|
|
18
91
|
static async new(config, logger = createLogger('bb-prover:verifier')) {
|
|
92
|
+
if (!config.bbWorkingDirectory) {
|
|
93
|
+
throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
|
|
94
|
+
}
|
|
19
95
|
await fs.mkdir(config.bbWorkingDirectory, {
|
|
20
96
|
recursive: true
|
|
21
97
|
});
|
|
22
98
|
return new BBCircuitVerifier(config, logger);
|
|
23
99
|
}
|
|
24
|
-
getVerificationKeyData(
|
|
25
|
-
const vk =
|
|
100
|
+
getVerificationKeyData(circuit) {
|
|
101
|
+
const vk = ProtocolCircuitVks[circuit];
|
|
26
102
|
if (vk === undefined) {
|
|
27
|
-
throw new Error(
|
|
103
|
+
throw new Error(`Could not find VK for artifact ${circuit}`);
|
|
28
104
|
}
|
|
29
105
|
return vk;
|
|
30
106
|
}
|
|
31
|
-
async verifyProofForCircuit(circuit, proof) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
107
|
+
/** Verify an UltraHonk proof via bb.js API (no temp files). */ async verifyProofForCircuit(circuit, proof) {
|
|
108
|
+
const env = {
|
|
109
|
+
stack: [],
|
|
110
|
+
error: void 0,
|
|
111
|
+
hasError: false
|
|
112
|
+
};
|
|
113
|
+
try {
|
|
35
114
|
const verificationKey = this.getVerificationKeyData(circuit);
|
|
115
|
+
const flavor = getUltraHonkFlavorForCircuit(circuit);
|
|
36
116
|
this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
117
|
+
// Split proof buffer into public input fields and proof fields (32-byte each)
|
|
118
|
+
const publicInputFields = splitBufferToFieldArrays(proof.buffer.subarray(0, proof.numPublicInputs * 32));
|
|
119
|
+
const proofFields = splitBufferToFieldArrays(proof.buffer.subarray(proof.numPublicInputs * 32));
|
|
120
|
+
const instance = _ts_add_disposable_resource(env, await this.bbJsFactory.getInstance(), true);
|
|
121
|
+
const { verified, durationMs } = await instance.verifyProof(proofFields, verificationKey.keyAsBytes, publicInputFields, flavor);
|
|
122
|
+
if (!verified) {
|
|
123
|
+
throw new Error(`Failed to verify ${circuit} proof!`);
|
|
43
124
|
}
|
|
44
125
|
this.logger.debug(`${circuit} verification successful`, {
|
|
45
126
|
circuitName: mapProtocolArtifactNameToCircuitName(circuit),
|
|
46
|
-
duration:
|
|
127
|
+
duration: durationMs,
|
|
47
128
|
eventName: 'circuit-verification',
|
|
48
129
|
proofType: 'ultra-honk'
|
|
49
130
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
131
|
+
} catch (e) {
|
|
132
|
+
env.error = e;
|
|
133
|
+
env.hasError = true;
|
|
134
|
+
} finally{
|
|
135
|
+
const result = _ts_dispose_resources(env);
|
|
136
|
+
if (result) await result;
|
|
137
|
+
}
|
|
52
138
|
}
|
|
53
|
-
async verifyProof(tx) {
|
|
139
|
+
/** Verify a Chonk (IVC) proof from a transaction via bb.js API. */ async verifyProof(tx) {
|
|
140
|
+
const proofType = 'Chonk';
|
|
54
141
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
throw new Error(
|
|
142
|
+
const env = {
|
|
143
|
+
stack: [],
|
|
144
|
+
error: void 0,
|
|
145
|
+
hasError: false
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
const totalTimer = new Timer();
|
|
149
|
+
const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
150
|
+
const verificationKey = this.getVerificationKeyData(circuit);
|
|
151
|
+
// Reconstruct the full proof with public inputs prepended, then convert Fr[] to Uint8Array[]
|
|
152
|
+
const proofWithPubInputs = tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields());
|
|
153
|
+
const fieldsAsBuffers = proofWithPubInputs.fieldsWithPublicInputs.map((f)=>new Uint8Array(f.toBuffer()));
|
|
154
|
+
const instance = _ts_add_disposable_resource(env, await this.bbJsFactory.getInstance(), true);
|
|
155
|
+
const { verified, durationMs } = await instance.verifyChonkProof(fieldsAsBuffers, verificationKey.keyAsBytes);
|
|
156
|
+
if (!verified) {
|
|
157
|
+
throw new Error(`Failed to verify ${proofType} proof for ${circuit}!`);
|
|
71
158
|
}
|
|
72
|
-
this.logger.debug(`${
|
|
73
|
-
circuitName: mapProtocolArtifactNameToCircuitName(
|
|
74
|
-
duration:
|
|
159
|
+
this.logger.debug(`${proofType} verification successful`, {
|
|
160
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuit),
|
|
161
|
+
duration: durationMs,
|
|
75
162
|
eventName: 'circuit-verification',
|
|
76
|
-
proofType: '
|
|
163
|
+
proofType: 'chonk'
|
|
77
164
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
165
|
+
return {
|
|
166
|
+
valid: true,
|
|
167
|
+
durationMs,
|
|
168
|
+
totalDurationMs: totalTimer.ms()
|
|
169
|
+
};
|
|
170
|
+
} catch (e) {
|
|
171
|
+
env.error = e;
|
|
172
|
+
env.hasError = true;
|
|
173
|
+
} finally{
|
|
174
|
+
const result = _ts_dispose_resources(env);
|
|
175
|
+
if (result) await result;
|
|
176
|
+
}
|
|
81
177
|
} catch (err) {
|
|
82
|
-
this.logger.warn(`Failed to verify
|
|
83
|
-
return
|
|
178
|
+
this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
|
|
179
|
+
return {
|
|
180
|
+
valid: false,
|
|
181
|
+
durationMs: 0,
|
|
182
|
+
totalDurationMs: 0
|
|
183
|
+
};
|
|
84
184
|
}
|
|
85
185
|
}
|
|
86
186
|
}
|
|
187
|
+
/** Split a buffer into 32-byte Uint8Array field elements. */ function splitBufferToFieldArrays(buffer) {
|
|
188
|
+
const fields = [];
|
|
189
|
+
for(let i = 0; i < buffer.length; i += 32){
|
|
190
|
+
fields.push(new Uint8Array(buffer.subarray(i, i + 32)));
|
|
191
|
+
}
|
|
192
|
+
return fields;
|
|
193
|
+
}
|
package/dest/verifier/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export * from './batch_chonk_verifier.js';
|
|
1
2
|
export * from './bb_verifier.js';
|
|
2
|
-
|
|
3
|
+
export * from './queued_chonk_verifier.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDO0FBQzFDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyw0QkFBNEIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
package/dest/verifier/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
5
|
+
private verifier;
|
|
6
|
+
private telemetry;
|
|
7
|
+
private logger;
|
|
8
|
+
private queue;
|
|
9
|
+
private metrics;
|
|
10
|
+
constructor(verifier: ClientProtocolCircuitVerifier, concurrency: number, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
11
|
+
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWVkX2Nob25rX3ZlcmlmaWVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvcXVldWVkX2Nob25rX3ZlcmlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLDZCQUE2QixFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDM0MsT0FBTyxFQU1MLEtBQUssZUFBZSxFQUlyQixNQUFNLHlCQUF5QixDQUFDO0FBbUVqQyxxQkFBYSxpQkFBa0IsWUFBVyw2QkFBNkI7SUFLbkUsT0FBTyxDQUFDLFFBQVE7SUFFaEIsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLE1BQU07SUFQaEIsT0FBTyxDQUFDLEtBQUssQ0FBYztJQUMzQixPQUFPLENBQUMsT0FBTyxDQUFxQjtJQUVwQyxZQUNVLFFBQVEsRUFBRSw2QkFBNkIsRUFDL0MsV0FBVyxFQUFFLE1BQU0sRUFDWCxTQUFTLEdBQUUsZUFBc0MsRUFDakQsTUFBTSx5Q0FBa0QsRUFNakU7SUFFWSxXQUFXLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FJcEU7SUFFSyxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUcxQjtDQUNGIn0=
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault, 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
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
22
|
+
this.ivcFailureCount = createUpDownCounterWithDefault(meter, Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
23
|
+
this.aggDurationMetrics = {
|
|
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)
|
|
29
|
+
};
|
|
30
|
+
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
31
|
+
}
|
|
32
|
+
recordIVCVerification(result) {
|
|
33
|
+
this.ivcVerificationHistogram.record(Math.ceil(result.durationMs), {
|
|
34
|
+
[Attributes.OK]: result.valid
|
|
35
|
+
});
|
|
36
|
+
this.ivcTotalVerificationHistogram.record(Math.ceil(result.totalDurationMs), {
|
|
37
|
+
[Attributes.OK]: result.valid
|
|
38
|
+
});
|
|
39
|
+
if (!result.valid) {
|
|
40
|
+
this.ivcFailureCount.add(1);
|
|
41
|
+
this.localHistogramFails.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
42
|
+
} else {
|
|
43
|
+
this.localHistogramOk.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
aggregate = (res)=>{
|
|
47
|
+
for (const [histogram, ok] of [
|
|
48
|
+
[
|
|
49
|
+
this.localHistogramOk,
|
|
50
|
+
true
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
this.localHistogramFails,
|
|
54
|
+
false
|
|
55
|
+
]
|
|
56
|
+
]){
|
|
57
|
+
if (histogram.count === 0) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
res.observe(this.aggDurationMetrics.avg, histogram.mean, {
|
|
61
|
+
[Attributes.OK]: ok
|
|
62
|
+
});
|
|
63
|
+
res.observe(this.aggDurationMetrics.max, histogram.max, {
|
|
64
|
+
[Attributes.OK]: ok
|
|
65
|
+
});
|
|
66
|
+
res.observe(this.aggDurationMetrics.min, histogram.min, {
|
|
67
|
+
[Attributes.OK]: ok
|
|
68
|
+
});
|
|
69
|
+
res.observe(this.aggDurationMetrics.p50, histogram.percentile(50), {
|
|
70
|
+
[Attributes.OK]: ok
|
|
71
|
+
});
|
|
72
|
+
res.observe(this.aggDurationMetrics.p90, histogram.percentile(90), {
|
|
73
|
+
[Attributes.OK]: ok
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export class QueuedIVCVerifier {
|
|
79
|
+
verifier;
|
|
80
|
+
telemetry;
|
|
81
|
+
logger;
|
|
82
|
+
queue;
|
|
83
|
+
metrics;
|
|
84
|
+
constructor(verifier, concurrency, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
|
|
85
|
+
this.verifier = verifier;
|
|
86
|
+
this.telemetry = telemetry;
|
|
87
|
+
this.logger = logger;
|
|
88
|
+
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
89
|
+
this.queue = new SerialQueue();
|
|
90
|
+
this.logger.info(`Starting QueuedIVCVerifier with ${concurrency} concurrent verifiers`);
|
|
91
|
+
this.queue.start(concurrency);
|
|
92
|
+
}
|
|
93
|
+
async verifyProof(tx) {
|
|
94
|
+
const result = await this.queue.put(()=>this.verifier.verifyProof(tx));
|
|
95
|
+
this.metrics.recordIVCVerification(result);
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
async stop() {
|
|
99
|
+
await this.queue.end();
|
|
100
|
+
await this.verifier.stop();
|
|
101
|
+
}
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-commit.017a351",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
-
"./
|
|
8
|
-
"./
|
|
9
|
-
"./
|
|
7
|
+
"./client/bundle": "./dest/prover/client/bundle.js",
|
|
8
|
+
"./client/lazy": "./dest/prover/client/lazy.js",
|
|
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"
|
|
@@ -25,11 +26,9 @@
|
|
|
25
26
|
"../package.common.json"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
|
-
"build": "yarn clean && tsc
|
|
29
|
-
"build:dev": "tsc
|
|
29
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
30
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
30
31
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
31
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
32
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
33
32
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
34
33
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
35
34
|
},
|
|
@@ -64,40 +63,45 @@
|
|
|
64
63
|
"testTimeout": 120000,
|
|
65
64
|
"setupFiles": [
|
|
66
65
|
"../../foundation/src/jest/setup.mjs"
|
|
66
|
+
],
|
|
67
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
68
|
+
"setupFilesAfterEnv": [
|
|
69
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
67
70
|
]
|
|
68
71
|
},
|
|
69
72
|
"dependencies": {
|
|
70
|
-
"@aztec/bb.js": "0.0.
|
|
71
|
-
"@aztec/constants": "0.0.
|
|
72
|
-
"@aztec/foundation": "0.0.
|
|
73
|
-
"@aztec/noir-
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@
|
|
73
|
+
"@aztec/bb.js": "0.0.1-commit.017a351",
|
|
74
|
+
"@aztec/constants": "0.0.1-commit.017a351",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.017a351",
|
|
76
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.017a351",
|
|
77
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.017a351",
|
|
78
|
+
"@aztec/noir-types": "0.0.1-commit.017a351",
|
|
79
|
+
"@aztec/simulator": "0.0.1-commit.017a351",
|
|
80
|
+
"@aztec/stdlib": "0.0.1-commit.017a351",
|
|
81
|
+
"@aztec/telemetry-client": "0.0.1-commit.017a351",
|
|
82
|
+
"@aztec/world-state": "0.0.1-commit.017a351",
|
|
79
83
|
"commander": "^12.1.0",
|
|
84
|
+
"msgpackr": "^1.11.2",
|
|
80
85
|
"pako": "^2.1.0",
|
|
81
86
|
"source-map-support": "^0.5.21",
|
|
82
|
-
"tslib": "^2.4.0"
|
|
83
|
-
"@aztec/noir-noirc_abi": "0.0.0-test.1",
|
|
84
|
-
"@aztec/noir-types": "0.0.0-test.1"
|
|
87
|
+
"tslib": "^2.4.0"
|
|
85
88
|
},
|
|
86
89
|
"devDependencies": {
|
|
87
|
-
"@aztec/ethereum": "0.0.
|
|
88
|
-
"@aztec/kv-store": "0.0.
|
|
89
|
-
"@aztec/noir-contracts.js": "0.0.
|
|
90
|
-
"@aztec/
|
|
91
|
-
"@
|
|
92
|
-
"@
|
|
93
|
-
"@types/
|
|
94
|
-
"@types/node": "^
|
|
90
|
+
"@aztec/ethereum": "0.0.1-commit.017a351",
|
|
91
|
+
"@aztec/kv-store": "0.0.1-commit.017a351",
|
|
92
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.017a351",
|
|
93
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.017a351",
|
|
94
|
+
"@aztec/protocol-contracts": "0.0.1-commit.017a351",
|
|
95
|
+
"@jest/globals": "^30.0.0",
|
|
96
|
+
"@types/jest": "^30.0.0",
|
|
97
|
+
"@types/node": "^22.15.17",
|
|
95
98
|
"@types/source-map-support": "^0.5.10",
|
|
96
|
-
"
|
|
97
|
-
"jest
|
|
99
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
100
|
+
"jest": "^30.0.0",
|
|
101
|
+
"jest-mock-extended": "^4.0.0",
|
|
98
102
|
"ts-node": "^10.9.1",
|
|
99
|
-
"typescript": "^5.
|
|
100
|
-
"viem": "2.
|
|
103
|
+
"typescript": "^5.3.3",
|
|
104
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
101
105
|
},
|
|
102
106
|
"files": [
|
|
103
107
|
"dest",
|
|
@@ -106,6 +110,6 @@
|
|
|
106
110
|
],
|
|
107
111
|
"types": "./dest/index.d.ts",
|
|
108
112
|
"engines": {
|
|
109
|
-
"node": ">=
|
|
113
|
+
"node": ">=20.10"
|
|
110
114
|
}
|
|
111
115
|
}
|