new slashing function for block commitment offence

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-12-09 17:23:08 +03:00
parent dc785e30d9
commit ddd3a42564
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
4 changed files with 15 additions and 7 deletions

2
Cargo.lock generated
View File

@ -3837,7 +3837,7 @@ dependencies = [
[[package]]
name = "ghost-slow-clap"
version = "0.4.8"
version = "0.4.9"
dependencies = [
"frame-benchmarking",
"frame-support",

View File

@ -1,6 +1,6 @@
[package]
name = "ghost-slow-clap"
version = "0.4.9"
version = "0.4.10"
description = "Applause protocol for the EVM bridge"
license.workspace = true
authors.workspace = true

View File

@ -1398,8 +1398,11 @@ impl<Offender: Clone> Offence<Offender> for SlowClapOffence<Offender> {
missed_percent.saturating_mul(Perbill::from_rational(1, offenders_count))
}
OffenceType::CommitmentOffence => offenders_count
.checked_sub(self.validator_set_count / 10 + 1)
.map(|threshold| Perbill::from_rational(3 * threshold, self.validator_set_count))
.checked_sub(Perbill::from_percent(9).mul_ceil(self.validator_set_count))
.map(|threshold| {
Perbill::from_rational(threshold.saturating_mul(4), self.validator_set_count)
.square()
})
.unwrap_or_default(),
}
}

View File

@ -40,16 +40,21 @@ fn should_calculate_throttling_slash_function_correctly() {
assert_eq!(dummy_offence.slash_fraction(5), Perbill::zero());
assert_eq!(
dummy_offence.slash_fraction(15),
Perbill::from_parts(120_000_000)
Perbill::from_parts(57_600_000)
);
assert_eq!(
dummy_offence.slash_fraction(20),
Perbill::from_parts(270_000_000)
Perbill::from_parts(193_600_000)
);
assert_eq!(
dummy_offence.slash_fraction(25),
Perbill::from_parts(409_600_000)
);
assert_eq!(
dummy_offence.slash_fraction(30),
Perbill::from_parts(570_000_000)
Perbill::from_parts(705_600_000)
);
assert_eq!(dummy_offence.slash_fraction(50), Perbill::one());
}
#[test]