@aztec/aztec-node 0.0.1-commit.a072138 → 0.0.1-commit.a5db02d
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/block_response_helpers.d.ts +25 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +112 -0
- package/dest/aztec-node/config.d.ts +23 -8
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +26 -8
- package/dest/aztec-node/node_public_calls_simulator.d.ts +90 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +346 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
- package/dest/aztec-node/server.d.ts +140 -135
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +490 -730
- package/dest/bin/index.js +15 -10
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +509 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/modules/block_parameter.d.ts +25 -0
- package/dest/modules/block_parameter.d.ts.map +1 -0
- package/dest/modules/block_parameter.js +100 -0
- package/dest/modules/node_block_provider.d.ts +19 -0
- package/dest/modules/node_block_provider.d.ts.map +1 -0
- package/dest/modules/node_block_provider.js +112 -0
- package/dest/modules/node_tx_receipt.d.ts +24 -0
- package/dest/modules/node_tx_receipt.d.ts.map +1 -0
- package/dest/modules/node_tx_receipt.js +70 -0
- package/dest/modules/node_world_state_queries.d.ts +65 -0
- package/dest/modules/node_world_state_queries.d.ts.map +1 -0
- package/dest/modules/node_world_state_queries.js +272 -0
- package/dest/sentinel/config.d.ts +3 -2
- package/dest/sentinel/config.d.ts.map +1 -1
- package/dest/sentinel/config.js +15 -5
- package/dest/sentinel/factory.d.ts +6 -4
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +12 -5
- package/dest/sentinel/sentinel.d.ts +146 -22
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +266 -118
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +33 -21
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +55 -16
- package/src/aztec-node/node_public_calls_simulator.ts +383 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
- package/src/aztec-node/server.ts +632 -939
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +673 -0
- package/src/index.ts +2 -0
- package/src/modules/block_parameter.ts +93 -0
- package/src/modules/node_block_provider.ts +149 -0
- package/src/modules/node_tx_receipt.ts +115 -0
- package/src/modules/node_world_state_queries.ts +374 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +22 -7
- package/src/sentinel/sentinel.ts +316 -136
- package/src/sentinel/store.ts +35 -27
- package/src/test/index.ts +2 -2
|
@@ -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;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/sentinel/sentinel.ts"],"names":[],"mappings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OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAkC3C;IAED,SAAS,CAAC,wBAAwB,CAChC,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,UAAU,EAAE,sBAAsB,EAClC,QAAQ,CAAC,EAAE,UAAU,EACrB,MAAM,CAAC,EAAE,UAAU,GAClB,cAAc,CAmBhB;IAED,SAAS,CAAC,aAAa,CACrB,OAAO,EAAE,sBAAsB,EAC/B,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,EACpD,MAAM,EAAE,qBAAqB,EAAE;;;;;MAYhC;IAED,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;;;;kBAMrD;CACF"}
|
|
@@ -1,33 +1,114 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { L2BlockStream, getAttestationInfoFromPublishedCheckpoint } from '@aztec/stdlib/block';
|
|
6
|
+
import { OffenseType, WANT_TO_SLASH_EVENT, getOffenseTypeName } from '@aztec/slasher';
|
|
7
|
+
import { getAttestationInfoFromPublishedCheckpoint } from '@aztec/stdlib/block';
|
|
9
8
|
import { getEpochAtSlot, getSlotRangeForEpoch, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
9
|
+
import { ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
10
10
|
import EventEmitter from 'node:events';
|
|
11
|
-
|
|
11
|
+
/** Maps a validator status to its category: proposer or attestation. */ function statusToCategory(status) {
|
|
12
|
+
switch(status){
|
|
13
|
+
case 'attestation-sent':
|
|
14
|
+
case 'attestation-missed':
|
|
15
|
+
return 'attestation';
|
|
16
|
+
default:
|
|
17
|
+
return 'proposer';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Sentinel observes validator behaviour every L2 slot, classifies it into a per-slot status,
|
|
22
|
+
* aggregates those statuses into per-epoch performance once each epoch is fully observed, and
|
|
23
|
+
* emits inactivity slash payloads when a validator has been inactive for the configured number
|
|
24
|
+
* of consecutive epochs.
|
|
25
|
+
*
|
|
26
|
+
* ## Two cadences
|
|
27
|
+
*
|
|
28
|
+
* The sentinel runs `work()` every quarter L2 slot and drives two independent pipelines:
|
|
29
|
+
*
|
|
30
|
+
* 1. **Per-slot activity recording.** `processSlot(currentSlot - 2)` runs once per slot, with a
|
|
31
|
+
* two-slot lag to let P2P attestations settle and the archiver catch up. It classifies each
|
|
32
|
+
* committee member's behaviour for that slot via `getSlotActivity` and persists the result to
|
|
33
|
+
* `SentinelStore.historyMap` (sliding window of `sentinelHistoryLengthInEpochs * epochDuration`
|
|
34
|
+
* slots, default 24 epochs).
|
|
35
|
+
*
|
|
36
|
+
* 2. **Per-epoch evaluation.** `processEpochEnds(currentSlot)` runs every tick too. Once
|
|
37
|
+
* `sentinelEpochEndBufferSlots` (default 2) has elapsed past an epoch's last slot AND the
|
|
38
|
+
* per-slot recorder has covered that last slot, the sentinel calls `handleEpochEnd(epoch)`.
|
|
39
|
+
* That aggregates the slot-level statuses for the epoch into per-validator `{missed, total}`,
|
|
40
|
+
* persists it to `SentinelStore.epochMap` (default 2000-epoch window), and runs the slashing
|
|
41
|
+
* decision.
|
|
42
|
+
*
|
|
43
|
+
* Triggering per-epoch evaluation off local L2 state — rather than waiting for L1 proof
|
|
44
|
+
* publication — decouples slashing from prover availability.
|
|
45
|
+
*
|
|
46
|
+
* ## Six-case taxonomy in `getSlotActivity`
|
|
47
|
+
*
|
|
48
|
+
* For each slot, the sentinel assigns the proposer one of six statuses, ranked highest-confidence
|
|
49
|
+
* first:
|
|
50
|
+
*
|
|
51
|
+
* - `checkpoint-mined` — a checkpoint covering this slot has landed on L1
|
|
52
|
+
* (fetched on demand via `archiver.getCheckpoint({ slot })`).
|
|
53
|
+
* - `checkpoint-valid` — the local node re-executed a checkpoint proposal for this slot
|
|
54
|
+
* successfully (consulted via `CheckpointReexecutionTracker`).
|
|
55
|
+
* - `checkpoint-invalid` — the local node re-executed a checkpoint proposal for this slot
|
|
56
|
+
* and rejected it (e.g. header/archive/out-hash mismatch, limit
|
|
57
|
+
* breach). Proposer-fault.
|
|
58
|
+
* - `checkpoint-unvalidated` — the local node observed a checkpoint proposal but could not
|
|
59
|
+
* validate it (missing blocks/txs, timeouts). Treated as
|
|
60
|
+
* proposer-fault for slashing.
|
|
61
|
+
* - `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal at all.
|
|
62
|
+
* - `blocks-missed` — no block proposals seen for this slot.
|
|
63
|
+
*
|
|
64
|
+
* Missing-attestor faults are recorded only in `checkpoint-mined` and `checkpoint-valid`, where
|
|
65
|
+
* the local node has positive evidence the checkpoint was canonical or valid. In the other four
|
|
66
|
+
* cases the proposer is at fault and no attestor penalty applies.
|
|
67
|
+
*
|
|
68
|
+
* ## Re-execution tracker
|
|
69
|
+
*
|
|
70
|
+
* `CheckpointReexecutionTracker` is populated by the validator client's checkpoint proposal
|
|
71
|
+
* handler. Every early return in `validateCheckpointProposal` records an outcome
|
|
72
|
+
* (`valid` / `invalid` / `unvalidated`) keyed by slot.
|
|
73
|
+
*
|
|
74
|
+
* ## Inactivity slashing
|
|
75
|
+
*
|
|
76
|
+
* `handleEpochPerformance` filters the epoch's per-validator stats by
|
|
77
|
+
* `slashInactivityTargetPercentage` and then calls `checkPastInactivity` to require
|
|
78
|
+
* `slashInactivityConsecutiveEpochThreshold` consecutive past epochs over the same threshold
|
|
79
|
+
* (read from `SentinelStore.epochMap`). Only validators meeting both conditions are emitted as
|
|
80
|
+
* `WANT_TO_SLASH_EVENT` with `OffenseType.INACTIVITY`. The slot-level counters that feed this —
|
|
81
|
+
* `missedProposals` and `missedAttestations` — include the four proposer-fault statuses plus
|
|
82
|
+
* `attestation-missed`.
|
|
83
|
+
*
|
|
84
|
+
* ## Escape hatch
|
|
85
|
+
*
|
|
86
|
+
* If `epochCache.getCommittee(slot)` reports `isEscapeHatchOpen`, per-slot recording is skipped
|
|
87
|
+
* (no history entries for that slot) and per-epoch evaluation writes an empty performance map
|
|
88
|
+
* (no slashing).
|
|
89
|
+
*/ export class Sentinel extends EventEmitter {
|
|
12
90
|
epochCache;
|
|
13
91
|
archiver;
|
|
14
92
|
p2p;
|
|
15
93
|
store;
|
|
94
|
+
reexecutionTracker;
|
|
16
95
|
config;
|
|
17
96
|
logger;
|
|
18
97
|
runningPromise;
|
|
19
|
-
blockStream;
|
|
20
|
-
l2TipsStore;
|
|
21
98
|
initialSlot;
|
|
22
99
|
lastProcessedSlot;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
super(), this.epochCache = epochCache, this.archiver = archiver, this.p2p = p2p, this.store = store, this.config = config, this.logger = logger, this.slotNumberToCheckpoint = new Map();
|
|
27
|
-
this.l2TipsStore = new L2TipsMemoryStore();
|
|
100
|
+
/** Largest epoch number for which the end-of-epoch aggregator has run. */ lastEvaluatedEpoch;
|
|
101
|
+
constructor(epochCache, archiver, p2p, store, reexecutionTracker, config, logger = createLogger('node:sentinel')){
|
|
102
|
+
super(), this.epochCache = epochCache, this.archiver = archiver, this.p2p = p2p, this.store = store, this.reexecutionTracker = reexecutionTracker, this.config = config, this.logger = logger;
|
|
28
103
|
const interval = epochCache.getL1Constants().ethereumSlotDuration * 1000 / 4;
|
|
29
104
|
this.runningPromise = new RunningPromise(this.work.bind(this), logger, interval);
|
|
30
105
|
}
|
|
106
|
+
getSignatureContext() {
|
|
107
|
+
return {
|
|
108
|
+
chainId: this.config.l1ChainId,
|
|
109
|
+
rollupAddress: this.config.rollupAddress
|
|
110
|
+
};
|
|
111
|
+
}
|
|
31
112
|
updateConfig(config) {
|
|
32
113
|
this.config = {
|
|
33
114
|
...this.config,
|
|
@@ -38,69 +119,67 @@ export class Sentinel extends EventEmitter {
|
|
|
38
119
|
await this.init();
|
|
39
120
|
this.runningPromise.start();
|
|
40
121
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Loads the initial slot. We will not process anything at or before the initial slot. Floors at the
|
|
124
|
+
* archiver's synced L2 slot so the sentinel keeps making forward progress when L1 is advancing but L2 has no
|
|
125
|
+
* activity (the synced slot is driven by L1 sync, not by L2 blocks). Falls back to the wallclock if the
|
|
126
|
+
* archiver isn't ready yet (cold start).
|
|
127
|
+
*/ async init() {
|
|
128
|
+
this.initialSlot = await this.getCurrentSlot();
|
|
129
|
+
this.logger.info(`Starting validator sentinel with initial slot ${this.initialSlot}`);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the L2 slot the sentinel should treat as "current": the archiver's last fully
|
|
133
|
+
* synced L2 slot, falling back to the wallclock slot when the archiver isn't ready yet
|
|
134
|
+
* (cold start). Anchoring to the synced slot keeps timing arithmetic (initial floor,
|
|
135
|
+
* per-slot lag, end-of-epoch buffer, stats-range fallback) from speculating ahead of where
|
|
136
|
+
* L1 actually is.
|
|
137
|
+
*/ async getCurrentSlot() {
|
|
138
|
+
return await this.archiver.getSyncedL2SlotNumber() ?? this.epochCache.getSlotNow();
|
|
48
139
|
}
|
|
49
140
|
stop() {
|
|
50
141
|
return this.runningPromise.stop();
|
|
51
142
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Fetches the L1-confirmed checkpoint covering a slot (if any) and derives the slot-level data the
|
|
145
|
+
* activity classifier needs: the checkpoint number, archive root, consensus payload hash (used to fetch
|
|
146
|
+
* matching p2p attestations regardless of feeAssetPriceModifier variants), and the recovered attestor set.
|
|
147
|
+
* Reads on demand so the result is always against the canonical chain — a reorged-out checkpoint simply
|
|
148
|
+
* stops being returned, with no stale mapping to clean up.
|
|
149
|
+
*/ async getCheckpointForSlot(slot) {
|
|
150
|
+
const checkpoint = await this.archiver.getCheckpoint({
|
|
151
|
+
slot
|
|
152
|
+
});
|
|
153
|
+
if (!checkpoint) {
|
|
154
|
+
return undefined;
|
|
63
155
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
156
|
+
const signatureContext = this.getSignatureContext();
|
|
157
|
+
const proposalPayloadHash = CheckpointProposalHash.fromBuffer(ConsensusPayload.fromCheckpoint(checkpoint.checkpoint, signatureContext).getPayloadHash());
|
|
158
|
+
return {
|
|
67
159
|
checkpointNumber: checkpoint.checkpoint.number,
|
|
68
160
|
archive: checkpoint.checkpoint.archive.root.toString(),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const historyLength = this.store.getHistoryLength();
|
|
73
|
-
if (this.slotNumberToCheckpoint.size > historyLength) {
|
|
74
|
-
const toDelete = Array.from(this.slotNumberToCheckpoint.keys()).sort((a, b)=>Number(a - b)).slice(0, this.slotNumberToCheckpoint.size - historyLength);
|
|
75
|
-
for (const key of toDelete){
|
|
76
|
-
this.slotNumberToCheckpoint.delete(key);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
161
|
+
proposalPayloadHash,
|
|
162
|
+
attestors: getAttestationInfoFromPublishedCheckpoint(checkpoint, signatureContext).filter((a)=>a.status === 'recovered-from-signature').map((a)=>a.address)
|
|
163
|
+
};
|
|
79
164
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// TODO(palla/slash): We should only be computing proven performance if this is
|
|
93
|
-
// a full proof epoch and not a partial one, otherwise we'll end up with skewed stats.
|
|
94
|
-
const epoch = getEpochAtSlot(block.header.getSlot(), this.epochCache.getL1Constants());
|
|
95
|
-
this.logger.debug(`Computing proven performance for epoch ${epoch}`);
|
|
96
|
-
const performance = await this.computeProvenPerformance(epoch);
|
|
97
|
-
this.logger.info(`Computed proven performance for epoch ${epoch}`, performance);
|
|
98
|
-
await this.store.updateProvenPerformance(epoch, performance);
|
|
99
|
-
await this.handleProvenPerformance(epoch, performance);
|
|
165
|
+
/**
|
|
166
|
+
* Called once per epoch, after the configured end-of-epoch buffer has elapsed beyond the
|
|
167
|
+
* epoch's last slot. Computes per-epoch performance from the slot-level history collected
|
|
168
|
+
* by `processSlot` and emits any inactivity slash payloads.
|
|
169
|
+
*/ async handleEpochEnd(epoch) {
|
|
170
|
+
this.logger.debug(`Computing epoch performance for epoch ${epoch}`);
|
|
171
|
+
const performance = await this.computeEpochPerformance(epoch);
|
|
172
|
+
this.logger.info(`Computed epoch performance for epoch ${epoch}`, performance);
|
|
173
|
+
await this.store.updateEpochPerformance(epoch, performance);
|
|
174
|
+
await this.handleEpochPerformance(epoch, performance);
|
|
100
175
|
}
|
|
101
|
-
async
|
|
176
|
+
async computeEpochPerformance(epoch) {
|
|
102
177
|
const [fromSlot, toSlot] = getSlotRangeForEpoch(epoch, this.epochCache.getL1Constants());
|
|
103
|
-
const { committee } = await this.epochCache.getCommittee(fromSlot);
|
|
178
|
+
const { committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(fromSlot);
|
|
179
|
+
if (isEscapeHatchOpen) {
|
|
180
|
+
this.logger.info(`Skipping epoch performance for epoch ${epoch} - escape hatch is open`);
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
104
183
|
if (!committee) {
|
|
105
184
|
this.logger.trace(`No committee found for slot ${fromSlot}`);
|
|
106
185
|
return {};
|
|
@@ -136,8 +215,8 @@ export class Sentinel extends EventEmitter {
|
|
|
136
215
|
if (requiredConsecutiveEpochs === 0) {
|
|
137
216
|
return true;
|
|
138
217
|
}
|
|
139
|
-
// Get all historical performance for this validator
|
|
140
|
-
const allPerformance = await this.store.
|
|
218
|
+
// Get all historical per-epoch performance for this validator
|
|
219
|
+
const allPerformance = await this.store.getEpochPerformance(validator);
|
|
141
220
|
// Sort by epoch descending to get most recent first, keep only epochs strictly before the current one, and get the first N
|
|
142
221
|
const pastEpochs = allPerformance.sort((a, b)=>Number(b.epoch - a.epoch)).filter((p)=>p.epoch < currentEpoch);
|
|
143
222
|
// If we don't have enough historical data, don't slash
|
|
@@ -146,13 +225,10 @@ export class Sentinel extends EventEmitter {
|
|
|
146
225
|
return false;
|
|
147
226
|
}
|
|
148
227
|
// Check that we have at least requiredConsecutiveEpochs and that all of them are above the inactivity threshold
|
|
149
|
-
return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.missed / p.total >= this.config.slashInactivityTargetPercentage);
|
|
228
|
+
return pastEpochs.slice(0, requiredConsecutiveEpochs).every((p)=>p.total === 0 ? false : p.missed / p.total >= this.config.slashInactivityTargetPercentage);
|
|
150
229
|
}
|
|
151
|
-
async
|
|
152
|
-
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const inactiveValidators = getEntries(performance).filter(([_, { missed, total }])=>missed / total >= this.config.slashInactivityTargetPercentage).map(([address])=>address);
|
|
230
|
+
async handleEpochPerformance(epoch, performance) {
|
|
231
|
+
const inactiveValidators = getEntries(performance).filter(([_, { missed, total }])=>total > 0 && missed / total >= this.config.slashInactivityTargetPercentage).map(([address])=>address);
|
|
156
232
|
this.logger.debug(`Found ${inactiveValidators.length} inactive validators in epoch ${epoch}`, {
|
|
157
233
|
inactiveValidators,
|
|
158
234
|
epoch,
|
|
@@ -167,8 +243,13 @@ export class Sentinel extends EventEmitter {
|
|
|
167
243
|
epochOrSlot: BigInt(epoch)
|
|
168
244
|
}));
|
|
169
245
|
if (criminals.length > 0) {
|
|
170
|
-
this.logger.
|
|
171
|
-
|
|
246
|
+
this.logger.info(`Identified ${criminals.length} inactivity offenses in at least ${epochThreshold} consecutive epochs`, {
|
|
247
|
+
offenses: args.map((arg)=>({
|
|
248
|
+
validator: arg.validator.toString(),
|
|
249
|
+
amount: arg.amount,
|
|
250
|
+
offenseType: getOffenseTypeName(arg.offenseType),
|
|
251
|
+
epochOrSlot: arg.epochOrSlot
|
|
252
|
+
})),
|
|
172
253
|
epochThreshold
|
|
173
254
|
});
|
|
174
255
|
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
@@ -178,23 +259,58 @@ export class Sentinel extends EventEmitter {
|
|
|
178
259
|
* Process data for two L2 slots ago.
|
|
179
260
|
* Note that we do not process historical data, since we rely on p2p data for processing,
|
|
180
261
|
* and we don't have that data if we were offline during the period.
|
|
262
|
+
*
|
|
263
|
+
* `currentSlot` is anchored to the archiver's last synced L2 slot rather than the wallclock,
|
|
264
|
+
* so the per-slot lag (`isReadyToProcess`) and the end-of-epoch buffer (`processEpochEnds`)
|
|
265
|
+
* advance with archiver.
|
|
181
266
|
*/ async work() {
|
|
182
|
-
const
|
|
267
|
+
const currentSlot = await this.getCurrentSlot();
|
|
183
268
|
try {
|
|
184
|
-
//
|
|
185
|
-
// Note we never `start` the blockstream, so it loops at the same pace as we do.
|
|
186
|
-
await this.blockStream.sync();
|
|
187
|
-
// Check if we are ready to process data for two L2 slots ago.
|
|
269
|
+
// Per-slot activity recording (lag = 2 slots for P2P attestation settlement).
|
|
188
270
|
const targetSlot = await this.isReadyToProcess(currentSlot);
|
|
189
|
-
// And process it if we are.
|
|
190
271
|
if (targetSlot !== false) {
|
|
191
272
|
await this.processSlot(targetSlot);
|
|
192
273
|
}
|
|
274
|
+
// End-of-epoch evaluation (lag = sentinelEpochEndBufferSlots beyond the epoch's last slot).
|
|
275
|
+
await this.processEpochEnds(currentSlot);
|
|
193
276
|
} catch (err) {
|
|
194
277
|
this.logger.error(`Failed to process slot ${currentSlot}`, err);
|
|
195
278
|
}
|
|
196
279
|
}
|
|
197
280
|
/**
|
|
281
|
+
* After the configured buffer has elapsed past an epoch's last slot, runs the end-of-epoch
|
|
282
|
+
* aggregator for that epoch. Catches up if multiple epochs become eligible at once.
|
|
283
|
+
*/ async processEpochEnds(currentSlot) {
|
|
284
|
+
const constants = this.epochCache.getL1Constants();
|
|
285
|
+
const buffer = this.config.sentinelEpochEndBufferSlots;
|
|
286
|
+
if (currentSlot < buffer) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (this.initialSlot === undefined) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
// We can close epoch E iff:
|
|
293
|
+
// - the per-slot recorder has covered the epoch's last slot (lastProcessedSlot ≥ toSlot(E))
|
|
294
|
+
// - the buffer has elapsed past the epoch's last slot (currentSlot − buffer ≥ toSlot(E))
|
|
295
|
+
// - the epoch is not in the past relative to when the sentinel started (toSlot(E) > initialSlot)
|
|
296
|
+
if (this.lastProcessedSlot === undefined) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const slotForBuffer = SlotNumber(currentSlot - buffer);
|
|
300
|
+
// First eligible epoch to close is the one after lastEvaluatedEpoch, or the epoch containing
|
|
301
|
+
// the initial slot if we haven't evaluated any yet (the initialSlot epoch may be partial — we
|
|
302
|
+
// don't try to evaluate it, we start from initialSlot's epoch + 1).
|
|
303
|
+
const startEpoch = this.lastEvaluatedEpoch !== undefined ? EpochNumber(this.lastEvaluatedEpoch + 1) : EpochNumber(getEpochAtSlot(this.initialSlot, constants) + 1);
|
|
304
|
+
for(let epoch = startEpoch;; epoch = EpochNumber(epoch + 1)){
|
|
305
|
+
const [, toSlot] = getSlotRangeForEpoch(epoch, constants);
|
|
306
|
+
if (toSlot > this.lastProcessedSlot || toSlot > slotForBuffer) {
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
await this.handleEpochEnd(epoch);
|
|
310
|
+
this.lastEvaluatedEpoch = epoch;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
198
314
|
* 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.
|
|
199
315
|
* 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.
|
|
200
316
|
* Last, we check the p2p is synced with the archiver, so it has pulled all attestations from it.
|
|
@@ -218,15 +334,15 @@ export class Sentinel extends EventEmitter {
|
|
|
218
334
|
this.logger.trace(`Refusing to process slot ${targetSlot} given initial slot ${this.initialSlot}`);
|
|
219
335
|
return false;
|
|
220
336
|
}
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
337
|
+
const syncedSlot = await this.archiver.getSyncedL2SlotNumber();
|
|
338
|
+
if (syncedSlot === undefined || syncedSlot < targetSlot) {
|
|
223
339
|
this.logger.debug(`Waiting for archiver to sync with L2 slot ${targetSlot}`, {
|
|
224
|
-
|
|
340
|
+
syncedSlot,
|
|
225
341
|
targetSlot
|
|
226
342
|
});
|
|
227
343
|
return false;
|
|
228
344
|
}
|
|
229
|
-
const archiverLastBlockHash = await this.
|
|
345
|
+
const archiverLastBlockHash = await this.archiver.getL2Tips().then((tip)=>tip.proposed.hash);
|
|
230
346
|
const p2pLastBlockHash = await this.p2p.getL2Tips().then((tips)=>tips.proposed.hash);
|
|
231
347
|
const isP2pSynced = archiverLastBlockHash === p2pLastBlockHash;
|
|
232
348
|
if (!isP2pSynced) {
|
|
@@ -242,7 +358,12 @@ export class Sentinel extends EventEmitter {
|
|
|
242
358
|
* Gathers committee and proposer data for a given slot, computes slot stats,
|
|
243
359
|
* and updates overall stats.
|
|
244
360
|
*/ async processSlot(slot) {
|
|
245
|
-
const { epoch, seed, committee } = await this.epochCache.getCommittee(slot);
|
|
361
|
+
const { epoch, seed, committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(slot);
|
|
362
|
+
if (isEscapeHatchOpen) {
|
|
363
|
+
this.logger.info(`Skipping slot ${slot} at epoch ${epoch} - escape hatch is open`);
|
|
364
|
+
this.lastProcessedSlot = slot;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
246
367
|
if (!committee || committee.length === 0) {
|
|
247
368
|
this.logger.trace(`No committee found for slot ${slot} at epoch ${epoch}`);
|
|
248
369
|
this.lastProcessedSlot = slot;
|
|
@@ -255,43 +376,67 @@ export class Sentinel extends EventEmitter {
|
|
|
255
376
|
await this.updateValidators(slot, stats);
|
|
256
377
|
this.lastProcessedSlot = slot;
|
|
257
378
|
}
|
|
258
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* Computes activity for a given slot using the six-case taxonomy.
|
|
381
|
+
*
|
|
382
|
+
* Proposer status:
|
|
383
|
+
* - case 6 `checkpoint-mined` — a checkpoint covering this slot has landed on L1.
|
|
384
|
+
* - case 5 `checkpoint-valid` — the local node re-executed a checkpoint proposal for this
|
|
385
|
+
* slot successfully.
|
|
386
|
+
* - case 4 `checkpoint-invalid` — the local node re-executed a checkpoint proposal for this
|
|
387
|
+
* slot and rejected it.
|
|
388
|
+
* - case 3 `checkpoint-unvalidated` — the local node observed a checkpoint proposal for this
|
|
389
|
+
* slot but could not validate it (missing data, timeouts).
|
|
390
|
+
* - case 2 `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal.
|
|
391
|
+
* - case 1 `blocks-missed` — no block proposals seen for this slot.
|
|
392
|
+
*
|
|
393
|
+
* Missing-attestor penalties apply only in cases 5 and 6, where the local node has positive
|
|
394
|
+
* evidence the checkpoint was valid or has been canonicalised on L1.
|
|
395
|
+
*/ async getSlotActivity(slot, epoch, proposer, committee) {
|
|
259
396
|
this.logger.debug(`Computing stats for slot ${slot} at epoch ${epoch}`, {
|
|
260
397
|
slot,
|
|
261
398
|
epoch,
|
|
262
399
|
proposer,
|
|
263
400
|
committee
|
|
264
401
|
});
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const block = this.slotNumberToCheckpoint.get(slot);
|
|
271
|
-
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, block?.archive);
|
|
272
|
-
// Filter out attestations with invalid signatures
|
|
402
|
+
// Gather attestors from both p2p (live attestations) and the archiver (signers on the
|
|
403
|
+
// checkpoint if one has landed on L1). Fetched on demand so it always reflects the canonical chain.
|
|
404
|
+
// Used regardless of which case applies.
|
|
405
|
+
const checkpoint = await this.getCheckpointForSlot(slot);
|
|
406
|
+
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, checkpoint?.proposalPayloadHash);
|
|
273
407
|
const p2pAttestors = p2pAttested.map((a)=>a.getSender()).filter((s)=>s !== undefined);
|
|
274
408
|
const attestors = new Set([
|
|
275
409
|
...p2pAttestors.map((a)=>a.toString()),
|
|
276
|
-
...
|
|
410
|
+
...checkpoint?.attestors.map((a)=>a.toString()) ?? []
|
|
277
411
|
].filter((addr)=>proposer.toString() !== addr));
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
412
|
+
// Determine the proposer status from the six-case taxonomy.
|
|
413
|
+
const reexecutionOutcome = this.reexecutionTracker.getOutcomeForSlot(slot);
|
|
414
|
+
let status;
|
|
415
|
+
if (checkpoint) {
|
|
416
|
+
status = 'checkpoint-mined';
|
|
417
|
+
} else if (reexecutionOutcome === 'valid') {
|
|
418
|
+
status = 'checkpoint-valid';
|
|
419
|
+
} else if (reexecutionOutcome === 'invalid') {
|
|
420
|
+
status = 'checkpoint-invalid';
|
|
421
|
+
} else if (reexecutionOutcome === 'unvalidated') {
|
|
422
|
+
status = 'checkpoint-unvalidated';
|
|
423
|
+
} else {
|
|
424
|
+
// No L1 checkpoint, no local re-execution outcome for this slot. Distinguish "proposer
|
|
425
|
+
// sent block proposals but never made a checkpoint" from "proposer sent nothing".
|
|
426
|
+
const hasBlockProposals = await this.p2p.hasBlockProposalsForSlot(slot);
|
|
427
|
+
status = hasBlockProposals ? 'checkpoint-missed' : 'blocks-missed';
|
|
428
|
+
}
|
|
429
|
+
this.logger.debug(`Checkpoint status for slot ${slot}: ${status}`, {
|
|
430
|
+
...checkpoint,
|
|
287
431
|
slot
|
|
288
432
|
});
|
|
289
|
-
//
|
|
290
|
-
const
|
|
433
|
+
// Missing-attestor faults only apply when we have positive evidence the proposal was valid.
|
|
434
|
+
const attestorsExpected = status === 'checkpoint-mined' || status === 'checkpoint-valid';
|
|
435
|
+
const missedAttestors = new Set(attestorsExpected ? committee.filter((v)=>!attestors.has(v.toString()) && !proposer.equals(v)).map((v)=>v.toString()) : []);
|
|
291
436
|
this.logger.debug(`Retrieved ${attestors.size} attestors out of ${committee.length} for slot ${slot}`, {
|
|
292
|
-
|
|
437
|
+
status,
|
|
293
438
|
proposer: proposer.toString(),
|
|
294
|
-
...
|
|
439
|
+
...checkpoint,
|
|
295
440
|
slot,
|
|
296
441
|
attestors: [
|
|
297
442
|
...attestors
|
|
@@ -304,7 +449,7 @@ export class Sentinel extends EventEmitter {
|
|
|
304
449
|
// Compute the status for each validator in the committee
|
|
305
450
|
const statusFor = (who)=>{
|
|
306
451
|
if (who === proposer.toString()) {
|
|
307
|
-
return
|
|
452
|
+
return status;
|
|
308
453
|
} else if (attestors.has(who)) {
|
|
309
454
|
return 'attestation-sent';
|
|
310
455
|
} else if (missedAttestors.has(who)) {
|
|
@@ -326,7 +471,7 @@ export class Sentinel extends EventEmitter {
|
|
|
326
471
|
v.toString(),
|
|
327
472
|
await this.store.getHistory(v)
|
|
328
473
|
]))) : await this.store.getHistories();
|
|
329
|
-
const slotNow = this.
|
|
474
|
+
const slotNow = await this.getCurrentSlot();
|
|
330
475
|
fromSlot ??= SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
|
|
331
476
|
toSlot ??= this.lastProcessedSlot ?? slotNow;
|
|
332
477
|
const stats = mapValues(histories, (history, address)=>this.computeStatsForValidator(address, history ?? [], fromSlot, toSlot));
|
|
@@ -342,7 +487,7 @@ export class Sentinel extends EventEmitter {
|
|
|
342
487
|
if (!history || history.length === 0) {
|
|
343
488
|
return undefined;
|
|
344
489
|
}
|
|
345
|
-
const slotNow = this.
|
|
490
|
+
const slotNow = await this.getCurrentSlot();
|
|
346
491
|
const effectiveFromSlot = fromSlot ?? SlotNumber(Math.max((this.lastProcessedSlot ?? slotNow) - this.store.getHistoryLength(), 0));
|
|
347
492
|
const effectiveToSlot = toSlot ?? this.lastProcessedSlot ?? slotNow;
|
|
348
493
|
const historyLength = BigInt(this.store.getHistoryLength());
|
|
@@ -352,7 +497,7 @@ export class Sentinel extends EventEmitter {
|
|
|
352
497
|
const validator = this.computeStatsForValidator(validatorAddress.toString(), history, effectiveFromSlot, effectiveToSlot);
|
|
353
498
|
return {
|
|
354
499
|
validator,
|
|
355
|
-
|
|
500
|
+
allTimeEpochPerformance: await this.store.getEpochPerformance(validatorAddress),
|
|
356
501
|
lastProcessedSlot: this.lastProcessedSlot,
|
|
357
502
|
initialSlot: this.initialSlot,
|
|
358
503
|
slotWindow: this.store.getHistoryLength()
|
|
@@ -361,15 +506,18 @@ export class Sentinel extends EventEmitter {
|
|
|
361
506
|
computeStatsForValidator(address, allHistory, fromSlot, toSlot) {
|
|
362
507
|
let history = fromSlot ? allHistory.filter((h)=>BigInt(h.slot) >= fromSlot) : allHistory;
|
|
363
508
|
history = toSlot ? history.filter((h)=>BigInt(h.slot) <= toSlot) : history;
|
|
364
|
-
const lastProposal = history.filter((h)=>h.status === '
|
|
509
|
+
const lastProposal = history.filter((h)=>h.status === 'checkpoint-valid' || h.status === 'checkpoint-mined').at(-1);
|
|
365
510
|
const lastAttestation = history.filter((h)=>h.status === 'attestation-sent').at(-1);
|
|
366
511
|
return {
|
|
367
512
|
address: EthAddress.fromString(address),
|
|
368
513
|
lastProposal: this.computeFromSlot(lastProposal?.slot),
|
|
369
514
|
lastAttestation: this.computeFromSlot(lastAttestation?.slot),
|
|
370
515
|
totalSlots: history.length,
|
|
371
|
-
missedProposals: this.computeMissed(history, '
|
|
372
|
-
'
|
|
516
|
+
missedProposals: this.computeMissed(history, 'proposer', [
|
|
517
|
+
'checkpoint-missed',
|
|
518
|
+
'blocks-missed',
|
|
519
|
+
'checkpoint-invalid',
|
|
520
|
+
'checkpoint-unvalidated'
|
|
373
521
|
]),
|
|
374
522
|
missedAttestations: this.computeMissed(history, 'attestation', [
|
|
375
523
|
'attestation-missed'
|
|
@@ -377,8 +525,8 @@ export class Sentinel extends EventEmitter {
|
|
|
377
525
|
history
|
|
378
526
|
};
|
|
379
527
|
}
|
|
380
|
-
computeMissed(history,
|
|
381
|
-
const relevantHistory = history.filter((h)=>!
|
|
528
|
+
computeMissed(history, computeOverCategory, filter) {
|
|
529
|
+
const relevantHistory = history.filter((h)=>!computeOverCategory || statusToCategory(h.status) === computeOverCategory);
|
|
382
530
|
const filteredHistory = relevantHistory.filter((h)=>filter.includes(h.status));
|
|
383
531
|
return {
|
|
384
532
|
currentStreak: countWhile([
|
package/dest/sentinel/store.d.ts
CHANGED
|
@@ -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 =
|
|
8
|
+
static readonly SCHEMA_VERSION = 4;
|
|
9
9
|
private readonly historyMap;
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly epochMap;
|
|
11
11
|
constructor(store: AztecAsyncKVStore, config: {
|
|
12
12
|
historyLength: number;
|
|
13
|
-
|
|
13
|
+
historicEpochPerformanceLength: number;
|
|
14
14
|
});
|
|
15
15
|
getHistoryLength(): number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZW50aW5lbC9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzFFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUUzRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFDVixzQkFBc0IsRUFDdEIscUJBQXFCLEVBQ3JCLDBCQUEwQixFQUMzQixNQUFNLDBCQUEwQixDQUFDO0FBRWxDLHFCQUFhLGFBQWE7SUFXdEIsT0FBTyxDQUFDLEtBQUs7SUFDYixPQUFPLENBQUMsTUFBTTtJQVhoQixnQkFBdUIsY0FBYyxLQUFLO0lBRzFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUF1QztJQUlsRSxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsQ0FBdUM7SU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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/sentinel/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAElC,qBAAa,aAAa;IAWtB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IAXhB,gBAAuB,cAAc,KAAK;IAG1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAIlE,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/sentinel/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAElC,qBAAa,aAAa;IAWtB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IAXhB,gBAAuB,cAAc,KAAK;IAG1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAIlE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;IAEhE,YACU,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,8BAA8B,EAAE,MAAM,CAAA;KAAE,EAIlF;IAEM,gBAAgB,WAEtB;IAEM,iCAAiC,WAEvC;I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