@aztec/sequencer-client 0.0.0-test.1 → 0.0.1-commit.023c3e5
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/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +31 -31
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +82 -60
- package/dest/config.d.ts +15 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +118 -70
- package/dest/global_variable_builder/global_builder.d.ts +26 -15
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +62 -44
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +2 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -3
- package/dest/publisher/config.d.ts +15 -12
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +32 -19
- package/dest/publisher/index.d.ts +3 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +44 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +51 -0
- package/dest/publisher/sequencer-publisher-metrics.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +34 -62
- package/dest/publisher/sequencer-publisher.d.ts +134 -88
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1172 -254
- package/dest/sequencer/checkpoint_proposal_job.d.ts +96 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1192 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +7 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- 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 +48 -12
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +213 -68
- package/dest/sequencer/sequencer.d.ts +144 -137
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +967 -525
- package/dest/sequencer/timetable.d.ts +76 -24
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +177 -61
- 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 +20 -38
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -47
- package/dest/test/index.d.ts +9 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- 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 +220 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +103 -0
- package/package.json +47 -45
- package/src/client/sequencer-client.ts +106 -107
- package/src/config.ts +131 -81
- package/src/global_variable_builder/global_builder.ts +84 -55
- package/src/index.ts +1 -3
- package/src/publisher/config.ts +45 -32
- package/src/publisher/index.ts +4 -0
- package/src/publisher/sequencer-publisher-factory.ts +92 -0
- package/src/publisher/sequencer-publisher-metrics.ts +33 -63
- package/src/publisher/sequencer-publisher.ts +990 -302
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +874 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +8 -0
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +288 -73
- package/src/sequencer/sequencer.ts +708 -588
- package/src/sequencer/timetable.ts +221 -62
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +28 -60
- package/src/test/index.ts +12 -4
- package/src/test/mock_checkpoint_builder.ts +309 -0
- package/src/test/utils.ts +164 -0
- package/dest/sequencer/allowed.d.ts +0 -3
- package/dest/sequencer/allowed.d.ts.map +0 -1
- package/dest/sequencer/allowed.js +0 -27
- package/dest/slasher/factory.d.ts +0 -7
- package/dest/slasher/factory.d.ts.map +0 -1
- package/dest/slasher/factory.js +0 -8
- package/dest/slasher/index.d.ts +0 -3
- package/dest/slasher/index.d.ts.map +0 -1
- package/dest/slasher/index.js +0 -2
- package/dest/slasher/slasher_client.d.ts +0 -75
- package/dest/slasher/slasher_client.d.ts.map +0 -1
- package/dest/slasher/slasher_client.js +0 -132
- package/dest/tx_validator/archive_cache.d.ts +0 -14
- package/dest/tx_validator/archive_cache.d.ts.map +0 -1
- package/dest/tx_validator/archive_cache.js +0 -22
- package/dest/tx_validator/gas_validator.d.ts +0 -14
- package/dest/tx_validator/gas_validator.d.ts.map +0 -1
- package/dest/tx_validator/gas_validator.js +0 -78
- package/dest/tx_validator/nullifier_cache.d.ts +0 -16
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/phases_validator.d.ts +0 -12
- package/dest/tx_validator/phases_validator.d.ts.map +0 -1
- package/dest/tx_validator/phases_validator.js +0 -80
- package/dest/tx_validator/test_utils.d.ts +0 -23
- package/dest/tx_validator/test_utils.d.ts.map +0 -1
- package/dest/tx_validator/test_utils.js +0 -26
- 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 -50
- package/src/sequencer/allowed.ts +0 -36
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -193
- package/src/tx_validator/archive_cache.ts +0 -28
- package/src/tx_validator/gas_validator.ts +0 -101
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
- package/src/tx_validator/tx_validator_factory.ts +0 -120
|
@@ -1,74 +1,501 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
374
|
+
import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
375
|
+
import { 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';
|
|
379
|
+
import { sumBigint } from '@aztec/foundation/bigint';
|
|
380
|
+
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
381
|
+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
382
|
+
import { pick } from '@aztec/foundation/collection';
|
|
5
383
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
384
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
6
385
|
import { createLogger } from '@aztec/foundation/log';
|
|
386
|
+
import { bufferToHex } from '@aztec/foundation/string';
|
|
7
387
|
import { Timer } from '@aztec/foundation/timer';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { encodeFunctionData } from 'viem';
|
|
388
|
+
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
389
|
+
import { encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
390
|
+
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
391
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
392
|
+
import { encodeFunctionData, toHex } from 'viem';
|
|
13
393
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
394
|
+
export const Actions = [
|
|
395
|
+
'invalidate-by-invalid-attestation',
|
|
396
|
+
'invalidate-by-insufficient-attestations',
|
|
397
|
+
'propose',
|
|
398
|
+
'governance-signal',
|
|
399
|
+
'empire-slashing-signal',
|
|
400
|
+
'create-empire-payload',
|
|
401
|
+
'execute-empire-payload',
|
|
402
|
+
'vote-offenses',
|
|
403
|
+
'execute-slash'
|
|
404
|
+
];
|
|
405
|
+
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
|
|
406
|
+
export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
|
|
407
|
+
_dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader'), _dec2 = trackSpan('SequencerPublisher.validateCheckpointForSubmission');
|
|
19
408
|
export class SequencerPublisher {
|
|
20
|
-
|
|
409
|
+
config;
|
|
410
|
+
static{
|
|
411
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
412
|
+
[
|
|
413
|
+
_dec,
|
|
414
|
+
2,
|
|
415
|
+
"sendRequests"
|
|
416
|
+
],
|
|
417
|
+
[
|
|
418
|
+
_dec1,
|
|
419
|
+
2,
|
|
420
|
+
"validateBlockHeader"
|
|
421
|
+
],
|
|
422
|
+
[
|
|
423
|
+
_dec2,
|
|
424
|
+
2,
|
|
425
|
+
"validateCheckpointForSubmission"
|
|
426
|
+
]
|
|
427
|
+
], []));
|
|
428
|
+
}
|
|
429
|
+
interrupted;
|
|
21
430
|
metrics;
|
|
22
431
|
epochCache;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
slashingProposerAddress;
|
|
29
|
-
getSlashPayload = undefined;
|
|
30
|
-
myLastVotes = {
|
|
31
|
-
[0]: 0n,
|
|
32
|
-
[1]: 0n
|
|
33
|
-
};
|
|
34
|
-
log = createLogger('sequencer:publisher');
|
|
432
|
+
governanceLog;
|
|
433
|
+
slashingLog;
|
|
434
|
+
lastActions;
|
|
435
|
+
isPayloadEmptyCache;
|
|
436
|
+
log;
|
|
35
437
|
ethereumSlotDuration;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
static
|
|
438
|
+
blobClient;
|
|
439
|
+
/** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
|
|
440
|
+
/** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
|
|
441
|
+
// A CALL to a cold address is 2700 gas
|
|
442
|
+
static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
|
|
443
|
+
// Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
|
|
444
|
+
static VOTE_GAS_GUESS = 800_000n;
|
|
41
445
|
l1TxUtils;
|
|
42
446
|
rollupContract;
|
|
43
447
|
govProposerContract;
|
|
44
448
|
slashingProposerContract;
|
|
45
|
-
|
|
449
|
+
slashFactoryContract;
|
|
450
|
+
tracer;
|
|
451
|
+
requests;
|
|
46
452
|
constructor(config, deps){
|
|
453
|
+
this.config = config;
|
|
454
|
+
this.interrupted = (_initProto(this), false);
|
|
455
|
+
this.governanceLog = createLogger('sequencer:publisher:governance');
|
|
456
|
+
this.slashingLog = createLogger('sequencer:publisher:slashing');
|
|
457
|
+
this.lastActions = {};
|
|
458
|
+
this.isPayloadEmptyCache = new Map();
|
|
459
|
+
this.requests = [];
|
|
460
|
+
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
47
461
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
48
462
|
this.epochCache = deps.epochCache;
|
|
49
|
-
this.
|
|
463
|
+
this.lastActions = deps.lastActions;
|
|
464
|
+
this.blobClient = deps.blobClient;
|
|
50
465
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
51
|
-
this.metrics = new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
466
|
+
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
467
|
+
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
52
468
|
this.l1TxUtils = deps.l1TxUtils;
|
|
53
469
|
this.rollupContract = deps.rollupContract;
|
|
54
|
-
this.forwarderContract = deps.forwarderContract;
|
|
55
470
|
this.govProposerContract = deps.governanceProposerContract;
|
|
56
471
|
this.slashingProposerContract = deps.slashingProposerContract;
|
|
472
|
+
this.rollupContract.listenToSlasherChanged(async ()=>{
|
|
473
|
+
this.log.info('Slashing proposer changed');
|
|
474
|
+
const newSlashingProposer = await this.rollupContract.getSlashingProposer();
|
|
475
|
+
this.slashingProposerContract = newSlashingProposer;
|
|
476
|
+
});
|
|
477
|
+
this.slashFactoryContract = deps.slashFactoryContract;
|
|
478
|
+
// Initialize L1 fee analyzer for fisherman mode
|
|
479
|
+
if (config.fishermanMode) {
|
|
480
|
+
this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
|
|
481
|
+
}
|
|
57
482
|
}
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
}
|
|
61
|
-
getForwarderAddress() {
|
|
62
|
-
return EthAddress.fromString(this.forwarderContract.getAddress());
|
|
483
|
+
getRollupContract() {
|
|
484
|
+
return this.rollupContract;
|
|
63
485
|
}
|
|
64
486
|
getSenderAddress() {
|
|
65
|
-
return
|
|
487
|
+
return this.l1TxUtils.getSenderAddress();
|
|
66
488
|
}
|
|
67
|
-
|
|
68
|
-
|
|
489
|
+
/**
|
|
490
|
+
* Gets the L1 fee analyzer instance (only available in fisherman mode)
|
|
491
|
+
*/ getL1FeeAnalyzer() {
|
|
492
|
+
return this.l1FeeAnalyzer;
|
|
69
493
|
}
|
|
70
|
-
|
|
71
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Sets the proposer address to use for simulations in fisherman mode.
|
|
496
|
+
* @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
|
|
497
|
+
*/ setProposerAddressForSimulation(proposerAddress) {
|
|
498
|
+
this.proposerAddressForSimulation = proposerAddress;
|
|
72
499
|
}
|
|
73
500
|
addRequest(request) {
|
|
74
501
|
this.requests.push(request);
|
|
@@ -77,6 +504,55 @@ export class SequencerPublisher {
|
|
|
77
504
|
return this.epochCache.getEpochAndSlotNow().slot;
|
|
78
505
|
}
|
|
79
506
|
/**
|
|
507
|
+
* Clears all pending requests without sending them.
|
|
508
|
+
*/ clearPendingRequests() {
|
|
509
|
+
const count = this.requests.length;
|
|
510
|
+
this.requests = [];
|
|
511
|
+
if (count > 0) {
|
|
512
|
+
this.log.debug(`Cleared ${count} pending request(s)`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Analyzes L1 fees for the pending requests without sending them.
|
|
517
|
+
* This is used in fisherman mode to validate fee calculations.
|
|
518
|
+
* @param l2SlotNumber - The L2 slot number for this analysis
|
|
519
|
+
* @param onComplete - Optional callback to invoke when analysis completes (after block is mined)
|
|
520
|
+
* @returns The analysis result (incomplete until block mines), or undefined if no requests
|
|
521
|
+
*/ async analyzeL1Fees(l2SlotNumber, onComplete) {
|
|
522
|
+
if (!this.l1FeeAnalyzer) {
|
|
523
|
+
this.log.warn('L1 fee analyzer not available (not in fisherman mode)');
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
const requestsToAnalyze = [
|
|
527
|
+
...this.requests
|
|
528
|
+
];
|
|
529
|
+
if (requestsToAnalyze.length === 0) {
|
|
530
|
+
this.log.debug('No requests to analyze for L1 fees');
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
533
|
+
// Extract blob config from requests (if any)
|
|
534
|
+
const blobConfigs = requestsToAnalyze.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
|
|
535
|
+
const blobConfig = blobConfigs[0];
|
|
536
|
+
// Get gas configs
|
|
537
|
+
const gasConfigs = requestsToAnalyze.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
538
|
+
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
539
|
+
const gasLimit = gasLimits.length > 0 ? gasLimits.reduce((sum, g)=>sum + g, 0n) : 0n;
|
|
540
|
+
// Get the transaction requests
|
|
541
|
+
const l1Requests = requestsToAnalyze.map((r)=>r.request);
|
|
542
|
+
// Start the analysis
|
|
543
|
+
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
|
|
544
|
+
this.log.info('Started L1 fee analysis', {
|
|
545
|
+
analysisId,
|
|
546
|
+
l2SlotNumber: l2SlotNumber.toString(),
|
|
547
|
+
requestCount: requestsToAnalyze.length,
|
|
548
|
+
hasBlobConfig: !!blobConfig,
|
|
549
|
+
gasLimit: gasLimit.toString(),
|
|
550
|
+
actions: requestsToAnalyze.map((r)=>r.action)
|
|
551
|
+
});
|
|
552
|
+
// Return the analysis result (will be incomplete until block mines)
|
|
553
|
+
return this.l1FeeAnalyzer.getAnalysis(analysisId);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
80
556
|
* Sends all requests that are still valid.
|
|
81
557
|
* @returns one of:
|
|
82
558
|
* - A receipt and stats if the tx succeeded
|
|
@@ -87,12 +563,14 @@ export class SequencerPublisher {
|
|
|
87
563
|
...this.requests
|
|
88
564
|
];
|
|
89
565
|
this.requests = [];
|
|
90
|
-
if (this.interrupted) {
|
|
566
|
+
if (this.interrupted || requestsToProcess.length === 0) {
|
|
91
567
|
return undefined;
|
|
92
568
|
}
|
|
93
569
|
const currentL2Slot = this.getCurrentL2Slot();
|
|
94
|
-
this.log.debug(`
|
|
570
|
+
this.log.debug(`Sending requests on L2 slot ${currentL2Slot}`);
|
|
95
571
|
const validRequests = requestsToProcess.filter((request)=>request.lastValidL2Slot >= currentL2Slot);
|
|
572
|
+
const validActions = validRequests.map((x)=>x.action);
|
|
573
|
+
const expiredActions = requestsToProcess.filter((request)=>request.lastValidL2Slot < currentL2Slot).map((x)=>x.action);
|
|
96
574
|
if (validRequests.length !== requestsToProcess.length) {
|
|
97
575
|
this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
|
|
98
576
|
validRequests: validRequests.map((request)=>({
|
|
@@ -109,56 +587,107 @@ export class SequencerPublisher {
|
|
|
109
587
|
this.log.debug(`No valid requests to send`);
|
|
110
588
|
return undefined;
|
|
111
589
|
}
|
|
112
|
-
// @note - we can only have one
|
|
590
|
+
// @note - we can only have one blob config per bundle
|
|
113
591
|
// find requests with gas and blob configs
|
|
114
592
|
// See https://github.com/AztecProtocol/aztec-packages/issues/11513
|
|
115
|
-
const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig);
|
|
116
|
-
const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig);
|
|
117
|
-
if (
|
|
118
|
-
throw new Error('Multiple
|
|
593
|
+
const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
594
|
+
const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
|
|
595
|
+
if (blobConfigs.length > 1) {
|
|
596
|
+
throw new Error('Multiple blob configs found');
|
|
597
|
+
}
|
|
598
|
+
const blobConfig = blobConfigs[0];
|
|
599
|
+
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
600
|
+
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
601
|
+
let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
602
|
+
// Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
|
|
603
|
+
const maxGas = MAX_L1_TX_LIMIT;
|
|
604
|
+
if (gasLimit !== undefined && gasLimit > maxGas) {
|
|
605
|
+
this.log.debug('Capping bundled tx gas limit to L1 max', {
|
|
606
|
+
requested: gasLimit,
|
|
607
|
+
capped: maxGas
|
|
608
|
+
});
|
|
609
|
+
gasLimit = maxGas;
|
|
119
610
|
}
|
|
120
|
-
const
|
|
121
|
-
const
|
|
611
|
+
const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
|
|
612
|
+
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
|
|
613
|
+
const txConfig = {
|
|
614
|
+
gasLimit,
|
|
615
|
+
txTimeoutAt
|
|
616
|
+
};
|
|
617
|
+
// Sort the requests so that proposals always go first
|
|
618
|
+
// This ensures the committee gets precomputed correctly
|
|
619
|
+
validRequests.sort((a, b)=>compareActions(a.action, b.action));
|
|
122
620
|
try {
|
|
123
621
|
this.log.debug('Forwarding transactions', {
|
|
124
|
-
validRequests: validRequests.map((request)=>request.action)
|
|
622
|
+
validRequests: validRequests.map((request)=>request.action),
|
|
623
|
+
txConfig
|
|
125
624
|
});
|
|
126
|
-
const result = await
|
|
127
|
-
this.callbackBundledTransactions(validRequests, result);
|
|
128
|
-
return
|
|
625
|
+
const result = await Multicall3.forward(validRequests.map((request)=>request.request), this.l1TxUtils, txConfig, blobConfig, this.rollupContract.address, this.log);
|
|
626
|
+
const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result);
|
|
627
|
+
return {
|
|
628
|
+
result,
|
|
629
|
+
expiredActions,
|
|
630
|
+
sentActions: validActions,
|
|
631
|
+
successfulActions,
|
|
632
|
+
failedActions
|
|
633
|
+
};
|
|
129
634
|
} catch (err) {
|
|
130
635
|
const viemError = formatViemError(err);
|
|
131
636
|
this.log.error(`Failed to publish bundled transactions`, viemError);
|
|
132
637
|
return undefined;
|
|
133
638
|
} finally{
|
|
134
639
|
try {
|
|
135
|
-
this.metrics.recordSenderBalance(await this.l1TxUtils.getSenderBalance(), this.l1TxUtils.getSenderAddress());
|
|
640
|
+
this.metrics.recordSenderBalance(await this.l1TxUtils.getSenderBalance(), this.l1TxUtils.getSenderAddress().toString());
|
|
136
641
|
} catch (err) {
|
|
137
642
|
this.log.warn(`Failed to record balance after sending tx: ${err}`);
|
|
138
643
|
}
|
|
139
644
|
}
|
|
140
645
|
}
|
|
141
646
|
callbackBundledTransactions(requests, result) {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
647
|
+
const actionsListStr = requests.map((r)=>r.action).join(', ');
|
|
648
|
+
if (result instanceof FormattedViemError) {
|
|
649
|
+
this.log.error(`Failed to publish bundled transactions (${actionsListStr})`, result);
|
|
650
|
+
return {
|
|
651
|
+
failedActions: requests.map((r)=>r.action)
|
|
652
|
+
};
|
|
653
|
+
} else {
|
|
654
|
+
this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
|
|
655
|
+
result,
|
|
656
|
+
requests
|
|
657
|
+
});
|
|
658
|
+
const successfulActions = [];
|
|
659
|
+
const failedActions = [];
|
|
660
|
+
for (const request of requests){
|
|
661
|
+
if (request.checkSuccess(request.request, result)) {
|
|
662
|
+
successfulActions.push(request.action);
|
|
663
|
+
} else {
|
|
664
|
+
failedActions.push(request.action);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
successfulActions,
|
|
669
|
+
failedActions
|
|
670
|
+
};
|
|
147
671
|
}
|
|
148
672
|
}
|
|
149
673
|
/**
|
|
150
674
|
* @notice Will call `canProposeAtNextEthBlock` to make sure that it is possible to propose
|
|
151
675
|
* @param tipArchive - The archive to check
|
|
152
676
|
* @returns The slot and block number if it is possible to propose, undefined otherwise
|
|
153
|
-
*/ canProposeAtNextEthBlock(tipArchive) {
|
|
677
|
+
*/ canProposeAtNextEthBlock(tipArchive, msgSender, opts = {}) {
|
|
678
|
+
// TODO: #14291 - should loop through multiple keys to check if any of them can propose
|
|
154
679
|
const ignoredErrors = [
|
|
155
680
|
'SlotAlreadyInChain',
|
|
156
681
|
'InvalidProposer',
|
|
157
682
|
'InvalidArchive'
|
|
158
683
|
];
|
|
159
|
-
return this.rollupContract.canProposeAtNextEthBlock(tipArchive
|
|
684
|
+
return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
|
|
685
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
686
|
+
}).catch((err)=>{
|
|
160
687
|
if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
|
|
161
|
-
this.log.
|
|
688
|
+
this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
|
|
689
|
+
error: err.message
|
|
690
|
+
});
|
|
162
691
|
} else {
|
|
163
692
|
this.log.error(err.name, err);
|
|
164
693
|
}
|
|
@@ -166,135 +695,498 @@ export class SequencerPublisher {
|
|
|
166
695
|
});
|
|
167
696
|
}
|
|
168
697
|
/**
|
|
169
|
-
* @notice Will
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
* @param digest - The digest that attestations are signing over
|
|
175
|
-
*
|
|
176
|
-
*/ async validateBlockForSubmission(header, attestationData = {
|
|
177
|
-
digest: Buffer.alloc(32),
|
|
178
|
-
signatures: []
|
|
179
|
-
}) {
|
|
180
|
-
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
181
|
-
const formattedSignatures = attestationData.signatures.map((attest)=>attest.toViemSignature());
|
|
698
|
+
* @notice Will simulate `validateHeader` to make sure that the block header is valid
|
|
699
|
+
* @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
|
|
700
|
+
* It will throw if the block header is invalid.
|
|
701
|
+
* @param header - The block header to validate
|
|
702
|
+
*/ async validateBlockHeader(header, opts) {
|
|
182
703
|
const flags = {
|
|
183
704
|
ignoreDA: true,
|
|
184
|
-
ignoreSignatures:
|
|
705
|
+
ignoreSignatures: true
|
|
185
706
|
};
|
|
186
707
|
const args = [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
`0x${
|
|
708
|
+
header.toViem(),
|
|
709
|
+
CommitteeAttestationsAndSigners.empty().getPackedAttestations(),
|
|
710
|
+
[],
|
|
711
|
+
Signature.empty().toViemSignature(),
|
|
712
|
+
`0x${'0'.repeat(64)}`,
|
|
713
|
+
header.blobsHash.toString(),
|
|
192
714
|
flags
|
|
193
715
|
];
|
|
194
|
-
await this.
|
|
195
|
-
|
|
716
|
+
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
717
|
+
const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
|
|
718
|
+
let balance = 0n;
|
|
719
|
+
if (this.config.fishermanMode) {
|
|
720
|
+
// In fisherman mode, we can't know where the proposer is publishing from
|
|
721
|
+
// so we just add sufficient balance to the multicall3 address
|
|
722
|
+
balance = 10n * WEI_CONST * WEI_CONST; // 10 ETH
|
|
723
|
+
} else {
|
|
724
|
+
balance = await this.l1TxUtils.getSenderBalance();
|
|
725
|
+
}
|
|
726
|
+
stateOverrides.push({
|
|
727
|
+
address: MULTI_CALL_3_ADDRESS,
|
|
728
|
+
balance
|
|
729
|
+
});
|
|
730
|
+
await this.l1TxUtils.simulate({
|
|
731
|
+
to: this.rollupContract.address,
|
|
732
|
+
data: encodeFunctionData({
|
|
733
|
+
abi: RollupAbi,
|
|
734
|
+
functionName: 'validateHeaderWithAttestations',
|
|
735
|
+
args
|
|
736
|
+
}),
|
|
737
|
+
from: MULTI_CALL_3_ADDRESS
|
|
738
|
+
}, {
|
|
739
|
+
time: ts + 1n
|
|
740
|
+
}, stateOverrides);
|
|
741
|
+
this.log.debug(`Simulated validateHeader`);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Simulate making a call to invalidate a checkpoint with invalid attestations. Returns undefined if no need to invalidate.
|
|
745
|
+
* @param validationResult - The validation result indicating which checkpoint to invalidate (as returned by the archiver)
|
|
746
|
+
*/ async simulateInvalidateCheckpoint(validationResult) {
|
|
747
|
+
if (validationResult.valid) {
|
|
748
|
+
return undefined;
|
|
749
|
+
}
|
|
750
|
+
const { reason, checkpoint } = validationResult;
|
|
751
|
+
const checkpointNumber = checkpoint.checkpointNumber;
|
|
752
|
+
const logData = {
|
|
753
|
+
...checkpoint,
|
|
754
|
+
reason
|
|
755
|
+
};
|
|
756
|
+
const currentCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
757
|
+
if (currentCheckpointNumber < checkpointNumber) {
|
|
758
|
+
this.log.verbose(`Skipping checkpoint ${checkpointNumber} invalidation since it has already been removed from the pending chain`, {
|
|
759
|
+
currentCheckpointNumber,
|
|
760
|
+
...logData
|
|
761
|
+
});
|
|
762
|
+
return undefined;
|
|
763
|
+
}
|
|
764
|
+
const request = this.buildInvalidateCheckpointRequest(validationResult);
|
|
765
|
+
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, {
|
|
766
|
+
...logData,
|
|
767
|
+
request
|
|
768
|
+
});
|
|
769
|
+
try {
|
|
770
|
+
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
|
|
771
|
+
request.abi ?? [],
|
|
772
|
+
ErrorsAbi
|
|
773
|
+
]));
|
|
774
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
775
|
+
...logData,
|
|
776
|
+
request,
|
|
777
|
+
gasUsed
|
|
778
|
+
});
|
|
779
|
+
return {
|
|
780
|
+
request,
|
|
781
|
+
gasUsed,
|
|
782
|
+
checkpointNumber,
|
|
783
|
+
forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
|
|
784
|
+
reason
|
|
785
|
+
};
|
|
786
|
+
} catch (err) {
|
|
787
|
+
const viemError = formatViemError(err);
|
|
788
|
+
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
789
|
+
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
790
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
791
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
|
|
792
|
+
...logData,
|
|
793
|
+
request,
|
|
794
|
+
error: viemError.message
|
|
795
|
+
});
|
|
796
|
+
const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
797
|
+
if (latestPendingCheckpointNumber < checkpointNumber) {
|
|
798
|
+
this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
|
|
799
|
+
...logData
|
|
800
|
+
});
|
|
801
|
+
return undefined;
|
|
802
|
+
} else {
|
|
803
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed and it is still in pending chain`, viemError, logData);
|
|
804
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber} while it is still in pending chain`, {
|
|
805
|
+
cause: viemError
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
810
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
811
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
|
|
812
|
+
cause: viemError
|
|
813
|
+
});
|
|
814
|
+
}
|
|
196
815
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
816
|
+
buildInvalidateCheckpointRequest(validationResult) {
|
|
817
|
+
if (validationResult.valid) {
|
|
818
|
+
throw new Error('Cannot invalidate a valid checkpoint');
|
|
819
|
+
}
|
|
820
|
+
const { checkpoint, committee, reason } = validationResult;
|
|
821
|
+
const logData = {
|
|
822
|
+
...checkpoint,
|
|
823
|
+
reason
|
|
824
|
+
};
|
|
825
|
+
this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
|
|
826
|
+
const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
|
|
827
|
+
if (reason === 'invalid-attestation') {
|
|
828
|
+
return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
|
|
829
|
+
} else if (reason === 'insufficient-attestations') {
|
|
830
|
+
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee);
|
|
831
|
+
} else {
|
|
832
|
+
const _ = reason;
|
|
833
|
+
throw new Error(`Unknown reason for invalidation`);
|
|
834
|
+
}
|
|
200
835
|
}
|
|
201
|
-
async
|
|
202
|
-
|
|
836
|
+
/** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
|
|
837
|
+
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
838
|
+
// TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
|
|
839
|
+
// If we have no attestations, we still need to provide the empty attestations
|
|
840
|
+
// so that the committee is recalculated correctly
|
|
841
|
+
// const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
842
|
+
// if (ignoreSignatures) {
|
|
843
|
+
// const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
844
|
+
// if (!committee) {
|
|
845
|
+
// this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
846
|
+
// throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
847
|
+
// }
|
|
848
|
+
// attestationsAndSigners.attestations = committee.map(committeeMember =>
|
|
849
|
+
// CommitteeAttestation.fromAddress(committeeMember),
|
|
850
|
+
// );
|
|
851
|
+
// }
|
|
852
|
+
const blobFields = checkpoint.toBlobFields();
|
|
853
|
+
const blobs = getBlobsPerL1Block(blobFields);
|
|
854
|
+
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
855
|
+
const args = [
|
|
856
|
+
{
|
|
857
|
+
header: checkpoint.header.toViem(),
|
|
858
|
+
archive: toHex(checkpoint.archive.root.toBuffer()),
|
|
859
|
+
oracleInput: {
|
|
860
|
+
feeAssetPriceModifier: 0n
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
attestationsAndSigners.getPackedAttestations(),
|
|
864
|
+
attestationsAndSigners.getSigners().map((signer)=>signer.toString()),
|
|
865
|
+
attestationsAndSignersSignature.toViemSignature(),
|
|
866
|
+
blobInput
|
|
867
|
+
];
|
|
868
|
+
await this.simulateProposeTx(args, ts, options);
|
|
869
|
+
return ts;
|
|
870
|
+
}
|
|
871
|
+
async enqueueCastSignalHelper(slotNumber, timestamp, signalType, payload, base, signerAddress, signer) {
|
|
872
|
+
if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
|
|
873
|
+
this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
|
|
203
874
|
return false;
|
|
204
875
|
}
|
|
205
876
|
if (payload.equals(EthAddress.ZERO)) {
|
|
206
877
|
return false;
|
|
207
878
|
}
|
|
879
|
+
if (signerAddress.equals(EthAddress.ZERO)) {
|
|
880
|
+
this.log.warn(`Cannot enqueue vote cast signal ${signalType} for address zero at slot ${slotNumber}`);
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
208
883
|
const round = await base.computeRound(slotNumber);
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (
|
|
884
|
+
const roundInfo = await base.getRoundInfo(this.rollupContract.address, round);
|
|
885
|
+
if (roundInfo.quorumReached) {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
if (roundInfo.lastSignalSlot >= slotNumber) {
|
|
214
889
|
return false;
|
|
215
890
|
}
|
|
216
|
-
if (
|
|
891
|
+
if (await this.isPayloadEmpty(payload)) {
|
|
892
|
+
this.log.warn(`Skipping vote cast for payload with empty code`);
|
|
217
893
|
return false;
|
|
218
894
|
}
|
|
219
|
-
const cachedLastVote = this.
|
|
220
|
-
this.
|
|
895
|
+
const cachedLastVote = this.lastActions[signalType];
|
|
896
|
+
this.lastActions[signalType] = slotNumber;
|
|
897
|
+
const action = signalType;
|
|
898
|
+
const request = await base.createSignalRequestWithSignature(payload.toString(), slotNumber, this.config.l1ChainId, signerAddress.toString(), signer);
|
|
899
|
+
this.log.debug(`Created ${action} request with signature`, {
|
|
900
|
+
request,
|
|
901
|
+
round,
|
|
902
|
+
signer: this.l1TxUtils.client.account?.address,
|
|
903
|
+
lastValidL2Slot: slotNumber
|
|
904
|
+
});
|
|
905
|
+
try {
|
|
906
|
+
await this.l1TxUtils.simulate(request, {
|
|
907
|
+
time: timestamp
|
|
908
|
+
}, [], mergeAbis([
|
|
909
|
+
request.abi ?? [],
|
|
910
|
+
ErrorsAbi
|
|
911
|
+
]));
|
|
912
|
+
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
|
|
913
|
+
request
|
|
914
|
+
});
|
|
915
|
+
} catch (err) {
|
|
916
|
+
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
|
|
917
|
+
// Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
|
|
918
|
+
}
|
|
919
|
+
// TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
|
|
221
920
|
this.addRequest({
|
|
222
|
-
|
|
223
|
-
|
|
921
|
+
gasConfig: {
|
|
922
|
+
gasLimit: SequencerPublisher.VOTE_GAS_GUESS
|
|
923
|
+
},
|
|
924
|
+
action,
|
|
925
|
+
request,
|
|
224
926
|
lastValidL2Slot: slotNumber,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
927
|
+
checkSuccess: (_request, result)=>{
|
|
928
|
+
const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, base.address.toString(), EmpireBaseAbi, 'SignalCast');
|
|
929
|
+
const logData = {
|
|
930
|
+
...result,
|
|
931
|
+
slotNumber,
|
|
932
|
+
round,
|
|
933
|
+
payload: payload.toString()
|
|
934
|
+
};
|
|
935
|
+
if (!success) {
|
|
936
|
+
this.log.error(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} failed`, logData);
|
|
937
|
+
this.lastActions[signalType] = cachedLastVote;
|
|
938
|
+
return false;
|
|
228
939
|
} else {
|
|
229
|
-
this.log.info(`
|
|
940
|
+
this.log.info(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} succeeded`, logData);
|
|
941
|
+
return true;
|
|
230
942
|
}
|
|
231
943
|
}
|
|
232
944
|
});
|
|
233
945
|
return true;
|
|
234
946
|
}
|
|
235
|
-
async
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
};
|
|
241
|
-
} else if (voteType === 1) {
|
|
242
|
-
if (!this.getSlashPayload) {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
const slashPayload = await this.getSlashPayload(slotNumber);
|
|
246
|
-
if (!slashPayload) {
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
payload: slashPayload,
|
|
251
|
-
base: this.slashingProposerContract
|
|
252
|
-
};
|
|
947
|
+
async isPayloadEmpty(payload) {
|
|
948
|
+
const key = payload.toString();
|
|
949
|
+
const cached = this.isPayloadEmptyCache.get(key);
|
|
950
|
+
if (cached) {
|
|
951
|
+
return cached;
|
|
253
952
|
}
|
|
254
|
-
|
|
953
|
+
const isEmpty = !await this.l1TxUtils.getCode(payload);
|
|
954
|
+
this.isPayloadEmptyCache.set(key, isEmpty);
|
|
955
|
+
return isEmpty;
|
|
255
956
|
}
|
|
256
957
|
/**
|
|
257
|
-
* Enqueues a
|
|
258
|
-
* @param slotNumber - The slot number to cast a
|
|
259
|
-
* @param timestamp - The timestamp of the slot to cast a
|
|
260
|
-
* @
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
958
|
+
* Enqueues a governance castSignal transaction to cast a signal for a given slot number.
|
|
959
|
+
* @param slotNumber - The slot number to cast a signal for.
|
|
960
|
+
* @param timestamp - The timestamp of the slot to cast a signal for.
|
|
961
|
+
* @returns True if the signal was successfully enqueued, false otherwise.
|
|
962
|
+
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber, timestamp, signerAddress, signer) {
|
|
963
|
+
return this.enqueueCastSignalHelper(slotNumber, timestamp, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
|
|
964
|
+
}
|
|
965
|
+
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, timestamp, signerAddress, signer) {
|
|
966
|
+
if (actions.length === 0) {
|
|
967
|
+
this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
|
|
265
968
|
return false;
|
|
266
969
|
}
|
|
267
|
-
const
|
|
268
|
-
|
|
970
|
+
for (const action of actions){
|
|
971
|
+
switch(action.type){
|
|
972
|
+
case 'vote-empire-payload':
|
|
973
|
+
{
|
|
974
|
+
if (this.slashingProposerContract?.type !== 'empire') {
|
|
975
|
+
this.log.error('Cannot vote for empire payload on non-empire slashing contract');
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
|
|
979
|
+
signerAddress
|
|
980
|
+
});
|
|
981
|
+
await this.enqueueCastSignalHelper(slotNumber, timestamp, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
case 'create-empire-payload':
|
|
985
|
+
{
|
|
986
|
+
this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, {
|
|
987
|
+
slotNumber,
|
|
988
|
+
signerAddress
|
|
989
|
+
});
|
|
990
|
+
const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
|
|
991
|
+
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber, timestamp);
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
case 'execute-empire-payload':
|
|
995
|
+
{
|
|
996
|
+
this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, {
|
|
997
|
+
slotNumber,
|
|
998
|
+
signerAddress
|
|
999
|
+
});
|
|
1000
|
+
if (this.slashingProposerContract?.type !== 'empire') {
|
|
1001
|
+
this.log.error('Cannot execute slashing payload on non-empire slashing contract');
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
const empireSlashingProposer = this.slashingProposerContract;
|
|
1005
|
+
const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
|
|
1006
|
+
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber, timestamp);
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
case 'vote-offenses':
|
|
1010
|
+
{
|
|
1011
|
+
this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
|
|
1012
|
+
slotNumber,
|
|
1013
|
+
round: action.round,
|
|
1014
|
+
votesCount: action.votes.length,
|
|
1015
|
+
signerAddress
|
|
1016
|
+
});
|
|
1017
|
+
if (this.slashingProposerContract?.type !== 'tally') {
|
|
1018
|
+
this.log.error('Cannot vote for slashing offenses on non-tally slashing contract');
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
const tallySlashingProposer = this.slashingProposerContract;
|
|
1022
|
+
const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
|
|
1023
|
+
const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
|
|
1024
|
+
await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber, timestamp);
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
case 'execute-slash':
|
|
1028
|
+
{
|
|
1029
|
+
this.log.debug(`Enqueuing slash execution for round ${action.round} at slot ${slotNumber}`, {
|
|
1030
|
+
slotNumber,
|
|
1031
|
+
round: action.round,
|
|
1032
|
+
signerAddress
|
|
1033
|
+
});
|
|
1034
|
+
if (this.slashingProposerContract?.type !== 'tally') {
|
|
1035
|
+
this.log.error('Cannot execute slashing offenses on non-tally slashing contract');
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
const tallySlashingProposer = this.slashingProposerContract;
|
|
1039
|
+
const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
|
|
1040
|
+
await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber, timestamp);
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
default:
|
|
1044
|
+
{
|
|
1045
|
+
const _ = action;
|
|
1046
|
+
throw new Error(`Unknown slashing action type: ${action.type}`);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return true;
|
|
269
1051
|
}
|
|
270
|
-
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
* @returns True if the tx has been enqueued, throws otherwise. See #9315
|
|
275
|
-
*/ async enqueueProposeL2Block(block, attestations, txHashes, opts = {}) {
|
|
276
|
-
const consensusPayload = new ConsensusPayload(block.header, block.archive.root, txHashes ?? []);
|
|
277
|
-
const digest = await getHashedSignaturePayload(consensusPayload, SignatureDomainSeparator.blockAttestation);
|
|
278
|
-
const blobs = await Blob.getBlobs(block.body.toBlobFields());
|
|
1052
|
+
/** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
|
|
1053
|
+
const checkpointHeader = checkpoint.header;
|
|
1054
|
+
const blobFields = checkpoint.toBlobFields();
|
|
1055
|
+
const blobs = getBlobsPerL1Block(blobFields);
|
|
279
1056
|
const proposeTxArgs = {
|
|
280
|
-
header:
|
|
281
|
-
archive:
|
|
282
|
-
blockHash: (await block.header.hash()).toBuffer(),
|
|
283
|
-
body: block.body.toBuffer(),
|
|
1057
|
+
header: checkpointHeader,
|
|
1058
|
+
archive: checkpoint.archive.root.toBuffer(),
|
|
284
1059
|
blobs,
|
|
285
|
-
|
|
286
|
-
|
|
1060
|
+
attestationsAndSigners,
|
|
1061
|
+
attestationsAndSignersSignature
|
|
1062
|
+
};
|
|
1063
|
+
let ts;
|
|
1064
|
+
try {
|
|
1065
|
+
// @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
|
|
1066
|
+
// This means that we can avoid the simulation issues in later checks.
|
|
1067
|
+
// By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
|
|
1068
|
+
// make time consistency checks break.
|
|
1069
|
+
// TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
|
|
1070
|
+
ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
|
|
1071
|
+
} catch (err) {
|
|
1072
|
+
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
1073
|
+
...checkpoint.getStats(),
|
|
1074
|
+
slotNumber: checkpoint.header.slotNumber,
|
|
1075
|
+
forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
|
|
1076
|
+
});
|
|
1077
|
+
throw err;
|
|
1078
|
+
}
|
|
1079
|
+
this.log.verbose(`Enqueuing checkpoint propose transaction`, {
|
|
1080
|
+
...checkpoint.toCheckpointInfo(),
|
|
1081
|
+
...opts
|
|
1082
|
+
});
|
|
1083
|
+
await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
|
|
1084
|
+
}
|
|
1085
|
+
enqueueInvalidateCheckpoint(request, opts = {}) {
|
|
1086
|
+
if (!request) {
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
1090
|
+
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
|
|
1091
|
+
const { gasUsed, checkpointNumber } = request;
|
|
1092
|
+
const logData = {
|
|
1093
|
+
gasUsed,
|
|
1094
|
+
checkpointNumber,
|
|
1095
|
+
gasLimit,
|
|
1096
|
+
opts
|
|
1097
|
+
};
|
|
1098
|
+
this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
|
|
1099
|
+
this.addRequest({
|
|
1100
|
+
action: `invalidate-by-${request.reason}`,
|
|
1101
|
+
request: request.request,
|
|
1102
|
+
gasConfig: {
|
|
1103
|
+
gasLimit,
|
|
1104
|
+
txTimeoutAt: opts.txTimeoutAt
|
|
1105
|
+
},
|
|
1106
|
+
lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
|
|
1107
|
+
checkSuccess: (_req, result)=>{
|
|
1108
|
+
const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
|
|
1109
|
+
if (!success) {
|
|
1110
|
+
this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
|
|
1111
|
+
...result,
|
|
1112
|
+
...logData
|
|
1113
|
+
});
|
|
1114
|
+
} else {
|
|
1115
|
+
this.log.info(`Invalidate checkpoint ${request.checkpointNumber} succeeded`, {
|
|
1116
|
+
...result,
|
|
1117
|
+
...logData
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
return !!success;
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber, timestamp) {
|
|
1125
|
+
const logData = {
|
|
1126
|
+
slotNumber,
|
|
1127
|
+
timestamp,
|
|
1128
|
+
gasLimit: undefined
|
|
287
1129
|
};
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
1130
|
+
if (this.lastActions[action] && this.lastActions[action] === slotNumber) {
|
|
1131
|
+
this.log.debug(`Skipping duplicate action ${action} for slot ${slotNumber}`);
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
const cachedLastActionSlot = this.lastActions[action];
|
|
1135
|
+
this.lastActions[action] = slotNumber;
|
|
1136
|
+
this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
|
|
1137
|
+
let gasUsed;
|
|
1138
|
+
const simulateAbi = mergeAbis([
|
|
1139
|
+
request.abi ?? [],
|
|
1140
|
+
ErrorsAbi
|
|
1141
|
+
]);
|
|
1142
|
+
try {
|
|
1143
|
+
({ gasUsed } = await this.l1TxUtils.simulate(request, {
|
|
1144
|
+
time: timestamp
|
|
1145
|
+
}, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
|
|
1146
|
+
this.log.verbose(`Simulation for ${action} succeeded`, {
|
|
1147
|
+
...logData,
|
|
1148
|
+
request,
|
|
1149
|
+
gasUsed
|
|
1150
|
+
});
|
|
1151
|
+
} catch (err) {
|
|
1152
|
+
const viemError = formatViemError(err, simulateAbi);
|
|
1153
|
+
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
1157
|
+
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
|
|
1158
|
+
logData.gasLimit = gasLimit;
|
|
1159
|
+
// Store the ABI used for simulation on the request so Multicall3.forward can decode errors
|
|
1160
|
+
// when the tx is sent and a revert is diagnosed via simulation.
|
|
1161
|
+
const requestWithAbi = {
|
|
1162
|
+
...request,
|
|
1163
|
+
abi: simulateAbi
|
|
1164
|
+
};
|
|
1165
|
+
this.log.debug(`Enqueuing ${action}`, logData);
|
|
1166
|
+
this.addRequest({
|
|
1167
|
+
action,
|
|
1168
|
+
request: requestWithAbi,
|
|
1169
|
+
gasConfig: {
|
|
1170
|
+
gasLimit
|
|
1171
|
+
},
|
|
1172
|
+
lastValidL2Slot: slotNumber,
|
|
1173
|
+
checkSuccess: (_req, result)=>{
|
|
1174
|
+
const success = result && result.receipt && result.receipt.status === 'success' && checkSuccess(result.receipt);
|
|
1175
|
+
if (!success) {
|
|
1176
|
+
this.log.warn(`Action ${action} at ${slotNumber} failed`, {
|
|
1177
|
+
...result,
|
|
1178
|
+
...logData
|
|
1179
|
+
});
|
|
1180
|
+
this.lastActions[action] = cachedLastActionSlot;
|
|
1181
|
+
} else {
|
|
1182
|
+
this.log.info(`Action ${action} at ${slotNumber} succeeded`, {
|
|
1183
|
+
...result,
|
|
1184
|
+
...logData
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
return !!success;
|
|
1188
|
+
}
|
|
295
1189
|
});
|
|
296
|
-
this.log.debug(`Submitting propose transaction`);
|
|
297
|
-
await this.addProposeTx(block, proposeTxArgs, opts, ts);
|
|
298
1190
|
return true;
|
|
299
1191
|
}
|
|
300
1192
|
/**
|
|
@@ -310,172 +1202,198 @@ export class SequencerPublisher {
|
|
|
310
1202
|
this.interrupted = false;
|
|
311
1203
|
this.l1TxUtils.restart();
|
|
312
1204
|
}
|
|
313
|
-
async prepareProposeTx(encodedData, timestamp) {
|
|
1205
|
+
async prepareProposeTx(encodedData, timestamp, options) {
|
|
314
1206
|
const kzg = Blob.getViemKzgInstance();
|
|
315
|
-
const blobInput =
|
|
1207
|
+
const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
|
|
316
1208
|
this.log.debug('Validating blob input', {
|
|
317
1209
|
blobInput
|
|
318
1210
|
});
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
1211
|
+
// Get blob evaluation gas
|
|
1212
|
+
let blobEvaluationGas;
|
|
1213
|
+
if (this.config.fishermanMode) {
|
|
1214
|
+
// In fisherman mode, we can't estimate blob gas because estimateGas doesn't support state overrides
|
|
1215
|
+
// Use a fixed estimate.
|
|
1216
|
+
blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
|
|
1217
|
+
this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
|
|
1218
|
+
} else {
|
|
1219
|
+
// Normal mode - use estimateGas with blob inputs
|
|
1220
|
+
blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
|
|
1221
|
+
to: this.rollupContract.address,
|
|
1222
|
+
data: encodeFunctionData({
|
|
1223
|
+
abi: RollupAbi,
|
|
1224
|
+
functionName: 'validateBlobs',
|
|
1225
|
+
args: [
|
|
1226
|
+
blobInput
|
|
1227
|
+
]
|
|
1228
|
+
})
|
|
1229
|
+
}, {}, {
|
|
1230
|
+
blobs: encodedData.blobs.map((b)=>b.data),
|
|
1231
|
+
kzg
|
|
1232
|
+
}).catch((err)=>{
|
|
1233
|
+
const { message, metaMessages } = formatViemError(err);
|
|
1234
|
+
this.log.error(`Failed to validate blobs`, message, {
|
|
1235
|
+
metaMessages
|
|
1236
|
+
});
|
|
1237
|
+
throw new Error('Failed to validate blobs');
|
|
335
1238
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const attestations = encodedData.attestations ? encodedData.attestations.map((attest)=>attest.toViemSignature()) : [];
|
|
339
|
-
const txHashes = encodedData.txHashes ? encodedData.txHashes.map((txHash)=>txHash.toString()) : [];
|
|
1239
|
+
}
|
|
1240
|
+
const signers = encodedData.attestationsAndSigners.getSigners().map((signer)=>signer.toString());
|
|
340
1241
|
const args = [
|
|
341
1242
|
{
|
|
342
|
-
header:
|
|
343
|
-
archive:
|
|
1243
|
+
header: encodedData.header.toViem(),
|
|
1244
|
+
archive: toHex(encodedData.archive),
|
|
344
1245
|
oracleInput: {
|
|
345
1246
|
// We are currently not modifying these. See #9963
|
|
346
1247
|
feeAssetPriceModifier: 0n
|
|
347
|
-
}
|
|
348
|
-
blockHash: `0x${encodedData.blockHash.toString('hex')}`,
|
|
349
|
-
txHashes
|
|
1248
|
+
}
|
|
350
1249
|
},
|
|
351
|
-
|
|
1250
|
+
encodedData.attestationsAndSigners.getPackedAttestations(),
|
|
1251
|
+
signers,
|
|
1252
|
+
encodedData.attestationsAndSignersSignature.toViemSignature(),
|
|
352
1253
|
blobInput
|
|
353
1254
|
];
|
|
1255
|
+
const { rollupData, simulationResult } = await this.simulateProposeTx(args, timestamp, options);
|
|
1256
|
+
return {
|
|
1257
|
+
args,
|
|
1258
|
+
blobEvaluationGas,
|
|
1259
|
+
rollupData,
|
|
1260
|
+
simulationResult
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Simulates the propose tx with eth_simulateV1
|
|
1265
|
+
* @param args - The propose tx args
|
|
1266
|
+
* @param timestamp - The timestamp to simulate proposal at
|
|
1267
|
+
* @returns The simulation result
|
|
1268
|
+
*/ async simulateProposeTx(args, timestamp, options) {
|
|
354
1269
|
const rollupData = encodeFunctionData({
|
|
355
1270
|
abi: RollupAbi,
|
|
356
1271
|
functionName: 'propose',
|
|
357
1272
|
args
|
|
358
1273
|
});
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
args: [
|
|
363
|
-
[
|
|
364
|
-
this.rollupContract.address
|
|
365
|
-
],
|
|
366
|
-
[
|
|
367
|
-
rollupData
|
|
368
|
-
]
|
|
369
|
-
]
|
|
370
|
-
});
|
|
371
|
-
const simulationResult = await this.l1TxUtils.simulateGasUsed({
|
|
372
|
-
to: this.getForwarderAddress().toString(),
|
|
373
|
-
data: forwarderData,
|
|
374
|
-
gas: SequencerPublisher.PROPOSE_GAS_GUESS
|
|
375
|
-
}, {
|
|
376
|
-
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
377
|
-
time: timestamp + 1n,
|
|
378
|
-
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit
|
|
379
|
-
gasLimit: SequencerPublisher.PROPOSE_GAS_GUESS * 2n
|
|
380
|
-
}, [
|
|
1274
|
+
// override the pending checkpoint number if requested
|
|
1275
|
+
const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
|
|
1276
|
+
const stateOverrides = [
|
|
381
1277
|
{
|
|
382
1278
|
address: this.rollupContract.address,
|
|
383
1279
|
// @note we override checkBlob to false since blobs are not part simulate()
|
|
384
1280
|
stateDiff: [
|
|
385
1281
|
{
|
|
386
|
-
slot:
|
|
387
|
-
value:
|
|
388
|
-
}
|
|
1282
|
+
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
1283
|
+
value: toPaddedHex(0n, true)
|
|
1284
|
+
},
|
|
1285
|
+
...forcePendingCheckpointNumberStateDiff
|
|
389
1286
|
]
|
|
390
1287
|
}
|
|
391
|
-
]
|
|
1288
|
+
];
|
|
1289
|
+
// In fisherman mode, simulate as the proposer but with sufficient balance
|
|
1290
|
+
if (this.proposerAddressForSimulation) {
|
|
1291
|
+
stateOverrides.push({
|
|
1292
|
+
address: this.proposerAddressForSimulation.toString(),
|
|
1293
|
+
balance: 10n * WEI_CONST * WEI_CONST
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
const simulationResult = await this.l1TxUtils.simulate({
|
|
1297
|
+
to: this.rollupContract.address,
|
|
1298
|
+
data: rollupData,
|
|
1299
|
+
gas: MAX_L1_TX_LIMIT,
|
|
1300
|
+
...this.proposerAddressForSimulation && {
|
|
1301
|
+
from: this.proposerAddressForSimulation.toString()
|
|
1302
|
+
}
|
|
1303
|
+
}, {
|
|
1304
|
+
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
1305
|
+
time: timestamp + 1n,
|
|
1306
|
+
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
1307
|
+
gasLimit: MAX_L1_TX_LIMIT * 2n
|
|
1308
|
+
}, stateOverrides, RollupAbi, {
|
|
392
1309
|
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
393
|
-
fallbackGasEstimate:
|
|
1310
|
+
fallbackGasEstimate: MAX_L1_TX_LIMIT
|
|
394
1311
|
}).catch((err)=>{
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
1312
|
+
// In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
|
|
1313
|
+
const viemError = formatViemError(err);
|
|
1314
|
+
if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
|
|
1315
|
+
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
1316
|
+
// Return a minimal simulation result with the fallback gas estimate
|
|
1317
|
+
return {
|
|
1318
|
+
gasUsed: MAX_L1_TX_LIMIT,
|
|
1319
|
+
logs: []
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
this.log.error(`Failed to simulate propose tx`, viemError);
|
|
1323
|
+
throw err;
|
|
400
1324
|
});
|
|
401
1325
|
return {
|
|
402
|
-
args,
|
|
403
|
-
blobEvaluationGas,
|
|
404
1326
|
rollupData,
|
|
405
1327
|
simulationResult
|
|
406
1328
|
};
|
|
407
1329
|
}
|
|
408
|
-
async addProposeTx(
|
|
1330
|
+
async addProposeTx(checkpoint, encodedData, opts = {}, timestamp) {
|
|
1331
|
+
const slot = checkpoint.header.slotNumber;
|
|
409
1332
|
const timer = new Timer();
|
|
410
1333
|
const kzg = Blob.getViemKzgInstance();
|
|
411
|
-
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp);
|
|
1334
|
+
const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp, opts);
|
|
412
1335
|
const startBlock = await this.l1TxUtils.getBlockNumber();
|
|
413
|
-
const
|
|
1336
|
+
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
|
|
1337
|
+
// Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
|
|
1338
|
+
// tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
|
|
1339
|
+
void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
|
|
1340
|
+
this.log.error('Failed to send blobs to blob client');
|
|
1341
|
+
}));
|
|
414
1342
|
return this.addRequest({
|
|
415
1343
|
action: 'propose',
|
|
416
1344
|
request: {
|
|
417
1345
|
to: this.rollupContract.address,
|
|
418
1346
|
data: rollupData
|
|
419
1347
|
},
|
|
420
|
-
lastValidL2Slot:
|
|
1348
|
+
lastValidL2Slot: checkpoint.header.slotNumber,
|
|
421
1349
|
gasConfig: {
|
|
422
1350
|
...opts,
|
|
423
|
-
gasLimit
|
|
1351
|
+
gasLimit
|
|
424
1352
|
},
|
|
425
1353
|
blobConfig: {
|
|
426
1354
|
blobs: encodedData.blobs.map((b)=>b.data),
|
|
427
1355
|
kzg
|
|
428
1356
|
},
|
|
429
|
-
|
|
1357
|
+
checkSuccess: (_request, result)=>{
|
|
430
1358
|
if (!result) {
|
|
431
|
-
return;
|
|
1359
|
+
return false;
|
|
432
1360
|
}
|
|
433
1361
|
const { receipt, stats, errorMsg } = result;
|
|
434
|
-
|
|
1362
|
+
const success = receipt && receipt.status === 'success' && tryExtractEvent(receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointProposed');
|
|
1363
|
+
if (success) {
|
|
435
1364
|
const endBlock = receipt.blockNumber;
|
|
436
1365
|
const inclusionBlocks = Number(endBlock - startBlock);
|
|
1366
|
+
const { calldataGas, calldataSize, sender } = stats;
|
|
437
1367
|
const publishStats = {
|
|
438
1368
|
gasPrice: receipt.effectiveGasPrice,
|
|
439
1369
|
gasUsed: receipt.gasUsed,
|
|
440
1370
|
blobGasUsed: receipt.blobGasUsed ?? 0n,
|
|
441
1371
|
blobDataGas: receipt.blobGasPrice ?? 0n,
|
|
442
1372
|
transactionHash: receipt.transactionHash,
|
|
443
|
-
|
|
444
|
-
|
|
1373
|
+
calldataGas,
|
|
1374
|
+
calldataSize,
|
|
1375
|
+
sender,
|
|
1376
|
+
...checkpoint.getStats(),
|
|
445
1377
|
eventName: 'rollup-published-to-l1',
|
|
446
1378
|
blobCount: encodedData.blobs.length,
|
|
447
1379
|
inclusionBlocks
|
|
448
1380
|
};
|
|
449
|
-
this.log.
|
|
1381
|
+
this.log.info(`Published checkpoint ${checkpoint.number} at slot ${slot} to rollup contract`, {
|
|
450
1382
|
...stats,
|
|
451
|
-
...
|
|
1383
|
+
...checkpoint.getStats(),
|
|
1384
|
+
...pick(receipt, 'transactionHash', 'blockHash')
|
|
452
1385
|
});
|
|
453
1386
|
this.metrics.recordProcessBlockTx(timer.ms(), publishStats);
|
|
454
|
-
// Send the blobs to the blob sink
|
|
455
|
-
this.sendBlobsToBlobSink(receipt.blockHash, encodedData.blobs).catch((_err)=>{
|
|
456
|
-
this.log.error('Failed to send blobs to blob sink');
|
|
457
|
-
});
|
|
458
1387
|
return true;
|
|
459
1388
|
} else {
|
|
460
1389
|
this.metrics.recordFailedTx('process');
|
|
461
|
-
this.log.error(`
|
|
462
|
-
...
|
|
463
|
-
|
|
464
|
-
blockHash,
|
|
465
|
-
slotNumber: block.header.globalVariables.slotNumber.toBigInt()
|
|
1390
|
+
this.log.error(`Publishing checkpoint at slot ${slot} failed with ${errorMsg ?? 'no error message'}`, undefined, {
|
|
1391
|
+
...checkpoint.getStats(),
|
|
1392
|
+
...receipt
|
|
466
1393
|
});
|
|
1394
|
+
return false;
|
|
467
1395
|
}
|
|
468
1396
|
}
|
|
469
1397
|
});
|
|
470
1398
|
}
|
|
471
|
-
/**
|
|
472
|
-
* Send blobs to the blob sink
|
|
473
|
-
*
|
|
474
|
-
* If a blob sink url is configured, then we send blobs to the blob sink
|
|
475
|
-
* - for now we use the blockHash as the identifier for the blobs;
|
|
476
|
-
* In the future this will move to be the beacon block id - which takes a bit more work
|
|
477
|
-
* to calculate and will need to be mocked in e2e tests
|
|
478
|
-
*/ sendBlobsToBlobSink(blockHash, blobs) {
|
|
479
|
-
return this.blobSinkClient.sendBlobsToBlobSink(blockHash, blobs);
|
|
480
|
-
}
|
|
481
1399
|
}
|