@aztec/prover-node 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/actions/download-epoch-proving-job.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +3 -2
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +5 -3
- package/dest/bin/run-failed-epoch.js +5 -2
- package/dest/config.d.ts +7 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +17 -19
- package/dest/factory.d.ts +20 -15
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +28 -61
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/job/epoch-proving-job-data.d.ts +7 -6
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
- package/dest/job/epoch-proving-job-data.js +24 -18
- package/dest/job/epoch-proving-job.d.ts +5 -4
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +501 -108
- package/dest/metrics.d.ts +4 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +29 -97
- package/dest/monitors/epoch-monitor.d.ts +1 -1
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +3 -11
- package/dest/prover-node-publisher.d.ts +12 -10
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +46 -40
- package/dest/prover-node.d.ts +21 -11
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +438 -53
- package/dest/prover-publisher-factory.d.ts +9 -5
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +4 -2
- package/package.json +25 -25
- package/src/actions/rerun-epoch-proving-job.ts +5 -3
- package/src/bin/run-failed-epoch.ts +5 -2
- package/src/config.ts +25 -31
- package/src/factory.ts +65 -101
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job-data.ts +28 -23
- package/src/job/epoch-proving-job.ts +135 -111
- package/src/metrics.ts +30 -81
- package/src/monitors/epoch-monitor.ts +3 -10
- package/src/prover-node-publisher.ts +67 -55
- package/src/prover-node.ts +49 -39
- package/src/prover-publisher-factory.ts +16 -8
|
@@ -1,13 +1,381 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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, _initProto;
|
|
7
374
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
8
375
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
376
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
9
377
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
378
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
379
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
380
|
import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
13
381
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -21,6 +389,11 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
|
21
389
|
import { Attributes, trackSpan } from '@aztec/telemetry-client';
|
|
22
390
|
import * as crypto from 'node:crypto';
|
|
23
391
|
import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
392
|
+
_dec = trackSpan('EpochProvingJob.run', function() {
|
|
393
|
+
return {
|
|
394
|
+
[Attributes.EPOCH_NUMBER]: this.data.epochNumber
|
|
395
|
+
};
|
|
396
|
+
});
|
|
24
397
|
/**
|
|
25
398
|
* Job that grabs a range of blocks from the unfinalized chain from L1, gets their txs given their hashes,
|
|
26
399
|
* re-executes their public calls, generates a rollup proof, and submits it to L1. This job will update the
|
|
@@ -35,6 +408,15 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
35
408
|
metrics;
|
|
36
409
|
deadline;
|
|
37
410
|
config;
|
|
411
|
+
static{
|
|
412
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
413
|
+
[
|
|
414
|
+
_dec,
|
|
415
|
+
2,
|
|
416
|
+
"run"
|
|
417
|
+
]
|
|
418
|
+
], []));
|
|
419
|
+
}
|
|
38
420
|
state;
|
|
39
421
|
log;
|
|
40
422
|
uuid;
|
|
@@ -42,7 +424,7 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
42
424
|
epochCheckPromise;
|
|
43
425
|
deadlineTimeoutHandler;
|
|
44
426
|
tracer;
|
|
45
|
-
constructor(data, dbProvider, prover, publicProcessorFactory, publisher, l2BlockSource, metrics, deadline, config){
|
|
427
|
+
constructor(data, dbProvider, prover, publicProcessorFactory, publisher, l2BlockSource, metrics, deadline, config, bindings){
|
|
46
428
|
this.data = data;
|
|
47
429
|
this.dbProvider = dbProvider;
|
|
48
430
|
this.prover = prover;
|
|
@@ -52,10 +434,13 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
52
434
|
this.metrics = metrics;
|
|
53
435
|
this.deadline = deadline;
|
|
54
436
|
this.config = config;
|
|
55
|
-
this.state = 'initialized';
|
|
56
|
-
this.log = createLogger('prover-node:epoch-proving-job');
|
|
437
|
+
this.state = (_initProto(this), 'initialized');
|
|
57
438
|
validateEpochProvingJobData(data);
|
|
58
439
|
this.uuid = crypto.randomUUID();
|
|
440
|
+
this.log = createLogger('prover-node:epoch-proving-job', {
|
|
441
|
+
...bindings,
|
|
442
|
+
instanceId: `epoch-${data.epochNumber}`
|
|
443
|
+
});
|
|
59
444
|
this.tracer = metrics.tracer;
|
|
60
445
|
}
|
|
61
446
|
getId() {
|
|
@@ -76,8 +461,8 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
76
461
|
get epochNumber() {
|
|
77
462
|
return this.data.epochNumber;
|
|
78
463
|
}
|
|
79
|
-
get
|
|
80
|
-
return this.data.
|
|
464
|
+
get checkpoints() {
|
|
465
|
+
return this.data.checkpoints;
|
|
81
466
|
}
|
|
82
467
|
get txs() {
|
|
83
468
|
return this.data.txs;
|
|
@@ -94,16 +479,17 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
94
479
|
}
|
|
95
480
|
const attestations = this.attestations.map((attestation)=>attestation.toViem());
|
|
96
481
|
const epochNumber = this.epochNumber;
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
];
|
|
103
|
-
this.
|
|
482
|
+
const epochSizeCheckpoints = this.checkpoints.length;
|
|
483
|
+
const epochSizeBlocks = this.checkpoints.reduce((accum, checkpoint)=>accum + checkpoint.blocks.length, 0);
|
|
484
|
+
const epochSizeTxs = this.checkpoints.reduce((accum, checkpoint)=>accum + checkpoint.blocks.reduce((accumC, block)=>accumC + block.body.txEffects.length, 0), 0);
|
|
485
|
+
const fromCheckpoint = this.checkpoints[0].number;
|
|
486
|
+
const toCheckpoint = this.checkpoints.at(-1).number;
|
|
487
|
+
const fromBlock = this.checkpoints[0].blocks[0].number;
|
|
488
|
+
const toBlock = this.checkpoints.at(-1).blocks.at(-1).number;
|
|
489
|
+
this.log.info(`Starting epoch ${epochNumber} proving job with checkpoints ${fromCheckpoint} to ${toCheckpoint}`, {
|
|
104
490
|
fromBlock,
|
|
105
491
|
toBlock,
|
|
106
|
-
|
|
492
|
+
epochSizeTxs,
|
|
107
493
|
epochNumber,
|
|
108
494
|
uuid: this.uuid
|
|
109
495
|
});
|
|
@@ -112,70 +498,79 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
112
498
|
const { promise, resolve } = promiseWithResolvers();
|
|
113
499
|
this.runPromise = promise;
|
|
114
500
|
try {
|
|
115
|
-
const blobFieldsPerCheckpoint = this.
|
|
501
|
+
const blobFieldsPerCheckpoint = this.checkpoints.map((checkpoint)=>checkpoint.toBlobFields());
|
|
502
|
+
this.log.info(`Blob fields per checkpoint: ${timer.ms()}ms`);
|
|
116
503
|
const finalBlobBatchingChallenges = await buildFinalBlobChallenges(blobFieldsPerCheckpoint);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const totalNumCheckpoints = epochSizeBlocks;
|
|
120
|
-
this.prover.startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges);
|
|
504
|
+
this.log.info(`Final blob batching challeneger: ${timer.ms()}ms`);
|
|
505
|
+
this.prover.startNewEpoch(epochNumber, epochSizeCheckpoints, finalBlobBatchingChallenges);
|
|
121
506
|
await this.prover.startChonkVerifierCircuits(Array.from(this.txs.values()));
|
|
122
|
-
|
|
507
|
+
// Everything in the epoch should have the same chainId and version.
|
|
508
|
+
const { chainId, version } = this.checkpoints[0].blocks[0].header.globalVariables;
|
|
509
|
+
const previousBlockHeaders = this.gatherPreviousBlockHeaders();
|
|
510
|
+
await asyncPool(this.config.parallelBlockLimit ?? 32, this.checkpoints, async (checkpoint)=>{
|
|
123
511
|
this.checkState();
|
|
124
|
-
const
|
|
125
|
-
const txs = this.getTxs(block);
|
|
126
|
-
const l1ToL2Messages = this.getL1ToL2Messages(block);
|
|
127
|
-
const previousHeader = this.getBlockHeader(block.number - 1);
|
|
128
|
-
this.log.verbose(`Starting processing block ${block.number}`, {
|
|
129
|
-
number: block.number,
|
|
130
|
-
blockHash: (await block.hash()).toString(),
|
|
131
|
-
lastArchive: block.header.lastArchive.root,
|
|
132
|
-
noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
|
|
133
|
-
nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
|
|
134
|
-
publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
|
|
135
|
-
previousHeader: previousHeader.hash(),
|
|
136
|
-
uuid: this.uuid,
|
|
137
|
-
...globalVariables
|
|
138
|
-
});
|
|
512
|
+
const checkpointIndex = checkpoint.number - fromCheckpoint;
|
|
139
513
|
const checkpointConstants = CheckpointConstantData.from({
|
|
140
|
-
chainId
|
|
141
|
-
version
|
|
514
|
+
chainId,
|
|
515
|
+
version,
|
|
142
516
|
vkTreeRoot: getVKTreeRoot(),
|
|
143
517
|
protocolContractsHash: protocolContractsHash,
|
|
144
518
|
proverId: this.prover.getProverId().toField(),
|
|
145
|
-
slotNumber:
|
|
146
|
-
coinbase:
|
|
147
|
-
feeRecipient:
|
|
148
|
-
gasFees:
|
|
519
|
+
slotNumber: checkpoint.header.slotNumber,
|
|
520
|
+
coinbase: checkpoint.header.coinbase,
|
|
521
|
+
feeRecipient: checkpoint.header.feeRecipient,
|
|
522
|
+
gasFees: checkpoint.header.gasFees
|
|
149
523
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// Process public fns
|
|
158
|
-
const db = await this.createFork(block.number - 1, l1ToL2Messages);
|
|
159
|
-
const config = PublicSimulatorConfig.from({
|
|
160
|
-
proverId: this.prover.getProverId().toField(),
|
|
161
|
-
skipFeeEnforcement: false,
|
|
162
|
-
collectDebugLogs: false,
|
|
163
|
-
collectHints: true,
|
|
164
|
-
maxDebugLogMemoryReads: 0,
|
|
165
|
-
collectStatistics: false
|
|
166
|
-
});
|
|
167
|
-
const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, config);
|
|
168
|
-
const processed = await this.processTxs(publicProcessor, txs);
|
|
169
|
-
await this.prover.addTxs(processed);
|
|
170
|
-
await db.close();
|
|
171
|
-
this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
|
|
172
|
-
blockNumber: block.number,
|
|
173
|
-
blockHash: (await block.hash()).toString(),
|
|
524
|
+
const previousHeader = previousBlockHeaders[checkpointIndex];
|
|
525
|
+
const l1ToL2Messages = this.getL1ToL2Messages(checkpoint);
|
|
526
|
+
this.log.verbose(`Starting processing checkpoint ${checkpoint.number}`, {
|
|
527
|
+
number: checkpoint.number,
|
|
528
|
+
checkpointHash: checkpoint.hash().toString(),
|
|
529
|
+
lastArchive: checkpoint.header.lastArchiveRoot,
|
|
530
|
+
previousHeader: previousHeader.hash(),
|
|
174
531
|
uuid: this.uuid
|
|
175
532
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
533
|
+
await this.prover.startNewCheckpoint(checkpointIndex, checkpointConstants, l1ToL2Messages, checkpoint.blocks.length, previousHeader);
|
|
534
|
+
for(let blockIndex = 0; blockIndex < checkpoint.blocks.length; blockIndex++){
|
|
535
|
+
const block = checkpoint.blocks[blockIndex];
|
|
536
|
+
const globalVariables = block.header.globalVariables;
|
|
537
|
+
const txs = this.getTxs(block);
|
|
538
|
+
this.log.verbose(`Starting processing block ${block.number}`, {
|
|
539
|
+
number: block.number,
|
|
540
|
+
blockHash: (await block.hash()).toString(),
|
|
541
|
+
lastArchive: block.header.lastArchive.root,
|
|
542
|
+
noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
|
|
543
|
+
nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
|
|
544
|
+
publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
|
|
545
|
+
...globalVariables,
|
|
546
|
+
numTxs: txs.length
|
|
547
|
+
});
|
|
548
|
+
// Start block proving
|
|
549
|
+
await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
|
|
550
|
+
// Process public fns. L1 to L2 messages are only inserted for the first block of a checkpoint,
|
|
551
|
+
// as the fork for subsequent blocks already includes them from the previous block's synced state.
|
|
552
|
+
const db = await this.createFork(BlockNumber(block.number - 1), blockIndex === 0 ? l1ToL2Messages : undefined);
|
|
553
|
+
const config = PublicSimulatorConfig.from({
|
|
554
|
+
proverId: this.prover.getProverId().toField(),
|
|
555
|
+
skipFeeEnforcement: false,
|
|
556
|
+
collectDebugLogs: false,
|
|
557
|
+
collectHints: true,
|
|
558
|
+
collectPublicInputs: true,
|
|
559
|
+
collectStatistics: false
|
|
560
|
+
});
|
|
561
|
+
const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, config);
|
|
562
|
+
const processed = await this.processTxs(publicProcessor, txs);
|
|
563
|
+
await this.prover.addTxs(processed);
|
|
564
|
+
await db.close();
|
|
565
|
+
this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
|
|
566
|
+
blockNumber: block.number,
|
|
567
|
+
blockHash: (await block.hash()).toString(),
|
|
568
|
+
uuid: this.uuid
|
|
569
|
+
});
|
|
570
|
+
// Mark block as completed to pad it
|
|
571
|
+
const expectedBlockHeader = block.header;
|
|
572
|
+
await this.prover.setBlockCompleted(block.number, expectedBlockHeader);
|
|
573
|
+
}
|
|
179
574
|
});
|
|
180
575
|
const executionTime = timer.ms();
|
|
181
576
|
this.progressState('awaiting-prover');
|
|
@@ -187,14 +582,14 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
187
582
|
});
|
|
188
583
|
this.progressState('publishing-proof');
|
|
189
584
|
if (this.config.skipSubmitProof) {
|
|
190
|
-
this.log.info(`Proof publishing is disabled. Dropping valid proof for epoch ${epochNumber} (
|
|
585
|
+
this.log.info(`Proof publishing is disabled. Dropping valid proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`);
|
|
191
586
|
this.state = 'completed';
|
|
192
|
-
this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeBlocks, epochSizeTxs);
|
|
587
|
+
this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
|
|
193
588
|
return;
|
|
194
589
|
}
|
|
195
590
|
const success = await this.publisher.submitEpochProof({
|
|
196
|
-
|
|
197
|
-
|
|
591
|
+
fromCheckpoint,
|
|
592
|
+
toCheckpoint,
|
|
198
593
|
epochNumber,
|
|
199
594
|
publicInputs,
|
|
200
595
|
proof,
|
|
@@ -204,12 +599,12 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
204
599
|
if (!success) {
|
|
205
600
|
throw new Error('Failed to submit epoch proof to L1');
|
|
206
601
|
}
|
|
207
|
-
this.log.info(`Submitted proof for epoch ${epochNumber} (
|
|
602
|
+
this.log.info(`Submitted proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`, {
|
|
208
603
|
epochNumber,
|
|
209
604
|
uuid: this.uuid
|
|
210
605
|
});
|
|
211
606
|
this.state = 'completed';
|
|
212
|
-
this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeBlocks, epochSizeTxs);
|
|
607
|
+
this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
|
|
213
608
|
} catch (err) {
|
|
214
609
|
if (err && err.name === 'HaltExecutionError') {
|
|
215
610
|
this.log.warn(`Halted execution of epoch ${epochNumber} prover job`, {
|
|
@@ -234,16 +629,23 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
234
629
|
}
|
|
235
630
|
}
|
|
236
631
|
/**
|
|
237
|
-
* Create a new db fork for tx processing, inserting
|
|
632
|
+
* Create a new db fork for tx processing, optionally inserting L1 to L2 messages.
|
|
633
|
+
* L1 to L2 messages should only be inserted for the first block in a checkpoint,
|
|
634
|
+
* as subsequent blocks' synced state already includes them.
|
|
238
635
|
* REFACTOR: The prover already spawns a db fork of its own for each block, so we may be able to do away with just one fork.
|
|
239
636
|
*/ async createFork(blockNumber, l1ToL2Messages) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.log.verbose(`Creating fork at ${blockNumber} with ${l1ToL2Messages.length} L1 to L2 messages`, {
|
|
243
|
-
blockNumber,
|
|
244
|
-
l1ToL2Messages: l1ToL2Messages.map((m)=>m.toString())
|
|
637
|
+
this.log.verbose(`Creating fork at ${blockNumber}`, {
|
|
638
|
+
blockNumber
|
|
245
639
|
});
|
|
246
|
-
await
|
|
640
|
+
const db = await this.dbProvider.fork(blockNumber);
|
|
641
|
+
if (l1ToL2Messages !== undefined) {
|
|
642
|
+
this.log.verbose(`Inserting ${l1ToL2Messages.length} L1 to L2 messages in fork`, {
|
|
643
|
+
blockNumber,
|
|
644
|
+
l1ToL2Messages: l1ToL2Messages.map((m)=>m.toString())
|
|
645
|
+
});
|
|
646
|
+
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
|
|
647
|
+
await db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
|
|
648
|
+
}
|
|
247
649
|
return db;
|
|
248
650
|
}
|
|
249
651
|
progressState(state) {
|
|
@@ -297,10 +699,11 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
297
699
|
}
|
|
298
700
|
const intervalMs = Math.ceil((await l2BlockSource.getL1Constants()).ethereumSlotDuration / 2) * 1000;
|
|
299
701
|
this.epochCheckPromise = new RunningPromise(async ()=>{
|
|
300
|
-
const
|
|
301
|
-
const blockHashes = await Promise.all(
|
|
302
|
-
const
|
|
303
|
-
|
|
702
|
+
const blockHeaders = await l2BlockSource.getCheckpointedBlockHeadersForEpoch(this.epochNumber);
|
|
703
|
+
const blockHashes = await Promise.all(blockHeaders.map((header)=>header.hash()));
|
|
704
|
+
const thisBlocks = this.checkpoints.flatMap((checkpoint)=>checkpoint.blocks);
|
|
705
|
+
const thisBlockHashes = await Promise.all(thisBlocks.map((block)=>block.hash()));
|
|
706
|
+
if (blockHeaders.length !== thisBlocks.length || !blockHashes.every((block, i)=>block.equals(thisBlockHashes[i]))) {
|
|
304
707
|
this.log.warn('Epoch blocks changed underfoot', {
|
|
305
708
|
uuid: this.uuid,
|
|
306
709
|
epochNumber: this.epochNumber,
|
|
@@ -312,21 +715,18 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
312
715
|
}, this.log, intervalMs).start();
|
|
313
716
|
this.log.verbose(`Scheduled epoch check for epoch ${this.epochNumber} every ${intervalMs}ms`);
|
|
314
717
|
}
|
|
315
|
-
/* Returns the header
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return this.data.previousBlockHeader;
|
|
322
|
-
}
|
|
323
|
-
throw new Error(`Block header not found for block number ${blockNumber} (got ${this.blocks.map((b)=>b.number).join(', ')} and previous header ${this.data.previousBlockHeader.getBlockNumber()})`);
|
|
718
|
+
/* Returns the last block header in the previous checkpoint for all checkpoints in the epoch */ gatherPreviousBlockHeaders() {
|
|
719
|
+
const lastBlocks = this.checkpoints.map((checkpoint)=>checkpoint.blocks.at(-1));
|
|
720
|
+
return [
|
|
721
|
+
this.data.previousBlockHeader,
|
|
722
|
+
...lastBlocks.map((block)=>block.header).slice(0, -1)
|
|
723
|
+
];
|
|
324
724
|
}
|
|
325
725
|
getTxs(block) {
|
|
326
726
|
return block.body.txEffects.map((txEffect)=>this.txs.get(txEffect.txHash.toString()));
|
|
327
727
|
}
|
|
328
|
-
getL1ToL2Messages(
|
|
329
|
-
return this.data.l1ToL2Messages[
|
|
728
|
+
getL1ToL2Messages(checkpoint) {
|
|
729
|
+
return this.data.l1ToL2Messages[checkpoint.number];
|
|
330
730
|
}
|
|
331
731
|
async processTxs(publicProcessor, txs) {
|
|
332
732
|
const { deadline } = this;
|
|
@@ -343,13 +743,6 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
|
|
|
343
743
|
return processedTxs;
|
|
344
744
|
}
|
|
345
745
|
}
|
|
346
|
-
_ts_decorate([
|
|
347
|
-
trackSpan('EpochProvingJob.run', function() {
|
|
348
|
-
return {
|
|
349
|
-
[Attributes.EPOCH_NUMBER]: this.data.epochNumber
|
|
350
|
-
};
|
|
351
|
-
})
|
|
352
|
-
], EpochProvingJob.prototype, "run", null);
|
|
353
746
|
class HaltExecutionError extends Error {
|
|
354
747
|
state;
|
|
355
748
|
constructor(state){
|