@aztec/slasher 0.0.1-commit.e3c1de76 → 0.0.1-commit.e57c76e
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 +83 -76
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +41 -29
- 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 +25 -2
- package/dest/factory/create_implementation.d.ts +6 -7
- package/dest/factory/create_implementation.d.ts.map +1 -1
- package/dest/factory/create_implementation.js +8 -56
- 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 +8 -6
- package/dest/generated/slasher-defaults.d.ts.map +1 -1
- package/dest/generated/slasher-defaults.js +7 -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 +10 -9
- package/dest/slash_offenses_collector.d.ts.map +1 -1
- package/dest/slash_offenses_collector.js +50 -34
- 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} +45 -45
- package/dest/slasher_client_facade.d.ts +6 -8
- package/dest/slasher_client_facade.d.ts.map +1 -1
- package/dest/slasher_client_facade.js +6 -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 +48 -29
- package/src/factory/create_facade.ts +32 -4
- package/src/factory/create_implementation.ts +24 -105
- package/src/factory/get_settings.ts +8 -8
- package/src/factory/index.ts +1 -1
- package/src/generated/slasher-defaults.ts +7 -5
- package/src/index.ts +5 -3
- package/src/null_slasher_client.ts +2 -6
- package/src/slash_offenses_collector.ts +70 -36
- package/src/{tally_slasher_client.ts → slasher_client.ts} +63 -54
- package/src/slasher_client_facade.ts +6 -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 -38
- package/dest/watchers/epoch_prune_watcher.d.ts.map +0 -1
- package/dest/watchers/epoch_prune_watcher.js +0 -158
- package/src/empire_slasher_client.ts +0 -649
- package/src/stores/payloads_store.ts +0 -149
- package/src/watchers/epoch_prune_watcher.ts +0 -221
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { deserializeSlashPayload, serializeSlashPayload } from '@aztec/stdlib/slashing';
|
|
2
|
-
export class SlasherPayloadsStore {
|
|
3
|
-
kvStore;
|
|
4
|
-
settings;
|
|
5
|
-
/** Map from payload address to payload data */ payloads;
|
|
6
|
-
/** Map from `round:payload` to votes */ roundPayloadVotes;
|
|
7
|
-
constructor(kvStore, settings){
|
|
8
|
-
this.kvStore = kvStore;
|
|
9
|
-
this.settings = settings;
|
|
10
|
-
this.payloads = kvStore.openMap('slash-payloads');
|
|
11
|
-
this.roundPayloadVotes = kvStore.openMap('round-payload-votes');
|
|
12
|
-
}
|
|
13
|
-
async getPayloadsForRound(round) {
|
|
14
|
-
const payloads = [];
|
|
15
|
-
const votes = await this.getVotesForRound(round);
|
|
16
|
-
for (const [address, votesCount] of votes){
|
|
17
|
-
const payload = await this.getPayload(address);
|
|
18
|
-
if (payload) {
|
|
19
|
-
payloads.push({
|
|
20
|
-
...payload,
|
|
21
|
-
votes: votesCount,
|
|
22
|
-
round
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return payloads;
|
|
27
|
-
}
|
|
28
|
-
async getPayloadAtRound(payloadAddress, round) {
|
|
29
|
-
const address = payloadAddress.toString();
|
|
30
|
-
const buffer = await this.payloads.getAsync(address);
|
|
31
|
-
if (!buffer) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
const data = deserializeSlashPayload(buffer);
|
|
35
|
-
const votes = await this.roundPayloadVotes.getAsync(this.getPayloadVotesKey(round, address)) ?? 0n;
|
|
36
|
-
return {
|
|
37
|
-
...data,
|
|
38
|
-
votes,
|
|
39
|
-
round
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async getVotesForRound(round) {
|
|
43
|
-
const votes = [];
|
|
44
|
-
for await (const [fullKey, roundVotes] of this.roundPayloadVotes.entriesAsync(this.getPayloadVotesKeyRangeForRound(round))){
|
|
45
|
-
// Extract just the address part from the key (remove "round:" prefix)
|
|
46
|
-
const address = fullKey.split(':')[1];
|
|
47
|
-
votes.push([
|
|
48
|
-
address,
|
|
49
|
-
roundVotes
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
52
|
-
return votes;
|
|
53
|
-
}
|
|
54
|
-
getRoundKey(round) {
|
|
55
|
-
return round.toString().padStart(16, '0');
|
|
56
|
-
}
|
|
57
|
-
getPayloadVotesKey(round, payloadAddress) {
|
|
58
|
-
return `${this.getRoundKey(round)}:${payloadAddress.toString()}`;
|
|
59
|
-
}
|
|
60
|
-
getPayloadVotesKeyRangeForRound(round) {
|
|
61
|
-
const start = `${this.getRoundKey(round)}:`;
|
|
62
|
-
const end = `${this.getRoundKey(round)}:Z`; // 'Z' sorts after any hex address, 0x-prefixed or not
|
|
63
|
-
return {
|
|
64
|
-
start,
|
|
65
|
-
end
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Purge vote payload data for expired rounds. Does not delete actual payload data.
|
|
70
|
-
*/ async clearExpiredPayloads(currentRound) {
|
|
71
|
-
const lifetimeInRounds = this.settings?.slashingPayloadLifetimeInRounds ?? 0;
|
|
72
|
-
if (lifetimeInRounds <= 0) {
|
|
73
|
-
return; // No lifetime configured
|
|
74
|
-
}
|
|
75
|
-
const expiredBefore = currentRound - BigInt(lifetimeInRounds);
|
|
76
|
-
if (expiredBefore < 0) {
|
|
77
|
-
return; // Not enough rounds have passed to expire anything
|
|
78
|
-
}
|
|
79
|
-
// Collect expired payload votes by scanning round-payload keys
|
|
80
|
-
const expiredPayloads = [];
|
|
81
|
-
const expiredVoteKeys = [];
|
|
82
|
-
for await (const key of this.roundPayloadVotes.keysAsync({
|
|
83
|
-
end: `${this.getRoundKey(expiredBefore)}:Z`
|
|
84
|
-
})){
|
|
85
|
-
const [roundStr, payloadAddress] = key.split(':');
|
|
86
|
-
if (BigInt(roundStr) <= expiredBefore) {
|
|
87
|
-
expiredVoteKeys.push(key);
|
|
88
|
-
expiredPayloads.push(payloadAddress);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (expiredVoteKeys.length === 0) {
|
|
92
|
-
return; // No expired payloads to clean up
|
|
93
|
-
}
|
|
94
|
-
// Remove expired payload vote records
|
|
95
|
-
// Note that we do not delete payload data since these could be repurposed in future votes
|
|
96
|
-
await this.kvStore.transactionAsync(async ()=>{
|
|
97
|
-
for (const key of expiredVoteKeys){
|
|
98
|
-
await this.roundPayloadVotes.delete(key);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
async incrementPayloadVotes(payloadAddress, round) {
|
|
103
|
-
const key = this.getPayloadVotesKey(round, payloadAddress);
|
|
104
|
-
let newVotes;
|
|
105
|
-
await this.kvStore.transactionAsync(async ()=>{
|
|
106
|
-
const currentVotes = await this.roundPayloadVotes.getAsync(key) || 0n;
|
|
107
|
-
newVotes = currentVotes + 1n;
|
|
108
|
-
await this.roundPayloadVotes.set(key, newVotes);
|
|
109
|
-
});
|
|
110
|
-
return newVotes;
|
|
111
|
-
}
|
|
112
|
-
async addPayload(payload) {
|
|
113
|
-
const address = payload.address.toString();
|
|
114
|
-
await this.kvStore.transactionAsync(async ()=>{
|
|
115
|
-
await this.payloads.set(address, serializeSlashPayload(payload));
|
|
116
|
-
await this.roundPayloadVotes.set(this.getPayloadVotesKey(payload.round, address), payload.votes);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
async getPayload(payloadAddress) {
|
|
120
|
-
const address = payloadAddress.toString();
|
|
121
|
-
const buffer = await this.payloads.getAsync(address);
|
|
122
|
-
return buffer ? deserializeSlashPayload(buffer) : undefined;
|
|
123
|
-
}
|
|
124
|
-
async hasPayload(payload) {
|
|
125
|
-
const address = payload.toString();
|
|
126
|
-
return await this.payloads.getAsync(address) !== undefined;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import { RollupContract, SlasherContract, TallySlashingProposerContract } from '@aztec/ethereum/contracts';
|
|
3
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
-
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type { Prettify } from '@aztec/foundation/types';
|
|
6
|
-
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { type Offense, type ProposerSlashAction, type ProposerSlashActionProvider, type SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
8
|
-
import type { Hex } from 'viem';
|
|
9
|
-
import { SlashOffensesCollector, type SlashOffensesCollectorConfig, type SlashOffensesCollectorSettings } from './slash_offenses_collector.js';
|
|
10
|
-
import { SlashRoundMonitor, type SlashRoundMonitorSettings } from './slash_round_monitor.js';
|
|
11
|
-
import type { SlasherClientInterface } from './slasher_client_interface.js';
|
|
12
|
-
import type { SlasherOffensesStore } from './stores/offenses_store.js';
|
|
13
|
-
import type { Watcher } from './watcher.js';
|
|
14
|
-
/** Settings used in the tally slasher client, loaded from the L1 contracts during initialization */
|
|
15
|
-
export type TallySlasherSettings = Prettify<SlashRoundMonitorSettings & SlashOffensesCollectorSettings & {
|
|
16
|
-
slashingLifetimeInRounds: number;
|
|
17
|
-
slashingExecutionDelayInRounds: number;
|
|
18
|
-
slashingRoundSizeInEpochs: number;
|
|
19
|
-
slashingOffsetInRounds: number;
|
|
20
|
-
slashingQuorumSize: number;
|
|
21
|
-
slashingAmounts: [bigint, bigint, bigint];
|
|
22
|
-
/** Committee size for block proposal */
|
|
23
|
-
targetCommitteeSize: number;
|
|
24
|
-
}>;
|
|
25
|
-
export type TallySlasherClientConfig = SlashOffensesCollectorConfig & Pick<SlasherConfig, 'slashValidatorsAlways' | 'slashValidatorsNever' | 'slashExecuteRoundsLookBack'>;
|
|
26
|
-
/**
|
|
27
|
-
* The Tally Slasher client is responsible for managing slashable offenses using
|
|
28
|
-
* the consensus-based slashing model where proposers vote on individual validator offenses.
|
|
29
|
-
*
|
|
30
|
-
* The client subscribes to several slash watchers that emit offenses and tracks them. When the slasher is the
|
|
31
|
-
* proposer, it votes for which validators from past epochs should be slashed based on collected offenses.
|
|
32
|
-
* Voting is handled by the sequencer publisher, the slasher client does not interact with L1 directly.
|
|
33
|
-
* The client also monitors rounds and executes slashing when rounds become executable after reaching quorum.
|
|
34
|
-
*
|
|
35
|
-
* Voting and offense collection
|
|
36
|
-
* - Time is divided into rounds (ROUND_SIZE slots each). During each round, block proposers can submit votes
|
|
37
|
-
* indicating which validators from SLASH_OFFSET_IN_ROUNDS rounds ago should be slashed.
|
|
38
|
-
* - Votes are encoded as bytes where each validator's vote is represented by 2 bits indicating the slash amount (0-3 slash units)
|
|
39
|
-
* for the validator in the committee being slashed.
|
|
40
|
-
* - When gathering offenses for round N, the system looks at offenses from round N-2 (where 2 is the hardcoded
|
|
41
|
-
* offset), giving time to detect offenses and vote on them in a later round.
|
|
42
|
-
* - Each offense carries an epoch or block identifier to differentiate multiple offenses by the same validator.
|
|
43
|
-
*
|
|
44
|
-
* Quorum and execution
|
|
45
|
-
* - After a round ends, there is an execution delay period for review so the VETOER in the Slasher can veto
|
|
46
|
-
* if needed.
|
|
47
|
-
* - Once the delay passes, anyone can call executeRound() to tally votes and execute slashing.
|
|
48
|
-
* - Validators that reach the quorum threshold are slashed. A vote for slashing N units is also considered
|
|
49
|
-
* a vote for slashing N-1, N-2, ..., 1 units. The system slashes for the largest amount that reaches quorum.
|
|
50
|
-
* - The client monitors executable rounds and triggers execution when appropriate.
|
|
51
|
-
*
|
|
52
|
-
* Differences from Empire model
|
|
53
|
-
* - No fixed slash payloads - votes are for individual validator offenses encoded in bytes
|
|
54
|
-
* - The L1 contract determines which offenses reach quorum rather than nodes agreeing on a payload
|
|
55
|
-
* - Proposers vote directly on which validators to slash and by how much
|
|
56
|
-
* - Uses a slash offset to vote on validators from past rounds (e.g., round N votes on round N-2)
|
|
57
|
-
*/
|
|
58
|
-
export declare class TallySlasherClient implements ProposerSlashActionProvider, SlasherClientInterface {
|
|
59
|
-
private config;
|
|
60
|
-
private settings;
|
|
61
|
-
private tallySlashingProposer;
|
|
62
|
-
private slasher;
|
|
63
|
-
private rollup;
|
|
64
|
-
private epochCache;
|
|
65
|
-
private dateProvider;
|
|
66
|
-
private offensesStore;
|
|
67
|
-
private log;
|
|
68
|
-
protected unwatchCallbacks: (() => void)[];
|
|
69
|
-
protected roundMonitor: SlashRoundMonitor;
|
|
70
|
-
protected offensesCollector: SlashOffensesCollector;
|
|
71
|
-
constructor(config: TallySlasherClientConfig, settings: TallySlasherSettings, tallySlashingProposer: TallySlashingProposerContract, slasher: SlasherContract, rollup: RollupContract, watchers: Watcher[], epochCache: EpochCache, dateProvider: DateProvider, offensesStore: SlasherOffensesStore, log?: import("@aztec/foundation/log").Logger);
|
|
72
|
-
start(): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Stop the tally slasher client
|
|
75
|
-
*/
|
|
76
|
-
stop(): Promise<void>;
|
|
77
|
-
/** Returns the current config */
|
|
78
|
-
getConfig(): SlasherConfig;
|
|
79
|
-
/** Update the config of the slasher client */
|
|
80
|
-
updateConfig(config: Partial<SlasherConfig>): void;
|
|
81
|
-
/** Triggered on a time basis when we enter a new slashing round. Clears expired offenses. */
|
|
82
|
-
protected handleNewRound(round: bigint): Promise<void>;
|
|
83
|
-
/** Called when we see a RoundExecuted event on the TallySlashingProposer (just for logging). */
|
|
84
|
-
protected handleRoundExecuted(round: bigint, slashCount: bigint, l1BlockHash: Hex): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Get the actions the proposer should take for slashing
|
|
87
|
-
* @param slotNumber - The current slot number
|
|
88
|
-
* @returns The actions to take
|
|
89
|
-
*/
|
|
90
|
-
getProposerActions(slotNumber: SlotNumber): Promise<ProposerSlashAction[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Returns an execute slash action if there are any rounds ready to be executed.
|
|
93
|
-
* Returns the oldest slash action if there are multiple rounds pending execution.
|
|
94
|
-
*/
|
|
95
|
-
protected getExecuteSlashAction(slotNumber: SlotNumber): Promise<ProposerSlashAction | undefined>;
|
|
96
|
-
private tryGetRoundExecuteAction;
|
|
97
|
-
/** Returns a vote action based on offenses from the target round (with offset applied) */
|
|
98
|
-
protected getVoteOffensesAction(slotNumber: SlotNumber): Promise<ProposerSlashAction | undefined>;
|
|
99
|
-
/** Returns the committees that were active during the timespan of a given round */
|
|
100
|
-
private collectCommitteesActiveDuringRound;
|
|
101
|
-
/**
|
|
102
|
-
* Get slash payloads is NOT SUPPORTED in tally model
|
|
103
|
-
* @throws Error indicating this operation is not supported
|
|
104
|
-
*/
|
|
105
|
-
getSlashPayloads(): Promise<SlashPayloadRound[]>;
|
|
106
|
-
/**
|
|
107
|
-
* Gather offenses to be slashed on a given round.
|
|
108
|
-
* In tally slashing, round N slashes validators from round N - slashOffsetInRounds.
|
|
109
|
-
* @param round - The round to get offenses for, defaults to current round
|
|
110
|
-
* @returns Array of pending offenses for the round with offset applied
|
|
111
|
-
*/
|
|
112
|
-
gatherOffensesForRound(round?: bigint): Promise<Offense[]>;
|
|
113
|
-
/** Returns all pending offenses stored */
|
|
114
|
-
getPendingOffenses(): Promise<Offense[]>;
|
|
115
|
-
/**
|
|
116
|
-
* Returns the round to be slashed given the current round by applying the slash offset.
|
|
117
|
-
* During round N, we cannot slash the validators from the epochs of the same round, since the round is not over,
|
|
118
|
-
* and besides we would be asking the current validators to vote to slash themselves. So during round N we look at the
|
|
119
|
-
* epochs spanned during round N - SLASH_OFFSET_IN_ROUNDS. This offset means that the epochs we slash are complete,
|
|
120
|
-
* and also gives nodes time to detect any misbehavior (eg slashing for prunes requires the proof submission window to
|
|
121
|
-
* pass).
|
|
122
|
-
*/
|
|
123
|
-
private getSlashedRound;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFsbHlfc2xhc2hlcl9jbGllbnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90YWxseV9zbGFzaGVyX2NsaWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNyRCxPQUFPLEVBQUUsY0FBYyxFQUFFLGVBQWUsRUFBRSw2QkFBNkIsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTNHLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUc3RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNyRSxPQUFPLEVBQ0wsS0FBSyxPQUFPLEVBRVosS0FBSyxtQkFBbUIsRUFDeEIsS0FBSywyQkFBMkIsRUFDaEMsS0FBSyxpQkFBaUIsRUFHdkIsTUFBTSx3QkFBd0IsQ0FBQztBQU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,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,iBAGtF;IAED;;;;OAIG;IACU,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAOtF;IAED;;;OAGG;IACH,UAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CA0CtG;YAOa,wBAAwB;IA0EtC,0FAA0F;IAC1F,UAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAyFtG;IAED,mFAAmF;IACnF,OAAO,CAAC,kCAAkC;IAQ1C;;;OAGG;IACI,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAEtD;IAED;;;;;OAKG;IACU,sBAAsB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAOtE;IAED,0CAA0C;IACnC,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAE9C;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;CAIxB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { L2Block, type L2BlockSourceEventEmitter } from '@aztec/stdlib/block';
|
|
4
|
-
import type { ICheckpointsBuilder, ITxProvider, MerkleTreeWriteOperations, SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
6
|
-
import { type Watcher, type WatcherEmitter } from '../watcher.js';
|
|
7
|
-
declare const EpochPruneWatcherPenaltiesConfigKeys: readonly ["slashPrunePenalty", "slashDataWithholdingPenalty"];
|
|
8
|
-
type EpochPruneWatcherPenalties = Pick<SlasherConfig, (typeof EpochPruneWatcherPenaltiesConfigKeys)[number]>;
|
|
9
|
-
declare const EpochPruneWatcher_base: new () => WatcherEmitter;
|
|
10
|
-
/**
|
|
11
|
-
* This watcher is responsible for detecting chain prunes and creating slashing arguments for the committee.
|
|
12
|
-
* It only wants to slash if:
|
|
13
|
-
* - the transactions are not available
|
|
14
|
-
* - OR the archive roots match when re-building all the blocks in the epoch (i.e. the epoch *could* have been proven)
|
|
15
|
-
*/
|
|
16
|
-
export declare class EpochPruneWatcher extends EpochPruneWatcher_base implements Watcher {
|
|
17
|
-
private l2BlockSource;
|
|
18
|
-
private l1ToL2MessageSource;
|
|
19
|
-
private epochCache;
|
|
20
|
-
private txProvider;
|
|
21
|
-
private checkpointsBuilder;
|
|
22
|
-
private log;
|
|
23
|
-
private boundHandlePruneL2Blocks;
|
|
24
|
-
private penalties;
|
|
25
|
-
constructor(l2BlockSource: L2BlockSourceEventEmitter, l1ToL2MessageSource: L1ToL2MessageSource, epochCache: EpochCache, txProvider: Pick<ITxProvider, 'getAvailableTxs'>, checkpointsBuilder: ICheckpointsBuilder, penalties: EpochPruneWatcherPenalties);
|
|
26
|
-
start(): Promise<void>;
|
|
27
|
-
stop(): Promise<void>;
|
|
28
|
-
updateConfig(config: Partial<SlasherConfig>): void;
|
|
29
|
-
private handlePruneL2Blocks;
|
|
30
|
-
private emitSlashForEpoch;
|
|
31
|
-
private processPruneL2Blocks;
|
|
32
|
-
validateBlocks(blocks: L2Block[]): Promise<void>;
|
|
33
|
-
validateBlock(blockFromL1: L2Block, previousCheckpointOutHashes: Fr[], fork: MerkleTreeWriteOperations): Promise<void>;
|
|
34
|
-
private getValidatorsForEpoch;
|
|
35
|
-
private validatorsToSlashingArgs;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfcHJ1bmVfd2F0Y2hlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsi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B;IASnC,OAAO,CAAC,wBAAwB;CAgBjC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { merge, pick } from '@aztec/foundation/collection';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
5
|
-
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
-
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
7
|
-
import { OffenseType, getOffenseTypeName } from '@aztec/stdlib/slashing';
|
|
8
|
-
import { ReExFailedTxsError, ReExStateMismatchError, TransactionsNotAvailableError, ValidatorError } from '@aztec/stdlib/validators';
|
|
9
|
-
import EventEmitter from 'node:events';
|
|
10
|
-
import { WANT_TO_SLASH_EVENT } from '../watcher.js';
|
|
11
|
-
const EpochPruneWatcherPenaltiesConfigKeys = [
|
|
12
|
-
'slashPrunePenalty',
|
|
13
|
-
'slashDataWithholdingPenalty'
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* This watcher is responsible for detecting chain prunes and creating slashing arguments for the committee.
|
|
17
|
-
* It only wants to slash if:
|
|
18
|
-
* - the transactions are not available
|
|
19
|
-
* - OR the archive roots match when re-building all the blocks in the epoch (i.e. the epoch *could* have been proven)
|
|
20
|
-
*/ export class EpochPruneWatcher extends EventEmitter {
|
|
21
|
-
l2BlockSource;
|
|
22
|
-
l1ToL2MessageSource;
|
|
23
|
-
epochCache;
|
|
24
|
-
txProvider;
|
|
25
|
-
checkpointsBuilder;
|
|
26
|
-
log;
|
|
27
|
-
// Store bound function reference for proper listener removal
|
|
28
|
-
boundHandlePruneL2Blocks;
|
|
29
|
-
penalties;
|
|
30
|
-
constructor(l2BlockSource, l1ToL2MessageSource, epochCache, txProvider, checkpointsBuilder, penalties){
|
|
31
|
-
super(), this.l2BlockSource = l2BlockSource, this.l1ToL2MessageSource = l1ToL2MessageSource, this.epochCache = epochCache, this.txProvider = txProvider, this.checkpointsBuilder = checkpointsBuilder, this.log = createLogger('epoch-prune-watcher'), this.boundHandlePruneL2Blocks = this.handlePruneL2Blocks.bind(this);
|
|
32
|
-
this.penalties = pick(penalties, ...EpochPruneWatcherPenaltiesConfigKeys);
|
|
33
|
-
this.log.verbose(`EpochPruneWatcher initialized with penalties: valid epoch pruned=${penalties.slashPrunePenalty} data withholding=${penalties.slashDataWithholdingPenalty}`);
|
|
34
|
-
}
|
|
35
|
-
start() {
|
|
36
|
-
this.l2BlockSource.events.on(L2BlockSourceEvents.L2PruneUnproven, this.boundHandlePruneL2Blocks);
|
|
37
|
-
return Promise.resolve();
|
|
38
|
-
}
|
|
39
|
-
stop() {
|
|
40
|
-
this.l2BlockSource.events.removeListener(L2BlockSourceEvents.L2PruneUnproven, this.boundHandlePruneL2Blocks);
|
|
41
|
-
return Promise.resolve();
|
|
42
|
-
}
|
|
43
|
-
updateConfig(config) {
|
|
44
|
-
this.penalties = merge(this.penalties, pick(config, ...EpochPruneWatcherPenaltiesConfigKeys));
|
|
45
|
-
this.log.verbose('EpochPruneWatcher config updated', this.penalties);
|
|
46
|
-
}
|
|
47
|
-
handlePruneL2Blocks(event) {
|
|
48
|
-
const { blocks, epochNumber } = event;
|
|
49
|
-
void this.processPruneL2Blocks(blocks, epochNumber).catch((err)=>this.log.error('Error processing pruned L2 blocks', err, {
|
|
50
|
-
epochNumber
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
async emitSlashForEpoch(offense, epochNumber) {
|
|
54
|
-
const validators = await this.getValidatorsForEpoch(epochNumber);
|
|
55
|
-
if (validators.length === 0) {
|
|
56
|
-
this.log.warn(`No validators found for epoch ${epochNumber} (cannot slash for ${getOffenseTypeName(offense)})`);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const args = this.validatorsToSlashingArgs(validators, offense, epochNumber);
|
|
60
|
-
this.log.verbose(`Created slash for ${getOffenseTypeName(offense)} at epoch ${epochNumber}`, args);
|
|
61
|
-
this.emit(WANT_TO_SLASH_EVENT, args);
|
|
62
|
-
}
|
|
63
|
-
async processPruneL2Blocks(blocks, epochNumber) {
|
|
64
|
-
try {
|
|
65
|
-
const l1Constants = this.epochCache.getL1Constants();
|
|
66
|
-
const epochBlocks = blocks.filter((b)=>getEpochAtSlot(b.header.getSlot(), l1Constants) === epochNumber);
|
|
67
|
-
this.log.info(`Detected chain prune. Validating epoch ${epochNumber} with blocks ${epochBlocks[0]?.number} to ${epochBlocks[epochBlocks.length - 1]?.number}.`, {
|
|
68
|
-
blocks: epochBlocks.map((b)=>b.toBlockInfo())
|
|
69
|
-
});
|
|
70
|
-
await this.validateBlocks(epochBlocks);
|
|
71
|
-
this.log.info(`Pruned epoch ${epochNumber} was valid. Want to slash committee for not having it proven.`);
|
|
72
|
-
await this.emitSlashForEpoch(OffenseType.VALID_EPOCH_PRUNED, epochNumber);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (error instanceof TransactionsNotAvailableError) {
|
|
75
|
-
this.log.info(`Data for pruned epoch ${epochNumber} was not available. Will want to slash.`, {
|
|
76
|
-
message: error.message
|
|
77
|
-
});
|
|
78
|
-
await this.emitSlashForEpoch(OffenseType.DATA_WITHHOLDING, epochNumber);
|
|
79
|
-
} else {
|
|
80
|
-
this.log.error(`Error while validating pruned epoch ${epochNumber}. Will not want to slash.`, error);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async validateBlocks(blocks) {
|
|
85
|
-
if (blocks.length === 0) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
let previousCheckpointOutHashes = [];
|
|
89
|
-
const fork = await this.checkpointsBuilder.getFork(BlockNumber(blocks[0].header.globalVariables.blockNumber - 1));
|
|
90
|
-
try {
|
|
91
|
-
for (const block of blocks){
|
|
92
|
-
await this.validateBlock(block, previousCheckpointOutHashes, fork);
|
|
93
|
-
// TODO(mbps): This assumes one block per checkpoint, which is only true for now.
|
|
94
|
-
const checkpointOutHash = computeCheckpointOutHash([
|
|
95
|
-
block.body.txEffects.map((tx)=>tx.l2ToL1Msgs)
|
|
96
|
-
]);
|
|
97
|
-
previousCheckpointOutHashes = [
|
|
98
|
-
...previousCheckpointOutHashes,
|
|
99
|
-
checkpointOutHash
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
} finally{
|
|
103
|
-
await fork.close();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async validateBlock(blockFromL1, previousCheckpointOutHashes, fork) {
|
|
107
|
-
this.log.debug(`Validating pruned block ${blockFromL1.header.globalVariables.blockNumber}`);
|
|
108
|
-
const txHashes = blockFromL1.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
109
|
-
// We load txs from the mempool directly, since the TxCollector running in the background has already been
|
|
110
|
-
// trying to fetch them from nodes or via reqresp. If we haven't managed to collect them by now,
|
|
111
|
-
// it's likely that they are not available in the network at all.
|
|
112
|
-
const { txs, missingTxs } = await this.txProvider.getAvailableTxs(txHashes);
|
|
113
|
-
if (missingTxs && missingTxs.length > 0) {
|
|
114
|
-
throw new TransactionsNotAvailableError(missingTxs);
|
|
115
|
-
}
|
|
116
|
-
const checkpointNumber = CheckpointNumber.fromBlockNumber(blockFromL1.number);
|
|
117
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
118
|
-
const gv = blockFromL1.header.globalVariables;
|
|
119
|
-
const constants = {
|
|
120
|
-
chainId: gv.chainId,
|
|
121
|
-
version: gv.version,
|
|
122
|
-
slotNumber: gv.slotNumber,
|
|
123
|
-
coinbase: gv.coinbase,
|
|
124
|
-
feeRecipient: gv.feeRecipient,
|
|
125
|
-
gasFees: gv.gasFees
|
|
126
|
-
};
|
|
127
|
-
// Use checkpoint builder to validate the block
|
|
128
|
-
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
129
|
-
const { block, failedTxs, numTxs } = await checkpointBuilder.buildBlock(txs, gv.blockNumber, gv.timestamp, {});
|
|
130
|
-
if (numTxs !== txs.length) {
|
|
131
|
-
// This should be detected by state mismatch, but this makes it easier to debug.
|
|
132
|
-
throw new ValidatorError(`Built block with ${numTxs} txs, expected ${txs.length}`);
|
|
133
|
-
}
|
|
134
|
-
if (failedTxs.length > 0) {
|
|
135
|
-
throw new ReExFailedTxsError(failedTxs.length);
|
|
136
|
-
}
|
|
137
|
-
if (!block.archive.root.equals(blockFromL1.archive.root)) {
|
|
138
|
-
throw new ReExStateMismatchError(blockFromL1.archive.root, block.archive.root);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async getValidatorsForEpoch(epochNumber) {
|
|
142
|
-
const { committee } = await this.epochCache.getCommitteeForEpoch(epochNumber);
|
|
143
|
-
if (!committee) {
|
|
144
|
-
this.log.trace(`No committee found for epoch ${epochNumber}`);
|
|
145
|
-
return [];
|
|
146
|
-
}
|
|
147
|
-
return committee;
|
|
148
|
-
}
|
|
149
|
-
validatorsToSlashingArgs(validators, offenseType, epochOrSlot) {
|
|
150
|
-
const penalty = offenseType === OffenseType.DATA_WITHHOLDING ? this.penalties.slashDataWithholdingPenalty : this.penalties.slashPrunePenalty;
|
|
151
|
-
return validators.map((v)=>({
|
|
152
|
-
validator: v,
|
|
153
|
-
amount: penalty,
|
|
154
|
-
offenseType,
|
|
155
|
-
epochOrSlot: BigInt(epochOrSlot)
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
}
|