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

add candidacy un-bonding period #1281

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,17 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// New invulnerables candidates were set.
NewInvulnerables(Vec<T::AccountId>),
/// The number of desired candidates was set.
NewDesiredCandidates(u32),
/// The candidacy bond was set.
NewCandidacyBond(BalanceOf<T>),
/// A new candidate joined.
CandidateAdded(T::AccountId, BalanceOf<T>),
/// A candidate was removed.
CandidateRemoved(T::AccountId),
/// A candidate was slashed.
CandidateSlashed(T::AccountId),
}

Expand Down Expand Up @@ -557,7 +563,7 @@ pub mod pallet {
Self::slash_non_candidate(&who);
}
}
(count, count - Self::candidates().len() as u32)
(count, count.saturating_sub(Self::candidates().len() as u32))
}

/// Check whether an account is a candidate.
Expand Down
4 changes: 2 additions & 2 deletions pallets/collator-selection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// limitations under the License.

use crate as collator_selection;
use crate::{mock::*, CandidateInfo, Error, NonCandidates};
use crate::{mock::*, CandidateInfo, Error, LastAuthoredBlock, NonCandidates};
use frame_support::{
assert_noop, assert_ok,
traits::{Currency, OnInitialize},
Expand Down Expand Up @@ -520,7 +520,7 @@ fn slash_mechanism_for_unbonding_candidates() {
initialize_to_block(20);
assert_eq!(CollatorSelection::candidates().len(), 1);
assert_eq!(SessionChangeBlock::get(), 20);
assert_eq!(CollatorSelection::last_authored_block(3), 0);
assert_eq!(LastAuthoredBlock::<Test>::contains_key(3), false);
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(CollatorSelection::last_authored_block(4), 20);

// slashed, remaining bond was refunded
Expand Down
Loading