@aztec/aztec-node 0.0.1-commit.5daedc8 → 0.0.1-commit.5de5ca79e
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/config.d.ts +12 -6
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +18 -4
- 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/server.d.ts +75 -136
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +905 -300
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +6 -5
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +89 -58
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +11 -7
- package/package.json +29 -28
- package/src/aztec-node/config.ts +35 -15
- package/src/aztec-node/node_metrics.ts +6 -17
- package/src/aztec-node/server.ts +658 -376
- package/src/sentinel/factory.ts +2 -7
- package/src/sentinel/sentinel.ts +101 -59
- package/src/sentinel/store.ts +12 -12
|
@@ -1,18 +1,388 @@
|
|
|
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
|
}
|
|
373
|
+
var _dec, _initProto;
|
|
7
374
|
import { createArchiver } from '@aztec/archiver';
|
|
8
375
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
376
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
377
|
+
import { Blob } from '@aztec/blob-lib';
|
|
11
378
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
379
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
380
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
381
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
382
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
383
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
384
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
385
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
16
386
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
17
387
|
import { createLogger } from '@aztec/foundation/log';
|
|
18
388
|
import { count } from '@aztec/foundation/string';
|
|
@@ -20,31 +390,36 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
20
390
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
21
391
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
22
392
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
23
|
-
import {
|
|
24
|
-
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
393
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
394
|
+
import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
25
395
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
26
|
-
import {
|
|
396
|
+
import { createProverNode } from '@aztec/prover-node';
|
|
397
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
398
|
+
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
27
399
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
28
400
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
29
|
-
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
401
|
+
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
30
402
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
|
-
import {
|
|
403
|
+
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
32
404
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
33
405
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
34
406
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
35
407
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
408
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
36
409
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
37
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
38
410
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
39
411
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
40
412
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
41
413
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
42
|
-
import { NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
414
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
43
415
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
44
|
-
import { createPublicClient
|
|
416
|
+
import { createPublicClient } from 'viem';
|
|
45
417
|
import { createSentinel } from '../sentinel/factory.js';
|
|
46
418
|
import { createKeyStoreForValidator } from './config.js';
|
|
47
419
|
import { NodeMetrics } from './node_metrics.js';
|
|
420
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
421
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
422
|
+
}));
|
|
48
423
|
/**
|
|
49
424
|
* The aztec node.
|
|
50
425
|
*/ export class AztecNodeService {
|
|
@@ -56,6 +431,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
56
431
|
l1ToL2MessageSource;
|
|
57
432
|
worldStateSynchronizer;
|
|
58
433
|
sequencer;
|
|
434
|
+
proverNode;
|
|
59
435
|
slasherClient;
|
|
60
436
|
validatorsSentinel;
|
|
61
437
|
epochPruneWatcher;
|
|
@@ -67,11 +443,25 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
67
443
|
proofVerifier;
|
|
68
444
|
telemetry;
|
|
69
445
|
log;
|
|
446
|
+
blobClient;
|
|
447
|
+
validatorClient;
|
|
448
|
+
keyStoreManager;
|
|
449
|
+
debugLogStore;
|
|
450
|
+
static{
|
|
451
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
452
|
+
[
|
|
453
|
+
_dec,
|
|
454
|
+
2,
|
|
455
|
+
"simulatePublicCalls"
|
|
456
|
+
]
|
|
457
|
+
], []));
|
|
458
|
+
}
|
|
70
459
|
metrics;
|
|
460
|
+
initialHeaderHashPromise;
|
|
71
461
|
// Prevent two snapshot operations to happen simultaneously
|
|
72
462
|
isUploadingSnapshot;
|
|
73
463
|
tracer;
|
|
74
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node')){
|
|
464
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
75
465
|
this.config = config;
|
|
76
466
|
this.p2pClient = p2pClient;
|
|
77
467
|
this.blockSource = blockSource;
|
|
@@ -80,6 +470,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
80
470
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
81
471
|
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
82
472
|
this.sequencer = sequencer;
|
|
473
|
+
this.proverNode = proverNode;
|
|
83
474
|
this.slasherClient = slasherClient;
|
|
84
475
|
this.validatorsSentinel = validatorsSentinel;
|
|
85
476
|
this.epochPruneWatcher = epochPruneWatcher;
|
|
@@ -91,11 +482,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
91
482
|
this.proofVerifier = proofVerifier;
|
|
92
483
|
this.telemetry = telemetry;
|
|
93
484
|
this.log = log;
|
|
485
|
+
this.blobClient = blobClient;
|
|
486
|
+
this.validatorClient = validatorClient;
|
|
487
|
+
this.keyStoreManager = keyStoreManager;
|
|
488
|
+
this.debugLogStore = debugLogStore;
|
|
489
|
+
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
94
490
|
this.isUploadingSnapshot = false;
|
|
95
491
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
96
492
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
97
493
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
98
494
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
495
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
496
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
497
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
498
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
499
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
|
+
}
|
|
99
501
|
}
|
|
100
502
|
async getWorldStateSyncStatus() {
|
|
101
503
|
const status = await this.worldStateSynchronizer.status();
|
|
@@ -116,20 +518,28 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
116
518
|
const packageVersion = getPackageVersion() ?? '';
|
|
117
519
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
118
520
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
119
|
-
const blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config, {
|
|
120
|
-
logger: createLogger('node:blob-sink:client')
|
|
121
|
-
});
|
|
122
521
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
123
|
-
// Build a key store from file if given or from environment otherwise
|
|
522
|
+
// Build a key store from file if given or from environment otherwise.
|
|
523
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
124
524
|
let keyStoreManager;
|
|
125
525
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
126
526
|
if (keyStoreProvided) {
|
|
127
527
|
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
128
528
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
129
529
|
} else {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
530
|
+
const rawKeyStores = [];
|
|
531
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
532
|
+
if (validatorKeyStore) {
|
|
533
|
+
rawKeyStores.push(validatorKeyStore);
|
|
534
|
+
}
|
|
535
|
+
if (config.enableProverNode) {
|
|
536
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
537
|
+
if (proverKeyStore) {
|
|
538
|
+
rawKeyStores.push(proverKeyStore);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (rawKeyStores.length > 0) {
|
|
542
|
+
keyStoreManager = new KeystoreManager(rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores));
|
|
133
543
|
}
|
|
134
544
|
}
|
|
135
545
|
await keyStoreManager?.validateSigners();
|
|
@@ -138,8 +548,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
138
548
|
if (keyStoreManager === undefined) {
|
|
139
549
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
140
550
|
}
|
|
141
|
-
if (!keyStoreProvided) {
|
|
142
|
-
log.warn(
|
|
551
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
552
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
143
553
|
}
|
|
144
554
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
145
555
|
}
|
|
@@ -149,7 +559,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
149
559
|
}
|
|
150
560
|
const publicClient = createPublicClient({
|
|
151
561
|
chain: ethereumChain.chainInfo,
|
|
152
|
-
transport:
|
|
562
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
563
|
+
timeout: config.l1HttpTimeoutMS
|
|
564
|
+
}),
|
|
153
565
|
pollingInterval: config.viemPollingIntervalMS
|
|
154
566
|
});
|
|
155
567
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -159,22 +571,24 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
159
571
|
...l1ContractsAddresses
|
|
160
572
|
};
|
|
161
573
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
162
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
574
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
163
575
|
rollupContract.getL1GenesisTime(),
|
|
164
576
|
rollupContract.getSlotDuration(),
|
|
165
|
-
rollupContract.getVersion()
|
|
577
|
+
rollupContract.getVersion(),
|
|
578
|
+
rollupContract.getManaLimit().then(Number)
|
|
166
579
|
]);
|
|
167
580
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
168
581
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
169
582
|
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}).`);
|
|
170
583
|
}
|
|
584
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
171
585
|
// attempt snapshot sync if possible
|
|
172
586
|
await trySnapshotSync(config, log);
|
|
173
587
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
174
588
|
dateProvider
|
|
175
589
|
});
|
|
176
590
|
const archiver = await createArchiver(config, {
|
|
177
|
-
|
|
591
|
+
blobClient,
|
|
178
592
|
epochCache,
|
|
179
593
|
telemetry,
|
|
180
594
|
dateProvider
|
|
@@ -183,74 +597,97 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
183
597
|
});
|
|
184
598
|
// now create the merkle trees and the world state synchronizer
|
|
185
599
|
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
186
|
-
const circuitVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
600
|
+
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
601
|
+
let debugLogStore;
|
|
187
602
|
if (!config.realProofs) {
|
|
188
603
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
604
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
605
|
+
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
606
|
+
} else {
|
|
607
|
+
debugLogStore = new NullDebugLogStore();
|
|
189
608
|
}
|
|
190
609
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
610
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
611
|
+
if (proverOnly) {
|
|
612
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
613
|
+
}
|
|
191
614
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
192
|
-
const p2pClient = await createP2PClient(
|
|
193
|
-
// We
|
|
194
|
-
|
|
195
|
-
|
|
615
|
+
const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
616
|
+
// We'll accumulate sentinel watchers here
|
|
617
|
+
const watchers = [];
|
|
618
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
619
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
620
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
196
621
|
...config,
|
|
197
622
|
l1GenesisTime,
|
|
198
|
-
slotDuration: Number(slotDuration)
|
|
623
|
+
slotDuration: Number(slotDuration),
|
|
624
|
+
rollupManaLimit,
|
|
625
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
199
626
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
627
|
+
let validatorClient;
|
|
628
|
+
if (!proverOnly) {
|
|
629
|
+
// Create validator client if required
|
|
630
|
+
validatorClient = await createValidatorClient(config, {
|
|
631
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
632
|
+
worldState: worldStateSynchronizer,
|
|
633
|
+
p2pClient,
|
|
634
|
+
telemetry,
|
|
635
|
+
dateProvider,
|
|
636
|
+
epochCache,
|
|
637
|
+
blockSource: archiver,
|
|
638
|
+
l1ToL2MessageSource: archiver,
|
|
639
|
+
keyStoreManager,
|
|
640
|
+
blobClient,
|
|
641
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
642
|
+
});
|
|
643
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
644
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
645
|
+
// like attestations or auths will fail.
|
|
646
|
+
if (validatorClient) {
|
|
647
|
+
watchers.push(validatorClient);
|
|
648
|
+
if (!options.dontStartSequencer) {
|
|
649
|
+
await validatorClient.registerHandlers();
|
|
650
|
+
}
|
|
220
651
|
}
|
|
221
652
|
}
|
|
222
|
-
// If there's no validator client
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
|
|
653
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
654
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
655
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
656
|
+
if (!validatorClient) {
|
|
657
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
658
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
226
659
|
createBlockProposalHandler(config, {
|
|
227
|
-
|
|
660
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
661
|
+
worldState: worldStateSynchronizer,
|
|
228
662
|
epochCache,
|
|
229
663
|
blockSource: archiver,
|
|
230
664
|
l1ToL2MessageSource: archiver,
|
|
231
665
|
p2pClient,
|
|
232
666
|
dateProvider,
|
|
233
667
|
telemetry
|
|
234
|
-
}).
|
|
668
|
+
}).register(p2pClient, reexecute);
|
|
235
669
|
}
|
|
236
670
|
// Start world state and wait for it to sync to the archiver.
|
|
237
671
|
await worldStateSynchronizer.start();
|
|
238
672
|
// Start p2p. Note that it depends on world state to be running.
|
|
239
673
|
await p2pClient.start();
|
|
240
|
-
|
|
241
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
242
|
-
watchers.push(validatorsSentinel);
|
|
243
|
-
}
|
|
674
|
+
let validatorsSentinel;
|
|
244
675
|
let epochPruneWatcher;
|
|
245
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
246
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), blockBuilder, config);
|
|
247
|
-
watchers.push(epochPruneWatcher);
|
|
248
|
-
}
|
|
249
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
250
676
|
let attestationsBlockWatcher;
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
677
|
+
if (!proverOnly) {
|
|
678
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
679
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
680
|
+
watchers.push(validatorsSentinel);
|
|
681
|
+
}
|
|
682
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
683
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
684
|
+
watchers.push(epochPruneWatcher);
|
|
685
|
+
}
|
|
686
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
687
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
688
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
689
|
+
watchers.push(attestationsBlockWatcher);
|
|
690
|
+
}
|
|
254
691
|
}
|
|
255
692
|
// Start p2p-related services once the archiver has completed sync
|
|
256
693
|
void archiver.waitForInitialSync().then(async ()=>{
|
|
@@ -263,21 +700,36 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
263
700
|
// Validator enabled, create/start relevant service
|
|
264
701
|
let sequencer;
|
|
265
702
|
let slasherClient;
|
|
266
|
-
if (!config.disableValidator) {
|
|
703
|
+
if (!config.disableValidator && validatorClient) {
|
|
267
704
|
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
268
705
|
// as they are executed when the node is selected as proposer.
|
|
269
706
|
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
270
707
|
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
271
708
|
await slasherClient.start();
|
|
272
|
-
const l1TxUtils = await
|
|
709
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
710
|
+
...config,
|
|
711
|
+
scope: 'sequencer'
|
|
712
|
+
}, {
|
|
713
|
+
telemetry,
|
|
714
|
+
logger: log.createChild('l1-tx-utils'),
|
|
715
|
+
dateProvider,
|
|
716
|
+
kzg: Blob.getViemKzgInstance()
|
|
717
|
+
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
273
718
|
...config,
|
|
274
719
|
scope: 'sequencer'
|
|
275
720
|
}, {
|
|
276
721
|
telemetry,
|
|
277
722
|
logger: log.createChild('l1-tx-utils'),
|
|
278
|
-
dateProvider
|
|
723
|
+
dateProvider,
|
|
724
|
+
kzg: Blob.getViemKzgInstance()
|
|
279
725
|
});
|
|
280
726
|
// Create and start the sequencer client
|
|
727
|
+
const checkpointsBuilder = new CheckpointsBuilder({
|
|
728
|
+
...config,
|
|
729
|
+
l1GenesisTime,
|
|
730
|
+
slotDuration: Number(slotDuration),
|
|
731
|
+
rollupManaLimit
|
|
732
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
281
733
|
sequencer = await SequencerClient.new(config, {
|
|
282
734
|
...deps,
|
|
283
735
|
epochCache,
|
|
@@ -286,12 +738,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
286
738
|
p2pClient,
|
|
287
739
|
worldStateSynchronizer,
|
|
288
740
|
slasherClient,
|
|
289
|
-
|
|
741
|
+
checkpointsBuilder,
|
|
290
742
|
l2BlockSource: archiver,
|
|
291
743
|
l1ToL2MessageSource: archiver,
|
|
292
744
|
telemetry,
|
|
293
745
|
dateProvider,
|
|
294
|
-
|
|
746
|
+
blobClient,
|
|
295
747
|
nodeKeyStore: keyStoreManager
|
|
296
748
|
});
|
|
297
749
|
}
|
|
@@ -301,7 +753,35 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
301
753
|
} else if (sequencer) {
|
|
302
754
|
log.warn(`Sequencer created but not started`);
|
|
303
755
|
}
|
|
304
|
-
|
|
756
|
+
// Create prover node subsystem if enabled
|
|
757
|
+
let proverNode;
|
|
758
|
+
if (config.enableProverNode) {
|
|
759
|
+
proverNode = await createProverNode(config, {
|
|
760
|
+
...deps.proverNodeDeps,
|
|
761
|
+
telemetry,
|
|
762
|
+
dateProvider,
|
|
763
|
+
archiver,
|
|
764
|
+
worldStateSynchronizer,
|
|
765
|
+
p2pClient,
|
|
766
|
+
epochCache,
|
|
767
|
+
blobClient,
|
|
768
|
+
keyStoreManager
|
|
769
|
+
});
|
|
770
|
+
if (!options.dontStartProverNode) {
|
|
771
|
+
await proverNode.start();
|
|
772
|
+
log.info(`Prover node subsystem started`);
|
|
773
|
+
} else {
|
|
774
|
+
log.info(`Prover node subsystem created but not started`);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
778
|
+
...config,
|
|
779
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
780
|
+
l1GenesisTime,
|
|
781
|
+
slotDuration: Number(slotDuration)
|
|
782
|
+
});
|
|
783
|
+
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
784
|
+
return node;
|
|
305
785
|
}
|
|
306
786
|
/**
|
|
307
787
|
* Returns the sequencer client instance.
|
|
@@ -309,6 +789,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
309
789
|
*/ getSequencer() {
|
|
310
790
|
return this.sequencer;
|
|
311
791
|
}
|
|
792
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
793
|
+
return this.proverNode;
|
|
794
|
+
}
|
|
312
795
|
getBlockSource() {
|
|
313
796
|
return this.blockSource;
|
|
314
797
|
}
|
|
@@ -328,7 +811,10 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
328
811
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
329
812
|
}
|
|
330
813
|
async getAllowedPublicSetup() {
|
|
331
|
-
return
|
|
814
|
+
return [
|
|
815
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
816
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
817
|
+
];
|
|
332
818
|
}
|
|
333
819
|
/**
|
|
334
820
|
* Method to determine if the node is ready to accept transactions.
|
|
@@ -351,33 +837,46 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
351
837
|
rollupVersion,
|
|
352
838
|
enr,
|
|
353
839
|
l1ContractAddresses: contractAddresses,
|
|
354
|
-
protocolContractAddresses: protocolContractAddresses
|
|
840
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
841
|
+
realProofs: !!this.config.realProofs
|
|
355
842
|
};
|
|
356
843
|
return nodeInfo;
|
|
357
844
|
}
|
|
358
845
|
/**
|
|
359
|
-
* Get a block specified by its number.
|
|
360
|
-
* @param
|
|
846
|
+
* Get a block specified by its block number, block hash, or 'latest'.
|
|
847
|
+
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
361
848
|
* @returns The requested block.
|
|
362
|
-
*/ async getBlock(
|
|
363
|
-
|
|
364
|
-
|
|
849
|
+
*/ async getBlock(block) {
|
|
850
|
+
if (BlockHash.isBlockHash(block)) {
|
|
851
|
+
return this.getBlockByHash(block);
|
|
852
|
+
}
|
|
853
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
854
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
855
|
+
return this.buildInitialBlock();
|
|
856
|
+
}
|
|
857
|
+
return await this.blockSource.getL2Block(blockNumber);
|
|
365
858
|
}
|
|
366
859
|
/**
|
|
367
860
|
* Get a block specified by its hash.
|
|
368
861
|
* @param blockHash - The block hash being requested.
|
|
369
862
|
* @returns The requested block.
|
|
370
863
|
*/ async getBlockByHash(blockHash) {
|
|
371
|
-
const
|
|
372
|
-
|
|
864
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
865
|
+
if (blockHash.equals(initialBlockHash)) {
|
|
866
|
+
return this.buildInitialBlock();
|
|
867
|
+
}
|
|
868
|
+
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
869
|
+
}
|
|
870
|
+
buildInitialBlock() {
|
|
871
|
+
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
872
|
+
return L2Block.empty(initialHeader);
|
|
373
873
|
}
|
|
374
874
|
/**
|
|
375
875
|
* Get a block specified by its archive root.
|
|
376
876
|
* @param archive - The archive root being requested.
|
|
377
877
|
* @returns The requested block.
|
|
378
878
|
*/ async getBlockByArchive(archive) {
|
|
379
|
-
|
|
380
|
-
return publishedBlock?.block;
|
|
879
|
+
return await this.blockSource.getL2BlockByArchive(archive);
|
|
381
880
|
}
|
|
382
881
|
/**
|
|
383
882
|
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
@@ -385,16 +884,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
385
884
|
* @param limit - The maximum number of blocks to obtain.
|
|
386
885
|
* @returns The blocks requested.
|
|
387
886
|
*/ async getBlocks(from, limit) {
|
|
388
|
-
return await this.blockSource.getBlocks(from, limit) ?? [];
|
|
887
|
+
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
888
|
+
}
|
|
889
|
+
async getCheckpoints(from, limit) {
|
|
890
|
+
return await this.blockSource.getCheckpoints(from, limit) ?? [];
|
|
389
891
|
}
|
|
390
|
-
async
|
|
391
|
-
return await this.blockSource.
|
|
892
|
+
async getCheckpointedBlocks(from, limit) {
|
|
893
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
894
|
+
}
|
|
895
|
+
getCheckpointsDataForEpoch(epochNumber) {
|
|
896
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
392
897
|
}
|
|
393
898
|
/**
|
|
394
|
-
* Method to fetch the current
|
|
395
|
-
* @returns The current
|
|
396
|
-
*/ async
|
|
397
|
-
return await this.globalVariableBuilder.
|
|
899
|
+
* Method to fetch the current min L2 fees.
|
|
900
|
+
* @returns The current min L2 fees.
|
|
901
|
+
*/ async getCurrentMinFees() {
|
|
902
|
+
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
398
903
|
}
|
|
399
904
|
async getMaxPriorityFees() {
|
|
400
905
|
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
@@ -414,6 +919,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
414
919
|
async getProvenBlockNumber() {
|
|
415
920
|
return await this.blockSource.getProvenBlockNumber();
|
|
416
921
|
}
|
|
922
|
+
async getCheckpointedBlockNumber() {
|
|
923
|
+
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
924
|
+
}
|
|
925
|
+
getCheckpointNumber() {
|
|
926
|
+
return this.blockSource.getCheckpointNumber();
|
|
927
|
+
}
|
|
417
928
|
/**
|
|
418
929
|
* Method to fetch the version of the package.
|
|
419
930
|
* @returns The node package version
|
|
@@ -438,22 +949,37 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
438
949
|
getContract(address) {
|
|
439
950
|
return this.contractDataSource.getContract(address);
|
|
440
951
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
952
|
+
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
953
|
+
let upToBlockNumber;
|
|
954
|
+
if (referenceBlock) {
|
|
955
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
956
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
957
|
+
upToBlockNumber = BlockNumber(0);
|
|
958
|
+
} else {
|
|
959
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
960
|
+
if (!header) {
|
|
961
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
962
|
+
}
|
|
963
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
967
|
+
}
|
|
968
|
+
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
969
|
+
let upToBlockNumber;
|
|
970
|
+
if (referenceBlock) {
|
|
971
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
972
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
973
|
+
upToBlockNumber = BlockNumber(0);
|
|
974
|
+
} else {
|
|
975
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
976
|
+
if (!header) {
|
|
977
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
978
|
+
}
|
|
979
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
457
983
|
}
|
|
458
984
|
/**
|
|
459
985
|
* Gets public logs based on the provided filter.
|
|
@@ -488,24 +1014,33 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
488
1014
|
throw new Error(`Invalid tx: ${reason}`);
|
|
489
1015
|
}
|
|
490
1016
|
await this.p2pClient.sendTx(tx);
|
|
491
|
-
|
|
492
|
-
this.
|
|
1017
|
+
const duration = timer.ms();
|
|
1018
|
+
this.metrics.receivedTx(duration, true);
|
|
1019
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
493
1020
|
txHash
|
|
494
1021
|
});
|
|
495
1022
|
}
|
|
496
1023
|
async getTxReceipt(txHash) {
|
|
497
|
-
|
|
498
|
-
//
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
503
|
-
}
|
|
1024
|
+
// Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
|
|
1025
|
+
// as a fallback if we don't find a settled receipt in the archiver.
|
|
1026
|
+
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
1027
|
+
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
1028
|
+
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
504
1029
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1030
|
+
let receipt;
|
|
505
1031
|
if (settledTxReceipt) {
|
|
506
|
-
|
|
1032
|
+
receipt = settledTxReceipt;
|
|
1033
|
+
} else if (isKnownToPool) {
|
|
1034
|
+
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1035
|
+
// This handles race conditions between archiver and p2p, where the archiver
|
|
1036
|
+
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1037
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1038
|
+
} else {
|
|
1039
|
+
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1040
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
507
1041
|
}
|
|
508
|
-
|
|
1042
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1043
|
+
return receipt;
|
|
509
1044
|
}
|
|
510
1045
|
getTxEffect(txHash) {
|
|
511
1046
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -519,13 +1054,21 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
519
1054
|
await tryStop(this.slasherClient);
|
|
520
1055
|
await tryStop(this.proofVerifier);
|
|
521
1056
|
await tryStop(this.sequencer);
|
|
1057
|
+
await tryStop(this.proverNode);
|
|
522
1058
|
await tryStop(this.p2pClient);
|
|
523
1059
|
await tryStop(this.worldStateSynchronizer);
|
|
524
1060
|
await tryStop(this.blockSource);
|
|
1061
|
+
await tryStop(this.blobClient);
|
|
525
1062
|
await tryStop(this.telemetry);
|
|
526
1063
|
this.log.info(`Stopped Aztec Node`);
|
|
527
1064
|
}
|
|
528
1065
|
/**
|
|
1066
|
+
* Returns the blob client used by this node.
|
|
1067
|
+
* @internal - Exposed for testing purposes only.
|
|
1068
|
+
*/ getBlobClient() {
|
|
1069
|
+
return this.blobClient;
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
529
1072
|
* Method to retrieve pending txs.
|
|
530
1073
|
* @param limit - The number of items to returns
|
|
531
1074
|
* @param after - The last known pending tx. Used for pagination
|
|
@@ -550,101 +1093,79 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
550
1093
|
*/ async getTxsByHash(txHashes) {
|
|
551
1094
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
552
1095
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
* the leaves were inserted.
|
|
556
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
557
|
-
* @param treeId - The tree to search in.
|
|
558
|
-
* @param leafValues - The values to search for.
|
|
559
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
560
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
561
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1096
|
+
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1097
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
562
1098
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
563
|
-
//
|
|
564
|
-
const
|
|
565
|
-
// Now we find the block numbers for the indices
|
|
566
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
567
|
-
//
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
1099
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1100
|
+
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1101
|
+
// Now we find the block numbers for the defined indices
|
|
1102
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1103
|
+
// Build a map from leaf index to block number
|
|
1104
|
+
const indexToBlockNumber = new Map();
|
|
1105
|
+
for(let i = 0; i < definedIndices.length; i++){
|
|
1106
|
+
const blockNumber = blockNumbers[i];
|
|
1107
|
+
if (blockNumber === undefined) {
|
|
1108
|
+
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
571
1109
|
}
|
|
1110
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
572
1111
|
}
|
|
573
1112
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
574
1113
|
const uniqueBlockNumbers = [
|
|
575
|
-
...new Set(
|
|
1114
|
+
...new Set(indexToBlockNumber.values())
|
|
576
1115
|
];
|
|
577
|
-
// Now we obtain the block hashes from the archive tree
|
|
578
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1116
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
579
1117
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
580
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber);
|
|
1118
|
+
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
581
1119
|
}));
|
|
582
|
-
//
|
|
1120
|
+
// Build a map from block number to block hash
|
|
1121
|
+
const blockNumberToHash = new Map();
|
|
583
1122
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
584
|
-
|
|
1123
|
+
const blockHash = blockHashes[i];
|
|
1124
|
+
if (blockHash === undefined) {
|
|
585
1125
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
586
1126
|
}
|
|
1127
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
587
1128
|
}
|
|
588
|
-
// Create
|
|
589
|
-
return maybeIndices.map((index
|
|
1129
|
+
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1130
|
+
return maybeIndices.map((index)=>{
|
|
590
1131
|
if (index === undefined) {
|
|
591
1132
|
return undefined;
|
|
592
1133
|
}
|
|
593
|
-
const blockNumber =
|
|
1134
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
594
1135
|
if (blockNumber === undefined) {
|
|
595
|
-
|
|
1136
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
596
1137
|
}
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
return undefined;
|
|
1138
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1139
|
+
if (blockHash === undefined) {
|
|
1140
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
601
1141
|
}
|
|
602
1142
|
return {
|
|
603
|
-
l2BlockNumber:
|
|
604
|
-
l2BlockHash:
|
|
1143
|
+
l2BlockNumber: blockNumber,
|
|
1144
|
+
l2BlockHash: new BlockHash(blockHash),
|
|
605
1145
|
data: index
|
|
606
1146
|
};
|
|
607
1147
|
});
|
|
608
1148
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
616
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Returns a sibling path for the given index in the data tree.
|
|
620
|
-
* @param blockNumber - The block number at which to get the data.
|
|
621
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
622
|
-
* @returns The sibling path for the leaf index.
|
|
623
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
624
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
625
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
626
|
-
}
|
|
627
|
-
async getArchiveMembershipWitness(blockNumber, archive) {
|
|
628
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1149
|
+
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1150
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1151
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1152
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1153
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1154
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
629
1155
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
630
|
-
|
|
1156
|
+
blockHash
|
|
631
1157
|
]);
|
|
632
1158
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
633
1159
|
}
|
|
634
|
-
async getNoteHashMembershipWitness(
|
|
635
|
-
const committedDb = await this
|
|
1160
|
+
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1161
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
636
1162
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
637
1163
|
noteHash
|
|
638
1164
|
]);
|
|
639
1165
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
640
1166
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
* @param blockNumber - The block number at which to get the data.
|
|
644
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
645
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
646
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
647
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1167
|
+
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1168
|
+
const db = await this.getWorldState(referenceBlock);
|
|
648
1169
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
649
1170
|
l1ToL2Message
|
|
650
1171
|
]);
|
|
@@ -657,9 +1178,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
657
1178
|
witness.path
|
|
658
1179
|
];
|
|
659
1180
|
}
|
|
660
|
-
async
|
|
1181
|
+
async getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
661
1182
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
662
|
-
return messageIndex ? InboxLeaf.
|
|
1183
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
663
1184
|
}
|
|
664
1185
|
/**
|
|
665
1186
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -670,38 +1191,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
670
1191
|
return messageIndex !== undefined;
|
|
671
1192
|
}
|
|
672
1193
|
/**
|
|
673
|
-
* Returns all the L2 to L1 messages in
|
|
674
|
-
* @param
|
|
675
|
-
* @returns The L2 to L1 messages (
|
|
676
|
-
*/ async getL2ToL1Messages(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
* @returns The sibling path.
|
|
685
|
-
*/ async getArchiveSiblingPath(blockNumber, leafIndex) {
|
|
686
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
687
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Returns a sibling path for a leaf in the committed public data tree.
|
|
691
|
-
* @param blockNumber - The block number at which to get the data.
|
|
692
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
693
|
-
* @returns The sibling path.
|
|
694
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
695
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
696
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
700
|
-
* @param blockNumber - The block number at which to get the index.
|
|
701
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
702
|
-
* @returns The nullifier membership witness (if found).
|
|
703
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
704
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1194
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
1195
|
+
* @param epoch - The epoch at which to get the data.
|
|
1196
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1197
|
+
*/ async getL2ToL1Messages(epoch) {
|
|
1198
|
+
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1199
|
+
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1200
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1201
|
+
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1202
|
+
}
|
|
1203
|
+
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1204
|
+
const db = await this.getWorldState(referenceBlock);
|
|
705
1205
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
706
1206
|
nullifier.toBuffer()
|
|
707
1207
|
]);
|
|
@@ -715,35 +1215,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
715
1215
|
}
|
|
716
1216
|
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
717
1217
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
* @param blockNumber - The block number at which to get the index.
|
|
721
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
722
|
-
* @returns The low nullifier membership witness (if found).
|
|
723
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
724
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
725
|
-
* we are trying to prove non-inclusion for.
|
|
726
|
-
*
|
|
727
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
728
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
729
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
730
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
731
|
-
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
732
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1218
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1219
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
733
1220
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
734
1221
|
if (!findResult) {
|
|
735
1222
|
return undefined;
|
|
736
1223
|
}
|
|
737
1224
|
const { index, alreadyPresent } = findResult;
|
|
738
1225
|
if (alreadyPresent) {
|
|
739
|
-
|
|
1226
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
740
1227
|
}
|
|
741
1228
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
742
1229
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
743
1230
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
744
1231
|
}
|
|
745
|
-
async getPublicDataWitness(
|
|
746
|
-
const committedDb = await this
|
|
1232
|
+
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1233
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
747
1234
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
748
1235
|
if (!lowLeafResult) {
|
|
749
1236
|
return undefined;
|
|
@@ -753,18 +1240,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
753
1240
|
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
754
1241
|
}
|
|
755
1242
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
*
|
|
759
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
760
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
761
|
-
*
|
|
762
|
-
* @param contract - Address of the contract to query.
|
|
763
|
-
* @param slot - Slot to query.
|
|
764
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
765
|
-
* @returns Storage value at the given contract slot.
|
|
766
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
767
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1243
|
+
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1244
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
768
1245
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
769
1246
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
770
1247
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -773,18 +1250,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
773
1250
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
774
1251
|
return preimage.leaf.value;
|
|
775
1252
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1253
|
+
async getBlockHeader(block = 'latest') {
|
|
1254
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1255
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1256
|
+
if (block.equals(initialBlockHash)) {
|
|
1257
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1258
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1259
|
+
}
|
|
1260
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1261
|
+
} else {
|
|
1262
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1263
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1264
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
1265
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1266
|
+
}
|
|
1267
|
+
return this.blockSource.getBlockHeader(block);
|
|
1268
|
+
}
|
|
788
1269
|
}
|
|
789
1270
|
/**
|
|
790
1271
|
* Get a block header specified by its archive root.
|
|
@@ -793,6 +1274,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
793
1274
|
*/ async getBlockHeaderByArchive(archive) {
|
|
794
1275
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
795
1276
|
}
|
|
1277
|
+
getBlockData(number) {
|
|
1278
|
+
return this.blockSource.getBlockData(number);
|
|
1279
|
+
}
|
|
1280
|
+
getBlockDataByArchive(archive) {
|
|
1281
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1282
|
+
}
|
|
796
1283
|
/**
|
|
797
1284
|
* Simulates the public part of a transaction with the current state.
|
|
798
1285
|
* @param tx - The transaction to simulate.
|
|
@@ -805,17 +1292,20 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
805
1292
|
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
806
1293
|
}
|
|
807
1294
|
const txHash = tx.getTxHash();
|
|
808
|
-
const
|
|
1295
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1296
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
809
1297
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
810
1298
|
const coinbase = EthAddress.ZERO;
|
|
811
1299
|
const feeRecipient = AztecAddress.ZERO;
|
|
812
1300
|
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
813
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry);
|
|
1301
|
+
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
814
1302
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
815
1303
|
globalVariables: newGlobalVariables.toInspect(),
|
|
816
1304
|
txHash,
|
|
817
1305
|
blockNumber
|
|
818
1306
|
});
|
|
1307
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1308
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
819
1309
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
820
1310
|
try {
|
|
821
1311
|
const config = PublicSimulatorConfig.from({
|
|
@@ -823,12 +1313,14 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
823
1313
|
collectDebugLogs: true,
|
|
824
1314
|
collectHints: false,
|
|
825
1315
|
collectCallMetadata: true,
|
|
826
|
-
|
|
827
|
-
|
|
1316
|
+
collectStatistics: false,
|
|
1317
|
+
collectionLimits: CollectionLimitsConfig.from({
|
|
1318
|
+
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1319
|
+
})
|
|
828
1320
|
});
|
|
829
1321
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
830
1322
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
831
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([
|
|
1323
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
832
1324
|
tx
|
|
833
1325
|
]);
|
|
834
1326
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -839,7 +1331,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
839
1331
|
throw failedTxs[0].error;
|
|
840
1332
|
}
|
|
841
1333
|
const [processedTx] = processedTxs;
|
|
842
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed);
|
|
1334
|
+
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
843
1335
|
} finally{
|
|
844
1336
|
await merkleTreeFork.close();
|
|
845
1337
|
}
|
|
@@ -847,19 +1339,26 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
847
1339
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
848
1340
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
849
1341
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
850
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1342
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
851
1343
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
852
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
853
|
-
const
|
|
1344
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1345
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1346
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
854
1347
|
timestamp: nextSlotTimestamp,
|
|
855
1348
|
blockNumber,
|
|
856
1349
|
l1ChainId: this.l1ChainId,
|
|
857
1350
|
rollupVersion: this.version,
|
|
858
|
-
setupAllowList:
|
|
859
|
-
|
|
1351
|
+
setupAllowList: [
|
|
1352
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
1353
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
1354
|
+
],
|
|
1355
|
+
gasFees: await this.getCurrentMinFees(),
|
|
860
1356
|
skipFeeEnforcement,
|
|
861
|
-
txsPermitted: !this.config.disableTransactions
|
|
862
|
-
|
|
1357
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1358
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1359
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1360
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1361
|
+
}, this.log.getBindings());
|
|
863
1362
|
return await validator.validateTx(tx);
|
|
864
1363
|
}
|
|
865
1364
|
getConfig() {
|
|
@@ -919,7 +1418,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
919
1418
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
920
1419
|
}
|
|
921
1420
|
// And it has an L2 block hash
|
|
922
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
1421
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
923
1422
|
if (!l2BlockHash) {
|
|
924
1423
|
this.metrics.recordSnapshotError();
|
|
925
1424
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -946,7 +1445,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
946
1445
|
if (!('rollbackTo' in archiver)) {
|
|
947
1446
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
948
1447
|
}
|
|
949
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1448
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
950
1449
|
if (targetBlock < finalizedBlock) {
|
|
951
1450
|
if (force) {
|
|
952
1451
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -1001,42 +1500,148 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1001
1500
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1002
1501
|
}
|
|
1003
1502
|
}
|
|
1503
|
+
async reloadKeystore() {
|
|
1504
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1505
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1506
|
+
}
|
|
1507
|
+
if (!this.validatorClient) {
|
|
1508
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1509
|
+
}
|
|
1510
|
+
this.log.info('Reloading keystore from disk');
|
|
1511
|
+
// Re-read and validate keystore files
|
|
1512
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1513
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1514
|
+
await newManager.validateSigners();
|
|
1515
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1516
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1517
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1518
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1519
|
+
// would silently fail on every proposer slot.
|
|
1520
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1521
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1522
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1523
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1524
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1525
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1526
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1527
|
+
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 ` + `[${[
|
|
1528
|
+
...availablePublishers
|
|
1529
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
// Build adapters for old and new keystores to compute diff
|
|
1534
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1535
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1536
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1537
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1538
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1539
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1540
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1541
|
+
if (added.length > 0) {
|
|
1542
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1543
|
+
}
|
|
1544
|
+
if (removed.length > 0) {
|
|
1545
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1546
|
+
}
|
|
1547
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1548
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1549
|
+
}
|
|
1550
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1551
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1552
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1553
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1554
|
+
if (this.sequencer) {
|
|
1555
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1556
|
+
}
|
|
1557
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1558
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1559
|
+
const slashValidatorsNever = unique([
|
|
1560
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1561
|
+
...newAddresses
|
|
1562
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1563
|
+
this.slasherClient.updateConfig({
|
|
1564
|
+
slashValidatorsNever
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
this.keyStoreManager = newManager;
|
|
1568
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1569
|
+
}
|
|
1570
|
+
#getInitialHeaderHash() {
|
|
1571
|
+
if (!this.initialHeaderHashPromise) {
|
|
1572
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1573
|
+
}
|
|
1574
|
+
return this.initialHeaderHashPromise;
|
|
1575
|
+
}
|
|
1004
1576
|
/**
|
|
1005
1577
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1006
|
-
* @param
|
|
1578
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1007
1579
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1008
|
-
*/ async
|
|
1009
|
-
|
|
1010
|
-
throw new Error('Invalid block number to get world state for: ' + blockNumber);
|
|
1011
|
-
}
|
|
1012
|
-
let blockSyncedTo = 0;
|
|
1580
|
+
*/ async getWorldState(block) {
|
|
1581
|
+
let blockSyncedTo = BlockNumber.ZERO;
|
|
1013
1582
|
try {
|
|
1014
1583
|
// Attempt to sync the world state if necessary
|
|
1015
1584
|
blockSyncedTo = await this.#syncWorldState();
|
|
1016
1585
|
} catch (err) {
|
|
1017
1586
|
this.log.error(`Error getting world state: ${err}`);
|
|
1018
1587
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
this.log.debug(`Using committed db for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1588
|
+
if (block === 'latest') {
|
|
1589
|
+
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1022
1590
|
return this.worldStateSynchronizer.getCommitted();
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1591
|
+
}
|
|
1592
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1593
|
+
let blockNumber;
|
|
1594
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1595
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1596
|
+
if (block.equals(initialBlockHash)) {
|
|
1597
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1598
|
+
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1599
|
+
}
|
|
1600
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1601
|
+
if (!header) {
|
|
1602
|
+
throw new Error(`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1603
|
+
}
|
|
1604
|
+
blockNumber = header.getBlockNumber();
|
|
1026
1605
|
} else {
|
|
1027
|
-
|
|
1606
|
+
blockNumber = block;
|
|
1607
|
+
}
|
|
1608
|
+
// Check it's within world state sync range
|
|
1609
|
+
if (blockNumber > blockSyncedTo) {
|
|
1610
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1611
|
+
}
|
|
1612
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1613
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1614
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1615
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1616
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1617
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1618
|
+
throw new Error(`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
return snapshot;
|
|
1622
|
+
}
|
|
1623
|
+
/** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
|
|
1624
|
+
if (block === 'latest') {
|
|
1625
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1626
|
+
}
|
|
1627
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1628
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1629
|
+
if (block.equals(initialBlockHash)) {
|
|
1630
|
+
return BlockNumber.ZERO;
|
|
1631
|
+
}
|
|
1632
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1633
|
+
if (!header) {
|
|
1634
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1635
|
+
}
|
|
1636
|
+
return header.getBlockNumber();
|
|
1028
1637
|
}
|
|
1638
|
+
return block;
|
|
1029
1639
|
}
|
|
1030
1640
|
/**
|
|
1031
1641
|
* Ensure we fully sync the world state
|
|
1032
1642
|
* @returns A promise that fulfils once the world state is synced
|
|
1033
1643
|
*/ async #syncWorldState() {
|
|
1034
1644
|
const blockSourceHeight = await this.blockSource.getBlockNumber();
|
|
1035
|
-
return this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1645
|
+
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1036
1646
|
}
|
|
1037
1647
|
}
|
|
1038
|
-
_ts_decorate([
|
|
1039
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1040
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1041
|
-
}))
|
|
1042
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|