@aztec/prover-client 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891

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 (144) 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/index.d.ts +1 -1
  5. package/dest/light/index.d.ts +2 -0
  6. package/dest/light/index.d.ts.map +1 -0
  7. package/dest/light/index.js +1 -0
  8. package/dest/light/lightweight_checkpoint_builder.d.ts +52 -0
  9. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
  10. package/dest/light/lightweight_checkpoint_builder.js +223 -0
  11. package/dest/mocks/fixtures.d.ts +1 -4
  12. package/dest/mocks/fixtures.d.ts.map +1 -1
  13. package/dest/mocks/fixtures.js +9 -18
  14. package/dest/mocks/test_context.d.ts +29 -46
  15. package/dest/mocks/test_context.d.ts.map +1 -1
  16. package/dest/mocks/test_context.js +120 -117
  17. package/dest/orchestrator/block-building-helpers.d.ts +18 -20
  18. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  19. package/dest/orchestrator/block-building-helpers.js +90 -115
  20. package/dest/orchestrator/block-proving-state.d.ts +20 -11
  21. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  22. package/dest/orchestrator/block-proving-state.js +87 -19
  23. package/dest/orchestrator/checkpoint-proving-state.d.ts +22 -9
  24. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
  25. package/dest/orchestrator/checkpoint-proving-state.js +52 -20
  26. package/dest/orchestrator/epoch-proving-state.d.ts +12 -10
  27. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  28. package/dest/orchestrator/epoch-proving-state.js +40 -4
  29. package/dest/orchestrator/index.d.ts +1 -1
  30. package/dest/orchestrator/orchestrator.d.ts +28 -11
  31. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  32. package/dest/orchestrator/orchestrator.js +582 -180
  33. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  34. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  35. package/dest/orchestrator/orchestrator_metrics.js +2 -15
  36. package/dest/orchestrator/tx-proving-state.d.ts +6 -5
  37. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  38. package/dest/orchestrator/tx-proving-state.js +7 -16
  39. package/dest/prover-client/factory.d.ts +3 -3
  40. package/dest/prover-client/factory.d.ts.map +1 -1
  41. package/dest/prover-client/index.d.ts +1 -1
  42. package/dest/prover-client/prover-client.d.ts +6 -6
  43. package/dest/prover-client/prover-client.d.ts.map +1 -1
  44. package/dest/prover-client/prover-client.js +15 -10
  45. package/dest/prover-client/server-epoch-prover.d.ts +8 -7
  46. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  47. package/dest/prover-client/server-epoch-prover.js +2 -2
  48. package/dest/proving_broker/broker_prover_facade.d.ts +25 -23
  49. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  50. package/dest/proving_broker/broker_prover_facade.js +11 -17
  51. package/dest/proving_broker/config.d.ts +25 -9
  52. package/dest/proving_broker/config.d.ts.map +1 -1
  53. package/dest/proving_broker/config.js +27 -4
  54. package/dest/proving_broker/factory.d.ts +1 -1
  55. package/dest/proving_broker/fixtures.d.ts +3 -2
  56. package/dest/proving_broker/fixtures.d.ts.map +1 -1
  57. package/dest/proving_broker/fixtures.js +3 -2
  58. package/dest/proving_broker/index.d.ts +1 -1
  59. package/dest/proving_broker/proof_store/factory.d.ts +2 -5
  60. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  61. package/dest/proving_broker/proof_store/factory.js +7 -30
  62. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
  63. package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
  64. package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
  65. package/dest/proving_broker/proof_store/index.d.ts +2 -2
  66. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  67. package/dest/proving_broker/proof_store/index.js +1 -1
  68. package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
  69. package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
  70. package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
  71. package/dest/proving_broker/proving_agent.d.ts +5 -9
  72. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  73. package/dest/proving_broker/proving_agent.js +4 -19
  74. package/dest/proving_broker/proving_broker.d.ts +7 -4
  75. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  76. package/dest/proving_broker/proving_broker.js +42 -15
  77. package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
  78. package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
  79. package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
  80. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  81. package/dest/proving_broker/proving_broker_database/persisted.js +392 -3
  82. package/dest/proving_broker/proving_broker_database.d.ts +3 -2
  83. package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
  84. package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
  85. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  86. package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
  87. package/dest/proving_broker/proving_job_controller.d.ts +5 -3
  88. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  89. package/dest/proving_broker/proving_job_controller.js +8 -6
  90. package/dest/proving_broker/rpc.d.ts +7 -5
  91. package/dest/proving_broker/rpc.d.ts.map +1 -1
  92. package/dest/proving_broker/rpc.js +8 -0
  93. package/dest/test/mock_proof_store.d.ts +1 -1
  94. package/dest/test/mock_proof_store.d.ts.map +1 -1
  95. package/dest/test/mock_prover.d.ts +5 -6
  96. package/dest/test/mock_prover.d.ts.map +1 -1
  97. package/dest/test/mock_prover.js +4 -4
  98. package/package.json +22 -21
  99. package/src/config.ts +1 -1
  100. package/src/light/index.ts +1 -0
  101. package/src/light/lightweight_checkpoint_builder.ts +312 -0
  102. package/src/mocks/fixtures.ts +9 -31
  103. package/src/mocks/test_context.ts +159 -178
  104. package/src/orchestrator/block-building-helpers.ts +129 -209
  105. package/src/orchestrator/block-proving-state.ts +109 -22
  106. package/src/orchestrator/checkpoint-proving-state.ts +75 -25
  107. package/src/orchestrator/epoch-proving-state.ts +67 -15
  108. package/src/orchestrator/orchestrator.ts +191 -173
  109. package/src/orchestrator/orchestrator_metrics.ts +2 -25
  110. package/src/orchestrator/tx-proving-state.ts +10 -27
  111. package/src/prover-client/factory.ts +6 -2
  112. package/src/prover-client/prover-client.ts +33 -24
  113. package/src/prover-client/server-epoch-prover.ts +6 -7
  114. package/src/proving_broker/broker_prover_facade.ts +38 -39
  115. package/src/proving_broker/config.ts +31 -2
  116. package/src/proving_broker/fixtures.ts +8 -3
  117. package/src/proving_broker/proof_store/factory.ts +10 -32
  118. package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
  119. package/src/proving_broker/proof_store/index.ts +1 -1
  120. package/src/proving_broker/proving_agent.ts +6 -19
  121. package/src/proving_broker/proving_broker.ts +43 -12
  122. package/src/proving_broker/proving_broker_database/memory.ts +2 -1
  123. package/src/proving_broker/proving_broker_database/persisted.ts +20 -5
  124. package/src/proving_broker/proving_broker_database.ts +2 -1
  125. package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
  126. package/src/proving_broker/proving_job_controller.ts +13 -7
  127. package/src/proving_broker/rpc.ts +14 -0
  128. package/src/test/mock_prover.ts +2 -14
  129. package/dest/block-factory/index.d.ts +0 -2
  130. package/dest/block-factory/index.d.ts.map +0 -1
  131. package/dest/block-factory/index.js +0 -1
  132. package/dest/block-factory/light.d.ts +0 -38
  133. package/dest/block-factory/light.d.ts.map +0 -1
  134. package/dest/block-factory/light.js +0 -94
  135. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
  136. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
  137. package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
  138. package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
  139. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
  140. package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
  141. package/src/block-factory/index.ts +0 -1
  142. package/src/block-factory/light.ts +0 -140
  143. package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
  144. package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
@@ -1,29 +1,405 @@
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
+ };
369
+ }
370
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
6
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';
375
+ import { BlockNumber } from '@aztec/foundation/branded-types';
8
376
  import { padArrayEnd } from '@aztec/foundation/collection';
377
+ import { Fr } from '@aztec/foundation/curves/bn254';
9
378
  import { AbortError } from '@aztec/foundation/error';
10
- import { Fr } from '@aztec/foundation/fields';
11
379
  import { createLogger } from '@aztec/foundation/log';
12
380
  import { promiseWithResolvers } from '@aztec/foundation/promise';
381
+ import { SerialQueue } from '@aztec/foundation/queue';
13
382
  import { assertLength } from '@aztec/foundation/serialize';
383
+ import { sleep } from '@aztec/foundation/sleep';
14
384
  import { pushTestData } from '@aztec/foundation/testing';
15
385
  import { elapsed } from '@aztec/foundation/timer';
16
- import { readAvmMinimalPublicTxInputsFromFile } from '@aztec/simulator/public/fixtures';
17
- import { createBlockEndMarker } from '@aztec/stdlib/block';
18
386
  import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, PrivateTxBaseRollupPrivateInputs } from '@aztec/stdlib/rollup';
19
387
  import { MerkleTreeId } from '@aztec/stdlib/trees';
20
388
  import { Attributes, getTelemetryClient, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
21
389
  import { inspect } from 'util';
22
- import { buildBlockHeaderFromTxs, buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifierPrivateInputsFromTx, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
390
+ import { buildHeaderFromCircuitOutputs, getLastSiblingPath, getPublicChonkVerifierPrivateInputsFromTx, getRootTreeSiblingPath, getSubtreeSiblingPath, getTreeSnapshot, insertSideEffectsAndBuildBaseRollupHints, validatePartialState, validateTx } from './block-building-helpers.js';
23
391
  import { EpochProvingState } from './epoch-proving-state.js';
24
392
  import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
25
393
  import { TxProvingState } from './tx-proving-state.js';
26
- const logger = createLogger('prover-client:orchestrator');
394
+ _dec = trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
395
+ [Attributes.BLOCK_NUMBER]: blockNumber
396
+ })), _dec1 = trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
397
+ [Attributes.BLOCK_TXS_COUNT]: txs.length
398
+ })), _dec2 = trackSpan('ProvingOrchestrator.startChonkVerifierCircuits'), _dec3 = trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
399
+ [Attributes.BLOCK_NUMBER]: blockNumber
400
+ })), _dec4 = trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
401
+ [Attributes.TX_HASH]: tx.hash.toString()
402
+ }));
27
403
  /**
28
404
  * Implements an event driven proving scheduler to build the recursive proof tree. The idea being:
29
405
  * 1. Transactions are provided to the scheduler post simulation.
@@ -39,20 +415,59 @@ const logger = createLogger('prover-client:orchestrator');
39
415
  dbProvider;
40
416
  prover;
41
417
  proverId;
418
+ cancelJobsOnStop;
419
+ enqueueConcurrency;
420
+ static{
421
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
422
+ [
423
+ _dec,
424
+ 2,
425
+ "startNewBlock"
426
+ ],
427
+ [
428
+ _dec1,
429
+ 2,
430
+ "addTxs"
431
+ ],
432
+ [
433
+ _dec2,
434
+ 2,
435
+ "startChonkVerifierCircuits"
436
+ ],
437
+ [
438
+ _dec3,
439
+ 2,
440
+ "setBlockCompleted"
441
+ ],
442
+ [
443
+ _dec4,
444
+ 2,
445
+ "prepareBaseRollupInputs"
446
+ ]
447
+ ], []));
448
+ }
42
449
  provingState;
43
450
  pendingProvingJobs;
44
451
  provingPromise;
45
452
  metrics;
453
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
46
454
  dbs;
47
- constructor(dbProvider, prover, proverId, telemetryClient = getTelemetryClient()){
455
+ logger;
456
+ deferredJobQueue;
457
+ constructor(dbProvider, prover, proverId, cancelJobsOnStop = false, enqueueConcurrency, telemetryClient = getTelemetryClient(), bindings){
48
458
  this.dbProvider = dbProvider;
49
459
  this.prover = prover;
50
460
  this.proverId = proverId;
51
- this.provingState = undefined;
461
+ this.cancelJobsOnStop = cancelJobsOnStop;
462
+ this.enqueueConcurrency = enqueueConcurrency;
463
+ this.provingState = (_initProto(this), undefined);
52
464
  this.pendingProvingJobs = [];
53
465
  this.provingPromise = undefined;
54
466
  this.dbs = new Map();
467
+ this.deferredJobQueue = new SerialQueue();
468
+ this.logger = createLogger('prover-client:orchestrator', bindings);
55
469
  this.metrics = new ProvingOrchestratorMetrics(telemetryClient, 'ProvingOrchestrator');
470
+ this.deferredJobQueue.start(this.enqueueConcurrency);
56
471
  }
57
472
  get tracer() {
58
473
  return this.metrics.tracer;
@@ -60,9 +475,14 @@ const logger = createLogger('prover-client:orchestrator');
60
475
  getProverId() {
61
476
  return this.proverId;
62
477
  }
63
- stop() {
478
+ getNumActiveForks() {
479
+ return this.dbs.size;
480
+ }
481
+ async stop() {
482
+ // Grab the old queue before cancel() replaces it, so we can await its draining.
483
+ const oldQueue = this.deferredJobQueue;
64
484
  this.cancel();
65
- return Promise.resolve();
485
+ await oldQueue.cancel();
66
486
  }
67
487
  startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges) {
68
488
  if (this.provingState?.verifyState()) {
@@ -73,11 +493,18 @@ const logger = createLogger('prover-client:orchestrator');
73
493
  status: 'failure',
74
494
  reason
75
495
  }));
76
- logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
496
+ this.logger.info(`Starting epoch ${epochNumber} with ${totalNumCheckpoints} checkpoints.`);
77
497
  this.provingState = new EpochProvingState(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges, (provingState)=>this.checkAndEnqueueCheckpointRootRollup(provingState), resolve, reject);
78
498
  this.provingPromise = promise;
79
499
  }
80
- async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, totalNumBlobFields, headerOfLastBlockInPreviousCheckpoint) {
500
+ /**
501
+ * Starts a new checkpoint.
502
+ * @param checkpointIndex - The index of the checkpoint in the epoch.
503
+ * @param constants - The constants for this checkpoint.
504
+ * @param l1ToL2Messages - The set of L1 to L2 messages to be inserted at the beginning of this checkpoint.
505
+ * @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
506
+ * @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
507
+ */ async startNewCheckpoint(checkpointIndex, constants, l1ToL2Messages, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint) {
81
508
  if (!this.provingState) {
82
509
  throw new Error('Empty epoch proving state. Call startNewEpoch before starting a checkpoint.');
83
510
  }
@@ -87,13 +514,13 @@ const logger = createLogger('prover-client:orchestrator');
87
514
  // Fork world state at the end of the immediately previous block.
88
515
  const lastBlockNumber = headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber;
89
516
  const db = await this.dbProvider.fork(lastBlockNumber);
90
- const firstBlockNumber = lastBlockNumber + 1;
517
+ const firstBlockNumber = BlockNumber(lastBlockNumber + 1);
91
518
  this.dbs.set(firstBlockNumber, db);
92
519
  // Get archive sibling path before any block in this checkpoint lands.
93
520
  const lastArchiveSiblingPath = await getLastSiblingPath(MerkleTreeId.ARCHIVE, db);
94
521
  // Insert all the l1 to l2 messages into the db. And get the states before and after the insertion.
95
522
  const { lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeRootSiblingPath, newL1ToL2MessageTreeSnapshot, newL1ToL2MessageSubtreeRootSiblingPath } = await this.updateL1ToL2MessageTree(l1ToL2Messages, db);
96
- this.provingState.startNewCheckpoint(checkpointIndex, constants, totalNumBlocks, totalNumBlobFields, headerOfLastBlockInPreviousCheckpoint, lastArchiveSiblingPath, l1ToL2Messages, lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeRootSiblingPath, newL1ToL2MessageTreeSnapshot, newL1ToL2MessageSubtreeRootSiblingPath);
523
+ this.provingState.startNewCheckpoint(checkpointIndex, constants, totalNumBlocks, headerOfLastBlockInPreviousCheckpoint, lastArchiveSiblingPath, l1ToL2Messages, lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeRootSiblingPath, newL1ToL2MessageTreeSnapshot, newL1ToL2MessageSubtreeRootSiblingPath);
97
524
  }
98
525
  /**
99
526
  * Starts off a new block
@@ -113,18 +540,18 @@ const logger = createLogger('prover-client:orchestrator');
113
540
  throw new Error(`Checkpoint not accepting further blocks.`);
114
541
  }
115
542
  const constants = checkpointProvingState.constants;
116
- logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber.toNumber()}.`);
543
+ this.logger.info(`Starting block ${blockNumber} for slot ${constants.slotNumber}.`);
117
544
  // Fork the db only when it's not already set. The db for the first block is set in `startNewCheckpoint`.
118
545
  if (!this.dbs.has(blockNumber)) {
119
546
  // Fork world state at the end of the immediately previous block
120
- const db = await this.dbProvider.fork(blockNumber - 1);
547
+ const db = await this.dbProvider.fork(BlockNumber(blockNumber - 1));
121
548
  this.dbs.set(blockNumber, db);
122
549
  }
123
- const db = this.dbs.get(blockNumber);
550
+ const db = this.getDbForBlock(blockNumber);
124
551
  // Get archive snapshot and sibling path before any txs in this block lands.
125
552
  const lastArchiveTreeSnapshot = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
126
553
  const lastArchiveSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.ARCHIVE, db);
127
- const blockProvingState = await checkpointProvingState.startNewBlock(blockNumber, timestamp, totalNumTxs, lastArchiveTreeSnapshot, lastArchiveSiblingPath);
554
+ const blockProvingState = checkpointProvingState.startNewBlock(blockNumber, timestamp, totalNumTxs, lastArchiveTreeSnapshot, lastArchiveSiblingPath);
128
555
  // Enqueue base parity circuits for the first block in the checkpoint.
129
556
  if (blockProvingState.index === 0) {
130
557
  for(let i = 0; i < NUM_BASE_PARITY_PER_ROOT_PARITY; i++){
@@ -134,12 +561,14 @@ const logger = createLogger('prover-client:orchestrator');
134
561
  // Because `addTxs` won't be called for a block without txs, and that's where the sponge blob state is computed.
135
562
  // We need to set its end sponge blob here, which will become the start sponge blob for the next block.
136
563
  if (totalNumTxs === 0) {
564
+ const endState = await db.getStateReference();
565
+ blockProvingState.setEndState(endState);
137
566
  const endSpongeBlob = blockProvingState.getStartSpongeBlob().clone();
138
- await endSpongeBlob.absorb([
139
- createBlockEndMarker(0)
140
- ]);
567
+ const blockEndBlobFields = blockProvingState.getBlockEndBlobFields();
568
+ await endSpongeBlob.absorb(blockEndBlobFields);
141
569
  blockProvingState.setEndSpongeBlob(endSpongeBlob);
142
- // And also try to accumulate the blobs as far as we can:
570
+ // Try to accumulate the out hashes and blobs as far as we can:
571
+ await this.provingState.accumulateCheckpointOutHashes();
143
572
  await this.provingState.setBlobAccumulators();
144
573
  }
145
574
  }
@@ -153,10 +582,10 @@ const logger = createLogger('prover-client:orchestrator');
153
582
  if (!txs.length) {
154
583
  // To avoid an ugly throw below. If we require an empty block, we can just call setBlockCompleted
155
584
  // on a block with no txs. We cannot do that here because we cannot find the blockNumber without any txs.
156
- logger.warn(`Provided no txs to orchestrator addTxs.`);
585
+ this.logger.warn(`Provided no txs to orchestrator addTxs.`);
157
586
  return;
158
587
  }
159
- const blockNumber = txs[0].globalVariables.blockNumber;
588
+ const blockNumber = BlockNumber(txs[0].globalVariables.blockNumber);
160
589
  const provingState = this.provingState.getBlockProvingStateByBlockNumber(blockNumber);
161
590
  if (!provingState) {
162
591
  throw new Error(`Proving state for block ${blockNumber} not found. Call startNewBlock first.`);
@@ -167,8 +596,8 @@ const logger = createLogger('prover-client:orchestrator');
167
596
  if (!provingState.isAcceptingTxs()) {
168
597
  throw new Error(`Block ${blockNumber} has been initialized with transactions.`);
169
598
  }
170
- logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
171
- const db = this.dbs.get(blockNumber);
599
+ this.logger.info(`Adding ${txs.length} transactions to block ${blockNumber}`);
600
+ const db = this.getDbForBlock(blockNumber);
172
601
  const lastArchive = provingState.lastArchiveTreeSnapshot;
173
602
  const newL1ToL2MessageTreeSnapshot = provingState.newL1ToL2MessageTreeSnapshot;
174
603
  const spongeBlobState = provingState.getStartSpongeBlob().clone();
@@ -178,7 +607,7 @@ const logger = createLogger('prover-client:orchestrator');
178
607
  throw new Error(`Invalid proving state when adding a tx`);
179
608
  }
180
609
  validateTx(tx);
181
- logger.info(`Received transaction: ${tx.hash}`);
610
+ this.logger.debug(`Received transaction: ${tx.hash}`);
182
611
  const startSpongeBlob = spongeBlobState.clone();
183
612
  const [hints, treeSnapshots] = await this.prepareBaseRollupInputs(tx, lastArchive, newL1ToL2MessageTreeSnapshot, startSpongeBlob, db);
184
613
  if (!provingState.verifyState()) {
@@ -189,10 +618,10 @@ const logger = createLogger('prover-client:orchestrator');
189
618
  const txIndex = provingState.addNewTx(txProvingState);
190
619
  if (txProvingState.requireAvmProof) {
191
620
  this.getOrEnqueueChonkVerifier(provingState, txIndex);
192
- logger.debug(`Enqueueing public VM for tx ${txIndex}`);
621
+ this.logger.debug(`Enqueueing public VM for tx ${txIndex}`);
193
622
  this.enqueueVM(provingState, txIndex);
194
623
  } else {
195
- logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
624
+ this.logger.debug(`Enqueueing base rollup for private-only tx ${txIndex}`);
196
625
  this.enqueueBaseRollup(provingState, txIndex);
197
626
  }
198
627
  } catch (err) {
@@ -201,11 +630,13 @@ const logger = createLogger('prover-client:orchestrator');
201
630
  });
202
631
  }
203
632
  }
204
- await spongeBlobState.absorb([
205
- createBlockEndMarker(txs.length)
206
- ]);
633
+ const endState = await db.getStateReference();
634
+ provingState.setEndState(endState);
635
+ const blockEndBlobFields = provingState.getBlockEndBlobFields();
636
+ await spongeBlobState.absorb(blockEndBlobFields);
207
637
  provingState.setEndSpongeBlob(spongeBlobState);
208
- // Txs have been added to the block. Now try to accumulate the blobs as far as we can:
638
+ // Txs have been added to the block. Now try to accumulate the out hashes and blobs as far as we can:
639
+ await this.provingState.accumulateCheckpointOutHashes();
209
640
  await this.provingState.setBlobAccumulators();
210
641
  }
211
642
  /**
@@ -220,7 +651,7 @@ const logger = createLogger('prover-client:orchestrator');
220
651
  const txHash = tx.getTxHash().toString();
221
652
  const privateInputs = getPublicChonkVerifierPrivateInputsFromTx(tx, this.proverId.toField());
222
653
  const tubeProof = promiseWithResolvers();
223
- logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
654
+ this.logger.debug(`Starting chonk verifier circuit for tx ${txHash}`);
224
655
  this.doEnqueueChonkVerifier(txHash, privateInputs, (proof)=>{
225
656
  tubeProof.resolve(proof);
226
657
  });
@@ -248,78 +679,90 @@ const logger = createLogger('prover-client:orchestrator');
248
679
  if (provingState.isAcceptingTxs()) {
249
680
  throw new Error(`Block ${blockNumber} is still accepting txs. Call setBlockCompleted after all txs have been added.`);
250
681
  }
251
- // And build the block header
252
- logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
253
- const header = await this.buildL2BlockHeader(provingState, expectedHeader);
254
- await this.verifyBuiltBlockAgainstSyncedState(provingState);
255
- return header;
256
- }
257
- async buildL2BlockHeader(provingState, expectedHeader) {
258
- // Collect all txs in this block to build the header. The function calling this has made sure that all txs have been added.
259
- const txs = provingState.getProcessedTxs();
260
- const startSpongeBlob = provingState.getStartSpongeBlob();
261
- // Get db for this block
262
- const db = this.dbs.get(provingState.blockNumber);
263
- // Given we've applied every change from this block, now assemble the block header
264
- // and update the archive tree, so we're ready to start processing the next block
265
- const header = await buildBlockHeaderFromTxs(txs, provingState.getGlobalVariables(), startSpongeBlob, db);
682
+ // Given we've applied every change from this block, now assemble the block header:
683
+ this.logger.verbose(`Block ${blockNumber} completed. Assembling header.`);
684
+ const header = await provingState.buildBlockHeader();
266
685
  if (expectedHeader && !header.equals(expectedHeader)) {
267
- logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
686
+ this.logger.error(`Block header mismatch: header=${header} expectedHeader=${expectedHeader}`);
268
687
  throw new Error('Block header mismatch');
269
688
  }
270
- logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
271
- await db.updateArchive(header);
272
- provingState.setBuiltBlockHeader(header);
689
+ // Get db for this block and remove from map — no other code should use it after this point.
690
+ const db = this.getDbForBlock(provingState.blockNumber);
691
+ this.dbs.delete(provingState.blockNumber);
692
+ // Update the archive tree, capture the snapshot, and close the fork deterministically.
693
+ try {
694
+ this.logger.verbose(`Updating archive tree with block ${provingState.blockNumber} header ${(await header.hash()).toString()}`);
695
+ await db.updateArchive(header);
696
+ provingState.setBuiltArchive(await getTreeSnapshot(MerkleTreeId.ARCHIVE, db));
697
+ } finally{
698
+ await db.close();
699
+ }
700
+ await this.verifyBuiltBlockAgainstSyncedState(provingState);
273
701
  return header;
274
702
  }
275
703
  // Flagged as protected to disable in certain unit tests
276
704
  async verifyBuiltBlockAgainstSyncedState(provingState) {
277
705
  const builtBlockHeader = provingState.getBuiltBlockHeader();
278
706
  if (!builtBlockHeader) {
279
- logger.debug('Block header not built yet, skipping header check.');
707
+ this.logger.debug('Block header not built yet, skipping header check.');
280
708
  return;
281
709
  }
282
710
  const output = provingState.getBlockRootRollupOutput();
283
711
  if (!output) {
284
- logger.debug('Block root rollup proof not built yet, skipping header check.');
712
+ this.logger.debug('Block root rollup proof not built yet, skipping header check.');
713
+ return;
714
+ }
715
+ const newArchive = provingState.getBuiltArchive();
716
+ if (!newArchive) {
717
+ this.logger.debug('Archive snapshot not yet captured, skipping header check.');
285
718
  return;
286
719
  }
287
720
  const header = await buildHeaderFromCircuitOutputs(output);
288
721
  if (!(await header.hash()).equals(await builtBlockHeader.hash())) {
289
- logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
722
+ this.logger.error(`Block header mismatch.\nCircuit: ${inspect(header)}\nComputed: ${inspect(builtBlockHeader)}`);
290
723
  provingState.reject(`Block header hash mismatch.`);
291
724
  return;
292
725
  }
293
- // Get db for this block
294
726
  const blockNumber = provingState.blockNumber;
295
- const db = this.dbs.get(blockNumber);
296
- const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, db);
297
727
  const syncedArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.dbProvider.getSnapshot(blockNumber));
298
728
  if (!syncedArchive.equals(newArchive)) {
299
- logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
729
+ this.logger.error(`Archive tree mismatch for block ${blockNumber}: world state synced to ${inspect(syncedArchive)} but built ${inspect(newArchive)}`);
300
730
  provingState.reject(`Archive tree mismatch.`);
301
731
  return;
302
732
  }
303
733
  const circuitArchive = output.newArchive;
304
734
  if (!newArchive.equals(circuitArchive)) {
305
- logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
735
+ this.logger.error(`New archive mismatch.\nCircuit: ${output.newArchive}\nComputed: ${newArchive}`);
306
736
  provingState.reject(`New archive mismatch.`);
307
737
  return;
308
738
  }
309
- // TODO(palla/prover): This closes the fork only on the happy path. If this epoch orchestrator
310
- // is aborted and never reaches this point, it will leak the fork. We need to add a global cleanup,
311
- // but have to make sure it only runs once all operations are completed, otherwise some function here
312
- // will attempt to access the fork after it was closed.
313
- logger.debug(`Cleaning up world state fork for ${blockNumber}`);
314
- void this.dbs.get(blockNumber)?.close().then(()=>this.dbs.delete(blockNumber)).catch((err)=>logger.error(`Error closing db for block ${blockNumber}`, err));
315
739
  }
316
740
  /**
317
- * Cancel any further proving
741
+ * Cancel any further proving.
742
+ * If cancelJobsOnStop is true, aborts all pending jobs with the broker (which marks them as 'Aborted').
743
+ * If cancelJobsOnStop is false (default), jobs remain in the broker queue and can be reused on restart/reorg.
318
744
  */ cancel() {
319
- for (const controller of this.pendingProvingJobs){
320
- controller.abort();
745
+ void this.deferredJobQueue.cancel();
746
+ // Recreate the queue so it can accept jobs for subsequent epochs.
747
+ this.deferredJobQueue = new SerialQueue();
748
+ this.deferredJobQueue.start(this.enqueueConcurrency);
749
+ if (this.cancelJobsOnStop) {
750
+ for (const controller of this.pendingProvingJobs){
751
+ controller.abort();
752
+ }
321
753
  }
322
754
  this.provingState?.cancel();
755
+ for (const [blockNumber, db] of this.dbs.entries()){
756
+ void db.close().catch((err)=>this.logger.error(`Error closing db for block ${blockNumber}`, err));
757
+ }
758
+ this.dbs.clear();
759
+ }
760
+ getDbForBlock(blockNumber) {
761
+ const db = this.dbs.get(blockNumber);
762
+ if (!db) {
763
+ throw new Error(`World state fork for block ${blockNumber} not found.`);
764
+ }
765
+ return db;
323
766
  }
324
767
  /**
325
768
  * Returns the proof for the current epoch.
@@ -346,7 +789,7 @@ const logger = createLogger('prover-client:orchestrator');
346
789
  * @param job - The actual job, returns a promise notifying of the job's completion
347
790
  */ deferredProving(provingState, request, callback) {
348
791
  if (!provingState.verifyState()) {
349
- logger.debug(`Not enqueuing job, state no longer valid`);
792
+ this.logger.debug(`Not enqueuing job, state no longer valid`);
350
793
  return;
351
794
  }
352
795
  const controller = new AbortController();
@@ -361,7 +804,7 @@ const logger = createLogger('prover-client:orchestrator');
361
804
  }
362
805
  const result = await request(controller.signal);
363
806
  if (!provingState.verifyState()) {
364
- logger.debug(`State no longer valid, discarding result`);
807
+ this.logger.debug(`State no longer valid, discarding result`);
365
808
  return;
366
809
  }
367
810
  // we could have been cancelled whilst waiting for the result
@@ -376,7 +819,7 @@ const logger = createLogger('prover-client:orchestrator');
376
819
  // drop this result
377
820
  return;
378
821
  }
379
- logger.error(`Error thrown when proving job`, err);
822
+ this.logger.error(`Error thrown when proving job`, err);
380
823
  provingState.reject(`${err}`);
381
824
  } finally{
382
825
  const index = this.pendingProvingJobs.indexOf(controller);
@@ -385,8 +828,11 @@ const logger = createLogger('prover-client:orchestrator');
385
828
  }
386
829
  }
387
830
  };
388
- // let the callstack unwind before adding the job to the queue
389
- setImmediate(()=>void safeJob());
831
+ void this.deferredJobQueue.put(async ()=>{
832
+ void safeJob();
833
+ // we yield here to the macro task queue such to give Nodejs a chance to run other operatoins in between enqueues
834
+ await sleep(0);
835
+ });
390
836
  }
391
837
  async updateL1ToL2MessageTree(l1ToL2Messages, db) {
392
838
  const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
@@ -432,17 +878,17 @@ const logger = createLogger('prover-client:orchestrator');
432
878
  // Executes the next level of merge if all inputs are available
433
879
  enqueueBaseRollup(provingState, txIndex) {
434
880
  if (!provingState.verifyState()) {
435
- logger.debug('Not running base rollup, state invalid');
881
+ this.logger.debug('Not running base rollup, state invalid');
436
882
  return;
437
883
  }
438
884
  if (!provingState.tryStartProvingBase(txIndex)) {
439
- logger.debug(`Base rollup for tx ${txIndex} already started.`);
885
+ this.logger.debug(`Base rollup for tx ${txIndex} already started.`);
440
886
  return;
441
887
  }
442
888
  const txProvingState = provingState.getTxProvingState(txIndex);
443
889
  const { processedTx } = txProvingState;
444
890
  const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
445
- logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
891
+ this.logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
446
892
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, `ProvingOrchestrator.prover.${inputs instanceof PrivateTxBaseRollupPrivateInputs ? 'getPrivateTxBaseRollupProof' : 'getPublicTxBaseRollupProof'}`, {
447
893
  [Attributes.TX_HASH]: processedTx.hash.toString(),
448
894
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
@@ -453,7 +899,7 @@ const logger = createLogger('prover-client:orchestrator');
453
899
  return this.prover.getPublicTxBaseRollupProof(inputs, signal, provingState.epochNumber);
454
900
  }
455
901
  }), (result)=>{
456
- logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
902
+ this.logger.debug(`Completed proof for ${rollupType} for tx ${processedTx.hash.toString()}`);
457
903
  validatePartialState(result.inputs.endTreeSnapshots, txProvingState.treeSnapshots);
458
904
  const leafLocation = provingState.setBaseRollupProof(txIndex, result);
459
905
  if (provingState.totalNumTxs === 1) {
@@ -467,14 +913,14 @@ const logger = createLogger('prover-client:orchestrator');
467
913
  // Once completed, will enqueue the the public tx base rollup.
468
914
  getOrEnqueueChonkVerifier(provingState, txIndex) {
469
915
  if (!provingState.verifyState()) {
470
- logger.debug('Not running chonk verifier circuit, state invalid');
916
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
471
917
  return;
472
918
  }
473
919
  const txProvingState = provingState.getTxProvingState(txIndex);
474
920
  const txHash = txProvingState.processedTx.hash.toString();
475
921
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH;
476
922
  const handleResult = (result)=>{
477
- logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
923
+ this.logger.debug(`Got chonk verifier proof for tx index: ${txIndex}`, {
478
924
  txHash
479
925
  });
480
926
  txProvingState.setPublicChonkVerifierProof(result);
@@ -482,18 +928,18 @@ const logger = createLogger('prover-client:orchestrator');
482
928
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
483
929
  };
484
930
  if (this.provingState?.cachedChonkVerifierProofs.has(txHash)) {
485
- logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
931
+ this.logger.debug(`Chonk verifier proof already enqueued for tx index: ${txIndex}`, {
486
932
  txHash
487
933
  });
488
934
  void this.provingState.cachedChonkVerifierProofs.get(txHash).then(handleResult);
489
935
  return;
490
936
  }
491
- logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
937
+ this.logger.debug(`Enqueuing chonk verifier circuit for tx index: ${txIndex}`);
492
938
  this.doEnqueueChonkVerifier(txHash, txProvingState.getPublicChonkVerifierPrivateInputs(), handleResult);
493
939
  }
494
940
  doEnqueueChonkVerifier(txHash, inputs, handler, provingState = this.provingState) {
495
941
  if (!provingState.verifyState()) {
496
- logger.debug('Not running chonk verifier circuit, state invalid');
942
+ this.logger.debug('Not running chonk verifier circuit, state invalid');
497
943
  return;
498
944
  }
499
945
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getPublicChonkVerifierProof', {
@@ -505,11 +951,11 @@ const logger = createLogger('prover-client:orchestrator');
505
951
  // Enqueues the next level of merge if all inputs are available
506
952
  enqueueMergeRollup(provingState, location) {
507
953
  if (!provingState.verifyState()) {
508
- logger.debug('Not running merge rollup. State no longer valid.');
954
+ this.logger.debug('Not running merge rollup. State no longer valid.');
509
955
  return;
510
956
  }
511
957
  if (!provingState.tryStartProvingMerge(location)) {
512
- logger.debug('Merge rollup already started.');
958
+ this.logger.debug('Merge rollup already started.');
513
959
  return;
514
960
  }
515
961
  const inputs = provingState.getMergeRollupInputs(location);
@@ -523,15 +969,15 @@ const logger = createLogger('prover-client:orchestrator');
523
969
  // Executes the block root rollup circuit
524
970
  enqueueBlockRootRollup(provingState) {
525
971
  if (!provingState.verifyState()) {
526
- logger.debug('Not running block root rollup, state no longer valid');
972
+ this.logger.debug('Not running block root rollup, state no longer valid');
527
973
  return;
528
974
  }
529
975
  if (!provingState.tryStartProvingBlockRoot()) {
530
- logger.debug('Block root rollup already started.');
976
+ this.logger.debug('Block root rollup already started.');
531
977
  return;
532
978
  }
533
979
  const { rollupType, inputs } = provingState.getBlockRootRollupTypeAndInputs();
534
- logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
980
+ this.logger.debug(`Enqueuing ${rollupType} for block ${provingState.blockNumber}.`);
535
981
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockRootRollupProof', {
536
982
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
537
983
  }, (signal)=>{
@@ -547,15 +993,16 @@ const logger = createLogger('prover-client:orchestrator');
547
993
  return this.prover.getBlockRootRollupProof(inputs, signal, provingState.epochNumber);
548
994
  }
549
995
  }), async (result)=>{
550
- // If the proofs were slower than the block header building, then we need to try validating the block header hashes here.
551
- await this.verifyBuiltBlockAgainstSyncedState(provingState);
552
- logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
996
+ this.logger.debug(`Completed ${rollupType} proof for block ${provingState.blockNumber}`);
553
997
  const leafLocation = provingState.setBlockRootRollupProof(result);
554
998
  const checkpointProvingState = provingState.parentCheckpoint;
999
+ // Verification is called from both here and setBlockCompleted. Whichever runs last
1000
+ // will be the first to see all three pieces (header, proof output, archive) and run the checks.
1001
+ await this.verifyBuiltBlockAgainstSyncedState(provingState);
555
1002
  if (checkpointProvingState.totalNumBlocks === 1) {
556
- this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
1003
+ await this.checkAndEnqueueCheckpointRootRollup(checkpointProvingState);
557
1004
  } else {
558
- this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
1005
+ await this.checkAndEnqueueNextBlockMergeRollup(checkpointProvingState, leafLocation);
559
1006
  }
560
1007
  });
561
1008
  }
@@ -563,11 +1010,11 @@ const logger = createLogger('prover-client:orchestrator');
563
1010
  // Enqueues the root parity circuit if all inputs are available
564
1011
  enqueueBaseParityCircuit(checkpointProvingState, provingState, baseParityIndex) {
565
1012
  if (!provingState.verifyState()) {
566
- logger.debug('Not running base parity. State no longer valid.');
1013
+ this.logger.debug('Not running base parity. State no longer valid.');
567
1014
  return;
568
1015
  }
569
1016
  if (!provingState.tryStartProvingBaseParity(baseParityIndex)) {
570
- logger.warn(`Base parity ${baseParityIndex} already started.`);
1017
+ this.logger.warn(`Base parity ${baseParityIndex} already started.`);
571
1018
  return;
572
1019
  }
573
1020
  const inputs = checkpointProvingState.getBaseParityInputs(baseParityIndex);
@@ -588,11 +1035,11 @@ const logger = createLogger('prover-client:orchestrator');
588
1035
  // Enqueues the root rollup proof if all inputs are available
589
1036
  enqueueRootParityCircuit(provingState) {
590
1037
  if (!provingState.verifyState()) {
591
- logger.debug('Not running root parity. State no longer valid.');
1038
+ this.logger.debug('Not running root parity. State no longer valid.');
592
1039
  return;
593
1040
  }
594
1041
  if (!provingState.tryStartProvingRootParity()) {
595
- logger.debug('Root parity already started.');
1042
+ this.logger.debug('Root parity already started.');
596
1043
  return;
597
1044
  }
598
1045
  const inputs = provingState.getParityRootInputs();
@@ -607,33 +1054,33 @@ const logger = createLogger('prover-client:orchestrator');
607
1054
  // Enqueues the next level of merge if all inputs are available
608
1055
  enqueueBlockMergeRollup(provingState, location) {
609
1056
  if (!provingState.verifyState()) {
610
- logger.debug('Not running block merge rollup. State no longer valid.');
1057
+ this.logger.debug('Not running block merge rollup. State no longer valid.');
611
1058
  return;
612
1059
  }
613
1060
  if (!provingState.tryStartProvingBlockMerge(location)) {
614
- logger.debug('Block merge rollup already started.');
1061
+ this.logger.debug('Block merge rollup already started.');
615
1062
  return;
616
1063
  }
617
1064
  const inputs = provingState.getBlockMergeRollupInputs(location);
618
1065
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getBlockMergeRollupProof', {
619
1066
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-block-merge'
620
- }, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
1067
+ }, (signal)=>this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber)), async (result)=>{
621
1068
  provingState.setBlockMergeRollupProof(location, result);
622
- this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
1069
+ await this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
623
1070
  });
624
1071
  }
625
- enqueueCheckpointRootRollup(provingState) {
1072
+ async enqueueCheckpointRootRollup(provingState) {
626
1073
  if (!provingState.verifyState()) {
627
- logger.debug('Not running checkpoint root rollup. State no longer valid.');
1074
+ this.logger.debug('Not running checkpoint root rollup. State no longer valid.');
628
1075
  return;
629
1076
  }
630
1077
  if (!provingState.tryStartProvingCheckpointRoot()) {
631
- logger.debug('Checkpoint root rollup already started.');
1078
+ this.logger.debug('Checkpoint root rollup already started.');
632
1079
  return;
633
1080
  }
634
1081
  const rollupType = provingState.getCheckpointRootRollupType();
635
- logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
636
- const inputs = provingState.getCheckpointRootRollupInputs();
1082
+ this.logger.debug(`Enqueuing ${rollupType} for checkpoint ${provingState.index}.`);
1083
+ const inputs = await provingState.getCheckpointRootRollupInputs();
637
1084
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointRootRollupProof', {
638
1085
  [Attributes.PROTOCOL_CIRCUIT_NAME]: rollupType
639
1086
  }, (signal)=>{
@@ -646,11 +1093,11 @@ const logger = createLogger('prover-client:orchestrator');
646
1093
  const computedEndBlobAccumulatorState = provingState.getEndBlobAccumulator().toBlobAccumulator();
647
1094
  const circuitEndBlobAccumulatorState = result.inputs.endBlobAccumulator;
648
1095
  if (!circuitEndBlobAccumulatorState.equals(computedEndBlobAccumulatorState)) {
649
- logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
1096
+ this.logger.error(`Blob accumulator state mismatch.\nCircuit: ${inspect(circuitEndBlobAccumulatorState)}\nComputed: ${inspect(computedEndBlobAccumulatorState)}`);
650
1097
  provingState.reject(`Blob accumulator state mismatch.`);
651
1098
  return;
652
1099
  }
653
- logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
1100
+ this.logger.debug(`Completed ${rollupType} proof for checkpoint ${provingState.index}.`);
654
1101
  const leafLocation = provingState.setCheckpointRootRollupProof(result);
655
1102
  const epochProvingState = provingState.parentEpoch;
656
1103
  if (epochProvingState.totalNumCheckpoints === 1) {
@@ -662,37 +1109,37 @@ const logger = createLogger('prover-client:orchestrator');
662
1109
  }
663
1110
  enqueueCheckpointMergeRollup(provingState, location) {
664
1111
  if (!provingState.verifyState()) {
665
- logger.debug('Not running checkpoint merge rollup. State no longer valid.');
1112
+ this.logger.debug('Not running checkpoint merge rollup. State no longer valid.');
666
1113
  return;
667
1114
  }
668
1115
  if (!provingState.tryStartProvingCheckpointMerge(location)) {
669
- logger.debug('Checkpoint merge rollup already started.');
1116
+ this.logger.debug('Checkpoint merge rollup already started.');
670
1117
  return;
671
1118
  }
672
1119
  const inputs = provingState.getCheckpointMergeRollupInputs(location);
673
1120
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointMergeRollupProof', {
674
1121
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-merge'
675
1122
  }, (signal)=>this.prover.getCheckpointMergeRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
676
- logger.debug('Completed proof for checkpoint merge rollup.');
1123
+ this.logger.debug('Completed proof for checkpoint merge rollup.');
677
1124
  provingState.setCheckpointMergeRollupProof(location, result);
678
1125
  this.checkAndEnqueueNextCheckpointMergeRollup(provingState, location);
679
1126
  });
680
1127
  }
681
1128
  enqueueEpochPadding(provingState) {
682
1129
  if (!provingState.verifyState()) {
683
- logger.debug('Not running epoch padding. State no longer valid.');
1130
+ this.logger.debug('Not running epoch padding. State no longer valid.');
684
1131
  return;
685
1132
  }
686
1133
  if (!provingState.tryStartProvingPaddingCheckpoint()) {
687
- logger.debug('Padding checkpoint already started.');
1134
+ this.logger.debug('Padding checkpoint already started.');
688
1135
  return;
689
1136
  }
690
- logger.debug('Padding epoch proof with a padding block root proof.');
1137
+ this.logger.debug('Padding epoch proof with a padding block root proof.');
691
1138
  const inputs = provingState.getPaddingCheckpointInputs();
692
1139
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getCheckpointPaddingRollupProof', {
693
1140
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-checkpoint-padding'
694
1141
  }, (signal)=>this.prover.getCheckpointPaddingRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
695
- logger.debug('Completed proof for padding checkpoint.');
1142
+ this.logger.debug('Completed proof for padding checkpoint.');
696
1143
  provingState.setCheckpointPaddingProof(result);
697
1144
  this.checkAndEnqueueRootRollup(provingState);
698
1145
  });
@@ -700,15 +1147,15 @@ const logger = createLogger('prover-client:orchestrator');
700
1147
  // Executes the root rollup circuit
701
1148
  enqueueRootRollup(provingState) {
702
1149
  if (!provingState.verifyState()) {
703
- logger.debug('Not running root rollup, state no longer valid');
1150
+ this.logger.debug('Not running root rollup, state no longer valid');
704
1151
  return;
705
1152
  }
706
- logger.debug(`Preparing root rollup`);
1153
+ this.logger.debug(`Preparing root rollup`);
707
1154
  const inputs = provingState.getRootRollupInputs();
708
1155
  this.deferredProving(provingState, wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getRootRollupProof', {
709
1156
  [Attributes.PROTOCOL_CIRCUIT_NAME]: 'rollup-root'
710
1157
  }, (signal)=>this.prover.getRootRollupProof(inputs, signal, provingState.epochNumber)), (result)=>{
711
- logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
1158
+ this.logger.verbose(`Orchestrator completed root rollup for epoch ${provingState.epochNumber}`);
712
1159
  provingState.setRootRollupProof(result);
713
1160
  provingState.resolve({
714
1161
  status: 'success'
@@ -728,27 +1175,27 @@ const logger = createLogger('prover-client:orchestrator');
728
1175
  }
729
1176
  checkAndEnqueueBlockRootRollup(provingState) {
730
1177
  if (!provingState.isReadyForBlockRootRollup()) {
731
- logger.debug('Not ready for block root rollup');
1178
+ this.logger.debug('Not ready for block root rollup');
732
1179
  return;
733
1180
  }
734
1181
  this.enqueueBlockRootRollup(provingState);
735
1182
  }
736
- checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
1183
+ async checkAndEnqueueNextBlockMergeRollup(provingState, currentLocation) {
737
1184
  if (!provingState.isReadyForBlockMerge(currentLocation)) {
738
1185
  return;
739
1186
  }
740
1187
  const parentLocation = provingState.getParentLocation(currentLocation);
741
1188
  if (parentLocation.level === 0) {
742
- this.checkAndEnqueueCheckpointRootRollup(provingState);
1189
+ await this.checkAndEnqueueCheckpointRootRollup(provingState);
743
1190
  } else {
744
1191
  this.enqueueBlockMergeRollup(provingState, parentLocation);
745
1192
  }
746
1193
  }
747
- checkAndEnqueueCheckpointRootRollup(provingState) {
1194
+ async checkAndEnqueueCheckpointRootRollup(provingState) {
748
1195
  if (!provingState.isReadyForCheckpointRoot()) {
749
1196
  return;
750
1197
  }
751
- this.enqueueCheckpointRootRollup(provingState);
1198
+ await this.enqueueCheckpointRootRollup(provingState);
752
1199
  }
753
1200
  checkAndEnqueueNextCheckpointMergeRollup(provingState, currentLocation) {
754
1201
  if (!provingState.isReadyForCheckpointMerge(currentLocation)) {
@@ -763,7 +1210,7 @@ const logger = createLogger('prover-client:orchestrator');
763
1210
  }
764
1211
  checkAndEnqueueRootRollup(provingState) {
765
1212
  if (!provingState.isReadyForRootRollup()) {
766
- logger.debug('Not ready for root rollup');
1213
+ this.logger.debug('Not ready for root rollup');
767
1214
  return;
768
1215
  }
769
1216
  this.enqueueRootRollup(provingState);
@@ -775,41 +1222,19 @@ const logger = createLogger('prover-client:orchestrator');
775
1222
  * @param txIndex - The index of the transaction being proven
776
1223
  */ enqueueVM(provingState, txIndex) {
777
1224
  if (!provingState.verifyState()) {
778
- logger.debug(`Not running VM circuit as state is no longer valid`);
1225
+ this.logger.debug(`Not running VM circuit as state is no longer valid`);
779
1226
  return;
780
1227
  }
781
1228
  const txProvingState = provingState.getTxProvingState(txIndex);
782
- // This function tries to do AVM proving. If there is a failure, it fakes the proof unless AVM_PROVING_STRICT is defined.
783
- // Nothing downstream depends on the AVM proof yet. So having this mode lets us incrementally build the AVM circuit.
784
1229
  const doAvmProving = wrapCallbackInSpan(this.tracer, 'ProvingOrchestrator.prover.getAvmProof', {
785
1230
  [Attributes.TX_HASH]: txProvingState.processedTx.hash.toString()
786
1231
  }, async (signal)=>{
787
1232
  const inputs = txProvingState.getAvmInputs();
788
- try {
789
- // TODO(#14234)[Unconditional PIs validation]: Remove the whole try-catch logic and
790
- // just keep the next line but removing the second argument (false).
791
- return await this.prover.getAvmProof(inputs, false, signal, provingState.epochNumber);
792
- } catch (err) {
793
- if (process.env.AVM_PROVING_STRICT) {
794
- logger.error(`Error thrown when proving AVM circuit with AVM_PROVING_STRICT on`, err);
795
- throw err;
796
- } else {
797
- logger.warn(`Error thrown when proving AVM circuit but AVM_PROVING_STRICT is off. Use snapshotted
798
- AVM inputs and carrying on. ${inspect(err)}.`);
799
- try {
800
- this.metrics.incAvmFallback();
801
- const snapshotAvmPrivateInputs = readAvmMinimalPublicTxInputsFromFile();
802
- return await this.prover.getAvmProof(snapshotAvmPrivateInputs, true, signal, provingState.epochNumber);
803
- } catch (err) {
804
- logger.error(`Error thrown when proving snapshotted AVM inputs.`, err);
805
- throw err;
806
- }
807
- }
808
- }
1233
+ return await this.prover.getAvmProof(inputs, signal, provingState.epochNumber);
809
1234
  });
810
- this.deferredProving(provingState, doAvmProving, (proofAndVk)=>{
811
- logger.debug(`Proven VM for tx index: ${txIndex}`);
812
- txProvingState.setAvmProof(proofAndVk);
1235
+ this.deferredProving(provingState, doAvmProving, (proof)=>{
1236
+ this.logger.debug(`Proven VM for tx index: ${txIndex}`);
1237
+ txProvingState.setAvmProof(proof);
813
1238
  this.checkAndEnqueueBaseRollup(provingState, txIndex);
814
1239
  });
815
1240
  }
@@ -819,30 +1244,7 @@ const logger = createLogger('prover-client:orchestrator');
819
1244
  return;
820
1245
  }
821
1246
  // We must have completed all proving (chonk verifier proof and (if required) vm proof are generated), we now move to the base rollup.
822
- logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
1247
+ this.logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
823
1248
  this.enqueueBaseRollup(provingState, txIndex);
824
1249
  }
825
1250
  }
826
- _ts_decorate([
827
- trackSpan('ProvingOrchestrator.startNewBlock', (blockNumber)=>({
828
- [Attributes.BLOCK_NUMBER]: blockNumber
829
- }))
830
- ], ProvingOrchestrator.prototype, "startNewBlock", null);
831
- _ts_decorate([
832
- trackSpan('ProvingOrchestrator.addTxs', (txs)=>({
833
- [Attributes.BLOCK_TXS_COUNT]: txs.length
834
- }))
835
- ], ProvingOrchestrator.prototype, "addTxs", null);
836
- _ts_decorate([
837
- trackSpan('ProvingOrchestrator.startChonkVerifierCircuits')
838
- ], ProvingOrchestrator.prototype, "startChonkVerifierCircuits", null);
839
- _ts_decorate([
840
- trackSpan('ProvingOrchestrator.setBlockCompleted', (blockNumber)=>({
841
- [Attributes.BLOCK_NUMBER]: blockNumber
842
- }))
843
- ], ProvingOrchestrator.prototype, "setBlockCompleted", null);
844
- _ts_decorate([
845
- trackSpan('ProvingOrchestrator.prepareBaseRollupInputs', (tx)=>({
846
- [Attributes.TX_HASH]: tx.hash.toString()
847
- }))
848
- ], ProvingOrchestrator.prototype, "prepareBaseRollupInputs", null);