@aztec/sequencer-client 0.0.1-commit.c7c42ec → 0.0.1-commit.cf93bcc56
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 +14 -10
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +15 -4
- package/dest/config.d.ts +3 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +22 -12
- package/dest/global_variable_builder/global_builder.d.ts +5 -7
- 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/config.d.ts +31 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +101 -42
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +13 -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 +32 -23
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +522 -88
- 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 +633 -62
- 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 +19 -7
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +131 -141
- package/dest/sequencer/sequencer.d.ts +33 -18
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +508 -66
- package/dest/sequencer/timetable.d.ts +1 -4
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +1 -4
- package/dest/test/index.d.ts +4 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +25 -11
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +52 -9
- package/dest/test/utils.d.ts +13 -9
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +27 -17
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +28 -11
- package/src/config.ts +31 -19
- package/src/global_variable_builder/global_builder.ts +14 -14
- package/src/index.ts +1 -9
- package/src/publisher/config.ts +112 -43
- package/src/publisher/sequencer-publisher-factory.ts +23 -6
- package/src/publisher/sequencer-publisher-metrics.ts +17 -69
- package/src/publisher/sequencer-publisher.ts +180 -118
- package/src/sequencer/checkpoint_proposal_job.ts +299 -91
- package/src/sequencer/checkpoint_voter.ts +32 -7
- package/src/sequencer/index.ts +0 -2
- package/src/sequencer/metrics.ts +132 -148
- package/src/sequencer/sequencer.ts +152 -68
- package/src/sequencer/timetable.ts +6 -5
- package/src/test/index.ts +3 -6
- package/src/test/mock_checkpoint_builder.ts +102 -29
- package/src/test/utils.ts +58 -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,21 +1,395 @@
|
|
|
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);
|
|
372
|
+
}
|
|
373
|
+
var _dec, _dec1, _dec2, _initProto;
|
|
1
374
|
import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
2
|
-
import { MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
|
|
375
|
+
import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
|
|
3
376
|
import { L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
|
|
4
|
-
import { WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
|
|
5
|
-
import { FormattedViemError, formatViemError, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
377
|
+
import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
|
|
378
|
+
import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
6
379
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
7
380
|
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
8
|
-
import {
|
|
381
|
+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
382
|
import { pick } from '@aztec/foundation/collection';
|
|
10
383
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
384
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
12
385
|
import { createLogger } from '@aztec/foundation/log';
|
|
386
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
13
387
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
14
388
|
import { Timer } from '@aztec/foundation/timer';
|
|
15
389
|
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
16
390
|
import { encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
17
391
|
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
18
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
392
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
19
393
|
import { encodeFunctionData, toHex } from 'viem';
|
|
20
394
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
21
395
|
export const Actions = [
|
|
@@ -31,8 +405,28 @@ export const Actions = [
|
|
|
31
405
|
];
|
|
32
406
|
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
|
|
33
407
|
export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
|
|
408
|
+
_dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader'), _dec2 = trackSpan('SequencerPublisher.validateCheckpointForSubmission');
|
|
34
409
|
export class SequencerPublisher {
|
|
35
410
|
config;
|
|
411
|
+
static{
|
|
412
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
413
|
+
[
|
|
414
|
+
_dec,
|
|
415
|
+
2,
|
|
416
|
+
"sendRequests"
|
|
417
|
+
],
|
|
418
|
+
[
|
|
419
|
+
_dec1,
|
|
420
|
+
2,
|
|
421
|
+
"validateBlockHeader"
|
|
422
|
+
],
|
|
423
|
+
[
|
|
424
|
+
_dec2,
|
|
425
|
+
2,
|
|
426
|
+
"validateCheckpointForSubmission"
|
|
427
|
+
]
|
|
428
|
+
], []));
|
|
429
|
+
}
|
|
36
430
|
interrupted;
|
|
37
431
|
metrics;
|
|
38
432
|
epochCache;
|
|
@@ -40,15 +434,13 @@ export class SequencerPublisher {
|
|
|
40
434
|
slashingLog;
|
|
41
435
|
lastActions;
|
|
42
436
|
isPayloadEmptyCache;
|
|
437
|
+
payloadProposedCache;
|
|
43
438
|
log;
|
|
44
439
|
ethereumSlotDuration;
|
|
45
440
|
blobClient;
|
|
46
441
|
/** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
|
|
47
442
|
/** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
|
|
48
|
-
|
|
49
|
-
// Total used for full block from int_l1_pub e2e test: 1m (of which 86k is 1x blob)
|
|
50
|
-
// Total used for emptier block from above test: 429k (of which 84k is 1x blob)
|
|
51
|
-
static PROPOSE_GAS_GUESS = 12_000_000n;
|
|
443
|
+
/** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
|
|
52
444
|
// A CALL to a cold address is 2700 gas
|
|
53
445
|
static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
|
|
54
446
|
// Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
|
|
@@ -58,14 +450,16 @@ export class SequencerPublisher {
|
|
|
58
450
|
govProposerContract;
|
|
59
451
|
slashingProposerContract;
|
|
60
452
|
slashFactoryContract;
|
|
453
|
+
tracer;
|
|
61
454
|
requests;
|
|
62
455
|
constructor(config, deps){
|
|
63
456
|
this.config = config;
|
|
64
|
-
this.interrupted = false;
|
|
457
|
+
this.interrupted = (_initProto(this), false);
|
|
65
458
|
this.governanceLog = createLogger('sequencer:publisher:governance');
|
|
66
459
|
this.slashingLog = createLogger('sequencer:publisher:slashing');
|
|
67
460
|
this.lastActions = {};
|
|
68
461
|
this.isPayloadEmptyCache = new Map();
|
|
462
|
+
this.payloadProposedCache = new Set();
|
|
69
463
|
this.requests = [];
|
|
70
464
|
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
71
465
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
@@ -74,6 +468,7 @@ export class SequencerPublisher {
|
|
|
74
468
|
this.blobClient = deps.blobClient;
|
|
75
469
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
76
470
|
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
471
|
+
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
77
472
|
this.l1TxUtils = deps.l1TxUtils;
|
|
78
473
|
this.rollupContract = deps.rollupContract;
|
|
79
474
|
this.govProposerContract = deps.governanceProposerContract;
|
|
@@ -88,10 +483,18 @@ export class SequencerPublisher {
|
|
|
88
483
|
if (config.fishermanMode) {
|
|
89
484
|
this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
|
|
90
485
|
}
|
|
486
|
+
// Initialize fee asset price oracle
|
|
487
|
+
this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, createLogger('sequencer:publisher:price-oracle'));
|
|
91
488
|
}
|
|
92
489
|
getRollupContract() {
|
|
93
490
|
return this.rollupContract;
|
|
94
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Gets the fee asset price modifier from the oracle.
|
|
494
|
+
* Returns 0n if the oracle query fails.
|
|
495
|
+
*/ getFeeAssetPriceModifier() {
|
|
496
|
+
return this.feeAssetPriceOracle.computePriceModifier();
|
|
497
|
+
}
|
|
95
498
|
getSenderAddress() {
|
|
96
499
|
return this.l1TxUtils.getSenderAddress();
|
|
97
500
|
}
|
|
@@ -149,7 +552,7 @@ export class SequencerPublisher {
|
|
|
149
552
|
// Get the transaction requests
|
|
150
553
|
const l1Requests = requestsToAnalyze.map((r)=>r.request);
|
|
151
554
|
// Start the analysis
|
|
152
|
-
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit :
|
|
555
|
+
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
|
|
153
556
|
this.log.info('Started L1 fee analysis', {
|
|
154
557
|
analysisId,
|
|
155
558
|
l2SlotNumber: l2SlotNumber.toString(),
|
|
@@ -207,7 +610,16 @@ export class SequencerPublisher {
|
|
|
207
610
|
const blobConfig = blobConfigs[0];
|
|
208
611
|
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
209
612
|
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
210
|
-
|
|
613
|
+
let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
614
|
+
// Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
|
|
615
|
+
const maxGas = MAX_L1_TX_LIMIT;
|
|
616
|
+
if (gasLimit !== undefined && gasLimit > maxGas) {
|
|
617
|
+
this.log.debug('Capping bundled tx gas limit to L1 max', {
|
|
618
|
+
requested: gasLimit,
|
|
619
|
+
capped: maxGas
|
|
620
|
+
});
|
|
621
|
+
gasLimit = maxGas;
|
|
622
|
+
}
|
|
211
623
|
const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
|
|
212
624
|
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
|
|
213
625
|
const txConfig = {
|
|
@@ -282,7 +694,7 @@ export class SequencerPublisher {
|
|
|
282
694
|
'InvalidArchive'
|
|
283
695
|
];
|
|
284
696
|
return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
|
|
285
|
-
forcePendingCheckpointNumber: opts.
|
|
697
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
286
698
|
}).catch((err)=>{
|
|
287
699
|
if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
|
|
288
700
|
this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
|
|
@@ -310,12 +722,11 @@ export class SequencerPublisher {
|
|
|
310
722
|
[],
|
|
311
723
|
Signature.empty().toViemSignature(),
|
|
312
724
|
`0x${'0'.repeat(64)}`,
|
|
313
|
-
header.
|
|
725
|
+
header.blobsHash.toString(),
|
|
314
726
|
flags
|
|
315
727
|
];
|
|
316
728
|
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
317
|
-
const
|
|
318
|
-
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(optsForcePendingCheckpointNumber);
|
|
729
|
+
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
|
|
319
730
|
let balance = 0n;
|
|
320
731
|
if (this.config.fishermanMode) {
|
|
321
732
|
// In fisherman mode, we can't know where the proposer is publishing from
|
|
@@ -342,34 +753,37 @@ export class SequencerPublisher {
|
|
|
342
753
|
this.log.debug(`Simulated validateHeader`);
|
|
343
754
|
}
|
|
344
755
|
/**
|
|
345
|
-
* Simulate making a call to invalidate a
|
|
346
|
-
* @param
|
|
347
|
-
*/ async
|
|
756
|
+
* Simulate making a call to invalidate a checkpoint with invalid attestations. Returns undefined if no need to invalidate.
|
|
757
|
+
* @param validationResult - The validation result indicating which checkpoint to invalidate (as returned by the archiver)
|
|
758
|
+
*/ async simulateInvalidateCheckpoint(validationResult) {
|
|
348
759
|
if (validationResult.valid) {
|
|
349
760
|
return undefined;
|
|
350
761
|
}
|
|
351
|
-
const { reason,
|
|
352
|
-
const
|
|
762
|
+
const { reason, checkpoint } = validationResult;
|
|
763
|
+
const checkpointNumber = checkpoint.checkpointNumber;
|
|
353
764
|
const logData = {
|
|
354
|
-
...
|
|
765
|
+
...checkpoint,
|
|
355
766
|
reason
|
|
356
767
|
};
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
this.log.verbose(`Skipping
|
|
360
|
-
|
|
768
|
+
const currentCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
769
|
+
if (currentCheckpointNumber < checkpointNumber) {
|
|
770
|
+
this.log.verbose(`Skipping checkpoint ${checkpointNumber} invalidation since it has already been removed from the pending chain`, {
|
|
771
|
+
currentCheckpointNumber,
|
|
361
772
|
...logData
|
|
362
773
|
});
|
|
363
774
|
return undefined;
|
|
364
775
|
}
|
|
365
|
-
const request = this.
|
|
366
|
-
this.log.debug(`Simulating invalidate
|
|
776
|
+
const request = this.buildInvalidateCheckpointRequest(validationResult);
|
|
777
|
+
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, {
|
|
367
778
|
...logData,
|
|
368
779
|
request
|
|
369
780
|
});
|
|
370
781
|
try {
|
|
371
|
-
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined,
|
|
372
|
-
|
|
782
|
+
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
|
|
783
|
+
request.abi ?? [],
|
|
784
|
+
ErrorsAbi
|
|
785
|
+
]));
|
|
786
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
373
787
|
...logData,
|
|
374
788
|
request,
|
|
375
789
|
gasUsed
|
|
@@ -377,55 +791,55 @@ export class SequencerPublisher {
|
|
|
377
791
|
return {
|
|
378
792
|
request,
|
|
379
793
|
gasUsed,
|
|
380
|
-
|
|
381
|
-
|
|
794
|
+
checkpointNumber,
|
|
795
|
+
forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
|
|
382
796
|
reason
|
|
383
797
|
};
|
|
384
798
|
} catch (err) {
|
|
385
799
|
const viemError = formatViemError(err);
|
|
386
|
-
// If the error is due to the
|
|
387
|
-
// we can safely ignore it and return undefined so we go ahead with
|
|
388
|
-
if (viemError.message?.includes('
|
|
389
|
-
this.log.verbose(`Simulation for invalidate
|
|
800
|
+
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
801
|
+
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
802
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
803
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
|
|
390
804
|
...logData,
|
|
391
805
|
request,
|
|
392
806
|
error: viemError.message
|
|
393
807
|
});
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
this.log.verbose(`
|
|
808
|
+
const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
809
|
+
if (latestPendingCheckpointNumber < checkpointNumber) {
|
|
810
|
+
this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
|
|
397
811
|
...logData
|
|
398
812
|
});
|
|
399
813
|
return undefined;
|
|
400
814
|
} else {
|
|
401
|
-
this.log.error(`Simulation for invalidate ${
|
|
402
|
-
throw new Error(`Failed to simulate invalidate
|
|
815
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed and it is still in pending chain`, viemError, logData);
|
|
816
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber} while it is still in pending chain`, {
|
|
403
817
|
cause: viemError
|
|
404
818
|
});
|
|
405
819
|
}
|
|
406
820
|
}
|
|
407
|
-
// Otherwise, throw. We cannot build the next
|
|
408
|
-
this.log.error(`Simulation for invalidate
|
|
409
|
-
throw new Error(`Failed to simulate invalidate
|
|
821
|
+
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
822
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
823
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
|
|
410
824
|
cause: viemError
|
|
411
825
|
});
|
|
412
826
|
}
|
|
413
827
|
}
|
|
414
|
-
|
|
828
|
+
buildInvalidateCheckpointRequest(validationResult) {
|
|
415
829
|
if (validationResult.valid) {
|
|
416
|
-
throw new Error('Cannot invalidate a valid
|
|
830
|
+
throw new Error('Cannot invalidate a valid checkpoint');
|
|
417
831
|
}
|
|
418
|
-
const {
|
|
832
|
+
const { checkpoint, committee, reason } = validationResult;
|
|
419
833
|
const logData = {
|
|
420
|
-
...
|
|
834
|
+
...checkpoint,
|
|
421
835
|
reason
|
|
422
836
|
};
|
|
423
|
-
this.log.debug(`
|
|
837
|
+
this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
|
|
424
838
|
const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
|
|
425
839
|
if (reason === 'invalid-attestation') {
|
|
426
|
-
return this.rollupContract.buildInvalidateBadAttestationRequest(
|
|
840
|
+
return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
|
|
427
841
|
} else if (reason === 'insufficient-attestations') {
|
|
428
|
-
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(
|
|
842
|
+
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee);
|
|
429
843
|
} else {
|
|
430
844
|
const _ = reason;
|
|
431
845
|
throw new Error(`Unknown reason for invalidation`);
|
|
@@ -433,29 +847,15 @@ export class SequencerPublisher {
|
|
|
433
847
|
}
|
|
434
848
|
/** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
|
|
435
849
|
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
436
|
-
// TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
|
|
437
|
-
// If we have no attestations, we still need to provide the empty attestations
|
|
438
|
-
// so that the committee is recalculated correctly
|
|
439
|
-
// const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
440
|
-
// if (ignoreSignatures) {
|
|
441
|
-
// const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
442
|
-
// if (!committee) {
|
|
443
|
-
// this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
444
|
-
// throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
445
|
-
// }
|
|
446
|
-
// attestationsAndSigners.attestations = committee.map(committeeMember =>
|
|
447
|
-
// CommitteeAttestation.fromAddress(committeeMember),
|
|
448
|
-
// );
|
|
449
|
-
// }
|
|
450
850
|
const blobFields = checkpoint.toBlobFields();
|
|
451
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
851
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
452
852
|
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
453
853
|
const args = [
|
|
454
854
|
{
|
|
455
855
|
header: checkpoint.header.toViem(),
|
|
456
856
|
archive: toHex(checkpoint.archive.root.toBuffer()),
|
|
457
857
|
oracleInput: {
|
|
458
|
-
feeAssetPriceModifier:
|
|
858
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
459
859
|
}
|
|
460
860
|
},
|
|
461
861
|
attestationsAndSigners.getPackedAttestations(),
|
|
@@ -490,6 +890,28 @@ export class SequencerPublisher {
|
|
|
490
890
|
this.log.warn(`Skipping vote cast for payload with empty code`);
|
|
491
891
|
return false;
|
|
492
892
|
}
|
|
893
|
+
// Check if payload was already submitted to governance
|
|
894
|
+
const cacheKey = payload.toString();
|
|
895
|
+
if (!this.payloadProposedCache.has(cacheKey)) {
|
|
896
|
+
try {
|
|
897
|
+
const l1StartBlock = await this.rollupContract.getL1StartBlock();
|
|
898
|
+
const proposed = await retry(()=>base.hasPayloadBeenProposed(payload.toString(), l1StartBlock), 'Check if payload was proposed', makeBackoff([
|
|
899
|
+
0,
|
|
900
|
+
1,
|
|
901
|
+
2
|
|
902
|
+
]), this.log, true);
|
|
903
|
+
if (proposed) {
|
|
904
|
+
this.payloadProposedCache.add(cacheKey);
|
|
905
|
+
}
|
|
906
|
+
} catch (err) {
|
|
907
|
+
this.log.warn(`Failed to check if payload ${payload} was proposed after retries, skipping signal`, err);
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
if (this.payloadProposedCache.has(cacheKey)) {
|
|
912
|
+
this.log.info(`Payload ${payload} was already proposed to governance, stopping signals`);
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
493
915
|
const cachedLastVote = this.lastActions[signalType];
|
|
494
916
|
this.lastActions[signalType] = slotNumber;
|
|
495
917
|
const action = signalType;
|
|
@@ -503,7 +925,10 @@ export class SequencerPublisher {
|
|
|
503
925
|
try {
|
|
504
926
|
await this.l1TxUtils.simulate(request, {
|
|
505
927
|
time: timestamp
|
|
506
|
-
}, [],
|
|
928
|
+
}, [], mergeAbis([
|
|
929
|
+
request.abi ?? [],
|
|
930
|
+
ErrorsAbi
|
|
931
|
+
]));
|
|
507
932
|
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
|
|
508
933
|
request
|
|
509
934
|
});
|
|
@@ -647,13 +1072,14 @@ export class SequencerPublisher {
|
|
|
647
1072
|
/** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
|
|
648
1073
|
const checkpointHeader = checkpoint.header;
|
|
649
1074
|
const blobFields = checkpoint.toBlobFields();
|
|
650
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
1075
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
651
1076
|
const proposeTxArgs = {
|
|
652
1077
|
header: checkpointHeader,
|
|
653
1078
|
archive: checkpoint.archive.root.toBuffer(),
|
|
654
1079
|
blobs,
|
|
655
1080
|
attestationsAndSigners,
|
|
656
|
-
attestationsAndSignersSignature
|
|
1081
|
+
attestationsAndSignersSignature,
|
|
1082
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
657
1083
|
};
|
|
658
1084
|
let ts;
|
|
659
1085
|
try {
|
|
@@ -667,7 +1093,7 @@ export class SequencerPublisher {
|
|
|
667
1093
|
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
668
1094
|
...checkpoint.getStats(),
|
|
669
1095
|
slotNumber: checkpoint.header.slotNumber,
|
|
670
|
-
|
|
1096
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
671
1097
|
});
|
|
672
1098
|
throw err;
|
|
673
1099
|
}
|
|
@@ -677,20 +1103,20 @@ export class SequencerPublisher {
|
|
|
677
1103
|
});
|
|
678
1104
|
await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
|
|
679
1105
|
}
|
|
680
|
-
|
|
1106
|
+
enqueueInvalidateCheckpoint(request, opts = {}) {
|
|
681
1107
|
if (!request) {
|
|
682
1108
|
return;
|
|
683
1109
|
}
|
|
684
1110
|
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
685
1111
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
|
|
686
|
-
const { gasUsed,
|
|
1112
|
+
const { gasUsed, checkpointNumber } = request;
|
|
687
1113
|
const logData = {
|
|
688
1114
|
gasUsed,
|
|
689
|
-
|
|
1115
|
+
checkpointNumber,
|
|
690
1116
|
gasLimit,
|
|
691
1117
|
opts
|
|
692
1118
|
};
|
|
693
|
-
this.log.verbose(`Enqueuing invalidate
|
|
1119
|
+
this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
|
|
694
1120
|
this.addRequest({
|
|
695
1121
|
action: `invalidate-by-${request.reason}`,
|
|
696
1122
|
request: request.request,
|
|
@@ -702,12 +1128,12 @@ export class SequencerPublisher {
|
|
|
702
1128
|
checkSuccess: (_req, result)=>{
|
|
703
1129
|
const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
|
|
704
1130
|
if (!success) {
|
|
705
|
-
this.log.warn(`Invalidate
|
|
1131
|
+
this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
|
|
706
1132
|
...result,
|
|
707
1133
|
...logData
|
|
708
1134
|
});
|
|
709
1135
|
} else {
|
|
710
|
-
this.log.info(`Invalidate
|
|
1136
|
+
this.log.info(`Invalidate checkpoint ${request.checkpointNumber} succeeded`, {
|
|
711
1137
|
...result,
|
|
712
1138
|
...logData
|
|
713
1139
|
});
|
|
@@ -730,27 +1156,37 @@ export class SequencerPublisher {
|
|
|
730
1156
|
this.lastActions[action] = slotNumber;
|
|
731
1157
|
this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
|
|
732
1158
|
let gasUsed;
|
|
1159
|
+
const simulateAbi = mergeAbis([
|
|
1160
|
+
request.abi ?? [],
|
|
1161
|
+
ErrorsAbi
|
|
1162
|
+
]);
|
|
733
1163
|
try {
|
|
734
1164
|
({ gasUsed } = await this.l1TxUtils.simulate(request, {
|
|
735
1165
|
time: timestamp
|
|
736
|
-
}, [],
|
|
1166
|
+
}, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
|
|
737
1167
|
this.log.verbose(`Simulation for ${action} succeeded`, {
|
|
738
1168
|
...logData,
|
|
739
1169
|
request,
|
|
740
1170
|
gasUsed
|
|
741
1171
|
});
|
|
742
1172
|
} catch (err) {
|
|
743
|
-
const viemError = formatViemError(err);
|
|
1173
|
+
const viemError = formatViemError(err, simulateAbi);
|
|
744
1174
|
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
745
1175
|
return false;
|
|
746
1176
|
}
|
|
747
1177
|
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
748
1178
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
|
|
749
1179
|
logData.gasLimit = gasLimit;
|
|
1180
|
+
// Store the ABI used for simulation on the request so Multicall3.forward can decode errors
|
|
1181
|
+
// when the tx is sent and a revert is diagnosed via simulation.
|
|
1182
|
+
const requestWithAbi = {
|
|
1183
|
+
...request,
|
|
1184
|
+
abi: simulateAbi
|
|
1185
|
+
};
|
|
750
1186
|
this.log.debug(`Enqueuing ${action}`, logData);
|
|
751
1187
|
this.addRequest({
|
|
752
1188
|
action,
|
|
753
|
-
request,
|
|
1189
|
+
request: requestWithAbi,
|
|
754
1190
|
gasConfig: {
|
|
755
1191
|
gasLimit
|
|
756
1192
|
},
|
|
@@ -828,8 +1264,7 @@ export class SequencerPublisher {
|
|
|
828
1264
|
header: encodedData.header.toViem(),
|
|
829
1265
|
archive: toHex(encodedData.archive),
|
|
830
1266
|
oracleInput: {
|
|
831
|
-
|
|
832
|
-
feeAssetPriceModifier: 0n
|
|
1267
|
+
feeAssetPriceModifier: encodedData.feeAssetPriceModifier
|
|
833
1268
|
}
|
|
834
1269
|
},
|
|
835
1270
|
encodedData.attestationsAndSigners.getPackedAttestations(),
|
|
@@ -857,8 +1292,7 @@ export class SequencerPublisher {
|
|
|
857
1292
|
args
|
|
858
1293
|
});
|
|
859
1294
|
// override the pending checkpoint number if requested
|
|
860
|
-
const
|
|
861
|
-
const forcePendingCheckpointNumberStateDiff = (optsForcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(optsForcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
|
|
1295
|
+
const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
|
|
862
1296
|
const stateOverrides = [
|
|
863
1297
|
{
|
|
864
1298
|
address: this.rollupContract.address,
|
|
@@ -882,7 +1316,7 @@ export class SequencerPublisher {
|
|
|
882
1316
|
const simulationResult = await this.l1TxUtils.simulate({
|
|
883
1317
|
to: this.rollupContract.address,
|
|
884
1318
|
data: rollupData,
|
|
885
|
-
gas:
|
|
1319
|
+
gas: MAX_L1_TX_LIMIT,
|
|
886
1320
|
...this.proposerAddressForSimulation && {
|
|
887
1321
|
from: this.proposerAddressForSimulation.toString()
|
|
888
1322
|
}
|
|
@@ -890,10 +1324,10 @@ export class SequencerPublisher {
|
|
|
890
1324
|
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
891
1325
|
time: timestamp + 1n,
|
|
892
1326
|
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
893
|
-
gasLimit:
|
|
1327
|
+
gasLimit: MAX_L1_TX_LIMIT * 2n
|
|
894
1328
|
}, stateOverrides, RollupAbi, {
|
|
895
1329
|
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
896
|
-
fallbackGasEstimate:
|
|
1330
|
+
fallbackGasEstimate: MAX_L1_TX_LIMIT
|
|
897
1331
|
}).catch((err)=>{
|
|
898
1332
|
// In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
|
|
899
1333
|
const viemError = formatViemError(err);
|
|
@@ -901,7 +1335,7 @@ export class SequencerPublisher {
|
|
|
901
1335
|
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
902
1336
|
// Return a minimal simulation result with the fallback gas estimate
|
|
903
1337
|
return {
|
|
904
|
-
gasUsed:
|
|
1338
|
+
gasUsed: MAX_L1_TX_LIMIT,
|
|
905
1339
|
logs: []
|
|
906
1340
|
};
|
|
907
1341
|
}
|