@aztec/slasher 0.0.1-commit.2448fdb → 0.0.1-commit.2606882
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/README.md +76 -79
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +28 -28
- package/dest/factory/create_facade.d.ts +3 -3
- package/dest/factory/create_facade.d.ts.map +1 -1
- package/dest/factory/create_facade.js +1 -1
- package/dest/factory/create_implementation.d.ts +5 -7
- package/dest/factory/create_implementation.d.ts.map +1 -1
- package/dest/factory/create_implementation.js +7 -59
- package/dest/factory/get_settings.d.ts +4 -4
- package/dest/factory/get_settings.d.ts.map +1 -1
- package/dest/factory/get_settings.js +3 -3
- package/dest/factory/index.d.ts +2 -2
- package/dest/factory/index.d.ts.map +1 -1
- package/dest/factory/index.js +1 -1
- package/dest/generated/slasher-defaults.d.ts +5 -5
- package/dest/generated/slasher-defaults.js +5 -5
- package/dest/index.d.ts +6 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -3
- package/dest/null_slasher_client.d.ts +3 -4
- package/dest/null_slasher_client.d.ts.map +1 -1
- package/dest/null_slasher_client.js +1 -4
- package/dest/slash_offenses_collector.d.ts +6 -8
- package/dest/slash_offenses_collector.d.ts.map +1 -1
- package/dest/slash_offenses_collector.js +48 -28
- package/dest/slasher_client.d.ts +112 -0
- package/dest/slasher_client.d.ts.map +1 -0
- package/dest/{tally_slasher_client.js → slasher_client.js} +40 -40
- package/dest/slasher_client_facade.d.ts +5 -8
- package/dest/slasher_client_facade.d.ts.map +1 -1
- package/dest/slasher_client_facade.js +4 -9
- package/dest/slasher_client_interface.d.ts +7 -21
- package/dest/slasher_client_interface.d.ts.map +1 -1
- package/dest/slasher_client_interface.js +1 -4
- package/dest/stores/offenses_store.d.ts +12 -12
- package/dest/stores/offenses_store.d.ts.map +1 -1
- package/dest/stores/offenses_store.js +61 -38
- package/dest/watcher.d.ts +8 -1
- package/dest/watcher.d.ts.map +1 -1
- package/dest/watcher.js +1 -0
- package/dest/watchers/attestations_block_watcher.d.ts +26 -13
- package/dest/watchers/attestations_block_watcher.d.ts.map +1 -1
- package/dest/watchers/attestations_block_watcher.js +76 -61
- package/dest/watchers/attested_invalid_proposal_watcher.d.ts +42 -0
- package/dest/watchers/attested_invalid_proposal_watcher.d.ts.map +1 -0
- package/dest/watchers/attested_invalid_proposal_watcher.js +117 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts +38 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts.map +1 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.js +138 -0
- package/dest/watchers/checkpoint_equivocation_watcher.d.ts +30 -0
- package/dest/watchers/checkpoint_equivocation_watcher.d.ts.map +1 -0
- package/dest/watchers/checkpoint_equivocation_watcher.js +69 -0
- package/dest/watchers/data_withholding_watcher.d.ts +63 -0
- package/dest/watchers/data_withholding_watcher.d.ts.map +1 -0
- package/dest/watchers/data_withholding_watcher.js +193 -0
- package/package.json +10 -10
- package/src/config.ts +33 -28
- package/src/factory/create_facade.ts +2 -3
- package/src/factory/create_implementation.ts +12 -118
- package/src/factory/get_settings.ts +8 -8
- package/src/factory/index.ts +1 -1
- package/src/generated/slasher-defaults.ts +5 -5
- package/src/index.ts +5 -3
- package/src/null_slasher_client.ts +2 -6
- package/src/slash_offenses_collector.ts +62 -29
- package/src/{tally_slasher_client.ts → slasher_client.ts} +56 -48
- package/src/slasher_client_facade.ts +4 -11
- package/src/slasher_client_interface.ts +6 -21
- package/src/stores/offenses_store.ts +73 -47
- package/src/watcher.ts +8 -0
- package/src/watchers/attestations_block_watcher.ts +88 -82
- package/src/watchers/attested_invalid_proposal_watcher.ts +168 -0
- package/src/watchers/broadcasted_invalid_checkpoint_proposal_watcher.ts +192 -0
- package/src/watchers/checkpoint_equivocation_watcher.ts +96 -0
- package/src/watchers/data_withholding_watcher.ts +225 -0
- package/dest/empire_slasher_client.d.ts +0 -190
- package/dest/empire_slasher_client.d.ts.map +0 -1
- package/dest/empire_slasher_client.js +0 -564
- package/dest/stores/payloads_store.d.ts +0 -29
- package/dest/stores/payloads_store.d.ts.map +0 -1
- package/dest/stores/payloads_store.js +0 -128
- package/dest/tally_slasher_client.d.ts +0 -125
- package/dest/tally_slasher_client.d.ts.map +0 -1
- package/dest/watchers/epoch_prune_watcher.d.ts +0 -39
- package/dest/watchers/epoch_prune_watcher.d.ts.map +0 -1
- package/dest/watchers/epoch_prune_watcher.js +0 -179
- package/src/empire_slasher_client.ts +0 -649
- package/src/stores/payloads_store.ts +0 -149
- package/src/watchers/epoch_prune_watcher.ts +0 -256
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import { type CheckpointEquivocationDetectedEvent, type L2BlockSourceEventEmitter } from '@aztec/stdlib/block';
|
|
3
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import { type Watcher, type WatcherEmitter } from '../watcher.js';
|
|
5
|
+
declare const CheckpointEquivocationWatcherConfigKeys: readonly ["slashDuplicateProposalPenalty"];
|
|
6
|
+
type CheckpointEquivocationWatcherConfig = Pick<SlasherConfig, (typeof CheckpointEquivocationWatcherConfigKeys)[number]>;
|
|
7
|
+
type EquivocationEventSource = Pick<L2BlockSourceEventEmitter, 'events'>;
|
|
8
|
+
type ProposerLookup = Pick<EpochCacheInterface, 'getProposerAttesterAddressInSlot'>;
|
|
9
|
+
declare const CheckpointEquivocationWatcher_base: new () => WatcherEmitter;
|
|
10
|
+
/**
|
|
11
|
+
* Slashes the slot proposer for DUPLICATE_PROPOSAL when the archiver detects that a
|
|
12
|
+
* locally-stored proposed checkpoint disagrees with the L1-confirmed checkpoint at the
|
|
13
|
+
* same slot. Both are signed by the slot proposer (the proposed one by accepting it via
|
|
14
|
+
* P2P or building it locally; the L1 one by submission), so the proposer equivocated.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CheckpointEquivocationWatcher extends CheckpointEquivocationWatcher_base implements Watcher {
|
|
17
|
+
private readonly l2BlockSource;
|
|
18
|
+
private readonly epochCache;
|
|
19
|
+
private readonly log;
|
|
20
|
+
private readonly handler;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(l2BlockSource: EquivocationEventSource, epochCache: ProposerLookup, config: CheckpointEquivocationWatcherConfig);
|
|
23
|
+
updateConfig(config: Partial<CheckpointEquivocationWatcherConfig>): void;
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
/** Public for tests. */
|
|
27
|
+
onEquivocationDetected(event: CheckpointEquivocationDetectedEvent): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludF9lcXVpdm9jYXRpb25fd2F0Y2hlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3dhdGNoZXJzL2NoZWNrcG9pbnRfZXF1aXZvY2F0aW9uX3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUc5RCxPQUFPLEVBQ0wsS0FBSyxtQ0FBbUMsRUFDeEMsS0FBSyx5QkFBeUIsRUFFL0IsTUFBTSxxQkFBcUIsQ0FBQztBQUM3QixPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUtyRSxPQUFPLEVBQTZDLEtBQUssT0FBTyxFQUFFLEtBQUssY0FBYyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRTdHLFFBQUEsTUFBTSx1Q0FBdUMsNENBQTZDLENBQUM7QUFFM0YsS0FBSyxtQ0FBbUMsR0FBRyxJQ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F"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { merge, pick } from '@aztec/foundation/collection';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
4
|
+
import { OffenseType, getOffenseTypeName } from '@aztec/stdlib/slashing';
|
|
5
|
+
import EventEmitter from 'node:events';
|
|
6
|
+
import { WANT_TO_SLASH_EVENT } from '../watcher.js';
|
|
7
|
+
const CheckpointEquivocationWatcherConfigKeys = [
|
|
8
|
+
'slashDuplicateProposalPenalty'
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Slashes the slot proposer for DUPLICATE_PROPOSAL when the archiver detects that a
|
|
12
|
+
* locally-stored proposed checkpoint disagrees with the L1-confirmed checkpoint at the
|
|
13
|
+
* same slot. Both are signed by the slot proposer (the proposed one by accepting it via
|
|
14
|
+
* P2P or building it locally; the L1 one by submission), so the proposer equivocated.
|
|
15
|
+
*/ export class CheckpointEquivocationWatcher extends EventEmitter {
|
|
16
|
+
l2BlockSource;
|
|
17
|
+
epochCache;
|
|
18
|
+
log;
|
|
19
|
+
handler;
|
|
20
|
+
config;
|
|
21
|
+
constructor(l2BlockSource, epochCache, config){
|
|
22
|
+
super(), this.l2BlockSource = l2BlockSource, this.epochCache = epochCache, this.log = createLogger('checkpoint-equivocation-watcher');
|
|
23
|
+
this.config = pick(config, ...CheckpointEquivocationWatcherConfigKeys);
|
|
24
|
+
this.handler = (event)=>{
|
|
25
|
+
this.onEquivocationDetected(event).catch((err)=>this.log.error('Failed to handle checkpoint equivocation event', err));
|
|
26
|
+
};
|
|
27
|
+
this.log.info('CheckpointEquivocationWatcher initialized');
|
|
28
|
+
}
|
|
29
|
+
updateConfig(config) {
|
|
30
|
+
this.config = merge(this.config, pick(config, ...CheckpointEquivocationWatcherConfigKeys));
|
|
31
|
+
this.log.verbose('CheckpointEquivocationWatcher config updated', this.config);
|
|
32
|
+
}
|
|
33
|
+
start() {
|
|
34
|
+
this.l2BlockSource.events.on(L2BlockSourceEvents.CheckpointEquivocationDetected, this.handler);
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
}
|
|
37
|
+
stop() {
|
|
38
|
+
this.l2BlockSource.events.off(L2BlockSourceEvents.CheckpointEquivocationDetected, this.handler);
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
41
|
+
/** Public for tests. */ async onEquivocationDetected(event) {
|
|
42
|
+
const proposer = await this.epochCache.getProposerAttesterAddressInSlot(event.slotNumber);
|
|
43
|
+
if (!proposer) {
|
|
44
|
+
this.log.warn(`Cannot attribute checkpoint equivocation: no proposer for slot ${event.slotNumber}`, {
|
|
45
|
+
slotNumber: event.slotNumber,
|
|
46
|
+
checkpointNumber: event.checkpointNumber
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const slashArgs = {
|
|
51
|
+
validator: proposer,
|
|
52
|
+
amount: this.config.slashDuplicateProposalPenalty,
|
|
53
|
+
offenseType: OffenseType.DUPLICATE_PROPOSAL,
|
|
54
|
+
epochOrSlot: BigInt(event.slotNumber)
|
|
55
|
+
};
|
|
56
|
+
this.log.info(`Detected checkpoint equivocation offense`, {
|
|
57
|
+
slotNumber: event.slotNumber,
|
|
58
|
+
checkpointNumber: event.checkpointNumber,
|
|
59
|
+
amount: slashArgs.amount,
|
|
60
|
+
offenseType: getOffenseTypeName(slashArgs.offenseType),
|
|
61
|
+
l1ArchiveRoot: event.l1ArchiveRoot.toString(),
|
|
62
|
+
proposedArchiveRoot: event.proposedArchiveRoot.toString(),
|
|
63
|
+
validator: proposer.toString()
|
|
64
|
+
});
|
|
65
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
66
|
+
slashArgs
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
|
+
import type { CheckpointReexecutionTracker, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
6
|
+
import type { ITxProvider, P2PApi, SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { type CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
8
|
+
import { type Watcher, type WatcherEmitter } from '../watcher.js';
|
|
9
|
+
declare const DataWithholdingWatcherConfigKeys: readonly ["slashDataWithholdingPenalty", "slashDataWithholdingToleranceSlots"];
|
|
10
|
+
type DataWithholdingWatcherConfig = Pick<SlasherConfig, (typeof DataWithholdingWatcherConfigKeys)[number]>;
|
|
11
|
+
declare const DataWithholdingWatcher_base: new () => WatcherEmitter;
|
|
12
|
+
/**
|
|
13
|
+
* Detects data-withholding offenses by probing the local mempool for the txs in published
|
|
14
|
+
* checkpoints once they are old enough that an honest node should have collected them.
|
|
15
|
+
*
|
|
16
|
+
* Per AZIP-7: once `slashDataWithholdingToleranceSlots` full slots have elapsed after the
|
|
17
|
+
* checkpoint's slot — i.e. at `slotStart(checkpoint.slot + slashDataWithholdingToleranceSlots
|
|
18
|
+
* + 1)` — if any tx from the checkpoint's blocks is still missing locally, the checkpoint's
|
|
19
|
+
* attesters are considered at fault for not making the data available, and we emit a slash
|
|
20
|
+
* for them.
|
|
21
|
+
*
|
|
22
|
+
* The watcher ticks at quarter-eth-slot cadence (matching the Sentinel template). On boot it
|
|
23
|
+
* floors processing at the current slot — restart-time gaps are accepted and not back-filled,
|
|
24
|
+
* matching the Sentinel approach.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DataWithholdingWatcher extends DataWithholdingWatcher_base implements Watcher {
|
|
27
|
+
private readonly epochCache;
|
|
28
|
+
private readonly l2BlockSource;
|
|
29
|
+
private readonly txProvider;
|
|
30
|
+
private readonly p2p;
|
|
31
|
+
private readonly reexecutionTracker;
|
|
32
|
+
private readonly signatureContext;
|
|
33
|
+
private readonly log;
|
|
34
|
+
private runningPromise;
|
|
35
|
+
private initialSlot;
|
|
36
|
+
private lastCheckedSlot;
|
|
37
|
+
private config;
|
|
38
|
+
constructor(epochCache: EpochCache, l2BlockSource: Pick<L2BlockSource, 'getCheckpoint' | 'getSyncedL2SlotNumber'>, txProvider: Pick<ITxProvider, 'hasTxs'>, p2p: Pick<P2PApi, 'getCheckpointAttestationsForSlot'>, reexecutionTracker: Pick<CheckpointReexecutionTracker, 'getTxsCollectedRecord'>, signatureContext: CoordinationSignatureContext, config: DataWithholdingWatcherConfig, log?: Logger);
|
|
39
|
+
start(): Promise<void>;
|
|
40
|
+
stop(): Promise<void>;
|
|
41
|
+
updateConfig(config: Partial<SlasherConfig>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Runs every tick. Walks newly-eligible slots and probes their checkpoints for data
|
|
44
|
+
* availability; emits a DATA_WITHHOLDING slash for any checkpoint whose txs are missing.
|
|
45
|
+
*/
|
|
46
|
+
work(): Promise<void>;
|
|
47
|
+
private processSlot;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the union of:
|
|
50
|
+
* 1. attesters whose signatures landed in the published checkpoint on L1, and
|
|
51
|
+
* 2. attesters we observed signing the same proposal on p2p (the proposer publishes as
|
|
52
|
+
* soon as it has hit committee quorum, so honest peer attestations that arrive after
|
|
53
|
+
* that point are dropped — but they still vouched for the data and
|
|
54
|
+
* should be slashed for withholding it).
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* Exposed as protected so tests can substitute a deterministic recovery without having
|
|
58
|
+
* to construct real secp256k1 signatures.
|
|
59
|
+
*/
|
|
60
|
+
protected extractAttesters(published: PublishedCheckpoint): Promise<EthAddress[]>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YV93aXRoaG9sZGluZ193YXRjaG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AAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAEjC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAbtB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,eAAe,CAAyB;IAChD,OAAO,CAAC,MAAM,CAA+B;IAE7C,YACmB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,GAAG,uBAAuB,CAAC,EAC7E,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EACvC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,kCAAkC,CAAC,EACrD,kBAAkB,EAAE,IAAI,CAAC,4BAA4B,EAAE,uBAAuB,CAAC,EAC/E,gBAAgB,EAAE,4BAA4B,EAC/D,MAAM,EAAE,4BAA4B,EACnB,GAAG,GAAE,MAAiD,EAOxE;IAEY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlC;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAEM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAGxD;IAED;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA8BjC;YAGa,WAAW;IA6EzB;;;;;;;;;;;OAWG;IACH,UAAgB,gBAAgB,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAmBtF;CACF"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { compactArray, merge, pick } from '@aztec/foundation/collection';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
5
|
+
import { getAttestationInfoFromPublishedCheckpoint } from '@aztec/stdlib/block';
|
|
6
|
+
import { ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
7
|
+
import { OffenseType, getOffenseTypeName } from '@aztec/stdlib/slashing';
|
|
8
|
+
import EventEmitter from 'node:events';
|
|
9
|
+
import { WANT_TO_SLASH_EVENT } from '../watcher.js';
|
|
10
|
+
const DataWithholdingWatcherConfigKeys = [
|
|
11
|
+
'slashDataWithholdingPenalty',
|
|
12
|
+
'slashDataWithholdingToleranceSlots'
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Detects data-withholding offenses by probing the local mempool for the txs in published
|
|
16
|
+
* checkpoints once they are old enough that an honest node should have collected them.
|
|
17
|
+
*
|
|
18
|
+
* Per AZIP-7: once `slashDataWithholdingToleranceSlots` full slots have elapsed after the
|
|
19
|
+
* checkpoint's slot — i.e. at `slotStart(checkpoint.slot + slashDataWithholdingToleranceSlots
|
|
20
|
+
* + 1)` — if any tx from the checkpoint's blocks is still missing locally, the checkpoint's
|
|
21
|
+
* attesters are considered at fault for not making the data available, and we emit a slash
|
|
22
|
+
* for them.
|
|
23
|
+
*
|
|
24
|
+
* The watcher ticks at quarter-eth-slot cadence (matching the Sentinel template). On boot it
|
|
25
|
+
* floors processing at the current slot — restart-time gaps are accepted and not back-filled,
|
|
26
|
+
* matching the Sentinel approach.
|
|
27
|
+
*/ export class DataWithholdingWatcher extends EventEmitter {
|
|
28
|
+
epochCache;
|
|
29
|
+
l2BlockSource;
|
|
30
|
+
txProvider;
|
|
31
|
+
p2p;
|
|
32
|
+
reexecutionTracker;
|
|
33
|
+
signatureContext;
|
|
34
|
+
log;
|
|
35
|
+
runningPromise;
|
|
36
|
+
initialSlot;
|
|
37
|
+
lastCheckedSlot;
|
|
38
|
+
config;
|
|
39
|
+
constructor(epochCache, l2BlockSource, txProvider, p2p, reexecutionTracker, signatureContext, config, log = createLogger('data-withholding-watcher')){
|
|
40
|
+
super(), this.epochCache = epochCache, this.l2BlockSource = l2BlockSource, this.txProvider = txProvider, this.p2p = p2p, this.reexecutionTracker = reexecutionTracker, this.signatureContext = signatureContext, this.log = log;
|
|
41
|
+
this.config = pick(config, ...DataWithholdingWatcherConfigKeys);
|
|
42
|
+
const interval = epochCache.getL1Constants().ethereumSlotDuration * 1000 / 4;
|
|
43
|
+
this.runningPromise = new RunningPromise(this.work.bind(this), log, interval);
|
|
44
|
+
this.log.verbose(`DataWithholdingWatcher initialized`, this.config);
|
|
45
|
+
}
|
|
46
|
+
async start() {
|
|
47
|
+
// Floor processing at the archiver's synced slot rather than the wallclock — restart-time
|
|
48
|
+
// gaps before the archiver catches up are accepted and not back-filled. Falls back to the
|
|
49
|
+
// wallclock if the archiver isn't ready yet (cold start).
|
|
50
|
+
const syncedSlot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
51
|
+
this.initialSlot = syncedSlot ?? this.epochCache.getSlotNow();
|
|
52
|
+
this.log.info(`Starting data-withholding watcher with initial slot ${this.initialSlot}`);
|
|
53
|
+
this.runningPromise.start();
|
|
54
|
+
}
|
|
55
|
+
stop() {
|
|
56
|
+
return this.runningPromise.stop();
|
|
57
|
+
}
|
|
58
|
+
updateConfig(config) {
|
|
59
|
+
this.config = merge(this.config, pick(config, ...DataWithholdingWatcherConfigKeys));
|
|
60
|
+
this.log.verbose('DataWithholdingWatcher config updated', this.config);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Runs every tick. Walks newly-eligible slots and probes their checkpoints for data
|
|
64
|
+
* availability; emits a DATA_WITHHOLDING slash for any checkpoint whose txs are missing.
|
|
65
|
+
*/ async work() {
|
|
66
|
+
if (this.initialSlot === undefined) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// tolerance is the number of full slots that must elapse after the checkpoint's slot
|
|
70
|
+
// before we declare its data missing. For checkpoint slot S, we therefore process S
|
|
71
|
+
// only once we are in slot `S + tolerance + 1` or later. Drive this off the archiver's
|
|
72
|
+
// synced slot rather than the wallclock so we don't make claims about slots we haven't
|
|
73
|
+
// fully ingested yet (archiver may lag behind L1).
|
|
74
|
+
const tolerance = this.config.slashDataWithholdingToleranceSlots;
|
|
75
|
+
const currentSlot = await this.l2BlockSource.getSyncedL2SlotNumber() ?? this.epochCache.getSlotNow();
|
|
76
|
+
if (currentSlot <= tolerance) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const targetSlot = SlotNumber(currentSlot - tolerance - 1);
|
|
80
|
+
if (targetSlot <= this.initialSlot) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const startSlot = this.lastCheckedSlot === undefined ? this.initialSlot : this.lastCheckedSlot;
|
|
84
|
+
for(let slot = SlotNumber(startSlot + 1); slot <= targetSlot; slot = SlotNumber(slot + 1)){
|
|
85
|
+
try {
|
|
86
|
+
await this.processSlot(slot);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
this.log.error(`Error processing slot ${slot} for data-withholding check`, err, {
|
|
89
|
+
slot
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
this.lastCheckedSlot = slot;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Probes the checkpoint at the given slot, if any, and emits a slash on missing txs. */ async processSlot(slot) {
|
|
96
|
+
const published = await this.l2BlockSource.getCheckpoint({
|
|
97
|
+
slot
|
|
98
|
+
});
|
|
99
|
+
if (!published) {
|
|
100
|
+
this.log.trace(`No published checkpoint at slot ${slot}`, {
|
|
101
|
+
slot
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const checkpointNumber = published.checkpoint.number;
|
|
106
|
+
// Per-block tx-collection records (true | false | undefined) for every block in this
|
|
107
|
+
// published checkpoint. Captured by the validator's proposal handler at the moment of
|
|
108
|
+
// tx collection (i.e. by the *re-execution* deadline). Used as a positive short-circuit
|
|
109
|
+
// only: a `true` for every block means we know the data was available locally, so this
|
|
110
|
+
// checkpoint cannot be a data-withholding offense. A `false` does *not* trigger a slash
|
|
111
|
+
// on its own — the re-execution deadline is much earlier than the data-withholding
|
|
112
|
+
// tolerance window, so missing txs at that earlier deadline may still arrive in time.
|
|
113
|
+
// Anything other than all-true falls through to the mempool probe, which respects the
|
|
114
|
+
// tolerance window.
|
|
115
|
+
const collectionRecords = published.checkpoint.blocks.map((block, idx)=>this.reexecutionTracker.getTxsCollectedRecord(block.header.getSlot(), idx));
|
|
116
|
+
if (collectionRecords.every((r)=>r === true)) {
|
|
117
|
+
this.log.trace(`All blocks for checkpoint at slot ${slot} were collected locally; skipping`, {
|
|
118
|
+
slot,
|
|
119
|
+
checkpointNumber
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const txHashes = published.checkpoint.blocks.flatMap((block)=>block.body.txEffects.map((txEffect)=>txEffect.txHash));
|
|
124
|
+
if (txHashes.length === 0) {
|
|
125
|
+
this.log.trace(`Checkpoint at slot ${slot} has no txs`, {
|
|
126
|
+
slot
|
|
127
|
+
});
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const availability = await this.txProvider.hasTxs(txHashes);
|
|
131
|
+
const missingTxs = txHashes.filter((_, i)=>!availability[i]);
|
|
132
|
+
if (missingTxs.length === 0) {
|
|
133
|
+
this.log.trace(`All ${txHashes.length} txs available for checkpoint at slot ${slot}`, {
|
|
134
|
+
slot
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const attesters = await this.extractAttesters(published);
|
|
139
|
+
if (attesters.length === 0) {
|
|
140
|
+
this.log.warn(`Detected data withholding at slot ${slot} but no recoverable attesters`, {
|
|
141
|
+
slot,
|
|
142
|
+
checkpointNumber,
|
|
143
|
+
missingTxs: missingTxs.map((h)=>h.toString()),
|
|
144
|
+
records: collectionRecords
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.log.info(`Detected data withholding offense at slot ${slot}`, {
|
|
149
|
+
slot,
|
|
150
|
+
checkpointNumber,
|
|
151
|
+
amount: this.config.slashDataWithholdingPenalty,
|
|
152
|
+
offenseType: getOffenseTypeName(OffenseType.DATA_WITHHOLDING),
|
|
153
|
+
missingTxs: missingTxs.map((h)=>h.toString()),
|
|
154
|
+
records: collectionRecords,
|
|
155
|
+
attesters: attesters.map((a)=>a.toString())
|
|
156
|
+
});
|
|
157
|
+
const args = attesters.map((validator)=>({
|
|
158
|
+
validator,
|
|
159
|
+
amount: this.config.slashDataWithholdingPenalty,
|
|
160
|
+
offenseType: OffenseType.DATA_WITHHOLDING,
|
|
161
|
+
epochOrSlot: BigInt(slot)
|
|
162
|
+
}));
|
|
163
|
+
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns the union of:
|
|
167
|
+
* 1. attesters whose signatures landed in the published checkpoint on L1, and
|
|
168
|
+
* 2. attesters we observed signing the same proposal on p2p (the proposer publishes as
|
|
169
|
+
* soon as it has hit committee quorum, so honest peer attestations that arrive after
|
|
170
|
+
* that point are dropped — but they still vouched for the data and
|
|
171
|
+
* should be slashed for withholding it).
|
|
172
|
+
*
|
|
173
|
+
*
|
|
174
|
+
* Exposed as protected so tests can substitute a deterministic recovery without having
|
|
175
|
+
* to construct real secp256k1 signatures.
|
|
176
|
+
*/ async extractAttesters(published) {
|
|
177
|
+
const fromL1 = getAttestationInfoFromPublishedCheckpoint(published, this.signatureContext).filter((info)=>info.status === 'recovered-from-signature').map((info)=>info.address);
|
|
178
|
+
const slot = published.checkpoint.header.slotNumber;
|
|
179
|
+
const proposalPayloadHash = CheckpointProposalHash.fromBuffer(ConsensusPayload.fromCheckpoint(published.checkpoint, this.signatureContext).getPayloadHash());
|
|
180
|
+
const fromP2p = await this.p2p.getCheckpointAttestationsForSlot(slot, proposalPayloadHash).then((attestations)=>attestations.map((a)=>a.getSender()));
|
|
181
|
+
// Dedupe
|
|
182
|
+
const all = new Map();
|
|
183
|
+
for (const addr of compactArray([
|
|
184
|
+
...fromL1,
|
|
185
|
+
...fromP2p
|
|
186
|
+
])){
|
|
187
|
+
all.set(addr.toString(), addr);
|
|
188
|
+
}
|
|
189
|
+
return [
|
|
190
|
+
...all.values()
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/slasher",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.2606882",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -56,20 +56,20 @@
|
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
60
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
61
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
62
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
63
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
64
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
65
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
59
|
+
"@aztec/epoch-cache": "0.0.1-commit.2606882",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.2606882",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.2606882",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.2606882",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.2606882",
|
|
64
|
+
"@aztec/stdlib": "0.0.1-commit.2606882",
|
|
65
|
+
"@aztec/telemetry-client": "0.0.1-commit.2606882",
|
|
66
66
|
"source-map-support": "^0.5.21",
|
|
67
67
|
"tslib": "^2.4.0",
|
|
68
68
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
69
|
-
"zod": "^
|
|
69
|
+
"zod": "^4"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
+
"@aztec/aztec.js": "0.0.1-commit.2606882",
|
|
73
73
|
"@jest/globals": "^30.0.0",
|
|
74
74
|
"@types/jest": "^30.0.0",
|
|
75
75
|
"@types/node": "^22.15.17",
|
package/src/config.ts
CHANGED
|
@@ -14,20 +14,24 @@ export type { SlasherConfig };
|
|
|
14
14
|
|
|
15
15
|
export const DefaultSlasherConfig: SlasherConfig = {
|
|
16
16
|
slashOverridePayload: undefined,
|
|
17
|
-
slashMinPenaltyPercentage: slasherDefaultEnv.SLASH_MIN_PENALTY_PERCENTAGE,
|
|
18
|
-
slashMaxPenaltyPercentage: slasherDefaultEnv.SLASH_MAX_PENALTY_PERCENTAGE,
|
|
19
17
|
slashValidatorsAlways: [], // Empty by default
|
|
20
18
|
slashValidatorsNever: [], // Empty by default
|
|
21
|
-
slashPrunePenalty: BigInt(slasherDefaultEnv.SLASH_PRUNE_PENALTY),
|
|
22
19
|
slashDataWithholdingPenalty: BigInt(slasherDefaultEnv.SLASH_DATA_WITHHOLDING_PENALTY),
|
|
20
|
+
slashDataWithholdingToleranceSlots: slasherDefaultEnv.SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS,
|
|
23
21
|
slashInactivityTargetPercentage: slasherDefaultEnv.SLASH_INACTIVITY_TARGET_PERCENTAGE,
|
|
24
22
|
slashInactivityConsecutiveEpochThreshold: slasherDefaultEnv.SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD,
|
|
25
23
|
slashBroadcastedInvalidBlockPenalty: BigInt(slasherDefaultEnv.SLASH_INVALID_BLOCK_PENALTY),
|
|
24
|
+
slashBroadcastedInvalidCheckpointProposalPenalty: BigInt(slasherDefaultEnv.SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY),
|
|
26
25
|
slashDuplicateProposalPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_PROPOSAL_PENALTY),
|
|
27
26
|
slashDuplicateAttestationPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_ATTESTATION_PENALTY),
|
|
28
27
|
slashInactivityPenalty: BigInt(slasherDefaultEnv.SLASH_INACTIVITY_PENALTY),
|
|
29
28
|
slashProposeInvalidAttestationsPenalty: BigInt(slasherDefaultEnv.SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY),
|
|
30
|
-
|
|
29
|
+
slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty: BigInt(
|
|
30
|
+
slasherDefaultEnv.SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY,
|
|
31
|
+
),
|
|
32
|
+
slashAttestInvalidCheckpointProposalPenalty: BigInt(
|
|
33
|
+
slasherDefaultEnv.SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY,
|
|
34
|
+
),
|
|
31
35
|
slashUnknownPenalty: BigInt(slasherDefaultEnv.SLASH_UNKNOWN_PENALTY),
|
|
32
36
|
slashOffenseExpirationRounds: slasherDefaultEnv.SLASH_OFFENSE_EXPIRATION_ROUNDS,
|
|
33
37
|
slashMaxPayloadSize: slasherDefaultEnv.SLASH_MAX_PAYLOAD_SIZE,
|
|
@@ -40,19 +44,9 @@ export const slasherConfigMappings: ConfigMappingsType<SlasherConfig> = {
|
|
|
40
44
|
slashOverridePayload: {
|
|
41
45
|
env: 'SLASH_OVERRIDE_PAYLOAD',
|
|
42
46
|
description: 'An Ethereum address for a slash payload to vote for unconditionally.',
|
|
43
|
-
parseEnv: (val: string) =>
|
|
47
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
44
48
|
defaultValue: DefaultSlasherConfig.slashOverridePayload,
|
|
45
49
|
},
|
|
46
|
-
slashMinPenaltyPercentage: {
|
|
47
|
-
env: 'SLASH_MIN_PENALTY_PERCENTAGE',
|
|
48
|
-
description: 'Minimum penalty percentage for slashing offenses (0.1 is 10%).',
|
|
49
|
-
...floatConfigHelper(DefaultSlasherConfig.slashMinPenaltyPercentage),
|
|
50
|
-
},
|
|
51
|
-
slashMaxPenaltyPercentage: {
|
|
52
|
-
env: 'SLASH_MAX_PENALTY_PERCENTAGE',
|
|
53
|
-
description: 'Maximum penalty percentage for slashing offenses (2.0 is 200%).',
|
|
54
|
-
...floatConfigHelper(DefaultSlasherConfig.slashMaxPenaltyPercentage),
|
|
55
|
-
},
|
|
56
50
|
slashValidatorsAlways: {
|
|
57
51
|
env: 'SLASH_VALIDATORS_ALWAYS',
|
|
58
52
|
description: 'Comma-separated list of validator addresses that should always be slashed.',
|
|
@@ -75,21 +69,27 @@ export const slasherConfigMappings: ConfigMappingsType<SlasherConfig> = {
|
|
|
75
69
|
.map(addr => EthAddress.fromString(addr)),
|
|
76
70
|
defaultValue: DefaultSlasherConfig.slashValidatorsNever,
|
|
77
71
|
},
|
|
78
|
-
slashPrunePenalty: {
|
|
79
|
-
env: 'SLASH_PRUNE_PENALTY',
|
|
80
|
-
description: 'Penalty amount for slashing validators of a valid pruned epoch (set to 0 to disable).',
|
|
81
|
-
...bigintConfigHelper(DefaultSlasherConfig.slashPrunePenalty),
|
|
82
|
-
},
|
|
83
72
|
slashDataWithholdingPenalty: {
|
|
84
73
|
env: 'SLASH_DATA_WITHHOLDING_PENALTY',
|
|
85
|
-
description: 'Penalty
|
|
74
|
+
description: 'Penalty for data withholding (0 records offenses without slash votes).',
|
|
86
75
|
...bigintConfigHelper(DefaultSlasherConfig.slashDataWithholdingPenalty),
|
|
87
76
|
},
|
|
77
|
+
slashDataWithholdingToleranceSlots: {
|
|
78
|
+
env: 'SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS',
|
|
79
|
+
description:
|
|
80
|
+
'Number of full L2 slots that must elapse after a checkpoint slot before declaring its txs missing and slashing its attesters for data withholding.',
|
|
81
|
+
...numberConfigHelper(DefaultSlasherConfig.slashDataWithholdingToleranceSlots),
|
|
82
|
+
},
|
|
88
83
|
slashBroadcastedInvalidBlockPenalty: {
|
|
89
84
|
env: 'SLASH_INVALID_BLOCK_PENALTY',
|
|
90
85
|
description: 'Penalty amount for slashing a validator for an invalid block proposed via p2p.',
|
|
91
86
|
...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidBlockPenalty),
|
|
92
87
|
},
|
|
88
|
+
slashBroadcastedInvalidCheckpointProposalPenalty: {
|
|
89
|
+
env: 'SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
|
|
90
|
+
description: 'Penalty amount for slashing a validator for an invalid checkpoint proposal proposed via p2p.',
|
|
91
|
+
...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidCheckpointProposalPenalty),
|
|
92
|
+
},
|
|
93
93
|
slashDuplicateProposalPenalty: {
|
|
94
94
|
env: 'SLASH_DUPLICATE_PROPOSAL_PENALTY',
|
|
95
95
|
description: 'Penalty amount for slashing a validator for sending duplicate proposals.',
|
|
@@ -125,23 +125,28 @@ export const slasherConfigMappings: ConfigMappingsType<SlasherConfig> = {
|
|
|
125
125
|
},
|
|
126
126
|
slashInactivityPenalty: {
|
|
127
127
|
env: 'SLASH_INACTIVITY_PENALTY',
|
|
128
|
-
description: 'Penalty
|
|
128
|
+
description: 'Penalty for an inactive validator (0 records offenses without slash votes).',
|
|
129
129
|
...bigintConfigHelper(DefaultSlasherConfig.slashInactivityPenalty),
|
|
130
130
|
},
|
|
131
131
|
slashProposeInvalidAttestationsPenalty: {
|
|
132
132
|
env: 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY',
|
|
133
|
-
description: 'Penalty
|
|
133
|
+
description: 'Penalty for proposing invalid attestations (0 records offenses without slash votes).',
|
|
134
134
|
...bigintConfigHelper(DefaultSlasherConfig.slashProposeInvalidAttestationsPenalty),
|
|
135
135
|
},
|
|
136
|
-
|
|
137
|
-
env: '
|
|
136
|
+
slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty: {
|
|
137
|
+
env: 'SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY',
|
|
138
138
|
description:
|
|
139
|
-
'Penalty
|
|
140
|
-
...bigintConfigHelper(DefaultSlasherConfig.
|
|
139
|
+
'Penalty for publishing a checkpoint building on an invalid checkpoint (0 records offenses without slash votes).',
|
|
140
|
+
...bigintConfigHelper(DefaultSlasherConfig.slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty),
|
|
141
|
+
},
|
|
142
|
+
slashAttestInvalidCheckpointProposalPenalty: {
|
|
143
|
+
env: 'SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
|
|
144
|
+
description: 'Penalty for attesting to an invalid checkpoint proposal (0 records offenses without slash votes).',
|
|
145
|
+
...bigintConfigHelper(DefaultSlasherConfig.slashAttestInvalidCheckpointProposalPenalty),
|
|
141
146
|
},
|
|
142
147
|
slashUnknownPenalty: {
|
|
143
148
|
env: 'SLASH_UNKNOWN_PENALTY',
|
|
144
|
-
description: 'Penalty
|
|
149
|
+
description: 'Penalty for an unknown offense (0 records offenses without slash votes).',
|
|
145
150
|
...bigintConfigHelper(DefaultSlasherConfig.slashUnknownPenalty),
|
|
146
151
|
},
|
|
147
152
|
slashOffenseExpirationRounds: {
|
|
@@ -7,10 +7,10 @@ import { unique } from '@aztec/foundation/collection';
|
|
|
7
7
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
11
10
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
12
11
|
import { getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
13
12
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
13
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
14
14
|
|
|
15
15
|
import { SlasherClientFacade } from '../slasher_client_facade.js';
|
|
16
16
|
import type { SlasherClientInterface } from '../slasher_client_interface.js';
|
|
@@ -20,7 +20,7 @@ import type { Watcher } from '../watcher.js';
|
|
|
20
20
|
/** Creates a slasher client facade that updates itself whenever the rollup slasher changes */
|
|
21
21
|
export async function createSlasherFacade(
|
|
22
22
|
config: SlasherConfig & DataStoreConfig & { ethereumSlotDuration: number },
|
|
23
|
-
l1Contracts: Pick<L1ReaderConfig
|
|
23
|
+
l1Contracts: Pick<L1ReaderConfig, 'rollupAddress' | 'registryAddress'>,
|
|
24
24
|
l1Client: ViemClient,
|
|
25
25
|
watchers: Watcher[],
|
|
26
26
|
dateProvider: DateProvider,
|
|
@@ -71,7 +71,6 @@ export async function createSlasherFacade(
|
|
|
71
71
|
updatedConfig,
|
|
72
72
|
rollup,
|
|
73
73
|
l1Client,
|
|
74
|
-
l1Contracts.slashFactoryAddress,
|
|
75
74
|
watchers,
|
|
76
75
|
epochCache,
|
|
77
76
|
dateProvider,
|