@aztec/slasher 0.0.1-commit.f504929 → 0.0.1-commit.f650c0a5c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +28 -52
  2. package/dest/config.d.ts +1 -1
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +0 -12
  5. package/dest/factory/create_facade.d.ts +3 -3
  6. package/dest/factory/create_facade.d.ts.map +1 -1
  7. package/dest/factory/create_facade.js +1 -1
  8. package/dest/factory/create_implementation.d.ts +5 -7
  9. package/dest/factory/create_implementation.d.ts.map +1 -1
  10. package/dest/factory/create_implementation.js +7 -59
  11. package/dest/factory/get_settings.d.ts +4 -4
  12. package/dest/factory/get_settings.d.ts.map +1 -1
  13. package/dest/factory/get_settings.js +3 -3
  14. package/dest/factory/index.d.ts +2 -2
  15. package/dest/factory/index.d.ts.map +1 -1
  16. package/dest/factory/index.js +1 -1
  17. package/dest/generated/slasher-defaults.d.ts +1 -3
  18. package/dest/generated/slasher-defaults.d.ts.map +1 -1
  19. package/dest/generated/slasher-defaults.js +0 -2
  20. package/dest/index.d.ts +2 -3
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -2
  23. package/dest/null_slasher_client.d.ts +3 -4
  24. package/dest/null_slasher_client.d.ts.map +1 -1
  25. package/dest/null_slasher_client.js +1 -4
  26. package/dest/slash_offenses_collector.d.ts +1 -7
  27. package/dest/slash_offenses_collector.d.ts.map +1 -1
  28. package/dest/slash_offenses_collector.js +7 -16
  29. package/dest/slasher_client.d.ts +112 -0
  30. package/dest/slasher_client.d.ts.map +1 -0
  31. package/dest/{tally_slasher_client.js → slasher_client.js} +22 -43
  32. package/dest/slasher_client_facade.d.ts +5 -8
  33. package/dest/slasher_client_facade.d.ts.map +1 -1
  34. package/dest/slasher_client_facade.js +4 -9
  35. package/dest/slasher_client_interface.d.ts +7 -21
  36. package/dest/slasher_client_interface.d.ts.map +1 -1
  37. package/dest/slasher_client_interface.js +1 -4
  38. package/dest/stores/offenses_store.d.ts +6 -12
  39. package/dest/stores/offenses_store.d.ts.map +1 -1
  40. package/dest/stores/offenses_store.js +5 -24
  41. package/dest/watchers/epoch_prune_watcher.d.ts +1 -1
  42. package/dest/watchers/epoch_prune_watcher.d.ts.map +1 -1
  43. package/dest/watchers/epoch_prune_watcher.js +4 -1
  44. package/package.json +9 -9
  45. package/src/config.ts +0 -12
  46. package/src/factory/create_facade.ts +2 -3
  47. package/src/factory/create_implementation.ts +12 -118
  48. package/src/factory/get_settings.ts +8 -8
  49. package/src/factory/index.ts +1 -1
  50. package/src/generated/slasher-defaults.ts +0 -2
  51. package/src/index.ts +1 -2
  52. package/src/null_slasher_client.ts +2 -6
  53. package/src/slash_offenses_collector.ts +8 -17
  54. package/src/{tally_slasher_client.ts → slasher_client.ts} +27 -49
  55. package/src/slasher_client_facade.ts +4 -11
  56. package/src/slasher_client_interface.ts +6 -21
  57. package/src/stores/offenses_store.ts +8 -33
  58. package/src/watchers/epoch_prune_watcher.ts +4 -1
  59. package/dest/empire_slasher_client.d.ts +0 -190
  60. package/dest/empire_slasher_client.d.ts.map +0 -1
  61. package/dest/empire_slasher_client.js +0 -564
  62. package/dest/stores/payloads_store.d.ts +0 -29
  63. package/dest/stores/payloads_store.d.ts.map +0 -1
  64. package/dest/stores/payloads_store.js +0 -128
  65. package/dest/tally_slasher_client.d.ts +0 -125
  66. package/dest/tally_slasher_client.d.ts.map +0 -1
  67. package/src/empire_slasher_client.ts +0 -649
  68. package/src/stores/payloads_store.ts +0 -149
@@ -5,8 +5,7 @@ export class SlasherOffensesStore {
5
5
  kvStore;
6
6
  settings;
7
7
  /** Map from offense key to offense data */ offenses;
8
- /** Map from offense key to whether the offense has been executed (only used for empire based slashing) */ offensesSlashed;
9
- /** Multimap from round to offense keys (only used for consensus based slashing) */ roundsOffenses;
8
+ /** Multimap from round to offense keys */ roundsOffenses;
10
9
  log;
11
10
  constructor(kvStore, settings){
12
11
  this.kvStore = kvStore;
@@ -14,16 +13,11 @@ export class SlasherOffensesStore {
14
13
  this.log = createLogger('slasher:store:offenses');
15
14
  this.offenses = kvStore.openMap('offenses');
16
15
  this.roundsOffenses = kvStore.openMultiMap('rounds-offenses');
17
- this.offensesSlashed = kvStore.openSet('offenses-slashed');
18
16
  }
19
- /** Returns all offenses not marked as slashed */ async getPendingOffenses() {
17
+ /** Returns all offenses */ async getOffenses() {
20
18
  const offenses = [];
21
- for await (const [key, buffer] of this.offenses.entriesAsync()){
22
- if (await this.offensesSlashed.hasAsync(key)) {
23
- continue; // Skip executed offenses
24
- }
25
- const offense = deserializeOffense(buffer);
26
- offenses.push(offense);
19
+ for await (const [, buffer] of this.offenses.entriesAsync()){
20
+ offenses.push(deserializeOffense(buffer));
27
21
  }
28
22
  return offenses;
29
23
  }
@@ -38,15 +32,11 @@ export class SlasherOffensesStore {
38
32
  }
39
33
  return offenses;
40
34
  }
41
- /** Returns whether an offense is pending (ie not marked as slashed) */ async hasPendingOffense(offense) {
42
- const key = this.getOffenseKey(offense);
43
- return await this.offenses.getAsync(key) !== undefined && !await this.offensesSlashed.hasAsync(key);
44
- }
45
35
  /** Returns whether we have seen this offense */ async hasOffense(offense) {
46
36
  const key = this.getOffenseKey(offense);
47
37
  return await this.offenses.getAsync(key) !== undefined;
48
38
  }
49
- /** Adds a new offense (defaults to pending, but will be slashed if markAsSlashed had been called for it) */ async addPendingOffense(offense) {
39
+ /** Adds a new offense */ async addOffense(offense) {
50
40
  const key = this.getOffenseKey(offense);
51
41
  const round = getRoundForOffense(offense, this.settings);
52
42
  await this.kvStore.transactionAsync(async ()=>{
@@ -55,14 +45,6 @@ export class SlasherOffensesStore {
55
45
  });
56
46
  this.log.trace(`Adding pending offense ${key} for round ${round}`);
57
47
  }
58
- /** Marks the given offenses as slashed (regardless of whether they are known or not) */ async markAsSlashed(offenses) {
59
- await this.kvStore.transactionAsync(async ()=>{
60
- for (const offense of offenses){
61
- const key = this.getOffenseKey(offense);
62
- await this.offensesSlashed.add(key);
63
- }
64
- });
65
- }
66
48
  /** Prunes all offenses expired from the store */ async clearExpiredOffenses(currentRound) {
67
49
  const expirationRounds = this.settings.slashOffenseExpirationRounds ?? 0;
68
50
  if (expirationRounds <= 0) {
@@ -89,7 +71,6 @@ export class SlasherOffensesStore {
89
71
  for (const key of expiredOffenseKeys){
90
72
  this.log.trace(`Deleting offense ${key}`);
91
73
  await this.offenses.delete(key);
92
- await this.offensesSlashed.delete(key);
93
74
  }
94
75
  for (const roundKey of expiredRoundKeys){
95
76
  this.log.trace(`Deleting round info for ${roundKey}`);
@@ -36,4 +36,4 @@ export declare class EpochPruneWatcher extends EpochPruneWatcher_base implements
36
36
  private validatorsToSlashingArgs;
37
37
  }
38
38
  export {};
39
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfcHJ1bmVfd2F0Y2hlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3dhdGNoZXJzL2Vwb2NoX3BydW5lX3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2hELE9BQU8sRUFBZSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUkzRSxPQUFPLEVBRUwsT0FBTyxFQUNQLEtBQUsseUJBQXlCLEVBRy9CLE1BQU0scUJBQXFCLENBQUM7QUFFN0IsT0FBTyxLQUFLLEVBRVYsbUJBQW1CLEVBQ25CLFdBQVcsRUFFWCxhQUFhLEVBQ2QsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQUUsS0FBSyxtQkFBbUIsRUFBNEIsTUFBTSx5QkFBeUIsQ0FBQztBQVk3RixPQUFPLEVBQTZDLEtBQUssT0FBTyxFQUFFLEtBQUssY0FBYyxFQUFFLE1BQU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AI,kBAGV;IAEM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAGxD;IAED,OAAO,CAAC,mBAAmB;YAOb,iBAAiB;YAWjB,oBAAoB;IAwBrB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BtF;YAEa,kBAAkB;YAwClB,yBAAyB;YAiCzB,qBAAqB;IASnC,OAAO,CAAC,wBAAwB;CAgBjC"}
@@ -144,7 +144,10 @@ const EpochPruneWatcherPenaltiesConfigKeys = [
144
144
  throw new TransactionsNotAvailableError(missingTxs);
145
145
  }
146
146
  const gv = blockFromL1.header.globalVariables;
147
- const { block, failedTxs, numTxs } = await checkpointBuilder.buildBlock(txs, gv.blockNumber, gv.timestamp, {});
147
+ const { block, failedTxs, numTxs } = await checkpointBuilder.buildBlock(txs, gv.blockNumber, gv.timestamp, {
148
+ isBuildingProposal: false,
149
+ minValidTxs: 0
150
+ });
148
151
  if (numTxs !== txs.length) {
149
152
  // This should be detected by state mismatch, but this makes it easier to debug.
150
153
  throw new ValidatorError(`Built block with ${numTxs} txs, expected ${txs.length}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/slasher",
3
- "version": "0.0.1-commit.f504929",
3
+ "version": "0.0.1-commit.f650c0a5c",
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.f504929",
60
- "@aztec/ethereum": "0.0.1-commit.f504929",
61
- "@aztec/foundation": "0.0.1-commit.f504929",
62
- "@aztec/kv-store": "0.0.1-commit.f504929",
63
- "@aztec/l1-artifacts": "0.0.1-commit.f504929",
64
- "@aztec/stdlib": "0.0.1-commit.f504929",
65
- "@aztec/telemetry-client": "0.0.1-commit.f504929",
59
+ "@aztec/epoch-cache": "0.0.1-commit.f650c0a5c",
60
+ "@aztec/ethereum": "0.0.1-commit.f650c0a5c",
61
+ "@aztec/foundation": "0.0.1-commit.f650c0a5c",
62
+ "@aztec/kv-store": "0.0.1-commit.f650c0a5c",
63
+ "@aztec/l1-artifacts": "0.0.1-commit.f650c0a5c",
64
+ "@aztec/stdlib": "0.0.1-commit.f650c0a5c",
65
+ "@aztec/telemetry-client": "0.0.1-commit.f650c0a5c",
66
66
  "source-map-support": "^0.5.21",
67
67
  "tslib": "^2.4.0",
68
68
  "viem": "npm:@aztec/viem@2.38.2",
69
69
  "zod": "^3.23.8"
70
70
  },
71
71
  "devDependencies": {
72
- "@aztec/aztec.js": "0.0.1-commit.f504929",
72
+ "@aztec/aztec.js": "0.0.1-commit.f650c0a5c",
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,8 +14,6 @@ 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
19
  slashPrunePenalty: BigInt(slasherDefaultEnv.SLASH_PRUNE_PENALTY),
@@ -43,16 +41,6 @@ export const slasherConfigMappings: ConfigMappingsType<SlasherConfig> = {
43
41
  parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
44
42
  defaultValue: DefaultSlasherConfig.slashOverridePayload,
45
43
  },
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
44
  slashValidatorsAlways: {
57
45
  env: 'SLASH_VALIDATORS_ALWAYS',
58
46
  description: 'Comma-separated list of validator addresses that should always be slashed.',
@@ -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['l1Contracts'], 'rollupAddress' | 'slashFactoryAddress' | 'registryAddress'>,
23
+ l1Contracts: Pick<L1ReaderConfig['l1Contracts'], '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,
@@ -1,33 +1,24 @@
1
1
  import { EpochCache } from '@aztec/epoch-cache';
2
- import {
3
- EmpireSlashingProposerContract,
4
- RollupContract,
5
- TallySlashingProposerContract,
6
- } from '@aztec/ethereum/contracts';
2
+ import { RollupContract, SlashingProposerContract } from '@aztec/ethereum/contracts';
7
3
  import type { ViemClient } from '@aztec/ethereum/types';
8
4
  import type { SlotNumber } from '@aztec/foundation/branded-types';
9
- import { EthAddress } from '@aztec/foundation/eth-address';
10
5
  import { createLogger } from '@aztec/foundation/log';
11
6
  import { DateProvider } from '@aztec/foundation/timer';
12
- import type { DataStoreConfig } from '@aztec/kv-store/config';
13
7
  import { AztecLMDBStoreV2 } from '@aztec/kv-store/lmdb-v2';
14
8
  import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
15
- import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
9
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
16
10
 
17
- import { EmpireSlasherClient, type EmpireSlasherSettings } from '../empire_slasher_client.js';
18
11
  import { NullSlasherClient } from '../null_slasher_client.js';
12
+ import { SlasherClient } from '../slasher_client.js';
19
13
  import { SlasherOffensesStore } from '../stores/offenses_store.js';
20
- import { SlasherPayloadsStore } from '../stores/payloads_store.js';
21
- import { TallySlasherClient } from '../tally_slasher_client.js';
22
14
  import type { Watcher } from '../watcher.js';
23
- import { getTallySlasherSettings } from './get_settings.js';
15
+ import { getSlasherSettings } from './get_settings.js';
24
16
 
25
- /** Creates a slasher client implementation (either tally or empire) based on the slasher proposer type in the rollup */
17
+ /** Creates a slasher client implementation based on the slasher proposer type in the rollup */
26
18
  export async function createSlasherImplementation(
27
19
  config: SlasherConfig & DataStoreConfig & { ethereumSlotDuration: number },
28
20
  rollup: RollupContract,
29
21
  l1Client: ViemClient,
30
- slashFactoryAddress: EthAddress | undefined,
31
22
  watchers: Watcher[],
32
23
  epochCache: EpochCache,
33
24
  dateProvider: DateProvider,
@@ -38,30 +29,14 @@ export async function createSlasherImplementation(
38
29
  const proposer = await rollup.getSlashingProposer();
39
30
  if (!proposer) {
40
31
  return new NullSlasherClient(config);
41
- } else if (proposer.type === 'tally') {
42
- return createTallySlasher(
43
- config,
44
- rollup,
45
- proposer,
46
- watchers,
47
- dateProvider,
48
- epochCache,
49
- kvStore,
50
- rollupRegisteredAtL2Slot,
51
- logger,
52
- );
53
32
  } else {
54
- if (!slashFactoryAddress || slashFactoryAddress.equals(EthAddress.ZERO)) {
55
- throw new Error('Cannot initialize an empire-based SlasherClient without a SlashFactory address');
56
- }
57
- const slashFactory = new SlashFactoryContract(l1Client, slashFactoryAddress.toString());
58
- return createEmpireSlasher(
33
+ return createSlasher(
59
34
  config,
60
35
  rollup,
61
36
  proposer,
62
- slashFactory,
63
37
  watchers,
64
38
  dateProvider,
39
+ epochCache,
65
40
  kvStore,
66
41
  rollupRegisteredAtL2Slot,
67
42
  logger,
@@ -69,99 +44,18 @@ export async function createSlasherImplementation(
69
44
  }
70
45
  }
71
46
 
72
- async function createEmpireSlasher(
73
- config: SlasherConfig & DataStoreConfig & { ethereumSlotDuration: number },
74
- rollup: RollupContract,
75
- slashingProposer: EmpireSlashingProposerContract,
76
- slashFactoryContract: SlashFactoryContract,
77
- watchers: Watcher[],
78
- dateProvider: DateProvider,
79
- kvStore: AztecLMDBStoreV2,
80
- rollupRegisteredAtL2Slot: SlotNumber,
81
- logger = createLogger('slasher'),
82
- ): Promise<EmpireSlasherClient> {
83
- if (slashingProposer.type !== 'empire') {
84
- throw new Error('Slashing proposer contract is not of type Empire');
85
- }
86
-
87
- const [
88
- slashingExecutionDelayInRounds,
89
- slashingPayloadLifetimeInRounds,
90
- slashingRoundSize,
91
- slashingQuorumSize,
92
- epochDuration,
93
- proofSubmissionEpochs,
94
- l1GenesisTime,
95
- slotDuration,
96
- l1StartBlock,
97
- slasher,
98
- ] = await Promise.all([
99
- slashingProposer.getExecutionDelayInRounds(),
100
- slashingProposer.getLifetimeInRounds(),
101
- slashingProposer.getRoundSize(),
102
- slashingProposer.getQuorumSize(),
103
- rollup.getEpochDuration(),
104
- rollup.getProofSubmissionEpochs(),
105
- rollup.getL1GenesisTime(),
106
- rollup.getSlotDuration(),
107
- rollup.getL1StartBlock(),
108
- rollup.getSlasherContract(),
109
- ]);
110
-
111
- const settings: EmpireSlasherSettings = {
112
- slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
113
- slashingPayloadLifetimeInRounds: Number(slashingPayloadLifetimeInRounds),
114
- slashingRoundSize: Number(slashingRoundSize),
115
- slashingQuorumSize: Number(slashingQuorumSize),
116
- epochDuration: Number(epochDuration),
117
- proofSubmissionEpochs: Number(proofSubmissionEpochs),
118
- l1GenesisTime: l1GenesisTime,
119
- slotDuration: Number(slotDuration),
120
- l1StartBlock,
121
- ethereumSlotDuration: config.ethereumSlotDuration,
122
- slashingAmounts: undefined,
123
- rollupRegisteredAtL2Slot,
124
- };
125
-
126
- const payloadsStore = new SlasherPayloadsStore(kvStore, {
127
- slashingPayloadLifetimeInRounds: settings.slashingPayloadLifetimeInRounds,
128
- });
129
- const offensesStore = new SlasherOffensesStore(kvStore, {
130
- ...settings,
131
- slashOffenseExpirationRounds: config.slashOffenseExpirationRounds,
132
- });
133
-
134
- return new EmpireSlasherClient(
135
- config,
136
- settings,
137
- slashFactoryContract,
138
- slashingProposer,
139
- slasher!,
140
- rollup,
141
- watchers,
142
- dateProvider,
143
- offensesStore,
144
- payloadsStore,
145
- logger,
146
- );
147
- }
148
-
149
- async function createTallySlasher(
47
+ async function createSlasher(
150
48
  config: SlasherConfig & DataStoreConfig,
151
49
  rollup: RollupContract,
152
- slashingProposer: TallySlashingProposerContract,
50
+ slashingProposer: SlashingProposerContract,
153
51
  watchers: Watcher[],
154
52
  dateProvider: DateProvider,
155
53
  epochCache: EpochCache,
156
54
  kvStore: AztecLMDBStoreV2,
157
55
  rollupRegisteredAtL2Slot: SlotNumber,
158
56
  logger = createLogger('slasher'),
159
- ): Promise<TallySlasherClient> {
160
- if (slashingProposer.type !== 'tally') {
161
- throw new Error('Slashing proposer contract is not of type tally');
162
- }
163
-
164
- const settings = { ...(await getTallySlasherSettings(rollup, slashingProposer)), rollupRegisteredAtL2Slot };
57
+ ): Promise<SlasherClient> {
58
+ const settings = { ...(await getSlasherSettings(rollup, slashingProposer)), rollupRegisteredAtL2Slot };
165
59
  const slasher = await rollup.getSlasherContract();
166
60
 
167
61
  const offensesStore = new SlasherOffensesStore(kvStore, {
@@ -169,7 +63,7 @@ async function createTallySlasher(
169
63
  slashOffenseExpirationRounds: config.slashOffenseExpirationRounds,
170
64
  });
171
65
 
172
- return new TallySlasherClient(
66
+ return new SlasherClient(
173
67
  config,
174
68
  settings,
175
69
  slashingProposer,
@@ -1,15 +1,15 @@
1
- import type { RollupContract, TallySlashingProposerContract } from '@aztec/ethereum/contracts';
1
+ import type { RollupContract, SlashingProposerContract } from '@aztec/ethereum/contracts';
2
2
 
3
- import type { TallySlasherSettings } from '../tally_slasher_client.js';
3
+ import type { SlasherSettings } from '../slasher_client.js';
4
4
 
5
- export async function getTallySlasherSettings(
5
+ export async function getSlasherSettings(
6
6
  rollup: RollupContract,
7
- slashingProposer?: TallySlashingProposerContract,
8
- ): Promise<Omit<TallySlasherSettings, 'rollupRegisteredAtL2Slot'>> {
7
+ slashingProposer?: SlashingProposerContract,
8
+ ): Promise<Omit<SlasherSettings, 'rollupRegisteredAtL2Slot'>> {
9
9
  if (!slashingProposer) {
10
10
  const rollupSlashingProposer = await rollup.getSlashingProposer();
11
- if (!rollupSlashingProposer || rollupSlashingProposer.type !== 'tally') {
12
- throw new Error('Rollup slashing proposer is not of type tally');
11
+ if (!rollupSlashingProposer) {
12
+ throw new Error('Rollup slashing proposer not found');
13
13
  }
14
14
  slashingProposer = rollupSlashingProposer;
15
15
  }
@@ -40,7 +40,7 @@ export async function getTallySlasherSettings(
40
40
  rollup.getTargetCommitteeSize(),
41
41
  ]);
42
42
 
43
- const settings: Omit<TallySlasherSettings, 'rollupRegisteredAtL2Slot'> = {
43
+ const settings: Omit<SlasherSettings, 'rollupRegisteredAtL2Slot'> = {
44
44
  slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
45
45
  slashingRoundSize: Number(slashingRoundSize),
46
46
  slashingRoundSizeInEpochs: Number(slashingRoundSizeInEpochs),
@@ -1,2 +1,2 @@
1
1
  export { createSlasherFacade as createSlasher } from './create_facade.js';
2
- export { getTallySlasherSettings } from './get_settings.js';
2
+ export { getSlasherSettings } from './get_settings.js';
@@ -3,8 +3,6 @@
3
3
 
4
4
  /** Default slasher configuration values from network-defaults.yml */
5
5
  export const slasherDefaultEnv = {
6
- SLASH_MIN_PENALTY_PERCENTAGE: 0.5,
7
- SLASH_MAX_PENALTY_PERCENTAGE: 2,
8
6
  SLASH_OFFENSE_EXPIRATION_ROUNDS: 4,
9
7
  SLASH_MAX_PAYLOAD_SIZE: 80,
10
8
  SLASH_EXECUTE_ROUNDS_LOOK_BACK: 4,
package/src/index.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  export * from './config.js';
2
2
  export * from './watchers/epoch_prune_watcher.js';
3
3
  export * from './watchers/attestations_block_watcher.js';
4
- export * from './empire_slasher_client.js';
5
- export * from './tally_slasher_client.js';
4
+ export * from './slasher_client.js';
6
5
  export * from './slash_offenses_collector.js';
7
6
  export * from './slasher_client_interface.js';
8
7
  export * from './factory/index.js';
@@ -1,5 +1,5 @@
1
1
  import type { SlotNumber } from '@aztec/foundation/branded-types';
2
- import type { Offense, ProposerSlashAction, SlashPayloadRound } from '@aztec/stdlib/slashing';
2
+ import type { Offense, ProposerSlashAction } from '@aztec/stdlib/slashing';
3
3
 
4
4
  import type { SlasherConfig } from './config.js';
5
5
  import type { SlasherClientInterface } from './slasher_client_interface.js';
@@ -15,15 +15,11 @@ export class NullSlasherClient implements SlasherClientInterface {
15
15
  return Promise.resolve();
16
16
  }
17
17
 
18
- public getSlashPayloads(): Promise<SlashPayloadRound[]> {
19
- return Promise.resolve([]);
20
- }
21
-
22
18
  public gatherOffensesForRound(_round?: bigint): Promise<Offense[]> {
23
19
  return Promise.resolve([]);
24
20
  }
25
21
 
26
- public getPendingOffenses(): Promise<Offense[]> {
22
+ public getOffenses(): Promise<Offense[]> {
27
23
  return Promise.resolve([]);
28
24
  }
29
25
 
@@ -3,7 +3,7 @@ import { createLogger } from '@aztec/foundation/log';
3
3
  import type { Prettify } from '@aztec/foundation/types';
4
4
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
5
5
  import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
6
- import { type Offense, type OffenseIdentifier, getSlotForOffense } from '@aztec/stdlib/slashing';
6
+ import { type Offense, getSlotForOffense } from '@aztec/stdlib/slashing';
7
7
 
8
8
  import type { SlasherOffensesStore } from './stores/offenses_store.js';
9
9
  import { WANT_TO_SLASH_EVENT, type WantToSlashArgs, type Watcher } from './watcher.js';
@@ -66,20 +66,20 @@ export class SlashOffensesCollector {
66
66
  */
67
67
  public async handleWantToSlash(args: WantToSlashArgs[]) {
68
68
  for (const arg of args) {
69
- const pendingOffense: Offense = {
69
+ const offense: Offense = {
70
70
  validator: arg.validator,
71
71
  amount: arg.amount,
72
72
  offenseType: arg.offenseType,
73
73
  epochOrSlot: arg.epochOrSlot,
74
74
  };
75
75
 
76
- if (this.shouldSkipOffense(pendingOffense)) {
77
- this.log.verbose('Skipping offense during grace period', pendingOffense);
76
+ if (this.shouldSkipOffense(offense)) {
77
+ this.log.verbose('Skipping offense during grace period', offense);
78
78
  continue;
79
79
  }
80
80
 
81
- if (await this.offensesStore.hasOffense(pendingOffense)) {
82
- this.log.debug('Skipping repeated offense', pendingOffense);
81
+ if (await this.offensesStore.hasOffense(offense)) {
82
+ this.log.debug('Skipping repeated offense', offense);
83
83
  continue;
84
84
  }
85
85
 
@@ -90,8 +90,8 @@ export class SlashOffensesCollector {
90
90
  }
91
91
  }
92
92
 
93
- this.log.info(`Adding pending offense for validator ${arg.validator}`, pendingOffense);
94
- await this.offensesStore.addPendingOffense(pendingOffense);
93
+ this.log.info(`Adding pending offense for validator ${arg.validator}`, offense);
94
+ await this.offensesStore.addOffense(offense);
95
95
  }
96
96
  }
97
97
 
@@ -106,15 +106,6 @@ export class SlashOffensesCollector {
106
106
  }
107
107
  }
108
108
 
109
- /**
110
- * Marks offenses as slashed (no longer pending)
111
- * @param offenses - The offenses to mark as slashed
112
- */
113
- public markAsSlashed(offenses: OffenseIdentifier[]) {
114
- this.log.verbose(`Marking offenses as slashed`, { offenses });
115
- return this.offensesStore.markAsSlashed(offenses);
116
- }
117
-
118
109
  /** Returns whether to skip an offense if it happened during the grace period after the network upgrade */
119
110
  private shouldSkipOffense(offense: Offense): boolean {
120
111
  const offenseSlot = getSlotForOffense(offense, this.settings);