Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions yarn-project/cli/src/config/chain_l2_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const DefaultSlashConfig = {
slashGracePeriodL2Slots: 32 * 2, // Two epochs from genesis
slashOffenseExpirationRounds: 8,
sentinelEnabled: true,
slashExecuteRoundsLookBack: 4,
} satisfies Partial<L2ChainConfig>;

export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
Expand Down Expand Up @@ -148,6 +149,7 @@ export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
slashOffenseExpirationRounds: 8,
sentinelEnabled: true,
slashingDisableDuration: 5 * 24 * 60 * 60,
slashExecuteRoundsLookBack: 4,
};

export const stagingPublicL2ChainConfig: L2ChainConfig = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { EthAddress } from '@aztec/aztec.js';
import { type EthAddress, retryUntil } from '@aztec/aztec.js';
import { unique } from '@aztec/foundation/collection';
import { OffenseType } from '@aztec/slasher';

import { jest } from '@jest/globals';
import 'jest-extended';
Expand All @@ -26,8 +27,14 @@ describe('e2e_p2p_inactivity_slash_with_consecutive_epochs', () => {

it('only slashes validator inactive for N consecutive epochs', async () => {
const [offlineValidator, reenabledValidator] = test.offlineValidators;
const { aztecEpochDuration, slashingExecutionDelayInRounds, slashingOffsetInRounds, slashingRoundSizeInEpochs } =
test.ctx.aztecNodeConfig;

const {
aztecEpochDuration,
slashingExecutionDelayInRounds,
slashingOffsetInRounds,
slashingRoundSizeInEpochs,
aztecSlotDuration,
} = test.ctx.aztecNodeConfig;

const initialEpoch = Number(test.test.monitor.l2EpochNumber) + 1;
test.logger.warn(`Waiting until end of epoch ${initialEpoch} to reenable validator ${reenabledValidator}`);
Expand All @@ -38,6 +45,18 @@ describe('e2e_p2p_inactivity_slash_with_consecutive_epochs', () => {
expect(reenabledNode.getSequencer()!.validatorAddresses![0].toString()).toEqual(reenabledValidator.toString());
await reenabledNode.getSequencer()!.start();

test.logger.warn(`Waiting until offenses are created for ${offlineValidator}`);
const offenses = await retryUntil(
async () => {
const offenses = await test.activeNodes[0].getSlashOffenses('all');
return offenses.length > 0 ? offenses : undefined;
},
'slash offenses',
slashInactivityConsecutiveEpochThreshold * aztecEpochDuration * aztecSlotDuration * 2,
);
expect(unique(offenses.map(o => o.validator.toString()))).toEqual([offlineValidator.toString()]);
expect(unique(offenses.map(o => o.offenseType))).toEqual([OffenseType.INACTIVITY]);

test.logger.warn(`Expecting offline validator ${offlineValidator} to be slashed but not ${reenabledValidator}`);
const slashed: EthAddress[] = [];
test.rollup.listenToSlash(args => {
Expand All @@ -51,7 +70,7 @@ describe('e2e_p2p_inactivity_slash_with_consecutive_epochs', () => {
slashInactivityConsecutiveEpochThreshold +
(slashingExecutionDelayInRounds + slashingOffsetInRounds) * slashingRoundSizeInEpochs +
5;
test.logger.warn(`Waiting until slot ${aztecEpochDuration * targetEpoch} (epoch ${targetEpoch})`);
test.logger.warn(`Waiting until slot ${aztecEpochDuration * targetEpoch} (epoch ${targetEpoch}) for slash`);
await test.test.monitor.waitUntilL2Slot(aztecEpochDuration * targetEpoch);
expect(unique(slashed.map(addr => addr.toString()))).toEqual([offlineValidator.toString()]);
});
Expand Down
1 change: 1 addition & 0 deletions yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export type EnvVar =
| 'SLASH_GRACE_PERIOD_L2_SLOTS'
| 'SLASH_OFFENSE_EXPIRATION_ROUNDS'
| 'SLASH_MAX_PAYLOAD_SIZE'
| 'SLASH_EXECUTE_ROUNDS_LOOK_BACK'
| 'SYNC_MODE'
| 'SYNC_SNAPSHOTS_URL'
| 'TELEMETRY'
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/slasher/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const DefaultSlasherConfig: SlasherConfig = {
slashOffenseExpirationRounds: 4,
slashMaxPayloadSize: 50,
slashGracePeriodL2Slots: 0,
slashExecuteRoundsLookBack: 4,
slashSelfAllowed: false,
};

Expand Down Expand Up @@ -144,6 +145,11 @@ export const slasherConfigMappings: ConfigMappingsType<SlasherConfig> = {
env: 'SLASH_GRACE_PERIOD_L2_SLOTS',
...numberConfigHelper(DefaultSlasherConfig.slashGracePeriodL2Slots),
},
slashExecuteRoundsLookBack: {
env: 'SLASH_EXECUTE_ROUNDS_LOOK_BACK',
description: 'How many rounds to look back when searching for a round to execute.',
...numberConfigHelper(DefaultSlasherConfig.slashExecuteRoundsLookBack),
},
slashSelfAllowed: {
description: 'Whether to allow slashes to own validators',
...booleanConfigHelper(DefaultSlasherConfig.slashSelfAllowed),
Expand Down
Loading
Loading