mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +00:00
Freeze chain if there are byzantine threshold + 1 invalid votes against a local candidate (#7225)
This commit is contained in:
committed by
GitHub
parent
0759495cec
commit
9e4bca6895
@@ -560,6 +560,8 @@ bitflags::bitflags! {
|
||||
const FOR_SUPERMAJORITY = 0b0010;
|
||||
/// Is the supermajority against the validity of the block reached.
|
||||
const AGAINST_SUPERMAJORITY = 0b0100;
|
||||
/// Is there f+1 against the validity of the block reached
|
||||
const AGAINST_BYZANTINE = 0b1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,6 +584,10 @@ impl DisputeStateFlags {
|
||||
flags |= DisputeStateFlags::FOR_SUPERMAJORITY;
|
||||
}
|
||||
|
||||
if state.validators_against.count_ones() > byzantine_threshold {
|
||||
flags |= DisputeStateFlags::AGAINST_BYZANTINE;
|
||||
}
|
||||
|
||||
if state.validators_against.count_ones() >= supermajority_threshold {
|
||||
flags |= DisputeStateFlags::AGAINST_SUPERMAJORITY;
|
||||
}
|
||||
@@ -1243,8 +1249,8 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
<Disputes<T>>::insert(&session, &candidate_hash, &summary.state);
|
||||
|
||||
// Freeze if just concluded against some local candidate
|
||||
if summary.new_flags.contains(DisputeStateFlags::AGAINST_SUPERMAJORITY) {
|
||||
// Freeze if the INVALID votes against some local candidate are above the byzantine threshold
|
||||
if summary.new_flags.contains(DisputeStateFlags::AGAINST_BYZANTINE) {
|
||||
if let Some(revert_to) = <Included<T>>::get(&session, &candidate_hash) {
|
||||
Self::revert_and_freeze(revert_to);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user