@aztec/aztec-node 0.87.1 → 0.87.2-nightly.20250524
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 +2 -1
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +2 -0
- package/dest/aztec-node/server.d.ts +13 -7
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +93 -56
- package/dest/sentinel/factory.d.ts +2 -1
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +18 -5
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +101 -14
- package/dest/sentinel/store.d.ts +13 -3
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +73 -6
- package/package.json +23 -22
- package/src/aztec-node/config.ts +4 -1
- package/src/aztec-node/server.ts +117 -65
- package/src/sentinel/factory.ts +3 -2
- package/src/sentinel/sentinel.ts +114 -6
- package/src/sentinel/store.ts +83 -7
|
@@ -6,6 +6,7 @@ import { type SharedNodeConfig } from '@aztec/node-lib/config';
|
|
|
6
6
|
import { type P2PConfig } from '@aztec/p2p/config';
|
|
7
7
|
import { type ProverClientUserConfig } from '@aztec/prover-client/config';
|
|
8
8
|
import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
9
|
+
import { type SlasherConfig } from '@aztec/slasher';
|
|
9
10
|
import { type NodeRPCConfig } from '@aztec/stdlib/config';
|
|
10
11
|
import { type ValidatorClientConfig } from '@aztec/validator-client/config';
|
|
11
12
|
import { type WorldStateConfig } from '@aztec/world-state/config';
|
|
@@ -14,7 +15,7 @@ export { sequencerClientConfigMappings, type SequencerClientConfig };
|
|
|
14
15
|
/**
|
|
15
16
|
* The configuration the aztec node.
|
|
16
17
|
*/
|
|
17
|
-
export type AztecNodeConfig = ArchiverConfig & SequencerClientConfig & ValidatorClientConfig & ProverClientUserConfig & WorldStateConfig & Pick<ProverClientUserConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> & P2PConfig & DataStoreConfig & SentinelConfig & SharedNodeConfig & GenesisStateConfig & NodeRPCConfig & {
|
|
18
|
+
export type AztecNodeConfig = ArchiverConfig & SequencerClientConfig & ValidatorClientConfig & ProverClientUserConfig & WorldStateConfig & Pick<ProverClientUserConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> & P2PConfig & DataStoreConfig & SentinelConfig & SharedNodeConfig & GenesisStateConfig & NodeRPCConfig & SlasherConfig & {
|
|
18
19
|
/** L1 contracts addresses */
|
|
19
20
|
l1Contracts: L1ContractAddresses;
|
|
20
21
|
/** Whether the validator is disabled for this node */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/aztec-node/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,wBAAwB,CAAC;AACrF,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAGzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,kBAAkB,EAA8C,MAAM,0BAA0B,CAAC;AAC/G,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,KAAK,sBAAsB,EAA8B,MAAM,6BAA6B,CAAC;AACtG,OAAO,EAAE,KAAK,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC3G,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,KAAK,qBAAqB,EAAiC,MAAM,gCAAgC,CAAC;AAC3G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gB,CAAC;AAC3E,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,KAAK,qBAAqB,EAAiC,MAAM,gCAAgC,CAAC;AAC3G,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,2BAA2B,CAAC;AAE5F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,uBAAuB,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,KAAK,qBAAqB,EAAE,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAC1C,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,gBAAgB,GAChB,IAAI,CAAC,sBAAsB,EAAE,cAAc,GAAG,oBAAoB,GAAG,YAAY,CAAC,GAClF,SAAS,GACT,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,aAAa,GACb,aAAa,GAAG;IACd,6BAA6B;IAC7B,WAAW,EAAE,mBAAmB,CAAC;IACjC,sDAAsD;IACtD,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEJ,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,eAAe,CAsBvE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAElD"}
|
|
@@ -6,6 +6,7 @@ import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
|
6
6
|
import { p2pConfigMappings } from '@aztec/p2p/config';
|
|
7
7
|
import { proverClientConfigMappings } from '@aztec/prover-client/config';
|
|
8
8
|
import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
9
|
+
import { slasherConfigMappings } from '@aztec/slasher';
|
|
9
10
|
import { nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
10
11
|
import { validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
11
12
|
import { worldStateConfigMappings } from '@aztec/world-state/config';
|
|
@@ -23,6 +24,7 @@ export const aztecNodeConfigMappings = {
|
|
|
23
24
|
...sharedNodeConfigMappings,
|
|
24
25
|
...genesisStateConfigMappings,
|
|
25
26
|
...nodeRpcConfigMappings,
|
|
27
|
+
...slasherConfigMappings,
|
|
26
28
|
l1Contracts: {
|
|
27
29
|
description: 'The deployed L1 contract addresses',
|
|
28
30
|
nested: l1ContractAddressesMapping
|
|
@@ -218,14 +218,20 @@ export declare class AztecNodeService implements AztecNode, AztecNodeAdmin, Trac
|
|
|
218
218
|
*/
|
|
219
219
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
|
|
220
220
|
/**
|
|
221
|
-
* Returns the index
|
|
222
|
-
* @remarks
|
|
223
|
-
*
|
|
224
|
-
* The tree is
|
|
221
|
+
* Returns the index and sibling path for a L2->L1 message in a block's message tree.
|
|
222
|
+
* @remarks The message tree is constructed on-demand by taking all L2->L1 messages in a block
|
|
223
|
+
* and creating a variable depth append-only tree with the messages as leaves.
|
|
224
|
+
* The tree is constructed in two layers:
|
|
225
|
+
* 1. Subtree - For each transaction in the block, a subtree is created containing all L2->L1 messages from that
|
|
226
|
+
* transaction.
|
|
227
|
+
* 2. Top tree - A tree containing the roots of all the subtrees as leaves
|
|
228
|
+
* The final path is constructed by concatenating the path in the subtree with the path in the top tree.
|
|
229
|
+
* When there is only one transaction in the block, the subtree itself becomes the block's L2->L1 message tree,
|
|
230
|
+
* and no top tree is needed. The out hash is the root of the the block's L2->L1 message tree.
|
|
225
231
|
* TODO: Handle the case where two messages in the same tx have the same hash.
|
|
226
|
-
* @param blockNumber -
|
|
227
|
-
* @param l2ToL1Message -
|
|
228
|
-
* @returns
|
|
232
|
+
* @param blockNumber - Block number to get data from
|
|
233
|
+
* @param l2ToL1Message - Message to get index/path for
|
|
234
|
+
* @returns [index, siblingPath] for the message
|
|
229
235
|
*/
|
|
230
236
|
getL2ToL1MessageMembershipWitness(blockNumber: L2BlockNumber, l2ToL1Message: Fr): Promise<[bigint, SiblingPath<number>]>;
|
|
231
237
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/aztec-node/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/aztec-node/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAS,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,OAAO,EAAE,KAAK,GAAG,EAAoD,MAAM,YAAY,CAAC;AAExF,OAAO,EAEL,eAAe,EACf,KAAK,kBAAkB,EAExB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,Q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AAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC/D,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAMhC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CA6CnC"}
|
|
@@ -9,7 +9,8 @@ import { BBCircuitVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
|
9
9
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
10
10
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
11
11
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
12
|
-
import { RegistryContract, createEthereumChain } from '@aztec/ethereum';
|
|
12
|
+
import { RegistryContract, createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
13
|
+
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
13
14
|
import { compactArray } from '@aztec/foundation/collection';
|
|
14
15
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
16
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -25,8 +26,9 @@ import { SHA256Trunc, StandardTree, UnbalancedTree } from '@aztec/merkle-tree';
|
|
|
25
26
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
26
27
|
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
27
28
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
28
|
-
import { GlobalVariableBuilder, SequencerClient,
|
|
29
|
+
import { GlobalVariableBuilder, SequencerClient, createValidatorForAcceptingTxs } from '@aztec/sequencer-client';
|
|
29
30
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
31
|
+
import { EpochPruneWatcher, SlasherClient } from '@aztec/slasher';
|
|
30
32
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
33
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
32
34
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
@@ -125,6 +127,8 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
125
127
|
...config.l1Contracts,
|
|
126
128
|
...l1ContractsAddresses
|
|
127
129
|
};
|
|
130
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, config.publisherPrivateKey, ethereumChain.chainInfo);
|
|
131
|
+
const l1TxUtils = new L1TxUtilsWithBlobs(l1Client, log, config);
|
|
128
132
|
const rollup = getContract({
|
|
129
133
|
address: l1ContractsAddresses.rollupAddress.toString(),
|
|
130
134
|
abi: RollupAbi,
|
|
@@ -155,8 +159,15 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
155
159
|
await worldStateSynchronizer.start();
|
|
156
160
|
// Start p2p. Note that it depends on world state to be running.
|
|
157
161
|
await p2pClient.start();
|
|
158
|
-
const
|
|
159
|
-
|
|
162
|
+
const watchers = [];
|
|
163
|
+
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
164
|
+
if (validatorsSentinel) {
|
|
165
|
+
watchers.push(validatorsSentinel);
|
|
166
|
+
}
|
|
167
|
+
const epochPruneWatcher = new EpochPruneWatcher(archiver, epochCache, config.slashPrunePenalty);
|
|
168
|
+
watchers.push(epochPruneWatcher);
|
|
169
|
+
const slasherClient = await SlasherClient.new(config, config.l1Contracts, l1TxUtils, watchers, dateProvider);
|
|
170
|
+
await slasherClient.start();
|
|
160
171
|
const validatorClient = createValidatorClient(config, {
|
|
161
172
|
p2pClient,
|
|
162
173
|
telemetry,
|
|
@@ -164,12 +175,14 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
164
175
|
epochCache,
|
|
165
176
|
blockSource: archiver
|
|
166
177
|
});
|
|
167
|
-
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
168
|
-
await validatorsSentinel?.start();
|
|
169
178
|
log.verbose(`All Aztec Node subsystems synced`);
|
|
170
179
|
// now create the sequencer
|
|
171
180
|
const sequencer = config.disableValidator ? undefined : await SequencerClient.new(config, {
|
|
181
|
+
// if deps were provided, they should override the defaults,
|
|
182
|
+
// or things that we created in this function
|
|
172
183
|
...deps,
|
|
184
|
+
epochCache,
|
|
185
|
+
l1TxUtils,
|
|
173
186
|
validatorClient,
|
|
174
187
|
p2pClient,
|
|
175
188
|
worldStateSynchronizer,
|
|
@@ -365,7 +378,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
365
378
|
*/ async stop() {
|
|
366
379
|
this.log.info(`Stopping`);
|
|
367
380
|
await this.txQueue.end();
|
|
368
|
-
await this.validatorsSentinel?.stop();
|
|
381
|
+
// await this.validatorsSentinel?.stop(); <- The slasher client will stop this
|
|
369
382
|
await this.sequencer?.stop();
|
|
370
383
|
await this.p2pClient.stop();
|
|
371
384
|
await this.worldStateSynchronizer.stop();
|
|
@@ -495,65 +508,89 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
495
508
|
return await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message) !== undefined;
|
|
496
509
|
}
|
|
497
510
|
/**
|
|
498
|
-
* Returns the index
|
|
499
|
-
* @remarks
|
|
500
|
-
*
|
|
501
|
-
* The tree is
|
|
511
|
+
* Returns the index and sibling path for a L2->L1 message in a block's message tree.
|
|
512
|
+
* @remarks The message tree is constructed on-demand by taking all L2->L1 messages in a block
|
|
513
|
+
* and creating a variable depth append-only tree with the messages as leaves.
|
|
514
|
+
* The tree is constructed in two layers:
|
|
515
|
+
* 1. Subtree - For each transaction in the block, a subtree is created containing all L2->L1 messages from that
|
|
516
|
+
* transaction.
|
|
517
|
+
* 2. Top tree - A tree containing the roots of all the subtrees as leaves
|
|
518
|
+
* The final path is constructed by concatenating the path in the subtree with the path in the top tree.
|
|
519
|
+
* When there is only one transaction in the block, the subtree itself becomes the block's L2->L1 message tree,
|
|
520
|
+
* and no top tree is needed. The out hash is the root of the the block's L2->L1 message tree.
|
|
502
521
|
* TODO: Handle the case where two messages in the same tx have the same hash.
|
|
503
|
-
* @param blockNumber -
|
|
504
|
-
* @param l2ToL1Message -
|
|
505
|
-
* @returns
|
|
522
|
+
* @param blockNumber - Block number to get data from
|
|
523
|
+
* @param l2ToL1Message - Message to get index/path for
|
|
524
|
+
* @returns [index, siblingPath] for the message
|
|
506
525
|
*/ async getL2ToL1MessageMembershipWitness(blockNumber, l2ToL1Message) {
|
|
507
526
|
const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber);
|
|
508
527
|
if (block === undefined) {
|
|
509
|
-
throw new Error('Block
|
|
510
|
-
}
|
|
511
|
-
const
|
|
512
|
-
// Find index of message
|
|
513
|
-
let
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
528
|
+
throw new Error('Block not found in getL2ToL1MessageMembershipWitness');
|
|
529
|
+
}
|
|
530
|
+
const messagesPerTx = block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
531
|
+
// Find index of message in subtree and index of tx in a block
|
|
532
|
+
let messageIndexInTx = -1, txIndex = -1;
|
|
533
|
+
{
|
|
534
|
+
txIndex = messagesPerTx.findIndex((messages)=>{
|
|
535
|
+
const idx = messages.findIndex((msg)=>msg.equals(l2ToL1Message));
|
|
536
|
+
messageIndexInTx = Math.max(messageIndexInTx, idx);
|
|
537
|
+
return idx !== -1;
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if (txIndex === -1) {
|
|
520
541
|
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
521
542
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
543
|
+
// Get the message path in subtree and message subtree height
|
|
544
|
+
let messagePathInSubtree;
|
|
545
|
+
let messageSubtreeHeight;
|
|
546
|
+
{
|
|
547
|
+
const subtreeStore = openTmpStore(true);
|
|
548
|
+
const txMessages = messagesPerTx[txIndex];
|
|
549
|
+
messageSubtreeHeight = txMessages.length <= 1 ? 1 : Math.ceil(Math.log2(txMessages.length));
|
|
550
|
+
const subtree = new StandardTree(subtreeStore, new SHA256Trunc(), `subtree_${txIndex}`, messageSubtreeHeight, 0n, Fr);
|
|
551
|
+
subtree.appendLeaves(txMessages);
|
|
552
|
+
messagePathInSubtree = await subtree.getSiblingPath(BigInt(messageIndexInTx), true);
|
|
553
|
+
await subtreeStore.delete();
|
|
554
|
+
}
|
|
555
|
+
// If the number of txs is 1 we are dealing with a special case where the tx subtree itself is the whole block's
|
|
556
|
+
// l2 to l1 message tree.
|
|
557
|
+
const numTransactions = block.body.txEffects.length;
|
|
558
|
+
if (numTransactions === 1) {
|
|
536
559
|
return [
|
|
537
|
-
BigInt(
|
|
538
|
-
|
|
560
|
+
BigInt(messageIndexInTx),
|
|
561
|
+
messagePathInSubtree
|
|
539
562
|
];
|
|
540
563
|
}
|
|
541
|
-
//
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
564
|
+
// Calculate roots for all tx subtrees
|
|
565
|
+
const txSubtreeRoots = await Promise.all(messagesPerTx.map(async (messages, txIdx)=>{
|
|
566
|
+
// For a tx with no messages, we have to set an out hash of 0 to match what the circuit does.
|
|
567
|
+
if (messages.length === 0) {
|
|
568
|
+
return Fr.ZERO;
|
|
569
|
+
}
|
|
570
|
+
const txStore = openTmpStore(true);
|
|
571
|
+
const txTreeHeight = messages.length <= 1 ? 1 : Math.ceil(Math.log2(messages.length));
|
|
572
|
+
const txTree = new StandardTree(txStore, new SHA256Trunc(), `tx_messages_subtree_${txIdx}`, txTreeHeight, 0n, Fr);
|
|
573
|
+
txTree.appendLeaves(messages);
|
|
574
|
+
const root = Fr.fromBuffer(txTree.getRoot(true));
|
|
575
|
+
await txStore.delete();
|
|
576
|
+
return root;
|
|
577
|
+
}));
|
|
578
|
+
// Construct the top tree and compute the combined path
|
|
579
|
+
let combinedPath;
|
|
580
|
+
{
|
|
581
|
+
const topTreeHeight = Math.ceil(Math.log2(txSubtreeRoots.length));
|
|
582
|
+
// The root of this tree is the out_hash calculated in Noir => we truncate to match Noir's SHA
|
|
583
|
+
const topTree = new UnbalancedTree(new SHA256Trunc(), 'top_tree', topTreeHeight, Fr);
|
|
584
|
+
await topTree.appendLeaves(txSubtreeRoots);
|
|
585
|
+
const txPathInTopTree = await topTree.getSiblingPath(txSubtreeRoots[txIndex].toBigInt());
|
|
586
|
+
// Append subtree path to top tree path
|
|
587
|
+
combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
|
|
588
|
+
}
|
|
589
|
+
// Append binary index of subtree path to binary index of top tree path
|
|
590
|
+
const combinedIndex = parseInt(txIndex.toString(2).concat(messageIndexInTx.toString(2).padStart(messageSubtreeHeight, '0')), 2);
|
|
554
591
|
return [
|
|
555
|
-
BigInt(
|
|
556
|
-
new SiblingPath(
|
|
592
|
+
BigInt(combinedIndex),
|
|
593
|
+
new SiblingPath(combinedPath.length, combinedPath)
|
|
557
594
|
];
|
|
558
595
|
}
|
|
559
596
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
2
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
3
|
import type { P2PClient } from '@aztec/p2p';
|
|
4
|
+
import type { SlasherConfig } from '@aztec/slasher/config';
|
|
4
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
6
|
import type { SentinelConfig } from './config.js';
|
|
6
7
|
import { Sentinel } from './sentinel.js';
|
|
7
|
-
export declare function createSentinel(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, config: SentinelConfig & DataStoreConfig, logger?: import("@aztec/foundation/log").Logger): Promise<Sentinel | undefined>;
|
|
8
|
+
export declare function createSentinel(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, config: SentinelConfig & DataStoreConfig & SlasherConfig, logger?: import("@aztec/foundation/log").Logger): Promise<Sentinel | undefined>;
|
|
8
9
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAa/B"}
|
package/dest/sentinel/factory.js
CHANGED
|
@@ -11,5 +11,5 @@ export async function createSentinel(epochCache, archiver, p2p, config, logger =
|
|
|
11
11
|
const sentinelStore = new SentinelStore(kvStore, {
|
|
12
12
|
historyLength: storeHistoryLength
|
|
13
13
|
});
|
|
14
|
-
return new Sentinel(epochCache, archiver, p2p, sentinelStore, logger);
|
|
14
|
+
return new Sentinel(epochCache, archiver, p2p, sentinelStore, config, logger);
|
|
15
15
|
}
|
|
@@ -3,14 +3,18 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
4
4
|
import { type L2TipsStore } from '@aztec/kv-store/stores';
|
|
5
5
|
import type { P2PClient } from '@aztec/p2p';
|
|
6
|
+
import type { SlasherConfig, Watcher, WatcherEmitter } from '@aztec/slasher/config';
|
|
7
|
+
import { Offence } from '@aztec/slasher/config';
|
|
6
8
|
import { type L2BlockSource, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
7
|
-
import type { ValidatorStats, ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorStatusType, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
9
|
+
import type { ValidatorStats, ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorStatusType, ValidatorsEpochPerformance, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
8
10
|
import { SentinelStore } from './store.js';
|
|
9
|
-
|
|
11
|
+
declare const Sentinel_base: new () => WatcherEmitter;
|
|
12
|
+
export declare class Sentinel extends Sentinel_base implements L2BlockStreamEventHandler, Watcher {
|
|
10
13
|
protected epochCache: EpochCache;
|
|
11
14
|
protected archiver: L2BlockSource;
|
|
12
15
|
protected p2p: P2PClient;
|
|
13
16
|
protected store: SentinelStore;
|
|
17
|
+
protected config: Pick<SlasherConfig, 'slashInactivityCreateTargetPercentage' | 'slashInactivityCreatePenalty' | 'slashInactivitySignalTargetPercentage' | 'slashPayloadTtlSeconds'>;
|
|
14
18
|
protected logger: import("@aztec/foundation/log").Logger;
|
|
15
19
|
protected runningPromise: RunningPromise;
|
|
16
20
|
protected blockStream: L2BlockStream;
|
|
@@ -22,12 +26,17 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
22
26
|
archive: string;
|
|
23
27
|
attestors: EthAddress[];
|
|
24
28
|
}>;
|
|
25
|
-
constructor(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, store: SentinelStore, logger?: import("@aztec/foundation/log").Logger);
|
|
29
|
+
constructor(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, store: SentinelStore, config: Pick<SlasherConfig, 'slashInactivityCreateTargetPercentage' | 'slashInactivityCreatePenalty' | 'slashInactivitySignalTargetPercentage' | 'slashPayloadTtlSeconds'>, logger?: import("@aztec/foundation/log").Logger);
|
|
26
30
|
start(): Promise<void>;
|
|
27
31
|
/** Loads initial slot and initializes blockstream. We will not process anything at or before the initial slot. */
|
|
28
32
|
protected init(): Promise<void>;
|
|
29
33
|
stop(): Promise<void>;
|
|
30
34
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
35
|
+
protected handleChainProven(event: L2BlockStreamEvent): Promise<void>;
|
|
36
|
+
protected computeProvenPerformance(epoch: bigint): Promise<ValidatorsEpochPerformance>;
|
|
37
|
+
protected updateProvenPerformance(epoch: bigint, performance: ValidatorsEpochPerformance): Promise<void>;
|
|
38
|
+
protected handleProvenPerformance(performance: ValidatorsEpochPerformance): void;
|
|
39
|
+
shouldSlash(validator: `0x${string}`, _amount: bigint, _offense: Offence): Promise<boolean>;
|
|
31
40
|
/**
|
|
32
41
|
* Process data for two L2 slots ago.
|
|
33
42
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
@@ -52,8 +61,11 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
52
61
|
/** Push the status for each slot for each validator. */
|
|
53
62
|
protected updateValidators(slot: bigint, stats: Record<`0x${string}`, ValidatorStatusInSlot | undefined>): Promise<void>;
|
|
54
63
|
/** Computes stats to be returned based on stored data. */
|
|
55
|
-
computeStats(
|
|
56
|
-
|
|
64
|
+
computeStats({ fromSlot: _fromSlot, toSlot: _toSlot, }?: {
|
|
65
|
+
fromSlot?: bigint;
|
|
66
|
+
toSlot?: bigint;
|
|
67
|
+
}): Promise<ValidatorsStats>;
|
|
68
|
+
protected computeStatsForValidator(address: `0x${string}`, allHistory: ValidatorStatusHistory, fromSlot?: bigint, toSlot?: bigint): ValidatorStats;
|
|
57
69
|
protected computeMissed(history: ValidatorStatusHistory, computeOverPrefix: ValidatorStatusType, filter: ValidatorStatusInSlot): {
|
|
58
70
|
currentStreak: number;
|
|
59
71
|
rate: number | undefined;
|
|
@@ -65,4 +77,5 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
65
77
|
date: string;
|
|
66
78
|
} | undefined;
|
|
67
79
|
}
|
|
80
|
+
export {};
|
|
68
81
|
//# sourceMappingURL=sentinel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/sentinel/sentinel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO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AIG;IACU,IAAI;IAmBjB;;;;OAIG;cACa,gBAAgB,CAAC,WAAW,EAAE,MAAM;IAkCpD;;;OAGG;cACa,WAAW,CAAC,IAAI,EAAE,MAAM;IAexC,0CAA0C;cAC1B,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE;;;IAwD1G,wDAAwD;IACxD,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAIxG,0DAA0D;IAC7C,YAAY,CAAC,EACxB,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,OAAO,GAChB,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBzE,SAAS,CAAC,wBAAwB,CAChC,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,UAAU,EAAE,sBAAsB,EAClC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,cAAc;IAgBjB,SAAS,CAAC,aAAa,CACrB,OAAO,EAAE,sBAAsB,EAC/B,iBAAiB,EAAE,mBAAmB,EACtC,MAAM,EAAE,qBAAqB;;;;;IAW/B,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;;;;;CAOnD"}
|
|
@@ -3,13 +3,16 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
5
|
import { L2TipsMemoryStore } from '@aztec/kv-store/stores';
|
|
6
|
+
import { Offence, WANT_TO_SLASH_EVENT } from '@aztec/slasher/config';
|
|
6
7
|
import { L2BlockStream, getAttestationsFromPublishedL2Block } from '@aztec/stdlib/block';
|
|
7
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
8
|
-
|
|
8
|
+
import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
9
|
+
import EventEmitter from 'node:events';
|
|
10
|
+
export class Sentinel extends EventEmitter {
|
|
9
11
|
epochCache;
|
|
10
12
|
archiver;
|
|
11
13
|
p2p;
|
|
12
14
|
store;
|
|
15
|
+
config;
|
|
13
16
|
logger;
|
|
14
17
|
runningPromise;
|
|
15
18
|
blockStream;
|
|
@@ -17,13 +20,8 @@ export class Sentinel {
|
|
|
17
20
|
initialSlot;
|
|
18
21
|
lastProcessedSlot;
|
|
19
22
|
slotNumberToBlock;
|
|
20
|
-
constructor(epochCache, archiver, p2p, store, logger = createLogger('node:sentinel')){
|
|
21
|
-
this.epochCache = epochCache;
|
|
22
|
-
this.archiver = archiver;
|
|
23
|
-
this.p2p = p2p;
|
|
24
|
-
this.store = store;
|
|
25
|
-
this.logger = logger;
|
|
26
|
-
this.slotNumberToBlock = new Map();
|
|
23
|
+
constructor(epochCache, archiver, p2p, store, config, logger = createLogger('node:sentinel')){
|
|
24
|
+
super(), this.epochCache = epochCache, this.archiver = archiver, this.p2p = p2p, this.store = store, this.config = config, this.logger = logger, this.slotNumberToBlock = new Map();
|
|
27
25
|
this.l2TipsStore = new L2TipsMemoryStore();
|
|
28
26
|
const interval = epochCache.getL1Constants().ethereumSlotDuration * 1000 / 4;
|
|
29
27
|
this.runningPromise = new RunningPromise(this.work.bind(this), logger, interval);
|
|
@@ -62,8 +60,95 @@ export class Sentinel {
|
|
|
62
60
|
this.slotNumberToBlock.delete(key);
|
|
63
61
|
}
|
|
64
62
|
}
|
|
63
|
+
} else if (event.type === 'chain-proven') {
|
|
64
|
+
await this.handleChainProven(event);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
async handleChainProven(event) {
|
|
68
|
+
if (event.type !== 'chain-proven') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const blockNumber = event.block.number;
|
|
72
|
+
const block = await this.archiver.getBlock(blockNumber);
|
|
73
|
+
if (!block) {
|
|
74
|
+
this.logger.error(`Failed to get block ${blockNumber}`, {
|
|
75
|
+
block
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const epoch = getEpochAtSlot(block.header.getSlot(), await this.archiver.getL1Constants());
|
|
80
|
+
this.logger.info(`Computing proven performance for epoch ${epoch}`);
|
|
81
|
+
const performance = await this.computeProvenPerformance(epoch);
|
|
82
|
+
this.logger.info(`Proven performance for epoch ${epoch}`, performance);
|
|
83
|
+
await this.updateProvenPerformance(epoch, performance);
|
|
84
|
+
this.handleProvenPerformance(performance);
|
|
85
|
+
}
|
|
86
|
+
async computeProvenPerformance(epoch) {
|
|
87
|
+
const headers = await this.archiver.getBlockHeadersForEpoch(epoch);
|
|
88
|
+
const provenSlots = headers.map((h)=>h.getSlot());
|
|
89
|
+
const fromSlot = provenSlots[0];
|
|
90
|
+
const toSlot = provenSlots[provenSlots.length - 1];
|
|
91
|
+
const { committee } = await this.epochCache.getCommittee(fromSlot);
|
|
92
|
+
const stats = await this.computeStats({
|
|
93
|
+
fromSlot,
|
|
94
|
+
toSlot
|
|
95
|
+
});
|
|
96
|
+
this.logger.debug(`Stats for epoch ${epoch}`, stats);
|
|
97
|
+
const performance = {};
|
|
98
|
+
for (const validator of Object.keys(stats.stats)){
|
|
99
|
+
let address;
|
|
100
|
+
try {
|
|
101
|
+
address = EthAddress.fromString(validator);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
this.logger.error(`Invalid validator address ${validator}`, e);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!committee.find((v)=>v.equals(address))) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
let missed = 0;
|
|
110
|
+
for (const history of stats.stats[validator].history){
|
|
111
|
+
if (provenSlots.includes(history.slot) && history.status === 'attestation-missed') {
|
|
112
|
+
missed++;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
performance[address.toString()] = {
|
|
116
|
+
missed,
|
|
117
|
+
total: provenSlots.length
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return performance;
|
|
121
|
+
}
|
|
122
|
+
updateProvenPerformance(epoch, performance) {
|
|
123
|
+
return this.store.updateProvenPerformance(epoch, performance);
|
|
124
|
+
}
|
|
125
|
+
handleProvenPerformance(performance) {
|
|
126
|
+
const criminals = Object.entries(performance).filter(([_, { missed, total }])=>{
|
|
127
|
+
return missed / total >= this.config.slashInactivityCreateTargetPercentage;
|
|
128
|
+
}).map(([address])=>address);
|
|
129
|
+
const amounts = Array(criminals.length).fill(this.config.slashInactivityCreatePenalty);
|
|
130
|
+
const offenses = Array(criminals.length).fill(Offence.INACTIVITY);
|
|
131
|
+
this.logger.info(`Criminals: ${criminals.length}`, {
|
|
132
|
+
criminals,
|
|
133
|
+
amounts,
|
|
134
|
+
offenses
|
|
135
|
+
});
|
|
136
|
+
if (criminals.length > 0) {
|
|
137
|
+
this.emit(WANT_TO_SLASH_EVENT, {
|
|
138
|
+
validators: criminals,
|
|
139
|
+
amounts,
|
|
140
|
+
offenses
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async shouldSlash(validator, _amount, _offense) {
|
|
145
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
146
|
+
const ttlL2Slots = this.config.slashPayloadTtlSeconds / l1Constants.slotDuration;
|
|
147
|
+
const ttlEpochs = BigInt(Math.ceil(ttlL2Slots / l1Constants.epochDuration));
|
|
148
|
+
const currentEpoch = this.epochCache.getEpochAndSlotNow().epoch;
|
|
149
|
+
const performance = await this.store.getProvenPerformance(validator);
|
|
150
|
+
return performance.filter((p)=>p.epoch >= currentEpoch - ttlEpochs).findIndex((p)=>p.missed / p.total >= this.config.slashInactivitySignalTargetPercentage) !== -1;
|
|
151
|
+
}
|
|
67
152
|
/**
|
|
68
153
|
* Process data for two L2 slots ago.
|
|
69
154
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
@@ -203,14 +288,15 @@ export class Sentinel {
|
|
|
203
288
|
/** Push the status for each slot for each validator. */ updateValidators(slot, stats) {
|
|
204
289
|
return this.store.updateValidators(slot, stats);
|
|
205
290
|
}
|
|
206
|
-
/** Computes stats to be returned based on stored data. */ async computeStats() {
|
|
291
|
+
/** Computes stats to be returned based on stored data. */ async computeStats({ fromSlot: _fromSlot, toSlot: _toSlot } = {}) {
|
|
207
292
|
const histories = await this.store.getHistories();
|
|
208
293
|
const slotNow = this.epochCache.getEpochAndSlotNow().slot;
|
|
209
|
-
const fromSlot = (this.lastProcessedSlot ?? slotNow) - BigInt(this.store.getHistoryLength());
|
|
294
|
+
const fromSlot = _fromSlot ?? (this.lastProcessedSlot ?? slotNow) - BigInt(this.store.getHistoryLength());
|
|
295
|
+
const toSlot = _toSlot ?? this.lastProcessedSlot ?? slotNow;
|
|
210
296
|
const result = {};
|
|
211
297
|
for (const [address, history] of Object.entries(histories)){
|
|
212
298
|
const validatorAddress = address;
|
|
213
|
-
result[validatorAddress] = this.computeStatsForValidator(validatorAddress, history, fromSlot);
|
|
299
|
+
result[validatorAddress] = this.computeStatsForValidator(validatorAddress, history, fromSlot, toSlot);
|
|
214
300
|
}
|
|
215
301
|
return {
|
|
216
302
|
stats: result,
|
|
@@ -219,8 +305,9 @@ export class Sentinel {
|
|
|
219
305
|
slotWindow: this.store.getHistoryLength()
|
|
220
306
|
};
|
|
221
307
|
}
|
|
222
|
-
computeStatsForValidator(address, allHistory, fromSlot) {
|
|
223
|
-
|
|
308
|
+
computeStatsForValidator(address, allHistory, fromSlot, toSlot) {
|
|
309
|
+
let history = fromSlot ? allHistory.filter((h)=>h.slot >= fromSlot) : allHistory;
|
|
310
|
+
history = toSlot ? history.filter((h)=>h.slot <= toSlot) : history;
|
|
224
311
|
return {
|
|
225
312
|
address: EthAddress.fromString(address),
|
|
226
313
|
lastProposal: this.computeFromSlot(history.filter((h)=>h.status === 'block-proposed' || h.status === 'block-mined').at(-1)?.slot),
|
package/dest/sentinel/store.d.ts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type { ValidatorStatusHistory, ValidatorStatusInSlot } from '@aztec/stdlib/validators';
|
|
2
|
+
import type { ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorsEpochPerformance } from '@aztec/stdlib/validators';
|
|
3
3
|
export declare class SentinelStore {
|
|
4
4
|
private store;
|
|
5
5
|
private config;
|
|
6
|
-
static readonly SCHEMA_VERSION =
|
|
7
|
-
private readonly
|
|
6
|
+
static readonly SCHEMA_VERSION = 2;
|
|
7
|
+
private readonly historyMap;
|
|
8
|
+
private readonly provenMap;
|
|
8
9
|
constructor(store: AztecAsyncKVStore, config: {
|
|
9
10
|
historyLength: number;
|
|
10
11
|
});
|
|
11
12
|
getHistoryLength(): number;
|
|
13
|
+
updateProvenPerformance(epoch: bigint, performance: ValidatorsEpochPerformance): Promise<void>;
|
|
14
|
+
getProvenPerformance(who: `0x${string}`): Promise<{
|
|
15
|
+
missed: number;
|
|
16
|
+
total: number;
|
|
17
|
+
epoch: bigint;
|
|
18
|
+
}[]>;
|
|
19
|
+
private pushValidatorProvenPerformanceForEpoch;
|
|
12
20
|
updateValidators(slot: bigint, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>): Promise<void>;
|
|
13
21
|
private pushValidatorStatusForSlot;
|
|
14
22
|
getHistories(): Promise<Record<`0x${string}`, ValidatorStatusHistory>>;
|
|
15
23
|
private getHistory;
|
|
24
|
+
private serializePerformance;
|
|
25
|
+
private deserializePerformance;
|
|
16
26
|
private serializeHistory;
|
|
17
27
|
private deserializeHistory;
|
|
18
28
|
private statusToNumber;
|