@aztec/aztec-node 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/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 +26 -8
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +32 -8
- package/dest/aztec-node/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +9 -16
- package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +351 -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 +10 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
- package/dest/aztec-node/server.d.ts +161 -224
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +887 -705
- package/dest/bin/index.js +15 -10
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +523 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -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 +272 -0
- package/dest/sentinel/config.d.ts +3 -2
- package/dest/sentinel/config.d.ts.map +1 -1
- package/dest/sentinel/config.js +15 -5
- package/dest/sentinel/factory.d.ts +6 -4
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +13 -6
- package/dest/sentinel/sentinel.d.ts +146 -21
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +269 -116
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +33 -21
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +29 -26
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +64 -21
- package/src/aztec-node/node_metrics.ts +6 -17
- package/src/aztec-node/node_public_calls_simulator.ts +394 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
- package/src/aztec-node/server.ts +678 -944
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +688 -0
- package/src/index.ts +2 -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 +374 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +23 -13
- package/src/sentinel/sentinel.ts +320 -131
- package/src/sentinel/store.ts +35 -27
- package/src/test/index.ts +2 -2
|
@@ -1,54 +1,429 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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);
|
|
6
372
|
}
|
|
7
|
-
|
|
8
|
-
import { BBCircuitVerifier,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { EpochCache } from '@aztec/epoch-cache';
|
|
12
|
-
import { RegistryContract, RollupContract, createEthereumChain, getPublicClient } from '@aztec/ethereum';
|
|
373
|
+
var _dec, _initProto;
|
|
374
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
375
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
376
|
+
import { pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
13
377
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
14
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
378
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
15
379
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
17
380
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
18
381
|
import { createLogger } from '@aztec/foundation/log';
|
|
382
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
19
383
|
import { count } from '@aztec/foundation/string';
|
|
20
|
-
import {
|
|
21
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
384
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
22
385
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
386
|
+
import { uploadSnapshot } from '@aztec/node-lib/actions';
|
|
387
|
+
import { createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
26
388
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
31
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
32
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
33
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
34
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
389
|
+
import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint';
|
|
390
|
+
import { inspectBlockParameter } from '@aztec/stdlib/block';
|
|
391
|
+
import { GasFees, getNetworkTxGasLimits } from '@aztec/stdlib/gas';
|
|
35
392
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
36
393
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
37
|
-
import {
|
|
38
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
39
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
40
|
-
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
41
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
394
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
42
395
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
43
|
-
import { NodeKeystoreAdapter, ValidatorClient
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import { createKeyStoreForValidator } from './config.js';
|
|
396
|
+
import { NodeKeystoreAdapter, ValidatorClient } from '@aztec/validator-client';
|
|
397
|
+
import { NodeBlockProvider } from '../modules/node_block_provider.js';
|
|
398
|
+
import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
|
|
399
|
+
import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
|
|
48
400
|
import { NodeMetrics } from './node_metrics.js';
|
|
401
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
402
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
403
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
404
|
+
}));
|
|
49
405
|
/**
|
|
50
406
|
* The aztec node.
|
|
51
407
|
*/ export class AztecNodeService {
|
|
408
|
+
static{
|
|
409
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
410
|
+
[
|
|
411
|
+
_dec,
|
|
412
|
+
2,
|
|
413
|
+
"simulatePublicCalls"
|
|
414
|
+
]
|
|
415
|
+
], []));
|
|
416
|
+
}
|
|
417
|
+
metrics;
|
|
418
|
+
// Prevent two snapshot operations to happen simultaneously
|
|
419
|
+
isUploadingSnapshot = (_initProto(this), false);
|
|
420
|
+
// Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
|
|
421
|
+
sequencerPausedMinTxsPerBlock;
|
|
422
|
+
nodePublicCallsSimulator;
|
|
423
|
+
worldStateQueries;
|
|
424
|
+
blockProvider;
|
|
425
|
+
txReceiptBuilder;
|
|
426
|
+
tracer;
|
|
52
427
|
config;
|
|
53
428
|
p2pClient;
|
|
54
429
|
blockSource;
|
|
@@ -57,252 +432,158 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
57
432
|
l1ToL2MessageSource;
|
|
58
433
|
worldStateSynchronizer;
|
|
59
434
|
sequencer;
|
|
435
|
+
proverNode;
|
|
60
436
|
slasherClient;
|
|
61
437
|
validatorsSentinel;
|
|
62
|
-
|
|
438
|
+
stopStartedWatchers;
|
|
63
439
|
l1ChainId;
|
|
64
440
|
version;
|
|
65
441
|
globalVariableBuilder;
|
|
442
|
+
rollupContract;
|
|
443
|
+
feeProvider;
|
|
66
444
|
epochCache;
|
|
67
445
|
packageVersion;
|
|
68
|
-
|
|
446
|
+
peerProofVerifier;
|
|
447
|
+
rpcProofVerifier;
|
|
69
448
|
telemetry;
|
|
70
449
|
log;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
450
|
+
blobClient;
|
|
451
|
+
validatorClient;
|
|
452
|
+
keyStoreManager;
|
|
453
|
+
debugLogStore;
|
|
454
|
+
automineSequencer;
|
|
455
|
+
avmSimulator;
|
|
456
|
+
constructor(deps){
|
|
457
|
+
this.config = deps.config;
|
|
458
|
+
this.p2pClient = deps.p2pClient;
|
|
459
|
+
this.blockSource = deps.blockSource;
|
|
460
|
+
this.logsSource = deps.logsSource;
|
|
461
|
+
this.contractDataSource = deps.contractDataSource;
|
|
462
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
463
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
464
|
+
this.sequencer = deps.sequencer;
|
|
465
|
+
this.proverNode = deps.proverNode;
|
|
466
|
+
this.slasherClient = deps.slasherClient;
|
|
467
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
468
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
469
|
+
this.l1ChainId = deps.l1ChainId;
|
|
470
|
+
this.version = deps.version;
|
|
471
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
472
|
+
this.rollupContract = deps.rollupContract;
|
|
473
|
+
this.feeProvider = deps.feeProvider;
|
|
474
|
+
this.epochCache = deps.epochCache;
|
|
475
|
+
this.packageVersion = deps.packageVersion;
|
|
476
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
477
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
478
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
479
|
+
this.log = deps.log ?? createLogger('node');
|
|
480
|
+
this.blobClient = deps.blobClient;
|
|
481
|
+
this.validatorClient = deps.validatorClient;
|
|
482
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
483
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
484
|
+
this.automineSequencer = deps.automineSequencer;
|
|
485
|
+
this.avmSimulator = deps.avmSimulator;
|
|
486
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
487
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
488
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
489
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
490
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
491
|
+
blockSource: this.blockSource,
|
|
492
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
493
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
494
|
+
contractDataSource: this.contractDataSource,
|
|
495
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
496
|
+
rollupContract: this.rollupContract,
|
|
497
|
+
epochCache: this.epochCache,
|
|
498
|
+
signatureContext: {
|
|
499
|
+
chainId: this.l1ChainId,
|
|
500
|
+
rollupAddress: this.config.rollupAddress
|
|
501
|
+
},
|
|
502
|
+
config: this.config,
|
|
503
|
+
avmSimulator: this.avmSimulator,
|
|
504
|
+
telemetry: this.telemetry,
|
|
505
|
+
log: this.log.createChild('public-calls-simulator')
|
|
506
|
+
});
|
|
507
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
508
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
509
|
+
blockSource: this.blockSource,
|
|
510
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
511
|
+
log: this.log.createChild('world-state-queries')
|
|
512
|
+
});
|
|
513
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
514
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
515
|
+
p2pClient: this.p2pClient,
|
|
516
|
+
blockSource: this.blockSource,
|
|
517
|
+
debugLogStore: this.debugLogStore
|
|
518
|
+
});
|
|
98
519
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
99
|
-
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config
|
|
520
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
521
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
522
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
523
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
524
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
525
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
529
|
+
return this.rpcProofVerifier;
|
|
100
530
|
}
|
|
101
531
|
async getWorldStateSyncStatus() {
|
|
102
532
|
const status = await this.worldStateSynchronizer.status();
|
|
103
533
|
return status.syncSummary;
|
|
104
534
|
}
|
|
105
|
-
|
|
535
|
+
getChainTips() {
|
|
106
536
|
return this.blockSource.getL2Tips();
|
|
107
537
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
127
|
-
if (keyStoreProvided) {
|
|
128
|
-
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
129
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
130
|
-
} else {
|
|
131
|
-
const keyStore = createKeyStoreForValidator(config);
|
|
132
|
-
if (keyStore) {
|
|
133
|
-
keyStoreManager = new KeystoreManager(keyStore);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
await keyStoreManager?.validateSigners();
|
|
137
|
-
// If we are a validator, verify our configuration before doing too much more.
|
|
138
|
-
if (!config.disableValidator) {
|
|
139
|
-
if (keyStoreManager === undefined) {
|
|
140
|
-
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
141
|
-
}
|
|
142
|
-
if (!keyStoreProvided) {
|
|
143
|
-
log.warn('KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS');
|
|
144
|
-
}
|
|
145
|
-
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
146
|
-
}
|
|
147
|
-
// validate that the actual chain id matches that specified in configuration
|
|
148
|
-
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
149
|
-
throw new Error(`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`);
|
|
150
|
-
}
|
|
151
|
-
const publicClient = createPublicClient({
|
|
152
|
-
chain: ethereumChain.chainInfo,
|
|
153
|
-
transport: fallback(config.l1RpcUrls.map((url)=>http(url))),
|
|
154
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
155
|
-
});
|
|
156
|
-
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
157
|
-
// Overwrite the passed in vars.
|
|
158
|
-
config.l1Contracts = {
|
|
159
|
-
...config.l1Contracts,
|
|
160
|
-
...l1ContractsAddresses
|
|
161
|
-
};
|
|
162
|
-
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
163
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
164
|
-
rollupContract.getL1GenesisTime(),
|
|
165
|
-
rollupContract.getSlotDuration(),
|
|
166
|
-
rollupContract.getVersion()
|
|
167
|
-
]);
|
|
168
|
-
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
169
|
-
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
170
|
-
log.warn(`Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`);
|
|
171
|
-
}
|
|
172
|
-
// attempt snapshot sync if possible
|
|
173
|
-
await trySnapshotSync(config, log);
|
|
174
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
175
|
-
dateProvider
|
|
176
|
-
});
|
|
177
|
-
const archiver = await createArchiver(config, {
|
|
178
|
-
blobSinkClient,
|
|
179
|
-
epochCache,
|
|
180
|
-
telemetry,
|
|
181
|
-
dateProvider
|
|
182
|
-
}, {
|
|
183
|
-
blockUntilSync: !config.skipArchiverInitialSync
|
|
184
|
-
});
|
|
185
|
-
// now create the merkle trees and the world state synchronizer
|
|
186
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
187
|
-
const circuitVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
188
|
-
if (!config.realProofs) {
|
|
189
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
190
|
-
}
|
|
191
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
192
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
193
|
-
const p2pClient = await createP2PClient(P2PClientType.Full, config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
194
|
-
// We should really not be modifying the config object
|
|
195
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
196
|
-
const blockBuilder = new BlockBuilder({
|
|
197
|
-
...config,
|
|
198
|
-
l1GenesisTime,
|
|
199
|
-
slotDuration: Number(slotDuration)
|
|
200
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
201
|
-
// We'll accumulate sentinel watchers here
|
|
202
|
-
const watchers = [];
|
|
203
|
-
// Create validator client if required
|
|
204
|
-
const validatorClient = createValidatorClient(config, {
|
|
205
|
-
p2pClient,
|
|
206
|
-
telemetry,
|
|
207
|
-
dateProvider,
|
|
208
|
-
epochCache,
|
|
209
|
-
blockBuilder,
|
|
210
|
-
blockSource: archiver,
|
|
211
|
-
l1ToL2MessageSource: archiver,
|
|
212
|
-
keyStoreManager
|
|
213
|
-
});
|
|
214
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
215
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
216
|
-
// like attestations or auths will fail.
|
|
217
|
-
if (validatorClient) {
|
|
218
|
-
watchers.push(validatorClient);
|
|
219
|
-
if (!options.dontStartSequencer) {
|
|
220
|
-
await validatorClient.registerHandlers();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// If there's no validator client but alwaysReexecuteBlockProposals is enabled,
|
|
224
|
-
// create a BlockProposalHandler to reexecute block proposals for monitoring
|
|
225
|
-
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
226
|
-
log.info('Setting up block proposal reexecution for monitoring');
|
|
227
|
-
createBlockProposalHandler(config, {
|
|
228
|
-
blockBuilder,
|
|
229
|
-
epochCache,
|
|
230
|
-
blockSource: archiver,
|
|
231
|
-
l1ToL2MessageSource: archiver,
|
|
232
|
-
p2pClient,
|
|
233
|
-
dateProvider,
|
|
234
|
-
telemetry
|
|
235
|
-
}).registerForReexecution(p2pClient);
|
|
236
|
-
}
|
|
237
|
-
// Start world state and wait for it to sync to the archiver.
|
|
238
|
-
await worldStateSynchronizer.start();
|
|
239
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
240
|
-
await p2pClient.start();
|
|
241
|
-
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
242
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
243
|
-
watchers.push(validatorsSentinel);
|
|
244
|
-
}
|
|
245
|
-
let epochPruneWatcher;
|
|
246
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
247
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), blockBuilder, config);
|
|
248
|
-
watchers.push(epochPruneWatcher);
|
|
249
|
-
}
|
|
250
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
251
|
-
let attestationsBlockWatcher;
|
|
252
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
253
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
254
|
-
watchers.push(attestationsBlockWatcher);
|
|
255
|
-
}
|
|
256
|
-
// Start p2p-related services once the archiver has completed sync
|
|
257
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
258
|
-
await p2pClient.start();
|
|
259
|
-
await validatorsSentinel?.start();
|
|
260
|
-
await epochPruneWatcher?.start();
|
|
261
|
-
await attestationsBlockWatcher?.start();
|
|
262
|
-
log.info(`All p2p services started`);
|
|
263
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
264
|
-
// Validator enabled, create/start relevant service
|
|
265
|
-
let sequencer;
|
|
266
|
-
let slasherClient;
|
|
267
|
-
if (!config.disableValidator) {
|
|
268
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
269
|
-
// as they are executed when the node is selected as proposer.
|
|
270
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
271
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
272
|
-
await slasherClient.start();
|
|
273
|
-
const l1TxUtils = await createL1TxUtilsWithBlobsFromEthSigner(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
274
|
-
...config,
|
|
275
|
-
scope: 'sequencer'
|
|
276
|
-
}, {
|
|
277
|
-
telemetry,
|
|
278
|
-
logger: log.createChild('l1-tx-utils'),
|
|
279
|
-
dateProvider
|
|
280
|
-
});
|
|
281
|
-
// Create and start the sequencer client
|
|
282
|
-
sequencer = await SequencerClient.new(config, {
|
|
283
|
-
...deps,
|
|
284
|
-
epochCache,
|
|
285
|
-
l1TxUtils,
|
|
286
|
-
validatorClient,
|
|
287
|
-
p2pClient,
|
|
288
|
-
worldStateSynchronizer,
|
|
289
|
-
slasherClient,
|
|
290
|
-
blockBuilder,
|
|
291
|
-
l2BlockSource: archiver,
|
|
292
|
-
l1ToL2MessageSource: archiver,
|
|
293
|
-
telemetry,
|
|
294
|
-
dateProvider,
|
|
295
|
-
blobSinkClient,
|
|
296
|
-
nodeKeyStore: keyStoreManager
|
|
297
|
-
});
|
|
538
|
+
getL1Constants() {
|
|
539
|
+
return this.blockSource.getL1Constants();
|
|
540
|
+
}
|
|
541
|
+
getSyncedL2SlotNumber() {
|
|
542
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
543
|
+
}
|
|
544
|
+
getSyncedL2EpochNumber() {
|
|
545
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
546
|
+
}
|
|
547
|
+
getSyncedL1Timestamp() {
|
|
548
|
+
return this.blockSource.getL1Timestamp();
|
|
549
|
+
}
|
|
550
|
+
getCheckpointsData(query) {
|
|
551
|
+
return this.blockSource.getCheckpointsData(query);
|
|
552
|
+
}
|
|
553
|
+
async getBlockNumber(tip) {
|
|
554
|
+
if (tip === undefined || tip === 'proposed') {
|
|
555
|
+
return this.blockSource.getBlockNumber();
|
|
298
556
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
557
|
+
return await this.blockSource.getBlockNumber({
|
|
558
|
+
tag: tip
|
|
559
|
+
}) ?? BlockNumber.ZERO;
|
|
560
|
+
}
|
|
561
|
+
async getCheckpointNumber(tip) {
|
|
562
|
+
const tips = await this.blockSource.getL2Tips();
|
|
563
|
+
switch(tip){
|
|
564
|
+
case undefined:
|
|
565
|
+
case 'checkpointed':
|
|
566
|
+
return tips.checkpointed.checkpoint.number;
|
|
567
|
+
case 'proven':
|
|
568
|
+
return tips.proven.checkpoint.number;
|
|
569
|
+
case 'finalized':
|
|
570
|
+
return tips.finalized.checkpoint.number;
|
|
304
571
|
}
|
|
305
|
-
|
|
572
|
+
}
|
|
573
|
+
getBlock(param, options = {}) {
|
|
574
|
+
return this.blockProvider.getBlock(param, options);
|
|
575
|
+
}
|
|
576
|
+
getBlockData(param) {
|
|
577
|
+
return this.blockProvider.getBlockData(param);
|
|
578
|
+
}
|
|
579
|
+
getBlocks(from, limit, options = {}) {
|
|
580
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
581
|
+
}
|
|
582
|
+
getCheckpoint(param, options = {}) {
|
|
583
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
584
|
+
}
|
|
585
|
+
getCheckpoints(from, limit, options = {}) {
|
|
586
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
306
587
|
}
|
|
307
588
|
/**
|
|
308
589
|
* Returns the sequencer client instance.
|
|
@@ -310,6 +591,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
310
591
|
*/ getSequencer() {
|
|
311
592
|
return this.sequencer;
|
|
312
593
|
}
|
|
594
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */ getAutomineSequencer() {
|
|
595
|
+
return this.automineSequencer;
|
|
596
|
+
}
|
|
597
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
598
|
+
return this.proverNode;
|
|
599
|
+
}
|
|
313
600
|
getBlockSource() {
|
|
314
601
|
return this.blockSource;
|
|
315
602
|
}
|
|
@@ -323,13 +610,16 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
323
610
|
* Method to return the currently deployed L1 contract addresses.
|
|
324
611
|
* @returns - The currently deployed L1 contract addresses.
|
|
325
612
|
*/ getL1ContractAddresses() {
|
|
326
|
-
return Promise.resolve(this.config
|
|
613
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
327
614
|
}
|
|
328
615
|
getEncodedEnr() {
|
|
329
616
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
330
617
|
}
|
|
331
618
|
async getAllowedPublicSetup() {
|
|
332
|
-
return
|
|
619
|
+
return [
|
|
620
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
621
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
622
|
+
];
|
|
333
623
|
}
|
|
334
624
|
/**
|
|
335
625
|
* Method to determine if the node is ready to accept transactions.
|
|
@@ -338,67 +628,47 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
338
628
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
339
629
|
}
|
|
340
630
|
async getNodeInfo() {
|
|
341
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
631
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
342
632
|
this.getNodeVersion(),
|
|
343
633
|
this.getVersion(),
|
|
344
634
|
this.getChainId(),
|
|
345
635
|
this.getEncodedEnr(),
|
|
346
636
|
this.getL1ContractAddresses(),
|
|
347
|
-
this.getProtocolContractAddresses()
|
|
637
|
+
this.getProtocolContractAddresses(),
|
|
638
|
+
this.blockSource.getL1Constants()
|
|
348
639
|
]);
|
|
640
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
641
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
642
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
643
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
644
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
349
645
|
const nodeInfo = {
|
|
350
646
|
nodeVersion,
|
|
351
647
|
l1ChainId: chainId,
|
|
352
648
|
rollupVersion,
|
|
353
649
|
enr,
|
|
354
650
|
l1ContractAddresses: contractAddresses,
|
|
355
|
-
protocolContractAddresses: protocolContractAddresses
|
|
651
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
652
|
+
realProofs: !!this.config.realProofs,
|
|
653
|
+
txsLimits: {
|
|
654
|
+
gas: {
|
|
655
|
+
daGas: maxTxGas.daGas,
|
|
656
|
+
l2Gas: maxTxGas.l2Gas
|
|
657
|
+
}
|
|
658
|
+
}
|
|
356
659
|
};
|
|
357
660
|
return nodeInfo;
|
|
358
661
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
* @param number - The block number being requested.
|
|
362
|
-
* @returns The requested block.
|
|
363
|
-
*/ async getBlock(number) {
|
|
364
|
-
const blockNumber = number === 'latest' ? await this.getBlockNumber() : number;
|
|
365
|
-
return await this.blockSource.getBlock(blockNumber);
|
|
662
|
+
async getCurrentMinFees() {
|
|
663
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
366
664
|
}
|
|
367
|
-
/**
|
|
368
|
-
|
|
369
|
-
* @param blockHash - The block hash being requested.
|
|
370
|
-
* @returns The requested block.
|
|
371
|
-
*/ async getBlockByHash(blockHash) {
|
|
372
|
-
const publishedBlock = await this.blockSource.getPublishedBlockByHash(blockHash);
|
|
373
|
-
return publishedBlock?.block;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Get a block specified by its archive root.
|
|
377
|
-
* @param archive - The archive root being requested.
|
|
378
|
-
* @returns The requested block.
|
|
379
|
-
*/ async getBlockByArchive(archive) {
|
|
380
|
-
const publishedBlock = await this.blockSource.getPublishedBlockByArchive(archive);
|
|
381
|
-
return publishedBlock?.block;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
385
|
-
* @param from - The start of the range of blocks to return.
|
|
386
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
387
|
-
* @returns The blocks requested.
|
|
388
|
-
*/ async getBlocks(from, limit) {
|
|
389
|
-
return await this.blockSource.getBlocks(from, limit) ?? [];
|
|
390
|
-
}
|
|
391
|
-
async getPublishedBlocks(from, limit) {
|
|
392
|
-
return await this.blockSource.getPublishedBlocks(from, limit) ?? [];
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Method to fetch the current base fees.
|
|
396
|
-
* @returns The current base fees.
|
|
397
|
-
*/ async getCurrentBaseFees() {
|
|
398
|
-
return await this.globalVariableBuilder.getCurrentBaseFees();
|
|
665
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
666
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
399
667
|
}
|
|
400
668
|
async getMaxPriorityFees() {
|
|
401
|
-
for await (const tx of this.p2pClient.iteratePendingTxs(
|
|
669
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({
|
|
670
|
+
includeProof: false
|
|
671
|
+
})){
|
|
402
672
|
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
403
673
|
}
|
|
404
674
|
return GasFees.from({
|
|
@@ -407,15 +677,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
407
677
|
});
|
|
408
678
|
}
|
|
409
679
|
/**
|
|
410
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
411
|
-
* @returns The block number.
|
|
412
|
-
*/ async getBlockNumber() {
|
|
413
|
-
return await this.blockSource.getBlockNumber();
|
|
414
|
-
}
|
|
415
|
-
async getProvenBlockNumber() {
|
|
416
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
680
|
* Method to fetch the version of the package.
|
|
420
681
|
* @returns The node package version
|
|
421
682
|
*/ getNodeVersion() {
|
|
@@ -436,39 +697,18 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
436
697
|
getContractClass(id) {
|
|
437
698
|
return this.contractDataSource.getContractClass(id);
|
|
438
699
|
}
|
|
439
|
-
getContract(address) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
446
|
-
* @returns An array of private logs from the specified range of blocks.
|
|
447
|
-
*/ getPrivateLogs(from, limit) {
|
|
448
|
-
return this.logsSource.getPrivateLogs(from, limit);
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
452
|
-
* @param tags - The tags to filter the logs by.
|
|
453
|
-
* @param logsPerTag - The maximum number of logs to return for each tag. By default no limit is set
|
|
454
|
-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
455
|
-
* that tag.
|
|
456
|
-
*/ getLogsByTags(tags, logsPerTag) {
|
|
457
|
-
return this.logsSource.getLogsByTags(tags, logsPerTag);
|
|
700
|
+
async getContract(address, referenceBlock = 'latest') {
|
|
701
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
702
|
+
if (!blockData) {
|
|
703
|
+
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.`);
|
|
704
|
+
}
|
|
705
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
458
706
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
* @param filter - The filter to apply to the logs.
|
|
462
|
-
* @returns The requested logs.
|
|
463
|
-
*/ getPublicLogs(filter) {
|
|
464
|
-
return this.logsSource.getPublicLogs(filter);
|
|
707
|
+
getPrivateLogsByTags(query) {
|
|
708
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
465
709
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
* @param filter - The filter to apply to the logs.
|
|
469
|
-
* @returns The requested logs.
|
|
470
|
-
*/ getContractClassLogs(filter) {
|
|
471
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
710
|
+
getPublicLogsByTags(query) {
|
|
711
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
472
712
|
}
|
|
473
713
|
/**
|
|
474
714
|
* Method to submit a transaction to the p2p pool.
|
|
@@ -488,25 +728,23 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
488
728
|
});
|
|
489
729
|
throw new Error(`Invalid tx: ${reason}`);
|
|
490
730
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
731
|
+
try {
|
|
732
|
+
await this.p2pClient.sendTx(tx);
|
|
733
|
+
} catch (err) {
|
|
734
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
735
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${err.message}`, {
|
|
736
|
+
txHash
|
|
737
|
+
});
|
|
738
|
+
throw err;
|
|
739
|
+
}
|
|
740
|
+
const duration = timer.ms();
|
|
741
|
+
this.metrics.receivedTx(duration, true);
|
|
742
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
494
743
|
txHash
|
|
495
744
|
});
|
|
496
745
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
// We first check if the tx is in pending (instead of first checking if it is mined) because if we first check
|
|
500
|
-
// for mined and then for pending there could be a race condition where the tx is mined between the two checks
|
|
501
|
-
// and we would incorrectly return a TxReceipt with status DROPPED
|
|
502
|
-
if (await this.p2pClient.getTxStatus(txHash) === 'pending') {
|
|
503
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
504
|
-
}
|
|
505
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
506
|
-
if (settledTxReceipt) {
|
|
507
|
-
txReceipt = settledTxReceipt;
|
|
508
|
-
}
|
|
509
|
-
return txReceipt;
|
|
746
|
+
getTxReceipt(txHash, options) {
|
|
747
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
510
748
|
}
|
|
511
749
|
getTxEffect(txHash) {
|
|
512
750
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -515,354 +753,152 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
515
753
|
* Method to stop the aztec node.
|
|
516
754
|
*/ async stop() {
|
|
517
755
|
this.log.info(`Stopping Aztec Node`);
|
|
518
|
-
await
|
|
519
|
-
await tryStop(this.epochPruneWatcher);
|
|
756
|
+
await this.stopStartedWatchers();
|
|
520
757
|
await tryStop(this.slasherClient);
|
|
521
|
-
await
|
|
758
|
+
await Promise.all([
|
|
759
|
+
tryStop(this.peerProofVerifier),
|
|
760
|
+
tryStop(this.rpcProofVerifier)
|
|
761
|
+
]);
|
|
522
762
|
await tryStop(this.sequencer);
|
|
763
|
+
await tryStop(this.automineSequencer);
|
|
764
|
+
await tryStop(this.proverNode);
|
|
523
765
|
await tryStop(this.p2pClient);
|
|
766
|
+
// Dispose the AVM backend before world state: it kills the bb-avm-sim processes and closes the CDB IPC
|
|
767
|
+
// server, releasing their connections to the WSDB so it shuts down cleanly (and freeing the
|
|
768
|
+
// Server/Socket/ChildProcess handles that would otherwise keep the process alive after teardown).
|
|
769
|
+
await this.avmSimulator?.[Symbol.asyncDispose]();
|
|
524
770
|
await tryStop(this.worldStateSynchronizer);
|
|
525
771
|
await tryStop(this.blockSource);
|
|
772
|
+
await tryStop(this.blobClient);
|
|
526
773
|
await tryStop(this.telemetry);
|
|
527
774
|
this.log.info(`Stopped Aztec Node`);
|
|
528
775
|
}
|
|
529
776
|
/**
|
|
777
|
+
* Returns the blob client used by this node.
|
|
778
|
+
* @internal - Exposed for testing purposes only.
|
|
779
|
+
*/ getBlobClient() {
|
|
780
|
+
return this.blobClient;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
530
783
|
* Method to retrieve pending txs.
|
|
531
784
|
* @param limit - The number of items to returns
|
|
532
785
|
* @param after - The last known pending tx. Used for pagination
|
|
533
786
|
* @returns - The pending txs.
|
|
534
|
-
*/ getPendingTxs(limit, after) {
|
|
535
|
-
return this.p2pClient.getPendingTxs(limit, after);
|
|
787
|
+
*/ getPendingTxs(limit, after, options) {
|
|
788
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
536
789
|
}
|
|
537
790
|
getPendingTxCount() {
|
|
538
791
|
return this.p2pClient.getPendingTxCount();
|
|
539
792
|
}
|
|
793
|
+
getPeers(includePending) {
|
|
794
|
+
return this.p2pClient.getPeers(includePending);
|
|
795
|
+
}
|
|
796
|
+
getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
797
|
+
return this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
798
|
+
}
|
|
799
|
+
getProposalsForSlot(slot) {
|
|
800
|
+
return this.p2pClient.getProposalsForSlot(slot);
|
|
801
|
+
}
|
|
540
802
|
/**
|
|
541
|
-
* Method to retrieve a single tx from the mempool or unfinalized chain.
|
|
803
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
804
|
+
* when `includeProof` is set.
|
|
542
805
|
* @param txHash - The transaction hash to return.
|
|
806
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
543
807
|
* @returns - The tx if it exists.
|
|
544
|
-
*/ getTxByHash(txHash) {
|
|
545
|
-
return
|
|
808
|
+
*/ getTxByHash(txHash, options) {
|
|
809
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
810
|
+
includeProof: !!options?.includeProof
|
|
811
|
+
});
|
|
546
812
|
}
|
|
547
813
|
/**
|
|
548
|
-
* Method to retrieve txs from the mempool or unfinalized chain.
|
|
814
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
815
|
+
* `includeProof` is set.
|
|
549
816
|
* @param txHash - The transaction hash to return.
|
|
817
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
550
818
|
* @returns - The txs if it exists.
|
|
551
|
-
*/ async getTxsByHash(txHashes) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
556
|
-
* the leaves were inserted.
|
|
557
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
558
|
-
* @param treeId - The tree to search in.
|
|
559
|
-
* @param leafValues - The values to search for.
|
|
560
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
561
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
562
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
563
|
-
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
564
|
-
// We filter out undefined values
|
|
565
|
-
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
566
|
-
// Now we find the block numbers for the indices
|
|
567
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
|
|
568
|
-
// If any of the block numbers are undefined, we throw an error.
|
|
569
|
-
for(let i = 0; i < indices.length; i++){
|
|
570
|
-
if (blockNumbers[i] === undefined) {
|
|
571
|
-
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
575
|
-
const uniqueBlockNumbers = [
|
|
576
|
-
...new Set(blockNumbers.filter((x)=>x !== undefined))
|
|
577
|
-
];
|
|
578
|
-
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
579
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
580
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
581
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
582
|
-
}));
|
|
583
|
-
// If any of the block hashes are undefined, we throw an error.
|
|
584
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
585
|
-
if (blockHashes[i] === undefined) {
|
|
586
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
590
|
-
return maybeIndices.map((index, i)=>{
|
|
591
|
-
if (index === undefined) {
|
|
592
|
-
return undefined;
|
|
593
|
-
}
|
|
594
|
-
const blockNumber = blockNumbers[i];
|
|
595
|
-
if (blockNumber === undefined) {
|
|
596
|
-
return undefined;
|
|
597
|
-
}
|
|
598
|
-
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
599
|
-
const blockHash = blockHashes[blockHashIndex];
|
|
600
|
-
if (!blockHash) {
|
|
601
|
-
return undefined;
|
|
602
|
-
}
|
|
603
|
-
return {
|
|
604
|
-
l2BlockNumber: BlockNumber(Number(blockNumber)),
|
|
605
|
-
l2BlockHash: L2BlockHash.fromField(blockHash),
|
|
606
|
-
data: index
|
|
607
|
-
};
|
|
819
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
820
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
821
|
+
includeProof: !!options?.includeProof
|
|
608
822
|
});
|
|
823
|
+
return compactArray(txs);
|
|
609
824
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
* @param blockNumber - The block number at which to get the data.
|
|
613
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
614
|
-
* @returns The sibling path for the leaf index.
|
|
615
|
-
*/ async getNullifierSiblingPath(blockNumber, leafIndex) {
|
|
616
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
617
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Returns a sibling path for the given index in the data tree.
|
|
621
|
-
* @param blockNumber - The block number at which to get the data.
|
|
622
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
623
|
-
* @returns The sibling path for the leaf index.
|
|
624
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
625
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
626
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
627
|
-
}
|
|
628
|
-
async getArchiveMembershipWitness(blockNumber, archive) {
|
|
629
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
630
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
631
|
-
archive
|
|
632
|
-
]);
|
|
633
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
825
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
826
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
634
827
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
638
|
-
noteHash
|
|
639
|
-
]);
|
|
640
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
828
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
829
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
641
830
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
* @param blockNumber - The block number at which to get the data.
|
|
645
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
646
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
647
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
648
|
-
const db = await this.#getWorldState(blockNumber);
|
|
649
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
650
|
-
l1ToL2Message
|
|
651
|
-
]);
|
|
652
|
-
if (!witness) {
|
|
653
|
-
return undefined;
|
|
654
|
-
}
|
|
655
|
-
// REFACTOR: Return a MembershipWitness object
|
|
656
|
-
return [
|
|
657
|
-
witness.index,
|
|
658
|
-
witness.path
|
|
659
|
-
];
|
|
831
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
832
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
660
833
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
return messageIndex ? BlockNumber(InboxLeaf.l2BlockFromIndex(messageIndex)) : undefined;
|
|
834
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
835
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
664
836
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
668
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
669
|
-
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
670
|
-
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
671
|
-
return messageIndex !== undefined;
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Returns all the L2 to L1 messages in a block.
|
|
675
|
-
* @param blockNumber - The block number at which to get the data.
|
|
676
|
-
* @returns The L2 to L1 messages (undefined if the block number is not found).
|
|
677
|
-
*/ async getL2ToL1Messages(blockNumber) {
|
|
678
|
-
const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber);
|
|
679
|
-
return block?.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Returns a sibling path for a leaf in the committed blocks tree.
|
|
683
|
-
* @param blockNumber - The block number at which to get the data.
|
|
684
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
685
|
-
* @returns The sibling path.
|
|
686
|
-
*/ async getArchiveSiblingPath(blockNumber, leafIndex) {
|
|
687
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
688
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Returns a sibling path for a leaf in the committed public data tree.
|
|
692
|
-
* @param blockNumber - The block number at which to get the data.
|
|
693
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
694
|
-
* @returns The sibling path.
|
|
695
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
696
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
697
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
701
|
-
* @param blockNumber - The block number at which to get the index.
|
|
702
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
703
|
-
* @returns The nullifier membership witness (if found).
|
|
704
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
705
|
-
const db = await this.#getWorldState(blockNumber);
|
|
706
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
707
|
-
nullifier.toBuffer()
|
|
708
|
-
]);
|
|
709
|
-
if (!witness) {
|
|
710
|
-
return undefined;
|
|
711
|
-
}
|
|
712
|
-
const { index, path } = witness;
|
|
713
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
714
|
-
if (!leafPreimage) {
|
|
715
|
-
return undefined;
|
|
716
|
-
}
|
|
717
|
-
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
721
|
-
* @param blockNumber - The block number at which to get the index.
|
|
722
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
723
|
-
* @returns The low nullifier membership witness (if found).
|
|
724
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
725
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
726
|
-
* we are trying to prove non-inclusion for.
|
|
727
|
-
*
|
|
728
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
729
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
730
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
731
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
732
|
-
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
733
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
734
|
-
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
735
|
-
if (!findResult) {
|
|
736
|
-
return undefined;
|
|
737
|
-
}
|
|
738
|
-
const { index, alreadyPresent } = findResult;
|
|
739
|
-
if (alreadyPresent) {
|
|
740
|
-
this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
741
|
-
}
|
|
742
|
-
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
743
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
744
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
745
|
-
}
|
|
746
|
-
async getPublicDataWitness(blockNumber, leafSlot) {
|
|
747
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
748
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
749
|
-
if (!lowLeafResult) {
|
|
750
|
-
return undefined;
|
|
751
|
-
} else {
|
|
752
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
753
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
754
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
755
|
-
}
|
|
837
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
838
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
756
839
|
}
|
|
757
840
|
/**
|
|
758
|
-
*
|
|
841
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
759
842
|
*
|
|
760
|
-
* @
|
|
761
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
843
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
762
844
|
*
|
|
763
|
-
* @param
|
|
764
|
-
* @
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
768
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
769
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
770
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
771
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
772
|
-
return Fr.ZERO;
|
|
773
|
-
}
|
|
774
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
775
|
-
return preimage.leaf.value;
|
|
845
|
+
* @param epoch - The epoch at which to get the data.
|
|
846
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
847
|
+
*/ getL2ToL1Messages(epoch) {
|
|
848
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
776
849
|
}
|
|
777
850
|
/**
|
|
778
|
-
* Returns the
|
|
779
|
-
*
|
|
780
|
-
*/
|
|
781
|
-
return
|
|
851
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
852
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
853
|
+
*/ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
|
|
854
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
782
855
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
* @param blockHash - The block hash being requested.
|
|
786
|
-
* @returns The requested block header.
|
|
787
|
-
*/ async getBlockHeaderByHash(blockHash) {
|
|
788
|
-
return await this.blockSource.getBlockHeaderByHash(blockHash);
|
|
856
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
857
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
789
858
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
859
|
+
getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
860
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
861
|
+
}
|
|
862
|
+
getPublicDataWitness(referenceBlock, leafSlot) {
|
|
863
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
864
|
+
}
|
|
865
|
+
getPublicStorageAt(referenceBlock, contract, slot) {
|
|
866
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
796
867
|
}
|
|
797
868
|
/**
|
|
798
869
|
* Simulates the public part of a transaction with the current state.
|
|
799
870
|
* @param tx - The transaction to simulate.
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
805
|
-
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
806
|
-
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
807
|
-
}
|
|
808
|
-
const txHash = tx.getTxHash();
|
|
809
|
-
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
810
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
811
|
-
const coinbase = EthAddress.ZERO;
|
|
812
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
813
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
814
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry);
|
|
815
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
816
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
817
|
-
txHash,
|
|
818
|
-
blockNumber
|
|
819
|
-
});
|
|
820
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
821
|
-
try {
|
|
822
|
-
const config = PublicSimulatorConfig.from({
|
|
823
|
-
skipFeeEnforcement,
|
|
824
|
-
collectDebugLogs: true,
|
|
825
|
-
collectHints: false,
|
|
826
|
-
collectCallMetadata: true,
|
|
827
|
-
collectStatistics: false,
|
|
828
|
-
collectionLimits: CollectionLimitsConfig.from({
|
|
829
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
830
|
-
})
|
|
831
|
-
});
|
|
832
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
833
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
834
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([
|
|
835
|
-
tx
|
|
836
|
-
]);
|
|
837
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
838
|
-
if (failedTxs.length) {
|
|
839
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
|
|
840
|
-
txHash
|
|
841
|
-
});
|
|
842
|
-
throw failedTxs[0].error;
|
|
843
|
-
}
|
|
844
|
-
const [processedTx] = processedTxs;
|
|
845
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed);
|
|
846
|
-
} finally{
|
|
847
|
-
await merkleTreeFork.close();
|
|
848
|
-
}
|
|
871
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
872
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
873
|
+
**/ simulatePublicCalls(tx, skipFeeEnforcement = false, overrides) {
|
|
874
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
849
875
|
}
|
|
850
876
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
851
877
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
852
|
-
const verifier = isSimulation ? undefined : this.
|
|
853
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
878
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
879
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
854
880
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
855
881
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
856
|
-
const
|
|
882
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
883
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
884
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
885
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
886
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
857
887
|
timestamp: nextSlotTimestamp,
|
|
858
888
|
blockNumber,
|
|
859
889
|
l1ChainId: this.l1ChainId,
|
|
860
890
|
rollupVersion: this.version,
|
|
861
|
-
setupAllowList:
|
|
862
|
-
|
|
891
|
+
setupAllowList: [
|
|
892
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
893
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
894
|
+
],
|
|
895
|
+
gasFees: await this.getCurrentMinFees(),
|
|
863
896
|
skipFeeEnforcement,
|
|
864
|
-
|
|
865
|
-
|
|
897
|
+
isSimulation,
|
|
898
|
+
txsPermitted: !this.config.disableTransactions,
|
|
899
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
900
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
901
|
+
}, this.log.getBindings());
|
|
866
902
|
return await validator.validateTx(tx);
|
|
867
903
|
}
|
|
868
904
|
getConfig() {
|
|
@@ -875,7 +911,20 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
875
911
|
...this.config,
|
|
876
912
|
...config
|
|
877
913
|
};
|
|
878
|
-
|
|
914
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
915
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
916
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
917
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
918
|
+
// pauseSequencer() still considers it paused.
|
|
919
|
+
const sequencerUpdate = {
|
|
920
|
+
...config
|
|
921
|
+
};
|
|
922
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
923
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
924
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
925
|
+
}
|
|
926
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
927
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
879
928
|
this.slasherClient?.updateConfig(config);
|
|
880
929
|
this.validatorsSentinel?.updateConfig(config);
|
|
881
930
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -884,7 +933,18 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
884
933
|
archiver.updateConfig(config);
|
|
885
934
|
}
|
|
886
935
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
887
|
-
|
|
936
|
+
await Promise.all([
|
|
937
|
+
tryStop(this.peerProofVerifier),
|
|
938
|
+
tryStop(this.rpcProofVerifier)
|
|
939
|
+
]);
|
|
940
|
+
if (newConfig.realProofs) {
|
|
941
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
942
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
943
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
944
|
+
} else {
|
|
945
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
946
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
947
|
+
}
|
|
888
948
|
}
|
|
889
949
|
this.config = newConfig;
|
|
890
950
|
}
|
|
@@ -893,7 +953,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
893
953
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
894
954
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
895
955
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
896
|
-
multiCallEntrypoint:
|
|
956
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
897
957
|
});
|
|
898
958
|
}
|
|
899
959
|
registerContractFunctionSignatures(signatures) {
|
|
@@ -922,7 +982,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
922
982
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
923
983
|
}
|
|
924
984
|
// And it has an L2 block hash
|
|
925
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
985
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
926
986
|
if (!l2BlockHash) {
|
|
927
987
|
this.metrics.recordSnapshotError();
|
|
928
988
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -944,12 +1004,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
944
1004
|
});
|
|
945
1005
|
return Promise.resolve();
|
|
946
1006
|
}
|
|
947
|
-
async rollbackTo(targetBlock, force) {
|
|
1007
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
948
1008
|
const archiver = this.blockSource;
|
|
949
1009
|
if (!('rollbackTo' in archiver)) {
|
|
950
1010
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
951
1011
|
}
|
|
952
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1012
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
953
1013
|
if (targetBlock < finalizedBlock) {
|
|
954
1014
|
if (force) {
|
|
955
1015
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -972,9 +1032,13 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
972
1032
|
this.log.error(`Error during rollback`, err);
|
|
973
1033
|
throw err;
|
|
974
1034
|
} finally{
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1035
|
+
if (resumeSync) {
|
|
1036
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1037
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1038
|
+
archiver.resume();
|
|
1039
|
+
} else {
|
|
1040
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1041
|
+
}
|
|
978
1042
|
}
|
|
979
1043
|
}
|
|
980
1044
|
async pauseSync() {
|
|
@@ -988,58 +1052,176 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
988
1052
|
this.blockSource.resume();
|
|
989
1053
|
return Promise.resolve();
|
|
990
1054
|
}
|
|
991
|
-
|
|
992
|
-
if (
|
|
993
|
-
|
|
1055
|
+
pauseSequencer() {
|
|
1056
|
+
if (this.automineSequencer) {
|
|
1057
|
+
this.automineSequencer.pause();
|
|
1058
|
+
return Promise.resolve();
|
|
1059
|
+
}
|
|
1060
|
+
if (this.sequencer) {
|
|
1061
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
1062
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
1063
|
+
this.sequencer.updateConfig({
|
|
1064
|
+
minTxsPerBlock: Number.MAX_SAFE_INTEGER
|
|
1065
|
+
});
|
|
1066
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
1067
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
return Promise.resolve();
|
|
1071
|
+
}
|
|
1072
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
1073
|
+
}
|
|
1074
|
+
resumeSequencer() {
|
|
1075
|
+
if (this.automineSequencer) {
|
|
1076
|
+
this.automineSequencer.resume();
|
|
1077
|
+
return Promise.resolve();
|
|
1078
|
+
}
|
|
1079
|
+
if (this.sequencer) {
|
|
1080
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
1081
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
1082
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
1083
|
+
this.sequencer.updateConfig({
|
|
1084
|
+
minTxsPerBlock: restored
|
|
1085
|
+
});
|
|
1086
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, {
|
|
1087
|
+
minTxsPerBlock: restored
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
return Promise.resolve();
|
|
994
1091
|
}
|
|
995
|
-
|
|
1092
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
996
1093
|
}
|
|
997
1094
|
getSlashOffenses(round) {
|
|
998
1095
|
if (!this.slasherClient) {
|
|
999
1096
|
throw new Error(`Slasher client not enabled`);
|
|
1000
1097
|
}
|
|
1001
1098
|
if (round === 'all') {
|
|
1002
|
-
return this.slasherClient.
|
|
1099
|
+
return this.slasherClient.getOffenses();
|
|
1003
1100
|
} else {
|
|
1004
1101
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1005
1102
|
}
|
|
1006
1103
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1104
|
+
async reloadKeystore() {
|
|
1105
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1106
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1107
|
+
}
|
|
1108
|
+
if (!this.validatorClient) {
|
|
1109
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1110
|
+
}
|
|
1111
|
+
this.log.info('Reloading keystore from disk');
|
|
1112
|
+
// Re-read and validate keystore files
|
|
1113
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1114
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1115
|
+
await newManager.validateSigners();
|
|
1116
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1117
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1118
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1119
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1120
|
+
// would silently fail on every proposer slot.
|
|
1121
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1122
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1123
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1124
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1125
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1126
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1127
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1128
|
+
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 ` + `[${[
|
|
1129
|
+
...availablePublishers
|
|
1130
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
// Build adapters for old and new keystores to compute diff
|
|
1135
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1136
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1137
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1138
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1139
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1140
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1141
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1142
|
+
if (added.length > 0) {
|
|
1143
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1144
|
+
}
|
|
1145
|
+
if (removed.length > 0) {
|
|
1146
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1147
|
+
}
|
|
1148
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1149
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1150
|
+
}
|
|
1151
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1152
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1153
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1154
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1155
|
+
if (this.sequencer) {
|
|
1156
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1014
1157
|
}
|
|
1015
|
-
|
|
1158
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1159
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1160
|
+
const slashValidatorsNever = unique([
|
|
1161
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1162
|
+
...newAddresses
|
|
1163
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1164
|
+
this.slasherClient.updateConfig({
|
|
1165
|
+
slashValidatorsNever
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
this.keyStoreManager = newManager;
|
|
1169
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1170
|
+
}
|
|
1171
|
+
async mineBlock() {
|
|
1172
|
+
if (this.automineSequencer) {
|
|
1173
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (!this.sequencer) {
|
|
1177
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1178
|
+
}
|
|
1179
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1180
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1181
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1182
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1183
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1184
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1185
|
+
this.sequencer.updateConfig({
|
|
1186
|
+
minTxsPerBlock: 0
|
|
1187
|
+
});
|
|
1016
1188
|
try {
|
|
1017
|
-
//
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1189
|
+
// Trigger the sequencer to produce a block immediately
|
|
1190
|
+
void this.sequencer.trigger();
|
|
1191
|
+
// Wait for the new L2 block to appear
|
|
1192
|
+
await retryUntil(async ()=>{
|
|
1193
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1194
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1195
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1196
|
+
} finally{
|
|
1197
|
+
this.sequencer.updateConfig({
|
|
1198
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1199
|
+
});
|
|
1021
1200
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1201
|
+
}
|
|
1202
|
+
async prove(upToCheckpoint) {
|
|
1203
|
+
if (!this.automineSequencer) {
|
|
1204
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1205
|
+
}
|
|
1206
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1207
|
+
}
|
|
1208
|
+
async warpL2TimeAtLeastTo(targetTimestamp) {
|
|
1209
|
+
if (!this.automineSequencer) {
|
|
1210
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1211
|
+
}
|
|
1212
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1213
|
+
}
|
|
1214
|
+
async warpL2TimeAtLeastBy(duration) {
|
|
1215
|
+
if (!this.automineSequencer) {
|
|
1216
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1031
1217
|
}
|
|
1218
|
+
await this.automineSequencer.warpBy(duration);
|
|
1032
1219
|
}
|
|
1033
1220
|
/**
|
|
1034
|
-
*
|
|
1035
|
-
* @
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
return
|
|
1221
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1222
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1223
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1224
|
+
*/ getWorldState(block) {
|
|
1225
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1039
1226
|
}
|
|
1040
1227
|
}
|
|
1041
|
-
_ts_decorate([
|
|
1042
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1043
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1044
|
-
}))
|
|
1045
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|