@aztec/prover-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d431d1c

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 (105) hide show
  1. package/dest/config.d.ts +2 -2
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +1 -1
  4. package/dest/light/index.d.ts +2 -0
  5. package/dest/light/index.d.ts.map +1 -0
  6. package/dest/light/index.js +1 -0
  7. package/dest/light/lightweight_checkpoint_builder.d.ts +29 -14
  8. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
  9. package/dest/light/lightweight_checkpoint_builder.js +108 -21
  10. package/dest/mocks/fixtures.js +2 -2
  11. package/dest/mocks/test_context.d.ts +5 -3
  12. package/dest/mocks/test_context.d.ts.map +1 -1
  13. package/dest/mocks/test_context.js +21 -8
  14. package/dest/orchestrator/block-building-helpers.d.ts +3 -3
  15. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  16. package/dest/orchestrator/block-building-helpers.js +2 -2
  17. package/dest/orchestrator/block-proving-state.d.ts +2 -2
  18. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  19. package/dest/orchestrator/block-proving-state.js +1 -1
  20. package/dest/orchestrator/checkpoint-proving-state.d.ts +16 -3
  21. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  22. package/dest/orchestrator/checkpoint-proving-state.js +36 -2
  23. package/dest/orchestrator/epoch-proving-state.d.ts +5 -4
  24. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  25. package/dest/orchestrator/epoch-proving-state.js +35 -1
  26. package/dest/orchestrator/orchestrator.d.ts +14 -4
  27. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  28. package/dest/orchestrator/orchestrator.js +449 -64
  29. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  30. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  31. package/dest/orchestrator/orchestrator_metrics.js +2 -15
  32. package/dest/orchestrator/tx-proving-state.d.ts +6 -5
  33. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  34. package/dest/orchestrator/tx-proving-state.js +8 -8
  35. package/dest/prover-client/factory.d.ts +3 -3
  36. package/dest/prover-client/factory.d.ts.map +1 -1
  37. package/dest/prover-client/prover-client.d.ts +3 -3
  38. package/dest/prover-client/prover-client.d.ts.map +1 -1
  39. package/dest/prover-client/prover-client.js +1 -1
  40. package/dest/prover-client/server-epoch-prover.d.ts +2 -2
  41. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  42. package/dest/proving_broker/broker_prover_facade.d.ts +4 -3
  43. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  44. package/dest/proving_broker/broker_prover_facade.js +3 -10
  45. package/dest/proving_broker/config.d.ts +2 -2
  46. package/dest/proving_broker/config.d.ts.map +1 -1
  47. package/dest/proving_broker/config.js +1 -1
  48. package/dest/proving_broker/fixtures.js +1 -1
  49. package/dest/proving_broker/proving_agent.d.ts +3 -8
  50. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  51. package/dest/proving_broker/proving_agent.js +1 -16
  52. package/dest/proving_broker/proving_broker.d.ts +1 -1
  53. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  54. package/dest/proving_broker/proving_broker.js +4 -10
  55. package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -2
  56. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  57. package/dest/proving_broker/proving_broker_database/persisted.js +389 -1
  58. package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
  59. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  60. package/dest/proving_broker/proving_broker_instrumentation.js +11 -35
  61. package/dest/proving_broker/proving_job_controller.d.ts +1 -1
  62. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  63. package/dest/proving_broker/proving_job_controller.js +2 -3
  64. package/dest/test/mock_proof_store.d.ts +3 -3
  65. package/dest/test/mock_proof_store.d.ts.map +1 -1
  66. package/dest/test/mock_prover.d.ts +2 -2
  67. package/dest/test/mock_prover.d.ts.map +1 -1
  68. package/dest/test/mock_prover.js +4 -4
  69. package/package.json +18 -17
  70. package/src/config.ts +1 -1
  71. package/src/light/index.ts +1 -0
  72. package/src/light/lightweight_checkpoint_builder.ts +158 -27
  73. package/src/mocks/fixtures.ts +2 -2
  74. package/src/mocks/test_context.ts +18 -6
  75. package/src/orchestrator/block-building-helpers.ts +2 -2
  76. package/src/orchestrator/block-proving-state.ts +1 -1
  77. package/src/orchestrator/checkpoint-proving-state.ts +49 -2
  78. package/src/orchestrator/epoch-proving-state.ts +56 -8
  79. package/src/orchestrator/orchestrator.ts +45 -43
  80. package/src/orchestrator/orchestrator_metrics.ts +2 -25
  81. package/src/orchestrator/tx-proving-state.ts +10 -14
  82. package/src/prover-client/factory.ts +6 -2
  83. package/src/prover-client/prover-client.ts +4 -11
  84. package/src/prover-client/server-epoch-prover.ts +1 -1
  85. package/src/proving_broker/broker_prover_facade.ts +4 -14
  86. package/src/proving_broker/config.ts +1 -1
  87. package/src/proving_broker/fixtures.ts +1 -1
  88. package/src/proving_broker/proving_agent.ts +1 -17
  89. package/src/proving_broker/proving_broker.ts +4 -8
  90. package/src/proving_broker/proving_broker_database/persisted.ts +15 -1
  91. package/src/proving_broker/proving_broker_instrumentation.ts +10 -35
  92. package/src/proving_broker/proving_job_controller.ts +2 -3
  93. package/src/test/mock_prover.ts +2 -14
  94. package/dest/block-factory/index.d.ts +0 -2
  95. package/dest/block-factory/index.d.ts.map +0 -1
  96. package/dest/block-factory/index.js +0 -1
  97. package/dest/block-factory/light.d.ts +0 -38
  98. package/dest/block-factory/light.d.ts.map +0 -1
  99. package/dest/block-factory/light.js +0 -108
  100. package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
  101. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
  102. package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
  103. package/src/block-factory/index.ts +0 -1
  104. package/src/block-factory/light.ts +0 -137
  105. package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
@@ -1,20 +1,386 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ function applyDecs2203RFactory() {
2
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3
+ return function addInitializer(initializer) {
4
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
5
+ assertCallable(initializer, "An initializer");
6
+ initializers.push(initializer);
7
+ };
8
+ }
9
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
10
+ var kindStr;
11
+ switch(kind){
12
+ case 1:
13
+ kindStr = "accessor";
14
+ break;
15
+ case 2:
16
+ kindStr = "method";
17
+ break;
18
+ case 3:
19
+ kindStr = "getter";
20
+ break;
21
+ case 4:
22
+ kindStr = "setter";
23
+ break;
24
+ default:
25
+ kindStr = "field";
26
+ }
27
+ var ctx = {
28
+ kind: kindStr,
29
+ name: isPrivate ? "#" + name : name,
30
+ static: isStatic,
31
+ private: isPrivate,
32
+ metadata: metadata
33
+ };
34
+ var decoratorFinishedRef = {
35
+ v: false
36
+ };
37
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
38
+ var get, set;
39
+ if (kind === 0) {
40
+ if (isPrivate) {
41
+ get = desc.get;
42
+ set = desc.set;
43
+ } else {
44
+ get = function() {
45
+ return this[name];
46
+ };
47
+ set = function(v) {
48
+ this[name] = v;
49
+ };
50
+ }
51
+ } else if (kind === 2) {
52
+ get = function() {
53
+ return desc.value;
54
+ };
55
+ } else {
56
+ if (kind === 1 || kind === 3) {
57
+ get = function() {
58
+ return desc.get.call(this);
59
+ };
60
+ }
61
+ if (kind === 1 || kind === 4) {
62
+ set = function(v) {
63
+ desc.set.call(this, v);
64
+ };
65
+ }
66
+ }
67
+ ctx.access = get && set ? {
68
+ get: get,
69
+ set: set
70
+ } : get ? {
71
+ get: get
72
+ } : {
73
+ set: set
74
+ };
75
+ try {
76
+ return dec(value, ctx);
77
+ } finally{
78
+ decoratorFinishedRef.v = true;
79
+ }
80
+ }
81
+ function assertNotFinished(decoratorFinishedRef, fnName) {
82
+ if (decoratorFinishedRef.v) {
83
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
84
+ }
85
+ }
86
+ function assertCallable(fn, hint) {
87
+ if (typeof fn !== "function") {
88
+ throw new TypeError(hint + " must be a function");
89
+ }
90
+ }
91
+ function assertValidReturnValue(kind, value) {
92
+ var type = typeof value;
93
+ if (kind === 1) {
94
+ if (type !== "object" || value === null) {
95
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
96
+ }
97
+ if (value.get !== undefined) {
98
+ assertCallable(value.get, "accessor.get");
99
+ }
100
+ if (value.set !== undefined) {
101
+ assertCallable(value.set, "accessor.set");
102
+ }
103
+ if (value.init !== undefined) {
104
+ assertCallable(value.init, "accessor.init");
105
+ }
106
+ } else if (type !== "function") {
107
+ var hint;
108
+ if (kind === 0) {
109
+ hint = "field";
110
+ } else if (kind === 10) {
111
+ hint = "class";
112
+ } else {
113
+ hint = "method";
114
+ }
115
+ throw new TypeError(hint + " decorators must return a function or void 0");
116
+ }
117
+ }
118
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
119
+ var decs = decInfo[0];
120
+ var desc, init, value;
121
+ if (isPrivate) {
122
+ if (kind === 0 || kind === 1) {
123
+ desc = {
124
+ get: decInfo[3],
125
+ set: decInfo[4]
126
+ };
127
+ } else if (kind === 3) {
128
+ desc = {
129
+ get: decInfo[3]
130
+ };
131
+ } else if (kind === 4) {
132
+ desc = {
133
+ set: decInfo[3]
134
+ };
135
+ } else {
136
+ desc = {
137
+ value: decInfo[3]
138
+ };
139
+ }
140
+ } else if (kind !== 0) {
141
+ desc = Object.getOwnPropertyDescriptor(base, name);
142
+ }
143
+ if (kind === 1) {
144
+ value = {
145
+ get: desc.get,
146
+ set: desc.set
147
+ };
148
+ } else if (kind === 2) {
149
+ value = desc.value;
150
+ } else if (kind === 3) {
151
+ value = desc.get;
152
+ } else if (kind === 4) {
153
+ value = desc.set;
154
+ }
155
+ var newValue, get, set;
156
+ if (typeof decs === "function") {
157
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
158
+ if (newValue !== void 0) {
159
+ assertValidReturnValue(kind, newValue);
160
+ if (kind === 0) {
161
+ init = newValue;
162
+ } else if (kind === 1) {
163
+ init = newValue.init;
164
+ get = newValue.get || value.get;
165
+ set = newValue.set || value.set;
166
+ value = {
167
+ get: get,
168
+ set: set
169
+ };
170
+ } else {
171
+ value = newValue;
172
+ }
173
+ }
174
+ } else {
175
+ for(var i = decs.length - 1; i >= 0; i--){
176
+ var dec = decs[i];
177
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
178
+ if (newValue !== void 0) {
179
+ assertValidReturnValue(kind, newValue);
180
+ var newInit;
181
+ if (kind === 0) {
182
+ newInit = newValue;
183
+ } else if (kind === 1) {
184
+ newInit = newValue.init;
185
+ get = newValue.get || value.get;
186
+ set = newValue.set || value.set;
187
+ value = {
188
+ get: get,
189
+ set: set
190
+ };
191
+ } else {
192
+ value = newValue;
193
+ }
194
+ if (newInit !== void 0) {
195
+ if (init === void 0) {
196
+ init = newInit;
197
+ } else if (typeof init === "function") {
198
+ init = [
199
+ init,
200
+ newInit
201
+ ];
202
+ } else {
203
+ init.push(newInit);
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (kind === 0 || kind === 1) {
210
+ if (init === void 0) {
211
+ init = function(instance, init) {
212
+ return init;
213
+ };
214
+ } else if (typeof init !== "function") {
215
+ var ownInitializers = init;
216
+ init = function(instance, init) {
217
+ var value = init;
218
+ for(var i = 0; i < ownInitializers.length; i++){
219
+ value = ownInitializers[i].call(instance, value);
220
+ }
221
+ return value;
222
+ };
223
+ } else {
224
+ var originalInitializer = init;
225
+ init = function(instance, init) {
226
+ return originalInitializer.call(instance, init);
227
+ };
228
+ }
229
+ ret.push(init);
230
+ }
231
+ if (kind !== 0) {
232
+ if (kind === 1) {
233
+ desc.get = value.get;
234
+ desc.set = value.set;
235
+ } else if (kind === 2) {
236
+ desc.value = value;
237
+ } else if (kind === 3) {
238
+ desc.get = value;
239
+ } else if (kind === 4) {
240
+ desc.set = value;
241
+ }
242
+ if (isPrivate) {
243
+ if (kind === 1) {
244
+ ret.push(function(instance, args) {
245
+ return value.get.call(instance, args);
246
+ });
247
+ ret.push(function(instance, args) {
248
+ return value.set.call(instance, args);
249
+ });
250
+ } else if (kind === 2) {
251
+ ret.push(value);
252
+ } else {
253
+ ret.push(function(instance, args) {
254
+ return value.call(instance, args);
255
+ });
256
+ }
257
+ } else {
258
+ Object.defineProperty(base, name, desc);
259
+ }
260
+ }
261
+ }
262
+ function applyMemberDecs(Class, decInfos, metadata) {
263
+ var ret = [];
264
+ var protoInitializers;
265
+ var staticInitializers;
266
+ var existingProtoNonFields = new Map();
267
+ var existingStaticNonFields = new Map();
268
+ for(var i = 0; i < decInfos.length; i++){
269
+ var decInfo = decInfos[i];
270
+ if (!Array.isArray(decInfo)) continue;
271
+ var kind = decInfo[1];
272
+ var name = decInfo[2];
273
+ var isPrivate = decInfo.length > 3;
274
+ var isStatic = kind >= 5;
275
+ var base;
276
+ var initializers;
277
+ if (isStatic) {
278
+ base = Class;
279
+ kind = kind - 5;
280
+ staticInitializers = staticInitializers || [];
281
+ initializers = staticInitializers;
282
+ } else {
283
+ base = Class.prototype;
284
+ protoInitializers = protoInitializers || [];
285
+ initializers = protoInitializers;
286
+ }
287
+ if (kind !== 0 && !isPrivate) {
288
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
289
+ var existingKind = existingNonFields.get(name) || 0;
290
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
291
+ throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
292
+ } else if (!existingKind && kind > 2) {
293
+ existingNonFields.set(name, kind);
294
+ } else {
295
+ existingNonFields.set(name, true);
296
+ }
297
+ }
298
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
299
+ }
300
+ pushInitializers(ret, protoInitializers);
301
+ pushInitializers(ret, staticInitializers);
302
+ return ret;
303
+ }
304
+ function pushInitializers(ret, initializers) {
305
+ if (initializers) {
306
+ ret.push(function(instance) {
307
+ for(var i = 0; i < initializers.length; i++){
308
+ initializers[i].call(instance);
309
+ }
310
+ return instance;
311
+ });
312
+ }
313
+ }
314
+ function applyClassDecs(targetClass, classDecs, metadata) {
315
+ if (classDecs.length > 0) {
316
+ var initializers = [];
317
+ var newClass = targetClass;
318
+ var name = targetClass.name;
319
+ for(var i = classDecs.length - 1; i >= 0; i--){
320
+ var decoratorFinishedRef = {
321
+ v: false
322
+ };
323
+ try {
324
+ var nextNewClass = classDecs[i](newClass, {
325
+ kind: "class",
326
+ name: name,
327
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
328
+ metadata
329
+ });
330
+ } finally{
331
+ decoratorFinishedRef.v = true;
332
+ }
333
+ if (nextNewClass !== undefined) {
334
+ assertValidReturnValue(10, nextNewClass);
335
+ newClass = nextNewClass;
336
+ }
337
+ }
338
+ return [
339
+ defineMetadata(newClass, metadata),
340
+ function() {
341
+ for(var i = 0; i < initializers.length; i++){
342
+ initializers[i].call(newClass);
343
+ }
344
+ }
345
+ ];
346
+ }
347
+ }
348
+ function defineMetadata(Class, metadata) {
349
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
350
+ configurable: true,
351
+ enumerable: true,
352
+ value: metadata
353
+ });
354
+ }
355
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
356
+ if (parentClass !== void 0) {
357
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
358
+ }
359
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
360
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
361
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
362
+ return {
363
+ e: e,
364
+ get c () {
365
+ return applyClassDecs(targetClass, classDecs, metadata);
366
+ }
367
+ };
368
+ };
6
369
  }
370
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
+ }
373
+ var _dec, _dec1, _dec2, _dec3, _dec4, _initProto;
7
374
  import { L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
8
375
  import { BlockNumber } from '@aztec/foundation/branded-types';
9
376
  import { padArrayEnd } from '@aztec/foundation/collection';
377
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
378
  import { AbortError } from '@aztec/foundation/error';
11
- import { Fr } from '@aztec/foundation/fields';
12
379
  import { createLogger } from '@aztec/foundation/log';
13
380
  import { promiseWithResolvers } from '@aztec/foundation/promise';
14
381
  import { assertLength } from '@aztec/foundation/serialize';
15
382
  import { pushTestData } from '@aztec/foundation/testing';
16
383
  import { elapsed } from '@aztec/foundation/timer';
17
- import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
18
384
  import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
19
385
  import { MerkleTreeId } from '@aztec/stdlib/trees';
20
386
  import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
@@ -24,6 +390,15 @@ import { EpochProvingState } from './epoch-proving-state.js';
24
390
  import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
25
391
  import { TxProvingState } from './tx-proving-state.js';
26
392
  const logger = createLogger('prover-client:orchestrator');
393
+ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
394
+ [Attributes.BLOCK_NUMBER]: blockNumber
395
+ })), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
396
+ [Attributes.BLOCK_TXS_COUNT]: txs.length
397
+ })), _dec2 = trackSpan('ProvingOrchestrator.startChonkVerifierCircuits'), _dec3 = trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
398
+ [Attributes.BLOCK_NUMBER]: blockNumber
399
+ })), _dec4 = trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
400
+ [Attributes.TX_HASH]: tx.hash.toString()
401
+ }));
27
402
  /**
28
403
  * Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
29
404
  * 1. Transactions are provided to the scheduler post simulation.
@@ -39,6 +414,35 @@ const logger = createLogger('prover-client:orchestrator');
39
414
  dbProvider;
40
415
  prover;
41
416
  proverId;
417
+ static{
418
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
419
+ [
420
+ _dec,
421
+ 2,
422
+ "startNewBlock"
423
+ ],
424
+ [
425
+ _dec1,
426
+ 2,
427
+ "addTxs"
428
+ ],
429
+ [
430
+ _dec2,
431
+ 2,
432
+ "startChonkVerifierCircuits"
433
+ ],
434
+ [
435
+ _dec3,
436
+ 2,
437
+ "setBlockCompleted"
438
+ ],
439
+ [
440
+ _dec4,
441
+ 2,
442
+ "prepareBaseRollupInputs"
443
+ ]
444
+ ], []));
445
+ }
42
446
  provingState;
43
447
  pendingProvingJobs;
44
448
  provingPromise;
@@ -49,7 +453,7 @@ const logger = createLogger('prover-client:orchestrator');
49
453
  this.dbProvider = dbProvider;
50
454
  this.prover = prover;
51
455
  this.proverId = proverId;
52
- this.provingState = undefined;
456
+ this.provingState = (_initProto(this), undefined);
53
457
  this.pendingProvingJobs = [];
54
458
  this.provingPromise = undefined;
55
459
  this.dbs = new Map();
@@ -61,6 +465,9 @@ const logger = createLogger('prover-client:orchestrator');
61
465
  getProverId() {
62
466
  return this.proverId;
63
467
  }
468
+ getNumActiveForks() {
469
+ return this.dbs.size;
470
+ }
64
471
  stop() {
65
472
  this.cancel();
66
473
  return Promise.resolve();
@@ -78,7 +485,14 @@ const logger = createLogger('prover-client:orchestrator');
78
485
  this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
79
486
  this.provingPromise = promise;
80
487
  }
81
- async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
488
+ /**
489
+ * Starts a new checkpoint.
490
+ * @param checkpointIndex - The index of the checkpoint in the epoch.
491
+ * @param constants - The constants for this checkpoint.
492
+ * @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
493
+ * @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
494
+ * @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
495
+ */ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
82
496
  if (!this.provingState) {
83
497
  throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
84
498
  }
@@ -141,7 +555,8 @@ const logger = createLogger('prover-client:orchestrator');
141
555
  const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
142
556
  await endSpongeBlob.absorb(blockEndBlobFields);
143
557
  blockProvingState.setEndSpongeBlob(endSpongeBlob);
144
- // And also try to accumulate the blobs as far as we can:
558
+ // Try to accumulate the out hashes and blobs as far as we can:
559
+ await this.provingState.accumulateCheckpointOutHashes();
145
560
  await this.provingState.setBlobAccumulators();
146
561
  }
147
562
  }
@@ -180,7 +595,7 @@ const logger = createLogger('prover-client:orchestrator');
180
595
  throw new Error(`Invalid proving state when adding a tx`);
181
596
  }
182
597
  validateTx(tx);
183
- logger.info(`Received transaction: ${tx.hash}`);
598
+ logger.debug(`Received transaction: ${tx.hash}`);
184
599
  const startSpongeBlob = spongeBlobState.clone();
185
600
  const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
186
601
  if (!provingState.verifyState()) {
@@ -208,7 +623,8 @@ const logger = createLogger('prover-client:orchestrator');
208
623
  const blockEndBlobFields = provingState.getBlockEndBlobFields();
209
624
  await spongeBlobState.absorb(blockEndBlobFields);
210
625
  provingState.setEndSpongeBlob(spongeBlobState);
211
- // Txs have been added to the block. Now try to accumulate the blobs as far as we can:
626
+ // Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
627
+ await this.provingState.accumulateCheckpointOutHashes();
212
628
  await this.provingState.setBlobAccumulators();
213
629
  }
214
630
  /**
@@ -304,8 +720,7 @@ const logger = createLogger('prover-client:orchestrator');
304
720
  // is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
305
721
  // but have to make sure it only runs once all operations are completed, otherwise some function here
306
722
  // will attempt to access the fork after it was closed.
307
- logger.debug(`Cleaning up world state fork for ${blockNumber}`);
308
- void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
723
+ void this.cleanupDBFork(blockNumber);
309
724
  }
310
725
  /**
311
726
  * Cancel any further proving
@@ -333,6 +748,19 @@ const logger = createLogger('prover-client:orchestrator');
333
748
  });
334
749
  return epochProofResult;
335
750
  }
751
+ async cleanupDBFork(blockNumber) {
752
+ logger.debug(`Cleaning up world state fork for ${blockNumber}`);
753
+ const fork = this.dbs.get(blockNumber);
754
+ if (!fork) {
755
+ return;
756
+ }
757
+ try {
758
+ await fork.close();
759
+ this.dbs.delete(blockNumber);
760
+ } catch (err) {
761
+ logger.error(`Error closing db for block ${blockNumber}`, err);
762
+ }
763
+ }
336
764
  /**
337
765
  * Enqueue a job to be scheduled
338
766
  * @param provingState - The proving state object being operated on
@@ -541,16 +969,18 @@ const logger = createLogger('prover-client:orchestrator');
541
969
  return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
542
970
  }
543
971
  }), async (result)=>{
544
- // If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
545
- await this.verifyBuiltBlockAgainstSyncedState(provingState);
546
972
  logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
547
973
  const leafLocation = provingState.setBlockRootRollupProof(result);
548
974
  const checkpointProvingState = provingState.parentCheckpoint;
975
+ // If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
976
+ await this.verifyBuiltBlockAgainstSyncedState(provingState);
549
977
  if (checkpointProvingState.totalNumBlocks === 1) {
550
978
  this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
551
979
  } else {
552
980
  this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
553
981
  }
982
+ // We are finished with the block at this point, ensure the fork is cleaned up
983
+ void this.cleanupDBFork(provingState.blockNumber);
554
984
  });
555
985
  }
556
986
  // Executes the base parity circuit and stores the intermediate state for the root parity circuit
@@ -773,37 +1203,15 @@ const logger = createLogger('prover-client:orchestrator');
773
1203
  return;
774
1204
  }
775
1205
  const txProvingState = provingState.getTxProvingState(txIndex);
776
- // This function tries to do AVM proving. If there is a failure, it fakes the proof unless AVM_PROVING_STRICT is defined.
777
- // Nothing downstream depends on the AVM proof yet. So having this mode lets us incrementally build the AVM circuit.
778
1206
  const doAvmProving = wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getAvmProof', {
779
1207
  [Attributes.TX_HASH]: txProvingState.processedTx.hash.toString()
780
1208
  }, async (signal)=>{
781
1209
  const inputs = txProvingState.getAvmInputs();
782
- try {
783
- // TODO(#14234)[Unconditional PIs validation]: Remove the whole try-catch logic and
784
- // just keep the next line but removing the second argument (false).
785
- return await this.prover.getAvmProof(inputs, false, signal, provingState.epochNumber);
786
- } catch (err) {
787
- if (process.env.AVM_PROVING_STRICT) {
788
- logger.error(`Error thrown when proving AVM circuit with AVM_PROVING_STRICT on`, err);
789
- throw err;
790
- } else {
791
- logger.warn(`Error thrown when proving AVM circuit but AVM_PROVING_STRICT is off. Use snapshotted
792
- AVM inputs and carrying on. ${inspect(err)}.`);
793
- try {
794
- this.metrics.incAvmFallback();
795
- const snapshotAvmPrivateInputs = readAvmMinimalPublicTxInputsFromFile();
796
- return await this.prover.getAvmProof(snapshotAvmPrivateInputs, true, signal, provingState.epochNumber);
797
- } catch (err) {
798
- logger.error(`Error thrown when proving snapshotted AVM inputs.`, err);
799
- throw err;
800
- }
801
- }
802
- }
1210
+ return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
803
1211
  });
804
- this.deferredProving(provingState, doAvmProving, (proofAndVk)=>{
1212
+ this.deferredProving(provingState, doAvmProving, (proof)=>{
805
1213
  logger.debug(`Proven VM for tx index: ${txIndex}`);
806
- txProvingState.setAvmProof(proofAndVk);
1214
+ txProvingState.setAvmProof(proof);
807
1215
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
808
1216
  });
809
1217
  }
@@ -817,26 +1225,3 @@ const logger = createLogger('prover-client:orchestrator');
817
1225
  this.enqueueBaseRollup(provingState, txIndex);
818
1226
  }
819
1227
  }
820
- _ts_decorate([
821
- trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
822
- [Attributes.BLOCK_NUMBER]: blockNumber
823
- }))
824
- ], ProvingOrchestrator.prototype, "startNewBlock", null);
825
- _ts_decorate([
826
- trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
827
- [Attributes.BLOCK_TXS_COUNT]: txs.length
828
- }))
829
- ], ProvingOrchestrator.prototype, "addTxs", null);
830
- _ts_decorate([
831
- trackSpan('ProvingOrchestrator.startChonkVerifierCircuits')
832
- ], ProvingOrchestrator.prototype, "startChonkVerifierCircuits", null);
833
- _ts_decorate([
834
- trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
835
- [Attributes.BLOCK_NUMBER]: blockNumber
836
- }))
837
- ], ProvingOrchestrator.prototype, "setBlockCompleted", null);
838
- _ts_decorate([
839
- trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
840
- [Attributes.TX_HASH]: tx.hash.toString()
841
- }))
842
- ], ProvingOrchestrator.prototype, "prepareBaseRollupInputs", null);
@@ -2,9 +2,7 @@ import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
2
2
  export declare class ProvingOrchestratorMetrics {
3
3
  readonly tracer: Tracer;
4
4
  private baseRollupInputsDuration;
5
- private avmFallbackCount;
6
5
  constructor(client: TelemetryClient, name?: string);
7
6
  recordBaseRollupInputs(durationMs: number): void;
8
- incAvmFallback(): void;
9
7
  }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JjaGVzdHJhdG9yX21ldHJpY3MuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9vcmNoZXN0cmF0b3Ivb3JjaGVzdHJhdG9yX21ldHJpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUdMLEtBQUssZUFBZSxFQUNwQixLQUFLLE1BQU0sRUFHWixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLHFCQUFhLDBCQUEwQjtJQUNyQyxTQUFnQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBRS9CLE9BQU8sQ0FBQyx3QkFBd0IsQ0FBWTtJQUM1QyxPQUFPLENBQUMsZ0JBQWdCLENBQWdCO0lBRXhDLFlBQVksTUFBTSxFQUFFLGVBQWUsRUFBRSxJQUFJLFNBQXdCLEVBZ0JoRTtJQUVELHNCQUFzQixDQUFDLFVBQVUsRUFBRSxNQUFNLFFBRXhDO0lBRUQsY0FBYyxTQUViO0NBQ0YifQ==
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JjaGVzdHJhdG9yX21ldHJpY3MuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9vcmNoZXN0cmF0b3Ivb3JjaGVzdHJhdG9yX21ldHJpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUEyQixLQUFLLGVBQWUsRUFBRSxLQUFLLE1BQU0sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRXJHLHFCQUFhLDBCQUEwQjtJQUNyQyxTQUFnQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBRS9CLE9BQU8sQ0FBQyx3QkFBd0IsQ0FBWTtJQUU1QyxZQUFZLE1BQU0sRUFBRSxlQUFlLEVBQUUsSUFBSSxTQUF3QixFQUtoRTtJQUVELHNCQUFzQixDQUFDLFVBQVUsRUFBRSxNQUFNLFFBRXhDO0NBQ0YifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator_metrics.d.ts","sourceRoot":"","sources":["../../src/orchestrator/orchestrator_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,0BAA0B;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,wBAAwB,CAAY;IAC5C,OAAO,CAAC,gBAAgB,CAAgB;IAExC,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,SAAwB,EAgBhE;IAED,sBAAsB,CAAC,UAAU,EAAE,MAAM,QAExC;IAED,cAAc,SAEb;CACF"}
1
+ {"version":3,"file":"orchestrator_metrics.d.ts","sourceRoot":"","sources":["../../src/orchestrator/orchestrator_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,eAAe,EAAE,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAErG,qBAAa,0BAA0B;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,wBAAwB,CAAY;IAE5C,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,SAAwB,EAKhE;IAED,sBAAsB,CAAC,UAAU,EAAE,MAAM,QAExC;CACF"}
@@ -1,26 +1,13 @@
1
- import { Metrics, ValueType } from '@aztec/telemetry-client';
1
+ import { Metrics } from '@aztec/telemetry-client';
2
2
  export class ProvingOrchestratorMetrics {
3
3
  tracer;
4
4
  baseRollupInputsDuration;
5
- avmFallbackCount;
6
5
  constructor(client, name = 'ProvingOrchestrator'){
7
6
  this.tracer = client.getTracer(name);
8
7
  const meter = client.getMeter(name);
9
- this.baseRollupInputsDuration = meter.createHistogram(Metrics.PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION, {
10
- unit: 'ms',
11
- description: 'Duration to build base rollup inputs',
12
- valueType: ValueType.INT
13
- });
14
- this.avmFallbackCount = meter.createUpDownCounter(Metrics.PROVING_ORCHESTRATOR_AVM_FALLBACK_COUNT, {
15
- description: 'How many times the AVM fallback was used',
16
- valueType: ValueType.INT
17
- });
18
- this.avmFallbackCount.add(0);
8
+ this.baseRollupInputsDuration = meter.createHistogram(Metrics.PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION);
19
9
  }
20
10
  recordBaseRollupInputs(durationMs) {
21
11
  this.baseRollupInputsDuration.record(Math.ceil(durationMs));
22
12
  }
23
- incAvmFallback() {
24
- this.avmFallbackCount.add(1);
25
- }
26
13
  }