@aztec/bb-prover 0.0.1-commit.24de95ac → 0.0.1-commit.2606882

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.
Files changed (108) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +15 -11
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +167 -108
  4. package/dest/bb/bb_js_backend.d.ts +196 -0
  5. package/dest/bb/bb_js_backend.d.ts.map +1 -0
  6. package/dest/bb/bb_js_backend.js +379 -0
  7. package/dest/bb/bb_js_debug.d.ts +52 -0
  8. package/dest/bb/bb_js_debug.d.ts.map +1 -0
  9. package/dest/bb/bb_js_debug.js +176 -0
  10. package/dest/bb/cli.d.ts +1 -1
  11. package/dest/bb/file_names.d.ts +4 -0
  12. package/dest/bb/file_names.d.ts.map +1 -0
  13. package/dest/bb/file_names.js +5 -0
  14. package/dest/bb/index.d.ts +1 -1
  15. package/dest/config.d.ts +17 -1
  16. package/dest/config.d.ts.map +1 -1
  17. package/dest/honk.d.ts +1 -1
  18. package/dest/index.d.ts +3 -2
  19. package/dest/index.d.ts.map +1 -1
  20. package/dest/index.js +2 -1
  21. package/dest/instrumentation.d.ts +1 -1
  22. package/dest/instrumentation.d.ts.map +1 -1
  23. package/dest/instrumentation.js +21 -43
  24. package/dest/prover/client/bb_private_kernel_prover.d.ts +20 -6
  25. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
  26. package/dest/prover/client/bb_private_kernel_prover.js +73 -8
  27. package/dest/prover/client/bundle.d.ts +6 -0
  28. package/dest/prover/client/bundle.d.ts.map +1 -0
  29. package/dest/prover/client/bundle.js +7 -0
  30. package/dest/prover/client/lazy.d.ts +6 -0
  31. package/dest/prover/client/lazy.d.ts.map +1 -0
  32. package/dest/prover/client/lazy.js +7 -0
  33. package/dest/prover/index.d.ts +1 -1
  34. package/dest/prover/proof_utils.d.ts +11 -1
  35. package/dest/prover/proof_utils.d.ts.map +1 -1
  36. package/dest/prover/proof_utils.js +25 -2
  37. package/dest/prover/server/bb_prover.d.ts +8 -21
  38. package/dest/prover/server/bb_prover.d.ts.map +1 -1
  39. package/dest/prover/server/bb_prover.js +614 -112
  40. package/dest/test/delay_values.d.ts +1 -1
  41. package/dest/test/delay_values.d.ts.map +1 -1
  42. package/dest/test/delay_values.js +29 -27
  43. package/dest/test/index.d.ts +2 -1
  44. package/dest/test/index.d.ts.map +1 -1
  45. package/dest/test/index.js +1 -0
  46. package/dest/test/test_circuit_prover.d.ts +4 -4
  47. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  48. package/dest/test/test_circuit_prover.js +462 -59
  49. package/dest/test/test_verifier.d.ts +3 -1
  50. package/dest/test/test_verifier.d.ts.map +1 -1
  51. package/dest/test/test_verifier.js +15 -0
  52. package/dest/verification_key/verification_key_data.d.ts +1 -8
  53. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  54. package/dest/verification_key/verification_key_data.js +2 -21
  55. package/dest/verifier/batch_chonk_verifier.d.ts +56 -0
  56. package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
  57. package/dest/verifier/batch_chonk_verifier.js +384 -0
  58. package/dest/verifier/bb_verifier.d.ts +4 -1
  59. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  60. package/dest/verifier/bb_verifier.js +137 -48
  61. package/dest/verifier/index.d.ts +2 -1
  62. package/dest/verifier/index.d.ts.map +1 -1
  63. package/dest/verifier/index.js +1 -0
  64. package/dest/verifier/queued_chonk_verifier.d.ts +2 -3
  65. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
  66. package/dest/verifier/queued_chonk_verifier.js +15 -45
  67. package/package.json +26 -23
  68. package/src/avm_proving_tests/avm_proving_tester.ts +69 -138
  69. package/src/bb/bb_js_backend.ts +435 -0
  70. package/src/bb/bb_js_debug.ts +227 -0
  71. package/src/bb/file_names.ts +6 -0
  72. package/src/config.ts +16 -0
  73. package/src/index.ts +2 -1
  74. package/src/instrumentation.ts +20 -43
  75. package/src/prover/client/bb_private_kernel_prover.ts +158 -8
  76. package/src/prover/client/bundle.ts +10 -0
  77. package/src/prover/client/lazy.ts +10 -0
  78. package/src/prover/proof_utils.ts +42 -2
  79. package/src/prover/server/bb_prover.ts +139 -159
  80. package/src/test/delay_values.ts +31 -27
  81. package/src/test/index.ts +1 -0
  82. package/src/test/test_circuit_prover.ts +10 -13
  83. package/src/test/test_verifier.ts +8 -0
  84. package/src/verification_key/verification_key_data.ts +2 -27
  85. package/src/verifier/batch_chonk_verifier.ts +415 -0
  86. package/src/verifier/bb_verifier.ts +69 -80
  87. package/src/verifier/index.ts +1 -0
  88. package/src/verifier/queued_chonk_verifier.ts +15 -47
  89. package/dest/bb/execute.d.ts +0 -107
  90. package/dest/bb/execute.d.ts.map +0 -1
  91. package/dest/bb/execute.js +0 -672
  92. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
  93. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
  94. package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
  95. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
  96. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
  97. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -46
  98. package/dest/prover/client/wasm/bundle.d.ts +0 -6
  99. package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
  100. package/dest/prover/client/wasm/bundle.js +0 -8
  101. package/dest/prover/client/wasm/lazy.d.ts +0 -6
  102. package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
  103. package/dest/prover/client/wasm/lazy.js +0 -8
  104. package/src/bb/execute.ts +0 -709
  105. package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
  106. package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -58
  107. package/src/prover/client/wasm/bundle.ts +0 -11
  108. package/src/prover/client/wasm/lazy.ts +0 -11
@@ -1,24 +1,97 @@
1
- import { runInDirectory } from '@aztec/foundation/fs';
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
67
  import { Timer } from '@aztec/foundation/timer';
4
68
  import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
5
69
  import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
6
70
  import { promises as fs } from 'fs';
7
- import * as path from 'path';
8
- import { BB_RESULT, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME, VK_FILENAME, verifyChonkProof, verifyProof } from '../bb/execute.js';
71
+ import { BBJsFactory } from '../bb/bb_js_backend.js';
9
72
  import { getUltraHonkFlavorForCircuit } from '../honk.js';
10
- import { writeChonkProofToPath } from '../prover/proof_utils.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
+ });
17
87
  }
18
88
  stop() {
19
- return Promise.resolve();
89
+ return this.bbJsFactory.destroy();
20
90
  }
21
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
+ }
22
95
  await fs.mkdir(config.bbWorkingDirectory, {
23
96
  recursive: true
24
97
  });
@@ -31,67 +104,76 @@ export class BBCircuitVerifier {
31
104
  }
32
105
  return vk;
33
106
  }
34
- async verifyProofForCircuit(circuit, proof) {
35
- const operation = async (bbWorkingDirectory)=>{
36
- const publicInputsFileName = path.join(bbWorkingDirectory, PUBLIC_INPUTS_FILENAME);
37
- const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
38
- const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
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 {
39
114
  const verificationKey = this.getVerificationKeyData(circuit);
115
+ const flavor = getUltraHonkFlavorForCircuit(circuit);
40
116
  this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
41
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
42
- await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
43
- await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
44
- await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
45
- const result = await verifyProof(this.config.bbBinaryPath, proofFileName, verificationKeyPath, getUltraHonkFlavorForCircuit(circuit), this.logger);
46
- if (result.status === BB_RESULT.FAILURE) {
47
- const errorMessage = `Failed to verify ${circuit} proof!`;
48
- throw new Error(errorMessage);
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!`);
49
124
  }
50
125
  this.logger.debug(`${circuit} verification successful`, {
51
126
  circuitName: mapProtocolArtifactNameToCircuitName(circuit),
52
- duration: result.durationMs,
127
+ duration: durationMs,
53
128
  eventName: 'circuit-verification',
54
129
  proofType: 'ultra-honk'
55
130
  });
56
- };
57
- await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
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
+ }
58
138
  }
59
- async verifyProof(tx) {
139
+ /** Verify a Chonk (IVC) proof from a transaction via bb.js API. */ async verifyProof(tx) {
60
140
  const proofType = 'Chonk';
61
141
  try {
62
- const totalTimer = new Timer();
63
- let verificationDuration = 0;
64
- const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
65
- // Block below is almost copy-pasted from verifyProofForCircuit
66
- const operation = async (bbWorkingDirectory)=>{
67
- const logFunction = (message)=>{
68
- this.logger.debug(`${proofType} BB out - ${message}`);
69
- };
70
- const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
71
- await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
72
- const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
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';
73
150
  const verificationKey = this.getVerificationKeyData(circuit);
74
- await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
75
- const timer = new Timer();
76
- const result = await verifyChonkProof(this.config.bbBinaryPath, proofPath, verificationKeyPath, logFunction, this.config.bbIVCConcurrency);
77
- verificationDuration = timer.ms();
78
- if (result.status === BB_RESULT.FAILURE) {
79
- const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
80
- throw new Error(errorMessage);
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}!`);
81
158
  }
82
159
  this.logger.debug(`${proofType} verification successful`, {
83
160
  circuitName: mapProtocolArtifactNameToCircuitName(circuit),
84
- duration: result.durationMs,
161
+ duration: durationMs,
85
162
  eventName: 'circuit-verification',
86
163
  proofType: 'chonk'
87
164
  });
88
- };
89
- await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
90
- return {
91
- valid: true,
92
- durationMs: verificationDuration,
93
- totalDurationMs: totalTimer.ms()
94
- };
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
+ }
95
177
  } catch (err) {
96
178
  this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
97
179
  return {
@@ -102,3 +184,10 @@ export class BBCircuitVerifier {
102
184
  }
103
185
  }
104
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
+ }
@@ -1,3 +1,4 @@
1
+ export * from './batch_chonk_verifier.js';
1
2
  export * from './bb_verifier.js';
2
3
  export * from './queued_chonk_verifier.js';
3
- //# sourceMappingURL=index.d.ts.map
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;AACjC,cAAc,4BAA4B,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"}
@@ -1,2 +1,3 @@
1
+ export * from './batch_chonk_verifier.js';
1
2
  export * from './bb_verifier.js';
2
3
  export * from './queued_chonk_verifier.js';
@@ -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(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
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=queued_chonk_verifier.d.ts.map
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,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAgG7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAMnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;gBAGlC,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAkD;IAQrD,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAMrE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtB"}
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, ValueType, 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;
@@ -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
- unit: 'ms',
22
- description: 'Duration to verify chonk 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 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
- 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
- })
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
  }
@@ -112,21 +81,22 @@ export class QueuedIVCVerifier {
112
81
  logger;
113
82
  queue;
114
83
  metrics;
115
- constructor(config, verifier, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
84
+ constructor(verifier, concurrency, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
116
85
  this.verifier = verifier;
117
86
  this.telemetry = telemetry;
118
87
  this.logger = logger;
119
88
  this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
120
89
  this.queue = new SerialQueue();
121
- this.logger.info(`Starting QueuedIVCVerifier with ${config.numConcurrentIVCVerifiers} concurrent verifiers`);
122
- this.queue.start(config.numConcurrentIVCVerifiers);
90
+ this.logger.info(`Starting QueuedIVCVerifier with ${concurrency} concurrent verifiers`);
91
+ this.queue.start(concurrency);
123
92
  }
124
93
  async verifyProof(tx) {
125
94
  const result = await this.queue.put(()=>this.verifier.verifyProof(tx));
126
95
  this.metrics.recordIVCVerification(result);
127
96
  return result;
128
97
  }
129
- stop() {
130
- return this.queue.end();
98
+ async stop() {
99
+ await this.queue.end();
100
+ await this.verifier.stop();
131
101
  }
132
102
  }
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@aztec/bb-prover",
3
- "version": "0.0.1-commit.24de95ac",
3
+ "version": "0.0.1-commit.2606882",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
- "./client/wasm/bundle": "./dest/prover/client/wasm/bundle.js",
8
- "./client/wasm/lazy": "./dest/prover/client/wasm/lazy.js",
9
- "./client/native": "./dest/prover/client/native/bb_native_private_kernel_prover.js",
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,8 +26,8 @@
25
26
  "../package.common.json"
26
27
  ],
27
28
  "scripts": {
28
- "build": "yarn clean && tsc -b",
29
- "build:dev": "tsc -b --watch",
29
+ "build": "yarn clean && ../scripts/tsc.sh",
30
+ "build:dev": "../scripts/tsc.sh --watch",
30
31
  "clean": "rm -rf ./dest .tsbuildinfo",
31
32
  "bb": "node --no-warnings ./dest/bb/index.js",
32
33
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
@@ -69,36 +70,38 @@
69
70
  ]
70
71
  },
71
72
  "dependencies": {
72
- "@aztec/bb.js": "0.0.1-commit.24de95ac",
73
- "@aztec/constants": "0.0.1-commit.24de95ac",
74
- "@aztec/foundation": "0.0.1-commit.24de95ac",
75
- "@aztec/noir-noirc_abi": "0.0.1-commit.24de95ac",
76
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.24de95ac",
77
- "@aztec/noir-types": "0.0.1-commit.24de95ac",
78
- "@aztec/simulator": "0.0.1-commit.24de95ac",
79
- "@aztec/stdlib": "0.0.1-commit.24de95ac",
80
- "@aztec/telemetry-client": "0.0.1-commit.24de95ac",
81
- "@aztec/world-state": "0.0.1-commit.24de95ac",
73
+ "@aztec/bb.js": "0.0.1-commit.2606882",
74
+ "@aztec/constants": "0.0.1-commit.2606882",
75
+ "@aztec/foundation": "0.0.1-commit.2606882",
76
+ "@aztec/noir-noirc_abi": "0.0.1-commit.2606882",
77
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.2606882",
78
+ "@aztec/noir-types": "0.0.1-commit.2606882",
79
+ "@aztec/simulator": "0.0.1-commit.2606882",
80
+ "@aztec/stdlib": "0.0.1-commit.2606882",
81
+ "@aztec/telemetry-client": "0.0.1-commit.2606882",
82
+ "@aztec/world-state": "0.0.1-commit.2606882",
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.24de95ac",
89
- "@aztec/kv-store": "0.0.1-commit.24de95ac",
90
- "@aztec/noir-contracts.js": "0.0.1-commit.24de95ac",
91
- "@aztec/noir-test-contracts.js": "0.0.1-commit.24de95ac",
92
- "@aztec/protocol-contracts": "0.0.1-commit.24de95ac",
90
+ "@aztec/ethereum": "0.0.1-commit.2606882",
91
+ "@aztec/kv-store": "0.0.1-commit.2606882",
92
+ "@aztec/noir-contracts.js": "0.0.1-commit.2606882",
93
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.2606882",
94
+ "@aztec/protocol-contracts": "0.0.1-commit.2606882",
93
95
  "@jest/globals": "^30.0.0",
94
96
  "@types/jest": "^30.0.0",
95
97
  "@types/node": "^22.15.17",
96
98
  "@types/source-map-support": "^0.5.10",
99
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
97
100
  "jest": "^30.0.0",
98
101
  "jest-mock-extended": "^4.0.0",
99
102
  "ts-node": "^10.9.1",
100
103
  "typescript": "^5.3.3",
101
- "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
104
+ "viem": "npm:@aztec/viem@2.38.2"
102
105
  },
103
106
  "files": [
104
107
  "dest",