@aztec-labs/aztec-node 6.0.0-nightly.20260829
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 +15 -0
- package/dest/aztec-node/block_response_helpers.d.ts +25 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +112 -0
- package/dest/aztec-node/config.d.ts +52 -0
- package/dest/aztec-node/config.d.ts.map +1 -0
- package/dest/aztec-node/config.js +129 -0
- package/dest/aztec-node/node_metrics.d.ts +12 -0
- package/dest/aztec-node/node_metrics.d.ts.map +1 -0
- package/dest/aztec-node/node_metrics.js +36 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts +108 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +380 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +11 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +48 -0
- package/dest/aztec-node/server.d.ts +281 -0
- package/dest/aztec-node/server.d.ts.map +1 -0
- package/dest/aztec-node/server.js +1235 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +57 -0
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +539 -0
- package/dest/index.d.ts +5 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +4 -0
- package/dest/modules/block_parameter.d.ts +25 -0
- package/dest/modules/block_parameter.d.ts.map +1 -0
- package/dest/modules/block_parameter.js +100 -0
- package/dest/modules/node_block_provider.d.ts +19 -0
- package/dest/modules/node_block_provider.d.ts.map +1 -0
- package/dest/modules/node_block_provider.js +112 -0
- package/dest/modules/node_tx_receipt.d.ts +24 -0
- package/dest/modules/node_tx_receipt.d.ts.map +1 -0
- package/dest/modules/node_tx_receipt.js +70 -0
- package/dest/modules/node_world_state_queries.d.ts +65 -0
- package/dest/modules/node_world_state_queries.d.ts.map +1 -0
- package/dest/modules/node_world_state_queries.js +270 -0
- package/dest/sentinel/config.d.ts +9 -0
- package/dest/sentinel/config.d.ts.map +1 -0
- package/dest/sentinel/config.js +39 -0
- package/dest/sentinel/factory.d.ts +11 -0
- package/dest/sentinel/factory.d.ts.map +1 -0
- package/dest/sentinel/factory.js +24 -0
- package/dest/sentinel/index.d.ts +3 -0
- package/dest/sentinel/index.d.ts.map +1 -0
- package/dest/sentinel/index.js +1 -0
- package/dest/sentinel/sentinel.d.ts +217 -0
- package/dest/sentinel/sentinel.d.ts.map +1 -0
- package/dest/sentinel/sentinel.js +551 -0
- package/dest/sentinel/store.d.ts +35 -0
- package/dest/sentinel/store.d.ts.map +1 -0
- package/dest/sentinel/store.js +182 -0
- package/dest/test/index.d.ts +31 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/package.json +118 -0
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +216 -0
- package/src/aztec-node/node_metrics.ts +49 -0
- package/src/aztec-node/node_public_calls_simulator.ts +437 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +45 -0
- package/src/aztec-node/server.ts +1155 -0
- package/src/bin/index.ts +77 -0
- package/src/factory.ts +704 -0
- package/src/index.ts +4 -0
- package/src/modules/block_parameter.ts +93 -0
- package/src/modules/node_block_provider.ts +149 -0
- package/src/modules/node_tx_receipt.ts +115 -0
- package/src/modules/node_world_state_queries.ts +373 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +49 -0
- package/src/sentinel/factory.ts +46 -0
- package/src/sentinel/index.ts +8 -0
- package/src/sentinel/sentinel.ts +694 -0
- package/src/sentinel/store.ts +193 -0
- package/src/test/index.ts +32 -0
|
@@ -0,0 +1,1235 @@
|
|
|
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, _initProto;
|
|
374
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec-labs/bb-prover';
|
|
375
|
+
import { TestCircuitVerifier } from '@aztec-labs/bb-prover/test';
|
|
376
|
+
import { pickL1ContractAddresses } from '@aztec-labs/ethereum/l1-contract-addresses';
|
|
377
|
+
import { BlockNumber } from '@aztec-labs/foundation/branded-types';
|
|
378
|
+
import { compactArray, pick, unique } from '@aztec-labs/foundation/collection';
|
|
379
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
380
|
+
import { first } from '@aztec-labs/foundation/iterable';
|
|
381
|
+
import { BadRequestError } from '@aztec-labs/foundation/json-rpc';
|
|
382
|
+
import { createLogger } from '@aztec-labs/foundation/log';
|
|
383
|
+
import { retryUntil } from '@aztec-labs/foundation/retry';
|
|
384
|
+
import { count } from '@aztec-labs/foundation/string';
|
|
385
|
+
import { Timer } from '@aztec-labs/foundation/timer';
|
|
386
|
+
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec-labs/node-keystore';
|
|
387
|
+
import { uploadSnapshot } from '@aztec-labs/node-lib/actions';
|
|
388
|
+
import { createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec-labs/p2p';
|
|
389
|
+
import { ProtocolContractAddress } from '@aztec-labs/protocol-contracts';
|
|
390
|
+
import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec-labs/standard-contracts/multi-call-entrypoint';
|
|
391
|
+
import { inspectBlockParameter } from '@aztec-labs/stdlib/block';
|
|
392
|
+
import { GasFees, getNetworkTxGasLimits } from '@aztec-labs/stdlib/gas';
|
|
393
|
+
import { AztecNodeAdminConfigSchema } from '@aztec-labs/stdlib/interfaces/client';
|
|
394
|
+
import { tryStop } from '@aztec-labs/stdlib/interfaces/server';
|
|
395
|
+
import { NullDebugLogStore } from '@aztec-labs/stdlib/logs';
|
|
396
|
+
import { Attributes, getTelemetryClient, trackSpan } from '@aztec-labs/telemetry-client';
|
|
397
|
+
import { NodeKeystoreAdapter, ValidatorClient } from '@aztec-labs/validator-client';
|
|
398
|
+
import { NodeBlockProvider } from '../modules/node_block_provider.js';
|
|
399
|
+
import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
|
|
400
|
+
import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
|
|
401
|
+
import { NodeMetrics } from './node_metrics.js';
|
|
402
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
403
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
404
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
405
|
+
}));
|
|
406
|
+
/**
|
|
407
|
+
* The aztec node.
|
|
408
|
+
*/ export class AztecNodeService {
|
|
409
|
+
static{
|
|
410
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
411
|
+
[
|
|
412
|
+
_dec,
|
|
413
|
+
2,
|
|
414
|
+
"simulatePublicCalls"
|
|
415
|
+
]
|
|
416
|
+
], []));
|
|
417
|
+
}
|
|
418
|
+
metrics;
|
|
419
|
+
// Prevent two snapshot operations to happen simultaneously
|
|
420
|
+
isUploadingSnapshot = (_initProto(this), false);
|
|
421
|
+
// Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
|
|
422
|
+
sequencerPausedMinTxsPerBlock;
|
|
423
|
+
nodePublicCallsSimulator;
|
|
424
|
+
worldStateQueries;
|
|
425
|
+
blockProvider;
|
|
426
|
+
txReceiptBuilder;
|
|
427
|
+
tracer;
|
|
428
|
+
config;
|
|
429
|
+
p2pClient;
|
|
430
|
+
blockSource;
|
|
431
|
+
logsSource;
|
|
432
|
+
contractDataSource;
|
|
433
|
+
l1ToL2MessageSource;
|
|
434
|
+
worldStateSynchronizer;
|
|
435
|
+
sequencer;
|
|
436
|
+
proverNode;
|
|
437
|
+
slasherClient;
|
|
438
|
+
validatorsSentinel;
|
|
439
|
+
stopStartedWatchers;
|
|
440
|
+
l1ChainId;
|
|
441
|
+
version;
|
|
442
|
+
globalVariableBuilder;
|
|
443
|
+
rollupContract;
|
|
444
|
+
feeProvider;
|
|
445
|
+
epochCache;
|
|
446
|
+
packageVersion;
|
|
447
|
+
peerProofVerifier;
|
|
448
|
+
rpcProofVerifier;
|
|
449
|
+
telemetry;
|
|
450
|
+
log;
|
|
451
|
+
blobClient;
|
|
452
|
+
validatorClient;
|
|
453
|
+
keyStoreManager;
|
|
454
|
+
debugLogStore;
|
|
455
|
+
automineSequencer;
|
|
456
|
+
avmSimulator;
|
|
457
|
+
constructor(deps){
|
|
458
|
+
this.config = deps.config;
|
|
459
|
+
this.p2pClient = deps.p2pClient;
|
|
460
|
+
this.blockSource = deps.blockSource;
|
|
461
|
+
this.logsSource = deps.logsSource;
|
|
462
|
+
this.contractDataSource = deps.contractDataSource;
|
|
463
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
464
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
465
|
+
this.sequencer = deps.sequencer;
|
|
466
|
+
this.proverNode = deps.proverNode;
|
|
467
|
+
this.slasherClient = deps.slasherClient;
|
|
468
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
469
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
470
|
+
this.l1ChainId = deps.l1ChainId;
|
|
471
|
+
this.version = deps.version;
|
|
472
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
473
|
+
this.rollupContract = deps.rollupContract;
|
|
474
|
+
this.feeProvider = deps.feeProvider;
|
|
475
|
+
this.epochCache = deps.epochCache;
|
|
476
|
+
this.packageVersion = deps.packageVersion;
|
|
477
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
478
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
479
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
480
|
+
this.log = deps.log ?? createLogger('node');
|
|
481
|
+
this.blobClient = deps.blobClient;
|
|
482
|
+
this.validatorClient = deps.validatorClient;
|
|
483
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
484
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
485
|
+
this.automineSequencer = deps.automineSequencer;
|
|
486
|
+
this.avmSimulator = deps.avmSimulator;
|
|
487
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
488
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
489
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
490
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
491
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
492
|
+
blockSource: this.blockSource,
|
|
493
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
494
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
495
|
+
contractDataSource: this.contractDataSource,
|
|
496
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
497
|
+
rollupContract: this.rollupContract,
|
|
498
|
+
epochCache: this.epochCache,
|
|
499
|
+
signatureContext: {
|
|
500
|
+
chainId: this.l1ChainId,
|
|
501
|
+
rollupAddress: this.config.rollupAddress
|
|
502
|
+
},
|
|
503
|
+
config: this.config,
|
|
504
|
+
avmSimulator: this.avmSimulator,
|
|
505
|
+
telemetry: this.telemetry,
|
|
506
|
+
log: this.log.createChild('public-calls-simulator')
|
|
507
|
+
});
|
|
508
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
509
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
510
|
+
blockSource: this.blockSource,
|
|
511
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
512
|
+
log: this.log.createChild('world-state-queries')
|
|
513
|
+
});
|
|
514
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
515
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
516
|
+
p2pClient: this.p2pClient,
|
|
517
|
+
blockSource: this.blockSource,
|
|
518
|
+
debugLogStore: this.debugLogStore
|
|
519
|
+
});
|
|
520
|
+
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
521
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
522
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
523
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
524
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
525
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
526
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
530
|
+
return this.rpcProofVerifier;
|
|
531
|
+
}
|
|
532
|
+
async getWorldStateSyncStatus() {
|
|
533
|
+
const status = await this.worldStateSynchronizer.status();
|
|
534
|
+
return status.syncSummary;
|
|
535
|
+
}
|
|
536
|
+
getChainTips() {
|
|
537
|
+
return this.blockSource.getL2Tips();
|
|
538
|
+
}
|
|
539
|
+
getL1Constants() {
|
|
540
|
+
return this.blockSource.getL1Constants();
|
|
541
|
+
}
|
|
542
|
+
getSyncedL2SlotNumber() {
|
|
543
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
544
|
+
}
|
|
545
|
+
getSyncedL2EpochNumber() {
|
|
546
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
547
|
+
}
|
|
548
|
+
getSyncedL1Timestamp() {
|
|
549
|
+
return this.blockSource.getL1Timestamp();
|
|
550
|
+
}
|
|
551
|
+
getCheckpointsData(query) {
|
|
552
|
+
return this.blockSource.getCheckpointsData(query);
|
|
553
|
+
}
|
|
554
|
+
async getBlockNumber(tip) {
|
|
555
|
+
if (tip === undefined || tip === 'proposed') {
|
|
556
|
+
return this.blockSource.getBlockNumber();
|
|
557
|
+
}
|
|
558
|
+
return await this.blockSource.getBlockNumber({
|
|
559
|
+
tag: tip
|
|
560
|
+
}) ?? BlockNumber.ZERO;
|
|
561
|
+
}
|
|
562
|
+
async getCheckpointNumber(tip) {
|
|
563
|
+
const tips = await this.blockSource.getL2Tips();
|
|
564
|
+
switch(tip){
|
|
565
|
+
case undefined:
|
|
566
|
+
case 'checkpointed':
|
|
567
|
+
return tips.checkpointed.checkpoint.number;
|
|
568
|
+
case 'proven':
|
|
569
|
+
return tips.proven.checkpoint.number;
|
|
570
|
+
case 'finalized':
|
|
571
|
+
return tips.finalized.checkpoint.number;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
getBlock(param, options = {}) {
|
|
575
|
+
return this.blockProvider.getBlock(param, options);
|
|
576
|
+
}
|
|
577
|
+
getBlockData(param) {
|
|
578
|
+
return this.blockProvider.getBlockData(param);
|
|
579
|
+
}
|
|
580
|
+
getBlocks(from, limit, options = {}) {
|
|
581
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
582
|
+
}
|
|
583
|
+
getCheckpoint(param, options = {}) {
|
|
584
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
585
|
+
}
|
|
586
|
+
getCheckpoints(from, limit, options = {}) {
|
|
587
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Returns the sequencer client instance.
|
|
591
|
+
* @returns The sequencer client instance.
|
|
592
|
+
*/ getSequencer() {
|
|
593
|
+
return this.sequencer;
|
|
594
|
+
}
|
|
595
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */ getAutomineSequencer() {
|
|
596
|
+
return this.automineSequencer;
|
|
597
|
+
}
|
|
598
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
599
|
+
return this.proverNode;
|
|
600
|
+
}
|
|
601
|
+
getBlockSource() {
|
|
602
|
+
return this.blockSource;
|
|
603
|
+
}
|
|
604
|
+
getContractDataSource() {
|
|
605
|
+
return this.contractDataSource;
|
|
606
|
+
}
|
|
607
|
+
getP2P() {
|
|
608
|
+
return this.p2pClient;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Method to return the currently deployed L1 contract addresses.
|
|
612
|
+
* @returns - The currently deployed L1 contract addresses.
|
|
613
|
+
*/ getL1ContractAddresses() {
|
|
614
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
615
|
+
}
|
|
616
|
+
getEncodedEnr() {
|
|
617
|
+
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
618
|
+
}
|
|
619
|
+
async getAllowedPublicSetup() {
|
|
620
|
+
return [
|
|
621
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
622
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
623
|
+
];
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Method to determine if the node is ready to accept transactions.
|
|
627
|
+
* @returns - Flag indicating the readiness for tx submission.
|
|
628
|
+
*/ isReady() {
|
|
629
|
+
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
630
|
+
}
|
|
631
|
+
async getNodeInfo() {
|
|
632
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
633
|
+
this.getNodeVersion(),
|
|
634
|
+
this.getVersion(),
|
|
635
|
+
this.getChainId(),
|
|
636
|
+
this.getEncodedEnr(),
|
|
637
|
+
this.getL1ContractAddresses(),
|
|
638
|
+
this.getProtocolContractAddresses(),
|
|
639
|
+
this.blockSource.getL1Constants()
|
|
640
|
+
]);
|
|
641
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
642
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
643
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
644
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
645
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
646
|
+
const nodeInfo = {
|
|
647
|
+
nodeVersion,
|
|
648
|
+
l1ChainId: chainId,
|
|
649
|
+
rollupVersion,
|
|
650
|
+
enr,
|
|
651
|
+
l1ContractAddresses: contractAddresses,
|
|
652
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
653
|
+
realProofs: !!this.config.realProofs,
|
|
654
|
+
txsLimits: {
|
|
655
|
+
gas: {
|
|
656
|
+
daGas: maxTxGas.daGas,
|
|
657
|
+
l2Gas: maxTxGas.l2Gas
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
return nodeInfo;
|
|
662
|
+
}
|
|
663
|
+
async getCurrentMinFees() {
|
|
664
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
665
|
+
}
|
|
666
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
667
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
668
|
+
}
|
|
669
|
+
async getMaxPriorityFees() {
|
|
670
|
+
const tx = await first(this.p2pClient.iteratePendingTxs({
|
|
671
|
+
includeProof: false
|
|
672
|
+
}));
|
|
673
|
+
return tx ? tx.getGasSettings().maxPriorityFeesPerGas : GasFees.from({
|
|
674
|
+
feePerDaGas: 0n,
|
|
675
|
+
feePerL2Gas: 0n
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Method to fetch the version of the package.
|
|
680
|
+
* @returns The node package version
|
|
681
|
+
*/ getNodeVersion() {
|
|
682
|
+
return Promise.resolve(this.packageVersion);
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Method to fetch the version of the rollup the node is connected to.
|
|
686
|
+
* @returns The rollup version.
|
|
687
|
+
*/ getVersion() {
|
|
688
|
+
return Promise.resolve(this.version);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Method to fetch the chain id of the base-layer for the rollup.
|
|
692
|
+
* @returns The chain id.
|
|
693
|
+
*/ getChainId() {
|
|
694
|
+
return Promise.resolve(this.l1ChainId);
|
|
695
|
+
}
|
|
696
|
+
getContractClass(id) {
|
|
697
|
+
return this.contractDataSource.getContractClass(id);
|
|
698
|
+
}
|
|
699
|
+
async getContract(address, referenceBlock = 'latest') {
|
|
700
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
701
|
+
if (!blockData) {
|
|
702
|
+
throw new Error(`Reference block ${inspectBlockParameter(referenceBlock)} not found when querying contract ${address}. If the node API has been queried with an anchor block hash, possibly a reorg has occurred.`);
|
|
703
|
+
}
|
|
704
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
705
|
+
}
|
|
706
|
+
getPrivateLogsByTags(query) {
|
|
707
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
708
|
+
}
|
|
709
|
+
getPublicLogsByTags(query) {
|
|
710
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Method to submit a transaction to the p2p pool.
|
|
714
|
+
* @param tx - The transaction to be submitted.
|
|
715
|
+
*/ async sendTx(tx) {
|
|
716
|
+
await this.#sendTx(tx);
|
|
717
|
+
}
|
|
718
|
+
async #sendTx(tx) {
|
|
719
|
+
const timer = new Timer();
|
|
720
|
+
const txHash = tx.getTxHash().toString();
|
|
721
|
+
const connectivity = await this.p2pClient.getP2PConnectivity();
|
|
722
|
+
if (connectivity.enabled && connectivity.connectedPeers === 0) {
|
|
723
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
724
|
+
this.log.warn(`Rejecting tx ${txHash}: node has no connected peers`, {
|
|
725
|
+
txHash
|
|
726
|
+
});
|
|
727
|
+
throw new Error('Cannot accept tx: node has no connected peers to propagate it');
|
|
728
|
+
}
|
|
729
|
+
const valid = await this.isValidTx(tx);
|
|
730
|
+
if (valid.result !== 'valid') {
|
|
731
|
+
const reason = valid.reason.join(', ');
|
|
732
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
733
|
+
this.log.warn(`Received invalid tx ${txHash}: ${reason}`, {
|
|
734
|
+
txHash
|
|
735
|
+
});
|
|
736
|
+
throw new Error(`Invalid tx: ${reason}`);
|
|
737
|
+
}
|
|
738
|
+
try {
|
|
739
|
+
await this.p2pClient.sendTx(tx);
|
|
740
|
+
} catch (err) {
|
|
741
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
742
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${err.message}`, {
|
|
743
|
+
txHash
|
|
744
|
+
});
|
|
745
|
+
throw err;
|
|
746
|
+
}
|
|
747
|
+
const duration = timer.ms();
|
|
748
|
+
this.metrics.receivedTx(duration, true);
|
|
749
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
750
|
+
txHash
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
getTxReceipt(txHash, options) {
|
|
754
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
755
|
+
}
|
|
756
|
+
getTxEffect(txHash) {
|
|
757
|
+
return this.blockSource.getTxEffect(txHash);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Method to stop the aztec node.
|
|
761
|
+
*/ async stop() {
|
|
762
|
+
this.log.info(`Stopping Aztec Node`);
|
|
763
|
+
await this.stopStartedWatchers();
|
|
764
|
+
await tryStop(this.slasherClient);
|
|
765
|
+
await Promise.all([
|
|
766
|
+
tryStop(this.peerProofVerifier),
|
|
767
|
+
tryStop(this.rpcProofVerifier)
|
|
768
|
+
]);
|
|
769
|
+
await tryStop(this.sequencer);
|
|
770
|
+
await tryStop(this.automineSequencer);
|
|
771
|
+
await tryStop(this.proverNode);
|
|
772
|
+
await tryStop(this.p2pClient);
|
|
773
|
+
await tryStop(this.feeProvider);
|
|
774
|
+
// Dispose the AVM backend before world state: it kills the bb-avm-sim processes and closes the CDB IPC
|
|
775
|
+
// server, releasing their connections to the WSDB so it shuts down cleanly (and freeing the
|
|
776
|
+
// Server/Socket/ChildProcess handles that would otherwise keep the process alive after teardown).
|
|
777
|
+
await this.avmSimulator?.[Symbol.asyncDispose]();
|
|
778
|
+
await tryStop(this.worldStateSynchronizer);
|
|
779
|
+
await tryStop(this.blockSource);
|
|
780
|
+
await tryStop(this.blobClient);
|
|
781
|
+
await tryStop(this.telemetry);
|
|
782
|
+
this.log.info(`Stopped Aztec Node`);
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Returns the blob client used by this node.
|
|
786
|
+
* @internal - Exposed for testing purposes only.
|
|
787
|
+
*/ getBlobClient() {
|
|
788
|
+
return this.blobClient;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Method to retrieve pending txs.
|
|
792
|
+
* @param limit - The number of items to returns
|
|
793
|
+
* @param after - The last known pending tx. Used for pagination
|
|
794
|
+
* @returns - The pending txs.
|
|
795
|
+
*/ getPendingTxs(limit, after, options) {
|
|
796
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
797
|
+
}
|
|
798
|
+
getPendingTxCount() {
|
|
799
|
+
return this.p2pClient.getPendingTxCount();
|
|
800
|
+
}
|
|
801
|
+
getPeers(includePending) {
|
|
802
|
+
return this.p2pClient.getPeers(includePending);
|
|
803
|
+
}
|
|
804
|
+
getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
805
|
+
return this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
806
|
+
}
|
|
807
|
+
getProposalsForSlot(slot) {
|
|
808
|
+
return this.p2pClient.getProposalsForSlot(slot);
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
812
|
+
* when `includeProof` is set.
|
|
813
|
+
* @param txHash - The transaction hash to return.
|
|
814
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
815
|
+
* @returns - The tx if it exists.
|
|
816
|
+
*/ getTxByHash(txHash, options) {
|
|
817
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
818
|
+
includeProof: !!options?.includeProof
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
823
|
+
* `includeProof` is set.
|
|
824
|
+
* @param txHash - The transaction hash to return.
|
|
825
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
826
|
+
* @returns - The txs if it exists.
|
|
827
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
828
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
829
|
+
includeProof: !!options?.includeProof
|
|
830
|
+
});
|
|
831
|
+
return compactArray(txs);
|
|
832
|
+
}
|
|
833
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
834
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
835
|
+
}
|
|
836
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
837
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
838
|
+
}
|
|
839
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
840
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
841
|
+
}
|
|
842
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
843
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
844
|
+
}
|
|
845
|
+
getL1ToL2MessageIndex(l1ToL2Message) {
|
|
846
|
+
return this.worldStateQueries.getL1ToL2MessageIndex(l1ToL2Message);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
850
|
+
*
|
|
851
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
852
|
+
*
|
|
853
|
+
* @param epoch - The epoch at which to get the data.
|
|
854
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
855
|
+
*/ getL2ToL1Messages(epoch) {
|
|
856
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
860
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
861
|
+
*/ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
|
|
862
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
863
|
+
}
|
|
864
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
865
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
866
|
+
}
|
|
867
|
+
getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
868
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
869
|
+
}
|
|
870
|
+
getPublicDataWitness(referenceBlock, leafSlot) {
|
|
871
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
872
|
+
}
|
|
873
|
+
getPublicStorageAt(referenceBlock, contract, slot) {
|
|
874
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Simulates the public part of a transaction with the current state.
|
|
878
|
+
* @param tx - The transaction to simulate.
|
|
879
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
880
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
881
|
+
**/ simulatePublicCalls(tx, skipFeeEnforcement = false, overrides) {
|
|
882
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
883
|
+
}
|
|
884
|
+
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
885
|
+
const db = this.worldStateSynchronizer.getCommitted();
|
|
886
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
887
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
888
|
+
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
889
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
890
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
891
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
892
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
893
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
894
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
895
|
+
timestamp: nextSlotTimestamp,
|
|
896
|
+
blockNumber,
|
|
897
|
+
l1ChainId: this.l1ChainId,
|
|
898
|
+
rollupVersion: this.version,
|
|
899
|
+
setupAllowList: [
|
|
900
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
901
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
902
|
+
],
|
|
903
|
+
gasFees: await this.getCurrentMinFees(),
|
|
904
|
+
skipFeeEnforcement,
|
|
905
|
+
isSimulation,
|
|
906
|
+
txsPermitted: !this.config.disableTransactions,
|
|
907
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
908
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
909
|
+
}, this.log.getBindings());
|
|
910
|
+
return await validator.validateTx(tx);
|
|
911
|
+
}
|
|
912
|
+
getConfig() {
|
|
913
|
+
const schema = AztecNodeAdminConfigSchema;
|
|
914
|
+
const keys = schema.keyof().options;
|
|
915
|
+
return Promise.resolve(pick(this.config, ...keys));
|
|
916
|
+
}
|
|
917
|
+
async setConfig(config) {
|
|
918
|
+
const newConfig = {
|
|
919
|
+
...this.config,
|
|
920
|
+
...config
|
|
921
|
+
};
|
|
922
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
923
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
924
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
925
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
926
|
+
// pauseSequencer() still considers it paused.
|
|
927
|
+
const sequencerUpdate = {
|
|
928
|
+
...config
|
|
929
|
+
};
|
|
930
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
931
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
932
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
933
|
+
}
|
|
934
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
935
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
936
|
+
this.slasherClient?.updateConfig(config);
|
|
937
|
+
this.validatorsSentinel?.updateConfig(config);
|
|
938
|
+
await this.p2pClient.updateP2PConfig(config);
|
|
939
|
+
const archiver = this.blockSource;
|
|
940
|
+
if ('updateConfig' in archiver) {
|
|
941
|
+
archiver.updateConfig(config);
|
|
942
|
+
}
|
|
943
|
+
if (newConfig.realProofs !== this.config.realProofs) {
|
|
944
|
+
await Promise.all([
|
|
945
|
+
tryStop(this.peerProofVerifier),
|
|
946
|
+
tryStop(this.rpcProofVerifier)
|
|
947
|
+
]);
|
|
948
|
+
if (newConfig.realProofs) {
|
|
949
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
950
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
951
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
952
|
+
} else {
|
|
953
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
954
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
this.config = newConfig;
|
|
958
|
+
}
|
|
959
|
+
getProtocolContractAddresses() {
|
|
960
|
+
return Promise.resolve({
|
|
961
|
+
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
962
|
+
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
963
|
+
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
964
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
registerContractFunctionSignatures(signatures) {
|
|
968
|
+
return this.contractDataSource.registerContractFunctionSignatures(signatures);
|
|
969
|
+
}
|
|
970
|
+
getValidatorsStats() {
|
|
971
|
+
return this.validatorsSentinel?.computeStats() ?? Promise.resolve({
|
|
972
|
+
stats: {},
|
|
973
|
+
slotWindow: 0
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
getValidatorStats(validatorAddress, fromSlot, toSlot) {
|
|
977
|
+
return this.validatorsSentinel?.getValidatorStats(validatorAddress, fromSlot, toSlot) ?? Promise.resolve(undefined);
|
|
978
|
+
}
|
|
979
|
+
async startSnapshotUpload(location) {
|
|
980
|
+
// Note that we are forcefully casting the blocksource as an archiver
|
|
981
|
+
// We break support for archiver running remotely to the node
|
|
982
|
+
const archiver = this.blockSource;
|
|
983
|
+
if (!('backupTo' in archiver)) {
|
|
984
|
+
this.metrics.recordSnapshotError();
|
|
985
|
+
throw new Error('Archiver implementation does not support backups. Cannot generate snapshot.');
|
|
986
|
+
}
|
|
987
|
+
// Test that the archiver has done an initial sync.
|
|
988
|
+
if (!archiver.isInitialSyncComplete()) {
|
|
989
|
+
this.metrics.recordSnapshotError();
|
|
990
|
+
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
991
|
+
}
|
|
992
|
+
// And it has an L2 block hash
|
|
993
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
994
|
+
if (!l2BlockHash) {
|
|
995
|
+
this.metrics.recordSnapshotError();
|
|
996
|
+
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
997
|
+
}
|
|
998
|
+
if (this.isUploadingSnapshot) {
|
|
999
|
+
this.metrics.recordSnapshotError();
|
|
1000
|
+
throw new Error(`Snapshot upload already in progress. Cannot start another one until complete.`);
|
|
1001
|
+
}
|
|
1002
|
+
// Do not wait for the upload to be complete to return to the caller, but flag that an operation is in progress
|
|
1003
|
+
this.isUploadingSnapshot = true;
|
|
1004
|
+
const timer = new Timer();
|
|
1005
|
+
void uploadSnapshot(location, this.blockSource, this.worldStateSynchronizer, this.config, this.log).then(()=>{
|
|
1006
|
+
this.isUploadingSnapshot = false;
|
|
1007
|
+
this.metrics.recordSnapshot(timer.ms());
|
|
1008
|
+
}).catch((err)=>{
|
|
1009
|
+
this.isUploadingSnapshot = false;
|
|
1010
|
+
this.metrics.recordSnapshotError();
|
|
1011
|
+
this.log.error(`Error uploading snapshot: ${err}`);
|
|
1012
|
+
});
|
|
1013
|
+
return Promise.resolve();
|
|
1014
|
+
}
|
|
1015
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1016
|
+
const archiver = this.blockSource;
|
|
1017
|
+
if (!('rollbackTo' in archiver)) {
|
|
1018
|
+
throw new Error('Archiver implementation does not support rollbacks.');
|
|
1019
|
+
}
|
|
1020
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
1021
|
+
if (targetBlock < finalizedBlock) {
|
|
1022
|
+
if (force) {
|
|
1023
|
+
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
1024
|
+
await this.worldStateSynchronizer.clear();
|
|
1025
|
+
await this.p2pClient.clear();
|
|
1026
|
+
} else {
|
|
1027
|
+
throw new Error(`Cannot rollback to block ${targetBlock} as it is before finalized ${finalizedBlock}`);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
try {
|
|
1031
|
+
this.log.info(`Pausing archiver and world state sync to start rollback`);
|
|
1032
|
+
await archiver.stop();
|
|
1033
|
+
await this.worldStateSynchronizer.stopSync();
|
|
1034
|
+
const currentBlock = await archiver.getBlockNumber();
|
|
1035
|
+
const blocksToUnwind = currentBlock - targetBlock;
|
|
1036
|
+
this.log.info(`Unwinding ${count(blocksToUnwind, 'block')} from L2 block ${currentBlock} to ${targetBlock}`);
|
|
1037
|
+
await archiver.rollbackTo(targetBlock);
|
|
1038
|
+
this.log.info(`Unwinding complete.`);
|
|
1039
|
+
} catch (err) {
|
|
1040
|
+
this.log.error(`Error during rollback`, err);
|
|
1041
|
+
throw err;
|
|
1042
|
+
} finally{
|
|
1043
|
+
if (resumeSync) {
|
|
1044
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1045
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1046
|
+
archiver.resume();
|
|
1047
|
+
} else {
|
|
1048
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
async pauseSync() {
|
|
1053
|
+
this.log.info(`Pausing archiver and world state sync`);
|
|
1054
|
+
await this.blockSource.stop();
|
|
1055
|
+
await this.worldStateSynchronizer.stopSync();
|
|
1056
|
+
}
|
|
1057
|
+
resumeSync() {
|
|
1058
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1059
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1060
|
+
this.blockSource.resume();
|
|
1061
|
+
return Promise.resolve();
|
|
1062
|
+
}
|
|
1063
|
+
pauseSequencer() {
|
|
1064
|
+
if (this.automineSequencer) {
|
|
1065
|
+
this.automineSequencer.pause();
|
|
1066
|
+
return Promise.resolve();
|
|
1067
|
+
}
|
|
1068
|
+
if (this.sequencer) {
|
|
1069
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
1070
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
1071
|
+
this.sequencer.updateConfig({
|
|
1072
|
+
minTxsPerBlock: Number.MAX_SAFE_INTEGER
|
|
1073
|
+
});
|
|
1074
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
1075
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
return Promise.resolve();
|
|
1079
|
+
}
|
|
1080
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
1081
|
+
}
|
|
1082
|
+
resumeSequencer() {
|
|
1083
|
+
if (this.automineSequencer) {
|
|
1084
|
+
this.automineSequencer.resume();
|
|
1085
|
+
return Promise.resolve();
|
|
1086
|
+
}
|
|
1087
|
+
if (this.sequencer) {
|
|
1088
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
1089
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
1090
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
1091
|
+
this.sequencer.updateConfig({
|
|
1092
|
+
minTxsPerBlock: restored
|
|
1093
|
+
});
|
|
1094
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, {
|
|
1095
|
+
minTxsPerBlock: restored
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
return Promise.resolve();
|
|
1099
|
+
}
|
|
1100
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
1101
|
+
}
|
|
1102
|
+
getSlashOffenses(round) {
|
|
1103
|
+
if (!this.slasherClient) {
|
|
1104
|
+
throw new Error(`Slasher client not enabled`);
|
|
1105
|
+
}
|
|
1106
|
+
if (round === 'all') {
|
|
1107
|
+
return this.slasherClient.getOffenses();
|
|
1108
|
+
} else {
|
|
1109
|
+
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
async reloadKeystore() {
|
|
1113
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1114
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1115
|
+
}
|
|
1116
|
+
if (!this.validatorClient) {
|
|
1117
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1118
|
+
}
|
|
1119
|
+
this.log.info('Reloading keystore from disk');
|
|
1120
|
+
// Re-read and validate keystore files
|
|
1121
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1122
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1123
|
+
await newManager.validateSigners();
|
|
1124
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1125
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1126
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1127
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1128
|
+
// would silently fail on every proposer slot.
|
|
1129
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1130
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1131
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1132
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1133
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1134
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1135
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1136
|
+
throw new BadRequestError(`Cannot reload keystore: validator ${attester} has publisher keys ` + `[${pubs.map((p)=>p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` + `[${[
|
|
1137
|
+
...availablePublishers
|
|
1138
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
// Build adapters for old and new keystores to compute diff
|
|
1143
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1144
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1145
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1146
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1147
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1148
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1149
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1150
|
+
if (added.length > 0) {
|
|
1151
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1152
|
+
}
|
|
1153
|
+
if (removed.length > 0) {
|
|
1154
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1155
|
+
}
|
|
1156
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1157
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1158
|
+
}
|
|
1159
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1160
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1161
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1162
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1163
|
+
if (this.sequencer) {
|
|
1164
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1165
|
+
}
|
|
1166
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1167
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1168
|
+
const slashValidatorsNever = unique([
|
|
1169
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1170
|
+
...newAddresses
|
|
1171
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1172
|
+
this.slasherClient.updateConfig({
|
|
1173
|
+
slashValidatorsNever
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
this.keyStoreManager = newManager;
|
|
1177
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1178
|
+
}
|
|
1179
|
+
async mineBlock() {
|
|
1180
|
+
if (this.automineSequencer) {
|
|
1181
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
if (!this.sequencer) {
|
|
1185
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1186
|
+
}
|
|
1187
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1188
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1189
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1190
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1191
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1192
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1193
|
+
this.sequencer.updateConfig({
|
|
1194
|
+
minTxsPerBlock: 0
|
|
1195
|
+
});
|
|
1196
|
+
try {
|
|
1197
|
+
// Trigger the sequencer to produce a block immediately
|
|
1198
|
+
void this.sequencer.trigger();
|
|
1199
|
+
// Wait for the new L2 block to appear
|
|
1200
|
+
await retryUntil(async ()=>{
|
|
1201
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1202
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1203
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1204
|
+
} finally{
|
|
1205
|
+
this.sequencer.updateConfig({
|
|
1206
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
async prove(upToCheckpoint) {
|
|
1211
|
+
if (!this.automineSequencer) {
|
|
1212
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1213
|
+
}
|
|
1214
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1215
|
+
}
|
|
1216
|
+
async warpL2TimeAtLeastTo(targetTimestamp) {
|
|
1217
|
+
if (!this.automineSequencer) {
|
|
1218
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1219
|
+
}
|
|
1220
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1221
|
+
}
|
|
1222
|
+
async warpL2TimeAtLeastBy(duration) {
|
|
1223
|
+
if (!this.automineSequencer) {
|
|
1224
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1225
|
+
}
|
|
1226
|
+
await this.automineSequencer.warpBy(duration);
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1230
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1231
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1232
|
+
*/ getWorldState(block) {
|
|
1233
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1234
|
+
}
|
|
1235
|
+
}
|