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