@aztec/sequencer-client 0.0.1-commit.6c91f13 → 0.0.1-commit.6d63667d
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/client/sequencer-client.d.ts +4 -5
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -1
- package/dest/global_variable_builder/global_builder.d.ts +4 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +13 -13
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +17 -17
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +481 -67
- package/dest/sequencer/checkpoint_proposal_job.d.ts +40 -12
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +605 -56
- package/dest/sequencer/checkpoint_voter.d.ts +3 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +34 -10
- package/dest/sequencer/index.d.ts +1 -3
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -2
- package/dest/sequencer/metrics.d.ts +4 -4
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +48 -129
- package/dest/sequencer/sequencer.d.ts +27 -15
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +491 -43
- package/dest/test/index.d.ts +2 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +23 -11
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +50 -9
- package/dest/test/utils.d.ts +13 -9
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +26 -17
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +4 -5
- package/src/config.ts +5 -0
- package/src/global_variable_builder/global_builder.ts +13 -13
- package/src/index.ts +1 -9
- package/src/publisher/sequencer-publisher-metrics.ts +17 -69
- package/src/publisher/sequencer-publisher.ts +118 -91
- package/src/sequencer/checkpoint_proposal_job.ts +257 -86
- package/src/sequencer/checkpoint_voter.ts +32 -7
- package/src/sequencer/index.ts +0 -2
- package/src/sequencer/metrics.ts +48 -138
- package/src/sequencer/sequencer.ts +132 -43
- package/src/test/index.ts +1 -2
- package/src/test/mock_checkpoint_builder.ts +91 -29
- package/src/test/utils.ts +55 -28
- package/dest/sequencer/block_builder.d.ts +0 -26
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -129
- package/dest/sequencer/checkpoint_builder.d.ts +0 -63
- package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
- package/dest/sequencer/checkpoint_builder.js +0 -131
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -217
- package/src/sequencer/checkpoint_builder.ts +0 -217
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
|
@@ -1,9 +1,376 @@
|
|
|
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, _dec1, _dec2, _dec3, _initProto;
|
|
7
374
|
import { getKzg } from '@aztec/blob-lib';
|
|
8
375
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
9
376
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
@@ -17,7 +384,7 @@ import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/ep
|
|
|
17
384
|
import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
18
385
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
19
386
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
20
|
-
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
387
|
+
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
21
388
|
import EventEmitter from 'node:events';
|
|
22
389
|
import { DefaultSequencerConfig } from '../config.js';
|
|
23
390
|
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
@@ -27,6 +394,11 @@ import { SequencerMetrics } from './metrics.js';
|
|
|
27
394
|
import { SequencerTimetable } from './timetable.js';
|
|
28
395
|
import { SequencerState } from './utils.js';
|
|
29
396
|
export { SequencerState };
|
|
397
|
+
_dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpointProposal'), _dec2 = trackSpan('Seqeuencer.tryVoteWhenSyncFails', ({ slot })=>({
|
|
398
|
+
[Attributes.SLOT_NUMBER]: slot
|
|
399
|
+
})), _dec3 = trackSpan('Sequencer.tryVoteWhenEscapeHatchOpen', ({ slot })=>({
|
|
400
|
+
[Attributes.SLOT_NUMBER]: slot
|
|
401
|
+
}));
|
|
30
402
|
/**
|
|
31
403
|
* Sequencer client
|
|
32
404
|
* - Checks whether it is elected as proposer for the next slot
|
|
@@ -50,10 +422,35 @@ export { SequencerState };
|
|
|
50
422
|
rollupContract;
|
|
51
423
|
telemetry;
|
|
52
424
|
log;
|
|
425
|
+
static{
|
|
426
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
427
|
+
[
|
|
428
|
+
_dec,
|
|
429
|
+
2,
|
|
430
|
+
"work"
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
_dec1,
|
|
434
|
+
2,
|
|
435
|
+
"prepareCheckpointProposal"
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
_dec2,
|
|
439
|
+
2,
|
|
440
|
+
"tryVoteWhenSyncFails"
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
_dec3,
|
|
444
|
+
2,
|
|
445
|
+
"tryVoteWhenEscapeHatchOpen"
|
|
446
|
+
]
|
|
447
|
+
], []));
|
|
448
|
+
}
|
|
53
449
|
runningPromise;
|
|
54
450
|
state;
|
|
55
451
|
metrics;
|
|
56
|
-
/** The last slot for which we attempted to
|
|
452
|
+
/** The last slot for which we attempted to perform our voting duties with degraded block production */ lastSlotForFallbackVote;
|
|
453
|
+
/** The last slot for which we logged "no committee" warning, to avoid spam */ lastSlotForNoCommitteeWarning;
|
|
57
454
|
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */ lastSlotForCheckpointProposalJob;
|
|
58
455
|
/** Last successful checkpoint proposed */ lastCheckpointProposed;
|
|
59
456
|
/** The last epoch for which we logged strategy comparison in fisherman mode. */ lastEpochForStrategyComparison;
|
|
@@ -67,7 +464,7 @@ export { SequencerState };
|
|
|
67
464
|
publisher;
|
|
68
465
|
/** Config for the sequencer */ config;
|
|
69
466
|
constructor(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, dateProvider, epochCache, rollupContract, config, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
|
|
70
|
-
super(), this.publisherFactory = publisherFactory, this.validatorClient = validatorClient, this.globalsBuilder = globalsBuilder, this.p2pClient = p2pClient, this.worldState = worldState, this.slasherClient = slasherClient, this.l2BlockSource = l2BlockSource, this.l1ToL2MessageSource = l1ToL2MessageSource, this.checkpointsBuilder = checkpointsBuilder, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.epochCache = epochCache, this.rollupContract = rollupContract, this.telemetry = telemetry, this.log = log, this.state = SequencerState.STOPPED, this.config = DefaultSequencerConfig;
|
|
467
|
+
super(), this.publisherFactory = publisherFactory, this.validatorClient = validatorClient, this.globalsBuilder = globalsBuilder, this.p2pClient = p2pClient, this.worldState = worldState, this.slasherClient = slasherClient, this.l2BlockSource = l2BlockSource, this.l1ToL2MessageSource = l1ToL2MessageSource, this.checkpointsBuilder = checkpointsBuilder, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.epochCache = epochCache, this.rollupContract = rollupContract, this.telemetry = telemetry, this.log = log, this.state = (_initProto(this), SequencerState.STOPPED), this.config = DefaultSequencerConfig;
|
|
71
468
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
72
469
|
if (config.fishermanMode) {
|
|
73
470
|
this.log = log.createChild('[FISHERMAN]');
|
|
@@ -112,7 +509,7 @@ export { SequencerState };
|
|
|
112
509
|
});
|
|
113
510
|
this.log.info('Stopped sequencer');
|
|
114
511
|
}
|
|
115
|
-
async safeWork() {
|
|
512
|
+
/** Main sequencer loop with a try/catch */ async safeWork() {
|
|
116
513
|
try {
|
|
117
514
|
await this.work();
|
|
118
515
|
} catch (err) {
|
|
@@ -153,7 +550,7 @@ export { SequencerState };
|
|
|
153
550
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
154
551
|
const { slot, ts, now, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
155
552
|
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
156
|
-
const checkpointProposalJob = await this.prepareCheckpointProposal(slot, ts, now);
|
|
553
|
+
const checkpointProposalJob = await this.prepareCheckpointProposal(epoch, slot, ts, now);
|
|
157
554
|
if (!checkpointProposalJob) {
|
|
158
555
|
return;
|
|
159
556
|
}
|
|
@@ -174,7 +571,7 @@ export { SequencerState };
|
|
|
174
571
|
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
175
572
|
* This is the initial step in the main loop.
|
|
176
573
|
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
177
|
-
*/ async prepareCheckpointProposal(slot, ts, now) {
|
|
574
|
+
*/ async prepareCheckpointProposal(epoch, slot, ts, now) {
|
|
178
575
|
// Check we have not already processed this slot (cheapest check)
|
|
179
576
|
// We only check this if enforce timetable is set, since we want to keep processing the same slot if we are not
|
|
180
577
|
// running against actual time (eg when we use sandbox-style automining)
|
|
@@ -199,8 +596,28 @@ export { SequencerState };
|
|
|
199
596
|
});
|
|
200
597
|
return undefined;
|
|
201
598
|
}
|
|
202
|
-
//
|
|
203
|
-
|
|
599
|
+
// If escape hatch is open for this epoch, do not start checkpoint proposal work and do not attempt invalidations.
|
|
600
|
+
// Still perform governance/slashing voting (as proposer) once per slot.
|
|
601
|
+
const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(epoch);
|
|
602
|
+
if (isEscapeHatchOpen) {
|
|
603
|
+
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
604
|
+
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
605
|
+
if (canPropose) {
|
|
606
|
+
await this.tryVoteWhenEscapeHatchOpen({
|
|
607
|
+
slot,
|
|
608
|
+
proposer
|
|
609
|
+
});
|
|
610
|
+
} else {
|
|
611
|
+
this.log.trace(`Escape hatch open but we are not proposer, skipping vote-only actions`, {
|
|
612
|
+
slot,
|
|
613
|
+
epoch,
|
|
614
|
+
proposer
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return undefined;
|
|
618
|
+
}
|
|
619
|
+
// Next checkpoint follows from the last synced one
|
|
620
|
+
const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
|
|
204
621
|
const logCtx = {
|
|
205
622
|
now,
|
|
206
623
|
syncedToL1Ts: syncedTo.l1Timestamp,
|
|
@@ -213,9 +630,9 @@ export { SequencerState };
|
|
|
213
630
|
// Check that we are a proposer for the next slot
|
|
214
631
|
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
215
632
|
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
216
|
-
// If we are not a proposer check if we should invalidate
|
|
633
|
+
// If we are not a proposer check if we should invalidate an invalid checkpoint, and bail
|
|
217
634
|
if (!canPropose) {
|
|
218
|
-
await this.
|
|
635
|
+
await this.considerInvalidatingCheckpoint(syncedTo, slot);
|
|
219
636
|
return undefined;
|
|
220
637
|
}
|
|
221
638
|
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
@@ -241,11 +658,10 @@ export { SequencerState };
|
|
|
241
658
|
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
242
659
|
}
|
|
243
660
|
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
|
|
244
|
-
|
|
245
|
-
const invalidateBlock = await publisher.simulateInvalidateBlock(syncedTo.pendingChainValidationStatus);
|
|
661
|
+
const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
246
662
|
// Check with the rollup contract if we can indeed propose at the next L2 slot. This check should not fail
|
|
247
663
|
// if all the previous checks are good, but we do it just in case.
|
|
248
|
-
const canProposeCheck = await publisher.canProposeAtNextEthBlock(syncedTo.archive, proposer ?? EthAddress.ZERO,
|
|
664
|
+
const canProposeCheck = await publisher.canProposeAtNextEthBlock(syncedTo.archive, proposer ?? EthAddress.ZERO, invalidateCheckpoint);
|
|
249
665
|
if (canProposeCheck === undefined) {
|
|
250
666
|
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`, logCtx);
|
|
251
667
|
this.emit('proposer-rollup-check-failed', {
|
|
@@ -287,10 +703,10 @@ export { SequencerState };
|
|
|
287
703
|
proposer
|
|
288
704
|
});
|
|
289
705
|
// Create and return the checkpoint proposal job
|
|
290
|
-
return this.createCheckpointProposalJob(slot, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress,
|
|
706
|
+
return this.createCheckpointProposalJob(epoch, slot, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint);
|
|
291
707
|
}
|
|
292
|
-
createCheckpointProposalJob(slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress,
|
|
293
|
-
return new CheckpointProposalJob(slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress,
|
|
708
|
+
createCheckpointProposalJob(epoch, slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint) {
|
|
709
|
+
return new CheckpointProposalJob(epoch, slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.l2BlockSource, this.checkpointsBuilder, this.l2BlockSource, this.l1Constants, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this, this.setState.bind(this), this.tracer, this.log.getBindings());
|
|
294
710
|
}
|
|
295
711
|
/**
|
|
296
712
|
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
@@ -350,14 +766,15 @@ export { SequencerState };
|
|
|
350
766
|
number: syncSummary.latestBlockNumber,
|
|
351
767
|
hash: syncSummary.latestBlockHash
|
|
352
768
|
})),
|
|
353
|
-
this.l2BlockSource.getL2Tips().then((t)=>t.
|
|
769
|
+
this.l2BlockSource.getL2Tips().then((t)=>t.proposed),
|
|
354
770
|
this.p2pClient.getStatus().then((p2p)=>p2p.syncedToL2Block),
|
|
355
|
-
this.l1ToL2MessageSource.getL2Tips().then((t)=>t.
|
|
771
|
+
this.l1ToL2MessageSource.getL2Tips().then((t)=>t.proposed),
|
|
356
772
|
this.l2BlockSource.getPendingChainValidationStatus()
|
|
357
773
|
]);
|
|
358
774
|
const [worldState, l2BlockSource, p2p, l1ToL2MessageSource, pendingChainValidationStatus] = syncedBlocks;
|
|
359
775
|
// Handle zero as a special case, since the block hash won't match across services if we're changing the prefilled data for the genesis block,
|
|
360
776
|
// as the world state can compute the new genesis block hash, but other components use the hardcoded constant.
|
|
777
|
+
// TODO(palla/mbps): Fix the above. All components should be able to handle dynamic genesis block hashes.
|
|
361
778
|
const result = l2BlockSource.number === 0 && worldState.number === 0 && p2p.number === 0 && l1ToL2MessageSource.number === 0 || worldState.hash === l2BlockSource.hash && p2p.hash === l2BlockSource.hash && l1ToL2MessageSource.hash === l2BlockSource.hash;
|
|
362
779
|
if (!result) {
|
|
363
780
|
this.log.debug(`Sequencer sync check failed`, {
|
|
@@ -373,13 +790,14 @@ export { SequencerState };
|
|
|
373
790
|
if (blockNumber < INITIAL_L2_BLOCK_NUM) {
|
|
374
791
|
const archive = new Fr((await this.worldState.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
375
792
|
return {
|
|
376
|
-
|
|
793
|
+
checkpointNumber: CheckpointNumber.ZERO,
|
|
794
|
+
blockNumber: BlockNumber.ZERO,
|
|
377
795
|
archive,
|
|
378
796
|
l1Timestamp,
|
|
379
797
|
pendingChainValidationStatus
|
|
380
798
|
};
|
|
381
799
|
}
|
|
382
|
-
const block = await this.l2BlockSource.
|
|
800
|
+
const block = await this.l2BlockSource.getL2Block(blockNumber);
|
|
383
801
|
if (!block) {
|
|
384
802
|
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
385
803
|
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
@@ -388,6 +806,7 @@ export { SequencerState };
|
|
|
388
806
|
return {
|
|
389
807
|
block,
|
|
390
808
|
blockNumber: block.number,
|
|
809
|
+
checkpointNumber: block.checkpointNumber,
|
|
391
810
|
archive: block.archive.root,
|
|
392
811
|
l1Timestamp,
|
|
393
812
|
pendingChainValidationStatus
|
|
@@ -402,7 +821,10 @@ export { SequencerState };
|
|
|
402
821
|
proposer = await this.epochCache.getProposerAttesterAddressInSlot(slot);
|
|
403
822
|
} catch (e) {
|
|
404
823
|
if (e instanceof NoCommitteeError) {
|
|
405
|
-
this.
|
|
824
|
+
if (this.lastSlotForNoCommitteeWarning !== slot) {
|
|
825
|
+
this.lastSlotForNoCommitteeWarning = slot;
|
|
826
|
+
this.log.warn(`Cannot propose at next L2 slot ${slot} since the committee does not exist on L1`);
|
|
827
|
+
}
|
|
406
828
|
return [
|
|
407
829
|
false,
|
|
408
830
|
undefined
|
|
@@ -451,7 +873,7 @@ export { SequencerState };
|
|
|
451
873
|
*/ async tryVoteWhenSyncFails(args) {
|
|
452
874
|
const { slot } = args;
|
|
453
875
|
// Prevent duplicate attempts in the same slot
|
|
454
|
-
if (this.
|
|
876
|
+
if (this.lastSlotForFallbackVote === slot) {
|
|
455
877
|
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
456
878
|
return;
|
|
457
879
|
}
|
|
@@ -481,7 +903,7 @@ export { SequencerState };
|
|
|
481
903
|
return;
|
|
482
904
|
}
|
|
483
905
|
// Mark this slot as attempted
|
|
484
|
-
this.
|
|
906
|
+
this.lastSlotForFallbackVote = slot;
|
|
485
907
|
// Get a publisher for voting
|
|
486
908
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
487
909
|
this.log.debug(`Attempting to vote despite sync failure at slot ${slot}`, {
|
|
@@ -502,24 +924,53 @@ export { SequencerState };
|
|
|
502
924
|
await publisher.sendRequests();
|
|
503
925
|
}
|
|
504
926
|
/**
|
|
927
|
+
* Tries to vote on slashing actions and governance proposals when escape hatch is open.
|
|
928
|
+
* This allows the sequencer to participate in voting without performing checkpoint proposal work.
|
|
929
|
+
*/ async tryVoteWhenEscapeHatchOpen(args) {
|
|
930
|
+
const { slot, proposer } = args;
|
|
931
|
+
// Prevent duplicate attempts in the same slot
|
|
932
|
+
if (this.lastSlotForFallbackVote === slot) {
|
|
933
|
+
this.log.trace(`Already attempted to vote in slot ${slot} (escape hatch open, skipping)`);
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
// Mark this slot as attempted
|
|
937
|
+
this.lastSlotForFallbackVote = slot;
|
|
938
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
939
|
+
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
940
|
+
slot,
|
|
941
|
+
attestorAddress
|
|
942
|
+
});
|
|
943
|
+
const voter = new CheckpointVoter(slot, publisher, attestorAddress, this.validatorClient, this.slasherClient, this.l1Constants, this.config, this.metrics, this.log);
|
|
944
|
+
const votesPromises = voter.enqueueVotes();
|
|
945
|
+
const votes = await Promise.all(votesPromises);
|
|
946
|
+
if (votes.every((p)=>!p)) {
|
|
947
|
+
this.log.debug(`No votes to enqueue for slot ${slot} (escape hatch open)`);
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
this.log.info(`Voting in slot ${slot} (escape hatch open)`, {
|
|
951
|
+
slot
|
|
952
|
+
});
|
|
953
|
+
await publisher.sendRequests();
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
505
956
|
* Considers invalidating a block if the pending chain is invalid. Depends on how long the invalid block
|
|
506
957
|
* has been there without being invalidated and whether the sequencer is in the committee or not. We always
|
|
507
958
|
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
508
959
|
* and if they fail, any sequencer will try as well.
|
|
509
|
-
*/ async
|
|
960
|
+
*/ async considerInvalidatingCheckpoint(syncedTo, currentSlot) {
|
|
510
961
|
const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
|
|
511
962
|
if (pendingChainValidationStatus.valid) {
|
|
512
963
|
return;
|
|
513
964
|
}
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(
|
|
965
|
+
const invalidCheckpointNumber = pendingChainValidationStatus.checkpoint.checkpointNumber;
|
|
966
|
+
const invalidCheckpointTimestamp = pendingChainValidationStatus.checkpoint.timestamp;
|
|
967
|
+
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidCheckpointTimestamp);
|
|
517
968
|
const ourValidatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
518
969
|
const { secondsBeforeInvalidatingBlockAsCommitteeMember, secondsBeforeInvalidatingBlockAsNonCommitteeMember } = this.config;
|
|
519
970
|
const logData = {
|
|
520
|
-
invalidL1Timestamp:
|
|
971
|
+
invalidL1Timestamp: invalidCheckpointTimestamp,
|
|
521
972
|
l1Timestamp,
|
|
522
|
-
|
|
973
|
+
invalidCheckpoint: pendingChainValidationStatus.checkpoint,
|
|
523
974
|
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
524
975
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
525
976
|
ourValidatorAddresses,
|
|
@@ -547,17 +998,17 @@ export { SequencerState };
|
|
|
547
998
|
validatorToUse = ourValidatorAddresses[0];
|
|
548
999
|
}
|
|
549
1000
|
const { publisher } = await this.publisherFactory.create(validatorToUse);
|
|
550
|
-
const
|
|
551
|
-
if (!
|
|
552
|
-
this.log.warn(`Failed to simulate invalidate
|
|
1001
|
+
const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(pendingChainValidationStatus);
|
|
1002
|
+
if (!invalidateCheckpoint) {
|
|
1003
|
+
this.log.warn(`Failed to simulate invalidate checkpoint`, logData);
|
|
553
1004
|
return;
|
|
554
1005
|
}
|
|
555
|
-
this.log.info(invalidateAsCommitteeMember ? `Invalidating
|
|
556
|
-
publisher.
|
|
1006
|
+
this.log.info(invalidateAsCommitteeMember ? `Invalidating checkpoint ${invalidCheckpointNumber} as committee member` : `Invalidating checkpoint ${invalidCheckpointNumber} as non-committee member`, logData);
|
|
1007
|
+
publisher.enqueueInvalidateCheckpoint(invalidateCheckpoint);
|
|
557
1008
|
if (!this.config.fishermanMode) {
|
|
558
1009
|
await publisher.sendRequests();
|
|
559
1010
|
} else {
|
|
560
|
-
this.log.info('Invalidating
|
|
1011
|
+
this.log.info('Invalidating checkpoint in fisherman mode, clearing pending requests');
|
|
561
1012
|
publisher.clearPendingRequests();
|
|
562
1013
|
}
|
|
563
1014
|
}
|
|
@@ -616,6 +1067,3 @@ export { SequencerState };
|
|
|
616
1067
|
return this.config.l1PublishingTime ?? this.l1Constants.ethereumSlotDuration;
|
|
617
1068
|
}
|
|
618
1069
|
}
|
|
619
|
-
_ts_decorate([
|
|
620
|
-
trackSpan('Sequencer.work')
|
|
621
|
-
], Sequencer.prototype, "safeWork", null);
|