@aztec/aztec-node 5.0.0-private.20260319 → 5.0.0-rc.1

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.
Files changed (47) hide show
  1. package/dest/aztec-node/block_response_helpers.d.ts +25 -0
  2. package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
  3. package/dest/aztec-node/block_response_helpers.js +112 -0
  4. package/dest/aztec-node/config.d.ts +14 -4
  5. package/dest/aztec-node/config.d.ts.map +1 -1
  6. package/dest/aztec-node/config.js +10 -5
  7. package/dest/aztec-node/public_data_overrides.d.ts +13 -0
  8. package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
  9. package/dest/aztec-node/public_data_overrides.js +21 -0
  10. package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
  11. package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
  12. package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
  13. package/dest/aztec-node/server.d.ts +91 -100
  14. package/dest/aztec-node/server.d.ts.map +1 -1
  15. package/dest/aztec-node/server.js +1073 -492
  16. package/dest/bin/index.js +14 -9
  17. package/dest/index.d.ts +2 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +1 -0
  20. package/dest/sentinel/config.d.ts +3 -2
  21. package/dest/sentinel/config.d.ts.map +1 -1
  22. package/dest/sentinel/config.js +15 -5
  23. package/dest/sentinel/factory.d.ts +4 -2
  24. package/dest/sentinel/factory.d.ts.map +1 -1
  25. package/dest/sentinel/factory.js +4 -4
  26. package/dest/sentinel/sentinel.d.ts +133 -9
  27. package/dest/sentinel/sentinel.d.ts.map +1 -1
  28. package/dest/sentinel/sentinel.js +212 -70
  29. package/dest/sentinel/store.d.ts +8 -8
  30. package/dest/sentinel/store.d.ts.map +1 -1
  31. package/dest/sentinel/store.js +25 -17
  32. package/dest/test/index.d.ts +3 -3
  33. package/dest/test/index.d.ts.map +1 -1
  34. package/package.json +27 -26
  35. package/src/aztec-node/block_response_helpers.ts +161 -0
  36. package/src/aztec-node/config.ts +23 -7
  37. package/src/aztec-node/public_data_overrides.ts +35 -0
  38. package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
  39. package/src/aztec-node/server.ts +1190 -625
  40. package/src/bin/index.ts +13 -11
  41. package/src/index.ts +1 -0
  42. package/src/sentinel/README.md +103 -0
  43. package/src/sentinel/config.ts +18 -6
  44. package/src/sentinel/factory.ts +7 -4
  45. package/src/sentinel/sentinel.ts +267 -82
  46. package/src/sentinel/store.ts +26 -18
  47. package/src/test/index.ts +2 -2
@@ -1,12 +1,13 @@
1
- import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
1
+ import { BlockNumber, CheckpointProposalHash, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import { countWhile, filterAsync, fromEntries, getEntries, mapValues } from '@aztec/foundation/collection';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
5
  import { RunningPromise } from '@aztec/foundation/running-promise';
6
6
  import { L2TipsMemoryStore } from '@aztec/kv-store/stores';
7
- import { OffenseType, WANT_TO_SLASH_EVENT } from '@aztec/slasher';
7
+ import { OffenseType, WANT_TO_SLASH_EVENT, getOffenseTypeName } from '@aztec/slasher';
8
8
  import { L2BlockStream, getAttestationInfoFromPublishedCheckpoint } from '@aztec/stdlib/block';
9
9
  import { getEpochAtSlot, getSlotRangeForEpoch, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
10
+ import { ConsensusPayload } from '@aztec/stdlib/p2p';
10
11
  import EventEmitter from 'node:events';
11
12
  /** Maps a validator status to its category: proposer or attestation. */ function statusToCategory(status) {
12
13
  switch(status){
@@ -17,11 +18,81 @@ import EventEmitter from 'node:events';
17
18
  return 'proposer';
18
19
  }
19
20
  }
20
- export class Sentinel extends EventEmitter {
21
+ /**
22
+ * The Sentinel observes validator behaviour every L2 slot, classifies it into a per-slot status,
23
+ * aggregates those statuses into per-epoch performance once each epoch is fully observed, and
24
+ * emits inactivity slash payloads when a validator has been inactive for the configured number
25
+ * of consecutive epochs.
26
+ *
27
+ * ## Two cadences
28
+ *
29
+ * The sentinel runs `work()` every quarter L2 slot and drives two independent pipelines:
30
+ *
31
+ * 1. **Per-slot activity recording.** `processSlot(currentSlot - 2)` runs once per slot, with a
32
+ * two-slot lag to let P2P attestations settle and the archiver catch up. It classifies each
33
+ * committee member's behaviour for that slot via `getSlotActivity` and persists the result to
34
+ * `SentinelStore.historyMap` (sliding window of `sentinelHistoryLengthInEpochs * epochDuration`
35
+ * slots, default 24 epochs).
36
+ *
37
+ * 2. **Per-epoch evaluation.** `processEpochEnds(currentSlot)` runs every tick too. Once
38
+ * `sentinelEpochEndBufferSlots` (default 2) has elapsed past an epoch's last slot AND the
39
+ * per-slot recorder has covered that last slot, the sentinel calls `handleEpochEnd(epoch)`.
40
+ * That aggregates the slot-level statuses for the epoch into per-validator `{missed, total}`,
41
+ * persists it to `SentinelStore.epochMap` (default 2000-epoch window), and runs the slashing
42
+ * decision.
43
+ *
44
+ * Triggering per-epoch evaluation off local L2 state — rather than waiting for L1 proof
45
+ * publication — decouples slashing from prover availability.
46
+ *
47
+ * ## Six-case taxonomy in `getSlotActivity`
48
+ *
49
+ * For each slot, the sentinel assigns the proposer one of six statuses, ranked highest-confidence
50
+ * first:
51
+ *
52
+ * - `checkpoint-mined` — a checkpoint covering this slot has landed on L1
53
+ * (`slotNumberToCheckpoint` populated from `chain-checkpointed`).
54
+ * - `checkpoint-valid` — the local node re-executed a checkpoint proposal for this slot
55
+ * successfully (consulted via `CheckpointReexecutionTracker`).
56
+ * - `checkpoint-invalid` — the local node re-executed a checkpoint proposal for this slot
57
+ * and rejected it (e.g. header/archive/out-hash mismatch, limit
58
+ * breach). Proposer-fault.
59
+ * - `checkpoint-unvalidated` — the local node observed a checkpoint proposal but could not
60
+ * validate it (missing blocks/txs, timeouts). Treated as
61
+ * proposer-fault for slashing.
62
+ * - `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal at all.
63
+ * - `blocks-missed` — no block proposals seen for this slot.
64
+ *
65
+ * Missing-attestor faults are recorded only in `checkpoint-mined` and `checkpoint-valid`, where
66
+ * the local node has positive evidence the checkpoint was canonical or valid. In the other four
67
+ * cases the proposer is at fault and no attestor penalty applies.
68
+ *
69
+ * ## Re-execution tracker
70
+ *
71
+ * `CheckpointReexecutionTracker` is populated by the validator client's checkpoint proposal
72
+ * handler. Every early return in `validateCheckpointProposal` records an outcome
73
+ * (`valid` / `invalid` / `unvalidated`) keyed by slot.
74
+ *
75
+ * ## Inactivity slashing
76
+ *
77
+ * `handleEpochPerformance` filters the epoch's per-validator stats by
78
+ * `slashInactivityTargetPercentage` and then calls `checkPastInactivity` to require
79
+ * `slashInactivityConsecutiveEpochThreshold` consecutive past epochs over the same threshold
80
+ * (read from `SentinelStore.epochMap`). Only validators meeting both conditions are emitted as
81
+ * `WANT_TO_SLASH_EVENT` with `OffenseType.INACTIVITY`. The slot-level counters that feed this —
82
+ * `missedProposals` and `missedAttestations` — include the four proposer-fault statuses plus
83
+ * `attestation-missed`.
84
+ *
85
+ * ## Escape hatch
86
+ *
87
+ * If `epochCache.getCommittee(slot)` reports `isEscapeHatchOpen`, per-slot recording is skipped
88
+ * (no history entries for that slot) and per-epoch evaluation writes an empty performance map
89
+ * (no slashing).
90
+ */ export class Sentinel extends EventEmitter {
21
91
  epochCache;
22
92
  archiver;
23
93
  p2p;
24
94
  store;
95
+ reexecutionTracker;
25
96
  config;
26
97
  logger;
27
98
  runningPromise;
@@ -29,14 +100,20 @@ export class Sentinel extends EventEmitter {
29
100
  l2TipsStore;
30
101
  initialSlot;
31
102
  lastProcessedSlot;
32
- // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
103
+ /** Largest epoch number for which the end-of-epoch aggregator has run. */ lastEvaluatedEpoch;
33
104
  slotNumberToCheckpoint;
34
- constructor(epochCache, archiver, p2p, store, config, logger = createLogger('node:sentinel')){
35
- super(), this.epochCache = epochCache, this.archiver = archiver, this.p2p = p2p, this.store = store, this.config = config, this.logger = logger, this.slotNumberToCheckpoint = new Map();
36
- this.l2TipsStore = new L2TipsMemoryStore();
105
+ constructor(epochCache, archiver, p2p, store, reexecutionTracker, config, logger = createLogger('node:sentinel')){
106
+ super(), this.epochCache = epochCache, this.archiver = archiver, this.p2p = p2p, this.store = store, this.reexecutionTracker = reexecutionTracker, this.config = config, this.logger = logger, this.slotNumberToCheckpoint = new Map();
107
+ this.l2TipsStore = new L2TipsMemoryStore(archiver.getGenesisBlockHash());
37
108
  const interval = epochCache.getL1Constants().ethereumSlotDuration * 1000 / 4;
38
109
  this.runningPromise = new RunningPromise(this.work.bind(this), logger, interval);
39
110
  }
111
+ getSignatureContext() {
112
+ return {
113
+ chainId: this.config.l1ChainId,
114
+ rollupAddress: this.config.rollupAddress
115
+ };
116
+ }
40
117
  updateConfig(config) {
41
118
  this.config = {
42
119
  ...this.config,
@@ -47,14 +124,29 @@ export class Sentinel extends EventEmitter {
47
124
  await this.init();
48
125
  this.runningPromise.start();
49
126
  }
50
- /** Loads initial slot and initializes blockstream. We will not process anything at or before the initial slot. */ async init() {
51
- this.initialSlot = this.epochCache.getSlotNow();
127
+ /**
128
+ * Loads initial slot and initializes blockstream. We will not process anything at or before
129
+ * the initial slot. Floors at the archiver's synced L2 slot so the sentinel keeps making
130
+ * forward progress when L1 is advancing but L2 has no activity (the synced slot is driven by
131
+ * L1 sync, not by L2 blocks). Falls back to the wallclock if the archiver isn't ready yet
132
+ * (cold start).
133
+ */ async init() {
134
+ this.initialSlot = await this.getCurrentSlot();
52
135
  const startingBlock = BlockNumber(await this.archiver.getBlockNumber());
53
136
  this.logger.info(`Starting validator sentinel with initial slot ${this.initialSlot} and block ${startingBlock}`);
54
137
  this.blockStream = new L2BlockStream(this.archiver, this.l2TipsStore, this, this.logger, {
55
138
  startingBlock
56
139
  });
57
140
  }
141
+ /**
142
+ * Returns the L2 slot the sentinel should treat as "current": the archiver's last fully
143
+ * synced L2 slot, falling back to the wallclock slot when the archiver isn't ready yet
144
+ * (cold start). Anchoring to the synced slot keeps timing arithmetic (initial floor,
145
+ * per-slot lag, end-of-epoch buffer, stats-range fallback) from speculating ahead of where
146
+ * L1 actually is.
147
+ */ async getCurrentSlot() {
148
+ return await this.archiver.getSyncedL2SlotNumber() ?? this.epochCache.getSlotNow();
149
+ }
58
150
  stop() {
59
151
  return this.runningPromise.stop();
60
152
  }
@@ -62,8 +154,6 @@ export class Sentinel extends EventEmitter {
62
154
  await this.l2TipsStore.handleBlockStreamEvent(event);
63
155
  if (event.type === 'chain-checkpointed') {
64
156
  this.handleCheckpoint(event);
65
- } else if (event.type === 'chain-proven') {
66
- await this.handleChainProven(event);
67
157
  }
68
158
  }
69
159
  handleCheckpoint(event) {
@@ -71,11 +161,15 @@ export class Sentinel extends EventEmitter {
71
161
  return;
72
162
  }
73
163
  const checkpoint = event.checkpoint;
74
- // Store mapping from slot to archive, checkpoint number, and attestors
164
+ // Store mapping from slot to archive, checkpoint number, attestors, and the consensus payload
165
+ // hash (used to query matching p2p attestations regardless of feeAssetPriceModifier variants).
166
+ const signatureContext = this.getSignatureContext();
167
+ const proposalPayloadHash = CheckpointProposalHash.fromBuffer(ConsensusPayload.fromCheckpoint(checkpoint.checkpoint, signatureContext).getPayloadHash());
75
168
  this.slotNumberToCheckpoint.set(checkpoint.checkpoint.header.slotNumber, {
76
169
  checkpointNumber: checkpoint.checkpoint.number,
77
170
  archive: checkpoint.checkpoint.archive.root.toString(),
78
- attestors: getAttestationInfoFromPublishedCheckpoint(checkpoint).filter((a)=>a.status === 'recovered-from-signature').map((a)=>a.address)
171
+ proposalPayloadHash,
172
+ attestors: getAttestationInfoFromPublishedCheckpoint(checkpoint, signatureContext).filter((a)=>a.status === 'recovered-from-signature').map((a)=>a.address)
79
173
  });
80
174
  // Prune the archive map to only keep at most N entries
81
175
  const historyLength = this.store.getHistoryLength();
@@ -86,30 +180,22 @@ export class Sentinel extends EventEmitter {
86
180
  }
87
181
  }
88
182
  }
89
- async handleChainProven(event) {
90
- if (event.type !== 'chain-proven') {
91
- return;
92
- }
93
- const blockNumber = event.block.number;
94
- const header = await this.archiver.getBlockHeader(blockNumber);
95
- if (!header) {
96
- this.logger.error(`Failed to get block header ${blockNumber}`);
97
- return;
98
- }
99
- // TODO(palla/slash): We should only be computing proven performance if this is
100
- // a full proof epoch and not a partial one, otherwise we'll end up with skewed stats.
101
- const epoch = getEpochAtSlot(header.getSlot(), this.epochCache.getL1Constants());
102
- this.logger.debug(`Computing proven performance for epoch ${epoch}`);
103
- const performance = await this.computeProvenPerformance(epoch);
104
- this.logger.info(`Computed proven performance for epoch ${epoch}`, performance);
105
- await this.store.updateProvenPerformance(epoch, performance);
106
- await this.handleProvenPerformance(epoch, performance);
183
+ /**
184
+ * Called once per epoch, after the configured end-of-epoch buffer has elapsed beyond the
185
+ * epoch's last slot. Computes per-epoch performance from the slot-level history collected
186
+ * by `processSlot` and emits any inactivity slash payloads.
187
+ */ async handleEpochEnd(epoch) {
188
+ this.logger.debug(`Computing epoch performance for epoch ${epoch}`);
189
+ const performance = await this.computeEpochPerformance(epoch);
190
+ this.logger.info(`Computed epoch performance for epoch ${epoch}`, performance);
191
+ await this.store.updateEpochPerformance(epoch, performance);
192
+ await this.handleEpochPerformance(epoch, performance);
107
193
  }
108
- async computeProvenPerformance(epoch) {
194
+ async computeEpochPerformance(epoch) {
109
195
  const [fromSlot, toSlot] = getSlotRangeForEpoch(epoch, this.epochCache.getL1Constants());
110
196
  const { committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(fromSlot);
111
197
  if (isEscapeHatchOpen) {
112
- this.logger.info(`Skipping proven performance for epoch ${epoch} - escape hatch is open`);
198
+ this.logger.info(`Skipping epoch performance for epoch ${epoch} - escape hatch is open`);
113
199
  return {};
114
200
  }
115
201
  if (!committee) {
@@ -147,8 +233,8 @@ export class Sentinel extends EventEmitter {
147
233
  if (requiredConsecutiveEpochs === 0) {
148
234
  return true;
149
235
  }
150
- // Get all historical performance for this validator
151
- const allPerformance = await this.store.getProvenPerformance(validator);
236
+ // Get all historical per-epoch performance for this validator
237
+ const allPerformance = await this.store.getEpochPerformance(validator);
152
238
  // Sort by epoch descending to get most recent first, keep only epochs strictly before the current one, and get the first N
153
239
  const pastEpochs = allPerformance.sort((a, b)=>Number(b.epoch - a.epoch)).filter((p)=>p.epoch < currentEpoch);
154
240
  // If we don't have enough historical data, don't slash
@@ -157,13 +243,10 @@ export class Sentinel extends EventEmitter {
157
243
  return false;
158
244
  }
159
245
  // Check that we have at least requiredConsecutiveEpochs and that all of them are above the inactivity threshold
160
- return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.missed / p.total >= this.config.slashInactivityTargetPercentage);
246
+ return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.total === 0 ? false : p.missed / p.total >= this.config.slashInactivityTargetPercentage);
161
247
  }
162
- async handleProvenPerformance(epoch, performance) {
163
- if (this.config.slashInactivityPenalty === 0n) {
164
- return;
165
- }
166
- const inactiveValidators = getEntries(performance).filter(([_, { missed, total }])=>missed / total >= this.config.slashInactivityTargetPercentage).map(([address])=>address);
248
+ async handleEpochPerformance(epoch, performance) {
249
+ const inactiveValidators = getEntries(performance).filter(([_, { missed, total }])=>total > 0 && missed / total >= this.config.slashInactivityTargetPercentage).map(([address])=>address);
167
250
  this.logger.debug(`Found ${inactiveValidators.length} inactive validators in epoch ${epoch}`, {
168
251
  inactiveValidators,
169
252
  epoch,
@@ -178,8 +261,13 @@ export class Sentinel extends EventEmitter {
178
261
  epochOrSlot: BigInt(epoch)
179
262
  }));
180
263
  if (criminals.length > 0) {
181
- this.logger.verbose(`Identified ${criminals.length} validators to slash due to inactivity in at least ${epochThreshold} consecutive epochs`, {
182
- ...args,
264
+ this.logger.info(`Identified ${criminals.length} inactivity offenses in at least ${epochThreshold} consecutive epochs`, {
265
+ offenses: args.map((arg)=>({
266
+ validator: arg.validator.toString(),
267
+ amount: arg.amount,
268
+ offenseType: getOffenseTypeName(arg.offenseType),
269
+ epochOrSlot: arg.epochOrSlot
270
+ })),
183
271
  epochThreshold
184
272
  });
185
273
  this.emit(WANT_TO_SLASH_EVENT, args);
@@ -189,23 +277,61 @@ export class Sentinel extends EventEmitter {
189
277
  * Process data for two L2 slots ago.
190
278
  * Note that we do not process historical data, since we rely on p2p data for processing,
191
279
  * and we don't have that data if we were offline during the period.
280
+ *
281
+ * `currentSlot` is anchored to the archiver's last synced L2 slot rather than the wallclock,
282
+ * so the per-slot lag (`isReadyToProcess`) and the end-of-epoch buffer (`processEpochEnds`)
283
+ * advance with archiver.
192
284
  */ async work() {
193
- const currentSlot = this.epochCache.getSlotNow();
285
+ const currentSlot = await this.getCurrentSlot();
194
286
  try {
195
287
  // Manually sync the block stream to ensure we have the latest data.
196
288
  // Note we never `start` the blockstream, so it loops at the same pace as we do.
197
289
  await this.blockStream.sync();
198
- // Check if we are ready to process data for two L2 slots ago.
290
+ // Per-slot activity recording (lag = 2 slots for P2P attestation settlement).
199
291
  const targetSlot = await this.isReadyToProcess(currentSlot);
200
- // And process it if we are.
201
292
  if (targetSlot !== false) {
202
293
  await this.processSlot(targetSlot);
203
294
  }
295
+ // End-of-epoch evaluation (lag = sentinelEpochEndBufferSlots beyond the epoch's last slot).
296
+ await this.processEpochEnds(currentSlot);
204
297
  } catch (err) {
205
298
  this.logger.error(`Failed to process slot ${currentSlot}`, err);
206
299
  }
207
300
  }
208
301
  /**
302
+ * After the configured buffer has elapsed past an epoch's last slot, runs the end-of-epoch
303
+ * aggregator for that epoch. Catches up if multiple epochs become eligible at once.
304
+ */ async processEpochEnds(currentSlot) {
305
+ const constants = this.epochCache.getL1Constants();
306
+ const buffer = this.config.sentinelEpochEndBufferSlots;
307
+ if (currentSlot < buffer) {
308
+ return;
309
+ }
310
+ if (this.initialSlot === undefined) {
311
+ return;
312
+ }
313
+ // We can close epoch E iff:
314
+ // - the per-slot recorder has covered the epoch's last slot (lastProcessedSlot ≥ toSlot(E))
315
+ // - the buffer has elapsed past the epoch's last slot (currentSlot − buffer ≥ toSlot(E))
316
+ // - the epoch is not in the past relative to when the sentinel started (toSlot(E) > initialSlot)
317
+ if (this.lastProcessedSlot === undefined) {
318
+ return;
319
+ }
320
+ const slotForBuffer = SlotNumber(currentSlot - buffer);
321
+ // First eligible epoch to close is the one after lastEvaluatedEpoch, or the epoch containing
322
+ // the initial slot if we haven't evaluated any yet (the initialSlot epoch may be partial — we
323
+ // don't try to evaluate it, we start from initialSlot's epoch + 1).
324
+ const startEpoch = this.lastEvaluatedEpoch !== undefined ? EpochNumber(this.lastEvaluatedEpoch + 1) : EpochNumber(getEpochAtSlot(this.initialSlot, constants) + 1);
325
+ for(let epoch = startEpoch;; epoch = EpochNumber(epoch + 1)){
326
+ const [, toSlot] = getSlotRangeForEpoch(epoch, constants);
327
+ if (toSlot > this.lastProcessedSlot || toSlot > slotForBuffer) {
328
+ break;
329
+ }
330
+ await this.handleEpochEnd(epoch);
331
+ this.lastEvaluatedEpoch = epoch;
332
+ }
333
+ }
334
+ /**
209
335
  * Check if we are ready to process data for two L2 slots ago, so we allow plenty of time for p2p to process all in-flight attestations.
210
336
  * We also don't move past the archiver last synced L2 slot, as we don't want to process data that is not yet available.
211
337
  * Last, we check the p2p is synced with the archiver, so it has pulled all attestations from it.
@@ -271,39 +397,52 @@ export class Sentinel extends EventEmitter {
271
397
  await this.updateValidators(slot, stats);
272
398
  this.lastProcessedSlot = slot;
273
399
  }
274
- /** Computes activity for a given slot. */ async getSlotActivity(slot, epoch, proposer, committee) {
400
+ /**
401
+ * Computes activity for a given slot using the six-case taxonomy.
402
+ *
403
+ * Proposer status:
404
+ * - case 6 `checkpoint-mined` — a checkpoint covering this slot has landed on L1.
405
+ * - case 5 `checkpoint-valid` — the local node re-executed a checkpoint proposal for this
406
+ * slot successfully.
407
+ * - case 4 `checkpoint-invalid` — the local node re-executed a checkpoint proposal for this
408
+ * slot and rejected it.
409
+ * - case 3 `checkpoint-unvalidated` — the local node observed a checkpoint proposal for this
410
+ * slot but could not validate it (missing data, timeouts).
411
+ * - case 2 `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal.
412
+ * - case 1 `blocks-missed` — no block proposals seen for this slot.
413
+ *
414
+ * Missing-attestor penalties apply only in cases 5 and 6, where the local node has positive
415
+ * evidence the checkpoint was valid or has been canonicalised on L1.
416
+ */ async getSlotActivity(slot, epoch, proposer, committee) {
275
417
  this.logger.debug(`Computing stats for slot ${slot} at epoch ${epoch}`, {
276
418
  slot,
277
419
  epoch,
278
420
  proposer,
279
421
  committee
280
422
  });
281
- // Check if there is an L2 block in L1 for this L2 slot
282
- // Here we get all checkpoint attestations for the checkpoint at the given slot,
283
- // or all checkpoint attestations for all proposals in the slot if no checkpoint was mined.
284
- // We gather from both p2p (contains the ones seen on the p2p layer) and archiver
285
- // (contains the ones synced from mined checkpoints, which we may have missed from p2p).
423
+ // Gather attestors from both p2p (live attestations) and the archiver (signers on the
424
+ // checkpoint if one has landed on L1). Used regardless of which case applies.
286
425
  const checkpoint = this.slotNumberToCheckpoint.get(slot);
287
- const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, checkpoint?.archive);
288
- // Filter out attestations with invalid signatures
426
+ const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, checkpoint?.proposalPayloadHash);
289
427
  const p2pAttestors = p2pAttested.map((a)=>a.getSender()).filter((s)=>s !== undefined);
290
428
  const attestors = new Set([
291
429
  ...p2pAttestors.map((a)=>a.toString()),
292
430
  ...checkpoint?.attestors.map((a)=>a.toString()) ?? []
293
431
  ].filter((addr)=>proposer.toString() !== addr));
294
- // We assume that there was a block proposal if at least one of the validators (other than the proposer) attested to it.
295
- // It could be the case that every single validator failed, and we could differentiate it by having
296
- // this node re-execute every block proposal it sees and storing it in the attestation pool.
297
- // But we'll leave that corner case out to reduce pressure on the node.
298
- // TODO(palla/slash): This breaks if a given node has more than one validator in the current committee,
299
- // since they will attest to their own proposal it even if it's not re-executable.
432
+ // Determine the proposer status from the six-case taxonomy.
433
+ const reexecutionOutcome = this.reexecutionTracker.getOutcomeForSlot(slot);
300
434
  let status;
301
435
  if (checkpoint) {
302
436
  status = 'checkpoint-mined';
303
- } else if (attestors.size > 0) {
304
- status = 'checkpoint-proposed';
437
+ } else if (reexecutionOutcome === 'valid') {
438
+ status = 'checkpoint-valid';
439
+ } else if (reexecutionOutcome === 'invalid') {
440
+ status = 'checkpoint-invalid';
441
+ } else if (reexecutionOutcome === 'unvalidated') {
442
+ status = 'checkpoint-unvalidated';
305
443
  } else {
306
- // No checkpoint on L1 and no checkpoint attestations seen. Check if block proposals were sent for this slot.
444
+ // No L1 checkpoint, no local re-execution outcome for this slot. Distinguish "proposer
445
+ // sent block proposals but never made a checkpoint" from "proposer sent nothing".
307
446
  const hasBlockProposals = await this.p2p.hasBlockProposalsForSlot(slot);
308
447
  status = hasBlockProposals ? 'checkpoint-missed' : 'blocks-missed';
309
448
  }
@@ -311,8 +450,9 @@ export class Sentinel extends EventEmitter {
311
450
  ...checkpoint,
312
451
  slot
313
452
  });
314
- // Get attestors that failed their checkpoint attestation duties, but only if there was a checkpoint proposed or mined
315
- const missedAttestors = new Set(status === 'blocks-missed' || status === 'checkpoint-missed' ? [] : committee.filter((v)=>!attestors.has(v.toString()) && !proposer.equals(v)).map((v)=>v.toString()));
453
+ // Missing-attestor faults only apply when we have positive evidence the proposal was valid.
454
+ const attestorsExpected = status === 'checkpoint-mined' || status === 'checkpoint-valid';
455
+ const missedAttestors = new Set(attestorsExpected ? committee.filter((v)=>!attestors.has(v.toString()) && !proposer.equals(v)).map((v)=>v.toString()) : []);
316
456
  this.logger.debug(`Retrieved ${attestors.size} attestors out of ${committee.length} for slot ${slot}`, {
317
457
  status,
318
458
  proposer: proposer.toString(),
@@ -351,7 +491,7 @@ export class Sentinel extends EventEmitter {
351
491
  v.toString(),
352
492
  await this.store.getHistory(v)
353
493
  ]))) : await this.store.getHistories();
354
- const slotNow = this.epochCache.getSlotNow();
494
+ const slotNow = await this.getCurrentSlot();
355
495
  fromSlot ??= SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
356
496
  toSlot ??= this.lastProcessedSlot ?? slotNow;
357
497
  const stats = mapValues(histories, (history, address)=>this.computeStatsForValidator(address, history ?? [], fromSlot, toSlot));
@@ -367,7 +507,7 @@ export class Sentinel extends EventEmitter {
367
507
  if (!history || history.length === 0) {
368
508
  return undefined;
369
509
  }
370
- const slotNow = this.epochCache.getSlotNow();
510
+ const slotNow = await this.getCurrentSlot();
371
511
  const effectiveFromSlot = fromSlot ?? SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
372
512
  const effectiveToSlot = toSlot ?? this.lastProcessedSlot ?? slotNow;
373
513
  const historyLength = BigInt(this.store.getHistoryLength());
@@ -377,7 +517,7 @@ export class Sentinel extends EventEmitter {
377
517
  const validator = this.computeStatsForValidator(validatorAddress.toString(), history, effectiveFromSlot, effectiveToSlot);
378
518
  return {
379
519
  validator,
380
- allTimeProvenPerformance: await this.store.getProvenPerformance(validatorAddress),
520
+ allTimeEpochPerformance: await this.store.getEpochPerformance(validatorAddress),
381
521
  lastProcessedSlot: this.lastProcessedSlot,
382
522
  initialSlot: this.initialSlot,
383
523
  slotWindow: this.store.getHistoryLength()
@@ -386,7 +526,7 @@ export class Sentinel extends EventEmitter {
386
526
  computeStatsForValidator(address, allHistory, fromSlot, toSlot) {
387
527
  let history = fromSlot ? allHistory.filter((h)=>BigInt(h.slot) >= fromSlot) : allHistory;
388
528
  history = toSlot ? history.filter((h)=>BigInt(h.slot) <= toSlot) : history;
389
- const lastProposal = history.filter((h)=>h.status === 'checkpoint-proposed' || h.status === 'checkpoint-mined').at(-1);
529
+ const lastProposal = history.filter((h)=>h.status === 'checkpoint-valid' || h.status === 'checkpoint-mined').at(-1);
390
530
  const lastAttestation = history.filter((h)=>h.status === 'attestation-sent').at(-1);
391
531
  return {
392
532
  address: EthAddress.fromString(address),
@@ -395,7 +535,9 @@ export class Sentinel extends EventEmitter {
395
535
  totalSlots: history.length,
396
536
  missedProposals: this.computeMissed(history, 'proposer', [
397
537
  'checkpoint-missed',
398
- 'blocks-missed'
538
+ 'blocks-missed',
539
+ 'checkpoint-invalid',
540
+ 'checkpoint-unvalidated'
399
541
  ]),
400
542
  missedAttestations: this.computeMissed(history, 'attestation', [
401
543
  'attestation-missed'
@@ -5,22 +5,22 @@ import type { ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorsEpochPerf
5
5
  export declare class SentinelStore {
6
6
  private store;
7
7
  private config;
8
- static readonly SCHEMA_VERSION = 3;
8
+ static readonly SCHEMA_VERSION = 4;
9
9
  private readonly historyMap;
10
- private readonly provenMap;
10
+ private readonly epochMap;
11
11
  constructor(store: AztecAsyncKVStore, config: {
12
12
  historyLength: number;
13
- historicProvenPerformanceLength: number;
13
+ historicEpochPerformanceLength: number;
14
14
  });
15
15
  getHistoryLength(): number;
16
- getHistoricProvenPerformanceLength(): number;
17
- updateProvenPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance): Promise<void>;
18
- getProvenPerformance(who: EthAddress): Promise<{
16
+ getHistoricEpochPerformanceLength(): number;
17
+ updateEpochPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance): Promise<void>;
18
+ getEpochPerformance(who: EthAddress): Promise<{
19
19
  missed: number;
20
20
  total: number;
21
21
  epoch: EpochNumber;
22
22
  }[]>;
23
- private pushValidatorProvenPerformanceForEpoch;
23
+ private pushValidatorEpochPerformance;
24
24
  updateValidators(slot: SlotNumber, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>): Promise<void>;
25
25
  private pushValidatorStatusForSlot;
26
26
  getHistories(): Promise<Record<`0x${string}`, ValidatorStatusHistory>>;
@@ -32,4 +32,4 @@ export declare class SentinelStore {
32
32
  private statusToNumber;
33
33
  private statusFromNumber;
34
34
  }
35
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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BAAsB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,0BAA0B,iBAM9F;IAEY,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAA;KAAE,EAAE,CAAC,CAGlH;YAEa,6BAA6B;IA6B9B,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,qBAAqB,GAAG,SAAS,CAAC,iBAQjH;YAEa,0BAA0B;IAQ3B,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAMlF;IAEY,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAGxF;IAED,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,gBAAgB;CAsBzB"}
@@ -4,28 +4,28 @@ import { BufferReader, numToUInt8, numToUInt32BE, serializeToBuffer } from '@azt
4
4
  export class SentinelStore {
5
5
  store;
6
6
  config;
7
- static SCHEMA_VERSION = 3;
7
+ static SCHEMA_VERSION = 4;
8
8
  // a map from validator address to their ValidatorStatusHistory
9
9
  historyMap;
10
- // a map from validator address to their historical proven epoch performance
10
+ // a map from validator address to their historical epoch performance, evaluated at end-of-epoch.
11
11
  // e.g. { validator: [{ epoch: 1, missed: 1, total: 10 }, { epoch: 2, missed: 3, total: 7 }, ...] }
12
- provenMap;
12
+ epochMap;
13
13
  constructor(store, config){
14
14
  this.store = store;
15
15
  this.config = config;
16
16
  this.historyMap = store.openMap('sentinel-validator-status');
17
- this.provenMap = store.openMap('sentinel-validator-proven');
17
+ this.epochMap = store.openMap('sentinel-validator-epoch');
18
18
  }
19
19
  getHistoryLength() {
20
20
  return this.config.historyLength;
21
21
  }
22
- getHistoricProvenPerformanceLength() {
23
- return this.config.historicProvenPerformanceLength;
22
+ getHistoricEpochPerformanceLength() {
23
+ return this.config.historicEpochPerformanceLength;
24
24
  }
25
- async updateProvenPerformance(epoch, performance) {
25
+ async updateEpochPerformance(epoch, performance) {
26
26
  await this.store.transactionAsync(async ()=>{
27
27
  for (const [who, { missed, total }] of Object.entries(performance)){
28
- await this.pushValidatorProvenPerformanceForEpoch({
28
+ await this.pushValidatorEpochPerformance({
29
29
  who: EthAddress.fromString(who),
30
30
  missed,
31
31
  total,
@@ -34,12 +34,12 @@ export class SentinelStore {
34
34
  }
35
35
  });
36
36
  }
37
- async getProvenPerformance(who) {
38
- const currentPerformanceBuffer = await this.provenMap.getAsync(who.toString());
37
+ async getEpochPerformance(who) {
38
+ const currentPerformanceBuffer = await this.epochMap.getAsync(who.toString());
39
39
  return currentPerformanceBuffer ? this.deserializePerformance(currentPerformanceBuffer) : [];
40
40
  }
41
- async pushValidatorProvenPerformanceForEpoch({ who, missed, total, epoch }) {
42
- const currentPerformance = await this.getProvenPerformance(who);
41
+ async pushValidatorEpochPerformance({ who, missed, total, epoch }) {
42
+ const currentPerformance = await this.getEpochPerformance(who);
43
43
  const existingIndex = currentPerformance.findIndex((p)=>p.epoch === epoch);
44
44
  if (existingIndex !== -1) {
45
45
  currentPerformance[existingIndex] = {
@@ -57,9 +57,9 @@ export class SentinelStore {
57
57
  // This should be sorted by epoch, but just in case.
58
58
  // Since we keep the size small, this is not a big deal.
59
59
  currentPerformance.sort((a, b)=>Number(a.epoch - b.epoch));
60
- // keep the most recent `historicProvenPerformanceLength` entries.
61
- const performanceToKeep = currentPerformance.slice(-this.config.historicProvenPerformanceLength);
62
- await this.provenMap.set(who.toString(), this.serializePerformance(performanceToKeep));
60
+ // keep the most recent `historicEpochPerformanceLength` entries.
61
+ const performanceToKeep = currentPerformance.slice(-this.config.historicEpochPerformanceLength);
62
+ await this.epochMap.set(who.toString(), this.serializePerformance(performanceToKeep));
63
63
  }
64
64
  async updateValidators(slot, statuses) {
65
65
  await this.store.transactionAsync(async ()=>{
@@ -136,7 +136,7 @@ export class SentinelStore {
136
136
  switch(status){
137
137
  case 'checkpoint-mined':
138
138
  return 1;
139
- case 'checkpoint-proposed':
139
+ case 'checkpoint-valid':
140
140
  return 2;
141
141
  case 'checkpoint-missed':
142
142
  return 3;
@@ -146,6 +146,10 @@ export class SentinelStore {
146
146
  return 5;
147
147
  case 'blocks-missed':
148
148
  return 6;
149
+ case 'checkpoint-invalid':
150
+ return 7;
151
+ case 'checkpoint-unvalidated':
152
+ return 8;
149
153
  default:
150
154
  {
151
155
  const _exhaustive = status;
@@ -158,7 +162,7 @@ export class SentinelStore {
158
162
  case 1:
159
163
  return 'checkpoint-mined';
160
164
  case 2:
161
- return 'checkpoint-proposed';
165
+ return 'checkpoint-valid';
162
166
  case 3:
163
167
  return 'checkpoint-missed';
164
168
  case 4:
@@ -167,6 +171,10 @@ export class SentinelStore {
167
171
  return 'attestation-missed';
168
172
  case 6:
169
173
  return 'blocks-missed';
174
+ case 7:
175
+ return 'checkpoint-invalid';
176
+ case 8:
177
+ return 'checkpoint-unvalidated';
170
178
  default:
171
179
  throw new Error(`Unknown status: ${status}`);
172
180
  }