@aztec/aztec-node 0.87.7 → 1.0.0-nightly.20250605
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 +5 -16
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +44 -104
- 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 +17 -5
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +110 -14
- package/dest/sentinel/store.d.ts +14 -3
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +71 -7
- package/package.json +23 -22
- package/src/aztec-node/config.ts +4 -1
- package/src/aztec-node/server.ts +66 -135
- package/src/sentinel/factory.ts +3 -2
- package/src/sentinel/sentinel.ts +129 -6
- package/src/sentinel/store.ts +82 -10
|
@@ -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,22 +218,11 @@ export declare class AztecNodeService implements AztecNode, AztecNodeAdmin, Trac
|
|
|
218
218
|
*/
|
|
219
219
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
|
|
220
220
|
/**
|
|
221
|
-
* Returns the
|
|
222
|
-
* @
|
|
223
|
-
*
|
|
224
|
-
|
|
225
|
-
|
|
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.
|
|
231
|
-
* TODO: Handle the case where two messages in the same tx have the same hash.
|
|
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
|
|
235
|
-
*/
|
|
236
|
-
getL2ToL1MessageMembershipWitness(blockNumber: L2BlockNumber, l2ToL1Message: Fr): Promise<[bigint, SiblingPath<number>]>;
|
|
221
|
+
* Returns all the L2 to L1 messages in a block.
|
|
222
|
+
* @param blockNumber - The block number at which to get the data.
|
|
223
|
+
* @returns The L2 to L1 messages (undefined if the block number is not found).
|
|
224
|
+
*/
|
|
225
|
+
getL2ToL1Messages(blockNumber: L2BlockNumber): Promise<Fr[][] | undefined>;
|
|
237
226
|
/**
|
|
238
227
|
* Returns a sibling path for a leaf in the committed blocks tree.
|
|
239
228
|
* @param blockNumber - The block number at which to get the data.
|
|
@@ -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,EAKzB,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;AAEtD,OAAO,EAAE,KAAK,GAAG,EAAoD,MAAM,YAAY,CAAC;AAExF,OAAO,EAGL,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,QAAQ,EACR,yBAAyB,EA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AC;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, RollupContract, 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';
|
|
@@ -18,15 +19,12 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
18
19
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
19
20
|
import { count } from '@aztec/foundation/string';
|
|
20
21
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
21
|
-
import { SiblingPath } from '@aztec/foundation/trees';
|
|
22
|
-
import { openTmpStore } from '@aztec/kv-store/lmdb';
|
|
23
|
-
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
24
|
-
import { SHA256Trunc, StandardTree, UnbalancedTree } from '@aztec/merkle-tree';
|
|
25
22
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
26
23
|
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
27
24
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
28
|
-
import { GlobalVariableBuilder, SequencerClient,
|
|
25
|
+
import { BlockBuilder, GlobalVariableBuilder, SequencerClient, createValidatorForAcceptingTxs } from '@aztec/sequencer-client';
|
|
29
26
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
27
|
+
import { EpochPruneWatcher, SlasherClient } from '@aztec/slasher';
|
|
30
28
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
31
29
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
32
30
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
@@ -37,7 +35,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
|
37
35
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
38
36
|
import { createValidatorClient } from '@aztec/validator-client';
|
|
39
37
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
40
|
-
import { createPublicClient, fallback,
|
|
38
|
+
import { createPublicClient, fallback, http } from 'viem';
|
|
41
39
|
import { createSentinel } from '../sentinel/factory.js';
|
|
42
40
|
import { NodeMetrics } from './node_metrics.js';
|
|
43
41
|
/**
|
|
@@ -125,14 +123,16 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
125
123
|
...config.l1Contracts,
|
|
126
124
|
...l1ContractsAddresses
|
|
127
125
|
};
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
const l1Client = createExtendedL1Client(config.l1RpcUrls, config.publisherPrivateKey, ethereumChain.chainInfo);
|
|
127
|
+
const l1TxUtils = new L1TxUtilsWithBlobs(l1Client, log, config);
|
|
128
|
+
const rollupContract = new RollupContract(l1Client, config.l1Contracts.rollupAddress.toString());
|
|
129
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
130
|
+
rollupContract.getL1GenesisTime(),
|
|
131
|
+
rollupContract.getSlotDuration(),
|
|
132
|
+
rollupContract.getVersion()
|
|
133
|
+
]);
|
|
134
|
+
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
135
|
+
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
136
136
|
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}).`);
|
|
137
137
|
}
|
|
138
138
|
// attempt snapshot sync if possible
|
|
@@ -155,26 +155,44 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
155
155
|
await worldStateSynchronizer.start();
|
|
156
156
|
// Start p2p. Note that it depends on world state to be running.
|
|
157
157
|
await p2pClient.start();
|
|
158
|
-
const
|
|
159
|
-
|
|
158
|
+
const watchers = [];
|
|
159
|
+
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
160
|
+
if (validatorsSentinel && config.slashInactivityEnabled) {
|
|
161
|
+
watchers.push(validatorsSentinel);
|
|
162
|
+
}
|
|
163
|
+
if (config.slashPruneEnabled) {
|
|
164
|
+
const epochPruneWatcher = new EpochPruneWatcher(archiver, epochCache, config.slashPrunePenalty, config.slashPruneMaxPenalty);
|
|
165
|
+
watchers.push(epochPruneWatcher);
|
|
166
|
+
}
|
|
167
|
+
const slasherClient = await SlasherClient.new(config, config.l1Contracts, l1TxUtils, watchers, dateProvider);
|
|
168
|
+
await slasherClient.start();
|
|
169
|
+
const blockBuilder = new BlockBuilder({
|
|
170
|
+
l1GenesisTime,
|
|
171
|
+
slotDuration: Number(slotDuration),
|
|
172
|
+
rollupVersion: config.rollupVersion,
|
|
173
|
+
l1ChainId: config.l1ChainId
|
|
174
|
+
}, archiver, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
160
175
|
const validatorClient = createValidatorClient(config, {
|
|
161
176
|
p2pClient,
|
|
162
177
|
telemetry,
|
|
163
178
|
dateProvider,
|
|
164
179
|
epochCache,
|
|
180
|
+
blockBuilder,
|
|
165
181
|
blockSource: archiver
|
|
166
182
|
});
|
|
167
|
-
const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
168
|
-
await validatorsSentinel?.start();
|
|
169
183
|
log.verbose(`All Aztec Node subsystems synced`);
|
|
170
184
|
// now create the sequencer
|
|
171
185
|
const sequencer = config.disableValidator ? undefined : await SequencerClient.new(config, {
|
|
186
|
+
// if deps were provided, they should override the defaults,
|
|
187
|
+
// or things that we created in this function
|
|
172
188
|
...deps,
|
|
189
|
+
epochCache,
|
|
190
|
+
l1TxUtils,
|
|
173
191
|
validatorClient,
|
|
174
192
|
p2pClient,
|
|
175
193
|
worldStateSynchronizer,
|
|
176
194
|
slasherClient,
|
|
177
|
-
|
|
195
|
+
blockBuilder,
|
|
178
196
|
l2BlockSource: archiver,
|
|
179
197
|
l1ToL2MessageSource: archiver,
|
|
180
198
|
telemetry,
|
|
@@ -365,7 +383,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
365
383
|
*/ async stop() {
|
|
366
384
|
this.log.info(`Stopping`);
|
|
367
385
|
await this.txQueue.end();
|
|
368
|
-
await this.validatorsSentinel?.stop();
|
|
386
|
+
// await this.validatorsSentinel?.stop(); <- The slasher client will stop this
|
|
369
387
|
await this.sequencer?.stop();
|
|
370
388
|
await this.p2pClient.stop();
|
|
371
389
|
await this.worldStateSynchronizer.stop();
|
|
@@ -495,90 +513,12 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
495
513
|
return await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message) !== undefined;
|
|
496
514
|
}
|
|
497
515
|
/**
|
|
498
|
-
* Returns the
|
|
499
|
-
* @
|
|
500
|
-
*
|
|
501
|
-
|
|
502
|
-
* 1. Subtree - For each transaction in the block, a subtree is created containing all L2->L1 messages from that
|
|
503
|
-
* transaction.
|
|
504
|
-
* 2. Top tree - A tree containing the roots of all the subtrees as leaves
|
|
505
|
-
* The final path is constructed by concatenating the path in the subtree with the path in the top tree.
|
|
506
|
-
* When there is only one transaction in the block, the subtree itself becomes the block's L2->L1 message tree,
|
|
507
|
-
* and no top tree is needed. The out hash is the root of the the block's L2->L1 message tree.
|
|
508
|
-
* TODO: Handle the case where two messages in the same tx have the same hash.
|
|
509
|
-
* @param blockNumber - Block number to get data from
|
|
510
|
-
* @param l2ToL1Message - Message to get index/path for
|
|
511
|
-
* @returns [index, siblingPath] for the message
|
|
512
|
-
*/ async getL2ToL1MessageMembershipWitness(blockNumber, l2ToL1Message) {
|
|
516
|
+
* Returns all the L2 to L1 messages in a block.
|
|
517
|
+
* @param blockNumber - The block number at which to get the data.
|
|
518
|
+
* @returns The L2 to L1 messages (undefined if the block number is not found).
|
|
519
|
+
*/ async getL2ToL1Messages(blockNumber) {
|
|
513
520
|
const block = await this.blockSource.getBlock(blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber);
|
|
514
|
-
|
|
515
|
-
throw new Error('Block not found in getL2ToL1MessageMembershipWitness');
|
|
516
|
-
}
|
|
517
|
-
const messagesPerTx = block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
518
|
-
// Find index of message in subtree and index of tx in a block
|
|
519
|
-
let messageIndexInTx = -1, txIndex = -1;
|
|
520
|
-
{
|
|
521
|
-
txIndex = messagesPerTx.findIndex((messages)=>{
|
|
522
|
-
const idx = messages.findIndex((msg)=>msg.equals(l2ToL1Message));
|
|
523
|
-
messageIndexInTx = Math.max(messageIndexInTx, idx);
|
|
524
|
-
return idx !== -1;
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
if (txIndex === -1) {
|
|
528
|
-
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
529
|
-
}
|
|
530
|
-
// Get the message path in subtree and message subtree height
|
|
531
|
-
let messagePathInSubtree;
|
|
532
|
-
let messageSubtreeHeight;
|
|
533
|
-
{
|
|
534
|
-
const subtreeStore = openTmpStore(true);
|
|
535
|
-
const txMessages = messagesPerTx[txIndex];
|
|
536
|
-
messageSubtreeHeight = txMessages.length <= 1 ? 1 : Math.ceil(Math.log2(txMessages.length));
|
|
537
|
-
const subtree = new StandardTree(subtreeStore, new SHA256Trunc(), `subtree_${txIndex}`, messageSubtreeHeight, 0n, Fr);
|
|
538
|
-
subtree.appendLeaves(txMessages);
|
|
539
|
-
messagePathInSubtree = await subtree.getSiblingPath(BigInt(messageIndexInTx), true);
|
|
540
|
-
await subtreeStore.delete();
|
|
541
|
-
}
|
|
542
|
-
// If the number of txs is 1 we are dealing with a special case where the tx subtree itself is the whole block's
|
|
543
|
-
// l2 to l1 message tree.
|
|
544
|
-
const numTransactions = block.body.txEffects.length;
|
|
545
|
-
if (numTransactions === 1) {
|
|
546
|
-
return [
|
|
547
|
-
BigInt(messageIndexInTx),
|
|
548
|
-
messagePathInSubtree
|
|
549
|
-
];
|
|
550
|
-
}
|
|
551
|
-
// Calculate roots for all tx subtrees
|
|
552
|
-
const txSubtreeRoots = await Promise.all(messagesPerTx.map(async (messages, txIdx)=>{
|
|
553
|
-
// For a tx with no messages, we have to set an out hash of 0 to match what the circuit does.
|
|
554
|
-
if (messages.length === 0) {
|
|
555
|
-
return Fr.ZERO;
|
|
556
|
-
}
|
|
557
|
-
const txStore = openTmpStore(true);
|
|
558
|
-
const txTreeHeight = messages.length <= 1 ? 1 : Math.ceil(Math.log2(messages.length));
|
|
559
|
-
const txTree = new StandardTree(txStore, new SHA256Trunc(), `tx_messages_subtree_${txIdx}`, txTreeHeight, 0n, Fr);
|
|
560
|
-
txTree.appendLeaves(messages);
|
|
561
|
-
const root = Fr.fromBuffer(txTree.getRoot(true));
|
|
562
|
-
await txStore.delete();
|
|
563
|
-
return root;
|
|
564
|
-
}));
|
|
565
|
-
// Construct the top tree and compute the combined path
|
|
566
|
-
let combinedPath;
|
|
567
|
-
{
|
|
568
|
-
const topTreeHeight = Math.ceil(Math.log2(txSubtreeRoots.length));
|
|
569
|
-
// The root of this tree is the out_hash calculated in Noir => we truncate to match Noir's SHA
|
|
570
|
-
const topTree = new UnbalancedTree(new SHA256Trunc(), 'top_tree', topTreeHeight, Fr);
|
|
571
|
-
await topTree.appendLeaves(txSubtreeRoots);
|
|
572
|
-
const txPathInTopTree = await topTree.getSiblingPath(txSubtreeRoots[txIndex].toBigInt());
|
|
573
|
-
// Append subtree path to top tree path
|
|
574
|
-
combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
|
|
575
|
-
}
|
|
576
|
-
// Append binary index of subtree path to binary index of top tree path
|
|
577
|
-
const combinedIndex = parseInt(txIndex.toString(2).concat(messageIndexInTx.toString(2).padStart(messageSubtreeHeight, '0')), 2);
|
|
578
|
-
return [
|
|
579
|
-
BigInt(combinedIndex),
|
|
580
|
-
new SiblingPath(combinedPath.length, combinedPath)
|
|
581
|
-
];
|
|
521
|
+
return block?.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs);
|
|
582
522
|
}
|
|
583
523
|
/**
|
|
584
524
|
* Returns a sibling path for a leaf in the committed blocks tree.
|
|
@@ -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,17 @@ 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, WantToSlashArgs, Watcher, WatcherEmitter } from '@aztec/slasher/config';
|
|
6
7
|
import { type L2BlockSource, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
7
|
-
import type { ValidatorStats, ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorStatusType, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
8
|
+
import type { ValidatorStats, ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorStatusType, ValidatorsEpochPerformance, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
8
9
|
import { SentinelStore } from './store.js';
|
|
9
|
-
|
|
10
|
+
declare const Sentinel_base: new () => WatcherEmitter;
|
|
11
|
+
export declare class Sentinel extends Sentinel_base implements L2BlockStreamEventHandler, Watcher {
|
|
10
12
|
protected epochCache: EpochCache;
|
|
11
13
|
protected archiver: L2BlockSource;
|
|
12
14
|
protected p2p: P2PClient;
|
|
13
15
|
protected store: SentinelStore;
|
|
16
|
+
protected config: Pick<SlasherConfig, 'slashInactivityCreateTargetPercentage' | 'slashInactivityCreatePenalty' | 'slashInactivitySignalTargetPercentage' | 'slashInactivityMaxPenalty' | 'slashPayloadTtlSeconds'>;
|
|
14
17
|
protected logger: import("@aztec/foundation/log").Logger;
|
|
15
18
|
protected runningPromise: RunningPromise;
|
|
16
19
|
protected blockStream: L2BlockStream;
|
|
@@ -22,12 +25,17 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
22
25
|
archive: string;
|
|
23
26
|
attestors: EthAddress[];
|
|
24
27
|
}>;
|
|
25
|
-
constructor(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, store: SentinelStore, logger?: import("@aztec/foundation/log").Logger);
|
|
28
|
+
constructor(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, store: SentinelStore, config: Pick<SlasherConfig, 'slashInactivityCreateTargetPercentage' | 'slashInactivityCreatePenalty' | 'slashInactivitySignalTargetPercentage' | 'slashInactivityMaxPenalty' | 'slashPayloadTtlSeconds'>, logger?: import("@aztec/foundation/log").Logger);
|
|
26
29
|
start(): Promise<void>;
|
|
27
30
|
/** Loads initial slot and initializes blockstream. We will not process anything at or before the initial slot. */
|
|
28
31
|
protected init(): Promise<void>;
|
|
29
32
|
stop(): Promise<void>;
|
|
30
33
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
34
|
+
protected handleChainProven(event: L2BlockStreamEvent): Promise<void>;
|
|
35
|
+
protected computeProvenPerformance(epoch: bigint): Promise<ValidatorsEpochPerformance>;
|
|
36
|
+
protected updateProvenPerformance(epoch: bigint, performance: ValidatorsEpochPerformance): Promise<void>;
|
|
37
|
+
protected handleProvenPerformance(performance: ValidatorsEpochPerformance): void;
|
|
38
|
+
shouldSlash({ validator, amount }: WantToSlashArgs): Promise<boolean>;
|
|
31
39
|
/**
|
|
32
40
|
* Process data for two L2 slots ago.
|
|
33
41
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
@@ -52,8 +60,11 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
52
60
|
/** Push the status for each slot for each validator. */
|
|
53
61
|
protected updateValidators(slot: bigint, stats: Record<`0x${string}`, ValidatorStatusInSlot | undefined>): Promise<void>;
|
|
54
62
|
/** Computes stats to be returned based on stored data. */
|
|
55
|
-
computeStats(
|
|
56
|
-
|
|
63
|
+
computeStats({ fromSlot: _fromSlot, toSlot: _toSlot, }?: {
|
|
64
|
+
fromSlot?: bigint;
|
|
65
|
+
toSlot?: bigint;
|
|
66
|
+
}): Promise<ValidatorsStats>;
|
|
67
|
+
protected computeStatsForValidator(address: `0x${string}`, allHistory: ValidatorStatusHistory, fromSlot?: bigint, toSlot?: bigint): ValidatorStats;
|
|
57
68
|
protected computeMissed(history: ValidatorStatusHistory, computeOverPrefix: ValidatorStatusType, filter: ValidatorStatusInSlot): {
|
|
58
69
|
currentStreak: number;
|
|
59
70
|
rate: number | undefined;
|
|
@@ -65,4 +76,5 @@ export declare class Sentinel implements L2BlockStreamEventHandler {
|
|
|
65
76
|
date: string;
|
|
66
77
|
} | undefined;
|
|
67
78
|
}
|
|
79
|
+
export {};
|
|
68
80
|
//# 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,EACL,KAAK,aAAa,EAClB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAE/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EAChB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/sentinel/sentinel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAA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AAS,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,104 @@ 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 args = criminals.map((address)=>({
|
|
130
|
+
validator: EthAddress.fromString(address),
|
|
131
|
+
amount: this.config.slashInactivityCreatePenalty,
|
|
132
|
+
offense: Offence.INACTIVITY
|
|
133
|
+
}));
|
|
134
|
+
this.logger.info(`Criminals: ${criminals.length}`, {
|
|
135
|
+
args
|
|
136
|
+
});
|
|
137
|
+
if (criminals.length > 0) {
|
|
138
|
+
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async shouldSlash({ validator, amount }) {
|
|
142
|
+
const l1Constants = this.epochCache.getL1Constants();
|
|
143
|
+
const ttlL2Slots = this.config.slashPayloadTtlSeconds / l1Constants.slotDuration;
|
|
144
|
+
const ttlEpochs = BigInt(Math.ceil(ttlL2Slots / l1Constants.epochDuration));
|
|
145
|
+
const currentEpoch = this.epochCache.getEpochAndSlotNow().epoch;
|
|
146
|
+
const performance = await this.store.getProvenPerformance(validator);
|
|
147
|
+
const isCriminal = performance.filter((p)=>p.epoch >= currentEpoch - ttlEpochs).findIndex((p)=>p.missed / p.total >= this.config.slashInactivitySignalTargetPercentage) !== -1;
|
|
148
|
+
if (isCriminal) {
|
|
149
|
+
if (amount <= this.config.slashInactivityMaxPenalty) {
|
|
150
|
+
return true;
|
|
151
|
+
} else {
|
|
152
|
+
this.logger.warn(`Validator ${validator} is a criminal but the penalty is too high`, {
|
|
153
|
+
amount,
|
|
154
|
+
maxPenalty: this.config.slashInactivityMaxPenalty
|
|
155
|
+
});
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
67
161
|
/**
|
|
68
162
|
* Process data for two L2 slots ago.
|
|
69
163
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
@@ -203,14 +297,15 @@ export class Sentinel {
|
|
|
203
297
|
/** Push the status for each slot for each validator. */ updateValidators(slot, stats) {
|
|
204
298
|
return this.store.updateValidators(slot, stats);
|
|
205
299
|
}
|
|
206
|
-
/** Computes stats to be returned based on stored data. */ async computeStats() {
|
|
300
|
+
/** Computes stats to be returned based on stored data. */ async computeStats({ fromSlot: _fromSlot, toSlot: _toSlot } = {}) {
|
|
207
301
|
const histories = await this.store.getHistories();
|
|
208
302
|
const slotNow = this.epochCache.getEpochAndSlotNow().slot;
|
|
209
|
-
const fromSlot = (this.lastProcessedSlot ?? slotNow) - BigInt(this.store.getHistoryLength());
|
|
303
|
+
const fromSlot = _fromSlot ?? (this.lastProcessedSlot ?? slotNow) - BigInt(this.store.getHistoryLength());
|
|
304
|
+
const toSlot = _toSlot ?? this.lastProcessedSlot ?? slotNow;
|
|
210
305
|
const result = {};
|
|
211
306
|
for (const [address, history] of Object.entries(histories)){
|
|
212
307
|
const validatorAddress = address;
|
|
213
|
-
result[validatorAddress] = this.computeStatsForValidator(validatorAddress, history, fromSlot);
|
|
308
|
+
result[validatorAddress] = this.computeStatsForValidator(validatorAddress, history, fromSlot, toSlot);
|
|
214
309
|
}
|
|
215
310
|
return {
|
|
216
311
|
stats: result,
|
|
@@ -219,8 +314,9 @@ export class Sentinel {
|
|
|
219
314
|
slotWindow: this.store.getHistoryLength()
|
|
220
315
|
};
|
|
221
316
|
}
|
|
222
|
-
computeStatsForValidator(address, allHistory, fromSlot) {
|
|
223
|
-
|
|
317
|
+
computeStatsForValidator(address, allHistory, fromSlot, toSlot) {
|
|
318
|
+
let history = fromSlot ? allHistory.filter((h)=>h.slot >= fromSlot) : allHistory;
|
|
319
|
+
history = toSlot ? history.filter((h)=>h.slot <= toSlot) : history;
|
|
224
320
|
return {
|
|
225
321
|
address: EthAddress.fromString(address),
|
|
226
322
|
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,29 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type { ValidatorStatusHistory, ValidatorStatusInSlot } from '@aztec/stdlib/validators';
|
|
3
|
+
import type { ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorsEpochPerformance } from '@aztec/stdlib/validators';
|
|
3
4
|
export declare class SentinelStore {
|
|
4
5
|
private store;
|
|
5
6
|
private config;
|
|
6
|
-
static readonly SCHEMA_VERSION =
|
|
7
|
-
private readonly
|
|
7
|
+
static readonly SCHEMA_VERSION = 2;
|
|
8
|
+
private readonly historyMap;
|
|
9
|
+
private readonly provenMap;
|
|
8
10
|
constructor(store: AztecAsyncKVStore, config: {
|
|
9
11
|
historyLength: number;
|
|
10
12
|
});
|
|
11
13
|
getHistoryLength(): number;
|
|
14
|
+
updateProvenPerformance(epoch: bigint, performance: ValidatorsEpochPerformance): Promise<void>;
|
|
15
|
+
getProvenPerformance(who: EthAddress): Promise<{
|
|
16
|
+
missed: number;
|
|
17
|
+
total: number;
|
|
18
|
+
epoch: bigint;
|
|
19
|
+
}[]>;
|
|
20
|
+
private pushValidatorProvenPerformanceForEpoch;
|
|
12
21
|
updateValidators(slot: bigint, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>): Promise<void>;
|
|
13
22
|
private pushValidatorStatusForSlot;
|
|
14
23
|
getHistories(): Promise<Record<`0x${string}`, ValidatorStatusHistory>>;
|
|
15
24
|
private getHistory;
|
|
25
|
+
private serializePerformance;
|
|
26
|
+
private deserializePerformance;
|
|
16
27
|
private serializeHistory;
|
|
17
28
|
private deserializeHistory;
|
|
18
29
|
private statusToNumber;
|