new slashing function for block commitment offence
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
dc785e30d9
commit
ddd3a42564
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3837,7 +3837,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.8"
|
version = "0.4.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.9"
|
version = "0.4.10"
|
||||||
description = "Applause protocol for the EVM bridge"
|
description = "Applause protocol for the EVM bridge"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -1398,8 +1398,11 @@ impl<Offender: Clone> Offence<Offender> for SlowClapOffence<Offender> {
|
|||||||
missed_percent.saturating_mul(Perbill::from_rational(1, offenders_count))
|
missed_percent.saturating_mul(Perbill::from_rational(1, offenders_count))
|
||||||
}
|
}
|
||||||
OffenceType::CommitmentOffence => offenders_count
|
OffenceType::CommitmentOffence => offenders_count
|
||||||
.checked_sub(self.validator_set_count / 10 + 1)
|
.checked_sub(Perbill::from_percent(9).mul_ceil(self.validator_set_count))
|
||||||
.map(|threshold| Perbill::from_rational(3 * threshold, self.validator_set_count))
|
.map(|threshold| {
|
||||||
|
Perbill::from_rational(threshold.saturating_mul(4), self.validator_set_count)
|
||||||
|
.square()
|
||||||
|
})
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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(5), Perbill::zero());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
dummy_offence.slash_fraction(15),
|
dummy_offence.slash_fraction(15),
|
||||||
Perbill::from_parts(120_000_000)
|
Perbill::from_parts(57_600_000)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
dummy_offence.slash_fraction(20),
|
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!(
|
assert_eq!(
|
||||||
dummy_offence.slash_fraction(30),
|
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]
|
#[test]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user