@aztec/aztec-node 0.0.0-test.0 → 0.0.1-commit.001888fc
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 +22 -11
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +90 -15
- package/dest/aztec-node/node_metrics.d.ts +5 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +20 -6
- package/dest/aztec-node/server.d.ts +132 -154
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +1292 -371
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +4 -2
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/sentinel/config.d.ts +8 -0
- package/dest/sentinel/config.d.ts.map +1 -0
- package/dest/sentinel/config.js +29 -0
- package/dest/sentinel/factory.d.ts +9 -0
- package/dest/sentinel/factory.d.ts.map +1 -0
- package/dest/sentinel/factory.js +17 -0
- package/dest/sentinel/index.d.ts +3 -0
- package/dest/sentinel/index.d.ts.map +1 -0
- package/dest/sentinel/index.js +1 -0
- package/dest/sentinel/sentinel.d.ts +93 -0
- package/dest/sentinel/sentinel.d.ts.map +1 -0
- package/dest/sentinel/sentinel.js +429 -0
- package/dest/sentinel/store.d.ts +35 -0
- package/dest/sentinel/store.d.ts.map +1 -0
- package/dest/sentinel/store.js +174 -0
- package/dest/test/index.d.ts +31 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/package.json +47 -35
- package/src/aztec-node/config.ts +149 -26
- package/src/aztec-node/node_metrics.ts +23 -6
- package/src/aztec-node/server.ts +1162 -467
- package/src/bin/index.ts +4 -2
- package/src/index.ts +0 -1
- package/src/sentinel/config.ts +37 -0
- package/src/sentinel/factory.ts +31 -0
- package/src/sentinel/index.ts +8 -0
- package/src/sentinel/sentinel.ts +543 -0
- package/src/sentinel/store.ts +185 -0
- package/src/test/index.ts +32 -0
- package/dest/aztec-node/http_rpc_server.d.ts +0 -8
- package/dest/aztec-node/http_rpc_server.d.ts.map +0 -1
- package/dest/aztec-node/http_rpc_server.js +0 -9
- package/src/aztec-node/http_rpc_server.ts +0 -11
|
@@ -1,38 +1,425 @@
|
|
|
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
|
+
};
|
|
6
369
|
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _dec, _initProto;
|
|
7
374
|
import { createArchiver } from '@aztec/archiver';
|
|
8
|
-
import { BBCircuitVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
375
|
+
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
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 { createEthereumChain } from '@aztec/ethereum';
|
|
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 {
|
|
386
|
+
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
16
387
|
import { createLogger } from '@aztec/foundation/log';
|
|
388
|
+
import { count } from '@aztec/foundation/string';
|
|
17
389
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
390
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
391
|
+
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
392
|
+
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
393
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
394
|
+
import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
22
395
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
23
|
-
import {
|
|
396
|
+
import { createProverNode } from '@aztec/prover-node';
|
|
397
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
398
|
+
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
24
399
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
400
|
+
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
401
|
+
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
25
402
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
|
-
import {
|
|
403
|
+
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
404
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
405
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
406
|
+
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
27
407
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
28
|
-
import {
|
|
408
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
409
|
+
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
29
410
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
30
411
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
412
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
31
413
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
32
|
-
import { createValidatorClient } from '@aztec/validator-client';
|
|
414
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
33
415
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
34
|
-
import {
|
|
416
|
+
import { createPublicClient } from 'viem';
|
|
417
|
+
import { createSentinel } from '../sentinel/factory.js';
|
|
418
|
+
import { createKeyStoreForValidator } from './config.js';
|
|
35
419
|
import { NodeMetrics } from './node_metrics.js';
|
|
420
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
421
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
422
|
+
}));
|
|
36
423
|
/**
|
|
37
424
|
* The aztec node.
|
|
38
425
|
*/ export class AztecNodeService {
|
|
@@ -42,39 +429,75 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
42
429
|
logsSource;
|
|
43
430
|
contractDataSource;
|
|
44
431
|
l1ToL2MessageSource;
|
|
45
|
-
nullifierSource;
|
|
46
432
|
worldStateSynchronizer;
|
|
47
433
|
sequencer;
|
|
434
|
+
proverNode;
|
|
435
|
+
slasherClient;
|
|
436
|
+
validatorsSentinel;
|
|
437
|
+
epochPruneWatcher;
|
|
48
438
|
l1ChainId;
|
|
49
439
|
version;
|
|
50
440
|
globalVariableBuilder;
|
|
441
|
+
epochCache;
|
|
442
|
+
packageVersion;
|
|
51
443
|
proofVerifier;
|
|
52
444
|
telemetry;
|
|
53
445
|
log;
|
|
54
|
-
|
|
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
|
+
}
|
|
55
459
|
metrics;
|
|
460
|
+
initialHeaderHashPromise;
|
|
461
|
+
// Prevent two snapshot operations to happen simultaneously
|
|
462
|
+
isUploadingSnapshot;
|
|
56
463
|
tracer;
|
|
57
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource,
|
|
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()){
|
|
58
465
|
this.config = config;
|
|
59
466
|
this.p2pClient = p2pClient;
|
|
60
467
|
this.blockSource = blockSource;
|
|
61
468
|
this.logsSource = logsSource;
|
|
62
469
|
this.contractDataSource = contractDataSource;
|
|
63
470
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
64
|
-
this.nullifierSource = nullifierSource;
|
|
65
471
|
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
66
472
|
this.sequencer = sequencer;
|
|
473
|
+
this.proverNode = proverNode;
|
|
474
|
+
this.slasherClient = slasherClient;
|
|
475
|
+
this.validatorsSentinel = validatorsSentinel;
|
|
476
|
+
this.epochPruneWatcher = epochPruneWatcher;
|
|
67
477
|
this.l1ChainId = l1ChainId;
|
|
68
478
|
this.version = version;
|
|
69
479
|
this.globalVariableBuilder = globalVariableBuilder;
|
|
480
|
+
this.epochCache = epochCache;
|
|
481
|
+
this.packageVersion = packageVersion;
|
|
70
482
|
this.proofVerifier = proofVerifier;
|
|
71
483
|
this.telemetry = telemetry;
|
|
72
484
|
this.log = log;
|
|
73
|
-
this.
|
|
485
|
+
this.blobClient = blobClient;
|
|
486
|
+
this.validatorClient = validatorClient;
|
|
487
|
+
this.keyStoreManager = keyStoreManager;
|
|
488
|
+
this.debugLogStore = debugLogStore;
|
|
489
|
+
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
490
|
+
this.isUploadingSnapshot = false;
|
|
74
491
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
75
492
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
76
493
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
77
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
|
+
}
|
|
78
501
|
}
|
|
79
502
|
async getWorldStateSyncStatus() {
|
|
80
503
|
const status = await this.worldStateSynchronizer.status();
|
|
@@ -87,59 +510,277 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
87
510
|
* initializes the Aztec Node, wait for component to sync.
|
|
88
511
|
* @param config - The configuration to be used by the aztec node.
|
|
89
512
|
* @returns - A fully synced Aztec Node for use in development/testing.
|
|
90
|
-
*/ static async createAndSync(
|
|
91
|
-
const
|
|
513
|
+
*/ static async createAndSync(inputConfig, deps = {}, options = {}) {
|
|
514
|
+
const config = {
|
|
515
|
+
...inputConfig
|
|
516
|
+
}; // Copy the config so we dont mutate the input object
|
|
92
517
|
const log = deps.logger ?? createLogger('node');
|
|
518
|
+
const packageVersion = getPackageVersion() ?? '';
|
|
519
|
+
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
93
520
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
94
|
-
const blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config);
|
|
95
521
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
96
|
-
//
|
|
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.
|
|
524
|
+
let keyStoreManager;
|
|
525
|
+
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
526
|
+
if (keyStoreProvided) {
|
|
527
|
+
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
528
|
+
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
529
|
+
} else {
|
|
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));
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
await keyStoreManager?.validateSigners();
|
|
546
|
+
// If we are a validator, verify our configuration before doing too much more.
|
|
547
|
+
if (!config.disableValidator) {
|
|
548
|
+
if (keyStoreManager === undefined) {
|
|
549
|
+
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
550
|
+
}
|
|
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");
|
|
553
|
+
}
|
|
554
|
+
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
555
|
+
}
|
|
556
|
+
// validate that the actual chain id matches that specified in configuration
|
|
97
557
|
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
98
558
|
throw new Error(`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`);
|
|
99
559
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
560
|
+
const publicClient = createPublicClient({
|
|
561
|
+
chain: ethereumChain.chainInfo,
|
|
562
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
563
|
+
timeout: config.l1HttpTimeoutMS
|
|
564
|
+
}),
|
|
565
|
+
pollingInterval: config.viemPollingIntervalMS
|
|
566
|
+
});
|
|
567
|
+
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
568
|
+
// Overwrite the passed in vars.
|
|
569
|
+
config.l1Contracts = {
|
|
570
|
+
...config.l1Contracts,
|
|
571
|
+
...l1ContractsAddresses
|
|
572
|
+
};
|
|
573
|
+
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
574
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
575
|
+
rollupContract.getL1GenesisTime(),
|
|
576
|
+
rollupContract.getSlotDuration(),
|
|
577
|
+
rollupContract.getVersion(),
|
|
578
|
+
rollupContract.getManaLimit().then(Number)
|
|
579
|
+
]);
|
|
580
|
+
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
581
|
+
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
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}).`);
|
|
108
583
|
}
|
|
584
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
585
|
+
// attempt snapshot sync if possible
|
|
586
|
+
await trySnapshotSync(config, log);
|
|
109
587
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
110
588
|
dateProvider
|
|
111
589
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// start both and wait for them to sync from the block source
|
|
116
|
-
await Promise.all([
|
|
117
|
-
p2pClient.start(),
|
|
118
|
-
worldStateSynchronizer.start(),
|
|
119
|
-
slasherClient.start()
|
|
120
|
-
]);
|
|
121
|
-
log.verbose(`All Aztec Node subsystems synced`);
|
|
122
|
-
const validatorClient = createValidatorClient(config, {
|
|
123
|
-
p2pClient,
|
|
590
|
+
const archiver = await createArchiver(config, {
|
|
591
|
+
blobClient,
|
|
592
|
+
epochCache,
|
|
124
593
|
telemetry,
|
|
125
|
-
dateProvider
|
|
126
|
-
|
|
594
|
+
dateProvider
|
|
595
|
+
}, {
|
|
596
|
+
blockUntilSync: !config.skipArchiverInitialSync
|
|
127
597
|
});
|
|
128
|
-
// now create the
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
598
|
+
// now create the merkle trees and the world state synchronizer
|
|
599
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
600
|
+
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
601
|
+
let debugLogStore;
|
|
602
|
+
if (!config.realProofs) {
|
|
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();
|
|
608
|
+
}
|
|
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
|
+
}
|
|
614
|
+
// create the tx pool and the p2p client, which will need the l2 block source
|
|
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({
|
|
621
|
+
...config,
|
|
622
|
+
l1GenesisTime,
|
|
623
|
+
slotDuration: Number(slotDuration),
|
|
624
|
+
rollupManaLimit,
|
|
625
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
626
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
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
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
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' : ''));
|
|
658
|
+
createBlockProposalHandler(config, {
|
|
659
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
660
|
+
worldState: worldStateSynchronizer,
|
|
661
|
+
epochCache,
|
|
662
|
+
blockSource: archiver,
|
|
663
|
+
l1ToL2MessageSource: archiver,
|
|
664
|
+
p2pClient,
|
|
665
|
+
dateProvider,
|
|
666
|
+
telemetry
|
|
667
|
+
}).register(p2pClient, reexecute);
|
|
668
|
+
}
|
|
669
|
+
// Start world state and wait for it to sync to the archiver.
|
|
670
|
+
await worldStateSynchronizer.start();
|
|
671
|
+
// Start p2p. Note that it depends on world state to be running.
|
|
672
|
+
await p2pClient.start();
|
|
673
|
+
let validatorsSentinel;
|
|
674
|
+
let epochPruneWatcher;
|
|
675
|
+
let attestationsBlockWatcher;
|
|
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
|
+
}
|
|
690
|
+
}
|
|
691
|
+
// Start p2p-related services once the archiver has completed sync
|
|
692
|
+
void archiver.waitForInitialSync().then(async ()=>{
|
|
693
|
+
await p2pClient.start();
|
|
694
|
+
await validatorsSentinel?.start();
|
|
695
|
+
await epochPruneWatcher?.start();
|
|
696
|
+
await attestationsBlockWatcher?.start();
|
|
697
|
+
log.info(`All p2p services started`);
|
|
698
|
+
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
699
|
+
// Validator enabled, create/start relevant service
|
|
700
|
+
let sequencer;
|
|
701
|
+
let slasherClient;
|
|
702
|
+
if (!config.disableValidator && validatorClient) {
|
|
703
|
+
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
704
|
+
// as they are executed when the node is selected as proposer.
|
|
705
|
+
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
706
|
+
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
707
|
+
await slasherClient.start();
|
|
708
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
709
|
+
...config,
|
|
710
|
+
scope: 'sequencer'
|
|
711
|
+
}, {
|
|
712
|
+
telemetry,
|
|
713
|
+
logger: log.createChild('l1-tx-utils'),
|
|
714
|
+
dateProvider,
|
|
715
|
+
kzg: Blob.getViemKzgInstance()
|
|
716
|
+
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
717
|
+
...config,
|
|
718
|
+
scope: 'sequencer'
|
|
719
|
+
}, {
|
|
720
|
+
telemetry,
|
|
721
|
+
logger: log.createChild('l1-tx-utils'),
|
|
722
|
+
dateProvider,
|
|
723
|
+
kzg: Blob.getViemKzgInstance()
|
|
724
|
+
});
|
|
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);
|
|
732
|
+
sequencer = await SequencerClient.new(config, {
|
|
733
|
+
...deps,
|
|
734
|
+
epochCache,
|
|
735
|
+
l1TxUtils,
|
|
736
|
+
validatorClient,
|
|
737
|
+
p2pClient,
|
|
738
|
+
worldStateSynchronizer,
|
|
739
|
+
slasherClient,
|
|
740
|
+
checkpointsBuilder,
|
|
741
|
+
l2BlockSource: archiver,
|
|
742
|
+
l1ToL2MessageSource: archiver,
|
|
743
|
+
telemetry,
|
|
744
|
+
dateProvider,
|
|
745
|
+
blobClient,
|
|
746
|
+
nodeKeyStore: keyStoreManager
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
if (!options.dontStartSequencer && sequencer) {
|
|
750
|
+
await sequencer.start();
|
|
751
|
+
log.verbose(`Sequencer started`);
|
|
752
|
+
} else if (sequencer) {
|
|
753
|
+
log.warn(`Sequencer created but not started`);
|
|
754
|
+
}
|
|
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)
|
|
141
781
|
});
|
|
142
|
-
|
|
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;
|
|
143
784
|
}
|
|
144
785
|
/**
|
|
145
786
|
* Returns the sequencer client instance.
|
|
@@ -147,6 +788,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
147
788
|
*/ getSequencer() {
|
|
148
789
|
return this.sequencer;
|
|
149
790
|
}
|
|
791
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
792
|
+
return this.proverNode;
|
|
793
|
+
}
|
|
150
794
|
getBlockSource() {
|
|
151
795
|
return this.blockSource;
|
|
152
796
|
}
|
|
@@ -165,6 +809,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
165
809
|
getEncodedEnr() {
|
|
166
810
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
167
811
|
}
|
|
812
|
+
async getAllowedPublicSetup() {
|
|
813
|
+
return [
|
|
814
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
815
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
816
|
+
];
|
|
817
|
+
}
|
|
168
818
|
/**
|
|
169
819
|
* Method to determine if the node is ready to accept transactions.
|
|
170
820
|
* @returns - Flag indicating the readiness for tx submission.
|
|
@@ -172,7 +822,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
172
822
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
173
823
|
}
|
|
174
824
|
async getNodeInfo() {
|
|
175
|
-
const [nodeVersion,
|
|
825
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
176
826
|
this.getNodeVersion(),
|
|
177
827
|
this.getVersion(),
|
|
178
828
|
this.getChainId(),
|
|
@@ -183,19 +833,49 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
183
833
|
const nodeInfo = {
|
|
184
834
|
nodeVersion,
|
|
185
835
|
l1ChainId: chainId,
|
|
186
|
-
|
|
836
|
+
rollupVersion,
|
|
187
837
|
enr,
|
|
188
838
|
l1ContractAddresses: contractAddresses,
|
|
189
|
-
protocolContractAddresses: protocolContractAddresses
|
|
839
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
840
|
+
realProofs: !!this.config.realProofs
|
|
190
841
|
};
|
|
191
842
|
return nodeInfo;
|
|
192
843
|
}
|
|
193
844
|
/**
|
|
194
|
-
* Get a block specified by its number.
|
|
195
|
-
* @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').
|
|
196
847
|
* @returns The requested block.
|
|
197
|
-
*/ async getBlock(
|
|
198
|
-
|
|
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);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Get a block specified by its hash.
|
|
860
|
+
* @param blockHash - The block hash being requested.
|
|
861
|
+
* @returns The requested block.
|
|
862
|
+
*/ async getBlockByHash(blockHash) {
|
|
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);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Get a block specified by its archive root.
|
|
875
|
+
* @param archive - The archive root being requested.
|
|
876
|
+
* @returns The requested block.
|
|
877
|
+
*/ async getBlockByArchive(archive) {
|
|
878
|
+
return await this.blockSource.getL2BlockByArchive(archive);
|
|
199
879
|
}
|
|
200
880
|
/**
|
|
201
881
|
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
@@ -203,16 +883,34 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
203
883
|
* @param limit - The maximum number of blocks to obtain.
|
|
204
884
|
* @returns The blocks requested.
|
|
205
885
|
*/ async getBlocks(from, limit) {
|
|
206
|
-
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) ?? [];
|
|
890
|
+
}
|
|
891
|
+
async getCheckpointedBlocks(from, limit) {
|
|
892
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
893
|
+
}
|
|
894
|
+
getCheckpointsDataForEpoch(epochNumber) {
|
|
895
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
207
896
|
}
|
|
208
897
|
/**
|
|
209
|
-
* Method to fetch the current
|
|
210
|
-
* @returns The current
|
|
211
|
-
*/ async
|
|
212
|
-
return await this.globalVariableBuilder.
|
|
898
|
+
* Method to fetch the current min L2 fees.
|
|
899
|
+
* @returns The current min L2 fees.
|
|
900
|
+
*/ async getCurrentMinFees() {
|
|
901
|
+
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
902
|
+
}
|
|
903
|
+
async getMaxPriorityFees() {
|
|
904
|
+
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
905
|
+
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
906
|
+
}
|
|
907
|
+
return GasFees.from({
|
|
908
|
+
feePerDaGas: 0n,
|
|
909
|
+
feePerL2Gas: 0n
|
|
910
|
+
});
|
|
213
911
|
}
|
|
214
912
|
/**
|
|
215
|
-
* Method to fetch the
|
|
913
|
+
* Method to fetch the latest block number synchronized by the node.
|
|
216
914
|
* @returns The block number.
|
|
217
915
|
*/ async getBlockNumber() {
|
|
218
916
|
return await this.blockSource.getBlockNumber();
|
|
@@ -220,6 +918,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
220
918
|
async getProvenBlockNumber() {
|
|
221
919
|
return await this.blockSource.getProvenBlockNumber();
|
|
222
920
|
}
|
|
921
|
+
async getCheckpointedBlockNumber() {
|
|
922
|
+
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
923
|
+
}
|
|
924
|
+
getCheckpointNumber() {
|
|
925
|
+
return this.blockSource.getCheckpointNumber();
|
|
926
|
+
}
|
|
223
927
|
/**
|
|
224
928
|
* Method to fetch the version of the package.
|
|
225
929
|
* @returns The node package version
|
|
@@ -238,44 +942,43 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
238
942
|
*/ getChainId() {
|
|
239
943
|
return Promise.resolve(this.l1ChainId);
|
|
240
944
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
// TODO(#10007): Remove this check. This is needed only because we're manually registering
|
|
244
|
-
// some contracts in the archiver so they are available to all nodes (see `registerCommonContracts`
|
|
245
|
-
// in `archiver/src/factory.ts`), but we still want clients to send the registration tx in order
|
|
246
|
-
// to emit the corresponding nullifier, which is now being checked. Note that this method
|
|
247
|
-
// is only called by the PXE to check if a contract is publicly registered.
|
|
248
|
-
if (klazz) {
|
|
249
|
-
const classNullifier = await siloNullifier(AztecAddress.fromNumber(REGISTERER_CONTRACT_ADDRESS), id);
|
|
250
|
-
const worldState = await this.#getWorldState('latest');
|
|
251
|
-
const [index] = await worldState.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
252
|
-
classNullifier.toBuffer()
|
|
253
|
-
]);
|
|
254
|
-
this.log.debug(`Registration nullifier ${classNullifier} for contract class ${id} found at index ${index}`);
|
|
255
|
-
if (index === undefined) {
|
|
256
|
-
return undefined;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return klazz;
|
|
945
|
+
getContractClass(id) {
|
|
946
|
+
return this.contractDataSource.getContractClass(id);
|
|
260
947
|
}
|
|
261
948
|
getContract(address) {
|
|
262
949
|
return this.contractDataSource.getContract(address);
|
|
263
950
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
951
|
+
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
952
|
+
let upToBlockNumber;
|
|
953
|
+
if (referenceBlock) {
|
|
954
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
955
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
956
|
+
upToBlockNumber = BlockNumber(0);
|
|
957
|
+
} else {
|
|
958
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
959
|
+
if (!header) {
|
|
960
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
961
|
+
}
|
|
962
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
271
966
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
967
|
+
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
968
|
+
let upToBlockNumber;
|
|
969
|
+
if (referenceBlock) {
|
|
970
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
971
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
972
|
+
upToBlockNumber = BlockNumber(0);
|
|
973
|
+
} else {
|
|
974
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
975
|
+
if (!header) {
|
|
976
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
977
|
+
}
|
|
978
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
279
982
|
}
|
|
280
983
|
/**
|
|
281
984
|
* Gets public logs based on the provided filter.
|
|
@@ -295,38 +998,48 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
295
998
|
* Method to submit a transaction to the p2p pool.
|
|
296
999
|
* @param tx - The transaction to be submitted.
|
|
297
1000
|
*/ async sendTx(tx) {
|
|
1001
|
+
await this.#sendTx(tx);
|
|
1002
|
+
}
|
|
1003
|
+
async #sendTx(tx) {
|
|
298
1004
|
const timer = new Timer();
|
|
299
|
-
const txHash =
|
|
1005
|
+
const txHash = tx.getTxHash().toString();
|
|
300
1006
|
const valid = await this.isValidTx(tx);
|
|
301
1007
|
if (valid.result !== 'valid') {
|
|
302
1008
|
const reason = valid.reason.join(', ');
|
|
303
1009
|
this.metrics.receivedTx(timer.ms(), false);
|
|
304
|
-
this.log.warn(`
|
|
1010
|
+
this.log.warn(`Received invalid tx ${txHash}: ${reason}`, {
|
|
305
1011
|
txHash
|
|
306
1012
|
});
|
|
307
|
-
|
|
308
|
-
// throw new Error(`Invalid tx: ${reason}`);
|
|
309
|
-
return;
|
|
1013
|
+
throw new Error(`Invalid tx: ${reason}`);
|
|
310
1014
|
}
|
|
311
1015
|
await this.p2pClient.sendTx(tx);
|
|
312
|
-
|
|
313
|
-
this.
|
|
1016
|
+
const duration = timer.ms();
|
|
1017
|
+
this.metrics.receivedTx(duration, true);
|
|
1018
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
314
1019
|
txHash
|
|
315
1020
|
});
|
|
316
1021
|
}
|
|
317
1022
|
async getTxReceipt(txHash) {
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
324
|
-
}
|
|
1023
|
+
// Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
|
|
1024
|
+
// as a fallback if we don't find a settled receipt in the archiver.
|
|
1025
|
+
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
1026
|
+
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
1027
|
+
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
325
1028
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1029
|
+
let receipt;
|
|
326
1030
|
if (settledTxReceipt) {
|
|
327
|
-
|
|
1031
|
+
receipt = settledTxReceipt;
|
|
1032
|
+
} else if (isKnownToPool) {
|
|
1033
|
+
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1034
|
+
// This handles race conditions between archiver and p2p, where the archiver
|
|
1035
|
+
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1036
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1037
|
+
} else {
|
|
1038
|
+
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1039
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
328
1040
|
}
|
|
329
|
-
|
|
1041
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1042
|
+
return receipt;
|
|
330
1043
|
}
|
|
331
1044
|
getTxEffect(txHash) {
|
|
332
1045
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -334,238 +1047,189 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
334
1047
|
/**
|
|
335
1048
|
* Method to stop the aztec node.
|
|
336
1049
|
*/ async stop() {
|
|
337
|
-
this.log.info(`Stopping`);
|
|
338
|
-
await this.
|
|
339
|
-
await this.
|
|
340
|
-
await this.
|
|
1050
|
+
this.log.info(`Stopping Aztec Node`);
|
|
1051
|
+
await tryStop(this.validatorsSentinel);
|
|
1052
|
+
await tryStop(this.epochPruneWatcher);
|
|
1053
|
+
await tryStop(this.slasherClient);
|
|
1054
|
+
await tryStop(this.proofVerifier);
|
|
1055
|
+
await tryStop(this.sequencer);
|
|
1056
|
+
await tryStop(this.proverNode);
|
|
1057
|
+
await tryStop(this.p2pClient);
|
|
1058
|
+
await tryStop(this.worldStateSynchronizer);
|
|
341
1059
|
await tryStop(this.blockSource);
|
|
342
|
-
await this.
|
|
343
|
-
this.
|
|
1060
|
+
await tryStop(this.blobClient);
|
|
1061
|
+
await tryStop(this.telemetry);
|
|
1062
|
+
this.log.info(`Stopped Aztec Node`);
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Returns the blob client used by this node.
|
|
1066
|
+
* @internal - Exposed for testing purposes only.
|
|
1067
|
+
*/ getBlobClient() {
|
|
1068
|
+
return this.blobClient;
|
|
344
1069
|
}
|
|
345
1070
|
/**
|
|
346
1071
|
* Method to retrieve pending txs.
|
|
1072
|
+
* @param limit - The number of items to returns
|
|
1073
|
+
* @param after - The last known pending tx. Used for pagination
|
|
347
1074
|
* @returns - The pending txs.
|
|
348
|
-
*/ getPendingTxs() {
|
|
349
|
-
return this.p2pClient.getPendingTxs();
|
|
1075
|
+
*/ getPendingTxs(limit, after) {
|
|
1076
|
+
return this.p2pClient.getPendingTxs(limit, after);
|
|
350
1077
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return pendingTxs.length;
|
|
1078
|
+
getPendingTxCount() {
|
|
1079
|
+
return this.p2pClient.getPendingTxCount();
|
|
354
1080
|
}
|
|
355
1081
|
/**
|
|
356
|
-
* Method to retrieve a single tx from the mempool or
|
|
1082
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain.
|
|
357
1083
|
* @param txHash - The transaction hash to return.
|
|
358
1084
|
* @returns - The tx if it exists.
|
|
359
1085
|
*/ getTxByHash(txHash) {
|
|
360
1086
|
return Promise.resolve(this.p2pClient.getTxByHashFromPool(txHash));
|
|
361
1087
|
}
|
|
362
1088
|
/**
|
|
363
|
-
* Method to retrieve txs from the mempool or
|
|
1089
|
+
* Method to retrieve txs from the mempool or unfinalized chain.
|
|
364
1090
|
* @param txHash - The transaction hash to return.
|
|
365
1091
|
* @returns - The txs if it exists.
|
|
366
1092
|
*/ async getTxsByHash(txHashes) {
|
|
367
1093
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
368
1094
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
1095
|
+
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1096
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1097
|
+
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1098
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1099
|
+
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1100
|
+
// Now we find the block numbers for the defined indices
|
|
1101
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1102
|
+
// Build a map from leaf index to block number
|
|
1103
|
+
const indexToBlockNumber = new Map();
|
|
1104
|
+
for(let i = 0; i < definedIndices.length; i++){
|
|
1105
|
+
const blockNumber = blockNumbers[i];
|
|
1106
|
+
if (blockNumber === undefined) {
|
|
1107
|
+
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1108
|
+
}
|
|
1109
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1110
|
+
}
|
|
1111
|
+
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1112
|
+
const uniqueBlockNumbers = [
|
|
1113
|
+
...new Set(indexToBlockNumber.values())
|
|
1114
|
+
];
|
|
1115
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1116
|
+
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1117
|
+
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1118
|
+
}));
|
|
1119
|
+
// Build a map from block number to block hash
|
|
1120
|
+
const blockNumberToHash = new Map();
|
|
1121
|
+
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1122
|
+
const blockHash = blockHashes[i];
|
|
1123
|
+
if (blockHash === undefined) {
|
|
1124
|
+
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1125
|
+
}
|
|
1126
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
392
1127
|
}
|
|
393
|
-
return
|
|
1128
|
+
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1129
|
+
return maybeIndices.map((index)=>{
|
|
1130
|
+
if (index === undefined) {
|
|
1131
|
+
return undefined;
|
|
1132
|
+
}
|
|
1133
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1134
|
+
if (blockNumber === undefined) {
|
|
1135
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1136
|
+
}
|
|
1137
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1138
|
+
if (blockHash === undefined) {
|
|
1139
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
l2BlockNumber: blockNumber,
|
|
1143
|
+
l2BlockHash: new BlockHash(blockHash),
|
|
1144
|
+
data: index
|
|
1145
|
+
};
|
|
1146
|
+
});
|
|
394
1147
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
|
|
1148
|
+
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1149
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1150
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1151
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1152
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1153
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1154
|
+
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1155
|
+
blockHash
|
|
1156
|
+
]);
|
|
1157
|
+
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
403
1158
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
411
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
1159
|
+
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1160
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1161
|
+
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1162
|
+
noteHash
|
|
1163
|
+
]);
|
|
1164
|
+
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
412
1165
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const index = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
420
|
-
if (index === undefined) {
|
|
1166
|
+
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1167
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1168
|
+
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1169
|
+
l1ToL2Message
|
|
1170
|
+
]);
|
|
1171
|
+
if (!witness) {
|
|
421
1172
|
return undefined;
|
|
422
1173
|
}
|
|
423
|
-
|
|
424
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, index);
|
|
1174
|
+
// REFACTOR: Return a MembershipWitness object
|
|
425
1175
|
return [
|
|
426
|
-
index,
|
|
427
|
-
|
|
1176
|
+
witness.index,
|
|
1177
|
+
witness.path
|
|
428
1178
|
];
|
|
429
1179
|
}
|
|
1180
|
+
async getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
1181
|
+
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1182
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1183
|
+
}
|
|
430
1184
|
/**
|
|
431
1185
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
432
1186
|
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
433
1187
|
* @returns Whether the message is synced and ready to be included in a block.
|
|
434
1188
|
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Returns the index of a l2ToL1Message in a ephemeral l2 to l1 data tree as well as its sibling path.
|
|
439
|
-
* @remarks This tree is considered ephemeral because it is created on-demand by: taking all the l2ToL1 messages
|
|
440
|
-
* in a single block, and then using them to make a variable depth append-only tree with these messages as leaves.
|
|
441
|
-
* The tree is discarded immediately after calculating what we need from it.
|
|
442
|
-
* TODO: Handle the case where two messages in the same tx have the same hash.
|
|
443
|
-
* @param blockNumber - The block number at which to get the data.
|
|
444
|
-
* @param l2ToL1Message - The l2ToL1Message get the index / sibling path for.
|
|
445
|
-
* @returns A tuple of the index and the sibling path of the L2ToL1Message.
|
|
446
|
-
*/ async getL2ToL1MessageMembershipWitness(blockNumber, l2ToL1Message) {
|
|
447
|
-
const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber);
|
|
448
|
-
if (block === undefined) {
|
|
449
|
-
throw new Error('Block is not defined');
|
|
450
|
-
}
|
|
451
|
-
const l2ToL1Messages = block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
452
|
-
// Find index of message
|
|
453
|
-
let indexOfMsgInSubtree = -1;
|
|
454
|
-
const indexOfMsgTx = l2ToL1Messages.findIndex((msgs)=>{
|
|
455
|
-
const idx = msgs.findIndex((msg)=>msg.equals(l2ToL1Message));
|
|
456
|
-
indexOfMsgInSubtree = Math.max(indexOfMsgInSubtree, idx);
|
|
457
|
-
return idx !== -1;
|
|
458
|
-
});
|
|
459
|
-
if (indexOfMsgTx === -1) {
|
|
460
|
-
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
461
|
-
}
|
|
462
|
-
const tempStores = [];
|
|
463
|
-
// Construct message subtrees
|
|
464
|
-
const l2toL1Subtrees = await Promise.all(l2ToL1Messages.map(async (msgs, i)=>{
|
|
465
|
-
const store = openTmpStore(true);
|
|
466
|
-
tempStores.push(store);
|
|
467
|
-
const treeHeight = msgs.length <= 1 ? 1 : Math.ceil(Math.log2(msgs.length));
|
|
468
|
-
const tree = new StandardTree(store, new SHA256Trunc(), `temp_msgs_subtrees_${i}`, treeHeight, 0n, Fr);
|
|
469
|
-
await tree.appendLeaves(msgs);
|
|
470
|
-
return tree;
|
|
471
|
-
}));
|
|
472
|
-
// path of the input msg from leaf -> first out hash calculated in base rolllup
|
|
473
|
-
const subtreePathOfL2ToL1Message = await l2toL1Subtrees[indexOfMsgTx].getSiblingPath(BigInt(indexOfMsgInSubtree), true);
|
|
474
|
-
const numTxs = block.body.txEffects.length;
|
|
475
|
-
if (numTxs === 1) {
|
|
476
|
-
return [
|
|
477
|
-
BigInt(indexOfMsgInSubtree),
|
|
478
|
-
subtreePathOfL2ToL1Message
|
|
479
|
-
];
|
|
480
|
-
}
|
|
481
|
-
const l2toL1SubtreeRoots = l2toL1Subtrees.map((t)=>Fr.fromBuffer(t.getRoot(true)));
|
|
482
|
-
const maxTreeHeight = Math.ceil(Math.log2(l2toL1SubtreeRoots.length));
|
|
483
|
-
// The root of this tree is the out_hash calculated in Noir => we truncate to match Noir's SHA
|
|
484
|
-
const outHashTree = new UnbalancedTree(new SHA256Trunc(), 'temp_outhash_sibling_path', maxTreeHeight, Fr);
|
|
485
|
-
await outHashTree.appendLeaves(l2toL1SubtreeRoots);
|
|
486
|
-
const pathOfTxInOutHashTree = await outHashTree.getSiblingPath(l2toL1SubtreeRoots[indexOfMsgTx].toBigInt());
|
|
487
|
-
// Append subtree path to out hash tree path
|
|
488
|
-
const mergedPath = subtreePathOfL2ToL1Message.toBufferArray().concat(pathOfTxInOutHashTree.toBufferArray());
|
|
489
|
-
// Append binary index of subtree path to binary index of out hash tree path
|
|
490
|
-
const mergedIndex = parseInt(indexOfMsgTx.toString(2).concat(indexOfMsgInSubtree.toString(2).padStart(l2toL1Subtrees[indexOfMsgTx].getDepth(), '0')), 2);
|
|
491
|
-
// clear the tmp stores
|
|
492
|
-
await Promise.all(tempStores.map((store)=>store.delete()));
|
|
493
|
-
return [
|
|
494
|
-
BigInt(mergedIndex),
|
|
495
|
-
new SiblingPath(mergedPath.length, mergedPath)
|
|
496
|
-
];
|
|
1189
|
+
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1190
|
+
return messageIndex !== undefined;
|
|
497
1191
|
}
|
|
498
1192
|
/**
|
|
499
|
-
* Returns
|
|
500
|
-
* @param
|
|
501
|
-
* @
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
1193
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
1194
|
+
* @param epoch - The epoch at which to get the data.
|
|
1195
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1196
|
+
*/ async getL2ToL1Messages(epoch) {
|
|
1197
|
+
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1198
|
+
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1199
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1200
|
+
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
506
1201
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
511
|
-
* @returns The sibling path.
|
|
512
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
513
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
514
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
518
|
-
* @param blockNumber - The block number at which to get the index.
|
|
519
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
520
|
-
* @returns The nullifier membership witness (if found).
|
|
521
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
522
|
-
const db = await this.#getWorldState(blockNumber);
|
|
523
|
-
const index = (await db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
1202
|
+
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1203
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1204
|
+
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
524
1205
|
nullifier.toBuffer()
|
|
525
|
-
])
|
|
526
|
-
if (!
|
|
1206
|
+
]);
|
|
1207
|
+
if (!witness) {
|
|
527
1208
|
return undefined;
|
|
528
1209
|
}
|
|
529
|
-
const
|
|
530
|
-
const
|
|
531
|
-
const [leafPreimage, siblingPath] = await Promise.all([
|
|
532
|
-
leafPreimagePromise,
|
|
533
|
-
siblingPathPromise
|
|
534
|
-
]);
|
|
1210
|
+
const { index, path } = witness;
|
|
1211
|
+
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
535
1212
|
if (!leafPreimage) {
|
|
536
1213
|
return undefined;
|
|
537
1214
|
}
|
|
538
|
-
return new NullifierMembershipWitness(
|
|
1215
|
+
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
539
1216
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
* @param blockNumber - The block number at which to get the index.
|
|
543
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
544
|
-
* @returns The low nullifier membership witness (if found).
|
|
545
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
546
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
547
|
-
* we are trying to prove non-inclusion for.
|
|
548
|
-
*
|
|
549
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
550
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
551
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
552
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
553
|
-
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
554
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1217
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1218
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
555
1219
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
556
1220
|
if (!findResult) {
|
|
557
1221
|
return undefined;
|
|
558
1222
|
}
|
|
559
1223
|
const { index, alreadyPresent } = findResult;
|
|
560
1224
|
if (alreadyPresent) {
|
|
561
|
-
|
|
1225
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
562
1226
|
}
|
|
563
1227
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
564
1228
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
565
1229
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
566
1230
|
}
|
|
567
|
-
async
|
|
568
|
-
const committedDb = await this
|
|
1231
|
+
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1232
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
569
1233
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
570
1234
|
if (!lowLeafResult) {
|
|
571
1235
|
return undefined;
|
|
@@ -575,53 +1239,87 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
575
1239
|
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
576
1240
|
}
|
|
577
1241
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
*
|
|
581
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
582
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
583
|
-
*
|
|
584
|
-
* @param contract - Address of the contract to query.
|
|
585
|
-
* @param slot - Slot to query.
|
|
586
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
587
|
-
* @returns Storage value at the given contract slot.
|
|
588
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
589
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1242
|
+
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1243
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
590
1244
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
591
1245
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
592
1246
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
593
1247
|
return Fr.ZERO;
|
|
594
1248
|
}
|
|
595
1249
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
596
|
-
return preimage.value;
|
|
1250
|
+
return preimage.leaf.value;
|
|
1251
|
+
}
|
|
1252
|
+
async getBlockHeader(block = 'latest') {
|
|
1253
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1254
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1255
|
+
if (block.equals(initialBlockHash)) {
|
|
1256
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1257
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1258
|
+
}
|
|
1259
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1260
|
+
} else {
|
|
1261
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1262
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1263
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
1264
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1265
|
+
}
|
|
1266
|
+
return this.blockSource.getBlockHeader(block);
|
|
1267
|
+
}
|
|
597
1268
|
}
|
|
598
1269
|
/**
|
|
599
|
-
*
|
|
600
|
-
* @
|
|
601
|
-
|
|
602
|
-
|
|
1270
|
+
* Get a block header specified by its archive root.
|
|
1271
|
+
* @param archive - The archive root being requested.
|
|
1272
|
+
* @returns The requested block header.
|
|
1273
|
+
*/ async getBlockHeaderByArchive(archive) {
|
|
1274
|
+
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1275
|
+
}
|
|
1276
|
+
getBlockData(number) {
|
|
1277
|
+
return this.blockSource.getBlockData(number);
|
|
1278
|
+
}
|
|
1279
|
+
getBlockDataByArchive(archive) {
|
|
1280
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
603
1281
|
}
|
|
604
1282
|
/**
|
|
605
1283
|
* Simulates the public part of a transaction with the current state.
|
|
606
1284
|
* @param tx - The transaction to simulate.
|
|
607
1285
|
**/ async simulatePublicCalls(tx, skipFeeEnforcement = false) {
|
|
608
|
-
|
|
609
|
-
const
|
|
1286
|
+
// Check total gas limit for simulation
|
|
1287
|
+
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
1288
|
+
const txGasLimit = gasSettings.gasLimits.l2Gas;
|
|
1289
|
+
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
1290
|
+
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
1291
|
+
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1292
|
+
}
|
|
1293
|
+
const txHash = tx.getTxHash();
|
|
1294
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1295
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
610
1296
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
611
|
-
const coinbase =
|
|
612
|
-
const feeRecipient =
|
|
613
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
|
|
614
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry);
|
|
615
|
-
const fork = await this.worldStateSynchronizer.fork();
|
|
1297
|
+
const coinbase = EthAddress.ZERO;
|
|
1298
|
+
const feeRecipient = AztecAddress.ZERO;
|
|
1299
|
+
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
1300
|
+
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
616
1301
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
617
1302
|
globalVariables: newGlobalVariables.toInspect(),
|
|
618
1303
|
txHash,
|
|
619
1304
|
blockNumber
|
|
620
1305
|
});
|
|
1306
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1307
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1308
|
+
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
621
1309
|
try {
|
|
622
|
-
const
|
|
1310
|
+
const config = PublicSimulatorConfig.from({
|
|
1311
|
+
skipFeeEnforcement,
|
|
1312
|
+
collectDebugLogs: true,
|
|
1313
|
+
collectHints: false,
|
|
1314
|
+
collectCallMetadata: true,
|
|
1315
|
+
collectStatistics: false,
|
|
1316
|
+
collectionLimits: CollectionLimitsConfig.from({
|
|
1317
|
+
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1318
|
+
})
|
|
1319
|
+
});
|
|
1320
|
+
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
623
1321
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
624
|
-
const [processedTxs, failedTxs, returns] = await processor.process([
|
|
1322
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
625
1323
|
tx
|
|
626
1324
|
]);
|
|
627
1325
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -632,30 +1330,54 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
632
1330
|
throw failedTxs[0].error;
|
|
633
1331
|
}
|
|
634
1332
|
const [processedTx] = processedTxs;
|
|
635
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.
|
|
1333
|
+
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
636
1334
|
} finally{
|
|
637
|
-
await
|
|
1335
|
+
await merkleTreeFork.close();
|
|
638
1336
|
}
|
|
639
1337
|
}
|
|
640
1338
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
641
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
642
1339
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
643
1340
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
644
|
-
|
|
1341
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1342
|
+
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1343
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1344
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1345
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1346
|
+
timestamp: nextSlotTimestamp,
|
|
645
1347
|
blockNumber,
|
|
646
1348
|
l1ChainId: this.l1ChainId,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
1349
|
+
rollupVersion: this.version,
|
|
1350
|
+
setupAllowList: [
|
|
1351
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
1352
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
1353
|
+
],
|
|
1354
|
+
gasFees: await this.getCurrentMinFees(),
|
|
1355
|
+
skipFeeEnforcement,
|
|
1356
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1357
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1358
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1359
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1360
|
+
}, this.log.getBindings());
|
|
651
1361
|
return await validator.validateTx(tx);
|
|
652
1362
|
}
|
|
1363
|
+
getConfig() {
|
|
1364
|
+
const schema = AztecNodeAdminConfigSchema;
|
|
1365
|
+
const keys = schema.keyof().options;
|
|
1366
|
+
return Promise.resolve(pick(this.config, ...keys));
|
|
1367
|
+
}
|
|
653
1368
|
async setConfig(config) {
|
|
654
1369
|
const newConfig = {
|
|
655
1370
|
...this.config,
|
|
656
1371
|
...config
|
|
657
1372
|
};
|
|
658
|
-
|
|
1373
|
+
this.sequencer?.updateConfig(config);
|
|
1374
|
+
this.slasherClient?.updateConfig(config);
|
|
1375
|
+
this.validatorsSentinel?.updateConfig(config);
|
|
1376
|
+
await this.p2pClient.updateP2PConfig(config);
|
|
1377
|
+
const archiver = this.blockSource;
|
|
1378
|
+
if ('updateConfig' in archiver) {
|
|
1379
|
+
archiver.updateConfig(config);
|
|
1380
|
+
}
|
|
659
1381
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
660
1382
|
this.proofVerifier = config.realProofs ? await BBCircuitVerifier.new(newConfig) : new TestCircuitVerifier();
|
|
661
1383
|
}
|
|
@@ -663,63 +1385,262 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
663
1385
|
}
|
|
664
1386
|
getProtocolContractAddresses() {
|
|
665
1387
|
return Promise.resolve({
|
|
666
|
-
|
|
1388
|
+
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
667
1389
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
668
|
-
|
|
1390
|
+
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
669
1391
|
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint
|
|
670
1392
|
});
|
|
671
1393
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
this.log.info(`Adding contract class via API ${contractClass.id}`);
|
|
675
|
-
return this.contractDataSource.addContractClass(contractClass);
|
|
1394
|
+
registerContractFunctionSignatures(signatures) {
|
|
1395
|
+
return this.contractDataSource.registerContractFunctionSignatures(signatures);
|
|
676
1396
|
}
|
|
677
|
-
|
|
678
|
-
return this.
|
|
1397
|
+
getValidatorsStats() {
|
|
1398
|
+
return this.validatorsSentinel?.computeStats() ?? Promise.resolve({
|
|
1399
|
+
stats: {},
|
|
1400
|
+
slotWindow: 0
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
getValidatorStats(validatorAddress, fromSlot, toSlot) {
|
|
1404
|
+
return this.validatorsSentinel?.getValidatorStats(validatorAddress, fromSlot, toSlot) ?? Promise.resolve(undefined);
|
|
1405
|
+
}
|
|
1406
|
+
async startSnapshotUpload(location) {
|
|
1407
|
+
// Note that we are forcefully casting the blocksource as an archiver
|
|
1408
|
+
// We break support for archiver running remotely to the node
|
|
1409
|
+
const archiver = this.blockSource;
|
|
1410
|
+
if (!('backupTo' in archiver)) {
|
|
1411
|
+
this.metrics.recordSnapshotError();
|
|
1412
|
+
throw new Error('Archiver implementation does not support backups. Cannot generate snapshot.');
|
|
1413
|
+
}
|
|
1414
|
+
// Test that the archiver has done an initial sync.
|
|
1415
|
+
if (!archiver.isInitialSyncComplete()) {
|
|
1416
|
+
this.metrics.recordSnapshotError();
|
|
1417
|
+
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
1418
|
+
}
|
|
1419
|
+
// And it has an L2 block hash
|
|
1420
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
1421
|
+
if (!l2BlockHash) {
|
|
1422
|
+
this.metrics.recordSnapshotError();
|
|
1423
|
+
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
1424
|
+
}
|
|
1425
|
+
if (this.isUploadingSnapshot) {
|
|
1426
|
+
this.metrics.recordSnapshotError();
|
|
1427
|
+
throw new Error(`Snapshot upload already in progress. Cannot start another one until complete.`);
|
|
1428
|
+
}
|
|
1429
|
+
// Do not wait for the upload to be complete to return to the caller, but flag that an operation is in progress
|
|
1430
|
+
this.isUploadingSnapshot = true;
|
|
1431
|
+
const timer = new Timer();
|
|
1432
|
+
void uploadSnapshot(location, this.blockSource, this.worldStateSynchronizer, this.config, this.log).then(()=>{
|
|
1433
|
+
this.isUploadingSnapshot = false;
|
|
1434
|
+
this.metrics.recordSnapshot(timer.ms());
|
|
1435
|
+
}).catch((err)=>{
|
|
1436
|
+
this.isUploadingSnapshot = false;
|
|
1437
|
+
this.metrics.recordSnapshotError();
|
|
1438
|
+
this.log.error(`Error uploading snapshot: ${err}`);
|
|
1439
|
+
});
|
|
1440
|
+
return Promise.resolve();
|
|
679
1441
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
1442
|
+
async rollbackTo(targetBlock, force) {
|
|
1443
|
+
const archiver = this.blockSource;
|
|
1444
|
+
if (!('rollbackTo' in archiver)) {
|
|
1445
|
+
throw new Error('Archiver implementation does not support rollbacks.');
|
|
1446
|
+
}
|
|
1447
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
1448
|
+
if (targetBlock < finalizedBlock) {
|
|
1449
|
+
if (force) {
|
|
1450
|
+
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
1451
|
+
await this.worldStateSynchronizer.clear();
|
|
1452
|
+
await this.p2pClient.clear();
|
|
1453
|
+
} else {
|
|
1454
|
+
throw new Error(`Cannot rollback to block ${targetBlock} as it is before finalized ${finalizedBlock}`);
|
|
1455
|
+
}
|
|
683
1456
|
}
|
|
684
|
-
|
|
1457
|
+
try {
|
|
1458
|
+
this.log.info(`Pausing archiver and world state sync to start rollback`);
|
|
1459
|
+
await archiver.stop();
|
|
1460
|
+
await this.worldStateSynchronizer.stopSync();
|
|
1461
|
+
const currentBlock = await archiver.getBlockNumber();
|
|
1462
|
+
const blocksToUnwind = currentBlock - targetBlock;
|
|
1463
|
+
this.log.info(`Unwinding ${count(blocksToUnwind, 'block')} from L2 block ${currentBlock} to ${targetBlock}`);
|
|
1464
|
+
await archiver.rollbackTo(targetBlock);
|
|
1465
|
+
this.log.info(`Unwinding complete.`);
|
|
1466
|
+
} catch (err) {
|
|
1467
|
+
this.log.error(`Error during rollback`, err);
|
|
1468
|
+
throw err;
|
|
1469
|
+
} finally{
|
|
1470
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1471
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1472
|
+
archiver.resume();
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
async pauseSync() {
|
|
1476
|
+
this.log.info(`Pausing archiver and world state sync`);
|
|
1477
|
+
await this.blockSource.stop();
|
|
1478
|
+
await this.worldStateSynchronizer.stopSync();
|
|
1479
|
+
}
|
|
1480
|
+
resumeSync() {
|
|
1481
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1482
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1483
|
+
this.blockSource.resume();
|
|
685
1484
|
return Promise.resolve();
|
|
686
1485
|
}
|
|
1486
|
+
getSlashPayloads() {
|
|
1487
|
+
if (!this.slasherClient) {
|
|
1488
|
+
throw new Error(`Slasher client not enabled`);
|
|
1489
|
+
}
|
|
1490
|
+
return this.slasherClient.getSlashPayloads();
|
|
1491
|
+
}
|
|
1492
|
+
getSlashOffenses(round) {
|
|
1493
|
+
if (!this.slasherClient) {
|
|
1494
|
+
throw new Error(`Slasher client not enabled`);
|
|
1495
|
+
}
|
|
1496
|
+
if (round === 'all') {
|
|
1497
|
+
return this.slasherClient.getPendingOffenses();
|
|
1498
|
+
} else {
|
|
1499
|
+
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
async reloadKeystore() {
|
|
1503
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1504
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1505
|
+
}
|
|
1506
|
+
if (!this.validatorClient) {
|
|
1507
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1508
|
+
}
|
|
1509
|
+
this.log.info('Reloading keystore from disk');
|
|
1510
|
+
// Re-read and validate keystore files
|
|
1511
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1512
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1513
|
+
await newManager.validateSigners();
|
|
1514
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1515
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1516
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1517
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1518
|
+
// would silently fail on every proposer slot.
|
|
1519
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1520
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1521
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1522
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1523
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1524
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1525
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1526
|
+
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 ` + `[${[
|
|
1527
|
+
...availablePublishers
|
|
1528
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
// Build adapters for old and new keystores to compute diff
|
|
1533
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1534
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1535
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1536
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1537
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1538
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1539
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1540
|
+
if (added.length > 0) {
|
|
1541
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1542
|
+
}
|
|
1543
|
+
if (removed.length > 0) {
|
|
1544
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1545
|
+
}
|
|
1546
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1547
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1548
|
+
}
|
|
1549
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1550
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1551
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1552
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1553
|
+
if (this.sequencer) {
|
|
1554
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1555
|
+
}
|
|
1556
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1557
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1558
|
+
const slashValidatorsNever = unique([
|
|
1559
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1560
|
+
...newAddresses
|
|
1561
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1562
|
+
this.slasherClient.updateConfig({
|
|
1563
|
+
slashValidatorsNever
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
this.keyStoreManager = newManager;
|
|
1567
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1568
|
+
}
|
|
1569
|
+
#getInitialHeaderHash() {
|
|
1570
|
+
if (!this.initialHeaderHashPromise) {
|
|
1571
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1572
|
+
}
|
|
1573
|
+
return this.initialHeaderHashPromise;
|
|
1574
|
+
}
|
|
687
1575
|
/**
|
|
688
1576
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
689
|
-
* @param
|
|
1577
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
690
1578
|
* @returns An instance of a committed MerkleTreeOperations
|
|
691
|
-
*/ async
|
|
692
|
-
|
|
693
|
-
throw new Error('Invalid block number to get world state for: ' + blockNumber);
|
|
694
|
-
}
|
|
695
|
-
let blockSyncedTo = 0;
|
|
1579
|
+
*/ async getWorldState(block) {
|
|
1580
|
+
let blockSyncedTo = BlockNumber.ZERO;
|
|
696
1581
|
try {
|
|
697
1582
|
// Attempt to sync the world state if necessary
|
|
698
1583
|
blockSyncedTo = await this.#syncWorldState();
|
|
699
1584
|
} catch (err) {
|
|
700
1585
|
this.log.error(`Error getting world state: ${err}`);
|
|
701
1586
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
this.log.debug(`Using committed db for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1587
|
+
if (block === 'latest') {
|
|
1588
|
+
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
705
1589
|
return this.worldStateSynchronizer.getCommitted();
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
1590
|
+
}
|
|
1591
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1592
|
+
let blockNumber;
|
|
1593
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1594
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1595
|
+
if (block.equals(initialBlockHash)) {
|
|
1596
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1597
|
+
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1598
|
+
}
|
|
1599
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1600
|
+
if (!header) {
|
|
1601
|
+
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.`);
|
|
1602
|
+
}
|
|
1603
|
+
blockNumber = header.getBlockNumber();
|
|
709
1604
|
} else {
|
|
710
|
-
|
|
1605
|
+
blockNumber = block;
|
|
1606
|
+
}
|
|
1607
|
+
// Check it's within world state sync range
|
|
1608
|
+
if (blockNumber > blockSyncedTo) {
|
|
1609
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1610
|
+
}
|
|
1611
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1612
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1613
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1614
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1615
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1616
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1617
|
+
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.`);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
return snapshot;
|
|
1621
|
+
}
|
|
1622
|
+
/** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
|
|
1623
|
+
if (block === 'latest') {
|
|
1624
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1625
|
+
}
|
|
1626
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1627
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1628
|
+
if (block.equals(initialBlockHash)) {
|
|
1629
|
+
return BlockNumber.ZERO;
|
|
1630
|
+
}
|
|
1631
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1632
|
+
if (!header) {
|
|
1633
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1634
|
+
}
|
|
1635
|
+
return header.getBlockNumber();
|
|
711
1636
|
}
|
|
1637
|
+
return block;
|
|
712
1638
|
}
|
|
713
1639
|
/**
|
|
714
1640
|
* Ensure we fully sync the world state
|
|
715
1641
|
* @returns A promise that fulfils once the world state is synced
|
|
716
1642
|
*/ async #syncWorldState() {
|
|
717
1643
|
const blockSourceHeight = await this.blockSource.getBlockNumber();
|
|
718
|
-
return this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1644
|
+
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
719
1645
|
}
|
|
720
1646
|
}
|
|
721
|
-
_ts_decorate([
|
|
722
|
-
trackSpan('AztecNodeService.simulatePublicCalls', async (tx)=>({
|
|
723
|
-
[Attributes.TX_HASH]: (await tx.getTxHash()).toString()
|
|
724
|
-
}))
|
|
725
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|