@aztec/aztec-node 0.0.1-commit.d3ec352c → 0.0.1-commit.f295ac2
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 +5 -16
- package/dest/aztec-node/server.d.ts +50 -117
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +581 -171
- package/dest/sentinel/sentinel.d.ts +5 -4
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +31 -26
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/aztec-node/config.ts +12 -8
- package/src/aztec-node/node_metrics.ts +5 -23
- package/src/aztec-node/server.ts +241 -202
- package/src/sentinel/sentinel.ts +41 -32
|
@@ -1,19 +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 {
|
|
13
|
-
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';
|
|
14
382
|
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
383
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
15
384
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
17
385
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
18
386
|
import { createLogger } from '@aztec/foundation/log';
|
|
19
387
|
import { count } from '@aztec/foundation/string';
|
|
@@ -21,15 +389,15 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
21
389
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
22
390
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
23
391
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
24
|
-
import { createL1TxUtilsWithBlobsFromEthSigner } from '@aztec/node-lib/factories';
|
|
392
|
+
import { createForwarderL1TxUtilsFromEthSigner, createL1TxUtilsWithBlobsFromEthSigner } from '@aztec/node-lib/factories';
|
|
25
393
|
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
26
394
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
27
|
-
import {
|
|
395
|
+
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
28
396
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
29
397
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
30
398
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
31
399
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
32
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
400
|
+
import { L2BlockHash, L2BlockNew } from '@aztec/stdlib/block';
|
|
33
401
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
34
402
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
35
403
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -40,12 +408,15 @@ import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@az
|
|
|
40
408
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
41
409
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
42
410
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
43
|
-
import { NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
411
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient, createValidatorForAcceptingTxs } from '@aztec/validator-client';
|
|
44
412
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
45
413
|
import { createPublicClient, fallback, http } from 'viem';
|
|
46
414
|
import { createSentinel } from '../sentinel/factory.js';
|
|
47
415
|
import { createKeyStoreForValidator } from './config.js';
|
|
48
416
|
import { NodeMetrics } from './node_metrics.js';
|
|
417
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
418
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
419
|
+
}));
|
|
49
420
|
/**
|
|
50
421
|
* The aztec node.
|
|
51
422
|
*/ export class AztecNodeService {
|
|
@@ -68,11 +439,22 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
68
439
|
proofVerifier;
|
|
69
440
|
telemetry;
|
|
70
441
|
log;
|
|
442
|
+
blobClient;
|
|
443
|
+
static{
|
|
444
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
445
|
+
[
|
|
446
|
+
_dec,
|
|
447
|
+
2,
|
|
448
|
+
"simulatePublicCalls"
|
|
449
|
+
]
|
|
450
|
+
], []));
|
|
451
|
+
}
|
|
71
452
|
metrics;
|
|
453
|
+
initialHeaderHashPromise;
|
|
72
454
|
// Prevent two snapshot operations to happen simultaneously
|
|
73
455
|
isUploadingSnapshot;
|
|
74
456
|
tracer;
|
|
75
|
-
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){
|
|
76
458
|
this.config = config;
|
|
77
459
|
this.p2pClient = p2pClient;
|
|
78
460
|
this.blockSource = blockSource;
|
|
@@ -92,6 +474,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
92
474
|
this.proofVerifier = proofVerifier;
|
|
93
475
|
this.telemetry = telemetry;
|
|
94
476
|
this.log = log;
|
|
477
|
+
this.blobClient = blobClient;
|
|
478
|
+
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
95
479
|
this.isUploadingSnapshot = false;
|
|
96
480
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
97
481
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
@@ -117,9 +501,6 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
117
501
|
const packageVersion = getPackageVersion() ?? '';
|
|
118
502
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
119
503
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
120
|
-
const blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config, {
|
|
121
|
-
logger: createLogger('node:blob-sink:client')
|
|
122
|
-
});
|
|
123
504
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
124
505
|
// Build a key store from file if given or from environment otherwise
|
|
125
506
|
let keyStoreManager;
|
|
@@ -150,7 +531,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
150
531
|
}
|
|
151
532
|
const publicClient = createPublicClient({
|
|
152
533
|
chain: ethereumChain.chainInfo,
|
|
153
|
-
transport: fallback(config.l1RpcUrls.map((url)=>http(url
|
|
534
|
+
transport: fallback(config.l1RpcUrls.map((url)=>http(url, {
|
|
535
|
+
batch: false
|
|
536
|
+
}))),
|
|
154
537
|
pollingInterval: config.viemPollingIntervalMS
|
|
155
538
|
});
|
|
156
539
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -169,13 +552,14 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
169
552
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
170
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}).`);
|
|
171
554
|
}
|
|
555
|
+
const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
|
|
172
556
|
// attempt snapshot sync if possible
|
|
173
557
|
await trySnapshotSync(config, log);
|
|
174
558
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
175
559
|
dateProvider
|
|
176
560
|
});
|
|
177
561
|
const archiver = await createArchiver(config, {
|
|
178
|
-
|
|
562
|
+
blobClient,
|
|
179
563
|
epochCache,
|
|
180
564
|
telemetry,
|
|
181
565
|
dateProvider
|
|
@@ -184,7 +568,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
184
568
|
});
|
|
185
569
|
// now create the merkle trees and the world state synchronizer
|
|
186
570
|
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
187
|
-
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);
|
|
188
572
|
if (!config.realProofs) {
|
|
189
573
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
190
574
|
}
|
|
@@ -193,7 +577,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
193
577
|
const p2pClient = await createP2PClient(P2PClientType.Full, config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
194
578
|
// We should really not be modifying the config object
|
|
195
579
|
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
196
|
-
|
|
580
|
+
// Create FullNodeCheckpointsBuilder for validator and non-validator block proposal handling
|
|
581
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
197
582
|
...config,
|
|
198
583
|
l1GenesisTime,
|
|
199
584
|
slotDuration: Number(slotDuration)
|
|
@@ -201,15 +586,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
201
586
|
// We'll accumulate sentinel watchers here
|
|
202
587
|
const watchers = [];
|
|
203
588
|
// Create validator client if required
|
|
204
|
-
const validatorClient = createValidatorClient(config, {
|
|
589
|
+
const validatorClient = await createValidatorClient(config, {
|
|
590
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
591
|
+
worldState: worldStateSynchronizer,
|
|
205
592
|
p2pClient,
|
|
206
593
|
telemetry,
|
|
207
594
|
dateProvider,
|
|
208
595
|
epochCache,
|
|
209
|
-
blockBuilder,
|
|
210
596
|
blockSource: archiver,
|
|
211
597
|
l1ToL2MessageSource: archiver,
|
|
212
|
-
keyStoreManager
|
|
598
|
+
keyStoreManager,
|
|
599
|
+
blobClient
|
|
213
600
|
});
|
|
214
601
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
215
602
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
@@ -225,7 +612,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
225
612
|
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
226
613
|
log.info('Setting up block proposal reexecution for monitoring');
|
|
227
614
|
createBlockProposalHandler(config, {
|
|
228
|
-
|
|
615
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
616
|
+
worldState: worldStateSynchronizer,
|
|
229
617
|
epochCache,
|
|
230
618
|
blockSource: archiver,
|
|
231
619
|
l1ToL2MessageSource: archiver,
|
|
@@ -244,7 +632,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
244
632
|
}
|
|
245
633
|
let epochPruneWatcher;
|
|
246
634
|
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
247
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(),
|
|
635
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
248
636
|
watchers.push(epochPruneWatcher);
|
|
249
637
|
}
|
|
250
638
|
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
@@ -264,13 +652,20 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
264
652
|
// Validator enabled, create/start relevant service
|
|
265
653
|
let sequencer;
|
|
266
654
|
let slasherClient;
|
|
267
|
-
if (!config.disableValidator) {
|
|
655
|
+
if (!config.disableValidator && validatorClient) {
|
|
268
656
|
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
269
657
|
// as they are executed when the node is selected as proposer.
|
|
270
658
|
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
271
659
|
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
272
660
|
await slasherClient.start();
|
|
273
|
-
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(), {
|
|
274
669
|
...config,
|
|
275
670
|
scope: 'sequencer'
|
|
276
671
|
}, {
|
|
@@ -279,6 +674,11 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
279
674
|
dateProvider
|
|
280
675
|
});
|
|
281
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);
|
|
282
682
|
sequencer = await SequencerClient.new(config, {
|
|
283
683
|
...deps,
|
|
284
684
|
epochCache,
|
|
@@ -287,12 +687,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
287
687
|
p2pClient,
|
|
288
688
|
worldStateSynchronizer,
|
|
289
689
|
slasherClient,
|
|
290
|
-
|
|
690
|
+
checkpointsBuilder,
|
|
291
691
|
l2BlockSource: archiver,
|
|
292
692
|
l1ToL2MessageSource: archiver,
|
|
293
693
|
telemetry,
|
|
294
694
|
dateProvider,
|
|
295
|
-
|
|
695
|
+
blobClient,
|
|
296
696
|
nodeKeyStore: keyStoreManager
|
|
297
697
|
});
|
|
298
698
|
}
|
|
@@ -302,7 +702,13 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
302
702
|
} else if (sequencer) {
|
|
303
703
|
log.warn(`Sequencer created but not started`);
|
|
304
704
|
}
|
|
305
|
-
|
|
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);
|
|
306
712
|
}
|
|
307
713
|
/**
|
|
308
714
|
* Returns the sequencer client instance.
|
|
@@ -357,28 +763,40 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
357
763
|
return nodeInfo;
|
|
358
764
|
}
|
|
359
765
|
/**
|
|
360
|
-
* Get a block specified by its number.
|
|
361
|
-
* @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').
|
|
362
768
|
* @returns The requested block.
|
|
363
|
-
*/ async getBlock(
|
|
364
|
-
|
|
365
|
-
|
|
769
|
+
*/ async getBlock(block) {
|
|
770
|
+
if (L2BlockHash.isL2BlockHash(block)) {
|
|
771
|
+
return this.getBlockByHash(Fr.fromBuffer(block.toBuffer()));
|
|
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.getL2BlockNew(blockNumber);
|
|
366
778
|
}
|
|
367
779
|
/**
|
|
368
780
|
* Get a block specified by its hash.
|
|
369
781
|
* @param blockHash - The block hash being requested.
|
|
370
782
|
* @returns The requested block.
|
|
371
783
|
*/ async getBlockByHash(blockHash) {
|
|
372
|
-
const
|
|
373
|
-
|
|
784
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
785
|
+
if (blockHash.equals(Fr.fromBuffer(initialBlockHash.toBuffer()))) {
|
|
786
|
+
return this.buildInitialBlock();
|
|
787
|
+
}
|
|
788
|
+
return await this.blockSource.getL2BlockNewByHash(blockHash);
|
|
789
|
+
}
|
|
790
|
+
buildInitialBlock() {
|
|
791
|
+
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
792
|
+
return L2BlockNew.empty(initialHeader);
|
|
374
793
|
}
|
|
375
794
|
/**
|
|
376
795
|
* Get a block specified by its archive root.
|
|
377
796
|
* @param archive - The archive root being requested.
|
|
378
797
|
* @returns The requested block.
|
|
379
798
|
*/ async getBlockByArchive(archive) {
|
|
380
|
-
|
|
381
|
-
return publishedBlock?.block;
|
|
799
|
+
return await this.blockSource.getL2BlockNewByArchive(archive);
|
|
382
800
|
}
|
|
383
801
|
/**
|
|
384
802
|
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
@@ -386,16 +804,25 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
386
804
|
* @param limit - The maximum number of blocks to obtain.
|
|
387
805
|
* @returns The blocks requested.
|
|
388
806
|
*/ async getBlocks(from, limit) {
|
|
389
|
-
return await this.blockSource.
|
|
807
|
+
return await this.blockSource.getL2BlocksNew(from, limit) ?? [];
|
|
390
808
|
}
|
|
391
809
|
async getPublishedBlocks(from, limit) {
|
|
392
810
|
return await this.blockSource.getPublishedBlocks(from, limit) ?? [];
|
|
393
811
|
}
|
|
812
|
+
async getPublishedCheckpoints(from, limit) {
|
|
813
|
+
return await this.blockSource.getPublishedCheckpoints(from, limit) ?? [];
|
|
814
|
+
}
|
|
815
|
+
async getL2BlocksNew(from, limit) {
|
|
816
|
+
return await this.blockSource.getL2BlocksNew(from, limit) ?? [];
|
|
817
|
+
}
|
|
818
|
+
async getCheckpointedBlocks(from, limit, proven) {
|
|
819
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit, proven) ?? [];
|
|
820
|
+
}
|
|
394
821
|
/**
|
|
395
|
-
* Method to fetch the current
|
|
396
|
-
* @returns The current
|
|
397
|
-
*/ async
|
|
398
|
-
return await this.globalVariableBuilder.
|
|
822
|
+
* Method to fetch the current min L2 fees.
|
|
823
|
+
* @returns The current min L2 fees.
|
|
824
|
+
*/ async getCurrentMinFees() {
|
|
825
|
+
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
399
826
|
}
|
|
400
827
|
async getMaxPriorityFees() {
|
|
401
828
|
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
@@ -439,22 +866,11 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
439
866
|
getContract(address) {
|
|
440
867
|
return this.contractDataSource.getContract(address);
|
|
441
868
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
* @param from - The block number from which to begin retrieving logs.
|
|
445
|
-
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
446
|
-
* @returns An array of private logs from the specified range of blocks.
|
|
447
|
-
*/ getPrivateLogs(from, limit) {
|
|
448
|
-
return this.logsSource.getPrivateLogs(from, limit);
|
|
869
|
+
getPrivateLogsByTags(tags) {
|
|
870
|
+
return this.logsSource.getPrivateLogsByTags(tags);
|
|
449
871
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
* @param tags - The tags to filter the logs by.
|
|
453
|
-
* @param logsPerTag - The maximum number of logs to return for each tag. By default no limit is set
|
|
454
|
-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
455
|
-
* that tag.
|
|
456
|
-
*/ getLogsByTags(tags, logsPerTag) {
|
|
457
|
-
return this.logsSource.getLogsByTags(tags, logsPerTag);
|
|
872
|
+
getPublicLogsByTagsFromContract(contractAddress, tags) {
|
|
873
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags);
|
|
458
874
|
}
|
|
459
875
|
/**
|
|
460
876
|
* Gets public logs based on the provided filter.
|
|
@@ -523,10 +939,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
523
939
|
await tryStop(this.p2pClient);
|
|
524
940
|
await tryStop(this.worldStateSynchronizer);
|
|
525
941
|
await tryStop(this.blockSource);
|
|
942
|
+
await tryStop(this.blobClient);
|
|
526
943
|
await tryStop(this.telemetry);
|
|
527
944
|
this.log.info(`Stopped Aztec Node`);
|
|
528
945
|
}
|
|
529
946
|
/**
|
|
947
|
+
* Returns the blob client used by this node.
|
|
948
|
+
* @internal - Exposed for testing purposes only.
|
|
949
|
+
*/ getBlobClient() {
|
|
950
|
+
return this.blobClient;
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
530
953
|
* Method to retrieve pending txs.
|
|
531
954
|
* @param limit - The number of items to returns
|
|
532
955
|
* @param after - The last known pending tx. Used for pagination
|
|
@@ -551,15 +974,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
551
974
|
*/ async getTxsByHash(txHashes) {
|
|
552
975
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
553
976
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
* the leaves were inserted.
|
|
557
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
558
|
-
* @param treeId - The tree to search in.
|
|
559
|
-
* @param leafValues - The values to search for.
|
|
560
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
561
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
562
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
977
|
+
async findLeavesIndexes(block, treeId, leafValues) {
|
|
978
|
+
const committedDb = await this.#getWorldState(block);
|
|
563
979
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
564
980
|
// We filter out undefined values
|
|
565
981
|
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
@@ -607,45 +1023,30 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
607
1023
|
};
|
|
608
1024
|
});
|
|
609
1025
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
* @param blockNumber - The block number at which to get the data.
|
|
613
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
614
|
-
* @returns The sibling path for the leaf index.
|
|
615
|
-
*/ async getNullifierSiblingPath(blockNumber, leafIndex) {
|
|
616
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1026
|
+
async getNullifierSiblingPath(block, leafIndex) {
|
|
1027
|
+
const committedDb = await this.#getWorldState(block);
|
|
617
1028
|
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
618
1029
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
* @param blockNumber - The block number at which to get the data.
|
|
622
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
623
|
-
* @returns The sibling path for the leaf index.
|
|
624
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
625
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1030
|
+
async getNoteHashSiblingPath(block, leafIndex) {
|
|
1031
|
+
const committedDb = await this.#getWorldState(block);
|
|
626
1032
|
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
627
1033
|
}
|
|
628
|
-
async getArchiveMembershipWitness(
|
|
629
|
-
const committedDb = await this.#getWorldState(
|
|
1034
|
+
async getArchiveMembershipWitness(block, archive) {
|
|
1035
|
+
const committedDb = await this.#getWorldState(block);
|
|
630
1036
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
631
1037
|
archive
|
|
632
1038
|
]);
|
|
633
1039
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
634
1040
|
}
|
|
635
|
-
async getNoteHashMembershipWitness(
|
|
636
|
-
const committedDb = await this.#getWorldState(
|
|
1041
|
+
async getNoteHashMembershipWitness(block, noteHash) {
|
|
1042
|
+
const committedDb = await this.#getWorldState(block);
|
|
637
1043
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
638
1044
|
noteHash
|
|
639
1045
|
]);
|
|
640
1046
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
641
1047
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
* @param blockNumber - The block number at which to get the data.
|
|
645
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
646
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
647
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
648
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1048
|
+
async getL1ToL2MessageMembershipWitness(block, l1ToL2Message) {
|
|
1049
|
+
const db = await this.#getWorldState(block);
|
|
649
1050
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
650
1051
|
l1ToL2Message
|
|
651
1052
|
]);
|
|
@@ -660,7 +1061,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
660
1061
|
}
|
|
661
1062
|
async getL1ToL2MessageBlock(l1ToL2Message) {
|
|
662
1063
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
663
|
-
return messageIndex ? BlockNumber(InboxLeaf.
|
|
1064
|
+
return messageIndex ? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex)) : undefined;
|
|
664
1065
|
}
|
|
665
1066
|
/**
|
|
666
1067
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -671,38 +1072,36 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
671
1072
|
return messageIndex !== undefined;
|
|
672
1073
|
}
|
|
673
1074
|
/**
|
|
674
|
-
* Returns all the L2 to L1 messages in
|
|
675
|
-
* @param
|
|
676
|
-
* @returns The L2 to L1 messages (
|
|
677
|
-
*/ async getL2ToL1Messages(
|
|
678
|
-
|
|
679
|
-
|
|
1075
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
1076
|
+
* @param epoch - The epoch at which to get the data.
|
|
1077
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1078
|
+
*/ async getL2ToL1Messages(epoch) {
|
|
1079
|
+
// Assumes `getBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1080
|
+
const blocks = await this.blockSource.getBlocksForEpoch(epoch);
|
|
1081
|
+
const blocksInCheckpoints = [];
|
|
1082
|
+
let previousSlotNumber = SlotNumber.ZERO;
|
|
1083
|
+
let checkpointIndex = -1;
|
|
1084
|
+
for (const block of blocks){
|
|
1085
|
+
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1086
|
+
if (slotNumber !== previousSlotNumber) {
|
|
1087
|
+
checkpointIndex++;
|
|
1088
|
+
blocksInCheckpoints.push([]);
|
|
1089
|
+
previousSlotNumber = slotNumber;
|
|
1090
|
+
}
|
|
1091
|
+
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1092
|
+
}
|
|
1093
|
+
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
680
1094
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
* @param blockNumber - The block number at which to get the data.
|
|
684
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
685
|
-
* @returns The sibling path.
|
|
686
|
-
*/ async getArchiveSiblingPath(blockNumber, leafIndex) {
|
|
687
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1095
|
+
async getArchiveSiblingPath(block, leafIndex) {
|
|
1096
|
+
const committedDb = await this.#getWorldState(block);
|
|
688
1097
|
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
689
1098
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
* @param blockNumber - The block number at which to get the data.
|
|
693
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
694
|
-
* @returns The sibling path.
|
|
695
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
696
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1099
|
+
async getPublicDataSiblingPath(block, leafIndex) {
|
|
1100
|
+
const committedDb = await this.#getWorldState(block);
|
|
697
1101
|
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
698
1102
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
* @param blockNumber - The block number at which to get the index.
|
|
702
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
703
|
-
* @returns The nullifier membership witness (if found).
|
|
704
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
705
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1103
|
+
async getNullifierMembershipWitness(block, nullifier) {
|
|
1104
|
+
const db = await this.#getWorldState(block);
|
|
706
1105
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
707
1106
|
nullifier.toBuffer()
|
|
708
1107
|
]);
|
|
@@ -718,7 +1117,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
718
1117
|
}
|
|
719
1118
|
/**
|
|
720
1119
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
721
|
-
* @param
|
|
1120
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
722
1121
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
723
1122
|
* @returns The low nullifier membership witness (if found).
|
|
724
1123
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -729,8 +1128,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
729
1128
|
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
730
1129
|
* index of the nullifier itself when it already exists in the tree.
|
|
731
1130
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
732
|
-
*/ async getLowNullifierMembershipWitness(
|
|
733
|
-
const committedDb = await this.#getWorldState(
|
|
1131
|
+
*/ async getLowNullifierMembershipWitness(block, nullifier) {
|
|
1132
|
+
const committedDb = await this.#getWorldState(block);
|
|
734
1133
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
735
1134
|
if (!findResult) {
|
|
736
1135
|
return undefined;
|
|
@@ -743,8 +1142,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
743
1142
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
744
1143
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
745
1144
|
}
|
|
746
|
-
async getPublicDataWitness(
|
|
747
|
-
const committedDb = await this.#getWorldState(
|
|
1145
|
+
async getPublicDataWitness(block, leafSlot) {
|
|
1146
|
+
const committedDb = await this.#getWorldState(block);
|
|
748
1147
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
749
1148
|
if (!lowLeafResult) {
|
|
750
1149
|
return undefined;
|
|
@@ -754,18 +1153,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
754
1153
|
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
755
1154
|
}
|
|
756
1155
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
*
|
|
760
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
761
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
762
|
-
*
|
|
763
|
-
* @param contract - Address of the contract to query.
|
|
764
|
-
* @param slot - Slot to query.
|
|
765
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
766
|
-
* @returns Storage value at the given contract slot.
|
|
767
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
768
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1156
|
+
async getPublicStorageAt(block, contract, slot) {
|
|
1157
|
+
const committedDb = await this.#getWorldState(block);
|
|
769
1158
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
770
1159
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
771
1160
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -774,18 +1163,23 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
774
1163
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
775
1164
|
return preimage.leaf.value;
|
|
776
1165
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
1166
|
+
async getBlockHeader(block = 'latest') {
|
|
1167
|
+
if (L2BlockHash.isL2BlockHash(block)) {
|
|
1168
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1169
|
+
if (block.equals(initialBlockHash)) {
|
|
1170
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1171
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1172
|
+
}
|
|
1173
|
+
const blockHashFr = Fr.fromBuffer(block.toBuffer());
|
|
1174
|
+
return this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1175
|
+
} else {
|
|
1176
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1177
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1178
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
1179
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1180
|
+
}
|
|
1181
|
+
return this.blockSource.getBlockHeader(block);
|
|
1182
|
+
}
|
|
789
1183
|
}
|
|
790
1184
|
/**
|
|
791
1185
|
* Get a block header specified by its archive root.
|
|
@@ -859,7 +1253,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
859
1253
|
l1ChainId: this.l1ChainId,
|
|
860
1254
|
rollupVersion: this.version,
|
|
861
1255
|
setupAllowList: this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions(),
|
|
862
|
-
gasFees: await this.
|
|
1256
|
+
gasFees: await this.getCurrentMinFees(),
|
|
863
1257
|
skipFeeEnforcement,
|
|
864
1258
|
txsPermitted: !this.config.disableTransactions
|
|
865
1259
|
});
|
|
@@ -922,7 +1316,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
922
1316
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
923
1317
|
}
|
|
924
1318
|
// And it has an L2 block hash
|
|
925
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
1319
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
926
1320
|
if (!l2BlockHash) {
|
|
927
1321
|
this.metrics.recordSnapshotError();
|
|
928
1322
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -949,7 +1343,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
949
1343
|
if (!('rollbackTo' in archiver)) {
|
|
950
1344
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
951
1345
|
}
|
|
952
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1346
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
953
1347
|
if (targetBlock < finalizedBlock) {
|
|
954
1348
|
if (force) {
|
|
955
1349
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -1004,14 +1398,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1004
1398
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1005
1399
|
}
|
|
1006
1400
|
}
|
|
1401
|
+
#getInitialHeaderHash() {
|
|
1402
|
+
if (!this.initialHeaderHashPromise) {
|
|
1403
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash().then((hash)=>L2BlockHash.fromField(hash));
|
|
1404
|
+
}
|
|
1405
|
+
return this.initialHeaderHashPromise;
|
|
1406
|
+
}
|
|
1007
1407
|
/**
|
|
1008
1408
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1009
|
-
* @param
|
|
1409
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1010
1410
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1011
|
-
*/ async #getWorldState(
|
|
1012
|
-
if (typeof blockNumber === 'number' && blockNumber < INITIAL_L2_BLOCK_NUM - 1) {
|
|
1013
|
-
throw new Error('Invalid block number to get world state for: ' + blockNumber);
|
|
1014
|
-
}
|
|
1411
|
+
*/ async #getWorldState(block) {
|
|
1015
1412
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1016
1413
|
try {
|
|
1017
1414
|
// Attempt to sync the world state if necessary
|
|
@@ -1019,15 +1416,33 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1019
1416
|
} catch (err) {
|
|
1020
1417
|
this.log.error(`Error getting world state: ${err}`);
|
|
1021
1418
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
this.log.debug(`Using committed db for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1419
|
+
if (block === 'latest') {
|
|
1420
|
+
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1025
1421
|
return this.worldStateSynchronizer.getCommitted();
|
|
1026
|
-
}
|
|
1422
|
+
}
|
|
1423
|
+
if (L2BlockHash.isL2BlockHash(block)) {
|
|
1424
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1425
|
+
if (block.equals(initialBlockHash)) {
|
|
1426
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1427
|
+
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1428
|
+
}
|
|
1429
|
+
const blockHashFr = Fr.fromBuffer(block.toBuffer());
|
|
1430
|
+
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1431
|
+
if (!header) {
|
|
1432
|
+
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.`);
|
|
1433
|
+
}
|
|
1434
|
+
const blockNumber = header.getBlockNumber();
|
|
1435
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1436
|
+
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1437
|
+
}
|
|
1438
|
+
// Block number provided
|
|
1439
|
+
{
|
|
1440
|
+
const blockNumber = block;
|
|
1441
|
+
if (blockNumber > blockSyncedTo) {
|
|
1442
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1443
|
+
}
|
|
1027
1444
|
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1028
1445
|
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1029
|
-
} else {
|
|
1030
|
-
throw new Error(`Block ${blockNumber} not yet synced`);
|
|
1031
1446
|
}
|
|
1032
1447
|
}
|
|
1033
1448
|
/**
|
|
@@ -1038,8 +1453,3 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1038
1453
|
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1039
1454
|
}
|
|
1040
1455
|
}
|
|
1041
|
-
_ts_decorate([
|
|
1042
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1043
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1044
|
-
}))
|
|
1045
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|