@aztec/stdlib 0.82.2 → 0.82.3
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/avm/avm.d.ts +919 -1252
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +138 -111
- package/dest/avm/avm_proving_request.d.ts +400 -575
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts +1 -0
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.js +6 -0
- package/dest/database-version/version_manager.d.ts +4 -2
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +13 -9
- package/dest/epoch-helpers/index.d.ts +2 -0
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +3 -0
- package/dest/file-store/factory.d.ts +7 -0
- package/dest/file-store/factory.d.ts.map +1 -0
- package/dest/file-store/factory.js +46 -0
- package/dest/file-store/gcs.d.ts +22 -0
- package/dest/file-store/gcs.d.ts.map +1 -0
- package/dest/file-store/gcs.js +115 -0
- package/dest/file-store/http.d.ts +15 -0
- package/dest/file-store/http.d.ts.map +1 -0
- package/dest/file-store/http.js +53 -0
- package/dest/file-store/index.d.ts +3 -0
- package/dest/file-store/index.d.ts.map +1 -0
- package/dest/file-store/index.js +2 -0
- package/dest/file-store/interface.d.ts +24 -0
- package/dest/file-store/interface.d.ts.map +1 -0
- package/dest/file-store/interface.js +1 -0
- package/dest/file-store/local.d.ts +16 -0
- package/dest/file-store/local.d.ts.map +1 -0
- package/dest/file-store/local.js +40 -0
- package/dest/interfaces/aztec-node-admin.d.ts +9 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +2 -1
- package/dest/interfaces/aztec-node.d.ts +3 -0
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/p2p.d.ts +2 -0
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +2 -1
- package/dest/interfaces/prover-node.d.ts +4 -0
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +5 -1
- package/dest/interfaces/proving-job.d.ts +400 -575
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/service.d.ts +3 -0
- package/dest/interfaces/service.d.ts.map +1 -1
- package/dest/interfaces/service.js +7 -0
- package/dest/interfaces/world_state.d.ts +13 -15
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/snapshots/download.d.ts +9 -0
- package/dest/snapshots/download.d.ts.map +1 -0
- package/dest/snapshots/download.js +37 -0
- package/dest/snapshots/index.d.ts +4 -0
- package/dest/snapshots/index.d.ts.map +1 -0
- package/dest/snapshots/index.js +3 -0
- package/dest/snapshots/types.d.ts +97 -0
- package/dest/snapshots/types.d.ts.map +1 -0
- package/dest/snapshots/types.js +27 -0
- package/dest/snapshots/upload.d.ts +5 -0
- package/dest/snapshots/upload.d.ts.map +1 -0
- package/dest/snapshots/upload.js +37 -0
- package/dest/tests/factories.d.ts +13 -7
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +37 -25
- package/dest/trees/merkle_tree_id.d.ts +8 -0
- package/dest/trees/merkle_tree_id.d.ts.map +1 -1
- package/dest/trees/merkle_tree_id.js +10 -0
- package/dest/trees/nullifier_leaf.d.ts +11 -2
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_leaf.js +12 -7
- package/dest/trees/nullifier_membership_witness.d.ts +7 -7
- package/dest/trees/public_data_leaf.d.ts +13 -0
- package/dest/trees/public_data_leaf.d.ts.map +1 -1
- package/dest/trees/public_data_leaf.js +6 -0
- package/dest/trees/public_data_witness.d.ts +7 -7
- package/dest/validators/index.d.ts +3 -0
- package/dest/validators/index.d.ts.map +1 -0
- package/dest/validators/index.js +1 -0
- package/dest/validators/schemas.d.ts +342 -0
- package/dest/validators/schemas.d.ts.map +1 -0
- package/dest/validators/schemas.js +40 -0
- package/dest/validators/types.d.ts +39 -0
- package/dest/validators/types.d.ts.map +1 -0
- package/dest/validators/types.js +1 -0
- package/package.json +11 -7
- package/src/avm/avm.ts +131 -106
- package/src/block/l2_block_downloader/l2_block_stream.ts +6 -0
- package/src/database-version/version_manager.ts +12 -8
- package/src/epoch-helpers/index.ts +8 -0
- package/src/file-store/factory.ts +61 -0
- package/src/file-store/gcs.ts +121 -0
- package/src/file-store/http.ts +58 -0
- package/src/file-store/index.ts +2 -0
- package/src/file-store/interface.ts +19 -0
- package/src/file-store/local.ts +46 -0
- package/src/interfaces/aztec-node-admin.ts +11 -1
- package/src/interfaces/aztec-node.ts +7 -0
- package/src/interfaces/p2p.ts +4 -0
- package/src/interfaces/prover-node.ts +10 -0
- package/src/interfaces/service.ts +13 -0
- package/src/interfaces/world_state.ts +17 -15
- package/src/snapshots/download.ts +60 -0
- package/src/snapshots/index.ts +3 -0
- package/src/snapshots/types.ts +58 -0
- package/src/snapshots/upload.ts +53 -0
- package/src/tests/factories.ts +74 -54
- package/src/trees/merkle_tree_id.ts +12 -0
- package/src/trees/nullifier_leaf.ts +9 -5
- package/src/trees/public_data_leaf.ts +9 -0
- package/src/validators/index.ts +3 -0
- package/src/validators/schemas.ts +53 -0
- package/src/validators/types.ts +37 -0
package/src/tests/factories.ts
CHANGED
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
import { type FieldsOf, makeHalfFullTuple, makeTuple } from '@aztec/foundation/array';
|
|
45
45
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
46
46
|
import { compact } from '@aztec/foundation/collection';
|
|
47
|
-
import { SchnorrSignature, poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
47
|
+
import { SchnorrSignature, poseidon2HashWithSeparator, sha256 } from '@aztec/foundation/crypto';
|
|
48
48
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
49
49
|
import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
50
50
|
import type { Bufferable } from '@aztec/foundation/serialize';
|
|
@@ -55,7 +55,6 @@ import { ContractStorageRead } from '../avm/contract_storage_read.js';
|
|
|
55
55
|
import { ContractStorageUpdateRequest } from '../avm/contract_storage_update_request.js';
|
|
56
56
|
import {
|
|
57
57
|
AvmAccumulatedData,
|
|
58
|
-
AvmAppendTreeHint,
|
|
59
58
|
AvmBytecodeCommitmentHint,
|
|
60
59
|
AvmCircuitInputs,
|
|
61
60
|
AvmCircuitPublicInputs,
|
|
@@ -63,10 +62,11 @@ import {
|
|
|
63
62
|
AvmContractInstanceHint,
|
|
64
63
|
AvmEnqueuedCallHint,
|
|
65
64
|
AvmExecutionHints,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
AvmGetLeafPreimageHintNullifierTree,
|
|
66
|
+
AvmGetLeafPreimageHintPublicDataTree,
|
|
67
|
+
AvmGetLeafValueHint,
|
|
68
|
+
AvmGetPreviousValueIndexHint,
|
|
69
|
+
AvmGetSiblingPathHint,
|
|
70
70
|
RevertCode,
|
|
71
71
|
} from '../avm/index.js';
|
|
72
72
|
import { PublicDataHint } from '../avm/public_data_hint.js';
|
|
@@ -144,7 +144,7 @@ import { PublicTubeData } from '../rollup/public_tube_data.js';
|
|
|
144
144
|
import { RootRollupInputs, RootRollupPublicInputs } from '../rollup/root_rollup.js';
|
|
145
145
|
import { PrivateBaseStateDiffHints } from '../rollup/state_diff_hints.js';
|
|
146
146
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
147
|
-
import { NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
|
|
147
|
+
import { NullifierLeaf, NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
|
|
148
148
|
import { PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '../trees/public_data_leaf.js';
|
|
149
149
|
import { BlockHeader } from '../tx/block_header.js';
|
|
150
150
|
import { CallContext } from '../tx/call_context.js';
|
|
@@ -990,6 +990,15 @@ export function makePublicDataTreeLeaf(seed = 0): PublicDataTreeLeaf {
|
|
|
990
990
|
return new PublicDataTreeLeaf(new Fr(seed), new Fr(seed + 1));
|
|
991
991
|
}
|
|
992
992
|
|
|
993
|
+
/**
|
|
994
|
+
* Makes arbitrary nullifier leaf.
|
|
995
|
+
* @param seed - The seed to use for generating the nullifier leaf.
|
|
996
|
+
* @returns A nullifier leaf.
|
|
997
|
+
*/
|
|
998
|
+
export function makeNullifierLeaf(seed = 0): NullifierLeaf {
|
|
999
|
+
return new NullifierLeaf(new Fr(seed));
|
|
1000
|
+
}
|
|
1001
|
+
|
|
993
1002
|
/**
|
|
994
1003
|
* Makes arbitrary public data tree leaf preimages.
|
|
995
1004
|
* @param seed - The seed to use for generating the public data tree leaf preimage.
|
|
@@ -1261,51 +1270,62 @@ export async function makeContractInstanceFromClassId(
|
|
|
1261
1270
|
}).withAddress(address);
|
|
1262
1271
|
}
|
|
1263
1272
|
|
|
1264
|
-
export function
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
export function makeAvmNullifierReadTreeHints(seed = 0): AvmNullifierReadTreeHint {
|
|
1273
|
-
const lowNullifierPreimage = new NullifierLeafPreimage(new Fr(seed), new Fr(seed + 1), BigInt(seed + 2));
|
|
1274
|
-
return new AvmNullifierReadTreeHint(
|
|
1275
|
-
lowNullifierPreimage,
|
|
1276
|
-
new Fr(seed + 1),
|
|
1277
|
-
makeArray(10, i => new Fr(i), seed + 0x1000),
|
|
1273
|
+
export function makeAvmGetSiblingPathHint(seed = 0): AvmGetSiblingPathHint {
|
|
1274
|
+
// We want a possibly large index, but non-random.
|
|
1275
|
+
const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
|
|
1276
|
+
return new AvmGetSiblingPathHint(
|
|
1277
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1278
|
+
/*treeId=*/ (seed + 1) % 5,
|
|
1279
|
+
/*index=*/ index,
|
|
1280
|
+
makeArray(seed % 64, i => new Fr(i), seed + 10),
|
|
1278
1281
|
);
|
|
1279
1282
|
}
|
|
1280
1283
|
|
|
1281
|
-
export function
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1284
|
+
export function makeAvmGetPreviousValueIndexHint(seed = 0): AvmGetPreviousValueIndexHint {
|
|
1285
|
+
// We want a possibly large index, but non-random.
|
|
1286
|
+
const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
|
|
1287
|
+
const value = new Fr(BigInt(`0x${sha256(Buffer.from((seed + 2).toString())).toString('hex')}`) % (1n << 128n));
|
|
1288
|
+
return new AvmGetPreviousValueIndexHint(
|
|
1289
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1290
|
+
/*treeId=*/ (seed + 1) % 5,
|
|
1291
|
+
value,
|
|
1292
|
+
index,
|
|
1293
|
+
/*alreadyPresent=*/ index % 2n === 0n,
|
|
1286
1294
|
);
|
|
1287
1295
|
}
|
|
1288
1296
|
|
|
1289
|
-
export function
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1297
|
+
export function makeAvmGetLeafPreimageHintPublicDataTree(seed = 0): AvmGetLeafPreimageHintPublicDataTree {
|
|
1298
|
+
// We want a possibly large index, but non-random.
|
|
1299
|
+
const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
|
|
1300
|
+
return new AvmGetLeafPreimageHintPublicDataTree(
|
|
1301
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1302
|
+
/*index=*/ index,
|
|
1303
|
+
/*leaf=*/ makePublicDataTreeLeaf(seed + 3),
|
|
1304
|
+
/*nextIndex=*/ index + 1n,
|
|
1305
|
+
/*nextValue*/ new Fr(seed + 0x500),
|
|
1293
1306
|
);
|
|
1294
1307
|
}
|
|
1295
1308
|
|
|
1296
|
-
export function
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1309
|
+
export function makeAvmGetLeafPreimageHintNullifierTree(seed = 0): AvmGetLeafPreimageHintNullifierTree {
|
|
1310
|
+
// We want a possibly large index, but non-random.
|
|
1311
|
+
const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
|
|
1312
|
+
return new AvmGetLeafPreimageHintNullifierTree(
|
|
1313
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1314
|
+
/*index=*/ index,
|
|
1315
|
+
/*leaf=*/ makeNullifierLeaf(seed + 3),
|
|
1316
|
+
/*nextIndex=*/ index + 1n,
|
|
1317
|
+
/*nextValue*/ new Fr(seed + 0x500),
|
|
1301
1318
|
);
|
|
1302
1319
|
}
|
|
1303
1320
|
|
|
1304
|
-
export function
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1321
|
+
export function makeAvmGetLeafValueHint(seed = 0): AvmGetLeafValueHint {
|
|
1322
|
+
// We want a possibly large index, but non-random.
|
|
1323
|
+
const index = BigInt(`0x${sha256(Buffer.from(seed.toString())).toString('hex')}`) % (1n << 64n);
|
|
1324
|
+
return new AvmGetLeafValueHint(
|
|
1325
|
+
makeAppendOnlyTreeSnapshot(seed),
|
|
1326
|
+
/*treeId=*/ (seed + 1) % 5,
|
|
1327
|
+
/*index=*/ index,
|
|
1328
|
+
/*value=*/ new Fr(seed + 3),
|
|
1309
1329
|
);
|
|
1310
1330
|
}
|
|
1311
1331
|
|
|
@@ -1373,13 +1393,15 @@ export async function makeAvmExecutionHints(
|
|
|
1373
1393
|
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1374
1394
|
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1375
1395
|
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1396
|
+
getSiblingPathHints: makeArray(baseLength + 5, makeAvmGetSiblingPathHint, seed + 0x4b00),
|
|
1397
|
+
getPreviousValueIndexHints: makeArray(baseLength + 5, makeAvmGetPreviousValueIndexHint, seed + 0x4d00),
|
|
1398
|
+
getLeafPreimageHintPublicDataTree: makeArray(
|
|
1399
|
+
baseLength + 5,
|
|
1400
|
+
makeAvmGetLeafPreimageHintPublicDataTree,
|
|
1401
|
+
seed + 0x4f00,
|
|
1402
|
+
),
|
|
1403
|
+
getLeafPreimageHintNullifierTree: makeArray(baseLength + 5, makeAvmGetLeafPreimageHintNullifierTree, seed + 0x5100),
|
|
1404
|
+
getLeafValueHints: makeArray(baseLength + 5, makeAvmGetLeafValueHint, seed + 0x5300),
|
|
1383
1405
|
...overrides,
|
|
1384
1406
|
};
|
|
1385
1407
|
|
|
@@ -1388,13 +1410,11 @@ export async function makeAvmExecutionHints(
|
|
|
1388
1410
|
fields.contractInstances,
|
|
1389
1411
|
fields.contractClasses,
|
|
1390
1412
|
fields.bytecodeCommitments,
|
|
1391
|
-
fields.
|
|
1392
|
-
fields.
|
|
1393
|
-
fields.
|
|
1394
|
-
fields.
|
|
1395
|
-
fields.
|
|
1396
|
-
fields.noteHashWrites,
|
|
1397
|
-
fields.l1ToL2MessageReads,
|
|
1413
|
+
fields.getSiblingPathHints,
|
|
1414
|
+
fields.getPreviousValueIndexHints,
|
|
1415
|
+
fields.getLeafPreimageHintPublicDataTree,
|
|
1416
|
+
fields.getLeafPreimageHintNullifierTree,
|
|
1417
|
+
fields.getLeafValueHints,
|
|
1398
1418
|
);
|
|
1399
1419
|
}
|
|
1400
1420
|
|
|
@@ -40,3 +40,15 @@ export type TreeHeights = typeof TREE_HEIGHTS;
|
|
|
40
40
|
export function getTreeHeight<TID extends MerkleTreeId>(treeId: TID): TreeHeights[TID] {
|
|
41
41
|
return TREE_HEIGHTS[treeId];
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
const TREE_NAMES = {
|
|
45
|
+
[MerkleTreeId.NULLIFIER_TREE]: 'NULLIFIER_TREE' as const,
|
|
46
|
+
[MerkleTreeId.NOTE_HASH_TREE]: 'NOTE_HASH_TREE' as const,
|
|
47
|
+
[MerkleTreeId.PUBLIC_DATA_TREE]: 'PUBLIC_DATA_TREE' as const,
|
|
48
|
+
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: 'L1_TO_L2_MESSAGE_TREE' as const,
|
|
49
|
+
[MerkleTreeId.ARCHIVE]: 'ARCHIVE' as const,
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
export function getTreeName<TID extends MerkleTreeId>(treeId: TID): (typeof TREE_NAMES)[TID] {
|
|
53
|
+
return TREE_NAMES[treeId];
|
|
54
|
+
}
|
|
@@ -88,7 +88,7 @@ export class NullifierLeafPreimage implements IndexedTreeLeafPreimage {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
static fromLeaf(leaf: NullifierLeaf, nextKey: bigint, nextIndex: bigint): NullifierLeafPreimage {
|
|
91
|
-
return new NullifierLeafPreimage(leaf.
|
|
91
|
+
return new NullifierLeafPreimage(leaf.value, new Fr(nextKey), nextIndex);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
static clone(preimage: NullifierLeafPreimage): NullifierLeafPreimage {
|
|
@@ -104,19 +104,19 @@ export class NullifierLeaf implements IndexedTreeLeaf {
|
|
|
104
104
|
/**
|
|
105
105
|
* Nullifier value.
|
|
106
106
|
*/
|
|
107
|
-
public
|
|
107
|
+
public value: Fr,
|
|
108
108
|
) {}
|
|
109
109
|
|
|
110
110
|
getKey(): bigint {
|
|
111
|
-
return this.
|
|
111
|
+
return this.value.toBigInt();
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
toBuffer(): Buffer {
|
|
115
|
-
return this.
|
|
115
|
+
return this.value.toBuffer();
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
isEmpty(): boolean {
|
|
119
|
-
return this.
|
|
119
|
+
return this.value.isZero();
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
updateTo(_another: NullifierLeaf): NullifierLeaf {
|
|
@@ -130,4 +130,8 @@ export class NullifierLeaf implements IndexedTreeLeaf {
|
|
|
130
130
|
static fromBuffer(buf: Buffer): NullifierLeaf {
|
|
131
131
|
return new NullifierLeaf(Fr.fromBuffer(buf));
|
|
132
132
|
}
|
|
133
|
+
|
|
134
|
+
static get schema() {
|
|
135
|
+
return z.object({ value: schemas.Fr }).transform(({ value }) => new NullifierLeaf(value));
|
|
136
|
+
}
|
|
133
137
|
}
|
|
@@ -161,4 +161,13 @@ export class PublicDataTreeLeaf implements IndexedTreeLeaf {
|
|
|
161
161
|
static empty(): PublicDataTreeLeaf {
|
|
162
162
|
return new PublicDataTreeLeaf(Fr.ZERO, Fr.ZERO);
|
|
163
163
|
}
|
|
164
|
+
|
|
165
|
+
static get schema() {
|
|
166
|
+
return z
|
|
167
|
+
.object({
|
|
168
|
+
slot: schemas.Fr,
|
|
169
|
+
value: schemas.Fr,
|
|
170
|
+
})
|
|
171
|
+
.transform(({ slot, value }) => new PublicDataTreeLeaf(slot, value));
|
|
172
|
+
}
|
|
164
173
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import type { ValidatorStats, ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorsStats } from './types.js';
|
|
6
|
+
|
|
7
|
+
export const ValidatorStatusInSlotSchema = z.enum([
|
|
8
|
+
'block-mined',
|
|
9
|
+
'block-proposed',
|
|
10
|
+
'block-missed',
|
|
11
|
+
'attestation-sent',
|
|
12
|
+
'attestation-missed',
|
|
13
|
+
]) satisfies ZodFor<ValidatorStatusInSlot>;
|
|
14
|
+
|
|
15
|
+
export const ValidatorStatusHistorySchema = z.array(
|
|
16
|
+
z.object({
|
|
17
|
+
slot: schemas.BigInt,
|
|
18
|
+
status: ValidatorStatusInSlotSchema,
|
|
19
|
+
}),
|
|
20
|
+
) satisfies ZodFor<ValidatorStatusHistory>;
|
|
21
|
+
|
|
22
|
+
export const ValidatorStatusHistorySchemaArray = z.array(ValidatorStatusHistorySchema);
|
|
23
|
+
|
|
24
|
+
export const ValidatorStatusHistorySchemaMap = z.record(ValidatorStatusHistorySchemaArray);
|
|
25
|
+
|
|
26
|
+
const ValidatorTimeStatSchema = z.object({
|
|
27
|
+
timestamp: schemas.BigInt,
|
|
28
|
+
slot: schemas.BigInt,
|
|
29
|
+
date: z.string(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const ValidatorFilteredHistorySchema = z.object({
|
|
33
|
+
currentStreak: schemas.Integer,
|
|
34
|
+
rate: z.number(),
|
|
35
|
+
count: schemas.Integer,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const ValidatorStatsSchema = z.object({
|
|
39
|
+
address: schemas.EthAddress,
|
|
40
|
+
lastProposal: ValidatorTimeStatSchema.optional(),
|
|
41
|
+
lastAttestation: ValidatorTimeStatSchema.optional(),
|
|
42
|
+
totalSlots: schemas.Integer,
|
|
43
|
+
missedProposals: ValidatorFilteredHistorySchema,
|
|
44
|
+
missedAttestations: ValidatorFilteredHistorySchema,
|
|
45
|
+
history: ValidatorStatusHistorySchema,
|
|
46
|
+
}) satisfies ZodFor<ValidatorStats>;
|
|
47
|
+
|
|
48
|
+
export const ValidatorsStatsSchema = z.object({
|
|
49
|
+
stats: z.record(ValidatorStatsSchema),
|
|
50
|
+
lastProcessedSlot: schemas.BigInt.optional(),
|
|
51
|
+
initialSlot: schemas.BigInt.optional(),
|
|
52
|
+
slotWindow: schemas.Integer,
|
|
53
|
+
}) satisfies ZodFor<ValidatorsStats>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
|
|
3
|
+
export type ValidatorStatusType = 'block' | 'attestation';
|
|
4
|
+
|
|
5
|
+
export type ValidatorStatusInSlot =
|
|
6
|
+
| 'block-mined'
|
|
7
|
+
| 'block-proposed'
|
|
8
|
+
| 'block-missed'
|
|
9
|
+
| 'attestation-sent'
|
|
10
|
+
| 'attestation-missed';
|
|
11
|
+
|
|
12
|
+
export type ValidatorStatusHistory = { slot: bigint; status: ValidatorStatusInSlot }[];
|
|
13
|
+
|
|
14
|
+
export type ValidatorStats = {
|
|
15
|
+
address: EthAddress;
|
|
16
|
+
lastProposal?: { timestamp: bigint; slot: bigint; date: string };
|
|
17
|
+
lastAttestation?: { timestamp: bigint; slot: bigint; date: string };
|
|
18
|
+
totalSlots: number;
|
|
19
|
+
missedProposals: {
|
|
20
|
+
currentStreak: number;
|
|
21
|
+
rate: number;
|
|
22
|
+
count: number;
|
|
23
|
+
};
|
|
24
|
+
missedAttestations: {
|
|
25
|
+
currentStreak: number;
|
|
26
|
+
rate: number;
|
|
27
|
+
count: number;
|
|
28
|
+
};
|
|
29
|
+
history: ValidatorStatusHistory;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ValidatorsStats = {
|
|
33
|
+
stats: Record<string, ValidatorStats>;
|
|
34
|
+
lastProcessedSlot?: bigint;
|
|
35
|
+
initialSlot?: bigint;
|
|
36
|
+
slotWindow: number;
|
|
37
|
+
};
|