@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.
Files changed (130) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +21 -20
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +196 -87
  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 +19 -1
  16. package/dest/config.d.ts.map +1 -1
  17. package/dest/honk.d.ts +3 -3
  18. package/dest/honk.d.ts.map +1 -1
  19. package/dest/honk.js +3 -2
  20. package/dest/index.d.ts +4 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +3 -1
  23. package/dest/instrumentation.d.ts +3 -3
  24. package/dest/instrumentation.d.ts.map +1 -1
  25. package/dest/instrumentation.js +22 -46
  26. package/dest/prover/client/bb_private_kernel_prover.d.ts +46 -0
  27. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
  28. package/dest/prover/client/bb_private_kernel_prover.js +177 -0
  29. package/dest/prover/client/bundle.d.ts +6 -0
  30. package/dest/prover/client/bundle.d.ts.map +1 -0
  31. package/dest/prover/client/bundle.js +7 -0
  32. package/dest/prover/client/lazy.d.ts +6 -0
  33. package/dest/prover/client/lazy.d.ts.map +1 -0
  34. package/dest/prover/client/lazy.js +7 -0
  35. package/dest/prover/index.d.ts +3 -4
  36. package/dest/prover/index.d.ts.map +1 -1
  37. package/dest/prover/index.js +2 -3
  38. package/dest/prover/proof_utils.d.ts +29 -0
  39. package/dest/prover/proof_utils.d.ts.map +1 -0
  40. package/dest/prover/proof_utils.js +95 -0
  41. package/dest/prover/server/bb_prover.d.ts +96 -0
  42. package/dest/prover/server/bb_prover.d.ts.map +1 -0
  43. package/dest/prover/server/bb_prover.js +841 -0
  44. package/dest/test/delay_values.d.ts +1 -1
  45. package/dest/test/delay_values.d.ts.map +1 -1
  46. package/dest/test/delay_values.js +37 -23
  47. package/dest/test/index.d.ts +2 -1
  48. package/dest/test/index.d.ts.map +1 -1
  49. package/dest/test/index.js +1 -0
  50. package/dest/test/test_circuit_prover.d.ts +27 -36
  51. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  52. package/dest/test/test_circuit_prover.js +517 -88
  53. package/dest/test/test_verifier.d.ts +6 -3
  54. package/dest/test/test_verifier.d.ts.map +1 -1
  55. package/dest/test/test_verifier.js +23 -1
  56. package/dest/verification_key/verification_key_data.d.ts +1 -2
  57. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  58. package/dest/verification_key/verification_key_data.js +9 -34
  59. package/dest/verifier/batch_chonk_verifier.d.ts +56 -0
  60. package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
  61. package/dest/verifier/batch_chonk_verifier.js +384 -0
  62. package/dest/verifier/bb_verifier.d.ts +9 -5
  63. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  64. package/dest/verifier/bb_verifier.js +156 -49
  65. package/dest/verifier/index.d.ts +3 -1
  66. package/dest/verifier/index.d.ts.map +1 -1
  67. package/dest/verifier/index.js +2 -0
  68. package/dest/verifier/queued_chonk_verifier.d.ts +14 -0
  69. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
  70. package/dest/verifier/queued_chonk_verifier.js +102 -0
  71. package/package.json +38 -34
  72. package/src/avm_proving_tests/avm_proving_tester.ts +163 -126
  73. package/src/bb/bb_js_backend.ts +435 -0
  74. package/src/bb/bb_js_debug.ts +227 -0
  75. package/src/bb/file_names.ts +6 -0
  76. package/src/config.ts +18 -0
  77. package/src/honk.ts +3 -2
  78. package/src/index.ts +3 -1
  79. package/src/instrumentation.ts +22 -47
  80. package/src/prover/client/bb_private_kernel_prover.ts +423 -0
  81. package/src/prover/client/bundle.ts +10 -0
  82. package/src/prover/client/lazy.ts +10 -0
  83. package/src/prover/index.ts +2 -3
  84. package/src/prover/proof_utils.ts +155 -0
  85. package/src/prover/server/bb_prover.ts +713 -0
  86. package/src/test/delay_values.ts +38 -22
  87. package/src/test/index.ts +1 -0
  88. package/src/test/test_circuit_prover.ts +264 -154
  89. package/src/test/test_verifier.ts +15 -3
  90. package/src/verification_key/verification_key_data.ts +11 -31
  91. package/src/verifier/batch_chonk_verifier.ts +415 -0
  92. package/src/verifier/bb_verifier.ts +93 -76
  93. package/src/verifier/index.ts +2 -0
  94. package/src/verifier/queued_chonk_verifier.ts +108 -0
  95. package/dest/bb/execute.d.ts +0 -140
  96. package/dest/bb/execute.d.ts.map +0 -1
  97. package/dest/bb/execute.js +0 -780
  98. package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
  99. package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
  100. package/dest/prover/bb_native_private_kernel_prover.js +0 -69
  101. package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
  102. package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
  103. package/dest/prover/bb_private_kernel_prover.js +0 -109
  104. package/dest/prover/bb_prover.d.ts +0 -120
  105. package/dest/prover/bb_prover.d.ts.map +0 -1
  106. package/dest/prover/bb_prover.js +0 -423
  107. package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
  108. package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
  109. package/dest/prover/client_ivc_proof_utils.js +0 -43
  110. package/dest/stats.d.ts +0 -5
  111. package/dest/stats.d.ts.map +0 -1
  112. package/dest/stats.js +0 -62
  113. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
  114. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
  115. package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
  116. package/dest/wasm/bundle.d.ts +0 -6
  117. package/dest/wasm/bundle.d.ts.map +0 -1
  118. package/dest/wasm/bundle.js +0 -8
  119. package/dest/wasm/lazy.d.ts +0 -6
  120. package/dest/wasm/lazy.d.ts.map +0 -1
  121. package/dest/wasm/lazy.js +0 -8
  122. package/src/bb/execute.ts +0 -853
  123. package/src/prover/bb_native_private_kernel_prover.ts +0 -119
  124. package/src/prover/bb_private_kernel_prover.ts +0 -249
  125. package/src/prover/bb_prover.ts +0 -781
  126. package/src/prover/client_ivc_proof_utils.ts +0 -42
  127. package/src/stats.ts +0 -64
  128. package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
  129. package/src/wasm/bundle.ts +0 -11
  130. package/src/wasm/lazy.ts +0 -11
@@ -1,86 +1,193 @@
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
- import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
4
- import { Tx } from '@aztec/stdlib/tx';
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 * as path from 'path';
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(circuitType) {
25
- const vk = ServerCircuitVks[circuitType];
100
+ getVerificationKeyData(circuit) {
101
+ const vk = ProtocolCircuitVks[circuit];
26
102
  if (vk === undefined) {
27
- throw new Error('Could not find VK for server artifact ' + circuitType);
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 operation = async (bbWorkingDirectory)=>{
33
- const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
34
- 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 {
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
- await fs.writeFile(proofFileName, proof.buffer);
38
- await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
39
- const result = await verifyProof(this.config.bbBinaryPath, proofFileName, verificationKeyPath, getUltraHonkFlavorForCircuit(circuit), this.logger);
40
- if (result.status === BB_RESULT.FAILURE) {
41
- const errorMessage = `Failed to verify ${circuit} proof!`;
42
- 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!`);
43
124
  }
44
125
  this.logger.debug(`${circuit} verification successful`, {
45
126
  circuitName: mapProtocolArtifactNameToCircuitName(circuit),
46
- duration: result.durationMs,
127
+ duration: durationMs,
47
128
  eventName: 'circuit-verification',
48
129
  proofType: 'ultra-honk'
49
130
  });
50
- };
51
- 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
+ }
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
- // TODO(#7370) The verification keys should be supplied separately and based on the expectedCircuit
56
- // rather than read from the tx object itself. We also need the vks for the translator and ecc, which
57
- // are not being saved along the other vks yet. Reuse the 'verifyProofForCircuit' method above once
58
- // we have all the verification keys available.
59
- const expectedCircuit = tx.data.forPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact';
60
- const circuit = 'ClientIVC';
61
- // Block below is almost copy-pasted from verifyProofForCircuit
62
- const operation = async (bbWorkingDirectory)=>{
63
- const logFunction = (message)=>{
64
- this.logger.debug(`${circuit} BB out - ${message}`);
65
- };
66
- await writeToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
67
- const result = await verifyClientIvcProof(this.config.bbBinaryPath, bbWorkingDirectory.concat('/proof'), bbWorkingDirectory.concat('/vk'), logFunction);
68
- if (result.status === BB_RESULT.FAILURE) {
69
- const errorMessage = `Failed to verify ${circuit} proof!`;
70
- throw new Error(errorMessage);
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(`${circuit} verification successful`, {
73
- circuitName: mapProtocolArtifactNameToCircuitName(expectedCircuit),
74
- duration: result.durationMs,
159
+ this.logger.debug(`${proofType} verification successful`, {
160
+ circuitName: mapProtocolArtifactNameToCircuitName(circuit),
161
+ duration: durationMs,
75
162
  eventName: 'circuit-verification',
76
- proofType: 'client-ivc'
163
+ proofType: 'chonk'
77
164
  });
78
- };
79
- await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
80
- return true;
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 ClientIVC proof for tx ${Tx.getHash(tx)}: ${String(err)}`);
83
- return false;
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
+ }
@@ -1,2 +1,4 @@
1
+ export * from './batch_chonk_verifier.js';
1
2
  export * from './bb_verifier.js';
2
- //# sourceMappingURL=index.d.ts.map
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"}
@@ -1 +1,3 @@
1
+ export * from './batch_chonk_verifier.js';
1
2
  export * from './bb_verifier.js';
3
+ export * from './queued_chonk_verifier.js';
@@ -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.0-test.1",
3
+ "version": "0.0.1-commit.017a351",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
- "./wasm/bundle": "./dest/wasm/bundle.js",
8
- "./wasm/lazy": "./dest/wasm/lazy.js",
9
- "./prover": "./dest/prover/index.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,11 +26,9 @@
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
- "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.0-test.1",
71
- "@aztec/constants": "0.0.0-test.1",
72
- "@aztec/foundation": "0.0.0-test.1",
73
- "@aztec/noir-protocol-circuits-types": "0.0.0-test.1",
74
- "@aztec/simulator": "0.0.0-test.1",
75
- "@aztec/stdlib": "0.0.0-test.1",
76
- "@aztec/telemetry-client": "0.0.0-test.1",
77
- "@aztec/world-state": "0.0.0-test.1",
78
- "@msgpack/msgpack": "^3.0.0-beta2",
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.0-test.1",
88
- "@aztec/kv-store": "0.0.0-test.1",
89
- "@aztec/noir-contracts.js": "0.0.0-test.1",
90
- "@aztec/protocol-contracts": "0.0.0-test.1",
91
- "@jest/globals": "^29.5.0",
92
- "@types/jest": "^29.5.0",
93
- "@types/memdown": "^3.0.0",
94
- "@types/node": "^18.7.23",
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
- "jest": "^29.5.0",
97
- "jest-mock-extended": "^3.0.3",
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.0.4",
100
- "viem": "2.22.8"
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": ">=18"
113
+ "node": ">=20.10"
110
114
  }
111
115
  }