@aztec/aztec-node 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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 +163 -225
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +897 -703
- package/dest/bin/index.d.ts +1 -1
- 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/index.d.ts +1 -1
- package/dest/sentinel/sentinel.d.ts +160 -34
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +285 -125
- package/dest/sentinel/store.d.ts +11 -10
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +36 -23
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +32 -28
- 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 +689 -940
- 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 +358 -157
- package/src/sentinel/store.ts +43 -34
- package/src/test/index.ts +2 -2
|
@@ -1,52 +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 {
|
|
12
|
-
import {
|
|
13
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
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';
|
|
377
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
378
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
14
379
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
16
380
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
17
381
|
import { createLogger } from '@aztec/foundation/log';
|
|
18
|
-
import {
|
|
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 { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
32
|
-
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';
|
|
33
392
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
34
393
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
35
|
-
import {
|
|
36
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
37
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
38
|
-
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
39
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
394
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
40
395
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
41
|
-
import { NodeKeystoreAdapter, ValidatorClient
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
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';
|
|
46
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
|
+
}));
|
|
47
405
|
/**
|
|
48
406
|
* The aztec node.
|
|
49
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;
|
|
50
427
|
config;
|
|
51
428
|
p2pClient;
|
|
52
429
|
blockSource;
|
|
@@ -55,256 +432,158 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
55
432
|
l1ToL2MessageSource;
|
|
56
433
|
worldStateSynchronizer;
|
|
57
434
|
sequencer;
|
|
435
|
+
proverNode;
|
|
58
436
|
slasherClient;
|
|
59
437
|
validatorsSentinel;
|
|
60
|
-
|
|
438
|
+
stopStartedWatchers;
|
|
61
439
|
l1ChainId;
|
|
62
440
|
version;
|
|
63
441
|
globalVariableBuilder;
|
|
442
|
+
rollupContract;
|
|
443
|
+
feeProvider;
|
|
64
444
|
epochCache;
|
|
65
445
|
packageVersion;
|
|
66
|
-
|
|
446
|
+
peerProofVerifier;
|
|
447
|
+
rpcProofVerifier;
|
|
67
448
|
telemetry;
|
|
68
449
|
log;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
constructor(
|
|
76
|
-
this.config = config;
|
|
77
|
-
this.p2pClient = p2pClient;
|
|
78
|
-
this.blockSource = blockSource;
|
|
79
|
-
this.logsSource = logsSource;
|
|
80
|
-
this.contractDataSource = contractDataSource;
|
|
81
|
-
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
82
|
-
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
83
|
-
this.sequencer = sequencer;
|
|
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.
|
|
98
|
-
this.
|
|
99
|
-
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
|
+
});
|
|
100
519
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
101
|
-
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;
|
|
102
530
|
}
|
|
103
531
|
async getWorldStateSyncStatus() {
|
|
104
532
|
const status = await this.worldStateSynchronizer.status();
|
|
105
533
|
return status.syncSummary;
|
|
106
534
|
}
|
|
107
|
-
|
|
535
|
+
getChainTips() {
|
|
108
536
|
return this.blockSource.getL2Tips();
|
|
109
537
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
129
|
-
if (keyStoreProvided) {
|
|
130
|
-
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
131
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
132
|
-
} else {
|
|
133
|
-
const keyStore = createKeyStoreForValidator(config);
|
|
134
|
-
if (keyStore) {
|
|
135
|
-
keyStoreManager = new KeystoreManager(keyStore);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
await keyStoreManager?.validateSigners();
|
|
139
|
-
// If we are a validator, verify our configuration before doing too much more.
|
|
140
|
-
if (!config.disableValidator) {
|
|
141
|
-
if (keyStoreManager === undefined) {
|
|
142
|
-
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
143
|
-
}
|
|
144
|
-
if (!keyStoreProvided) {
|
|
145
|
-
log.warn('KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS');
|
|
146
|
-
}
|
|
147
|
-
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
148
|
-
}
|
|
149
|
-
// validate that the actual chain id matches that specified in configuration
|
|
150
|
-
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
151
|
-
throw new Error(`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`);
|
|
152
|
-
}
|
|
153
|
-
const publicClient = createPublicClient({
|
|
154
|
-
chain: ethereumChain.chainInfo,
|
|
155
|
-
transport: fallback(config.l1RpcUrls.map((url)=>http(url))),
|
|
156
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
157
|
-
});
|
|
158
|
-
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
159
|
-
// Overwrite the passed in vars.
|
|
160
|
-
config.l1Contracts = {
|
|
161
|
-
...config.l1Contracts,
|
|
162
|
-
...l1ContractsAddresses
|
|
163
|
-
};
|
|
164
|
-
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
165
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
166
|
-
rollupContract.getL1GenesisTime(),
|
|
167
|
-
rollupContract.getSlotDuration(),
|
|
168
|
-
rollupContract.getVersion()
|
|
169
|
-
]);
|
|
170
|
-
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
171
|
-
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
172
|
-
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}).`);
|
|
173
|
-
}
|
|
174
|
-
// attempt snapshot sync if possible
|
|
175
|
-
await trySnapshotSync(config, log);
|
|
176
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
177
|
-
dateProvider
|
|
178
|
-
});
|
|
179
|
-
const archiver = await createArchiver(config, {
|
|
180
|
-
blobSinkClient,
|
|
181
|
-
epochCache,
|
|
182
|
-
telemetry,
|
|
183
|
-
dateProvider
|
|
184
|
-
}, {
|
|
185
|
-
blockUntilSync: !config.skipArchiverInitialSync
|
|
186
|
-
});
|
|
187
|
-
// now create the merkle trees and the world state synchronizer
|
|
188
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
189
|
-
const circuitVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
|
|
190
|
-
if (!config.realProofs) {
|
|
191
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
192
|
-
}
|
|
193
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
194
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
195
|
-
const p2pClient = await createP2PClient(P2PClientType.Full, config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
196
|
-
// We should really not be modifying the config object
|
|
197
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
198
|
-
const blockBuilder = new BlockBuilder({
|
|
199
|
-
...config,
|
|
200
|
-
l1GenesisTime,
|
|
201
|
-
slotDuration: Number(slotDuration)
|
|
202
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
203
|
-
// We'll accumulate sentinel watchers here
|
|
204
|
-
const watchers = [];
|
|
205
|
-
// Create validator client if required
|
|
206
|
-
const validatorClient = createValidatorClient(config, {
|
|
207
|
-
p2pClient,
|
|
208
|
-
telemetry,
|
|
209
|
-
dateProvider,
|
|
210
|
-
epochCache,
|
|
211
|
-
blockBuilder,
|
|
212
|
-
blockSource: archiver,
|
|
213
|
-
l1ToL2MessageSource: archiver,
|
|
214
|
-
keyStoreManager
|
|
215
|
-
});
|
|
216
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
217
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
218
|
-
// like attestations or auths will fail.
|
|
219
|
-
if (validatorClient) {
|
|
220
|
-
watchers.push(validatorClient);
|
|
221
|
-
if (!options.dontStartSequencer) {
|
|
222
|
-
await validatorClient.registerHandlers();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// If there's no validator client but alwaysReexecuteBlockProposals is enabled,
|
|
226
|
-
// create a BlockProposalHandler to reexecute block proposals for monitoring
|
|
227
|
-
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
228
|
-
log.info('Setting up block proposal reexecution for monitoring');
|
|
229
|
-
createBlockProposalHandler(config, {
|
|
230
|
-
blockBuilder,
|
|
231
|
-
epochCache,
|
|
232
|
-
blockSource: archiver,
|
|
233
|
-
l1ToL2MessageSource: archiver,
|
|
234
|
-
p2pClient,
|
|
235
|
-
dateProvider,
|
|
236
|
-
telemetry
|
|
237
|
-
}).registerForReexecution(p2pClient);
|
|
238
|
-
}
|
|
239
|
-
// Start world state and wait for it to sync to the archiver.
|
|
240
|
-
await worldStateSynchronizer.start();
|
|
241
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
242
|
-
await p2pClient.start();
|
|
243
|
-
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
244
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
245
|
-
watchers.push(validatorsSentinel);
|
|
246
|
-
}
|
|
247
|
-
let epochPruneWatcher;
|
|
248
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
249
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), blockBuilder, config);
|
|
250
|
-
watchers.push(epochPruneWatcher);
|
|
251
|
-
}
|
|
252
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
253
|
-
let attestationsBlockWatcher;
|
|
254
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
255
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
256
|
-
watchers.push(attestationsBlockWatcher);
|
|
257
|
-
}
|
|
258
|
-
// Start p2p-related services once the archiver has completed sync
|
|
259
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
260
|
-
await p2pClient.start();
|
|
261
|
-
await validatorsSentinel?.start();
|
|
262
|
-
await epochPruneWatcher?.start();
|
|
263
|
-
await attestationsBlockWatcher?.start();
|
|
264
|
-
log.info(`All p2p services started`);
|
|
265
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
266
|
-
// Validator enabled, create/start relevant service
|
|
267
|
-
let sequencer;
|
|
268
|
-
let slasherClient;
|
|
269
|
-
if (!config.disableValidator) {
|
|
270
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
271
|
-
// as they are executed when the node is selected as proposer.
|
|
272
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
273
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
274
|
-
await slasherClient.start();
|
|
275
|
-
const l1TxUtils = await createL1TxUtilsWithBlobsFromEthSigner(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
276
|
-
...config,
|
|
277
|
-
scope: 'sequencer'
|
|
278
|
-
}, {
|
|
279
|
-
telemetry,
|
|
280
|
-
logger: log.createChild('l1-tx-utils'),
|
|
281
|
-
dateProvider
|
|
282
|
-
});
|
|
283
|
-
// Create and start the sequencer client
|
|
284
|
-
sequencer = await SequencerClient.new(config, {
|
|
285
|
-
...deps,
|
|
286
|
-
epochCache,
|
|
287
|
-
l1TxUtils,
|
|
288
|
-
validatorClient,
|
|
289
|
-
p2pClient,
|
|
290
|
-
worldStateSynchronizer,
|
|
291
|
-
slasherClient,
|
|
292
|
-
blockBuilder,
|
|
293
|
-
l2BlockSource: archiver,
|
|
294
|
-
l1ToL2MessageSource: archiver,
|
|
295
|
-
telemetry,
|
|
296
|
-
dateProvider,
|
|
297
|
-
blobSinkClient,
|
|
298
|
-
nodeKeyStore: keyStoreManager
|
|
299
|
-
});
|
|
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();
|
|
300
556
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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;
|
|
306
571
|
}
|
|
307
|
-
|
|
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);
|
|
308
587
|
}
|
|
309
588
|
/**
|
|
310
589
|
* Returns the sequencer client instance.
|
|
@@ -312,6 +591,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
312
591
|
*/ getSequencer() {
|
|
313
592
|
return this.sequencer;
|
|
314
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
|
+
}
|
|
315
600
|
getBlockSource() {
|
|
316
601
|
return this.blockSource;
|
|
317
602
|
}
|
|
@@ -325,13 +610,16 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
325
610
|
* Method to return the currently deployed L1 contract addresses.
|
|
326
611
|
* @returns - The currently deployed L1 contract addresses.
|
|
327
612
|
*/ getL1ContractAddresses() {
|
|
328
|
-
return Promise.resolve(this.config
|
|
613
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
329
614
|
}
|
|
330
615
|
getEncodedEnr() {
|
|
331
616
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
332
617
|
}
|
|
333
618
|
async getAllowedPublicSetup() {
|
|
334
|
-
return
|
|
619
|
+
return [
|
|
620
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
621
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
622
|
+
];
|
|
335
623
|
}
|
|
336
624
|
/**
|
|
337
625
|
* Method to determine if the node is ready to accept transactions.
|
|
@@ -340,73 +628,53 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
340
628
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
341
629
|
}
|
|
342
630
|
async getNodeInfo() {
|
|
343
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
631
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
344
632
|
this.getNodeVersion(),
|
|
345
633
|
this.getVersion(),
|
|
346
634
|
this.getChainId(),
|
|
347
635
|
this.getEncodedEnr(),
|
|
348
636
|
this.getL1ContractAddresses(),
|
|
349
|
-
this.getProtocolContractAddresses()
|
|
637
|
+
this.getProtocolContractAddresses(),
|
|
638
|
+
this.blockSource.getL1Constants()
|
|
350
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);
|
|
351
645
|
const nodeInfo = {
|
|
352
646
|
nodeVersion,
|
|
353
647
|
l1ChainId: chainId,
|
|
354
648
|
rollupVersion,
|
|
355
649
|
enr,
|
|
356
650
|
l1ContractAddresses: contractAddresses,
|
|
357
|
-
protocolContractAddresses: protocolContractAddresses
|
|
651
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
652
|
+
realProofs: !!this.config.realProofs,
|
|
653
|
+
txsLimits: {
|
|
654
|
+
gas: {
|
|
655
|
+
daGas: maxTxGas.daGas,
|
|
656
|
+
l2Gas: maxTxGas.l2Gas
|
|
657
|
+
}
|
|
658
|
+
}
|
|
358
659
|
};
|
|
359
660
|
return nodeInfo;
|
|
360
661
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* @param number - The block number being requested.
|
|
364
|
-
* @returns The requested block.
|
|
365
|
-
*/ async getBlock(number) {
|
|
366
|
-
const blockNumber = number === 'latest' ? await this.getBlockNumber() : number;
|
|
367
|
-
return await this.blockSource.getBlock(blockNumber);
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Get a block specified by its hash.
|
|
371
|
-
* @param blockHash - The block hash being requested.
|
|
372
|
-
* @returns The requested block.
|
|
373
|
-
*/ async getBlockByHash(blockHash) {
|
|
374
|
-
const publishedBlock = await this.blockSource.getPublishedBlockByHash(blockHash);
|
|
375
|
-
return publishedBlock?.block;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Get a block specified by its archive root.
|
|
379
|
-
* @param archive - The archive root being requested.
|
|
380
|
-
* @returns The requested block.
|
|
381
|
-
*/ async getBlockByArchive(archive) {
|
|
382
|
-
const publishedBlock = await this.blockSource.getPublishedBlockByArchive(archive);
|
|
383
|
-
return publishedBlock?.block;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
387
|
-
* @param from - The start of the range of blocks to return.
|
|
388
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
389
|
-
* @returns The blocks requested.
|
|
390
|
-
*/ async getBlocks(from, limit) {
|
|
391
|
-
return await this.blockSource.getBlocks(from, limit) ?? [];
|
|
392
|
-
}
|
|
393
|
-
async getPublishedBlocks(from, limit) {
|
|
394
|
-
return await this.blockSource.getPublishedBlocks(from, limit) ?? [];
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Method to fetch the current base fees.
|
|
398
|
-
* @returns The current base fees.
|
|
399
|
-
*/ async getCurrentBaseFees() {
|
|
400
|
-
return await this.globalVariableBuilder.getCurrentBaseFees();
|
|
662
|
+
async getCurrentMinFees() {
|
|
663
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
401
664
|
}
|
|
402
|
-
/**
|
|
403
|
-
|
|
404
|
-
* @returns The block number.
|
|
405
|
-
*/ async getBlockNumber() {
|
|
406
|
-
return await this.blockSource.getBlockNumber();
|
|
665
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
666
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
407
667
|
}
|
|
408
|
-
async
|
|
409
|
-
|
|
668
|
+
async getMaxPriorityFees() {
|
|
669
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({
|
|
670
|
+
includeProof: false
|
|
671
|
+
})){
|
|
672
|
+
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
673
|
+
}
|
|
674
|
+
return GasFees.from({
|
|
675
|
+
feePerDaGas: 0n,
|
|
676
|
+
feePerL2Gas: 0n
|
|
677
|
+
});
|
|
410
678
|
}
|
|
411
679
|
/**
|
|
412
680
|
* Method to fetch the version of the package.
|
|
@@ -429,45 +697,24 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
429
697
|
getContractClass(id) {
|
|
430
698
|
return this.contractDataSource.getContractClass(id);
|
|
431
699
|
}
|
|
432
|
-
getContract(address) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
439
|
-
* @returns An array of private logs from the specified range of blocks.
|
|
440
|
-
*/ getPrivateLogs(from, limit) {
|
|
441
|
-
return this.logsSource.getPrivateLogs(from, limit);
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
445
|
-
* @param tags - The tags to filter the logs by.
|
|
446
|
-
* @param logsPerTag - The maximum number of logs to return for each tag. By default no limit is set
|
|
447
|
-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
448
|
-
* that tag.
|
|
449
|
-
*/ getLogsByTags(tags, logsPerTag) {
|
|
450
|
-
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);
|
|
451
706
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
* @param filter - The filter to apply to the logs.
|
|
455
|
-
* @returns The requested logs.
|
|
456
|
-
*/ getPublicLogs(filter) {
|
|
457
|
-
return this.logsSource.getPublicLogs(filter);
|
|
707
|
+
getPrivateLogsByTags(query) {
|
|
708
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
458
709
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
* @param filter - The filter to apply to the logs.
|
|
462
|
-
* @returns The requested logs.
|
|
463
|
-
*/ getContractClassLogs(filter) {
|
|
464
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
710
|
+
getPublicLogsByTags(query) {
|
|
711
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
465
712
|
}
|
|
466
713
|
/**
|
|
467
714
|
* Method to submit a transaction to the p2p pool.
|
|
468
715
|
* @param tx - The transaction to be submitted.
|
|
469
716
|
*/ async sendTx(tx) {
|
|
470
|
-
await this
|
|
717
|
+
await this.#sendTx(tx);
|
|
471
718
|
}
|
|
472
719
|
async #sendTx(tx) {
|
|
473
720
|
const timer = new Timer();
|
|
@@ -481,25 +728,23 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
481
728
|
});
|
|
482
729
|
throw new Error(`Invalid tx: ${reason}`);
|
|
483
730
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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`, {
|
|
487
743
|
txHash
|
|
488
744
|
});
|
|
489
745
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
// We first check if the tx is in pending (instead of first checking if it is mined) because if we first check
|
|
493
|
-
// for mined and then for pending there could be a race condition where the tx is mined between the two checks
|
|
494
|
-
// and we would incorrectly return a TxReceipt with status DROPPED
|
|
495
|
-
if (await this.p2pClient.getTxStatus(txHash) === 'pending') {
|
|
496
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
497
|
-
}
|
|
498
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
499
|
-
if (settledTxReceipt) {
|
|
500
|
-
txReceipt = settledTxReceipt;
|
|
501
|
-
}
|
|
502
|
-
return txReceipt;
|
|
746
|
+
getTxReceipt(txHash, options) {
|
|
747
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
503
748
|
}
|
|
504
749
|
getTxEffect(txHash) {
|
|
505
750
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -508,349 +753,152 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
508
753
|
* Method to stop the aztec node.
|
|
509
754
|
*/ async stop() {
|
|
510
755
|
this.log.info(`Stopping Aztec Node`);
|
|
511
|
-
await this.
|
|
512
|
-
await tryStop(this.validatorsSentinel);
|
|
513
|
-
await tryStop(this.epochPruneWatcher);
|
|
756
|
+
await this.stopStartedWatchers();
|
|
514
757
|
await tryStop(this.slasherClient);
|
|
515
|
-
await
|
|
758
|
+
await Promise.all([
|
|
759
|
+
tryStop(this.peerProofVerifier),
|
|
760
|
+
tryStop(this.rpcProofVerifier)
|
|
761
|
+
]);
|
|
516
762
|
await tryStop(this.sequencer);
|
|
763
|
+
await tryStop(this.automineSequencer);
|
|
764
|
+
await tryStop(this.proverNode);
|
|
517
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]();
|
|
518
770
|
await tryStop(this.worldStateSynchronizer);
|
|
519
771
|
await tryStop(this.blockSource);
|
|
772
|
+
await tryStop(this.blobClient);
|
|
520
773
|
await tryStop(this.telemetry);
|
|
521
774
|
this.log.info(`Stopped Aztec Node`);
|
|
522
775
|
}
|
|
523
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
|
+
/**
|
|
524
783
|
* Method to retrieve pending txs.
|
|
525
784
|
* @param limit - The number of items to returns
|
|
526
785
|
* @param after - The last known pending tx. Used for pagination
|
|
527
786
|
* @returns - The pending txs.
|
|
528
|
-
*/ getPendingTxs(limit, after) {
|
|
529
|
-
return this.p2pClient.getPendingTxs(limit, after);
|
|
787
|
+
*/ getPendingTxs(limit, after, options) {
|
|
788
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
530
789
|
}
|
|
531
790
|
getPendingTxCount() {
|
|
532
791
|
return this.p2pClient.getPendingTxCount();
|
|
533
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
|
+
}
|
|
534
802
|
/**
|
|
535
|
-
* 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.
|
|
536
805
|
* @param txHash - The transaction hash to return.
|
|
806
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
537
807
|
* @returns - The tx if it exists.
|
|
538
|
-
*/ getTxByHash(txHash) {
|
|
539
|
-
return
|
|
808
|
+
*/ getTxByHash(txHash, options) {
|
|
809
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
810
|
+
includeProof: !!options?.includeProof
|
|
811
|
+
});
|
|
540
812
|
}
|
|
541
813
|
/**
|
|
542
|
-
* 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.
|
|
543
816
|
* @param txHash - The transaction hash to return.
|
|
817
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
544
818
|
* @returns - The txs if it exists.
|
|
545
|
-
*/ async getTxsByHash(txHashes) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
550
|
-
* the leaves were inserted.
|
|
551
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
552
|
-
* @param treeId - The tree to search in.
|
|
553
|
-
* @param leafValues - The values to search for.
|
|
554
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
555
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
556
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
557
|
-
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
558
|
-
// We filter out undefined values
|
|
559
|
-
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
560
|
-
// Now we find the block numbers for the indices
|
|
561
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
|
|
562
|
-
// If any of the block numbers are undefined, we throw an error.
|
|
563
|
-
for(let i = 0; i < indices.length; i++){
|
|
564
|
-
if (blockNumbers[i] === undefined) {
|
|
565
|
-
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
569
|
-
const uniqueBlockNumbers = [
|
|
570
|
-
...new Set(blockNumbers.filter((x)=>x !== undefined))
|
|
571
|
-
];
|
|
572
|
-
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
573
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
574
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
575
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber);
|
|
576
|
-
}));
|
|
577
|
-
// If any of the block hashes are undefined, we throw an error.
|
|
578
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
579
|
-
if (blockHashes[i] === undefined) {
|
|
580
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
// Create InBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
584
|
-
return maybeIndices.map((index, i)=>{
|
|
585
|
-
if (index === undefined) {
|
|
586
|
-
return undefined;
|
|
587
|
-
}
|
|
588
|
-
const blockNumber = blockNumbers[i];
|
|
589
|
-
if (blockNumber === undefined) {
|
|
590
|
-
return undefined;
|
|
591
|
-
}
|
|
592
|
-
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
593
|
-
const blockHash = blockHashes[blockHashIndex];
|
|
594
|
-
if (!blockHash) {
|
|
595
|
-
return undefined;
|
|
596
|
-
}
|
|
597
|
-
return {
|
|
598
|
-
l2BlockNumber: Number(blockNumber),
|
|
599
|
-
l2BlockHash: L2BlockHash.fromField(blockHash),
|
|
600
|
-
data: index
|
|
601
|
-
};
|
|
819
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
820
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
821
|
+
includeProof: !!options?.includeProof
|
|
602
822
|
});
|
|
823
|
+
return compactArray(txs);
|
|
603
824
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
* @param blockNumber - The block number at which to get the data.
|
|
607
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
608
|
-
* @returns The sibling path for the leaf index.
|
|
609
|
-
*/ async getNullifierSiblingPath(blockNumber, leafIndex) {
|
|
610
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
611
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Returns a sibling path for the given index in the data tree.
|
|
615
|
-
* @param blockNumber - The block number at which to get the data.
|
|
616
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
617
|
-
* @returns The sibling path for the leaf index.
|
|
618
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
619
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
620
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
621
|
-
}
|
|
622
|
-
async getArchiveMembershipWitness(blockNumber, archive) {
|
|
623
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
624
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
625
|
-
archive
|
|
626
|
-
]);
|
|
627
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
825
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
826
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
628
827
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
632
|
-
noteHash
|
|
633
|
-
]);
|
|
634
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
828
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
829
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
635
830
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
* @param blockNumber - The block number at which to get the data.
|
|
639
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
640
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
641
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
642
|
-
const db = await this.#getWorldState(blockNumber);
|
|
643
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
644
|
-
l1ToL2Message
|
|
645
|
-
]);
|
|
646
|
-
if (!witness) {
|
|
647
|
-
return undefined;
|
|
648
|
-
}
|
|
649
|
-
// REFACTOR: Return a MembershipWitness object
|
|
650
|
-
return [
|
|
651
|
-
witness.index,
|
|
652
|
-
witness.path
|
|
653
|
-
];
|
|
831
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
832
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
654
833
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return messageIndex ? InboxLeaf.l2BlockFromIndex(messageIndex) : undefined;
|
|
834
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
835
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
658
836
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
662
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
663
|
-
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
664
|
-
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
665
|
-
return messageIndex !== undefined;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Returns all the L2 to L1 messages in a block.
|
|
669
|
-
* @param blockNumber - The block number at which to get the data.
|
|
670
|
-
* @returns The L2 to L1 messages (undefined if the block number is not found).
|
|
671
|
-
*/ async getL2ToL1Messages(blockNumber) {
|
|
672
|
-
const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber);
|
|
673
|
-
return block?.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Returns a sibling path for a leaf in the committed blocks tree.
|
|
677
|
-
* @param blockNumber - The block number at which to get the data.
|
|
678
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
679
|
-
* @returns The sibling path.
|
|
680
|
-
*/ async getArchiveSiblingPath(blockNumber, leafIndex) {
|
|
681
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
682
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Returns a sibling path for a leaf in the committed public data tree.
|
|
686
|
-
* @param blockNumber - The block number at which to get the data.
|
|
687
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
688
|
-
* @returns The sibling path.
|
|
689
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
690
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
691
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
695
|
-
* @param blockNumber - The block number at which to get the index.
|
|
696
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
697
|
-
* @returns The nullifier membership witness (if found).
|
|
698
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
699
|
-
const db = await this.#getWorldState(blockNumber);
|
|
700
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
701
|
-
nullifier.toBuffer()
|
|
702
|
-
]);
|
|
703
|
-
if (!witness) {
|
|
704
|
-
return undefined;
|
|
705
|
-
}
|
|
706
|
-
const { index, path } = witness;
|
|
707
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
708
|
-
if (!leafPreimage) {
|
|
709
|
-
return undefined;
|
|
710
|
-
}
|
|
711
|
-
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
715
|
-
* @param blockNumber - The block number at which to get the index.
|
|
716
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
717
|
-
* @returns The low nullifier membership witness (if found).
|
|
718
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
719
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
720
|
-
* we are trying to prove non-inclusion for.
|
|
721
|
-
*
|
|
722
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
723
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
724
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
725
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
726
|
-
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
727
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
728
|
-
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
729
|
-
if (!findResult) {
|
|
730
|
-
return undefined;
|
|
731
|
-
}
|
|
732
|
-
const { index, alreadyPresent } = findResult;
|
|
733
|
-
if (alreadyPresent) {
|
|
734
|
-
this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
735
|
-
}
|
|
736
|
-
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
737
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
738
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
739
|
-
}
|
|
740
|
-
async getPublicDataWitness(blockNumber, leafSlot) {
|
|
741
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
742
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
743
|
-
if (!lowLeafResult) {
|
|
744
|
-
return undefined;
|
|
745
|
-
} else {
|
|
746
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
747
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
748
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
749
|
-
}
|
|
837
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
838
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
750
839
|
}
|
|
751
840
|
/**
|
|
752
|
-
*
|
|
841
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
753
842
|
*
|
|
754
|
-
* @
|
|
755
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
843
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
756
844
|
*
|
|
757
|
-
* @param
|
|
758
|
-
* @
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
762
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
763
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
764
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
765
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
766
|
-
return Fr.ZERO;
|
|
767
|
-
}
|
|
768
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
769
|
-
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);
|
|
770
849
|
}
|
|
771
850
|
/**
|
|
772
|
-
* Returns the
|
|
773
|
-
*
|
|
774
|
-
*/
|
|
775
|
-
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);
|
|
776
855
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
* @param blockHash - The block hash being requested.
|
|
780
|
-
* @returns The requested block header.
|
|
781
|
-
*/ async getBlockHeaderByHash(blockHash) {
|
|
782
|
-
return await this.blockSource.getBlockHeaderByHash(blockHash);
|
|
856
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
857
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
783
858
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
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);
|
|
790
867
|
}
|
|
791
868
|
/**
|
|
792
869
|
* Simulates the public part of a transaction with the current state.
|
|
793
870
|
* @param tx - The transaction to simulate.
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
799
|
-
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
800
|
-
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
801
|
-
}
|
|
802
|
-
const txHash = tx.getTxHash();
|
|
803
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
804
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
805
|
-
const coinbase = EthAddress.ZERO;
|
|
806
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
807
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
808
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry);
|
|
809
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
810
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
811
|
-
txHash,
|
|
812
|
-
blockNumber
|
|
813
|
-
});
|
|
814
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
815
|
-
try {
|
|
816
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, {
|
|
817
|
-
skipFeeEnforcement,
|
|
818
|
-
clientInitiatedSimulation: true,
|
|
819
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
820
|
-
});
|
|
821
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
822
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([
|
|
823
|
-
tx
|
|
824
|
-
]);
|
|
825
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
826
|
-
if (failedTxs.length) {
|
|
827
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
|
|
828
|
-
txHash
|
|
829
|
-
});
|
|
830
|
-
throw failedTxs[0].error;
|
|
831
|
-
}
|
|
832
|
-
const [processedTx] = processedTxs;
|
|
833
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed);
|
|
834
|
-
} finally{
|
|
835
|
-
await merkleTreeFork.close();
|
|
836
|
-
}
|
|
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);
|
|
837
875
|
}
|
|
838
876
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
839
877
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
840
|
-
const verifier = isSimulation ? undefined : this.
|
|
841
|
-
// 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)
|
|
842
880
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
843
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
844
|
-
const
|
|
881
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
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, {
|
|
845
887
|
timestamp: nextSlotTimestamp,
|
|
846
888
|
blockNumber,
|
|
847
889
|
l1ChainId: this.l1ChainId,
|
|
848
890
|
rollupVersion: this.version,
|
|
849
|
-
setupAllowList:
|
|
850
|
-
|
|
891
|
+
setupAllowList: [
|
|
892
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
893
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
894
|
+
],
|
|
895
|
+
gasFees: await this.getCurrentMinFees(),
|
|
851
896
|
skipFeeEnforcement,
|
|
852
|
-
|
|
853
|
-
|
|
897
|
+
isSimulation,
|
|
898
|
+
txsPermitted: !this.config.disableTransactions,
|
|
899
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
900
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
901
|
+
}, this.log.getBindings());
|
|
854
902
|
return await validator.validateTx(tx);
|
|
855
903
|
}
|
|
856
904
|
getConfig() {
|
|
@@ -863,7 +911,20 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
863
911
|
...this.config,
|
|
864
912
|
...config
|
|
865
913
|
};
|
|
866
|
-
|
|
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);
|
|
867
928
|
this.slasherClient?.updateConfig(config);
|
|
868
929
|
this.validatorsSentinel?.updateConfig(config);
|
|
869
930
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -872,7 +933,18 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
872
933
|
archiver.updateConfig(config);
|
|
873
934
|
}
|
|
874
935
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
875
|
-
|
|
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
|
+
}
|
|
876
948
|
}
|
|
877
949
|
this.config = newConfig;
|
|
878
950
|
}
|
|
@@ -881,7 +953,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
881
953
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
882
954
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
883
955
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
884
|
-
multiCallEntrypoint:
|
|
956
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
885
957
|
});
|
|
886
958
|
}
|
|
887
959
|
registerContractFunctionSignatures(signatures) {
|
|
@@ -910,7 +982,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
910
982
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
911
983
|
}
|
|
912
984
|
// And it has an L2 block hash
|
|
913
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
985
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
914
986
|
if (!l2BlockHash) {
|
|
915
987
|
this.metrics.recordSnapshotError();
|
|
916
988
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -932,12 +1004,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
932
1004
|
});
|
|
933
1005
|
return Promise.resolve();
|
|
934
1006
|
}
|
|
935
|
-
async rollbackTo(targetBlock, force) {
|
|
1007
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
936
1008
|
const archiver = this.blockSource;
|
|
937
1009
|
if (!('rollbackTo' in archiver)) {
|
|
938
1010
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
939
1011
|
}
|
|
940
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1012
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
941
1013
|
if (targetBlock < finalizedBlock) {
|
|
942
1014
|
if (force) {
|
|
943
1015
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -960,9 +1032,13 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
960
1032
|
this.log.error(`Error during rollback`, err);
|
|
961
1033
|
throw err;
|
|
962
1034
|
} finally{
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
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
|
+
}
|
|
966
1042
|
}
|
|
967
1043
|
}
|
|
968
1044
|
async pauseSync() {
|
|
@@ -976,58 +1052,176 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
976
1052
|
this.blockSource.resume();
|
|
977
1053
|
return Promise.resolve();
|
|
978
1054
|
}
|
|
979
|
-
|
|
980
|
-
if (
|
|
981
|
-
|
|
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();
|
|
982
1091
|
}
|
|
983
|
-
|
|
1092
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
984
1093
|
}
|
|
985
1094
|
getSlashOffenses(round) {
|
|
986
1095
|
if (!this.slasherClient) {
|
|
987
1096
|
throw new Error(`Slasher client not enabled`);
|
|
988
1097
|
}
|
|
989
1098
|
if (round === 'all') {
|
|
990
|
-
return this.slasherClient.
|
|
1099
|
+
return this.slasherClient.getOffenses();
|
|
991
1100
|
} else {
|
|
992
1101
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
993
1102
|
}
|
|
994
1103
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
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);
|
|
1002
1157
|
}
|
|
1003
|
-
|
|
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
|
+
});
|
|
1004
1188
|
try {
|
|
1005
|
-
//
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
+
});
|
|
1009
1200
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
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');
|
|
1019
1217
|
}
|
|
1218
|
+
await this.automineSequencer.warpBy(duration);
|
|
1020
1219
|
}
|
|
1021
1220
|
/**
|
|
1022
|
-
*
|
|
1023
|
-
* @
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
return this.
|
|
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);
|
|
1027
1226
|
}
|
|
1028
1227
|
}
|
|
1029
|
-
_ts_decorate([
|
|
1030
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1031
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1032
|
-
}))
|
|
1033
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|