@aztec/sequencer-client 0.0.1-commit.5476d83 → 0.0.1-commit.5914bae
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 +25 -16
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +69 -29
- package/dest/config.d.ts +34 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +105 -44
- package/dest/global_variable_builder/global_builder.d.ts +27 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +65 -54
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- 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 +37 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +104 -39
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +14 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- 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 +76 -53
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +691 -169
- package/dest/sequencer/checkpoint_proposal_job.d.ts +102 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1247 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +106 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +38 -6
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +216 -72
- package/dest/sequencer/sequencer.d.ts +125 -133
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +733 -640
- package/dest/sequencer/timetable.d.ts +54 -16
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +147 -62
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +6 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +233 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +104 -0
- package/package.json +32 -30
- package/src/client/sequencer-client.ts +99 -53
- package/src/config.ts +121 -54
- package/src/global_variable_builder/global_builder.ts +76 -73
- package/src/global_variable_builder/index.ts +1 -1
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +122 -50
- package/src/publisher/sequencer-publisher-factory.ts +28 -10
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +406 -215
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +976 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +268 -82
- package/src/sequencer/sequencer.ts +481 -845
- package/src/sequencer/timetable.ts +178 -83
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +5 -6
- package/src/test/mock_checkpoint_builder.ts +325 -0
- package/src/test/utils.ts +167 -0
- package/dest/sequencer/block_builder.d.ts +0 -27
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- 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 -17
- 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 -222
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -132
|
@@ -1,18 +1,397 @@
|
|
|
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 {
|
|
3
|
-
import {
|
|
375
|
+
import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
|
|
376
|
+
import { L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
|
|
377
|
+
import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
|
|
378
|
+
import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
4
379
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
5
380
|
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
6
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
381
|
+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
382
|
+
import { trimmedBytesLength } from '@aztec/foundation/buffer';
|
|
383
|
+
import { pick } from '@aztec/foundation/collection';
|
|
7
384
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
385
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
9
386
|
import { createLogger } from '@aztec/foundation/log';
|
|
387
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
10
388
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
11
389
|
import { Timer } from '@aztec/foundation/timer';
|
|
12
390
|
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
13
391
|
import { encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
392
|
+
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
393
|
+
import { getLastL1SlotTimestampForL2Slot, getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
394
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
16
395
|
import { encodeFunctionData, toHex } from 'viem';
|
|
17
396
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
18
397
|
export const Actions = [
|
|
@@ -28,22 +407,44 @@ export const Actions = [
|
|
|
28
407
|
];
|
|
29
408
|
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
|
|
30
409
|
export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
|
|
410
|
+
_dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader'), _dec2 = trackSpan('SequencerPublisher.validateCheckpointForSubmission');
|
|
31
411
|
export class SequencerPublisher {
|
|
32
412
|
config;
|
|
413
|
+
static{
|
|
414
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
415
|
+
[
|
|
416
|
+
_dec,
|
|
417
|
+
2,
|
|
418
|
+
"sendRequests"
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
_dec1,
|
|
422
|
+
2,
|
|
423
|
+
"validateBlockHeader"
|
|
424
|
+
],
|
|
425
|
+
[
|
|
426
|
+
_dec2,
|
|
427
|
+
2,
|
|
428
|
+
"validateCheckpointForSubmission"
|
|
429
|
+
]
|
|
430
|
+
], []));
|
|
431
|
+
}
|
|
33
432
|
interrupted;
|
|
34
433
|
metrics;
|
|
35
434
|
epochCache;
|
|
36
435
|
governanceLog;
|
|
37
436
|
slashingLog;
|
|
38
437
|
lastActions;
|
|
438
|
+
isPayloadEmptyCache;
|
|
439
|
+
payloadProposedCache;
|
|
39
440
|
log;
|
|
40
441
|
ethereumSlotDuration;
|
|
41
|
-
|
|
442
|
+
aztecSlotDuration;
|
|
443
|
+
dateProvider;
|
|
444
|
+
blobClient;
|
|
42
445
|
/** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Total used for emptier block from above test: 429k (of which 84k is 1x blob)
|
|
46
|
-
static PROPOSE_GAS_GUESS = 12_000_000n;
|
|
446
|
+
/** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
|
|
447
|
+
/** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
|
|
47
448
|
// A CALL to a cold address is 2700 gas
|
|
48
449
|
static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
|
|
49
450
|
// Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
|
|
@@ -53,23 +454,27 @@ export class SequencerPublisher {
|
|
|
53
454
|
govProposerContract;
|
|
54
455
|
slashingProposerContract;
|
|
55
456
|
slashFactoryContract;
|
|
457
|
+
tracer;
|
|
56
458
|
requests;
|
|
57
459
|
constructor(config, deps){
|
|
58
460
|
this.config = config;
|
|
59
|
-
this.interrupted = false;
|
|
461
|
+
this.interrupted = (_initProto(this), false);
|
|
60
462
|
this.governanceLog = createLogger('sequencer:publisher:governance');
|
|
61
463
|
this.slashingLog = createLogger('sequencer:publisher:slashing');
|
|
62
464
|
this.lastActions = {};
|
|
465
|
+
this.isPayloadEmptyCache = new Map();
|
|
466
|
+
this.payloadProposedCache = new Set();
|
|
63
467
|
this.requests = [];
|
|
64
468
|
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
65
469
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
470
|
+
this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
|
|
471
|
+
this.dateProvider = deps.dateProvider;
|
|
66
472
|
this.epochCache = deps.epochCache;
|
|
67
473
|
this.lastActions = deps.lastActions;
|
|
68
|
-
this.
|
|
69
|
-
logger: createLogger('sequencer:blob-sink:client')
|
|
70
|
-
});
|
|
474
|
+
this.blobClient = deps.blobClient;
|
|
71
475
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
72
476
|
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
477
|
+
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
73
478
|
this.l1TxUtils = deps.l1TxUtils;
|
|
74
479
|
this.rollupContract = deps.rollupContract;
|
|
75
480
|
this.govProposerContract = deps.governanceProposerContract;
|
|
@@ -80,14 +485,31 @@ export class SequencerPublisher {
|
|
|
80
485
|
this.slashingProposerContract = newSlashingProposer;
|
|
81
486
|
});
|
|
82
487
|
this.slashFactoryContract = deps.slashFactoryContract;
|
|
488
|
+
// Initialize L1 fee analyzer for fisherman mode
|
|
489
|
+
if (config.fishermanMode) {
|
|
490
|
+
this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
|
|
491
|
+
}
|
|
492
|
+
// Initialize fee asset price oracle
|
|
493
|
+
this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, createLogger('sequencer:publisher:price-oracle'));
|
|
83
494
|
}
|
|
84
495
|
getRollupContract() {
|
|
85
496
|
return this.rollupContract;
|
|
86
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Gets the fee asset price modifier from the oracle.
|
|
500
|
+
* Returns 0n if the oracle query fails.
|
|
501
|
+
*/ getFeeAssetPriceModifier() {
|
|
502
|
+
return this.feeAssetPriceOracle.computePriceModifier();
|
|
503
|
+
}
|
|
87
504
|
getSenderAddress() {
|
|
88
505
|
return this.l1TxUtils.getSenderAddress();
|
|
89
506
|
}
|
|
90
507
|
/**
|
|
508
|
+
* Gets the L1 fee analyzer instance (only available in fisherman mode)
|
|
509
|
+
*/ getL1FeeAnalyzer() {
|
|
510
|
+
return this.l1FeeAnalyzer;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
91
513
|
* Sets the proposer address to use for simulations in fisherman mode.
|
|
92
514
|
* @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
|
|
93
515
|
*/ setProposerAddressForSimulation(proposerAddress) {
|
|
@@ -109,6 +531,46 @@ export class SequencerPublisher {
|
|
|
109
531
|
}
|
|
110
532
|
}
|
|
111
533
|
/**
|
|
534
|
+
* Analyzes L1 fees for the pending requests without sending them.
|
|
535
|
+
* This is used in fisherman mode to validate fee calculations.
|
|
536
|
+
* @param l2SlotNumber - The L2 slot number for this analysis
|
|
537
|
+
* @param onComplete - Optional callback to invoke when analysis completes (after block is mined)
|
|
538
|
+
* @returns The analysis result (incomplete until block mines), or undefined if no requests
|
|
539
|
+
*/ async analyzeL1Fees(l2SlotNumber, onComplete) {
|
|
540
|
+
if (!this.l1FeeAnalyzer) {
|
|
541
|
+
this.log.warn('L1 fee analyzer not available (not in fisherman mode)');
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|
|
544
|
+
const requestsToAnalyze = [
|
|
545
|
+
...this.requests
|
|
546
|
+
];
|
|
547
|
+
if (requestsToAnalyze.length === 0) {
|
|
548
|
+
this.log.debug('No requests to analyze for L1 fees');
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
// Extract blob config from requests (if any)
|
|
552
|
+
const blobConfigs = requestsToAnalyze.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
|
|
553
|
+
const blobConfig = blobConfigs[0];
|
|
554
|
+
// Get gas configs
|
|
555
|
+
const gasConfigs = requestsToAnalyze.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
556
|
+
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
557
|
+
const gasLimit = gasLimits.length > 0 ? gasLimits.reduce((sum, g)=>sum + g, 0n) : 0n;
|
|
558
|
+
// Get the transaction requests
|
|
559
|
+
const l1Requests = requestsToAnalyze.map((r)=>r.request);
|
|
560
|
+
// Start the analysis
|
|
561
|
+
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
|
|
562
|
+
this.log.info('Started L1 fee analysis', {
|
|
563
|
+
analysisId,
|
|
564
|
+
l2SlotNumber: l2SlotNumber.toString(),
|
|
565
|
+
requestCount: requestsToAnalyze.length,
|
|
566
|
+
hasBlobConfig: !!blobConfig,
|
|
567
|
+
gasLimit: gasLimit.toString(),
|
|
568
|
+
actions: requestsToAnalyze.map((r)=>r.action)
|
|
569
|
+
});
|
|
570
|
+
// Return the analysis result (will be incomplete until block mines)
|
|
571
|
+
return this.l1FeeAnalyzer.getAnalysis(analysisId);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
112
574
|
* Sends all requests that are still valid.
|
|
113
575
|
* @returns one of:
|
|
114
576
|
* - A receipt and stats if the tx succeeded
|
|
@@ -119,7 +581,7 @@ export class SequencerPublisher {
|
|
|
119
581
|
...this.requests
|
|
120
582
|
];
|
|
121
583
|
this.requests = [];
|
|
122
|
-
if (this.interrupted) {
|
|
584
|
+
if (this.interrupted || requestsToProcess.length === 0) {
|
|
123
585
|
return undefined;
|
|
124
586
|
}
|
|
125
587
|
const currentL2Slot = this.getCurrentL2Slot();
|
|
@@ -146,15 +608,24 @@ export class SequencerPublisher {
|
|
|
146
608
|
// @note - we can only have one blob config per bundle
|
|
147
609
|
// find requests with gas and blob configs
|
|
148
610
|
// See https://github.com/AztecProtocol/aztec-packages/issues/11513
|
|
149
|
-
const gasConfigs =
|
|
150
|
-
const blobConfigs =
|
|
611
|
+
const gasConfigs = validRequests.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
612
|
+
const blobConfigs = validRequests.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
|
|
151
613
|
if (blobConfigs.length > 1) {
|
|
152
614
|
throw new Error('Multiple blob configs found');
|
|
153
615
|
}
|
|
154
616
|
const blobConfig = blobConfigs[0];
|
|
155
617
|
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
156
618
|
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
157
|
-
|
|
619
|
+
let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
620
|
+
// Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
|
|
621
|
+
const maxGas = MAX_L1_TX_LIMIT;
|
|
622
|
+
if (gasLimit !== undefined && gasLimit > maxGas) {
|
|
623
|
+
this.log.debug('Capping bundled tx gas limit to L1 max', {
|
|
624
|
+
requested: gasLimit,
|
|
625
|
+
capped: maxGas
|
|
626
|
+
});
|
|
627
|
+
gasLimit = maxGas;
|
|
628
|
+
}
|
|
158
629
|
const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
|
|
159
630
|
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
|
|
160
631
|
const txConfig = {
|
|
@@ -200,7 +671,16 @@ export class SequencerPublisher {
|
|
|
200
671
|
} else {
|
|
201
672
|
this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
|
|
202
673
|
result,
|
|
203
|
-
requests
|
|
674
|
+
requests: requests.map((r)=>({
|
|
675
|
+
...r,
|
|
676
|
+
// Avoid logging large blob data
|
|
677
|
+
blobConfig: r.blobConfig ? {
|
|
678
|
+
...r.blobConfig,
|
|
679
|
+
blobs: r.blobConfig.blobs.map((b)=>({
|
|
680
|
+
size: trimmedBytesLength(b)
|
|
681
|
+
}))
|
|
682
|
+
} : undefined
|
|
683
|
+
}))
|
|
204
684
|
});
|
|
205
685
|
const successfulActions = [];
|
|
206
686
|
const failedActions = [];
|
|
@@ -218,18 +698,21 @@ export class SequencerPublisher {
|
|
|
218
698
|
}
|
|
219
699
|
}
|
|
220
700
|
/**
|
|
221
|
-
* @notice Will call `
|
|
701
|
+
* @notice Will call `canProposeAt` to make sure that it is possible to propose
|
|
222
702
|
* @param tipArchive - The archive to check
|
|
223
703
|
* @returns The slot and block number if it is possible to propose, undefined otherwise
|
|
224
|
-
*/
|
|
704
|
+
*/ canProposeAt(tipArchive, msgSender, opts = {}) {
|
|
225
705
|
// TODO: #14291 - should loop through multiple keys to check if any of them can propose
|
|
226
706
|
const ignoredErrors = [
|
|
227
707
|
'SlotAlreadyInChain',
|
|
228
708
|
'InvalidProposer',
|
|
229
709
|
'InvalidArchive'
|
|
230
710
|
];
|
|
231
|
-
|
|
232
|
-
|
|
711
|
+
const pipelined = opts.pipelined ?? false;
|
|
712
|
+
const slotOffset = pipelined ? this.aztecSlotDuration : 0n;
|
|
713
|
+
const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
|
|
714
|
+
return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, {
|
|
715
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
233
716
|
}).catch((err)=>{
|
|
234
717
|
if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
|
|
235
718
|
this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
|
|
@@ -257,11 +740,11 @@ export class SequencerPublisher {
|
|
|
257
740
|
[],
|
|
258
741
|
Signature.empty().toViemSignature(),
|
|
259
742
|
`0x${'0'.repeat(64)}`,
|
|
260
|
-
header.
|
|
743
|
+
header.blobsHash.toString(),
|
|
261
744
|
flags
|
|
262
745
|
];
|
|
263
|
-
const ts =
|
|
264
|
-
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.
|
|
746
|
+
const ts = this.getSimulationTimestamp(header.slotNumber);
|
|
747
|
+
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
|
|
265
748
|
let balance = 0n;
|
|
266
749
|
if (this.config.fishermanMode) {
|
|
267
750
|
// In fisherman mode, we can't know where the proposer is publishing from
|
|
@@ -283,39 +766,42 @@ export class SequencerPublisher {
|
|
|
283
766
|
}),
|
|
284
767
|
from: MULTI_CALL_3_ADDRESS
|
|
285
768
|
}, {
|
|
286
|
-
time: ts
|
|
769
|
+
time: ts
|
|
287
770
|
}, stateOverrides);
|
|
288
771
|
this.log.debug(`Simulated validateHeader`);
|
|
289
772
|
}
|
|
290
773
|
/**
|
|
291
|
-
* Simulate making a call to invalidate a
|
|
292
|
-
* @param
|
|
293
|
-
*/ async
|
|
774
|
+
* Simulate making a call to invalidate a checkpoint with invalid attestations. Returns undefined if no need to invalidate.
|
|
775
|
+
* @param validationResult - The validation result indicating which checkpoint to invalidate (as returned by the archiver)
|
|
776
|
+
*/ async simulateInvalidateCheckpoint(validationResult) {
|
|
294
777
|
if (validationResult.valid) {
|
|
295
778
|
return undefined;
|
|
296
779
|
}
|
|
297
|
-
const { reason,
|
|
298
|
-
const
|
|
780
|
+
const { reason, checkpoint } = validationResult;
|
|
781
|
+
const checkpointNumber = checkpoint.checkpointNumber;
|
|
299
782
|
const logData = {
|
|
300
|
-
...
|
|
783
|
+
...checkpoint,
|
|
301
784
|
reason
|
|
302
785
|
};
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
this.log.verbose(`Skipping
|
|
306
|
-
|
|
786
|
+
const currentCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
787
|
+
if (currentCheckpointNumber < checkpointNumber) {
|
|
788
|
+
this.log.verbose(`Skipping checkpoint ${checkpointNumber} invalidation since it has already been removed from the pending chain`, {
|
|
789
|
+
currentCheckpointNumber,
|
|
307
790
|
...logData
|
|
308
791
|
});
|
|
309
792
|
return undefined;
|
|
310
793
|
}
|
|
311
|
-
const request = this.
|
|
312
|
-
this.log.debug(`Simulating invalidate
|
|
794
|
+
const request = this.buildInvalidateCheckpointRequest(validationResult);
|
|
795
|
+
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, {
|
|
313
796
|
...logData,
|
|
314
797
|
request
|
|
315
798
|
});
|
|
316
799
|
try {
|
|
317
|
-
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined,
|
|
318
|
-
|
|
800
|
+
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
|
|
801
|
+
request.abi ?? [],
|
|
802
|
+
ErrorsAbi
|
|
803
|
+
]));
|
|
804
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
319
805
|
...logData,
|
|
320
806
|
request,
|
|
321
807
|
gasUsed
|
|
@@ -323,90 +809,70 @@ export class SequencerPublisher {
|
|
|
323
809
|
return {
|
|
324
810
|
request,
|
|
325
811
|
gasUsed,
|
|
326
|
-
|
|
327
|
-
|
|
812
|
+
checkpointNumber,
|
|
813
|
+
forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
|
|
328
814
|
reason
|
|
329
815
|
};
|
|
330
816
|
} catch (err) {
|
|
331
817
|
const viemError = formatViemError(err);
|
|
332
|
-
// If the error is due to the
|
|
333
|
-
// we can safely ignore it and return undefined so we go ahead with
|
|
334
|
-
if (viemError.message?.includes('
|
|
335
|
-
this.log.verbose(`Simulation for invalidate
|
|
818
|
+
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
819
|
+
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
820
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
821
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
|
|
336
822
|
...logData,
|
|
337
823
|
request,
|
|
338
824
|
error: viemError.message
|
|
339
825
|
});
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
this.log.verbose(`
|
|
826
|
+
const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
827
|
+
if (latestPendingCheckpointNumber < checkpointNumber) {
|
|
828
|
+
this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
|
|
343
829
|
...logData
|
|
344
830
|
});
|
|
345
831
|
return undefined;
|
|
346
832
|
} else {
|
|
347
|
-
this.log.error(`Simulation for invalidate ${
|
|
348
|
-
throw new Error(`Failed to simulate invalidate
|
|
833
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed and it is still in pending chain`, viemError, logData);
|
|
834
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber} while it is still in pending chain`, {
|
|
349
835
|
cause: viemError
|
|
350
836
|
});
|
|
351
837
|
}
|
|
352
838
|
}
|
|
353
|
-
// Otherwise, throw. We cannot build the next
|
|
354
|
-
this.log.error(`Simulation for invalidate
|
|
355
|
-
throw new Error(`Failed to simulate invalidate
|
|
839
|
+
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
840
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
841
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
|
|
356
842
|
cause: viemError
|
|
357
843
|
});
|
|
358
844
|
}
|
|
359
845
|
}
|
|
360
|
-
|
|
846
|
+
buildInvalidateCheckpointRequest(validationResult) {
|
|
361
847
|
if (validationResult.valid) {
|
|
362
|
-
throw new Error('Cannot invalidate a valid
|
|
848
|
+
throw new Error('Cannot invalidate a valid checkpoint');
|
|
363
849
|
}
|
|
364
|
-
const {
|
|
850
|
+
const { checkpoint, committee, reason } = validationResult;
|
|
365
851
|
const logData = {
|
|
366
|
-
...
|
|
852
|
+
...checkpoint,
|
|
367
853
|
reason
|
|
368
854
|
};
|
|
369
|
-
this.log.debug(`
|
|
855
|
+
this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
|
|
370
856
|
const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
|
|
371
857
|
if (reason === 'invalid-attestation') {
|
|
372
|
-
return this.rollupContract.buildInvalidateBadAttestationRequest(
|
|
858
|
+
return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
|
|
373
859
|
} else if (reason === 'insufficient-attestations') {
|
|
374
|
-
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(
|
|
860
|
+
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee);
|
|
375
861
|
} else {
|
|
376
862
|
const _ = reason;
|
|
377
863
|
throw new Error(`Unknown reason for invalidation`);
|
|
378
864
|
}
|
|
379
865
|
}
|
|
380
|
-
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
* @dev Throws if unable to propose
|
|
384
|
-
*
|
|
385
|
-
* @param block - The block to propose
|
|
386
|
-
* @param attestationData - The block's attestation data
|
|
387
|
-
*
|
|
388
|
-
*/ async validateBlockForSubmission(block, attestationsAndSigners, attestationsAndSignersSignature, options) {
|
|
389
|
-
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
390
|
-
// If we have no attestations, we still need to provide the empty attestations
|
|
391
|
-
// so that the committee is recalculated correctly
|
|
392
|
-
const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
393
|
-
if (ignoreSignatures) {
|
|
394
|
-
const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
395
|
-
if (!committee) {
|
|
396
|
-
this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
397
|
-
throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
398
|
-
}
|
|
399
|
-
attestationsAndSigners.attestations = committee.map((committeeMember)=>CommitteeAttestation.fromAddress(committeeMember));
|
|
400
|
-
}
|
|
401
|
-
const blobFields = block.getCheckpointBlobFields();
|
|
402
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
866
|
+
/** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
|
|
867
|
+
const blobFields = checkpoint.toBlobFields();
|
|
868
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
403
869
|
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
404
870
|
const args = [
|
|
405
871
|
{
|
|
406
|
-
header:
|
|
407
|
-
archive: toHex(
|
|
872
|
+
header: checkpoint.header.toViem(),
|
|
873
|
+
archive: toHex(checkpoint.archive.root.toBuffer()),
|
|
408
874
|
oracleInput: {
|
|
409
|
-
feeAssetPriceModifier:
|
|
875
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
410
876
|
}
|
|
411
877
|
},
|
|
412
878
|
attestationsAndSigners.getPackedAttestations(),
|
|
@@ -414,10 +880,9 @@ export class SequencerPublisher {
|
|
|
414
880
|
attestationsAndSignersSignature.toViemSignature(),
|
|
415
881
|
blobInput
|
|
416
882
|
];
|
|
417
|
-
await this.simulateProposeTx(args,
|
|
418
|
-
return ts;
|
|
883
|
+
await this.simulateProposeTx(args, options);
|
|
419
884
|
}
|
|
420
|
-
async enqueueCastSignalHelper(slotNumber,
|
|
885
|
+
async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
|
|
421
886
|
if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
|
|
422
887
|
this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
|
|
423
888
|
return false;
|
|
@@ -431,9 +896,38 @@ export class SequencerPublisher {
|
|
|
431
896
|
}
|
|
432
897
|
const round = await base.computeRound(slotNumber);
|
|
433
898
|
const roundInfo = await base.getRoundInfo(this.rollupContract.address, round);
|
|
899
|
+
if (roundInfo.quorumReached) {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
434
902
|
if (roundInfo.lastSignalSlot >= slotNumber) {
|
|
435
903
|
return false;
|
|
436
904
|
}
|
|
905
|
+
if (await this.isPayloadEmpty(payload)) {
|
|
906
|
+
this.log.warn(`Skipping vote cast for payload with empty code`);
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
// Check if payload was already submitted to governance
|
|
910
|
+
const cacheKey = payload.toString();
|
|
911
|
+
if (!this.payloadProposedCache.has(cacheKey)) {
|
|
912
|
+
try {
|
|
913
|
+
const l1StartBlock = await this.rollupContract.getL1StartBlock();
|
|
914
|
+
const proposed = await retry(()=>base.hasPayloadBeenProposed(payload.toString(), l1StartBlock), 'Check if payload was proposed', makeBackoff([
|
|
915
|
+
0,
|
|
916
|
+
1,
|
|
917
|
+
2
|
|
918
|
+
]), this.log, true);
|
|
919
|
+
if (proposed) {
|
|
920
|
+
this.payloadProposedCache.add(cacheKey);
|
|
921
|
+
}
|
|
922
|
+
} catch (err) {
|
|
923
|
+
this.log.warn(`Failed to check if payload ${payload} was proposed after retries, skipping signal`, err);
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (this.payloadProposedCache.has(cacheKey)) {
|
|
928
|
+
this.log.info(`Payload ${payload} was already proposed to governance, stopping signals`);
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
437
931
|
const cachedLastVote = this.lastActions[signalType];
|
|
438
932
|
this.lastActions[signalType] = slotNumber;
|
|
439
933
|
const action = signalType;
|
|
@@ -444,15 +938,22 @@ export class SequencerPublisher {
|
|
|
444
938
|
signer: this.l1TxUtils.client.account?.address,
|
|
445
939
|
lastValidL2Slot: slotNumber
|
|
446
940
|
});
|
|
941
|
+
const timestamp = this.getSimulationTimestamp(slotNumber);
|
|
447
942
|
try {
|
|
448
943
|
await this.l1TxUtils.simulate(request, {
|
|
449
944
|
time: timestamp
|
|
450
|
-
}, [],
|
|
945
|
+
}, [], mergeAbis([
|
|
946
|
+
request.abi ?? [],
|
|
947
|
+
ErrorsAbi
|
|
948
|
+
]));
|
|
451
949
|
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
|
|
452
950
|
request
|
|
453
951
|
});
|
|
454
952
|
} catch (err) {
|
|
455
|
-
|
|
953
|
+
const viemError = formatViemError(err);
|
|
954
|
+
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError, {
|
|
955
|
+
simulationTimestamp: timestamp
|
|
956
|
+
});
|
|
456
957
|
// Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
|
|
457
958
|
}
|
|
458
959
|
// TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
|
|
@@ -472,26 +973,35 @@ export class SequencerPublisher {
|
|
|
472
973
|
payload: payload.toString()
|
|
473
974
|
};
|
|
474
975
|
if (!success) {
|
|
475
|
-
this.log.error(`Signaling in
|
|
976
|
+
this.log.error(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} failed`, logData);
|
|
476
977
|
this.lastActions[signalType] = cachedLastVote;
|
|
477
978
|
return false;
|
|
478
979
|
} else {
|
|
479
|
-
this.log.info(`Signaling in
|
|
980
|
+
this.log.info(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} succeeded`, logData);
|
|
480
981
|
return true;
|
|
481
982
|
}
|
|
482
983
|
}
|
|
483
984
|
});
|
|
484
985
|
return true;
|
|
485
986
|
}
|
|
987
|
+
async isPayloadEmpty(payload) {
|
|
988
|
+
const key = payload.toString();
|
|
989
|
+
const cached = this.isPayloadEmptyCache.get(key);
|
|
990
|
+
if (cached) {
|
|
991
|
+
return cached;
|
|
992
|
+
}
|
|
993
|
+
const isEmpty = !await this.l1TxUtils.getCode(payload);
|
|
994
|
+
this.isPayloadEmptyCache.set(key, isEmpty);
|
|
995
|
+
return isEmpty;
|
|
996
|
+
}
|
|
486
997
|
/**
|
|
487
998
|
* Enqueues a governance castSignal transaction to cast a signal for a given slot number.
|
|
488
999
|
* @param slotNumber - The slot number to cast a signal for.
|
|
489
|
-
* @param timestamp - The timestamp of the slot to cast a signal for.
|
|
490
1000
|
* @returns True if the signal was successfully enqueued, false otherwise.
|
|
491
|
-
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber,
|
|
492
|
-
return this.enqueueCastSignalHelper(slotNumber,
|
|
1001
|
+
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
|
|
1002
|
+
return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
|
|
493
1003
|
}
|
|
494
|
-
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber,
|
|
1004
|
+
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
|
|
495
1005
|
if (actions.length === 0) {
|
|
496
1006
|
this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
|
|
497
1007
|
return false;
|
|
@@ -507,7 +1017,7 @@ export class SequencerPublisher {
|
|
|
507
1017
|
this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
|
|
508
1018
|
signerAddress
|
|
509
1019
|
});
|
|
510
|
-
await this.enqueueCastSignalHelper(slotNumber,
|
|
1020
|
+
await this.enqueueCastSignalHelper(slotNumber, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
|
|
511
1021
|
break;
|
|
512
1022
|
}
|
|
513
1023
|
case 'create-empire-payload':
|
|
@@ -517,7 +1027,7 @@ export class SequencerPublisher {
|
|
|
517
1027
|
signerAddress
|
|
518
1028
|
});
|
|
519
1029
|
const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
|
|
520
|
-
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber
|
|
1030
|
+
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber);
|
|
521
1031
|
break;
|
|
522
1032
|
}
|
|
523
1033
|
case 'execute-empire-payload':
|
|
@@ -532,7 +1042,7 @@ export class SequencerPublisher {
|
|
|
532
1042
|
}
|
|
533
1043
|
const empireSlashingProposer = this.slashingProposerContract;
|
|
534
1044
|
const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
|
|
535
|
-
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber
|
|
1045
|
+
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber);
|
|
536
1046
|
break;
|
|
537
1047
|
}
|
|
538
1048
|
case 'vote-offenses':
|
|
@@ -550,7 +1060,7 @@ export class SequencerPublisher {
|
|
|
550
1060
|
const tallySlashingProposer = this.slashingProposerContract;
|
|
551
1061
|
const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
|
|
552
1062
|
const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
|
|
553
|
-
await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber
|
|
1063
|
+
await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber);
|
|
554
1064
|
break;
|
|
555
1065
|
}
|
|
556
1066
|
case 'execute-slash':
|
|
@@ -566,7 +1076,7 @@ export class SequencerPublisher {
|
|
|
566
1076
|
}
|
|
567
1077
|
const tallySlashingProposer = this.slashingProposerContract;
|
|
568
1078
|
const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
|
|
569
|
-
await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber
|
|
1079
|
+
await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber);
|
|
570
1080
|
break;
|
|
571
1081
|
}
|
|
572
1082
|
default:
|
|
@@ -578,60 +1088,53 @@ export class SequencerPublisher {
|
|
|
578
1088
|
}
|
|
579
1089
|
return true;
|
|
580
1090
|
}
|
|
581
|
-
/**
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
* @returns True if the tx has been enqueued, throws otherwise. See #9315
|
|
586
|
-
*/ async enqueueProposeL2Block(block, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
|
|
587
|
-
const checkpointHeader = block.getCheckpointHeader();
|
|
588
|
-
const blobFields = block.getCheckpointBlobFields();
|
|
589
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
1091
|
+
/** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
|
|
1092
|
+
const checkpointHeader = checkpoint.header;
|
|
1093
|
+
const blobFields = checkpoint.toBlobFields();
|
|
1094
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
590
1095
|
const proposeTxArgs = {
|
|
591
1096
|
header: checkpointHeader,
|
|
592
|
-
archive:
|
|
593
|
-
body: block.body.toBuffer(),
|
|
1097
|
+
archive: checkpoint.archive.root.toBuffer(),
|
|
594
1098
|
blobs,
|
|
595
1099
|
attestationsAndSigners,
|
|
596
|
-
attestationsAndSignersSignature
|
|
1100
|
+
attestationsAndSignersSignature,
|
|
1101
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
597
1102
|
};
|
|
598
|
-
let ts;
|
|
599
1103
|
try {
|
|
600
1104
|
// @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
|
|
601
1105
|
// This means that we can avoid the simulation issues in later checks.
|
|
602
1106
|
// By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
|
|
603
1107
|
// make time consistency checks break.
|
|
604
1108
|
// TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
|
|
605
|
-
|
|
1109
|
+
await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
|
|
606
1110
|
} catch (err) {
|
|
607
|
-
this.log.error(`
|
|
608
|
-
...
|
|
609
|
-
slotNumber:
|
|
610
|
-
|
|
1111
|
+
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
1112
|
+
...checkpoint.getStats(),
|
|
1113
|
+
slotNumber: checkpoint.header.slotNumber,
|
|
1114
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
611
1115
|
});
|
|
612
1116
|
throw err;
|
|
613
1117
|
}
|
|
614
|
-
this.log.verbose(`Enqueuing
|
|
615
|
-
...
|
|
1118
|
+
this.log.verbose(`Enqueuing checkpoint propose transaction`, {
|
|
1119
|
+
...checkpoint.toCheckpointInfo(),
|
|
616
1120
|
...opts
|
|
617
1121
|
});
|
|
618
|
-
await this.addProposeTx(
|
|
619
|
-
return true;
|
|
1122
|
+
await this.addProposeTx(checkpoint, proposeTxArgs, opts);
|
|
620
1123
|
}
|
|
621
|
-
|
|
1124
|
+
enqueueInvalidateCheckpoint(request, opts = {}) {
|
|
622
1125
|
if (!request) {
|
|
623
1126
|
return;
|
|
624
1127
|
}
|
|
625
1128
|
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
626
1129
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
|
|
627
|
-
const { gasUsed,
|
|
1130
|
+
const { gasUsed, checkpointNumber } = request;
|
|
628
1131
|
const logData = {
|
|
629
1132
|
gasUsed,
|
|
630
|
-
|
|
1133
|
+
checkpointNumber,
|
|
631
1134
|
gasLimit,
|
|
632
1135
|
opts
|
|
633
1136
|
};
|
|
634
|
-
this.log.verbose(`Enqueuing invalidate
|
|
1137
|
+
this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
|
|
635
1138
|
this.addRequest({
|
|
636
1139
|
action: `invalidate-by-${request.reason}`,
|
|
637
1140
|
request: request.request,
|
|
@@ -643,12 +1146,12 @@ export class SequencerPublisher {
|
|
|
643
1146
|
checkSuccess: (_req, result)=>{
|
|
644
1147
|
const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
|
|
645
1148
|
if (!success) {
|
|
646
|
-
this.log.warn(`Invalidate
|
|
1149
|
+
this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
|
|
647
1150
|
...result,
|
|
648
1151
|
...logData
|
|
649
1152
|
});
|
|
650
1153
|
} else {
|
|
651
|
-
this.log.info(`Invalidate
|
|
1154
|
+
this.log.info(`Invalidate checkpoint ${request.checkpointNumber} succeeded`, {
|
|
652
1155
|
...result,
|
|
653
1156
|
...logData
|
|
654
1157
|
});
|
|
@@ -657,7 +1160,8 @@ export class SequencerPublisher {
|
|
|
657
1160
|
}
|
|
658
1161
|
});
|
|
659
1162
|
}
|
|
660
|
-
async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber
|
|
1163
|
+
async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber) {
|
|
1164
|
+
const timestamp = this.getSimulationTimestamp(slotNumber);
|
|
661
1165
|
const logData = {
|
|
662
1166
|
slotNumber,
|
|
663
1167
|
timestamp,
|
|
@@ -671,27 +1175,37 @@ export class SequencerPublisher {
|
|
|
671
1175
|
this.lastActions[action] = slotNumber;
|
|
672
1176
|
this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
|
|
673
1177
|
let gasUsed;
|
|
1178
|
+
const simulateAbi = mergeAbis([
|
|
1179
|
+
request.abi ?? [],
|
|
1180
|
+
ErrorsAbi
|
|
1181
|
+
]);
|
|
674
1182
|
try {
|
|
675
1183
|
({ gasUsed } = await this.l1TxUtils.simulate(request, {
|
|
676
1184
|
time: timestamp
|
|
677
|
-
}, [],
|
|
1185
|
+
}, [], simulateAbi));
|
|
678
1186
|
this.log.verbose(`Simulation for ${action} succeeded`, {
|
|
679
1187
|
...logData,
|
|
680
1188
|
request,
|
|
681
1189
|
gasUsed
|
|
682
1190
|
});
|
|
683
1191
|
} catch (err) {
|
|
684
|
-
const viemError = formatViemError(err);
|
|
1192
|
+
const viemError = formatViemError(err, simulateAbi);
|
|
685
1193
|
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
686
1194
|
return false;
|
|
687
1195
|
}
|
|
688
1196
|
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
689
1197
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
|
|
690
1198
|
logData.gasLimit = gasLimit;
|
|
1199
|
+
// Store the ABI used for simulation on the request so Multicall3.forward can decode errors
|
|
1200
|
+
// when the tx is sent and a revert is diagnosed via simulation.
|
|
1201
|
+
const requestWithAbi = {
|
|
1202
|
+
...request,
|
|
1203
|
+
abi: simulateAbi
|
|
1204
|
+
};
|
|
691
1205
|
this.log.debug(`Enqueuing ${action}`, logData);
|
|
692
1206
|
this.addRequest({
|
|
693
1207
|
action,
|
|
694
|
-
request,
|
|
1208
|
+
request: requestWithAbi,
|
|
695
1209
|
gasConfig: {
|
|
696
1210
|
gasLimit
|
|
697
1211
|
},
|
|
@@ -728,7 +1242,7 @@ export class SequencerPublisher {
|
|
|
728
1242
|
this.interrupted = false;
|
|
729
1243
|
this.l1TxUtils.restart();
|
|
730
1244
|
}
|
|
731
|
-
async prepareProposeTx(encodedData,
|
|
1245
|
+
async prepareProposeTx(encodedData, options) {
|
|
732
1246
|
const kzg = Blob.getViemKzgInstance();
|
|
733
1247
|
const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
|
|
734
1248
|
this.log.debug('Validating blob input', {
|
|
@@ -769,8 +1283,7 @@ export class SequencerPublisher {
|
|
|
769
1283
|
header: encodedData.header.toViem(),
|
|
770
1284
|
archive: toHex(encodedData.archive),
|
|
771
1285
|
oracleInput: {
|
|
772
|
-
|
|
773
|
-
feeAssetPriceModifier: 0n
|
|
1286
|
+
feeAssetPriceModifier: encodedData.feeAssetPriceModifier
|
|
774
1287
|
}
|
|
775
1288
|
},
|
|
776
1289
|
encodedData.attestationsAndSigners.getPackedAttestations(),
|
|
@@ -778,7 +1291,7 @@ export class SequencerPublisher {
|
|
|
778
1291
|
encodedData.attestationsAndSignersSignature.toViemSignature(),
|
|
779
1292
|
blobInput
|
|
780
1293
|
];
|
|
781
|
-
const { rollupData, simulationResult } = await this.simulateProposeTx(args,
|
|
1294
|
+
const { rollupData, simulationResult } = await this.simulateProposeTx(args, options);
|
|
782
1295
|
return {
|
|
783
1296
|
args,
|
|
784
1297
|
blobEvaluationGas,
|
|
@@ -789,16 +1302,15 @@ export class SequencerPublisher {
|
|
|
789
1302
|
/**
|
|
790
1303
|
* Simulates the propose tx with eth_simulateV1
|
|
791
1304
|
* @param args - The propose tx args
|
|
792
|
-
* @param timestamp - The timestamp to simulate proposal at
|
|
793
1305
|
* @returns The simulation result
|
|
794
|
-
*/ async simulateProposeTx(args,
|
|
1306
|
+
*/ async simulateProposeTx(args, options) {
|
|
795
1307
|
const rollupData = encodeFunctionData({
|
|
796
1308
|
abi: RollupAbi,
|
|
797
1309
|
functionName: 'propose',
|
|
798
1310
|
args
|
|
799
1311
|
});
|
|
800
|
-
// override the pending
|
|
801
|
-
const
|
|
1312
|
+
// override the pending checkpoint number if requested
|
|
1313
|
+
const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
|
|
802
1314
|
const stateOverrides = [
|
|
803
1315
|
{
|
|
804
1316
|
address: this.rollupContract.address,
|
|
@@ -808,7 +1320,7 @@ export class SequencerPublisher {
|
|
|
808
1320
|
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
809
1321
|
value: toPaddedHex(0n, true)
|
|
810
1322
|
},
|
|
811
|
-
...
|
|
1323
|
+
...forcePendingCheckpointNumberStateDiff
|
|
812
1324
|
]
|
|
813
1325
|
}
|
|
814
1326
|
];
|
|
@@ -819,21 +1331,21 @@ export class SequencerPublisher {
|
|
|
819
1331
|
balance: 10n * WEI_CONST * WEI_CONST
|
|
820
1332
|
});
|
|
821
1333
|
}
|
|
1334
|
+
const simTs = this.getSimulationTimestamp(SlotNumber.fromBigInt(args[0].header.slotNumber));
|
|
822
1335
|
const simulationResult = await this.l1TxUtils.simulate({
|
|
823
1336
|
to: this.rollupContract.address,
|
|
824
1337
|
data: rollupData,
|
|
825
|
-
gas:
|
|
1338
|
+
gas: MAX_L1_TX_LIMIT,
|
|
826
1339
|
...this.proposerAddressForSimulation && {
|
|
827
1340
|
from: this.proposerAddressForSimulation.toString()
|
|
828
1341
|
}
|
|
829
1342
|
}, {
|
|
830
|
-
|
|
831
|
-
time: timestamp + 1n,
|
|
1343
|
+
time: simTs,
|
|
832
1344
|
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
833
|
-
gasLimit:
|
|
1345
|
+
gasLimit: MAX_L1_TX_LIMIT * 2n
|
|
834
1346
|
}, stateOverrides, RollupAbi, {
|
|
835
1347
|
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
836
|
-
fallbackGasEstimate:
|
|
1348
|
+
fallbackGasEstimate: MAX_L1_TX_LIMIT
|
|
837
1349
|
}).catch((err)=>{
|
|
838
1350
|
// In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
|
|
839
1351
|
const viemError = formatViemError(err);
|
|
@@ -841,11 +1353,13 @@ export class SequencerPublisher {
|
|
|
841
1353
|
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
842
1354
|
// Return a minimal simulation result with the fallback gas estimate
|
|
843
1355
|
return {
|
|
844
|
-
gasUsed:
|
|
1356
|
+
gasUsed: MAX_L1_TX_LIMIT,
|
|
845
1357
|
logs: []
|
|
846
1358
|
};
|
|
847
1359
|
}
|
|
848
|
-
this.log.error(`Failed to simulate propose tx`, viemError
|
|
1360
|
+
this.log.error(`Failed to simulate propose tx`, viemError, {
|
|
1361
|
+
simulationTimestamp: simTs
|
|
1362
|
+
});
|
|
849
1363
|
throw err;
|
|
850
1364
|
});
|
|
851
1365
|
return {
|
|
@@ -853,24 +1367,25 @@ export class SequencerPublisher {
|
|
|
853
1367
|
simulationResult
|
|
854
1368
|
};
|
|
855
1369
|
}
|
|
856
|
-
async addProposeTx(
|
|
1370
|
+
async addProposeTx(checkpoint, encodedData, opts = {}) {
|
|
1371
|
+
const slot = checkpoint.header.slotNumber;
|
|
857
1372
|
const timer = new Timer();
|
|
858
1373
|
const kzg = Blob.getViemKzgInstance();
|
|
859
|
-
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData,
|
|
1374
|
+
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, opts);
|
|
860
1375
|
const startBlock = await this.l1TxUtils.getBlockNumber();
|
|
861
1376
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
|
|
862
|
-
// Send the blobs to the blob
|
|
863
|
-
// tx fails but it does get mined. We make sure that the blobs are sent to the blob
|
|
864
|
-
void this.
|
|
865
|
-
|
|
866
|
-
|
|
1377
|
+
// Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
|
|
1378
|
+
// tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
|
|
1379
|
+
void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
|
|
1380
|
+
this.log.error('Failed to send blobs to blob client');
|
|
1381
|
+
}));
|
|
867
1382
|
return this.addRequest({
|
|
868
1383
|
action: 'propose',
|
|
869
1384
|
request: {
|
|
870
1385
|
to: this.rollupContract.address,
|
|
871
1386
|
data: rollupData
|
|
872
1387
|
},
|
|
873
|
-
lastValidL2Slot:
|
|
1388
|
+
lastValidL2Slot: checkpoint.header.slotNumber,
|
|
874
1389
|
gasConfig: {
|
|
875
1390
|
...opts,
|
|
876
1391
|
gasLimit
|
|
@@ -898,29 +1413,36 @@ export class SequencerPublisher {
|
|
|
898
1413
|
calldataGas,
|
|
899
1414
|
calldataSize,
|
|
900
1415
|
sender,
|
|
901
|
-
...
|
|
1416
|
+
...checkpoint.getStats(),
|
|
902
1417
|
eventName: 'rollup-published-to-l1',
|
|
903
1418
|
blobCount: encodedData.blobs.length,
|
|
904
1419
|
inclusionBlocks
|
|
905
1420
|
};
|
|
906
|
-
this.log.info(`Published
|
|
1421
|
+
this.log.info(`Published checkpoint ${checkpoint.number} at slot ${slot} to rollup contract`, {
|
|
907
1422
|
...stats,
|
|
908
|
-
...
|
|
909
|
-
...receipt
|
|
1423
|
+
...checkpoint.getStats(),
|
|
1424
|
+
...pick(receipt, 'transactionHash', 'blockHash')
|
|
910
1425
|
});
|
|
911
1426
|
this.metrics.recordProcessBlockTx(timer.ms(), publishStats);
|
|
912
1427
|
return true;
|
|
913
1428
|
} else {
|
|
914
1429
|
this.metrics.recordFailedTx('process');
|
|
915
|
-
this.log.error(`
|
|
916
|
-
...
|
|
917
|
-
receipt
|
|
918
|
-
txHash: receipt.transactionHash,
|
|
919
|
-
slotNumber: block.header.globalVariables.slotNumber
|
|
1430
|
+
this.log.error(`Publishing checkpoint at slot ${slot} failed with ${errorMsg ?? 'no error message'}`, undefined, {
|
|
1431
|
+
...checkpoint.getStats(),
|
|
1432
|
+
...receipt
|
|
920
1433
|
});
|
|
921
1434
|
return false;
|
|
922
1435
|
}
|
|
923
1436
|
}
|
|
924
1437
|
});
|
|
925
1438
|
}
|
|
1439
|
+
/** Returns the timestamp of the last L1 slot within a given L2 slot. Used as the simulation timestamp
|
|
1440
|
+
* for eth_simulateV1 calls, since it's guaranteed to be greater than any L1 block produced during the slot. */ getSimulationTimestamp(slot) {
|
|
1441
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1442
|
+
return getLastL1SlotTimestampForL2Slot(slot, l1Constants);
|
|
1443
|
+
}
|
|
1444
|
+
/** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
|
|
1445
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1446
|
+
return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
|
|
1447
|
+
}
|
|
926
1448
|
}
|