@aztec/aztec-node 0.0.1-commit.9b94fc1 → 0.0.1-commit.a072138
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 +5 -2
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +7 -1
- package/dest/aztec-node/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +9 -16
- package/dest/aztec-node/server.d.ts +52 -122
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +632 -204
- package/dest/sentinel/factory.d.ts +1 -1
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +5 -4
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +32 -27
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/aztec-node/config.ts +12 -8
- package/src/aztec-node/node_metrics.ts +6 -17
- package/src/aztec-node/server.ts +320 -278
- package/src/sentinel/factory.ts +1 -6
- package/src/sentinel/sentinel.ts +41 -32
|
@@ -1,18 +1,387 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
6
372
|
}
|
|
373
|
+
var _dec, _initProto;
|
|
7
374
|
import { createArchiver } from '@aztec/archiver';
|
|
8
375
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
9
|
-
import {
|
|
10
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
376
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
11
377
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
12
|
-
import {
|
|
378
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
379
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
380
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
381
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
13
382
|
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
383
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
384
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
16
385
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
17
386
|
import { createLogger } from '@aztec/foundation/log';
|
|
18
387
|
import { count } from '@aztec/foundation/string';
|
|
@@ -20,15 +389,16 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
20
389
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
21
390
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
22
391
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
23
|
-
import { createL1TxUtilsWithBlobsFromEthSigner } from '@aztec/node-lib/factories';
|
|
392
|
+
import { createForwarderL1TxUtilsFromEthSigner, createL1TxUtilsWithBlobsFromEthSigner } from '@aztec/node-lib/factories';
|
|
24
393
|
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
25
394
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
26
|
-
import {
|
|
395
|
+
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
27
396
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
28
397
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
29
|
-
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
398
|
+
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
30
399
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
|
-
import {
|
|
400
|
+
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
401
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
32
402
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
33
403
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
34
404
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
@@ -38,12 +408,15 @@ import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@az
|
|
|
38
408
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
39
409
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
40
410
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
41
|
-
import { NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
411
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient, createValidatorForAcceptingTxs } from '@aztec/validator-client';
|
|
42
412
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
43
413
|
import { createPublicClient, fallback, http } from 'viem';
|
|
44
414
|
import { createSentinel } from '../sentinel/factory.js';
|
|
45
415
|
import { createKeyStoreForValidator } from './config.js';
|
|
46
416
|
import { NodeMetrics } from './node_metrics.js';
|
|
417
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
418
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
419
|
+
}));
|
|
47
420
|
/**
|
|
48
421
|
* The aztec node.
|
|
49
422
|
*/ export class AztecNodeService {
|
|
@@ -66,11 +439,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
66
439
|
proofVerifier;
|
|
67
440
|
telemetry;
|
|
68
441
|
log;
|
|
442
|
+
blobClient;
|
|
443
|
+
static{
|
|
444
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
445
|
+
[
|
|
446
|
+
_dec,
|
|
447
|
+
2,
|
|
448
|
+
"simulatePublicCalls"
|
|
449
|
+
]
|
|
450
|
+
], []));
|
|
451
|
+
}
|
|
69
452
|
metrics;
|
|
453
|
+
initialHeaderHashPromise;
|
|
70
454
|
// Prevent two snapshot operations to happen simultaneously
|
|
71
455
|
isUploadingSnapshot;
|
|
72
456
|
tracer;
|
|
73
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node')){
|
|
457
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient){
|
|
74
458
|
this.config = config;
|
|
75
459
|
this.p2pClient = p2pClient;
|
|
76
460
|
this.blockSource = blockSource;
|
|
@@ -90,6 +474,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
90
474
|
this.proofVerifier = proofVerifier;
|
|
91
475
|
this.telemetry = telemetry;
|
|
92
476
|
this.log = log;
|
|
477
|
+
this.blobClient = blobClient;
|
|
478
|
+
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
93
479
|
this.isUploadingSnapshot = false;
|
|
94
480
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
95
481
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
@@ -115,9 +501,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
115
501
|
const packageVersion = getPackageVersion() ?? '';
|
|
116
502
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
117
503
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
118
|
-
const blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config, {
|
|
119
|
-
logger: createLogger('node:blob-sink:client')
|
|
120
|
-
});
|
|
121
504
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
122
505
|
// Build a key store from file if given or from environment otherwise
|
|
123
506
|
let keyStoreManager;
|
|
@@ -148,7 +531,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
148
531
|
}
|
|
149
532
|
const publicClient = createPublicClient({
|
|
150
533
|
chain: ethereumChain.chainInfo,
|
|
151
|
-
transport: fallback(config.l1RpcUrls.map((url)=>http(url
|
|
534
|
+
transport: fallback(config.l1RpcUrls.map((url)=>http(url, {
|
|
535
|
+
batch: false
|
|
536
|
+
}))),
|
|
152
537
|
pollingInterval: config.viemPollingIntervalMS
|
|
153
538
|
});
|
|
154
539
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -167,13 +552,14 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
167
552
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
168
553
|
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}).`);
|
|
169
554
|
}
|
|
555
|
+
const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
|
|
170
556
|
// attempt snapshot sync if possible
|
|
171
557
|
await trySnapshotSync(config, log);
|
|
172
558
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
173
559
|
dateProvider
|
|
174
560
|
});
|
|
175
561
|
const archiver = await createArchiver(config, {
|
|
176
|
-
|
|
562
|
+
blobClient,
|
|
177
563
|
epochCache,
|
|
178
564
|
telemetry,
|
|
179
565
|
dateProvider
|
|
@@ -182,7 +568,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
182
568
|
});
|
|
183
569
|
// now create the merkle trees and the world state synchronizer
|
|
184
570
|
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
185
|
-
const circuitVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
571
|
+
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
186
572
|
if (!config.realProofs) {
|
|
187
573
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
188
574
|
}
|
|
@@ -191,7 +577,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
191
577
|
const p2pClient = await createP2PClient(P2PClientType.Full, config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
192
578
|
// We should really not be modifying the config object
|
|
193
579
|
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
194
|
-
|
|
580
|
+
// Create FullNodeCheckpointsBuilder for validator and non-validator block proposal handling
|
|
581
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
195
582
|
...config,
|
|
196
583
|
l1GenesisTime,
|
|
197
584
|
slotDuration: Number(slotDuration)
|
|
@@ -199,15 +586,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
199
586
|
// We'll accumulate sentinel watchers here
|
|
200
587
|
const watchers = [];
|
|
201
588
|
// Create validator client if required
|
|
202
|
-
const validatorClient = createValidatorClient(config, {
|
|
589
|
+
const validatorClient = await createValidatorClient(config, {
|
|
590
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
591
|
+
worldState: worldStateSynchronizer,
|
|
203
592
|
p2pClient,
|
|
204
593
|
telemetry,
|
|
205
594
|
dateProvider,
|
|
206
595
|
epochCache,
|
|
207
|
-
blockBuilder,
|
|
208
596
|
blockSource: archiver,
|
|
209
597
|
l1ToL2MessageSource: archiver,
|
|
210
|
-
keyStoreManager
|
|
598
|
+
keyStoreManager,
|
|
599
|
+
blobClient
|
|
211
600
|
});
|
|
212
601
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
213
602
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
@@ -223,7 +612,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
223
612
|
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
224
613
|
log.info('Setting up block proposal reexecution for monitoring');
|
|
225
614
|
createBlockProposalHandler(config, {
|
|
226
|
-
|
|
615
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
616
|
+
worldState: worldStateSynchronizer,
|
|
227
617
|
epochCache,
|
|
228
618
|
blockSource: archiver,
|
|
229
619
|
l1ToL2MessageSource: archiver,
|
|
@@ -242,7 +632,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
242
632
|
}
|
|
243
633
|
let epochPruneWatcher;
|
|
244
634
|
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
245
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(),
|
|
635
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
246
636
|
watchers.push(epochPruneWatcher);
|
|
247
637
|
}
|
|
248
638
|
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
@@ -262,13 +652,20 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
262
652
|
// Validator enabled, create/start relevant service
|
|
263
653
|
let sequencer;
|
|
264
654
|
let slasherClient;
|
|
265
|
-
if (!config.disableValidator) {
|
|
655
|
+
if (!config.disableValidator && validatorClient) {
|
|
266
656
|
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
267
657
|
// as they are executed when the node is selected as proposer.
|
|
268
658
|
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
269
659
|
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
270
660
|
await slasherClient.start();
|
|
271
|
-
const l1TxUtils = await
|
|
661
|
+
const l1TxUtils = config.publisherForwarderAddress ? await createForwarderL1TxUtilsFromEthSigner(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.publisherForwarderAddress, {
|
|
662
|
+
...config,
|
|
663
|
+
scope: 'sequencer'
|
|
664
|
+
}, {
|
|
665
|
+
telemetry,
|
|
666
|
+
logger: log.createChild('l1-tx-utils'),
|
|
667
|
+
dateProvider
|
|
668
|
+
}) : await createL1TxUtilsWithBlobsFromEthSigner(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
272
669
|
...config,
|
|
273
670
|
scope: 'sequencer'
|
|
274
671
|
}, {
|
|
@@ -277,6 +674,11 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
277
674
|
dateProvider
|
|
278
675
|
});
|
|
279
676
|
// Create and start the sequencer client
|
|
677
|
+
const checkpointsBuilder = new CheckpointsBuilder({
|
|
678
|
+
...config,
|
|
679
|
+
l1GenesisTime,
|
|
680
|
+
slotDuration: Number(slotDuration)
|
|
681
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
280
682
|
sequencer = await SequencerClient.new(config, {
|
|
281
683
|
...deps,
|
|
282
684
|
epochCache,
|
|
@@ -285,12 +687,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
285
687
|
p2pClient,
|
|
286
688
|
worldStateSynchronizer,
|
|
287
689
|
slasherClient,
|
|
288
|
-
|
|
690
|
+
checkpointsBuilder,
|
|
289
691
|
l2BlockSource: archiver,
|
|
290
692
|
l1ToL2MessageSource: archiver,
|
|
291
693
|
telemetry,
|
|
292
694
|
dateProvider,
|
|
293
|
-
|
|
695
|
+
blobClient,
|
|
294
696
|
nodeKeyStore: keyStoreManager
|
|
295
697
|
});
|
|
296
698
|
}
|
|
@@ -300,7 +702,13 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
300
702
|
} else if (sequencer) {
|
|
301
703
|
log.warn(`Sequencer created but not started`);
|
|
302
704
|
}
|
|
303
|
-
|
|
705
|
+
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
706
|
+
...config,
|
|
707
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
708
|
+
l1GenesisTime,
|
|
709
|
+
slotDuration: Number(slotDuration)
|
|
710
|
+
});
|
|
711
|
+
return new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry, log, blobClient);
|
|
304
712
|
}
|
|
305
713
|
/**
|
|
306
714
|
* Returns the sequencer client instance.
|
|
@@ -355,28 +763,40 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
355
763
|
return nodeInfo;
|
|
356
764
|
}
|
|
357
765
|
/**
|
|
358
|
-
* Get a block specified by its number.
|
|
359
|
-
* @param
|
|
766
|
+
* Get a block specified by its block number, block hash, or 'latest'.
|
|
767
|
+
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
360
768
|
* @returns The requested block.
|
|
361
|
-
*/ async getBlock(
|
|
362
|
-
|
|
363
|
-
|
|
769
|
+
*/ async getBlock(block) {
|
|
770
|
+
if (BlockHash.isBlockHash(block)) {
|
|
771
|
+
return this.getBlockByHash(block);
|
|
772
|
+
}
|
|
773
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
774
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
775
|
+
return this.buildInitialBlock();
|
|
776
|
+
}
|
|
777
|
+
return await this.blockSource.getL2Block(blockNumber);
|
|
364
778
|
}
|
|
365
779
|
/**
|
|
366
780
|
* Get a block specified by its hash.
|
|
367
781
|
* @param blockHash - The block hash being requested.
|
|
368
782
|
* @returns The requested block.
|
|
369
783
|
*/ async getBlockByHash(blockHash) {
|
|
370
|
-
const
|
|
371
|
-
|
|
784
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
785
|
+
if (blockHash.equals(initialBlockHash)) {
|
|
786
|
+
return this.buildInitialBlock();
|
|
787
|
+
}
|
|
788
|
+
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
789
|
+
}
|
|
790
|
+
buildInitialBlock() {
|
|
791
|
+
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
792
|
+
return L2Block.empty(initialHeader);
|
|
372
793
|
}
|
|
373
794
|
/**
|
|
374
795
|
* Get a block specified by its archive root.
|
|
375
796
|
* @param archive - The archive root being requested.
|
|
376
797
|
* @returns The requested block.
|
|
377
798
|
*/ async getBlockByArchive(archive) {
|
|
378
|
-
|
|
379
|
-
return publishedBlock?.block;
|
|
799
|
+
return await this.blockSource.getL2BlockByArchive(archive);
|
|
380
800
|
}
|
|
381
801
|
/**
|
|
382
802
|
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
@@ -384,16 +804,28 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
384
804
|
* @param limit - The maximum number of blocks to obtain.
|
|
385
805
|
* @returns The blocks requested.
|
|
386
806
|
*/ async getBlocks(from, limit) {
|
|
387
|
-
return await this.blockSource.getBlocks(from, limit) ?? [];
|
|
807
|
+
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
808
|
+
}
|
|
809
|
+
async getCheckpoints(from, limit) {
|
|
810
|
+
return await this.blockSource.getCheckpoints(from, limit) ?? [];
|
|
388
811
|
}
|
|
389
|
-
async
|
|
390
|
-
return await this.blockSource.
|
|
812
|
+
async getCheckpointedBlocks(from, limit) {
|
|
813
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
391
814
|
}
|
|
392
815
|
/**
|
|
393
|
-
* Method to fetch the current
|
|
394
|
-
* @returns The current
|
|
395
|
-
*/ async
|
|
396
|
-
return await this.globalVariableBuilder.
|
|
816
|
+
* Method to fetch the current min L2 fees.
|
|
817
|
+
* @returns The current min L2 fees.
|
|
818
|
+
*/ async getCurrentMinFees() {
|
|
819
|
+
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
820
|
+
}
|
|
821
|
+
async getMaxPriorityFees() {
|
|
822
|
+
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
823
|
+
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
824
|
+
}
|
|
825
|
+
return GasFees.from({
|
|
826
|
+
feePerDaGas: 0n,
|
|
827
|
+
feePerL2Gas: 0n
|
|
828
|
+
});
|
|
397
829
|
}
|
|
398
830
|
/**
|
|
399
831
|
* Method to fetch the latest block number synchronized by the node.
|
|
@@ -404,6 +836,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
404
836
|
async getProvenBlockNumber() {
|
|
405
837
|
return await this.blockSource.getProvenBlockNumber();
|
|
406
838
|
}
|
|
839
|
+
async getCheckpointedBlockNumber() {
|
|
840
|
+
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
841
|
+
}
|
|
407
842
|
/**
|
|
408
843
|
* Method to fetch the version of the package.
|
|
409
844
|
* @returns The node package version
|
|
@@ -428,22 +863,29 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
428
863
|
getContract(address) {
|
|
429
864
|
return this.contractDataSource.getContract(address);
|
|
430
865
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
866
|
+
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
867
|
+
if (referenceBlock) {
|
|
868
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
869
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
870
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
871
|
+
if (!header) {
|
|
872
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
877
|
+
}
|
|
878
|
+
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
879
|
+
if (referenceBlock) {
|
|
880
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
881
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
882
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
883
|
+
if (!header) {
|
|
884
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
447
889
|
}
|
|
448
890
|
/**
|
|
449
891
|
* Gets public logs based on the provided filter.
|
|
@@ -484,18 +926,24 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
484
926
|
});
|
|
485
927
|
}
|
|
486
928
|
async getTxReceipt(txHash) {
|
|
487
|
-
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
493
|
-
}
|
|
929
|
+
// Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
|
|
930
|
+
// as a fallback if we don't find a settled receipt in the archiver.
|
|
931
|
+
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
932
|
+
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
933
|
+
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
494
934
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
495
935
|
if (settledTxReceipt) {
|
|
496
|
-
|
|
936
|
+
// If the archiver has the receipt then return it.
|
|
937
|
+
return settledTxReceipt;
|
|
938
|
+
} else if (isKnownToPool) {
|
|
939
|
+
// If the tx is in the pool but not in the archiver, it's pending.
|
|
940
|
+
// This handles race conditions between archiver and p2p, where the archiver
|
|
941
|
+
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
942
|
+
return new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
943
|
+
} else {
|
|
944
|
+
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
945
|
+
return new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
497
946
|
}
|
|
498
|
-
return txReceipt;
|
|
499
947
|
}
|
|
500
948
|
getTxEffect(txHash) {
|
|
501
949
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -512,10 +960,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
512
960
|
await tryStop(this.p2pClient);
|
|
513
961
|
await tryStop(this.worldStateSynchronizer);
|
|
514
962
|
await tryStop(this.blockSource);
|
|
963
|
+
await tryStop(this.blobClient);
|
|
515
964
|
await tryStop(this.telemetry);
|
|
516
965
|
this.log.info(`Stopped Aztec Node`);
|
|
517
966
|
}
|
|
518
967
|
/**
|
|
968
|
+
* Returns the blob client used by this node.
|
|
969
|
+
* @internal - Exposed for testing purposes only.
|
|
970
|
+
*/ getBlobClient() {
|
|
971
|
+
return this.blobClient;
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
519
974
|
* Method to retrieve pending txs.
|
|
520
975
|
* @param limit - The number of items to returns
|
|
521
976
|
* @param after - The last known pending tx. Used for pagination
|
|
@@ -540,15 +995,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
540
995
|
*/ async getTxsByHash(txHashes) {
|
|
541
996
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
542
997
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
* the leaves were inserted.
|
|
546
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
547
|
-
* @param treeId - The tree to search in.
|
|
548
|
-
* @param leafValues - The values to search for.
|
|
549
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
550
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
551
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
998
|
+
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
999
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
552
1000
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
553
1001
|
// We filter out undefined values
|
|
554
1002
|
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
@@ -567,7 +1015,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
567
1015
|
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
568
1016
|
// (note that block number corresponds to the leaf index in the archive tree).
|
|
569
1017
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
570
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber);
|
|
1018
|
+
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
571
1019
|
}));
|
|
572
1020
|
// If any of the block hashes are undefined, we throw an error.
|
|
573
1021
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
@@ -575,7 +1023,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
575
1023
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
576
1024
|
}
|
|
577
1025
|
}
|
|
578
|
-
// Create
|
|
1026
|
+
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
579
1027
|
return maybeIndices.map((index, i)=>{
|
|
580
1028
|
if (index === undefined) {
|
|
581
1029
|
return undefined;
|
|
@@ -590,51 +1038,28 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
590
1038
|
return undefined;
|
|
591
1039
|
}
|
|
592
1040
|
return {
|
|
593
|
-
l2BlockNumber: Number(blockNumber),
|
|
594
|
-
l2BlockHash:
|
|
1041
|
+
l2BlockNumber: BlockNumber(Number(blockNumber)),
|
|
1042
|
+
l2BlockHash: new BlockHash(blockHash),
|
|
595
1043
|
data: index
|
|
596
1044
|
};
|
|
597
1045
|
});
|
|
598
1046
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
* @param blockNumber - The block number at which to get the data.
|
|
602
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
603
|
-
* @returns The sibling path for the leaf index.
|
|
604
|
-
*/ async getNullifierSiblingPath(blockNumber, leafIndex) {
|
|
605
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
606
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Returns a sibling path for the given index in the data tree.
|
|
610
|
-
* @param blockNumber - The block number at which to get the data.
|
|
611
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
612
|
-
* @returns The sibling path for the leaf index.
|
|
613
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
614
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
615
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
616
|
-
}
|
|
617
|
-
async getArchiveMembershipWitness(blockNumber, archive) {
|
|
618
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1047
|
+
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1048
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
619
1049
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
620
|
-
|
|
1050
|
+
blockHash
|
|
621
1051
|
]);
|
|
622
1052
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
623
1053
|
}
|
|
624
|
-
async getNoteHashMembershipWitness(
|
|
625
|
-
const committedDb = await this.#getWorldState(
|
|
1054
|
+
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1055
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
626
1056
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
627
1057
|
noteHash
|
|
628
1058
|
]);
|
|
629
1059
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
630
1060
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
* @param blockNumber - The block number at which to get the data.
|
|
634
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
635
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
636
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
637
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1061
|
+
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1062
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
638
1063
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
639
1064
|
l1ToL2Message
|
|
640
1065
|
]);
|
|
@@ -649,7 +1074,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
649
1074
|
}
|
|
650
1075
|
async getL1ToL2MessageBlock(l1ToL2Message) {
|
|
651
1076
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
652
|
-
return messageIndex ? InboxLeaf.
|
|
1077
|
+
return messageIndex ? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex)) : undefined;
|
|
653
1078
|
}
|
|
654
1079
|
/**
|
|
655
1080
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -660,38 +1085,29 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
660
1085
|
return messageIndex !== undefined;
|
|
661
1086
|
}
|
|
662
1087
|
/**
|
|
663
|
-
* Returns all the L2 to L1 messages in
|
|
664
|
-
* @param
|
|
665
|
-
* @returns The L2 to L1 messages (
|
|
666
|
-
*/ async getL2ToL1Messages(
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
* @returns The sibling path.
|
|
684
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
685
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
686
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
1088
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
1089
|
+
* @param epoch - The epoch at which to get the data.
|
|
1090
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1091
|
+
*/ async getL2ToL1Messages(epoch) {
|
|
1092
|
+
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1093
|
+
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1094
|
+
const blocksInCheckpoints = [];
|
|
1095
|
+
let previousSlotNumber = SlotNumber.ZERO;
|
|
1096
|
+
let checkpointIndex = -1;
|
|
1097
|
+
for (const checkpointedBlock of checkpointedBlocks){
|
|
1098
|
+
const block = checkpointedBlock.block;
|
|
1099
|
+
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1100
|
+
if (slotNumber !== previousSlotNumber) {
|
|
1101
|
+
checkpointIndex++;
|
|
1102
|
+
blocksInCheckpoints.push([]);
|
|
1103
|
+
previousSlotNumber = slotNumber;
|
|
1104
|
+
}
|
|
1105
|
+
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1106
|
+
}
|
|
1107
|
+
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
687
1108
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
* @param blockNumber - The block number at which to get the index.
|
|
691
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
692
|
-
* @returns The nullifier membership witness (if found).
|
|
693
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
694
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1109
|
+
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1110
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
695
1111
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
696
1112
|
nullifier.toBuffer()
|
|
697
1113
|
]);
|
|
@@ -707,7 +1123,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
707
1123
|
}
|
|
708
1124
|
/**
|
|
709
1125
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
710
|
-
* @param
|
|
1126
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1127
|
+
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
711
1128
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
712
1129
|
* @returns The low nullifier membership witness (if found).
|
|
713
1130
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -718,8 +1135,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
718
1135
|
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
719
1136
|
* index of the nullifier itself when it already exists in the tree.
|
|
720
1137
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
721
|
-
*/ async getLowNullifierMembershipWitness(
|
|
722
|
-
const committedDb = await this.#getWorldState(
|
|
1138
|
+
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1139
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
723
1140
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
724
1141
|
if (!findResult) {
|
|
725
1142
|
return undefined;
|
|
@@ -732,8 +1149,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
732
1149
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
733
1150
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
734
1151
|
}
|
|
735
|
-
async getPublicDataWitness(
|
|
736
|
-
const committedDb = await this.#getWorldState(
|
|
1152
|
+
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1153
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
737
1154
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
738
1155
|
if (!lowLeafResult) {
|
|
739
1156
|
return undefined;
|
|
@@ -743,18 +1160,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
743
1160
|
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
744
1161
|
}
|
|
745
1162
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
*
|
|
749
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
750
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
751
|
-
*
|
|
752
|
-
* @param contract - Address of the contract to query.
|
|
753
|
-
* @param slot - Slot to query.
|
|
754
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
755
|
-
* @returns Storage value at the given contract slot.
|
|
756
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
757
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1163
|
+
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1164
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
758
1165
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
759
1166
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
760
1167
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -763,18 +1170,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
763
1170
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
764
1171
|
return preimage.leaf.value;
|
|
765
1172
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
1173
|
+
async getBlockHeader(block = 'latest') {
|
|
1174
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1175
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1176
|
+
if (block.equals(initialBlockHash)) {
|
|
1177
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1178
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1179
|
+
}
|
|
1180
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1181
|
+
} else {
|
|
1182
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1183
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1184
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
1185
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1186
|
+
}
|
|
1187
|
+
return this.blockSource.getBlockHeader(block);
|
|
1188
|
+
}
|
|
778
1189
|
}
|
|
779
1190
|
/**
|
|
780
1191
|
* Get a block header specified by its archive root.
|
|
@@ -795,12 +1206,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
795
1206
|
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
796
1207
|
}
|
|
797
1208
|
const txHash = tx.getTxHash();
|
|
798
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
1209
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
799
1210
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
800
1211
|
const coinbase = EthAddress.ZERO;
|
|
801
1212
|
const feeRecipient = AztecAddress.ZERO;
|
|
802
1213
|
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
803
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry);
|
|
1214
|
+
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
804
1215
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
805
1216
|
globalVariables: newGlobalVariables.toInspect(),
|
|
806
1217
|
txHash,
|
|
@@ -813,8 +1224,10 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
813
1224
|
collectDebugLogs: true,
|
|
814
1225
|
collectHints: false,
|
|
815
1226
|
collectCallMetadata: true,
|
|
816
|
-
|
|
817
|
-
|
|
1227
|
+
collectStatistics: false,
|
|
1228
|
+
collectionLimits: CollectionLimitsConfig.from({
|
|
1229
|
+
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1230
|
+
})
|
|
818
1231
|
});
|
|
819
1232
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
820
1233
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
@@ -839,17 +1252,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
839
1252
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
840
1253
|
// We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
|
|
841
1254
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
842
|
-
const blockNumber = await this.blockSource.getBlockNumber() + 1;
|
|
1255
|
+
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
843
1256
|
const validator = createValidatorForAcceptingTxs(db, this.contractDataSource, verifier, {
|
|
844
1257
|
timestamp: nextSlotTimestamp,
|
|
845
1258
|
blockNumber,
|
|
846
1259
|
l1ChainId: this.l1ChainId,
|
|
847
1260
|
rollupVersion: this.version,
|
|
848
1261
|
setupAllowList: this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions(),
|
|
849
|
-
gasFees: await this.
|
|
1262
|
+
gasFees: await this.getCurrentMinFees(),
|
|
850
1263
|
skipFeeEnforcement,
|
|
851
1264
|
txsPermitted: !this.config.disableTransactions
|
|
852
|
-
});
|
|
1265
|
+
}, this.log.getBindings());
|
|
853
1266
|
return await validator.validateTx(tx);
|
|
854
1267
|
}
|
|
855
1268
|
getConfig() {
|
|
@@ -909,7 +1322,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
909
1322
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
910
1323
|
}
|
|
911
1324
|
// And it has an L2 block hash
|
|
912
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
1325
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
913
1326
|
if (!l2BlockHash) {
|
|
914
1327
|
this.metrics.recordSnapshotError();
|
|
915
1328
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -936,7 +1349,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
936
1349
|
if (!('rollbackTo' in archiver)) {
|
|
937
1350
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
938
1351
|
}
|
|
939
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1352
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
940
1353
|
if (targetBlock < finalizedBlock) {
|
|
941
1354
|
if (force) {
|
|
942
1355
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -991,30 +1404,50 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
991
1404
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
992
1405
|
}
|
|
993
1406
|
}
|
|
1407
|
+
#getInitialHeaderHash() {
|
|
1408
|
+
if (!this.initialHeaderHashPromise) {
|
|
1409
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1410
|
+
}
|
|
1411
|
+
return this.initialHeaderHashPromise;
|
|
1412
|
+
}
|
|
994
1413
|
/**
|
|
995
1414
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
996
|
-
* @param
|
|
1415
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
997
1416
|
* @returns An instance of a committed MerkleTreeOperations
|
|
998
|
-
*/ async #getWorldState(
|
|
999
|
-
|
|
1000
|
-
throw new Error('Invalid block number to get world state for: ' + blockNumber);
|
|
1001
|
-
}
|
|
1002
|
-
let blockSyncedTo = 0;
|
|
1417
|
+
*/ async #getWorldState(block) {
|
|
1418
|
+
let blockSyncedTo = BlockNumber.ZERO;
|
|
1003
1419
|
try {
|
|
1004
1420
|
// Attempt to sync the world state if necessary
|
|
1005
1421
|
blockSyncedTo = await this.#syncWorldState();
|
|
1006
1422
|
} catch (err) {
|
|
1007
1423
|
this.log.error(`Error getting world state: ${err}`);
|
|
1008
1424
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
this.log.debug(`Using committed db for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1425
|
+
if (block === 'latest') {
|
|
1426
|
+
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1012
1427
|
return this.worldStateSynchronizer.getCommitted();
|
|
1013
|
-
}
|
|
1428
|
+
}
|
|
1429
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1430
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1431
|
+
if (block.equals(initialBlockHash)) {
|
|
1432
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1433
|
+
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1434
|
+
}
|
|
1435
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1436
|
+
if (!header) {
|
|
1437
|
+
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.`);
|
|
1438
|
+
}
|
|
1439
|
+
const blockNumber = header.getBlockNumber();
|
|
1440
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1441
|
+
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1442
|
+
}
|
|
1443
|
+
// Block number provided
|
|
1444
|
+
{
|
|
1445
|
+
const blockNumber = block;
|
|
1446
|
+
if (blockNumber > blockSyncedTo) {
|
|
1447
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1448
|
+
}
|
|
1014
1449
|
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1015
1450
|
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1016
|
-
} else {
|
|
1017
|
-
throw new Error(`Block ${blockNumber} not yet synced`);
|
|
1018
1451
|
}
|
|
1019
1452
|
}
|
|
1020
1453
|
/**
|
|
@@ -1022,11 +1455,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1022
1455
|
* @returns A promise that fulfils once the world state is synced
|
|
1023
1456
|
*/ async #syncWorldState() {
|
|
1024
1457
|
const blockSourceHeight = await this.blockSource.getBlockNumber();
|
|
1025
|
-
return this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1458
|
+
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1026
1459
|
}
|
|
1027
1460
|
}
|
|
1028
|
-
_ts_decorate([
|
|
1029
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1030
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1031
|
-
}))
|
|
1032
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|