bridge slashing issue fix

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-01-30 22:09:32 +03:00
commit 885c519519
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
4 changed files with 11 additions and 6 deletions

2
Cargo.lock generated
View File

@ -3832,7 +3832,7 @@ dependencies = [
[[package]]
name = "ghost-slow-clap"
version = "0.3.14"
version = "0.3.15"
dependencies = [
"frame-benchmarking",
"frame-support",

View File

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

View File

@ -1162,16 +1162,22 @@ impl<T: Config> Pallet<T> {
session_index: SessionIndex,
average_claps: u32,
) -> bool {
if average_claps == 0 {
return true;
}
let claps_in_session = AuthorityInfoInSession::<T>::get(session_index);
match claps_in_session.get(authority_index) {
Some(clap_in_session) => {
let number_of_claps = &clap_in_session.actions;
let authority_deviation = if *number_of_claps < average_claps {
Perbill::from_rational(*number_of_claps, average_claps)
} else { Perbill::from_rational(average_claps, *number_of_claps) };
Perbill::from_rational(average_claps - *number_of_claps, average_claps)
} else {
Perbill::from_rational(*number_of_claps - average_claps, average_claps)
};
authority_deviation < Perbill::from_percent(T::OffenceThreshold::get())
},
_ => false,
None => false,
}
}

View File

@ -35,7 +35,6 @@ fn prepare_companion(amount: u64) -> Companion<NetworkIdOf<Runtime>, BalanceOf<R
Companion {
network_id: 1,
receiver: H160::from_low_u64_ne(1337),
fee: H256::from_low_u64_ne(40_000),
amount: amount,
}
}