@aztec/aztec-node 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/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 +40 -96
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +579 -173
- 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/node_metrics.ts +5 -23
- package/src/aztec-node/server.ts +227 -203
- package/src/sentinel/sentinel.ts +41 -32
|
@@ -1,19 +1,384 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
6
369
|
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
|
+
}
|
|
373
|
+
var _dec, _initProto;
|
|
7
374
|
import { createArchiver } from '@aztec/archiver';
|
|
8
375
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
9
|
-
import {
|
|
10
|
-
import { createReadOnlyFileStoreBlobClients, createWritableFileStoreBlobClient } from '@aztec/blob-client/filestore';
|
|
11
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
376
|
+
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
12
377
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
13
378
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
14
379
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
15
380
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
16
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
381
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
17
382
|
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
18
383
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
19
384
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -27,13 +392,12 @@ import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
|
27
392
|
import { createForwarderL1TxUtilsFromEthSigner, createL1TxUtilsWithBlobsFromEthSigner } from '@aztec/node-lib/factories';
|
|
28
393
|
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
29
394
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
30
|
-
import {
|
|
31
|
-
import { CheckpointsBuilder } from '@aztec/sequencer-client';
|
|
395
|
+
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
32
396
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
33
397
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
34
398
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
35
399
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
36
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
400
|
+
import { L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
37
401
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
38
402
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
39
403
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -44,12 +408,15 @@ import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@az
|
|
|
44
408
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
45
409
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
46
410
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
47
|
-
import { NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
411
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient, createValidatorForAcceptingTxs } from '@aztec/validator-client';
|
|
48
412
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
49
413
|
import { createPublicClient, fallback, http } from 'viem';
|
|
50
414
|
import { createSentinel } from '../sentinel/factory.js';
|
|
51
415
|
import { createKeyStoreForValidator } from './config.js';
|
|
52
416
|
import { NodeMetrics } from './node_metrics.js';
|
|
417
|
+
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
418
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
419
|
+
}));
|
|
53
420
|
/**
|
|
54
421
|
* The aztec node.
|
|
55
422
|
*/ export class AztecNodeService {
|
|
@@ -73,7 +440,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
73
440
|
telemetry;
|
|
74
441
|
log;
|
|
75
442
|
blobClient;
|
|
443
|
+
static{
|
|
444
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
445
|
+
[
|
|
446
|
+
_dec,
|
|
447
|
+
2,
|
|
448
|
+
"simulatePublicCalls"
|
|
449
|
+
]
|
|
450
|
+
], []));
|
|
451
|
+
}
|
|
76
452
|
metrics;
|
|
453
|
+
initialHeaderHashPromise;
|
|
77
454
|
// Prevent two snapshot operations to happen simultaneously
|
|
78
455
|
isUploadingSnapshot;
|
|
79
456
|
tracer;
|
|
@@ -98,6 +475,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
98
475
|
this.telemetry = telemetry;
|
|
99
476
|
this.log = log;
|
|
100
477
|
this.blobClient = blobClient;
|
|
478
|
+
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
101
479
|
this.isUploadingSnapshot = false;
|
|
102
480
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
103
481
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
@@ -174,20 +552,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
174
552
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
175
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}).`);
|
|
176
554
|
}
|
|
177
|
-
const
|
|
178
|
-
l1ChainId: config.l1ChainId,
|
|
179
|
-
rollupVersion: config.rollupVersion,
|
|
180
|
-
rollupAddress: config.l1Contracts.rollupAddress.toString()
|
|
181
|
-
};
|
|
182
|
-
const [fileStoreClients, fileStoreUploadClient] = await Promise.all([
|
|
183
|
-
createReadOnlyFileStoreBlobClients(config.blobFileStoreUrls, blobFileStoreMetadata, log),
|
|
184
|
-
createWritableFileStoreBlobClient(config.blobFileStoreUploadUrl, blobFileStoreMetadata, log)
|
|
185
|
-
]);
|
|
186
|
-
const blobClient = deps.blobClient ?? createBlobClient(config, {
|
|
187
|
-
logger: createLogger('node:blob-client:client'),
|
|
188
|
-
fileStoreClients,
|
|
189
|
-
fileStoreUploadClient
|
|
190
|
-
});
|
|
555
|
+
const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
|
|
191
556
|
// attempt snapshot sync if possible
|
|
192
557
|
await trySnapshotSync(config, log);
|
|
193
558
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
@@ -212,7 +577,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
212
577
|
const p2pClient = await createP2PClient(P2PClientType.Full, config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
213
578
|
// We should really not be modifying the config object
|
|
214
579
|
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
215
|
-
|
|
580
|
+
// Create FullNodeCheckpointsBuilder for validator and non-validator block proposal handling
|
|
581
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
216
582
|
...config,
|
|
217
583
|
l1GenesisTime,
|
|
218
584
|
slotDuration: Number(slotDuration)
|
|
@@ -220,16 +586,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
220
586
|
// We'll accumulate sentinel watchers here
|
|
221
587
|
const watchers = [];
|
|
222
588
|
// Create validator client if required
|
|
223
|
-
const validatorClient = createValidatorClient(config, {
|
|
589
|
+
const validatorClient = await createValidatorClient(config, {
|
|
590
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
591
|
+
worldState: worldStateSynchronizer,
|
|
224
592
|
p2pClient,
|
|
225
593
|
telemetry,
|
|
226
594
|
dateProvider,
|
|
227
595
|
epochCache,
|
|
228
|
-
blockBuilder,
|
|
229
596
|
blockSource: archiver,
|
|
230
597
|
l1ToL2MessageSource: archiver,
|
|
231
598
|
keyStoreManager,
|
|
232
|
-
|
|
599
|
+
blobClient
|
|
233
600
|
});
|
|
234
601
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
235
602
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
@@ -245,7 +612,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
245
612
|
if (!validatorClient && config.alwaysReexecuteBlockProposals) {
|
|
246
613
|
log.info('Setting up block proposal reexecution for monitoring');
|
|
247
614
|
createBlockProposalHandler(config, {
|
|
248
|
-
|
|
615
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
616
|
+
worldState: worldStateSynchronizer,
|
|
249
617
|
epochCache,
|
|
250
618
|
blockSource: archiver,
|
|
251
619
|
l1ToL2MessageSource: archiver,
|
|
@@ -264,7 +632,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
264
632
|
}
|
|
265
633
|
let epochPruneWatcher;
|
|
266
634
|
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
267
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(),
|
|
635
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
268
636
|
watchers.push(epochPruneWatcher);
|
|
269
637
|
}
|
|
270
638
|
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
@@ -310,7 +678,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
310
678
|
...config,
|
|
311
679
|
l1GenesisTime,
|
|
312
680
|
slotDuration: Number(slotDuration)
|
|
313
|
-
}, archiver, dateProvider, telemetry);
|
|
681
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
314
682
|
sequencer = await SequencerClient.new(config, {
|
|
315
683
|
...deps,
|
|
316
684
|
epochCache,
|
|
@@ -395,28 +763,40 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
395
763
|
return nodeInfo;
|
|
396
764
|
}
|
|
397
765
|
/**
|
|
398
|
-
* Get a block specified by its number.
|
|
399
|
-
* @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').
|
|
400
768
|
* @returns The requested block.
|
|
401
|
-
*/ async getBlock(
|
|
402
|
-
|
|
403
|
-
|
|
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.getL2Block(blockNumber);
|
|
404
778
|
}
|
|
405
779
|
/**
|
|
406
780
|
* Get a block specified by its hash.
|
|
407
781
|
* @param blockHash - The block hash being requested.
|
|
408
782
|
* @returns The requested block.
|
|
409
783
|
*/ async getBlockByHash(blockHash) {
|
|
410
|
-
const
|
|
411
|
-
|
|
784
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
785
|
+
if (blockHash.equals(Fr.fromBuffer(initialBlockHash.toBuffer()))) {
|
|
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);
|
|
412
793
|
}
|
|
413
794
|
/**
|
|
414
795
|
* Get a block specified by its archive root.
|
|
415
796
|
* @param archive - The archive root being requested.
|
|
416
797
|
* @returns The requested block.
|
|
417
798
|
*/ async getBlockByArchive(archive) {
|
|
418
|
-
|
|
419
|
-
return publishedBlock?.block;
|
|
799
|
+
return await this.blockSource.getL2BlockByArchive(archive);
|
|
420
800
|
}
|
|
421
801
|
/**
|
|
422
802
|
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
@@ -424,16 +804,19 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
424
804
|
* @param limit - The maximum number of blocks to obtain.
|
|
425
805
|
* @returns The blocks requested.
|
|
426
806
|
*/ async getBlocks(from, limit) {
|
|
427
|
-
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) ?? [];
|
|
428
811
|
}
|
|
429
|
-
async
|
|
430
|
-
return await this.blockSource.
|
|
812
|
+
async getCheckpointedBlocks(from, limit) {
|
|
813
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
431
814
|
}
|
|
432
815
|
/**
|
|
433
|
-
* Method to fetch the current
|
|
434
|
-
* @returns The current
|
|
435
|
-
*/ async
|
|
436
|
-
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();
|
|
437
820
|
}
|
|
438
821
|
async getMaxPriorityFees() {
|
|
439
822
|
for await (const tx of this.p2pClient.iteratePendingTxs()){
|
|
@@ -453,6 +836,9 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
453
836
|
async getProvenBlockNumber() {
|
|
454
837
|
return await this.blockSource.getProvenBlockNumber();
|
|
455
838
|
}
|
|
839
|
+
async getCheckpointedBlockNumber() {
|
|
840
|
+
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
841
|
+
}
|
|
456
842
|
/**
|
|
457
843
|
* Method to fetch the version of the package.
|
|
458
844
|
* @returns The node package version
|
|
@@ -477,11 +863,31 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
477
863
|
getContract(address) {
|
|
478
864
|
return this.contractDataSource.getContract(address);
|
|
479
865
|
}
|
|
480
|
-
getPrivateLogsByTags(tags) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
866
|
+
async getPrivateLogsByTags(tags, page, referenceBlock) {
|
|
867
|
+
if (referenceBlock) {
|
|
868
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
869
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
870
|
+
const blockHashFr = Fr.fromBuffer(referenceBlock.toBuffer());
|
|
871
|
+
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
872
|
+
if (!header) {
|
|
873
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
878
|
+
}
|
|
879
|
+
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
880
|
+
if (referenceBlock) {
|
|
881
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
882
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
883
|
+
const blockHashFr = Fr.fromBuffer(referenceBlock.toBuffer());
|
|
884
|
+
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
885
|
+
if (!header) {
|
|
886
|
+
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
485
891
|
}
|
|
486
892
|
/**
|
|
487
893
|
* Gets public logs based on the provided filter.
|
|
@@ -522,18 +928,24 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
522
928
|
});
|
|
523
929
|
}
|
|
524
930
|
async getTxReceipt(txHash) {
|
|
525
|
-
|
|
526
|
-
//
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
531
|
-
}
|
|
931
|
+
// Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
|
|
932
|
+
// as a fallback if we don't find a settled receipt in the archiver.
|
|
933
|
+
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
934
|
+
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
935
|
+
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
532
936
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
533
937
|
if (settledTxReceipt) {
|
|
534
|
-
|
|
938
|
+
// If the archiver has the receipt then return it.
|
|
939
|
+
return settledTxReceipt;
|
|
940
|
+
} else if (isKnownToPool) {
|
|
941
|
+
// If the tx is in the pool but not in the archiver, it's pending.
|
|
942
|
+
// This handles race conditions between archiver and p2p, where the archiver
|
|
943
|
+
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
944
|
+
return new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
945
|
+
} else {
|
|
946
|
+
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
947
|
+
return new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
535
948
|
}
|
|
536
|
-
return txReceipt;
|
|
537
949
|
}
|
|
538
950
|
getTxEffect(txHash) {
|
|
539
951
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -555,6 +967,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
555
967
|
this.log.info(`Stopped Aztec Node`);
|
|
556
968
|
}
|
|
557
969
|
/**
|
|
970
|
+
* Returns the blob client used by this node.
|
|
971
|
+
* @internal - Exposed for testing purposes only.
|
|
972
|
+
*/ getBlobClient() {
|
|
973
|
+
return this.blobClient;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
558
976
|
* Method to retrieve pending txs.
|
|
559
977
|
* @param limit - The number of items to returns
|
|
560
978
|
* @param after - The last known pending tx. Used for pagination
|
|
@@ -579,15 +997,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
579
997
|
*/ async getTxsByHash(txHashes) {
|
|
580
998
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
581
999
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
* the leaves were inserted.
|
|
585
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data.
|
|
586
|
-
* @param treeId - The tree to search in.
|
|
587
|
-
* @param leafValues - The values to search for.
|
|
588
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
589
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
590
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1000
|
+
async findLeavesIndexes(block, treeId, leafValues) {
|
|
1001
|
+
const committedDb = await this.#getWorldState(block);
|
|
591
1002
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
592
1003
|
// We filter out undefined values
|
|
593
1004
|
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
@@ -635,45 +1046,30 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
635
1046
|
};
|
|
636
1047
|
});
|
|
637
1048
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
* @param blockNumber - The block number at which to get the data.
|
|
641
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
642
|
-
* @returns The sibling path for the leaf index.
|
|
643
|
-
*/ async getNullifierSiblingPath(blockNumber, leafIndex) {
|
|
644
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1049
|
+
async getNullifierSiblingPath(block, leafIndex) {
|
|
1050
|
+
const committedDb = await this.#getWorldState(block);
|
|
645
1051
|
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
646
1052
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
* @param blockNumber - The block number at which to get the data.
|
|
650
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
651
|
-
* @returns The sibling path for the leaf index.
|
|
652
|
-
*/ async getNoteHashSiblingPath(blockNumber, leafIndex) {
|
|
653
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1053
|
+
async getNoteHashSiblingPath(block, leafIndex) {
|
|
1054
|
+
const committedDb = await this.#getWorldState(block);
|
|
654
1055
|
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
655
1056
|
}
|
|
656
|
-
async getArchiveMembershipWitness(
|
|
657
|
-
const committedDb = await this.#getWorldState(
|
|
1057
|
+
async getArchiveMembershipWitness(block, archive) {
|
|
1058
|
+
const committedDb = await this.#getWorldState(block);
|
|
658
1059
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
659
1060
|
archive
|
|
660
1061
|
]);
|
|
661
1062
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
662
1063
|
}
|
|
663
|
-
async getNoteHashMembershipWitness(
|
|
664
|
-
const committedDb = await this.#getWorldState(
|
|
1064
|
+
async getNoteHashMembershipWitness(block, noteHash) {
|
|
1065
|
+
const committedDb = await this.#getWorldState(block);
|
|
665
1066
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
666
1067
|
noteHash
|
|
667
1068
|
]);
|
|
668
1069
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
669
1070
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
* @param blockNumber - The block number at which to get the data.
|
|
673
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
674
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
675
|
-
*/ async getL1ToL2MessageMembershipWitness(blockNumber, l1ToL2Message) {
|
|
676
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1071
|
+
async getL1ToL2MessageMembershipWitness(block, l1ToL2Message) {
|
|
1072
|
+
const db = await this.#getWorldState(block);
|
|
677
1073
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
678
1074
|
l1ToL2Message
|
|
679
1075
|
]);
|
|
@@ -699,38 +1095,37 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
699
1095
|
return messageIndex !== undefined;
|
|
700
1096
|
}
|
|
701
1097
|
/**
|
|
702
|
-
* Returns all the L2 to L1 messages in
|
|
703
|
-
* @param
|
|
704
|
-
* @returns The L2 to L1 messages (
|
|
705
|
-
*/ async getL2ToL1Messages(
|
|
706
|
-
|
|
707
|
-
|
|
1098
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
1099
|
+
* @param epoch - The epoch at which to get the data.
|
|
1100
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1101
|
+
*/ async getL2ToL1Messages(epoch) {
|
|
1102
|
+
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1103
|
+
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1104
|
+
const blocksInCheckpoints = [];
|
|
1105
|
+
let previousSlotNumber = SlotNumber.ZERO;
|
|
1106
|
+
let checkpointIndex = -1;
|
|
1107
|
+
for (const checkpointedBlock of checkpointedBlocks){
|
|
1108
|
+
const block = checkpointedBlock.block;
|
|
1109
|
+
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1110
|
+
if (slotNumber !== previousSlotNumber) {
|
|
1111
|
+
checkpointIndex++;
|
|
1112
|
+
blocksInCheckpoints.push([]);
|
|
1113
|
+
previousSlotNumber = slotNumber;
|
|
1114
|
+
}
|
|
1115
|
+
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1116
|
+
}
|
|
1117
|
+
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
708
1118
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
* @param blockNumber - The block number at which to get the data.
|
|
712
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
713
|
-
* @returns The sibling path.
|
|
714
|
-
*/ async getArchiveSiblingPath(blockNumber, leafIndex) {
|
|
715
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1119
|
+
async getArchiveSiblingPath(block, leafIndex) {
|
|
1120
|
+
const committedDb = await this.#getWorldState(block);
|
|
716
1121
|
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
717
1122
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
* @param blockNumber - The block number at which to get the data.
|
|
721
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
722
|
-
* @returns The sibling path.
|
|
723
|
-
*/ async getPublicDataSiblingPath(blockNumber, leafIndex) {
|
|
724
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1123
|
+
async getPublicDataSiblingPath(block, leafIndex) {
|
|
1124
|
+
const committedDb = await this.#getWorldState(block);
|
|
725
1125
|
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
726
1126
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
* @param blockNumber - The block number at which to get the index.
|
|
730
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
731
|
-
* @returns The nullifier membership witness (if found).
|
|
732
|
-
*/ async getNullifierMembershipWitness(blockNumber, nullifier) {
|
|
733
|
-
const db = await this.#getWorldState(blockNumber);
|
|
1127
|
+
async getNullifierMembershipWitness(block, nullifier) {
|
|
1128
|
+
const db = await this.#getWorldState(block);
|
|
734
1129
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
735
1130
|
nullifier.toBuffer()
|
|
736
1131
|
]);
|
|
@@ -746,7 +1141,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
746
1141
|
}
|
|
747
1142
|
/**
|
|
748
1143
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
749
|
-
* @param
|
|
1144
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
750
1145
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
751
1146
|
* @returns The low nullifier membership witness (if found).
|
|
752
1147
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -757,8 +1152,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
757
1152
|
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
758
1153
|
* index of the nullifier itself when it already exists in the tree.
|
|
759
1154
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
760
|
-
*/ async getLowNullifierMembershipWitness(
|
|
761
|
-
const committedDb = await this.#getWorldState(
|
|
1155
|
+
*/ async getLowNullifierMembershipWitness(block, nullifier) {
|
|
1156
|
+
const committedDb = await this.#getWorldState(block);
|
|
762
1157
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
763
1158
|
if (!findResult) {
|
|
764
1159
|
return undefined;
|
|
@@ -771,8 +1166,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
771
1166
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
772
1167
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
773
1168
|
}
|
|
774
|
-
async getPublicDataWitness(
|
|
775
|
-
const committedDb = await this.#getWorldState(
|
|
1169
|
+
async getPublicDataWitness(block, leafSlot) {
|
|
1170
|
+
const committedDb = await this.#getWorldState(block);
|
|
776
1171
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
777
1172
|
if (!lowLeafResult) {
|
|
778
1173
|
return undefined;
|
|
@@ -782,18 +1177,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
782
1177
|
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
783
1178
|
}
|
|
784
1179
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
*
|
|
788
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
789
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
790
|
-
*
|
|
791
|
-
* @param contract - Address of the contract to query.
|
|
792
|
-
* @param slot - Slot to query.
|
|
793
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
794
|
-
* @returns Storage value at the given contract slot.
|
|
795
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
796
|
-
const committedDb = await this.#getWorldState(blockNumber);
|
|
1180
|
+
async getPublicStorageAt(block, contract, slot) {
|
|
1181
|
+
const committedDb = await this.#getWorldState(block);
|
|
797
1182
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
798
1183
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
799
1184
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -802,18 +1187,23 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
802
1187
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
803
1188
|
return preimage.leaf.value;
|
|
804
1189
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
1190
|
+
async getBlockHeader(block = 'latest') {
|
|
1191
|
+
if (L2BlockHash.isL2BlockHash(block)) {
|
|
1192
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1193
|
+
if (block.equals(initialBlockHash)) {
|
|
1194
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1195
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1196
|
+
}
|
|
1197
|
+
const blockHashFr = Fr.fromBuffer(block.toBuffer());
|
|
1198
|
+
return this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1199
|
+
} else {
|
|
1200
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1201
|
+
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1202
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
1203
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1204
|
+
}
|
|
1205
|
+
return this.blockSource.getBlockHeader(block);
|
|
1206
|
+
}
|
|
817
1207
|
}
|
|
818
1208
|
/**
|
|
819
1209
|
* Get a block header specified by its archive root.
|
|
@@ -887,7 +1277,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
887
1277
|
l1ChainId: this.l1ChainId,
|
|
888
1278
|
rollupVersion: this.version,
|
|
889
1279
|
setupAllowList: this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions(),
|
|
890
|
-
gasFees: await this.
|
|
1280
|
+
gasFees: await this.getCurrentMinFees(),
|
|
891
1281
|
skipFeeEnforcement,
|
|
892
1282
|
txsPermitted: !this.config.disableTransactions
|
|
893
1283
|
});
|
|
@@ -950,7 +1340,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
950
1340
|
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
951
1341
|
}
|
|
952
1342
|
// And it has an L2 block hash
|
|
953
|
-
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.
|
|
1343
|
+
const l2BlockHash = await archiver.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
954
1344
|
if (!l2BlockHash) {
|
|
955
1345
|
this.metrics.recordSnapshotError();
|
|
956
1346
|
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
@@ -977,7 +1367,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
977
1367
|
if (!('rollbackTo' in archiver)) {
|
|
978
1368
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
979
1369
|
}
|
|
980
|
-
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.number);
|
|
1370
|
+
const finalizedBlock = await archiver.getL2Tips().then((tips)=>tips.finalized.block.number);
|
|
981
1371
|
if (targetBlock < finalizedBlock) {
|
|
982
1372
|
if (force) {
|
|
983
1373
|
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
@@ -1032,14 +1422,17 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1032
1422
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1033
1423
|
}
|
|
1034
1424
|
}
|
|
1425
|
+
#getInitialHeaderHash() {
|
|
1426
|
+
if (!this.initialHeaderHashPromise) {
|
|
1427
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1428
|
+
}
|
|
1429
|
+
return this.initialHeaderHashPromise;
|
|
1430
|
+
}
|
|
1035
1431
|
/**
|
|
1036
1432
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1037
|
-
* @param
|
|
1433
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1038
1434
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1039
|
-
*/ async #getWorldState(
|
|
1040
|
-
if (typeof blockNumber === 'number' && blockNumber < INITIAL_L2_BLOCK_NUM - 1) {
|
|
1041
|
-
throw new Error('Invalid block number to get world state for: ' + blockNumber);
|
|
1042
|
-
}
|
|
1435
|
+
*/ async #getWorldState(block) {
|
|
1043
1436
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1044
1437
|
try {
|
|
1045
1438
|
// Attempt to sync the world state if necessary
|
|
@@ -1047,15 +1440,33 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1047
1440
|
} catch (err) {
|
|
1048
1441
|
this.log.error(`Error getting world state: ${err}`);
|
|
1049
1442
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
this.log.debug(`Using committed db for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1443
|
+
if (block === 'latest') {
|
|
1444
|
+
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1053
1445
|
return this.worldStateSynchronizer.getCommitted();
|
|
1054
|
-
}
|
|
1446
|
+
}
|
|
1447
|
+
if (L2BlockHash.isL2BlockHash(block)) {
|
|
1448
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1449
|
+
if (block.equals(initialBlockHash)) {
|
|
1450
|
+
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1451
|
+
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1452
|
+
}
|
|
1453
|
+
const blockHashFr = Fr.fromBuffer(block.toBuffer());
|
|
1454
|
+
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1455
|
+
if (!header) {
|
|
1456
|
+
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.`);
|
|
1457
|
+
}
|
|
1458
|
+
const blockNumber = header.getBlockNumber();
|
|
1459
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1460
|
+
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1461
|
+
}
|
|
1462
|
+
// Block number provided
|
|
1463
|
+
{
|
|
1464
|
+
const blockNumber = block;
|
|
1465
|
+
if (blockNumber > blockSyncedTo) {
|
|
1466
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1467
|
+
}
|
|
1055
1468
|
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1056
1469
|
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1057
|
-
} else {
|
|
1058
|
-
throw new Error(`Block ${blockNumber} not yet synced`);
|
|
1059
1470
|
}
|
|
1060
1471
|
}
|
|
1061
1472
|
/**
|
|
@@ -1066,8 +1477,3 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
1066
1477
|
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1067
1478
|
}
|
|
1068
1479
|
}
|
|
1069
|
-
_ts_decorate([
|
|
1070
|
-
trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
1071
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
1072
|
-
}))
|
|
1073
|
-
], AztecNodeService.prototype, "simulatePublicCalls", null);
|