Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give up liveness slashing #2254

Closed
wants to merge 2 commits into from
Closed
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
13 changes: 3 additions & 10 deletions substrate/frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,8 @@ impl<Offender: Clone> Offence<Offender> for UnresponsivenessOffence<Offender> {
DisableStrategy::Never
}

fn slash_fraction(&self, offenders: u32) -> Perbill {
// the formula is min((3 * (k - (n / 10 + 1))) / n, 1) * 0.07
// basically, 10% can be offline with no slash, but after that, it linearly climbs up to 7%
// when 13/30 are offline (around 5% when 1/3 are offline).
if let Some(threshold) = offenders.checked_sub(self.validator_set_count / 10 + 1) {
let x = Perbill::from_rational(3 * threshold, self.validator_set_count);
x.saturating_mul(Perbill::from_percent(7))
} else {
Perbill::default()
}
fn slash_fraction(&self, _offenders: u32) -> Perbill {
// We're not slashing for being offline anymore (see #1964)
Perbill::zero()
}
}
27 changes: 0 additions & 27 deletions substrate/frame/im-online/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,6 @@ use sp_runtime::{
transaction_validity::{InvalidTransaction, TransactionValidityError},
};

#[test]
fn test_unresponsiveness_slash_fraction() {
let dummy_offence =
UnresponsivenessOffence { session_index: 0, validator_set_count: 50, offenders: vec![()] };
// A single case of unresponsiveness is not slashed.
assert_eq!(dummy_offence.slash_fraction(1), Perbill::zero());

assert_eq!(
dummy_offence.slash_fraction(5),
Perbill::zero(), // 0%
);

assert_eq!(
dummy_offence.slash_fraction(7),
Perbill::from_parts(4200000), // 0.42%
);

// One third offline should be punished around 5%.
assert_eq!(
dummy_offence.slash_fraction(17),
Perbill::from_parts(46200000), // 4.62%
);

// Offline offences should never lead to being disabled.
assert_eq!(dummy_offence.disable_strategy(), DisableStrategy::Never);
}

#[test]
fn should_report_offline_validators() {
new_test_ext().execute_with(|| {
Expand Down
Loading