@aztec/sequencer-client 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
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/README.md +282 -21
- package/dest/client/sequencer-client.d.ts +20 -11
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +67 -33
- package/dest/config.d.ts +29 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +82 -37
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +14 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -50
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- 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 +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +12 -6
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +108 -81
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +876 -403
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +506 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +87 -16
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +1331 -203
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +3 -3
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +34 -13
- package/dest/sequencer/events.d.ts +47 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +3 -3
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -2
- package/dest/sequencer/metrics.d.ts +23 -8
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +158 -143
- package/dest/sequencer/sequencer.d.ts +92 -29
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +818 -157
- package/dest/sequencer/timetable.d.ts +17 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +51 -46
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +4 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +29 -17
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +86 -34
- package/dest/test/utils.d.ts +13 -9
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +31 -20
- package/package.json +29 -28
- package/src/client/sequencer-client.ts +94 -38
- package/src/config.ts +107 -46
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +26 -63
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +5 -4
- package/src/publisher/config.ts +157 -45
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +39 -10
- package/src/publisher/sequencer-publisher-metrics.ts +17 -69
- package/src/publisher/sequencer-publisher.ts +611 -521
- package/src/sequencer/README.md +152 -450
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +592 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1138 -230
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +31 -17
- package/src/sequencer/events.ts +50 -2
- package/src/sequencer/index.ts +2 -2
- package/src/sequencer/metrics.ts +168 -151
- package/src/sequencer/sequencer.ts +535 -162
- package/src/sequencer/timetable.ts +70 -57
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +3 -6
- package/src/test/mock_checkpoint_builder.ts +149 -73
- package/src/test/utils.ts +78 -30
- package/dest/sequencer/block_builder.d.ts +0 -26
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -129
- package/dest/sequencer/checkpoint_builder.d.ts +0 -63
- package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
- package/dest/sequencer/checkpoint_builder.js +0 -131
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -217
- package/src/sequencer/checkpoint_builder.ts +0 -217
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
|
@@ -1,83 +1,488 @@
|
|
|
1
|
-
|
|
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, _initProto;
|
|
2
374
|
import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
3
|
-
import { MULTI_CALL_3_ADDRESS, Multicall3,
|
|
375
|
+
import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, MulticallForwarderRevertedError, buildSimulationOverridesStateOverride } from '@aztec/ethereum/contracts';
|
|
4
376
|
import { L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
|
|
5
|
-
import { WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
|
|
6
|
-
import { FormattedViemError, formatViemError, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
377
|
+
import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
|
|
378
|
+
import { FormattedViemError, formatViemError, mergeAbis, tryDecodeRevertReason, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
379
|
+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
380
|
+
import { trimmedBytesLength } from '@aztec/foundation/buffer';
|
|
10
381
|
import { pick } from '@aztec/foundation/collection';
|
|
382
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
11
383
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
384
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
13
385
|
import { createLogger } from '@aztec/foundation/log';
|
|
386
|
+
import { InterruptibleSleep } from '@aztec/foundation/sleep';
|
|
14
387
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
15
388
|
import { Timer } from '@aztec/foundation/timer';
|
|
16
|
-
import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
389
|
+
import { EmpireBaseAbi, ErrorsAbi, RollupAbi, SlashingProposerAbi } from '@aztec/l1-artifacts';
|
|
17
390
|
import { encodeSlashConsensusVotes } from '@aztec/slasher';
|
|
18
391
|
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
392
|
+
import { getLastL1SlotTimestampForL2Slot, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
393
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
394
|
+
import { encodeFunctionData, keccak256, toHex } from 'viem';
|
|
395
|
+
import { createL1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
396
|
+
import { SequencerBundleSimulator } from './sequencer-bundle-simulator.js';
|
|
21
397
|
import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
398
|
+
/**
|
|
399
|
+
* Returns true if the receipt indicates a successful send AND the expected event was emitted
|
|
400
|
+
* by the target contract. Both pieces are required: an aggregate3 entry that reverted will
|
|
401
|
+
* have receipt.status === 'success' but no event log.
|
|
402
|
+
*/ function extractEventSuccess(receipt, opts) {
|
|
403
|
+
if (!receipt || receipt.status !== 'success') {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
return !!tryExtractEvent(receipt.logs, opts.address.toString(), opts.abi, opts.eventName);
|
|
407
|
+
}
|
|
22
408
|
export const Actions = [
|
|
23
409
|
'invalidate-by-invalid-attestation',
|
|
24
410
|
'invalidate-by-insufficient-attestations',
|
|
25
411
|
'propose',
|
|
26
412
|
'governance-signal',
|
|
27
|
-
'empire-slashing-signal',
|
|
28
|
-
'create-empire-payload',
|
|
29
|
-
'execute-empire-payload',
|
|
30
413
|
'vote-offenses',
|
|
31
414
|
'execute-slash'
|
|
32
415
|
];
|
|
33
416
|
// Sorting for actions such that invalidations go before proposals, and proposals go before votes
|
|
34
417
|
export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
|
|
418
|
+
_dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader');
|
|
35
419
|
export class SequencerPublisher {
|
|
36
420
|
config;
|
|
421
|
+
static{
|
|
422
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
423
|
+
[
|
|
424
|
+
_dec,
|
|
425
|
+
2,
|
|
426
|
+
"sendRequests"
|
|
427
|
+
],
|
|
428
|
+
[
|
|
429
|
+
_dec1,
|
|
430
|
+
2,
|
|
431
|
+
"validateBlockHeader"
|
|
432
|
+
]
|
|
433
|
+
], []));
|
|
434
|
+
}
|
|
37
435
|
interrupted;
|
|
38
436
|
metrics;
|
|
437
|
+
bundleSimulator;
|
|
39
438
|
epochCache;
|
|
40
|
-
|
|
41
|
-
|
|
439
|
+
failedTxStore;
|
|
440
|
+
/**
|
|
441
|
+
* ABI used to decode raw revert payloads from dropped bundle entries when the original
|
|
442
|
+
* request did not carry an abi (e.g. the propose request). Merges every contract the
|
|
443
|
+
* publisher can route to so any of their custom errors decode against it.
|
|
444
|
+
*/ revertDecoderAbi;
|
|
42
445
|
lastActions;
|
|
43
|
-
isPayloadEmptyCache;
|
|
44
446
|
log;
|
|
45
447
|
ethereumSlotDuration;
|
|
448
|
+
aztecSlotDuration;
|
|
449
|
+
/** Date provider for wall-clock time. */ dateProvider;
|
|
46
450
|
blobClient;
|
|
47
|
-
/**
|
|
451
|
+
/** Optional callback to obtain a replacement publisher when the current one fails to send. */ getNextPublisher;
|
|
48
452
|
/** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Total used for emptier block from above test: 429k (of which 84k is 1x blob)
|
|
52
|
-
static PROPOSE_GAS_GUESS = 12_000_000n;
|
|
53
|
-
// A CALL to a cold address is 2700 gas
|
|
54
|
-
static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
|
|
55
|
-
// Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
|
|
56
|
-
static VOTE_GAS_GUESS = 800_000n;
|
|
453
|
+
/** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
|
|
454
|
+
/** Interruptible sleep used by sendRequestsAt to wait until a target timestamp. */ interruptibleSleep;
|
|
57
455
|
l1TxUtils;
|
|
58
456
|
rollupContract;
|
|
59
457
|
govProposerContract;
|
|
60
458
|
slashingProposerContract;
|
|
61
|
-
|
|
459
|
+
tracer;
|
|
62
460
|
requests;
|
|
63
461
|
constructor(config, deps){
|
|
64
462
|
this.config = config;
|
|
65
|
-
this.interrupted = false;
|
|
66
|
-
this.
|
|
67
|
-
|
|
463
|
+
this.interrupted = (_initProto(this), false);
|
|
464
|
+
this.revertDecoderAbi = mergeAbis([
|
|
465
|
+
RollupAbi,
|
|
466
|
+
SlashingProposerAbi,
|
|
467
|
+
EmpireBaseAbi,
|
|
468
|
+
ErrorsAbi
|
|
469
|
+
]);
|
|
68
470
|
this.lastActions = {};
|
|
69
|
-
this.
|
|
471
|
+
this.interruptibleSleep = new InterruptibleSleep();
|
|
70
472
|
this.requests = [];
|
|
71
473
|
this.log = deps.log ?? createLogger('sequencer:publisher');
|
|
72
474
|
this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
|
|
475
|
+
this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
|
|
476
|
+
this.dateProvider = deps.dateProvider;
|
|
73
477
|
this.epochCache = deps.epochCache;
|
|
74
478
|
this.lastActions = deps.lastActions;
|
|
75
|
-
this.blobClient = deps.blobClient
|
|
76
|
-
|
|
77
|
-
});
|
|
479
|
+
this.blobClient = deps.blobClient;
|
|
480
|
+
this.dateProvider = deps.dateProvider;
|
|
78
481
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
79
482
|
this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
|
|
483
|
+
this.tracer = telemetry.getTracer('SequencerPublisher');
|
|
80
484
|
this.l1TxUtils = deps.l1TxUtils;
|
|
485
|
+
this.getNextPublisher = deps.getNextPublisher;
|
|
81
486
|
this.rollupContract = deps.rollupContract;
|
|
82
487
|
this.govProposerContract = deps.governanceProposerContract;
|
|
83
488
|
this.slashingProposerContract = deps.slashingProposerContract;
|
|
@@ -86,15 +491,50 @@ export class SequencerPublisher {
|
|
|
86
491
|
const newSlashingProposer = await this.rollupContract.getSlashingProposer();
|
|
87
492
|
this.slashingProposerContract = newSlashingProposer;
|
|
88
493
|
});
|
|
89
|
-
this.slashFactoryContract = deps.slashFactoryContract;
|
|
90
494
|
// Initialize L1 fee analyzer for fisherman mode
|
|
91
495
|
if (config.fishermanMode) {
|
|
92
|
-
this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider,
|
|
496
|
+
this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, this.log.createChild('fee-analyzer'));
|
|
497
|
+
}
|
|
498
|
+
// Initialize fee asset price oracle
|
|
499
|
+
this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, this.log.createChild('price-oracle'));
|
|
500
|
+
// Initialize failed L1 tx store (optional, for test networks)
|
|
501
|
+
this.failedTxStore = createL1TxFailedStore(config.l1TxFailedStore, this.log);
|
|
502
|
+
this.bundleSimulator = new SequencerBundleSimulator({
|
|
503
|
+
getL1TxUtils: ()=>this.l1TxUtils,
|
|
504
|
+
rollupContract: this.rollupContract,
|
|
505
|
+
epochCache: this.epochCache,
|
|
506
|
+
log: this.log.createChild('bundle-simulator')
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Backs up a failed L1 transaction to the configured store for debugging.
|
|
511
|
+
* Does nothing if no store is configured.
|
|
512
|
+
*/ backupFailedTx(failedTx) {
|
|
513
|
+
if (!this.failedTxStore) {
|
|
514
|
+
return;
|
|
93
515
|
}
|
|
516
|
+
const tx = {
|
|
517
|
+
...failedTx,
|
|
518
|
+
timestamp: Date.now()
|
|
519
|
+
};
|
|
520
|
+
// Fire and forget - don't block on backup
|
|
521
|
+
void this.failedTxStore.then((store)=>store?.saveFailedTx(tx)).catch((err)=>{
|
|
522
|
+
this.log.warn(`Failed to backup failed L1 tx to store`, err);
|
|
523
|
+
});
|
|
94
524
|
}
|
|
95
525
|
getRollupContract() {
|
|
96
526
|
return this.rollupContract;
|
|
97
527
|
}
|
|
528
|
+
/**
|
|
529
|
+
* Gets the fee asset price modifier from the oracle.
|
|
530
|
+
*
|
|
531
|
+
* @param predictedParentEthPerFeeAssetE12 - Optional predicted parent eth-per-fee-asset (E12).
|
|
532
|
+
* Pipelined proposers should pass the value from the predicted parent fee header so the
|
|
533
|
+
* modifier matches the parent L1 will use when applying it.
|
|
534
|
+
* @returns The fee asset price modifier in basis points, or 0n if the oracle query fails.
|
|
535
|
+
*/ getFeeAssetPriceModifier(predictedParentEthPerFeeAssetE12) {
|
|
536
|
+
return this.feeAssetPriceOracle.computePriceModifier(predictedParentEthPerFeeAssetE12);
|
|
537
|
+
}
|
|
98
538
|
getSenderAddress() {
|
|
99
539
|
return this.l1TxUtils.getSenderAddress();
|
|
100
540
|
}
|
|
@@ -103,17 +543,11 @@ export class SequencerPublisher {
|
|
|
103
543
|
*/ getL1FeeAnalyzer() {
|
|
104
544
|
return this.l1FeeAnalyzer;
|
|
105
545
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Sets the proposer address to use for simulations in fisherman mode.
|
|
108
|
-
* @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
|
|
109
|
-
*/ setProposerAddressForSimulation(proposerAddress) {
|
|
110
|
-
this.proposerAddressForSimulation = proposerAddress;
|
|
111
|
-
}
|
|
112
546
|
addRequest(request) {
|
|
113
547
|
this.requests.push(request);
|
|
114
548
|
}
|
|
115
549
|
getCurrentL2Slot() {
|
|
116
|
-
return this.epochCache.
|
|
550
|
+
return this.epochCache.getSlotNow();
|
|
117
551
|
}
|
|
118
552
|
/**
|
|
119
553
|
* Clears all pending requests without sending them.
|
|
@@ -152,7 +586,7 @@ export class SequencerPublisher {
|
|
|
152
586
|
// Get the transaction requests
|
|
153
587
|
const l1Requests = requestsToAnalyze.map((r)=>r.request);
|
|
154
588
|
// Start the analysis
|
|
155
|
-
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit :
|
|
589
|
+
const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
|
|
156
590
|
this.log.info('Started L1 fee analysis', {
|
|
157
591
|
analysisId,
|
|
158
592
|
l2SlotNumber: l2SlotNumber.toString(),
|
|
@@ -166,11 +600,15 @@ export class SequencerPublisher {
|
|
|
166
600
|
}
|
|
167
601
|
/**
|
|
168
602
|
* Sends all requests that are still valid.
|
|
603
|
+
* @param targetSlot - The target L2 slot for this send. When provided (pipelined path via
|
|
604
|
+
* sendRequestsAt), it is threaded into bundleSimulate so the block.timestamp override
|
|
605
|
+
* matches the slot the propose is built for. When omitted, falls back to
|
|
606
|
+
* getCurrentL2Slot() for the non-pipelined callers in Sequencer.doWork.
|
|
169
607
|
* @returns one of:
|
|
170
608
|
* - A receipt and stats if the tx succeeded
|
|
171
609
|
* - a receipt and errorMsg if it failed on L1
|
|
172
610
|
* - undefined if no valid requests are found OR the tx failed to send.
|
|
173
|
-
*/ async sendRequests() {
|
|
611
|
+
*/ async sendRequests(targetSlot) {
|
|
174
612
|
const requestsToProcess = [
|
|
175
613
|
...this.requests
|
|
176
614
|
];
|
|
@@ -178,10 +616,9 @@ export class SequencerPublisher {
|
|
|
178
616
|
if (this.interrupted || requestsToProcess.length === 0) {
|
|
179
617
|
return undefined;
|
|
180
618
|
}
|
|
181
|
-
const currentL2Slot = this.getCurrentL2Slot();
|
|
619
|
+
const currentL2Slot = targetSlot ?? this.getCurrentL2Slot();
|
|
182
620
|
this.log.debug(`Sending requests on L2 slot ${currentL2Slot}`);
|
|
183
621
|
const validRequests = requestsToProcess.filter((request)=>request.lastValidL2Slot >= currentL2Slot);
|
|
184
|
-
const validActions = validRequests.map((x)=>x.action);
|
|
185
622
|
const expiredActions = requestsToProcess.filter((request)=>request.lastValidL2Slot < currentL2Slot).map((x)=>x.action);
|
|
186
623
|
if (validRequests.length !== requestsToProcess.length) {
|
|
187
624
|
this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
|
|
@@ -199,40 +636,53 @@ export class SequencerPublisher {
|
|
|
199
636
|
this.log.debug(`No valid requests to send`);
|
|
200
637
|
return undefined;
|
|
201
638
|
}
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
// See https://github.com/AztecProtocol/aztec-packages/issues/11513
|
|
205
|
-
const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
206
|
-
const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
|
|
207
|
-
if (blobConfigs.length > 1) {
|
|
208
|
-
throw new Error('Multiple blob configs found');
|
|
209
|
-
}
|
|
210
|
-
const blobConfig = blobConfigs[0];
|
|
211
|
-
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
212
|
-
const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
|
|
213
|
-
const gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
639
|
+
// Collect earliest txTimeoutAt across all requests.
|
|
640
|
+
const gasConfigs = validRequests.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
|
|
214
641
|
const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
|
|
215
|
-
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined;
|
|
216
|
-
const txConfig = {
|
|
217
|
-
gasLimit,
|
|
218
|
-
txTimeoutAt
|
|
219
|
-
};
|
|
642
|
+
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined;
|
|
220
643
|
// Sort the requests so that proposals always go first
|
|
221
644
|
// This ensures the committee gets precomputed correctly
|
|
222
645
|
validRequests.sort((a, b)=>compareActions(a.action, b.action));
|
|
223
646
|
try {
|
|
647
|
+
// Bundle-level eth_simulateV1: filters out entries that revert and derives the gasLimit.
|
|
648
|
+
const bundleResult = await this.bundleSimulator.simulate(validRequests, currentL2Slot);
|
|
649
|
+
if (bundleResult.kind === 'aborted') {
|
|
650
|
+
this.logDroppedInSim(bundleResult.droppedRequests);
|
|
651
|
+
void this.backupDroppedInSim(bundleResult.droppedRequests);
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
const { requests, droppedRequests, gasLimit } = bundleResult.kind === 'fallback' ? {
|
|
655
|
+
requests: bundleResult.requests,
|
|
656
|
+
droppedRequests: bundleResult.droppedRequests,
|
|
657
|
+
gasLimit: MAX_L1_TX_LIMIT
|
|
658
|
+
} : bundleResult;
|
|
659
|
+
this.logDroppedInSim(droppedRequests);
|
|
660
|
+
// Compute blobConfig from survivors (not original validRequests) so that if the propose
|
|
661
|
+
// entry was dropped by bundleSimulate we don't attach a blob-typed config to a non-blob tx.
|
|
662
|
+
const [blobConfig] = requests.filter((r)=>r.blobConfig).map((r)=>r.blobConfig);
|
|
663
|
+
const txConfig = {
|
|
664
|
+
gasLimit,
|
|
665
|
+
txTimeoutAt
|
|
666
|
+
};
|
|
224
667
|
this.log.debug('Forwarding transactions', {
|
|
225
|
-
|
|
668
|
+
requests: requests.map((request)=>request.action),
|
|
226
669
|
txConfig
|
|
227
670
|
});
|
|
228
|
-
const result = await
|
|
229
|
-
|
|
671
|
+
const result = await this.forwardWithPublisherRotation(requests, txConfig, blobConfig);
|
|
672
|
+
if (result === undefined) {
|
|
673
|
+
return undefined;
|
|
674
|
+
}
|
|
675
|
+
const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(requests, result);
|
|
676
|
+
const allFailedActions = [
|
|
677
|
+
...failedActions,
|
|
678
|
+
...droppedRequests.map((d)=>d.request.action)
|
|
679
|
+
];
|
|
230
680
|
return {
|
|
231
681
|
result,
|
|
232
682
|
expiredActions,
|
|
233
|
-
sentActions:
|
|
683
|
+
sentActions: requests.map((x)=>x.action),
|
|
234
684
|
successfulActions,
|
|
235
|
-
failedActions
|
|
685
|
+
failedActions: allFailedActions
|
|
236
686
|
};
|
|
237
687
|
} catch (err) {
|
|
238
688
|
const viemError = formatViemError(err);
|
|
@@ -246,49 +696,174 @@ export class SequencerPublisher {
|
|
|
246
696
|
}
|
|
247
697
|
}
|
|
248
698
|
}
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
this.log.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
|
|
258
|
-
result,
|
|
259
|
-
requests
|
|
699
|
+
/** Logs entries dropped by bundle simulation as warnings on the publisher's logger. */ logDroppedInSim(dropped) {
|
|
700
|
+
for (const drop of dropped){
|
|
701
|
+
const revertReasonDecoded = drop.revertReason ?? tryDecodeRevertReason(drop.returnData, this.revertDecoderAbi);
|
|
702
|
+
this.log.warn('Bundle entry dropped: action reverted in sim', {
|
|
703
|
+
action: drop.request.action,
|
|
704
|
+
revertReason: revertReasonDecoded ?? drop.returnData,
|
|
705
|
+
revertReasonDecoded,
|
|
706
|
+
returnData: drop.returnData
|
|
260
707
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/** Backs up entries dropped by bundle simulation, one record per dropped action. */ async backupDroppedInSim(dropped) {
|
|
711
|
+
if (dropped.length === 0) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
715
|
+
for (const { request: req } of dropped){
|
|
716
|
+
this.backupFailedTx({
|
|
717
|
+
id: keccak256(req.request.data),
|
|
718
|
+
failureType: 'simulation',
|
|
719
|
+
request: {
|
|
720
|
+
to: req.request.to,
|
|
721
|
+
data: req.request.data
|
|
722
|
+
},
|
|
723
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
724
|
+
error: {
|
|
725
|
+
message: 'Bundle entry dropped: action reverted in sim'
|
|
726
|
+
},
|
|
727
|
+
context: {
|
|
728
|
+
actions: [
|
|
729
|
+
req.action
|
|
730
|
+
],
|
|
731
|
+
sender: this.getSenderAddress().toString()
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Forwards transactions via Multicall3, rotating to the next available publisher if a send
|
|
738
|
+
* failure occurs (i.e. the tx never reached the chain).
|
|
739
|
+
* On-chain reverts and simulation errors are returned as-is without rotation.
|
|
740
|
+
*/ async forwardWithPublisherRotation(validRequests, txConfig, blobConfig) {
|
|
741
|
+
if (!txConfig?.gasLimit) {
|
|
742
|
+
throw new Error('gasLimit is required for bundled transactions');
|
|
743
|
+
}
|
|
744
|
+
const txConfigWithGasLimit = txConfig;
|
|
745
|
+
const triedAddresses = [];
|
|
746
|
+
let currentPublisher = this.l1TxUtils;
|
|
747
|
+
while(true){
|
|
748
|
+
if (txConfig.txTimeoutAt && new Date() > txConfig.txTimeoutAt) {
|
|
749
|
+
this.log.warn(`Tx timeout (${txConfig.txTimeoutAt.toISOString()}) elapsed; stopping publisher rotation`, {
|
|
750
|
+
triedAddresses: triedAddresses.map((a)=>a.toString())
|
|
751
|
+
});
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
triedAddresses.push(currentPublisher.getSenderAddress());
|
|
755
|
+
try {
|
|
756
|
+
const result = await Multicall3.forward(validRequests.map((r)=>r.request), currentPublisher, txConfigWithGasLimit, blobConfig, {
|
|
757
|
+
gasLimitRequired: true
|
|
758
|
+
});
|
|
759
|
+
this.l1TxUtils = currentPublisher;
|
|
760
|
+
return result;
|
|
761
|
+
} catch (err) {
|
|
762
|
+
if (err instanceof TimeoutError) {
|
|
763
|
+
throw err;
|
|
764
|
+
}
|
|
765
|
+
if (err instanceof MulticallForwarderRevertedError) {
|
|
766
|
+
this.log.error('Forwarder transaction reverted on-chain; not rotating publisher', err, {
|
|
767
|
+
transactionHash: err.receipt.transactionHash
|
|
768
|
+
});
|
|
769
|
+
return undefined;
|
|
770
|
+
}
|
|
771
|
+
const viemError = formatViemError(err);
|
|
772
|
+
if (!this.getNextPublisher) {
|
|
773
|
+
this.log.error('Failed to publish bundled transactions', viemError);
|
|
774
|
+
return undefined;
|
|
268
775
|
}
|
|
776
|
+
this.log.warn(`Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`, viemError);
|
|
777
|
+
const nextPublisher = await this.getNextPublisher([
|
|
778
|
+
...triedAddresses
|
|
779
|
+
]);
|
|
780
|
+
if (!nextPublisher) {
|
|
781
|
+
this.log.error(`All available publishers exhausted (tried ${triedAddresses.length}), failed to publish bundled transactions`, viemError, {
|
|
782
|
+
triedAddresses: triedAddresses.map((a)=>a.toString())
|
|
783
|
+
});
|
|
784
|
+
return undefined;
|
|
785
|
+
}
|
|
786
|
+
currentPublisher = nextPublisher;
|
|
269
787
|
}
|
|
270
|
-
return {
|
|
271
|
-
successfulActions,
|
|
272
|
-
failedActions
|
|
273
|
-
};
|
|
274
788
|
}
|
|
275
789
|
}
|
|
790
|
+
/*
|
|
791
|
+
* Schedules sending all enqueued requests at (or after) the start of the given L2 slot.
|
|
792
|
+
* Sleeps until one L1 slot before the L2 slot boundary so the tx has a chance of being
|
|
793
|
+
* picked up by the first L1 block of the L2 slot.
|
|
794
|
+
* NB: there is a known correctness risk — being included in the L1 block right before the
|
|
795
|
+
* L2 slot starts would revert propose with HeaderLib__InvalidSlotNumber.
|
|
796
|
+
* Uses InterruptibleSleep so it can be cancelled via interrupt().
|
|
797
|
+
*/ async sendRequestsAt(targetSlot) {
|
|
798
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
799
|
+
// Start of the target L2 slot, in ms (getTimestampForSlot returns seconds).
|
|
800
|
+
const startOfTargetSlotMs = Number(getTimestampForSlot(targetSlot, l1Constants)) * 1000;
|
|
801
|
+
// Aim to be in the mempool one L1 slot before the L2 slot starts, so we have a chance of
|
|
802
|
+
// being picked up by the first L1 block of the L2 slot.
|
|
803
|
+
const submitAfterMs = startOfTargetSlotMs - Number(this.ethereumSlotDuration) * 1000;
|
|
804
|
+
const sleepMs = submitAfterMs - this.dateProvider.now();
|
|
805
|
+
if (sleepMs > 0) {
|
|
806
|
+
this.log.debug(`Sleeping ${sleepMs}ms before sending requests`, {
|
|
807
|
+
targetSlot,
|
|
808
|
+
submitAfterMs
|
|
809
|
+
});
|
|
810
|
+
await this.interruptibleSleep.sleep(sleepMs);
|
|
811
|
+
}
|
|
812
|
+
if (this.interrupted) {
|
|
813
|
+
return undefined;
|
|
814
|
+
}
|
|
815
|
+
return this.sendRequests(targetSlot);
|
|
816
|
+
}
|
|
817
|
+
callbackBundledTransactions(requests, result) {
|
|
818
|
+
const actionsListStr = requests.map((r)=>r.action).join(', ');
|
|
819
|
+
this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
|
|
820
|
+
result,
|
|
821
|
+
requests: requests.map((r)=>({
|
|
822
|
+
...r,
|
|
823
|
+
// Avoid logging large blob data
|
|
824
|
+
blobConfig: r.blobConfig ? {
|
|
825
|
+
...r.blobConfig,
|
|
826
|
+
blobs: r.blobConfig.blobs.map((b)=>({
|
|
827
|
+
size: trimmedBytesLength(b)
|
|
828
|
+
}))
|
|
829
|
+
} : undefined
|
|
830
|
+
}))
|
|
831
|
+
});
|
|
832
|
+
const successfulActions = [];
|
|
833
|
+
const failedActions = [];
|
|
834
|
+
for (const request of requests){
|
|
835
|
+
if (request.checkSuccess(request.request, result)) {
|
|
836
|
+
successfulActions.push(request.action);
|
|
837
|
+
} else {
|
|
838
|
+
failedActions.push(request.action);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return {
|
|
842
|
+
successfulActions,
|
|
843
|
+
failedActions
|
|
844
|
+
};
|
|
845
|
+
}
|
|
276
846
|
/**
|
|
277
|
-
* @notice Will call `
|
|
847
|
+
* @notice Will call `canProposeAt` to make sure that it is possible to propose
|
|
278
848
|
* @param tipArchive - The archive to check
|
|
279
849
|
* @returns The slot and block number if it is possible to propose, undefined otherwise
|
|
280
|
-
*/
|
|
850
|
+
*/ async canProposeAt(tipArchive, msgSender, simulationOverridesPlan) {
|
|
281
851
|
// TODO: #14291 - should loop through multiple keys to check if any of them can propose
|
|
282
|
-
|
|
852
|
+
// These errors are expected when we cannot actually propose right now — usually because our
|
|
853
|
+
// local view of the chain is ahead of L1 (proposed parent hasn't landed yet, or someone
|
|
854
|
+
// else has just landed the slot, or the archive override doesn't match). We log a warn and
|
|
855
|
+
// skip the proposal; we do NOT treat these as bugs.
|
|
856
|
+
const expectedErrors = [
|
|
283
857
|
'SlotAlreadyInChain',
|
|
284
858
|
'InvalidProposer',
|
|
285
859
|
'InvalidArchive'
|
|
286
860
|
];
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
861
|
+
const pipelined = this.epochCache.isProposerPipeliningEnabled();
|
|
862
|
+
const slotOffset = pipelined ? this.aztecSlotDuration : 0n;
|
|
863
|
+
const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
|
|
864
|
+
return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan)).catch((err)=>{
|
|
865
|
+
if (err instanceof FormattedViemError && expectedErrors.find((e)=>err.message.includes(e))) {
|
|
866
|
+
this.log.warn(`Failed canProposeAtTime check with ${expectedErrors.find((e)=>err.message.includes(e))}`, {
|
|
292
867
|
error: err.message
|
|
293
868
|
});
|
|
294
869
|
} else {
|
|
@@ -302,23 +877,23 @@ export class SequencerPublisher {
|
|
|
302
877
|
* @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
|
|
303
878
|
* It will throw if the block header is invalid.
|
|
304
879
|
* @param header - The block header to validate
|
|
305
|
-
*/ async validateBlockHeader(header,
|
|
880
|
+
*/ async validateBlockHeader(header, simulationOverridesPlan) {
|
|
306
881
|
const flags = {
|
|
307
882
|
ignoreDA: true,
|
|
308
883
|
ignoreSignatures: true
|
|
309
884
|
};
|
|
310
885
|
const args = [
|
|
311
886
|
header.toViem(),
|
|
312
|
-
CommitteeAttestationsAndSigners.
|
|
887
|
+
CommitteeAttestationsAndSigners.packAttestations([]),
|
|
313
888
|
[],
|
|
314
889
|
Signature.empty().toViemSignature(),
|
|
315
890
|
`0x${'0'.repeat(64)}`,
|
|
316
|
-
header.
|
|
891
|
+
header.blobsHash.toString(),
|
|
317
892
|
flags
|
|
318
893
|
];
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
const stateOverrides = await this.rollupContract
|
|
894
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
895
|
+
const ts = getLastL1SlotTimestampForL2Slot(header.slotNumber, l1Constants);
|
|
896
|
+
const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
322
897
|
let balance = 0n;
|
|
323
898
|
if (this.config.fishermanMode) {
|
|
324
899
|
// In fisherman mode, we can't know where the proposer is publishing from
|
|
@@ -340,39 +915,43 @@ export class SequencerPublisher {
|
|
|
340
915
|
}),
|
|
341
916
|
from: MULTI_CALL_3_ADDRESS
|
|
342
917
|
}, {
|
|
343
|
-
time: ts
|
|
918
|
+
time: ts
|
|
344
919
|
}, stateOverrides);
|
|
345
920
|
this.log.debug(`Simulated validateHeader`);
|
|
346
921
|
}
|
|
347
922
|
/**
|
|
348
|
-
* Simulate making a call to invalidate a
|
|
349
|
-
* @param
|
|
350
|
-
*/ async
|
|
923
|
+
* Simulate making a call to invalidate a checkpoint with invalid attestations. Returns undefined if no need to invalidate.
|
|
924
|
+
* @param validationResult - The validation result indicating which checkpoint to invalidate (as returned by the archiver)
|
|
925
|
+
*/ async simulateInvalidateCheckpoint(validationResult) {
|
|
351
926
|
if (validationResult.valid) {
|
|
352
927
|
return undefined;
|
|
353
928
|
}
|
|
354
|
-
const { reason,
|
|
355
|
-
const
|
|
929
|
+
const { reason, checkpoint } = validationResult;
|
|
930
|
+
const checkpointNumber = checkpoint.checkpointNumber;
|
|
356
931
|
const logData = {
|
|
357
|
-
...
|
|
932
|
+
...checkpoint,
|
|
358
933
|
reason
|
|
359
934
|
};
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
this.log.verbose(`Skipping
|
|
363
|
-
|
|
935
|
+
const currentCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
936
|
+
if (currentCheckpointNumber < checkpointNumber) {
|
|
937
|
+
this.log.verbose(`Skipping checkpoint ${checkpointNumber} invalidation since it has already been removed from the pending chain`, {
|
|
938
|
+
currentCheckpointNumber,
|
|
364
939
|
...logData
|
|
365
940
|
});
|
|
366
941
|
return undefined;
|
|
367
942
|
}
|
|
368
|
-
const request = this.
|
|
369
|
-
this.log.debug(`Simulating invalidate
|
|
943
|
+
const request = this.buildInvalidateCheckpointRequest(validationResult);
|
|
944
|
+
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, {
|
|
370
945
|
...logData,
|
|
371
946
|
request
|
|
372
947
|
});
|
|
948
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
373
949
|
try {
|
|
374
|
-
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined,
|
|
375
|
-
|
|
950
|
+
const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
|
|
951
|
+
request.abi ?? [],
|
|
952
|
+
ErrorsAbi
|
|
953
|
+
]));
|
|
954
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
376
955
|
...logData,
|
|
377
956
|
request,
|
|
378
957
|
gasUsed
|
|
@@ -380,96 +959,83 @@ export class SequencerPublisher {
|
|
|
380
959
|
return {
|
|
381
960
|
request,
|
|
382
961
|
gasUsed,
|
|
383
|
-
|
|
384
|
-
|
|
962
|
+
checkpointNumber,
|
|
963
|
+
forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
|
|
964
|
+
lastArchive: validationResult.checkpoint.lastArchive,
|
|
385
965
|
reason
|
|
386
966
|
};
|
|
387
967
|
} catch (err) {
|
|
388
968
|
const viemError = formatViemError(err);
|
|
389
|
-
// If the error is due to the
|
|
390
|
-
// we can safely ignore it and return undefined so we go ahead with
|
|
391
|
-
if (viemError.message?.includes('
|
|
392
|
-
this.log.verbose(`Simulation for invalidate
|
|
969
|
+
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
970
|
+
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
971
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
972
|
+
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
|
|
393
973
|
...logData,
|
|
394
974
|
request,
|
|
395
975
|
error: viemError.message
|
|
396
976
|
});
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
this.log.verbose(`
|
|
977
|
+
const latestProposedCheckpointNumber = await this.rollupContract.getCheckpointNumber();
|
|
978
|
+
if (latestProposedCheckpointNumber < checkpointNumber) {
|
|
979
|
+
this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
|
|
400
980
|
...logData
|
|
401
981
|
});
|
|
402
982
|
return undefined;
|
|
403
983
|
} else {
|
|
404
|
-
this.log.error(`Simulation for invalidate ${
|
|
405
|
-
throw new Error(`Failed to simulate invalidate
|
|
984
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed and it is still in pending chain`, viemError, logData);
|
|
985
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber} while it is still in pending chain`, {
|
|
406
986
|
cause: viemError
|
|
407
987
|
});
|
|
408
988
|
}
|
|
409
989
|
}
|
|
410
|
-
// Otherwise, throw. We cannot build the next
|
|
411
|
-
this.log.error(`Simulation for invalidate
|
|
412
|
-
|
|
990
|
+
// Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
|
|
991
|
+
this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
|
|
992
|
+
this.backupFailedTx({
|
|
993
|
+
id: keccak256(request.data),
|
|
994
|
+
failureType: 'simulation',
|
|
995
|
+
request: {
|
|
996
|
+
to: request.to,
|
|
997
|
+
data: request.data,
|
|
998
|
+
value: request.value?.toString()
|
|
999
|
+
},
|
|
1000
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
1001
|
+
error: {
|
|
1002
|
+
message: viemError.message,
|
|
1003
|
+
name: viemError.name
|
|
1004
|
+
},
|
|
1005
|
+
context: {
|
|
1006
|
+
actions: [
|
|
1007
|
+
`invalidate-${reason}`
|
|
1008
|
+
],
|
|
1009
|
+
checkpointNumber,
|
|
1010
|
+
sender: this.getSenderAddress().toString()
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
|
|
413
1014
|
cause: viemError
|
|
414
1015
|
});
|
|
415
1016
|
}
|
|
416
1017
|
}
|
|
417
|
-
|
|
1018
|
+
buildInvalidateCheckpointRequest(validationResult) {
|
|
418
1019
|
if (validationResult.valid) {
|
|
419
|
-
throw new Error('Cannot invalidate a valid
|
|
1020
|
+
throw new Error('Cannot invalidate a valid checkpoint');
|
|
420
1021
|
}
|
|
421
|
-
const {
|
|
1022
|
+
const { checkpoint, committee, reason } = validationResult;
|
|
422
1023
|
const logData = {
|
|
423
|
-
...
|
|
1024
|
+
...checkpoint,
|
|
424
1025
|
reason
|
|
425
1026
|
};
|
|
426
|
-
this.log.debug(`
|
|
427
|
-
const attestationsAndSigners =
|
|
1027
|
+
this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
|
|
1028
|
+
const attestationsAndSigners = CommitteeAttestationsAndSigners.packAttestations(validationResult.attestations);
|
|
428
1029
|
if (reason === 'invalid-attestation') {
|
|
429
|
-
return this.rollupContract.buildInvalidateBadAttestationRequest(
|
|
1030
|
+
return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
|
|
430
1031
|
} else if (reason === 'insufficient-attestations') {
|
|
431
|
-
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(
|
|
1032
|
+
return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee);
|
|
432
1033
|
} else {
|
|
433
1034
|
const _ = reason;
|
|
434
1035
|
throw new Error(`Unknown reason for invalidation`);
|
|
435
1036
|
}
|
|
436
1037
|
}
|
|
437
|
-
|
|
438
|
-
const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
|
|
439
|
-
// TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
|
|
440
|
-
// If we have no attestations, we still need to provide the empty attestations
|
|
441
|
-
// so that the committee is recalculated correctly
|
|
442
|
-
// const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
|
|
443
|
-
// if (ignoreSignatures) {
|
|
444
|
-
// const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
|
|
445
|
-
// if (!committee) {
|
|
446
|
-
// this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
447
|
-
// throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
|
|
448
|
-
// }
|
|
449
|
-
// attestationsAndSigners.attestations = committee.map(committeeMember =>
|
|
450
|
-
// CommitteeAttestation.fromAddress(committeeMember),
|
|
451
|
-
// );
|
|
452
|
-
// }
|
|
453
|
-
const blobFields = checkpoint.toBlobFields();
|
|
454
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
455
|
-
const blobInput = getPrefixedEthBlobCommitments(blobs);
|
|
456
|
-
const args = [
|
|
457
|
-
{
|
|
458
|
-
header: checkpoint.header.toViem(),
|
|
459
|
-
archive: toHex(checkpoint.archive.root.toBuffer()),
|
|
460
|
-
oracleInput: {
|
|
461
|
-
feeAssetPriceModifier: 0n
|
|
462
|
-
}
|
|
463
|
-
},
|
|
464
|
-
attestationsAndSigners.getPackedAttestations(),
|
|
465
|
-
attestationsAndSigners.getSigners().map((signer)=>signer.toString()),
|
|
466
|
-
attestationsAndSignersSignature.toViemSignature(),
|
|
467
|
-
blobInput
|
|
468
|
-
];
|
|
469
|
-
await this.simulateProposeTx(args, ts, options);
|
|
470
|
-
return ts;
|
|
471
|
-
}
|
|
472
|
-
async enqueueCastSignalHelper(slotNumber, timestamp, signalType, payload, base, signerAddress, signer) {
|
|
1038
|
+
async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
|
|
473
1039
|
if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
|
|
474
1040
|
this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
|
|
475
1041
|
return false;
|
|
@@ -489,10 +1055,28 @@ export class SequencerPublisher {
|
|
|
489
1055
|
if (roundInfo.lastSignalSlot >= slotNumber) {
|
|
490
1056
|
return false;
|
|
491
1057
|
}
|
|
492
|
-
if (await
|
|
1058
|
+
if (await base.isPayloadEmpty(payload)) {
|
|
493
1059
|
this.log.warn(`Skipping vote cast for payload with empty code`);
|
|
494
1060
|
return false;
|
|
495
1061
|
}
|
|
1062
|
+
// Skip signaling if there is already a live (non-terminal) Governance proposal for this
|
|
1063
|
+
// payload. This is intentionally not cached: a previously-live proposal may transition to
|
|
1064
|
+
// a terminal state (Dropped/Rejected/Expired/Executed), at which point we may want to re-signal
|
|
1065
|
+
// the same payload in a future round.
|
|
1066
|
+
let proposed = false;
|
|
1067
|
+
try {
|
|
1068
|
+
proposed = await base.hasActiveProposalWithPayload(payload.toString());
|
|
1069
|
+
} catch (err) {
|
|
1070
|
+
// We deliberately swallow the error and proceed to signal. Failing closed (skipping the
|
|
1071
|
+
// signal) on transient RPC errors would let a flaky L1 endpoint silence governance
|
|
1072
|
+
// participation entirely; failing open at worst produces a duplicate signal that the
|
|
1073
|
+
// contract will simply count alongside others in the round.
|
|
1074
|
+
this.log.error(`Failed to check if payload ${payload} was already proposed (signalling anyway)`, err);
|
|
1075
|
+
}
|
|
1076
|
+
if (proposed) {
|
|
1077
|
+
this.log.info(`Payload ${payload} has a live governance proposal, stopping signals`);
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
496
1080
|
const cachedLastVote = this.lastActions[signalType];
|
|
497
1081
|
this.lastActions[signalType] = slotNumber;
|
|
498
1082
|
const action = signalType;
|
|
@@ -503,27 +1087,17 @@ export class SequencerPublisher {
|
|
|
503
1087
|
signer: this.l1TxUtils.client.account?.address,
|
|
504
1088
|
lastValidL2Slot: slotNumber
|
|
505
1089
|
});
|
|
506
|
-
try {
|
|
507
|
-
await this.l1TxUtils.simulate(request, {
|
|
508
|
-
time: timestamp
|
|
509
|
-
}, [], ErrorsAbi);
|
|
510
|
-
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
|
|
511
|
-
request
|
|
512
|
-
});
|
|
513
|
-
} catch (err) {
|
|
514
|
-
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
|
|
515
|
-
// Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
|
|
516
|
-
}
|
|
517
1090
|
// TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
|
|
518
1091
|
this.addRequest({
|
|
519
|
-
gasConfig: {
|
|
520
|
-
gasLimit: SequencerPublisher.VOTE_GAS_GUESS
|
|
521
|
-
},
|
|
522
1092
|
action,
|
|
523
1093
|
request,
|
|
524
1094
|
lastValidL2Slot: slotNumber,
|
|
525
1095
|
checkSuccess: (_request, result)=>{
|
|
526
|
-
const success = result &&
|
|
1096
|
+
const success = result && extractEventSuccess(result.receipt, {
|
|
1097
|
+
address: base.address.toString(),
|
|
1098
|
+
abi: EmpireBaseAbi,
|
|
1099
|
+
eventName: 'SignalCast'
|
|
1100
|
+
});
|
|
527
1101
|
const logData = {
|
|
528
1102
|
...result,
|
|
529
1103
|
slotNumber,
|
|
@@ -542,68 +1116,20 @@ export class SequencerPublisher {
|
|
|
542
1116
|
});
|
|
543
1117
|
return true;
|
|
544
1118
|
}
|
|
545
|
-
async isPayloadEmpty(payload) {
|
|
546
|
-
const key = payload.toString();
|
|
547
|
-
const cached = this.isPayloadEmptyCache.get(key);
|
|
548
|
-
if (cached) {
|
|
549
|
-
return cached;
|
|
550
|
-
}
|
|
551
|
-
const isEmpty = !await this.l1TxUtils.getCode(payload);
|
|
552
|
-
this.isPayloadEmptyCache.set(key, isEmpty);
|
|
553
|
-
return isEmpty;
|
|
554
|
-
}
|
|
555
1119
|
/**
|
|
556
1120
|
* Enqueues a governance castSignal transaction to cast a signal for a given slot number.
|
|
557
1121
|
* @param slotNumber - The slot number to cast a signal for.
|
|
558
|
-
* @param timestamp - The timestamp of the slot to cast a signal for.
|
|
559
1122
|
* @returns True if the signal was successfully enqueued, false otherwise.
|
|
560
|
-
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber,
|
|
561
|
-
return this.enqueueCastSignalHelper(slotNumber,
|
|
1123
|
+
*/ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
|
|
1124
|
+
return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
|
|
562
1125
|
}
|
|
563
|
-
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber,
|
|
1126
|
+
/** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
|
|
564
1127
|
if (actions.length === 0) {
|
|
565
1128
|
this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
|
|
566
1129
|
return false;
|
|
567
1130
|
}
|
|
568
1131
|
for (const action of actions){
|
|
569
1132
|
switch(action.type){
|
|
570
|
-
case 'vote-empire-payload':
|
|
571
|
-
{
|
|
572
|
-
if (this.slashingProposerContract?.type !== 'empire') {
|
|
573
|
-
this.log.error('Cannot vote for empire payload on non-empire slashing contract');
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
|
|
577
|
-
signerAddress
|
|
578
|
-
});
|
|
579
|
-
await this.enqueueCastSignalHelper(slotNumber, timestamp, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
case 'create-empire-payload':
|
|
583
|
-
{
|
|
584
|
-
this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, {
|
|
585
|
-
slotNumber,
|
|
586
|
-
signerAddress
|
|
587
|
-
});
|
|
588
|
-
const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
|
|
589
|
-
await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber, timestamp);
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
case 'execute-empire-payload':
|
|
593
|
-
{
|
|
594
|
-
this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, {
|
|
595
|
-
slotNumber,
|
|
596
|
-
signerAddress
|
|
597
|
-
});
|
|
598
|
-
if (this.slashingProposerContract?.type !== 'empire') {
|
|
599
|
-
this.log.error('Cannot execute slashing payload on non-empire slashing contract');
|
|
600
|
-
return false;
|
|
601
|
-
}
|
|
602
|
-
const empireSlashingProposer = this.slashingProposerContract;
|
|
603
|
-
const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
|
|
604
|
-
await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber, timestamp);
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
1133
|
case 'vote-offenses':
|
|
608
1134
|
{
|
|
609
1135
|
this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
|
|
@@ -612,14 +1138,17 @@ export class SequencerPublisher {
|
|
|
612
1138
|
votesCount: action.votes.length,
|
|
613
1139
|
signerAddress
|
|
614
1140
|
});
|
|
615
|
-
if (this.slashingProposerContract
|
|
616
|
-
this.log.error('
|
|
1141
|
+
if (!this.slashingProposerContract) {
|
|
1142
|
+
this.log.error('No slashing proposer contract available');
|
|
617
1143
|
return false;
|
|
618
1144
|
}
|
|
619
|
-
const tallySlashingProposer = this.slashingProposerContract;
|
|
620
1145
|
const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
|
|
621
|
-
const request = await
|
|
622
|
-
|
|
1146
|
+
const request = await this.slashingProposerContract.buildVoteRequestFromSigner(votes, slotNumber, signer);
|
|
1147
|
+
this.enqueueRequest('vote-offenses', request, {
|
|
1148
|
+
address: this.slashingProposerContract.address.toString(),
|
|
1149
|
+
abi: SlashingProposerAbi,
|
|
1150
|
+
eventName: 'VoteCast'
|
|
1151
|
+
}, slotNumber);
|
|
623
1152
|
break;
|
|
624
1153
|
}
|
|
625
1154
|
case 'execute-slash':
|
|
@@ -629,13 +1158,16 @@ export class SequencerPublisher {
|
|
|
629
1158
|
round: action.round,
|
|
630
1159
|
signerAddress
|
|
631
1160
|
});
|
|
632
|
-
if (this.slashingProposerContract
|
|
633
|
-
this.log.error('
|
|
1161
|
+
if (!this.slashingProposerContract) {
|
|
1162
|
+
this.log.error('No slashing proposer contract available');
|
|
634
1163
|
return false;
|
|
635
1164
|
}
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
1165
|
+
const executeRequest = this.slashingProposerContract.buildExecuteRoundRequest(action.round, action.committees);
|
|
1166
|
+
this.enqueueRequest('execute-slash', executeRequest, {
|
|
1167
|
+
address: this.slashingProposerContract.address.toString(),
|
|
1168
|
+
abi: SlashingProposerAbi,
|
|
1169
|
+
eventName: 'RoundExecuted'
|
|
1170
|
+
}, slotNumber);
|
|
639
1171
|
break;
|
|
640
1172
|
}
|
|
641
1173
|
default:
|
|
@@ -647,70 +1179,57 @@ export class SequencerPublisher {
|
|
|
647
1179
|
}
|
|
648
1180
|
return true;
|
|
649
1181
|
}
|
|
650
|
-
/**
|
|
1182
|
+
/** Enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
|
|
651
1183
|
const checkpointHeader = checkpoint.header;
|
|
652
1184
|
const blobFields = checkpoint.toBlobFields();
|
|
653
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
1185
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
654
1186
|
const proposeTxArgs = {
|
|
655
1187
|
header: checkpointHeader,
|
|
656
1188
|
archive: checkpoint.archive.root.toBuffer(),
|
|
657
1189
|
blobs,
|
|
658
1190
|
attestationsAndSigners,
|
|
659
|
-
attestationsAndSignersSignature
|
|
1191
|
+
attestationsAndSignersSignature,
|
|
1192
|
+
feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
|
|
660
1193
|
};
|
|
661
|
-
let ts;
|
|
662
|
-
try {
|
|
663
|
-
// @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
|
|
664
|
-
// This means that we can avoid the simulation issues in later checks.
|
|
665
|
-
// By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
|
|
666
|
-
// make time consistency checks break.
|
|
667
|
-
// TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
|
|
668
|
-
ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
|
|
669
|
-
} catch (err) {
|
|
670
|
-
this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
|
|
671
|
-
...checkpoint.getStats(),
|
|
672
|
-
slotNumber: checkpoint.header.slotNumber,
|
|
673
|
-
forcePendingBlockNumber: opts.forcePendingBlockNumber
|
|
674
|
-
});
|
|
675
|
-
throw err;
|
|
676
|
-
}
|
|
677
1194
|
this.log.verbose(`Enqueuing checkpoint propose transaction`, {
|
|
678
1195
|
...checkpoint.toCheckpointInfo(),
|
|
679
|
-
|
|
1196
|
+
txTimeoutAt: opts.txTimeoutAt
|
|
1197
|
+
});
|
|
1198
|
+
await this.addProposeTx(checkpoint, proposeTxArgs, {
|
|
1199
|
+
txTimeoutAt: opts.txTimeoutAt
|
|
680
1200
|
});
|
|
681
|
-
await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
|
|
682
1201
|
}
|
|
683
|
-
|
|
1202
|
+
enqueueInvalidateCheckpoint(request, opts = {}) {
|
|
684
1203
|
if (!request) {
|
|
685
1204
|
return;
|
|
686
1205
|
}
|
|
687
|
-
|
|
688
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
|
|
689
|
-
const { gasUsed, blockNumber } = request;
|
|
1206
|
+
const { gasUsed, checkpointNumber } = request;
|
|
690
1207
|
const logData = {
|
|
691
1208
|
gasUsed,
|
|
692
|
-
|
|
693
|
-
gasLimit,
|
|
1209
|
+
checkpointNumber,
|
|
694
1210
|
opts
|
|
695
1211
|
};
|
|
696
|
-
this.log.verbose(`Enqueuing invalidate
|
|
1212
|
+
this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
|
|
697
1213
|
this.addRequest({
|
|
698
1214
|
action: `invalidate-by-${request.reason}`,
|
|
699
1215
|
request: request.request,
|
|
700
|
-
gasConfig: {
|
|
701
|
-
gasLimit,
|
|
1216
|
+
gasConfig: opts.txTimeoutAt ? {
|
|
702
1217
|
txTimeoutAt: opts.txTimeoutAt
|
|
703
|
-
},
|
|
1218
|
+
} : undefined,
|
|
704
1219
|
lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
|
|
705
1220
|
checkSuccess: (_req, result)=>{
|
|
706
|
-
const success = result &&
|
|
1221
|
+
const success = result && extractEventSuccess(result.receipt, {
|
|
1222
|
+
address: this.rollupContract.address,
|
|
1223
|
+
abi: RollupAbi,
|
|
1224
|
+
eventName: 'CheckpointInvalidated'
|
|
1225
|
+
});
|
|
707
1226
|
if (!success) {
|
|
708
|
-
this.log.warn(`Invalidate
|
|
1227
|
+
this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
|
|
709
1228
|
...result,
|
|
710
1229
|
...logData
|
|
711
1230
|
});
|
|
712
1231
|
} else {
|
|
713
|
-
this.log.info(`Invalidate
|
|
1232
|
+
this.log.info(`Invalidate checkpoint ${request.checkpointNumber} succeeded`, {
|
|
714
1233
|
...result,
|
|
715
1234
|
...logData
|
|
716
1235
|
});
|
|
@@ -719,57 +1238,36 @@ export class SequencerPublisher {
|
|
|
719
1238
|
}
|
|
720
1239
|
});
|
|
721
1240
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
};
|
|
1241
|
+
/**
|
|
1242
|
+
* Dedup-checked enqueue helper for actions that are simulated at bundle-send time rather
|
|
1243
|
+
* than at enqueue time. Validates the (action, slot) dedup key, sets `lastActions`, and
|
|
1244
|
+
* enqueues without a gasLimit so the bundle simulate sets the only gasLimit that matters.
|
|
1245
|
+
*/ enqueueRequest(action, request, eventOpts, slotNumber) {
|
|
728
1246
|
if (this.lastActions[action] && this.lastActions[action] === slotNumber) {
|
|
729
1247
|
this.log.debug(`Skipping duplicate action ${action} for slot ${slotNumber}`);
|
|
730
1248
|
return false;
|
|
731
1249
|
}
|
|
732
1250
|
const cachedLastActionSlot = this.lastActions[action];
|
|
733
1251
|
this.lastActions[action] = slotNumber;
|
|
734
|
-
this.log.debug(`
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
({ gasUsed } = await this.l1TxUtils.simulate(request, {
|
|
738
|
-
time: timestamp
|
|
739
|
-
}, [], ErrorsAbi)); // TODO(palla/slash): Check the timestamp logic
|
|
740
|
-
this.log.verbose(`Simulation for ${action} succeeded`, {
|
|
741
|
-
...logData,
|
|
742
|
-
request,
|
|
743
|
-
gasUsed
|
|
744
|
-
});
|
|
745
|
-
} catch (err) {
|
|
746
|
-
const viemError = formatViemError(err);
|
|
747
|
-
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
748
|
-
return false;
|
|
749
|
-
}
|
|
750
|
-
// We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
|
|
751
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
|
|
752
|
-
logData.gasLimit = gasLimit;
|
|
753
|
-
this.log.debug(`Enqueuing ${action}`, logData);
|
|
1252
|
+
this.log.debug(`Enqueuing ${action}`, {
|
|
1253
|
+
slotNumber
|
|
1254
|
+
});
|
|
754
1255
|
this.addRequest({
|
|
755
1256
|
action,
|
|
756
1257
|
request,
|
|
757
|
-
gasConfig: {
|
|
758
|
-
gasLimit
|
|
759
|
-
},
|
|
760
1258
|
lastValidL2Slot: slotNumber,
|
|
761
|
-
checkSuccess: (
|
|
762
|
-
const success = result && result.receipt
|
|
1259
|
+
checkSuccess: (_request, result)=>{
|
|
1260
|
+
const success = result && extractEventSuccess(result.receipt, eventOpts);
|
|
763
1261
|
if (!success) {
|
|
764
1262
|
this.log.warn(`Action ${action} at ${slotNumber} failed`, {
|
|
765
1263
|
...result,
|
|
766
|
-
|
|
1264
|
+
slotNumber
|
|
767
1265
|
});
|
|
768
1266
|
this.lastActions[action] = cachedLastActionSlot;
|
|
769
1267
|
} else {
|
|
770
1268
|
this.log.info(`Action ${action} at ${slotNumber} succeeded`, {
|
|
771
1269
|
...result,
|
|
772
|
-
|
|
1270
|
+
slotNumber
|
|
773
1271
|
});
|
|
774
1272
|
}
|
|
775
1273
|
return !!success;
|
|
@@ -784,13 +1282,14 @@ export class SequencerPublisher {
|
|
|
784
1282
|
* A call to `restart` is required before you can continue publishing.
|
|
785
1283
|
*/ interrupt() {
|
|
786
1284
|
this.interrupted = true;
|
|
1285
|
+
this.interruptibleSleep.interrupt();
|
|
787
1286
|
this.l1TxUtils.interrupt();
|
|
788
1287
|
}
|
|
789
1288
|
/** Restarts the publisher after calling `interrupt`. */ restart() {
|
|
790
1289
|
this.interrupted = false;
|
|
791
1290
|
this.l1TxUtils.restart();
|
|
792
1291
|
}
|
|
793
|
-
async prepareProposeTx(encodedData
|
|
1292
|
+
async prepareProposeTx(encodedData) {
|
|
794
1293
|
const kzg = Blob.getViemKzgInstance();
|
|
795
1294
|
const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
|
|
796
1295
|
this.log.debug('Validating blob input', {
|
|
@@ -804,7 +1303,11 @@ export class SequencerPublisher {
|
|
|
804
1303
|
blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
|
|
805
1304
|
this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
|
|
806
1305
|
} else {
|
|
807
|
-
//
|
|
1306
|
+
// We call validateBlobs via estimateGas with real blob+kzg sidecars as a consistency check
|
|
1307
|
+
// that our locally-built blob commitments match the blob data. The bundle simulate at send
|
|
1308
|
+
// time uses eth_simulateV1, which cannot carry blob inputs, so the rollup's on-chain blob
|
|
1309
|
+
// check is forced off there — making this the only pre-flight detector of a commitment/data
|
|
1310
|
+
// mismatch. The returned gas estimate is stashed on the request for the bundle path to read.
|
|
808
1311
|
blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
|
|
809
1312
|
to: this.rollupContract.address,
|
|
810
1313
|
data: encodeFunctionData({
|
|
@@ -817,10 +1320,38 @@ export class SequencerPublisher {
|
|
|
817
1320
|
}, {}, {
|
|
818
1321
|
blobs: encodedData.blobs.map((b)=>b.data),
|
|
819
1322
|
kzg
|
|
820
|
-
}).catch((err)=>{
|
|
821
|
-
const
|
|
822
|
-
this.log.error(`Failed to validate blobs`, message, {
|
|
823
|
-
metaMessages
|
|
1323
|
+
}).catch(async (err)=>{
|
|
1324
|
+
const viemError = formatViemError(err);
|
|
1325
|
+
this.log.error(`Failed to validate blobs`, viemError.message, {
|
|
1326
|
+
metaMessages: viemError.metaMessages
|
|
1327
|
+
});
|
|
1328
|
+
const validateBlobsData = encodeFunctionData({
|
|
1329
|
+
abi: RollupAbi,
|
|
1330
|
+
functionName: 'validateBlobs',
|
|
1331
|
+
args: [
|
|
1332
|
+
blobInput
|
|
1333
|
+
]
|
|
1334
|
+
});
|
|
1335
|
+
const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
|
|
1336
|
+
this.backupFailedTx({
|
|
1337
|
+
id: keccak256(validateBlobsData),
|
|
1338
|
+
failureType: 'simulation',
|
|
1339
|
+
request: {
|
|
1340
|
+
to: this.rollupContract.address,
|
|
1341
|
+
data: validateBlobsData
|
|
1342
|
+
},
|
|
1343
|
+
blobData: encodedData.blobs.map((b)=>toHex(b.data)),
|
|
1344
|
+
l1BlockNumber: l1BlockNumber.toString(),
|
|
1345
|
+
error: {
|
|
1346
|
+
message: viemError.message,
|
|
1347
|
+
name: viemError.name
|
|
1348
|
+
},
|
|
1349
|
+
context: {
|
|
1350
|
+
actions: [
|
|
1351
|
+
'validate-blobs'
|
|
1352
|
+
],
|
|
1353
|
+
sender: this.getSenderAddress().toString()
|
|
1354
|
+
}
|
|
824
1355
|
});
|
|
825
1356
|
throw new Error('Failed to validate blobs');
|
|
826
1357
|
});
|
|
@@ -831,8 +1362,7 @@ export class SequencerPublisher {
|
|
|
831
1362
|
header: encodedData.header.toViem(),
|
|
832
1363
|
archive: toHex(encodedData.archive),
|
|
833
1364
|
oracleInput: {
|
|
834
|
-
|
|
835
|
-
feeAssetPriceModifier: 0n
|
|
1365
|
+
feeAssetPriceModifier: encodedData.feeAssetPriceModifier
|
|
836
1366
|
}
|
|
837
1367
|
},
|
|
838
1368
|
encodedData.attestationsAndSigners.getPackedAttestations(),
|
|
@@ -840,89 +1370,23 @@ export class SequencerPublisher {
|
|
|
840
1370
|
encodedData.attestationsAndSignersSignature.toViemSignature(),
|
|
841
1371
|
blobInput
|
|
842
1372
|
];
|
|
843
|
-
const { rollupData, simulationResult } = await this.simulateProposeTx(args, timestamp, options);
|
|
844
|
-
return {
|
|
845
|
-
args,
|
|
846
|
-
blobEvaluationGas,
|
|
847
|
-
rollupData,
|
|
848
|
-
simulationResult
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Simulates the propose tx with eth_simulateV1
|
|
853
|
-
* @param args - The propose tx args
|
|
854
|
-
* @param timestamp - The timestamp to simulate proposal at
|
|
855
|
-
* @returns The simulation result
|
|
856
|
-
*/ async simulateProposeTx(args, timestamp, options) {
|
|
857
1373
|
const rollupData = encodeFunctionData({
|
|
858
1374
|
abi: RollupAbi,
|
|
859
1375
|
functionName: 'propose',
|
|
860
1376
|
args
|
|
861
1377
|
});
|
|
862
|
-
// override the pending checkpoint number if requested
|
|
863
|
-
const optsForcePendingCheckpointNumber = options.forcePendingBlockNumber !== undefined ? CheckpointNumber.fromBlockNumber(options.forcePendingBlockNumber) : undefined;
|
|
864
|
-
const forcePendingCheckpointNumberStateDiff = (optsForcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(optsForcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
|
|
865
|
-
const stateOverrides = [
|
|
866
|
-
{
|
|
867
|
-
address: this.rollupContract.address,
|
|
868
|
-
// @note we override checkBlob to false since blobs are not part simulate()
|
|
869
|
-
stateDiff: [
|
|
870
|
-
{
|
|
871
|
-
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
872
|
-
value: toPaddedHex(0n, true)
|
|
873
|
-
},
|
|
874
|
-
...forcePendingCheckpointNumberStateDiff
|
|
875
|
-
]
|
|
876
|
-
}
|
|
877
|
-
];
|
|
878
|
-
// In fisherman mode, simulate as the proposer but with sufficient balance
|
|
879
|
-
if (this.proposerAddressForSimulation) {
|
|
880
|
-
stateOverrides.push({
|
|
881
|
-
address: this.proposerAddressForSimulation.toString(),
|
|
882
|
-
balance: 10n * WEI_CONST * WEI_CONST
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
const simulationResult = await this.l1TxUtils.simulate({
|
|
886
|
-
to: this.rollupContract.address,
|
|
887
|
-
data: rollupData,
|
|
888
|
-
gas: SequencerPublisher.PROPOSE_GAS_GUESS,
|
|
889
|
-
...this.proposerAddressForSimulation && {
|
|
890
|
-
from: this.proposerAddressForSimulation.toString()
|
|
891
|
-
}
|
|
892
|
-
}, {
|
|
893
|
-
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
894
|
-
time: timestamp + 1n,
|
|
895
|
-
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
896
|
-
gasLimit: SequencerPublisher.PROPOSE_GAS_GUESS * 2n
|
|
897
|
-
}, stateOverrides, RollupAbi, {
|
|
898
|
-
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
899
|
-
fallbackGasEstimate: SequencerPublisher.PROPOSE_GAS_GUESS
|
|
900
|
-
}).catch((err)=>{
|
|
901
|
-
// In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
|
|
902
|
-
const viemError = formatViemError(err);
|
|
903
|
-
if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
|
|
904
|
-
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
905
|
-
// Return a minimal simulation result with the fallback gas estimate
|
|
906
|
-
return {
|
|
907
|
-
gasUsed: SequencerPublisher.PROPOSE_GAS_GUESS,
|
|
908
|
-
logs: []
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
this.log.error(`Failed to simulate propose tx`, viemError);
|
|
912
|
-
throw err;
|
|
913
|
-
});
|
|
914
1378
|
return {
|
|
915
|
-
|
|
916
|
-
|
|
1379
|
+
args,
|
|
1380
|
+
blobEvaluationGas,
|
|
1381
|
+
rollupData
|
|
917
1382
|
};
|
|
918
1383
|
}
|
|
919
|
-
async addProposeTx(checkpoint, encodedData, opts = {}
|
|
1384
|
+
async addProposeTx(checkpoint, encodedData, opts = {}) {
|
|
920
1385
|
const slot = checkpoint.header.slotNumber;
|
|
921
1386
|
const timer = new Timer();
|
|
922
1387
|
const kzg = Blob.getViemKzgInstance();
|
|
923
|
-
const { rollupData,
|
|
1388
|
+
const { rollupData, blobEvaluationGas } = await this.prepareProposeTx(encodedData);
|
|
924
1389
|
const startBlock = await this.l1TxUtils.getBlockNumber();
|
|
925
|
-
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
|
|
926
1390
|
// Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
|
|
927
1391
|
// tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
|
|
928
1392
|
void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
|
|
@@ -936,9 +1400,10 @@ export class SequencerPublisher {
|
|
|
936
1400
|
},
|
|
937
1401
|
lastValidL2Slot: checkpoint.header.slotNumber,
|
|
938
1402
|
gasConfig: {
|
|
939
|
-
|
|
940
|
-
gasLimit
|
|
1403
|
+
txTimeoutAt: opts.txTimeoutAt,
|
|
1404
|
+
gasLimit: undefined
|
|
941
1405
|
},
|
|
1406
|
+
blobEvaluationGas,
|
|
942
1407
|
blobConfig: {
|
|
943
1408
|
blobs: encodedData.blobs.map((b)=>b.data),
|
|
944
1409
|
kzg
|
|
@@ -948,7 +1413,11 @@ export class SequencerPublisher {
|
|
|
948
1413
|
return false;
|
|
949
1414
|
}
|
|
950
1415
|
const { receipt, stats, errorMsg } = result;
|
|
951
|
-
const success =
|
|
1416
|
+
const success = extractEventSuccess(receipt, {
|
|
1417
|
+
address: this.rollupContract.address,
|
|
1418
|
+
abi: RollupAbi,
|
|
1419
|
+
eventName: 'CheckpointProposed'
|
|
1420
|
+
});
|
|
952
1421
|
if (success) {
|
|
953
1422
|
const endBlock = receipt.blockNumber;
|
|
954
1423
|
const inclusionBlocks = Number(endBlock - startBlock);
|
|
@@ -985,4 +1454,8 @@ export class SequencerPublisher {
|
|
|
985
1454
|
}
|
|
986
1455
|
});
|
|
987
1456
|
}
|
|
1457
|
+
/** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
|
|
1458
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
1459
|
+
return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
|
|
1460
|
+
}
|
|
988
1461
|
}
|