mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
removed pallet::getter usage from cumulus pallets (#3471)
Part of #3326 @ggwpez @kianenigma @shawntabrizi polkadot address: 12poSUQPtcF1HUPQGY3zZu2P8emuW9YnsPduA4XG3oCEfJVp --------- Signed-off-by: Matteo Muraca <mmuraca247@gmail.com>
This commit is contained in:
@@ -54,8 +54,8 @@ where
|
|||||||
let velocity = V.max(1);
|
let velocity = V.max(1);
|
||||||
let relay_chain_slot = state_proof.read_slot().expect("failed to read relay chain slot");
|
let relay_chain_slot = state_proof.read_slot().expect("failed to read relay chain slot");
|
||||||
|
|
||||||
let (slot, authored) = pallet::Pallet::<T>::slot_info()
|
let (slot, authored) =
|
||||||
.expect("slot info is inserted on block initialization");
|
pallet::SlotInfo::<T>::get().expect("slot info is inserted on block initialization");
|
||||||
|
|
||||||
// Convert relay chain timestamp.
|
// Convert relay chain timestamp.
|
||||||
let relay_chain_timestamp =
|
let relay_chain_timestamp =
|
||||||
@@ -100,7 +100,7 @@ impl<
|
|||||||
/// is more recent than the included block itself.
|
/// is more recent than the included block itself.
|
||||||
pub fn can_build_upon(included_hash: T::Hash, new_slot: Slot) -> bool {
|
pub fn can_build_upon(included_hash: T::Hash, new_slot: Slot) -> bool {
|
||||||
let velocity = V.max(1);
|
let velocity = V.max(1);
|
||||||
let (last_slot, authored_so_far) = match pallet::Pallet::<T>::slot_info() {
|
let (last_slot, authored_so_far) = match pallet::SlotInfo::<T>::get() {
|
||||||
None => return true,
|
None => return true,
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Updated on each block initialization.
|
/// Updated on each block initialization.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn slot_info)]
|
|
||||||
pub(crate) type SlotInfo<T: Config> = StorageValue<_, (Slot, u32), OptionQuery>;
|
pub(crate) type SlotInfo<T: Config> = StorageValue<_, (Slot, u32), OptionQuery>;
|
||||||
|
|
||||||
#[pallet::genesis_config]
|
#[pallet::genesis_config]
|
||||||
|
|||||||
@@ -86,23 +86,23 @@ fn register_validators<T: Config + session::Config>(count: u32) -> Vec<T::Accoun
|
|||||||
|
|
||||||
fn register_candidates<T: Config>(count: u32) {
|
fn register_candidates<T: Config>(count: u32) {
|
||||||
let candidates = (0..count).map(|c| account("candidate", c, SEED)).collect::<Vec<_>>();
|
let candidates = (0..count).map(|c| account("candidate", c, SEED)).collect::<Vec<_>>();
|
||||||
assert!(<CandidacyBond<T>>::get() > 0u32.into(), "Bond cannot be zero!");
|
assert!(CandidacyBond::<T>::get() > 0u32.into(), "Bond cannot be zero!");
|
||||||
|
|
||||||
for who in candidates {
|
for who in candidates {
|
||||||
T::Currency::make_free_balance_be(&who, <CandidacyBond<T>>::get() * 3u32.into());
|
T::Currency::make_free_balance_be(&who, CandidacyBond::<T>::get() * 3u32.into());
|
||||||
<CollatorSelection<T>>::register_as_candidate(RawOrigin::Signed(who).into()).unwrap();
|
<CollatorSelection<T>>::register_as_candidate(RawOrigin::Signed(who).into()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn min_candidates<T: Config>() -> u32 {
|
fn min_candidates<T: Config>() -> u32 {
|
||||||
let min_collators = T::MinEligibleCollators::get();
|
let min_collators = T::MinEligibleCollators::get();
|
||||||
let invulnerable_length = <Invulnerables<T>>::get().len();
|
let invulnerable_length = Invulnerables::<T>::get().len();
|
||||||
min_collators.saturating_sub(invulnerable_length.try_into().unwrap())
|
min_collators.saturating_sub(invulnerable_length.try_into().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn min_invulnerables<T: Config>() -> u32 {
|
fn min_invulnerables<T: Config>() -> u32 {
|
||||||
let min_collators = T::MinEligibleCollators::get();
|
let min_collators = T::MinEligibleCollators::get();
|
||||||
let candidates_length = <CandidateList<T>>::decode_len()
|
let candidates_length = CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
@@ -143,8 +143,8 @@ mod benchmarks {
|
|||||||
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||||
|
|
||||||
// need to fill up candidates
|
// need to fill up candidates
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(c);
|
DesiredCandidates::<T>::put(c);
|
||||||
// get accounts and keys for the `c` candidates
|
// get accounts and keys for the `c` candidates
|
||||||
let mut candidates = (0..c).map(|cc| validator::<T>(cc)).collect::<Vec<_>>();
|
let mut candidates = (0..c).map(|cc| validator::<T>(cc)).collect::<Vec<_>>();
|
||||||
// add one more to the list. should not be in `b` (invulnerables) because it's the account
|
// add one more to the list. should not be in `b` (invulnerables) because it's the account
|
||||||
@@ -159,15 +159,15 @@ mod benchmarks {
|
|||||||
}
|
}
|
||||||
// ... and register them.
|
// ... and register them.
|
||||||
for (who, _) in candidates.iter() {
|
for (who, _) in candidates.iter() {
|
||||||
let deposit = <CandidacyBond<T>>::get();
|
let deposit = CandidacyBond::<T>::get();
|
||||||
T::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
|
T::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
|
||||||
<CandidateList<T>>::try_mutate(|list| {
|
CandidateList::<T>::try_mutate(|list| {
|
||||||
list.try_push(CandidateInfo { who: who.clone(), deposit }).unwrap();
|
list.try_push(CandidateInfo { who: who.clone(), deposit }).unwrap();
|
||||||
Ok::<(), BenchmarkError>(())
|
Ok::<(), BenchmarkError>(())
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
T::Currency::reserve(who, deposit)?;
|
T::Currency::reserve(who, deposit)?;
|
||||||
<LastAuthoredBlock<T>>::insert(
|
LastAuthoredBlock::<T>::insert(
|
||||||
who.clone(),
|
who.clone(),
|
||||||
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
||||||
);
|
);
|
||||||
@@ -178,7 +178,7 @@ mod benchmarks {
|
|||||||
invulnerables.sort();
|
invulnerables.sort();
|
||||||
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> =
|
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> =
|
||||||
frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
||||||
<Invulnerables<T>>::put(invulnerables);
|
Invulnerables::<T>::put(invulnerables);
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
_(origin as T::RuntimeOrigin, new_invulnerable.clone());
|
_(origin as T::RuntimeOrigin, new_invulnerable.clone());
|
||||||
@@ -197,8 +197,8 @@ mod benchmarks {
|
|||||||
invulnerables.sort();
|
invulnerables.sort();
|
||||||
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> =
|
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> =
|
||||||
frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
||||||
<Invulnerables<T>>::put(invulnerables);
|
Invulnerables::<T>::put(invulnerables);
|
||||||
let to_remove = <Invulnerables<T>>::get().first().unwrap().clone();
|
let to_remove = Invulnerables::<T>::get().first().unwrap().clone();
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
_(origin as T::RuntimeOrigin, to_remove.clone());
|
_(origin as T::RuntimeOrigin, to_remove.clone());
|
||||||
@@ -226,14 +226,14 @@ mod benchmarks {
|
|||||||
k: Linear<0, { T::MaxCandidates::get() }>,
|
k: Linear<0, { T::MaxCandidates::get() }>,
|
||||||
) -> Result<(), BenchmarkError> {
|
) -> Result<(), BenchmarkError> {
|
||||||
let initial_bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
|
let initial_bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
|
||||||
<CandidacyBond<T>>::put(initial_bond_amount);
|
CandidacyBond::<T>::put(initial_bond_amount);
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
register_candidates::<T>(c);
|
register_candidates::<T>(c);
|
||||||
let kicked = cmp::min(k, c);
|
let kicked = cmp::min(k, c);
|
||||||
let origin =
|
let origin =
|
||||||
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||||
let bond_amount = if k > 0 {
|
let bond_amount = if k > 0 {
|
||||||
<CandidateList<T>>::mutate(|candidates| {
|
CandidateList::<T>::mutate(|candidates| {
|
||||||
for info in candidates.iter_mut().skip(kicked as usize) {
|
for info in candidates.iter_mut().skip(kicked as usize) {
|
||||||
info.deposit = T::Currency::minimum_balance() * 3u32.into();
|
info.deposit = T::Currency::minimum_balance() * 3u32.into();
|
||||||
}
|
}
|
||||||
@@ -254,13 +254,13 @@ mod benchmarks {
|
|||||||
fn update_bond(
|
fn update_bond(
|
||||||
c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>,
|
c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>,
|
||||||
) -> Result<(), BenchmarkError> {
|
) -> Result<(), BenchmarkError> {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(c);
|
DesiredCandidates::<T>::put(c);
|
||||||
|
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
register_candidates::<T>(c);
|
register_candidates::<T>(c);
|
||||||
|
|
||||||
let caller = <CandidateList<T>>::get()[0].who.clone();
|
let caller = CandidateList::<T>::get()[0].who.clone();
|
||||||
v2::whitelist!(caller);
|
v2::whitelist!(caller);
|
||||||
|
|
||||||
let bond_amount: BalanceOf<T> =
|
let bond_amount: BalanceOf<T> =
|
||||||
@@ -273,7 +273,7 @@ mod benchmarks {
|
|||||||
Event::CandidateBondUpdated { account_id: caller, deposit: bond_amount }.into(),
|
Event::CandidateBondUpdated { account_id: caller, deposit: bond_amount }.into(),
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
<CandidateList<T>>::get().iter().last().unwrap().deposit ==
|
CandidateList::<T>::get().iter().last().unwrap().deposit ==
|
||||||
T::Currency::minimum_balance() * 2u32.into()
|
T::Currency::minimum_balance() * 2u32.into()
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -283,8 +283,8 @@ mod benchmarks {
|
|||||||
// one.
|
// one.
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn register_as_candidate(c: Linear<1, { T::MaxCandidates::get() - 1 }>) {
|
fn register_as_candidate(c: Linear<1, { T::MaxCandidates::get() - 1 }>) {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(c + 1);
|
DesiredCandidates::<T>::put(c + 1);
|
||||||
|
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
register_candidates::<T>(c);
|
register_candidates::<T>(c);
|
||||||
@@ -310,8 +310,8 @@ mod benchmarks {
|
|||||||
|
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn take_candidate_slot(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
|
fn take_candidate_slot(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(1);
|
DesiredCandidates::<T>::put(1);
|
||||||
|
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
register_candidates::<T>(c);
|
register_candidates::<T>(c);
|
||||||
@@ -327,7 +327,7 @@ mod benchmarks {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let target = <CandidateList<T>>::get().iter().last().unwrap().who.clone();
|
let target = CandidateList::<T>::get().iter().last().unwrap().who.clone();
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
_(RawOrigin::Signed(caller.clone()), bond / 2u32.into(), target.clone());
|
_(RawOrigin::Signed(caller.clone()), bond / 2u32.into(), target.clone());
|
||||||
@@ -341,13 +341,13 @@ mod benchmarks {
|
|||||||
// worse case is the last candidate leaving.
|
// worse case is the last candidate leaving.
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn leave_intent(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
|
fn leave_intent(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(c);
|
DesiredCandidates::<T>::put(c);
|
||||||
|
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
register_candidates::<T>(c);
|
register_candidates::<T>(c);
|
||||||
|
|
||||||
let leaving = <CandidateList<T>>::get().iter().last().unwrap().who.clone();
|
let leaving = CandidateList::<T>::get().iter().last().unwrap().who.clone();
|
||||||
v2::whitelist!(leaving);
|
v2::whitelist!(leaving);
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
@@ -359,7 +359,7 @@ mod benchmarks {
|
|||||||
// worse case is paying a non-existing candidate account.
|
// worse case is paying a non-existing candidate account.
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn note_author() {
|
fn note_author() {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
T::Currency::make_free_balance_be(
|
T::Currency::make_free_balance_be(
|
||||||
&<CollatorSelection<T>>::account_id(),
|
&<CollatorSelection<T>>::account_id(),
|
||||||
T::Currency::minimum_balance() * 4u32.into(),
|
T::Currency::minimum_balance() * 4u32.into(),
|
||||||
@@ -385,8 +385,8 @@ mod benchmarks {
|
|||||||
r: Linear<1, { T::MaxCandidates::get() }>,
|
r: Linear<1, { T::MaxCandidates::get() }>,
|
||||||
c: Linear<1, { T::MaxCandidates::get() }>,
|
c: Linear<1, { T::MaxCandidates::get() }>,
|
||||||
) {
|
) {
|
||||||
<CandidacyBond<T>>::put(T::Currency::minimum_balance());
|
CandidacyBond::<T>::put(T::Currency::minimum_balance());
|
||||||
<DesiredCandidates<T>>::put(c);
|
DesiredCandidates::<T>::put(c);
|
||||||
frame_system::Pallet::<T>::set_block_number(0u32.into());
|
frame_system::Pallet::<T>::set_block_number(0u32.into());
|
||||||
|
|
||||||
register_validators::<T>(c);
|
register_validators::<T>(c);
|
||||||
@@ -394,7 +394,7 @@ mod benchmarks {
|
|||||||
|
|
||||||
let new_block: BlockNumberFor<T> = T::KickThreshold::get();
|
let new_block: BlockNumberFor<T> = T::KickThreshold::get();
|
||||||
let zero_block: BlockNumberFor<T> = 0u32.into();
|
let zero_block: BlockNumberFor<T> = 0u32.into();
|
||||||
let candidates: Vec<T::AccountId> = <CandidateList<T>>::get()
|
let candidates: Vec<T::AccountId> = CandidateList::<T>::get()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|candidate_info| candidate_info.who.clone())
|
.map(|candidate_info| candidate_info.who.clone())
|
||||||
.collect();
|
.collect();
|
||||||
@@ -402,25 +402,25 @@ mod benchmarks {
|
|||||||
let non_removals = c.saturating_sub(r);
|
let non_removals = c.saturating_sub(r);
|
||||||
|
|
||||||
for i in 0..c {
|
for i in 0..c {
|
||||||
<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);
|
LastAuthoredBlock::<T>::insert(candidates[i as usize].clone(), zero_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if non_removals > 0 {
|
if non_removals > 0 {
|
||||||
for i in 0..non_removals {
|
for i in 0..non_removals {
|
||||||
<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);
|
LastAuthoredBlock::<T>::insert(candidates[i as usize].clone(), new_block);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i in 0..c {
|
for i in 0..c {
|
||||||
<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);
|
LastAuthoredBlock::<T>::insert(candidates[i as usize].clone(), new_block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let min_candidates = min_candidates::<T>();
|
let min_candidates = min_candidates::<T>();
|
||||||
let pre_length = <CandidateList<T>>::decode_len().unwrap_or_default();
|
let pre_length = CandidateList::<T>::decode_len().unwrap_or_default();
|
||||||
|
|
||||||
frame_system::Pallet::<T>::set_block_number(new_block);
|
frame_system::Pallet::<T>::set_block_number(new_block);
|
||||||
|
|
||||||
let current_length: u32 = <CandidateList<T>>::decode_len()
|
let current_length: u32 = CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
@@ -434,12 +434,12 @@ mod benchmarks {
|
|||||||
// candidates > removals and remaining candidates > min candidates
|
// candidates > removals and remaining candidates > min candidates
|
||||||
// => remaining candidates should be shorter than before removal, i.e. some were
|
// => remaining candidates should be shorter than before removal, i.e. some were
|
||||||
// actually removed.
|
// actually removed.
|
||||||
assert!(<CandidateList<T>>::decode_len().unwrap_or_default() < pre_length);
|
assert!(CandidateList::<T>::decode_len().unwrap_or_default() < pre_length);
|
||||||
} else if c > r && non_removals < min_candidates {
|
} else if c > r && non_removals < min_candidates {
|
||||||
// candidates > removals and remaining candidates would be less than min candidates
|
// candidates > removals and remaining candidates would be less than min candidates
|
||||||
// => remaining candidates should equal min candidates, i.e. some were removed up to
|
// => remaining candidates should equal min candidates, i.e. some were removed up to
|
||||||
// the minimum, but then any more were "forced" to stay in candidates.
|
// the minimum, but then any more were "forced" to stay in candidates.
|
||||||
let current_length: u32 = <CandidateList<T>>::decode_len()
|
let current_length: u32 = CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
@@ -447,7 +447,7 @@ mod benchmarks {
|
|||||||
} else {
|
} else {
|
||||||
// removals >= candidates, non removals must == 0
|
// removals >= candidates, non removals must == 0
|
||||||
// can't remove more than exist
|
// can't remove more than exist
|
||||||
assert!(<CandidateList<T>>::decode_len().unwrap_or_default() == pre_length);
|
assert!(CandidateList::<T>::decode_len().unwrap_or_default() == pre_length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// The invulnerable, permissioned collators. This list must be sorted.
|
/// The invulnerable, permissioned collators. This list must be sorted.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn invulnerables)]
|
|
||||||
pub type Invulnerables<T: Config> =
|
pub type Invulnerables<T: Config> =
|
||||||
StorageValue<_, BoundedVec<T::AccountId, T::MaxInvulnerables>, ValueQuery>;
|
StorageValue<_, BoundedVec<T::AccountId, T::MaxInvulnerables>, ValueQuery>;
|
||||||
|
|
||||||
@@ -206,7 +205,6 @@ pub mod pallet {
|
|||||||
/// This list is sorted in ascending order by deposit and when the deposits are equal, the least
|
/// This list is sorted in ascending order by deposit and when the deposits are equal, the least
|
||||||
/// recently updated is considered greater.
|
/// recently updated is considered greater.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn candidate_list)]
|
|
||||||
pub type CandidateList<T: Config> = StorageValue<
|
pub type CandidateList<T: Config> = StorageValue<
|
||||||
_,
|
_,
|
||||||
BoundedVec<CandidateInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>,
|
BoundedVec<CandidateInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>,
|
||||||
@@ -215,7 +213,6 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// Last block authored by collator.
|
/// Last block authored by collator.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn last_authored_block)]
|
|
||||||
pub type LastAuthoredBlock<T: Config> =
|
pub type LastAuthoredBlock<T: Config> =
|
||||||
StorageMap<_, Twox64Concat, T::AccountId, BlockNumberFor<T>, ValueQuery>;
|
StorageMap<_, Twox64Concat, T::AccountId, BlockNumberFor<T>, ValueQuery>;
|
||||||
|
|
||||||
@@ -223,14 +220,12 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// This should ideally always be less than [`Config::MaxCandidates`] for weights to be correct.
|
/// This should ideally always be less than [`Config::MaxCandidates`] for weights to be correct.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn desired_candidates)]
|
|
||||||
pub type DesiredCandidates<T> = StorageValue<_, u32, ValueQuery>;
|
pub type DesiredCandidates<T> = StorageValue<_, u32, ValueQuery>;
|
||||||
|
|
||||||
/// Fixed amount to deposit to become a collator.
|
/// Fixed amount to deposit to become a collator.
|
||||||
///
|
///
|
||||||
/// When a collator calls `leave_intent` they immediately receive the deposit back.
|
/// When a collator calls `leave_intent` they immediately receive the deposit back.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn candidacy_bond)]
|
|
||||||
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||||
|
|
||||||
#[pallet::genesis_config]
|
#[pallet::genesis_config]
|
||||||
@@ -263,9 +258,9 @@ pub mod pallet {
|
|||||||
|
|
||||||
bounded_invulnerables.sort();
|
bounded_invulnerables.sort();
|
||||||
|
|
||||||
<DesiredCandidates<T>>::put(self.desired_candidates);
|
DesiredCandidates::<T>::put(self.desired_candidates);
|
||||||
<CandidacyBond<T>>::put(self.candidacy_bond);
|
CandidacyBond::<T>::put(self.candidacy_bond);
|
||||||
<Invulnerables<T>>::put(bounded_invulnerables);
|
Invulnerables::<T>::put(bounded_invulnerables);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +419,7 @@ pub mod pallet {
|
|||||||
// Invulnerables must be sorted for removal.
|
// Invulnerables must be sorted for removal.
|
||||||
bounded_invulnerables.sort();
|
bounded_invulnerables.sort();
|
||||||
|
|
||||||
<Invulnerables<T>>::put(&bounded_invulnerables);
|
Invulnerables::<T>::put(&bounded_invulnerables);
|
||||||
Self::deposit_event(Event::NewInvulnerables {
|
Self::deposit_event(Event::NewInvulnerables {
|
||||||
invulnerables: bounded_invulnerables.to_vec(),
|
invulnerables: bounded_invulnerables.to_vec(),
|
||||||
});
|
});
|
||||||
@@ -448,7 +443,7 @@ pub mod pallet {
|
|||||||
if max > T::MaxCandidates::get() {
|
if max > T::MaxCandidates::get() {
|
||||||
log::warn!("max > T::MaxCandidates; you might need to run benchmarks again");
|
log::warn!("max > T::MaxCandidates; you might need to run benchmarks again");
|
||||||
}
|
}
|
||||||
<DesiredCandidates<T>>::put(max);
|
DesiredCandidates::<T>::put(max);
|
||||||
Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max });
|
Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max });
|
||||||
Ok(().into())
|
Ok(().into())
|
||||||
}
|
}
|
||||||
@@ -470,17 +465,17 @@ pub mod pallet {
|
|||||||
bond: BalanceOf<T>,
|
bond: BalanceOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
T::UpdateOrigin::ensure_origin(origin)?;
|
T::UpdateOrigin::ensure_origin(origin)?;
|
||||||
let bond_increased = <CandidacyBond<T>>::mutate(|old_bond| -> bool {
|
let bond_increased = CandidacyBond::<T>::mutate(|old_bond| -> bool {
|
||||||
let bond_increased = *old_bond < bond;
|
let bond_increased = *old_bond < bond;
|
||||||
*old_bond = bond;
|
*old_bond = bond;
|
||||||
bond_increased
|
bond_increased
|
||||||
});
|
});
|
||||||
let initial_len = <CandidateList<T>>::decode_len().unwrap_or_default();
|
let initial_len = CandidateList::<T>::decode_len().unwrap_or_default();
|
||||||
let kicked = (bond_increased && initial_len > 0)
|
let kicked = (bond_increased && initial_len > 0)
|
||||||
.then(|| {
|
.then(|| {
|
||||||
// Closure below returns the number of candidates which were kicked because
|
// Closure below returns the number of candidates which were kicked because
|
||||||
// their deposits were lower than the new candidacy bond.
|
// their deposits were lower than the new candidacy bond.
|
||||||
<CandidateList<T>>::mutate(|candidates| -> usize {
|
CandidateList::<T>::mutate(|candidates| -> usize {
|
||||||
let first_safe_candidate = candidates
|
let first_safe_candidate = candidates
|
||||||
.iter()
|
.iter()
|
||||||
.position(|candidate| candidate.deposit >= bond)
|
.position(|candidate| candidate.deposit >= bond)
|
||||||
@@ -488,7 +483,7 @@ pub mod pallet {
|
|||||||
let kicked_candidates = candidates.drain(..first_safe_candidate);
|
let kicked_candidates = candidates.drain(..first_safe_candidate);
|
||||||
for candidate in kicked_candidates {
|
for candidate in kicked_candidates {
|
||||||
T::Currency::unreserve(&candidate.who, candidate.deposit);
|
T::Currency::unreserve(&candidate.who, candidate.deposit);
|
||||||
<LastAuthoredBlock<T>>::remove(candidate.who);
|
LastAuthoredBlock::<T>::remove(candidate.who);
|
||||||
}
|
}
|
||||||
first_safe_candidate
|
first_safe_candidate
|
||||||
})
|
})
|
||||||
@@ -512,12 +507,12 @@ pub mod pallet {
|
|||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
// ensure we are below limit.
|
// ensure we are below limit.
|
||||||
let length: u32 = <CandidateList<T>>::decode_len()
|
let length: u32 = CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
ensure!(length < T::MaxCandidates::get(), Error::<T>::TooManyCandidates);
|
ensure!(length < T::MaxCandidates::get(), Error::<T>::TooManyCandidates);
|
||||||
ensure!(!Self::invulnerables().contains(&who), Error::<T>::AlreadyInvulnerable);
|
ensure!(!Invulnerables::<T>::get().contains(&who), Error::<T>::AlreadyInvulnerable);
|
||||||
|
|
||||||
let validator_key = T::ValidatorIdOf::convert(who.clone())
|
let validator_key = T::ValidatorIdOf::convert(who.clone())
|
||||||
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
|
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
|
||||||
@@ -526,15 +521,15 @@ pub mod pallet {
|
|||||||
Error::<T>::ValidatorNotRegistered
|
Error::<T>::ValidatorNotRegistered
|
||||||
);
|
);
|
||||||
|
|
||||||
let deposit = Self::candidacy_bond();
|
let deposit = CandidacyBond::<T>::get();
|
||||||
// First authored block is current block plus kick threshold to handle session delay
|
// First authored block is current block plus kick threshold to handle session delay
|
||||||
<CandidateList<T>>::try_mutate(|candidates| -> Result<(), DispatchError> {
|
CandidateList::<T>::try_mutate(|candidates| -> Result<(), DispatchError> {
|
||||||
ensure!(
|
ensure!(
|
||||||
!candidates.iter().any(|candidate_info| candidate_info.who == who),
|
!candidates.iter().any(|candidate_info| candidate_info.who == who),
|
||||||
Error::<T>::AlreadyCandidate
|
Error::<T>::AlreadyCandidate
|
||||||
);
|
);
|
||||||
T::Currency::reserve(&who, deposit)?;
|
T::Currency::reserve(&who, deposit)?;
|
||||||
<LastAuthoredBlock<T>>::insert(
|
LastAuthoredBlock::<T>::insert(
|
||||||
who.clone(),
|
who.clone(),
|
||||||
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
||||||
);
|
);
|
||||||
@@ -564,7 +559,7 @@ pub mod pallet {
|
|||||||
Self::eligible_collators() > T::MinEligibleCollators::get(),
|
Self::eligible_collators() > T::MinEligibleCollators::get(),
|
||||||
Error::<T>::TooFewEligibleCollators
|
Error::<T>::TooFewEligibleCollators
|
||||||
);
|
);
|
||||||
let length = <CandidateList<T>>::decode_len().unwrap_or_default();
|
let length = CandidateList::<T>::decode_len().unwrap_or_default();
|
||||||
// Do remove their last authored block.
|
// Do remove their last authored block.
|
||||||
Self::try_remove_candidate(&who, true)?;
|
Self::try_remove_candidate(&who, true)?;
|
||||||
|
|
||||||
@@ -594,7 +589,7 @@ pub mod pallet {
|
|||||||
Error::<T>::ValidatorNotRegistered
|
Error::<T>::ValidatorNotRegistered
|
||||||
);
|
);
|
||||||
|
|
||||||
<Invulnerables<T>>::try_mutate(|invulnerables| -> DispatchResult {
|
Invulnerables::<T>::try_mutate(|invulnerables| -> DispatchResult {
|
||||||
match invulnerables.binary_search(&who) {
|
match invulnerables.binary_search(&who) {
|
||||||
Ok(_) => return Err(Error::<T>::AlreadyInvulnerable)?,
|
Ok(_) => return Err(Error::<T>::AlreadyInvulnerable)?,
|
||||||
Err(pos) => invulnerables
|
Err(pos) => invulnerables
|
||||||
@@ -615,7 +610,7 @@ pub mod pallet {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or(T::MaxInvulnerables::get().saturating_sub(1)),
|
.unwrap_or(T::MaxInvulnerables::get().saturating_sub(1)),
|
||||||
<CandidateList<T>>::decode_len()
|
CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or(T::MaxCandidates::get()),
|
.unwrap_or(T::MaxCandidates::get()),
|
||||||
@@ -638,7 +633,7 @@ pub mod pallet {
|
|||||||
Error::<T>::TooFewEligibleCollators
|
Error::<T>::TooFewEligibleCollators
|
||||||
);
|
);
|
||||||
|
|
||||||
<Invulnerables<T>>::try_mutate(|invulnerables| -> DispatchResult {
|
Invulnerables::<T>::try_mutate(|invulnerables| -> DispatchResult {
|
||||||
let pos =
|
let pos =
|
||||||
invulnerables.binary_search(&who).map_err(|_| Error::<T>::NotInvulnerable)?;
|
invulnerables.binary_search(&who).map_err(|_| Error::<T>::NotInvulnerable)?;
|
||||||
invulnerables.remove(pos);
|
invulnerables.remove(pos);
|
||||||
@@ -663,12 +658,12 @@ pub mod pallet {
|
|||||||
new_deposit: BalanceOf<T>,
|
new_deposit: BalanceOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
ensure!(new_deposit >= <CandidacyBond<T>>::get(), Error::<T>::DepositTooLow);
|
ensure!(new_deposit >= CandidacyBond::<T>::get(), Error::<T>::DepositTooLow);
|
||||||
// The function below will try to mutate the `CandidateList` entry for the caller to
|
// The function below will try to mutate the `CandidateList` entry for the caller to
|
||||||
// update their deposit to the new value of `new_deposit`. The return value is the
|
// update their deposit to the new value of `new_deposit`. The return value is the
|
||||||
// position of the entry in the list, used for weight calculation.
|
// position of the entry in the list, used for weight calculation.
|
||||||
let length =
|
let length =
|
||||||
<CandidateList<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
|
CandidateList::<T>::try_mutate(|candidates| -> Result<usize, DispatchError> {
|
||||||
let idx = candidates
|
let idx = candidates
|
||||||
.iter()
|
.iter()
|
||||||
.position(|candidate_info| candidate_info.who == who)
|
.position(|candidate_info| candidate_info.who == who)
|
||||||
@@ -682,7 +677,7 @@ pub mod pallet {
|
|||||||
} else if new_deposit < old_deposit {
|
} else if new_deposit < old_deposit {
|
||||||
// Casting `u32` to `usize` should be safe on all machines running this.
|
// Casting `u32` to `usize` should be safe on all machines running this.
|
||||||
ensure!(
|
ensure!(
|
||||||
idx.saturating_add(<DesiredCandidates<T>>::get() as usize) <
|
idx.saturating_add(DesiredCandidates::<T>::get() as usize) <
|
||||||
candidate_count,
|
candidate_count,
|
||||||
Error::<T>::InvalidUnreserve
|
Error::<T>::InvalidUnreserve
|
||||||
);
|
);
|
||||||
@@ -727,8 +722,8 @@ pub mod pallet {
|
|||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
ensure!(!Self::invulnerables().contains(&who), Error::<T>::AlreadyInvulnerable);
|
ensure!(!Invulnerables::<T>::get().contains(&who), Error::<T>::AlreadyInvulnerable);
|
||||||
ensure!(deposit >= Self::candidacy_bond(), Error::<T>::InsufficientBond);
|
ensure!(deposit >= CandidacyBond::<T>::get(), Error::<T>::InsufficientBond);
|
||||||
|
|
||||||
let validator_key = T::ValidatorIdOf::convert(who.clone())
|
let validator_key = T::ValidatorIdOf::convert(who.clone())
|
||||||
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
|
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
|
||||||
@@ -737,12 +732,12 @@ pub mod pallet {
|
|||||||
Error::<T>::ValidatorNotRegistered
|
Error::<T>::ValidatorNotRegistered
|
||||||
);
|
);
|
||||||
|
|
||||||
let length = <CandidateList<T>>::decode_len().unwrap_or_default();
|
let length = CandidateList::<T>::decode_len().unwrap_or_default();
|
||||||
// The closure below iterates through all elements of the candidate list to ensure that
|
// The closure below iterates through all elements of the candidate list to ensure that
|
||||||
// the caller isn't already a candidate and to find the target it's trying to replace in
|
// the caller isn't already a candidate and to find the target it's trying to replace in
|
||||||
// the list. The return value is a tuple of the position of the candidate to be replaced
|
// the list. The return value is a tuple of the position of the candidate to be replaced
|
||||||
// in the list along with its candidate information.
|
// in the list along with its candidate information.
|
||||||
let target_info = <CandidateList<T>>::try_mutate(
|
let target_info = CandidateList::<T>::try_mutate(
|
||||||
|candidates| -> Result<CandidateInfo<T::AccountId, BalanceOf<T>>, DispatchError> {
|
|candidates| -> Result<CandidateInfo<T::AccountId, BalanceOf<T>>, DispatchError> {
|
||||||
// Find the position in the list of the candidate that is being replaced.
|
// Find the position in the list of the candidate that is being replaced.
|
||||||
let mut target_info_idx = None;
|
let mut target_info_idx = None;
|
||||||
@@ -787,8 +782,8 @@ pub mod pallet {
|
|||||||
)?;
|
)?;
|
||||||
T::Currency::reserve(&who, deposit)?;
|
T::Currency::reserve(&who, deposit)?;
|
||||||
T::Currency::unreserve(&target_info.who, target_info.deposit);
|
T::Currency::unreserve(&target_info.who, target_info.deposit);
|
||||||
<LastAuthoredBlock<T>>::remove(target_info.who.clone());
|
LastAuthoredBlock::<T>::remove(target_info.who.clone());
|
||||||
<LastAuthoredBlock<T>>::insert(
|
LastAuthoredBlock::<T>::insert(
|
||||||
who.clone(),
|
who.clone(),
|
||||||
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
|
||||||
);
|
);
|
||||||
@@ -807,7 +802,7 @@ pub mod pallet {
|
|||||||
/// Return the total number of accounts that are eligible collators (candidates and
|
/// Return the total number of accounts that are eligible collators (candidates and
|
||||||
/// invulnerables).
|
/// invulnerables).
|
||||||
fn eligible_collators() -> u32 {
|
fn eligible_collators() -> u32 {
|
||||||
<CandidateList<T>>::decode_len()
|
CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.saturating_add(Invulnerables::<T>::decode_len().unwrap_or_default())
|
.saturating_add(Invulnerables::<T>::decode_len().unwrap_or_default())
|
||||||
.try_into()
|
.try_into()
|
||||||
@@ -819,7 +814,7 @@ pub mod pallet {
|
|||||||
who: &T::AccountId,
|
who: &T::AccountId,
|
||||||
remove_last_authored: bool,
|
remove_last_authored: bool,
|
||||||
) -> Result<(), DispatchError> {
|
) -> Result<(), DispatchError> {
|
||||||
<CandidateList<T>>::try_mutate(|candidates| -> Result<(), DispatchError> {
|
CandidateList::<T>::try_mutate(|candidates| -> Result<(), DispatchError> {
|
||||||
let idx = candidates
|
let idx = candidates
|
||||||
.iter()
|
.iter()
|
||||||
.position(|candidate_info| candidate_info.who == *who)
|
.position(|candidate_info| candidate_info.who == *who)
|
||||||
@@ -828,7 +823,7 @@ pub mod pallet {
|
|||||||
T::Currency::unreserve(who, deposit);
|
T::Currency::unreserve(who, deposit);
|
||||||
candidates.remove(idx);
|
candidates.remove(idx);
|
||||||
if remove_last_authored {
|
if remove_last_authored {
|
||||||
<LastAuthoredBlock<T>>::remove(who.clone())
|
LastAuthoredBlock::<T>::remove(who.clone())
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
@@ -841,10 +836,10 @@ pub mod pallet {
|
|||||||
/// This is done on the fly, as frequent as we are told to do so, as the session manager.
|
/// This is done on the fly, as frequent as we are told to do so, as the session manager.
|
||||||
pub fn assemble_collators() -> Vec<T::AccountId> {
|
pub fn assemble_collators() -> Vec<T::AccountId> {
|
||||||
// Casting `u32` to `usize` should be safe on all machines running this.
|
// Casting `u32` to `usize` should be safe on all machines running this.
|
||||||
let desired_candidates = <DesiredCandidates<T>>::get() as usize;
|
let desired_candidates = DesiredCandidates::<T>::get() as usize;
|
||||||
let mut collators = Self::invulnerables().to_vec();
|
let mut collators = Invulnerables::<T>::get().to_vec();
|
||||||
collators.extend(
|
collators.extend(
|
||||||
<CandidateList<T>>::get()
|
CandidateList::<T>::get()
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
.cloned()
|
.cloned()
|
||||||
@@ -865,10 +860,10 @@ pub mod pallet {
|
|||||||
candidates
|
candidates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|c| {
|
.filter_map(|c| {
|
||||||
let last_block = <LastAuthoredBlock<T>>::get(c.clone());
|
let last_block = LastAuthoredBlock::<T>::get(c.clone());
|
||||||
let since_last = now.saturating_sub(last_block);
|
let since_last = now.saturating_sub(last_block);
|
||||||
|
|
||||||
let is_invulnerable = Self::invulnerables().contains(&c);
|
let is_invulnerable = Invulnerables::<T>::get().contains(&c);
|
||||||
let is_lazy = since_last >= kick_threshold;
|
let is_lazy = since_last >= kick_threshold;
|
||||||
|
|
||||||
if is_invulnerable {
|
if is_invulnerable {
|
||||||
@@ -907,7 +902,7 @@ pub mod pallet {
|
|||||||
/// or equal to the minimum number of eligible collators.
|
/// or equal to the minimum number of eligible collators.
|
||||||
#[cfg(any(test, feature = "try-runtime"))]
|
#[cfg(any(test, feature = "try-runtime"))]
|
||||||
pub fn do_try_state() -> Result<(), sp_runtime::TryRuntimeError> {
|
pub fn do_try_state() -> Result<(), sp_runtime::TryRuntimeError> {
|
||||||
let desired_candidates = <DesiredCandidates<T>>::get();
|
let desired_candidates = DesiredCandidates::<T>::get();
|
||||||
|
|
||||||
frame_support::ensure!(
|
frame_support::ensure!(
|
||||||
desired_candidates <= T::MaxCandidates::get(),
|
desired_candidates <= T::MaxCandidates::get(),
|
||||||
@@ -939,7 +934,7 @@ pub mod pallet {
|
|||||||
// `reward` is half of pot account minus ED, this should never fail.
|
// `reward` is half of pot account minus ED, this should never fail.
|
||||||
let _success = T::Currency::transfer(&pot, &author, reward, KeepAlive);
|
let _success = T::Currency::transfer(&pot, &author, reward, KeepAlive);
|
||||||
debug_assert!(_success.is_ok());
|
debug_assert!(_success.is_ok());
|
||||||
<LastAuthoredBlock<T>>::insert(author, frame_system::Pallet::<T>::block_number());
|
LastAuthoredBlock::<T>::insert(author, frame_system::Pallet::<T>::block_number());
|
||||||
|
|
||||||
frame_system::Pallet::<T>::register_extra_weight_unchecked(
|
frame_system::Pallet::<T>::register_extra_weight_unchecked(
|
||||||
T::WeightInfo::note_author(),
|
T::WeightInfo::note_author(),
|
||||||
@@ -960,12 +955,12 @@ pub mod pallet {
|
|||||||
// The `expect` below is safe because the list is a `BoundedVec` with a max size of
|
// The `expect` below is safe because the list is a `BoundedVec` with a max size of
|
||||||
// `T::MaxCandidates`, which is a `u32`. When `decode_len` returns `Some(len)`, `len`
|
// `T::MaxCandidates`, which is a `u32`. When `decode_len` returns `Some(len)`, `len`
|
||||||
// must be valid and at most `u32::MAX`, which must always be able to convert to `u32`.
|
// must be valid and at most `u32::MAX`, which must always be able to convert to `u32`.
|
||||||
let candidates_len_before: u32 = <CandidateList<T>>::decode_len()
|
let candidates_len_before: u32 = CandidateList::<T>::decode_len()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("length is at most `T::MaxCandidates`, so it must fit in `u32`; qed");
|
.expect("length is at most `T::MaxCandidates`, so it must fit in `u32`; qed");
|
||||||
let active_candidates_count = Self::kick_stale_candidates(
|
let active_candidates_count = Self::kick_stale_candidates(
|
||||||
<CandidateList<T>>::get()
|
CandidateList::<T>::get()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|candidate_info| candidate_info.who.clone()),
|
.map(|candidate_info| candidate_info.who.clone()),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub mod v1 {
|
|||||||
let on_chain_version = Pallet::<T>::on_chain_storage_version();
|
let on_chain_version = Pallet::<T>::on_chain_storage_version();
|
||||||
if on_chain_version == 0 {
|
if on_chain_version == 0 {
|
||||||
let invulnerables_len = Invulnerables::<T>::get().to_vec().len();
|
let invulnerables_len = Invulnerables::<T>::get().to_vec().len();
|
||||||
<Invulnerables<T>>::mutate(|invulnerables| {
|
Invulnerables::<T>::mutate(|invulnerables| {
|
||||||
invulnerables.sort();
|
invulnerables.sort();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use crate as collator_selection;
|
use crate as collator_selection;
|
||||||
use crate::{mock::*, CandidateInfo, Error};
|
use crate::{
|
||||||
|
mock::*, CandidacyBond, CandidateInfo, CandidateList, DesiredCandidates, Error, Invulnerables,
|
||||||
|
LastAuthoredBlock,
|
||||||
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
assert_noop, assert_ok,
|
assert_noop, assert_ok,
|
||||||
traits::{Currency, OnInitialize},
|
traits::{Currency, OnInitialize},
|
||||||
@@ -25,12 +28,12 @@ use sp_runtime::{testing::UintAuthorityId, traits::BadOrigin, BuildStorage};
|
|||||||
#[test]
|
#[test]
|
||||||
fn basic_setup_works() {
|
fn basic_setup_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
// genesis should sort input
|
// genesis should sort input
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +46,7 @@ fn it_should_set_invulnerables() {
|
|||||||
new_set.clone()
|
new_set.clone()
|
||||||
));
|
));
|
||||||
new_set.sort();
|
new_set.sort();
|
||||||
assert_eq!(CollatorSelection::invulnerables(), new_set);
|
assert_eq!(Invulnerables::<Test>::get(), new_set);
|
||||||
|
|
||||||
// cannot set with non-root.
|
// cannot set with non-root.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -56,7 +59,7 @@ fn it_should_set_invulnerables() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn it_should_set_invulnerables_even_with_some_invalid() {
|
fn it_should_set_invulnerables_even_with_some_invalid() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
let new_with_invalid = vec![1, 4, 3, 42, 2];
|
let new_with_invalid = vec![1, 4, 3, 42, 2];
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::set_invulnerables(
|
assert_ok!(CollatorSelection::set_invulnerables(
|
||||||
@@ -65,7 +68,7 @@ fn it_should_set_invulnerables_even_with_some_invalid() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// should succeed and order them, but not include 42
|
// should succeed and order them, but not include 42
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3, 4]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +76,7 @@ fn it_should_set_invulnerables_even_with_some_invalid() {
|
|||||||
fn add_invulnerable_works() {
|
fn add_invulnerable_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
initialize_to_block(1);
|
initialize_to_block(1);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
let new = 3;
|
let new = 3;
|
||||||
|
|
||||||
// function runs
|
// function runs
|
||||||
@@ -93,7 +96,7 @@ fn add_invulnerable_works() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// new element is now part of the invulnerables list
|
// new element is now part of the invulnerables list
|
||||||
assert!(CollatorSelection::invulnerables().to_vec().contains(&new));
|
assert!(Invulnerables::<Test>::get().to_vec().contains(&new));
|
||||||
|
|
||||||
// cannot add with non-root
|
// cannot add with non-root
|
||||||
assert_noop!(CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), new), BadOrigin);
|
assert_noop!(CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), new), BadOrigin);
|
||||||
@@ -113,7 +116,7 @@ fn add_invulnerable_works() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn invulnerable_limit_works() {
|
fn invulnerable_limit_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// MaxInvulnerables: u32 = 20
|
// MaxInvulnerables: u32 = 20
|
||||||
for ii in 3..=21 {
|
for ii in 3..=21 {
|
||||||
@@ -140,7 +143,7 @@ fn invulnerable_limit_works() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let expected: Vec<u64> = (1..=20).collect();
|
let expected: Vec<u64> = (1..=20).collect();
|
||||||
assert_eq!(CollatorSelection::invulnerables(), expected);
|
assert_eq!(Invulnerables::<Test>::get(), expected);
|
||||||
|
|
||||||
// Cannot set too many Invulnerables
|
// Cannot set too many Invulnerables
|
||||||
let too_many_invulnerables: Vec<u64> = (1..=21).collect();
|
let too_many_invulnerables: Vec<u64> = (1..=21).collect();
|
||||||
@@ -151,7 +154,7 @@ fn invulnerable_limit_works() {
|
|||||||
),
|
),
|
||||||
Error::<Test>::TooManyInvulnerables
|
Error::<Test>::TooManyInvulnerables
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), expected);
|
assert_eq!(Invulnerables::<Test>::get(), expected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +162,7 @@ fn invulnerable_limit_works() {
|
|||||||
fn remove_invulnerable_works() {
|
fn remove_invulnerable_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
initialize_to_block(1);
|
initialize_to_block(1);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::add_invulnerable(
|
assert_ok!(CollatorSelection::add_invulnerable(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
@@ -170,7 +173,7 @@ fn remove_invulnerable_works() {
|
|||||||
3
|
3
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3, 4]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2, 3, 4]);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::remove_invulnerable(
|
assert_ok!(CollatorSelection::remove_invulnerable(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
@@ -180,7 +183,7 @@ fn remove_invulnerable_works() {
|
|||||||
System::assert_last_event(RuntimeEvent::CollatorSelection(
|
System::assert_last_event(RuntimeEvent::CollatorSelection(
|
||||||
crate::Event::InvulnerableRemoved { account_id: 2 },
|
crate::Event::InvulnerableRemoved { account_id: 2 },
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 3, 4]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 3, 4]);
|
||||||
|
|
||||||
// cannot remove invulnerable not in the list
|
// cannot remove invulnerable not in the list
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -200,11 +203,11 @@ fn remove_invulnerable_works() {
|
|||||||
fn candidate_to_invulnerable_works() {
|
fn candidate_to_invulnerable_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
initialize_to_block(1);
|
initialize_to_block(1);
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
assert_eq!(Balances::free_balance(4), 100);
|
assert_eq!(Balances::free_balance(4), 100);
|
||||||
@@ -225,9 +228,9 @@ fn candidate_to_invulnerable_works() {
|
|||||||
System::assert_has_event(RuntimeEvent::CollatorSelection(
|
System::assert_has_event(RuntimeEvent::CollatorSelection(
|
||||||
crate::Event::InvulnerableAdded { account_id: 3 },
|
crate::Event::InvulnerableAdded { account_id: 3 },
|
||||||
));
|
));
|
||||||
assert!(CollatorSelection::invulnerables().to_vec().contains(&3));
|
assert!(Invulnerables::<Test>::get().to_vec().contains(&3));
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 1);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 1);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::add_invulnerable(
|
assert_ok!(CollatorSelection::add_invulnerable(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
@@ -239,10 +242,10 @@ fn candidate_to_invulnerable_works() {
|
|||||||
System::assert_has_event(RuntimeEvent::CollatorSelection(
|
System::assert_has_event(RuntimeEvent::CollatorSelection(
|
||||||
crate::Event::InvulnerableAdded { account_id: 4 },
|
crate::Event::InvulnerableAdded { account_id: 4 },
|
||||||
));
|
));
|
||||||
assert!(CollatorSelection::invulnerables().to_vec().contains(&4));
|
assert!(Invulnerables::<Test>::get().to_vec().contains(&4));
|
||||||
assert_eq!(Balances::free_balance(4), 100);
|
assert_eq!(Balances::free_balance(4), 100);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,14 +253,14 @@ fn candidate_to_invulnerable_works() {
|
|||||||
fn set_desired_candidates_works() {
|
fn set_desired_candidates_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
|
|
||||||
// can set
|
// can set
|
||||||
assert_ok!(CollatorSelection::set_desired_candidates(
|
assert_ok!(CollatorSelection::set_desired_candidates(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
7
|
7
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 7);
|
assert_eq!(DesiredCandidates::<Test>::get(), 7);
|
||||||
|
|
||||||
// rejects bad origin
|
// rejects bad origin
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -271,16 +274,16 @@ fn set_desired_candidates_works() {
|
|||||||
fn set_candidacy_bond_empty_candidate_list() {
|
fn set_candidacy_bond_empty_candidate_list() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
|
|
||||||
// can decrease without candidates
|
// can decrease without candidates
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
7
|
7
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 7);
|
assert_eq!(CandidacyBond::<Test>::get(), 7);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
|
|
||||||
// rejects bad origin.
|
// rejects bad origin.
|
||||||
assert_noop!(CollatorSelection::set_candidacy_bond(RuntimeOrigin::signed(1), 8), BadOrigin);
|
assert_noop!(CollatorSelection::set_candidacy_bond(RuntimeOrigin::signed(1), 8), BadOrigin);
|
||||||
@@ -290,8 +293,8 @@ fn set_candidacy_bond_empty_candidate_list() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
20
|
20
|
||||||
));
|
));
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 20);
|
assert_eq!(CandidacyBond::<Test>::get(), 20);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,36 +302,36 @@ fn set_candidacy_bond_empty_candidate_list() {
|
|||||||
fn set_candidacy_bond_with_one_candidate() {
|
fn set_candidacy_bond_with_one_candidate() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
|
|
||||||
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get(), vec![candidate_3.clone()]);
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_3.clone()]);
|
||||||
|
|
||||||
// can decrease with one candidate
|
// can decrease with one candidate
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
7
|
7
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 7);
|
assert_eq!(CandidacyBond::<Test>::get(), 7);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get(), vec![candidate_3.clone()]);
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_3.clone()]);
|
||||||
|
|
||||||
// can increase up to initial deposit
|
// can increase up to initial deposit
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
10
|
10
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get(), vec![candidate_3.clone()]);
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_3.clone()]);
|
||||||
|
|
||||||
// can increase past initial deposit, should kick existing candidate
|
// can increase past initial deposit, should kick existing candidate
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
20
|
20
|
||||||
));
|
));
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,8 +339,8 @@ fn set_candidacy_bond_with_one_candidate() {
|
|||||||
fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
|
|
||||||
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 10 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 10 };
|
||||||
@@ -347,7 +350,7 @@ fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
|||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(5)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(5)));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -356,9 +359,9 @@ fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
7
|
7
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 7);
|
assert_eq!(CandidacyBond::<Test>::get(), 7);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -367,9 +370,9 @@ fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
10
|
10
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
vec![candidate_5.clone(), candidate_4.clone(), candidate_3.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -378,7 +381,7 @@ fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
20
|
20
|
||||||
));
|
));
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,8 +389,8 @@ fn set_candidacy_bond_with_many_candidates_same_deposit() {
|
|||||||
fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
|
|
||||||
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 20 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 20 };
|
||||||
@@ -399,7 +402,7 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 30));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 30));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 20));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 20));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -408,9 +411,9 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
7
|
7
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 7);
|
assert_eq!(CandidacyBond::<Test>::get(), 7);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
||||||
);
|
);
|
||||||
// can increase up to initial deposit
|
// can increase up to initial deposit
|
||||||
@@ -418,9 +421,9 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
10
|
10
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -429,27 +432,24 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
20
|
20
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 20);
|
assert_eq!(CandidacyBond::<Test>::get(), 20);
|
||||||
assert_eq!(
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_4.clone(), candidate_5.clone()]);
|
||||||
<crate::CandidateList<Test>>::get(),
|
|
||||||
vec![candidate_4.clone(), candidate_5.clone()]
|
|
||||||
);
|
|
||||||
|
|
||||||
// can increase past 4's deposit, should kick 4
|
// can increase past 4's deposit, should kick 4
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
25
|
25
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 25);
|
assert_eq!(CandidacyBond::<Test>::get(), 25);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get(), vec![candidate_5.clone()]);
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_5.clone()]);
|
||||||
|
|
||||||
// lowering the minimum deposit should have no effect
|
// lowering the minimum deposit should have no effect
|
||||||
assert_ok!(CollatorSelection::set_candidacy_bond(
|
assert_ok!(CollatorSelection::set_candidacy_bond(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
5
|
5
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 5);
|
assert_eq!(CandidacyBond::<Test>::get(), 5);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get(), vec![candidate_5.clone()]);
|
assert_eq!(CandidateList::<Test>::get(), vec![candidate_5.clone()]);
|
||||||
|
|
||||||
// add 3 and 4 back but with higher deposits than minimum
|
// add 3 and 4 back but with higher deposits than minimum
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
@@ -457,7 +457,7 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 10));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 10));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 20));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 20));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get(),
|
CandidateList::<Test>::get(),
|
||||||
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
vec![candidate_3.clone(), candidate_4.clone(), candidate_5.clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -467,8 +467,8 @@ fn set_candidacy_bond_with_many_candidates_different_deposits() {
|
|||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
40
|
40
|
||||||
));
|
));
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 40);
|
assert_eq!(CandidacyBond::<Test>::get(), 40);
|
||||||
assert!(<crate::CandidateList<Test>>::get().is_empty());
|
assert!(CandidateList::<Test>::get().is_empty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,8 +500,8 @@ fn cannot_register_candidate_if_too_many() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn cannot_unregister_candidate_if_too_few() {
|
fn cannot_unregister_candidate_if_too_few() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
assert_ok!(CollatorSelection::remove_invulnerable(
|
assert_ok!(CollatorSelection::remove_invulnerable(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
1
|
1
|
||||||
@@ -532,7 +532,7 @@ fn cannot_unregister_candidate_if_too_few() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn cannot_register_as_candidate_if_invulnerable() {
|
fn cannot_register_as_candidate_if_invulnerable() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// can't 1 because it is invulnerable.
|
// can't 1 because it is invulnerable.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -561,10 +561,10 @@ fn cannot_register_dupe_candidate() {
|
|||||||
// tuple of (id, deposit).
|
// tuple of (id, deposit).
|
||||||
let addition = CandidateInfo { who: 3, deposit: 10 };
|
let addition = CandidateInfo { who: 3, deposit: 10 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![addition]
|
vec![addition]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(3), 10);
|
assert_eq!(LastAuthoredBlock::<Test>::get(3), 10);
|
||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
|
|
||||||
// but no more
|
// but no more
|
||||||
@@ -596,11 +596,11 @@ fn cannot_register_as_candidate_if_poor() {
|
|||||||
fn register_as_candidate_works() {
|
fn register_as_candidate_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take two endowed, non-invulnerables accounts.
|
// take two endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -612,14 +612,14 @@ fn register_as_candidate_works() {
|
|||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
assert_eq!(Balances::free_balance(4), 90);
|
assert_eq!(Balances::free_balance(4), 90);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 2);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cannot_take_candidate_slot_if_invulnerable() {
|
fn cannot_take_candidate_slot_if_invulnerable() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// can't 1 because it is invulnerable.
|
// can't 1 because it is invulnerable.
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
@@ -649,11 +649,10 @@ fn cannot_take_candidate_slot_if_duplicate() {
|
|||||||
// tuple of (id, deposit).
|
// tuple of (id, deposit).
|
||||||
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 10 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 10 };
|
||||||
let actual_candidates =
|
let actual_candidates = CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>();
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>();
|
|
||||||
assert_eq!(actual_candidates, vec![candidate_4, candidate_3]);
|
assert_eq!(actual_candidates, vec![candidate_4, candidate_3]);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(3), 10);
|
assert_eq!(LastAuthoredBlock::<Test>::get(3), 10);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(4), 10);
|
assert_eq!(LastAuthoredBlock::<Test>::get(4), 10);
|
||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
|
|
||||||
// but no more
|
// but no more
|
||||||
@@ -672,10 +671,10 @@ fn cannot_take_candidate_slot_if_target_invalid() {
|
|||||||
// tuple of (id, deposit).
|
// tuple of (id, deposit).
|
||||||
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
let candidate_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![candidate_3]
|
vec![candidate_3]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(3), 10);
|
assert_eq!(LastAuthoredBlock::<Test>::get(3), 10);
|
||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
assert_eq!(Balances::free_balance(4), 100);
|
assert_eq!(Balances::free_balance(4), 100);
|
||||||
|
|
||||||
@@ -744,11 +743,11 @@ fn cannot_take_candidate_slot_if_deposit_less_than_target() {
|
|||||||
fn take_candidate_slot_works() {
|
fn take_candidate_slot_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take two endowed, non-invulnerables accounts.
|
// take two endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -763,7 +762,7 @@ fn take_candidate_slot_works() {
|
|||||||
assert_eq!(Balances::free_balance(4), 90);
|
assert_eq!(Balances::free_balance(4), 90);
|
||||||
assert_eq!(Balances::free_balance(5), 90);
|
assert_eq!(Balances::free_balance(5), 90);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
Balances::make_free_balance_be(&6, 100);
|
Balances::make_free_balance_be(&6, 100);
|
||||||
let key = MockSessionKeys { aura: UintAuthorityId(6) };
|
let key = MockSessionKeys { aura: UintAuthorityId(6) };
|
||||||
@@ -785,10 +784,10 @@ fn take_candidate_slot_works() {
|
|||||||
let candidate_6 = CandidateInfo { who: 6, deposit: 50 };
|
let candidate_6 = CandidateInfo { who: 6, deposit: 50 };
|
||||||
let candidate_5 = CandidateInfo { who: 5, deposit: 10 };
|
let candidate_5 = CandidateInfo { who: 5, deposit: 10 };
|
||||||
let mut actual_candidates =
|
let mut actual_candidates =
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>();
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>();
|
||||||
actual_candidates.sort_by(|info_1, info_2| info_1.deposit.cmp(&info_2.deposit));
|
actual_candidates.sort_by(|info_1, info_2| info_1.deposit.cmp(&info_2.deposit));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![candidate_5, candidate_3, candidate_6]
|
vec![candidate_5, candidate_3, candidate_6]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -798,11 +797,11 @@ fn take_candidate_slot_works() {
|
|||||||
fn increase_candidacy_bond_non_candidate_account() {
|
fn increase_candidacy_bond_non_candidate_account() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
@@ -818,11 +817,11 @@ fn increase_candidacy_bond_non_candidate_account() {
|
|||||||
fn increase_candidacy_bond_insufficient_balance() {
|
fn increase_candidacy_bond_insufficient_balance() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take two endowed, non-invulnerables accounts.
|
// take two endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -850,11 +849,11 @@ fn increase_candidacy_bond_insufficient_balance() {
|
|||||||
fn increase_candidacy_bond_works() {
|
fn increase_candidacy_bond_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take three endowed, non-invulnerables accounts.
|
// take three endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -873,7 +872,7 @@ fn increase_candidacy_bond_works() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
assert_eq!(Balances::free_balance(3), 80);
|
assert_eq!(Balances::free_balance(3), 80);
|
||||||
assert_eq!(Balances::free_balance(4), 70);
|
assert_eq!(Balances::free_balance(4), 70);
|
||||||
assert_eq!(Balances::free_balance(5), 60);
|
assert_eq!(Balances::free_balance(5), 60);
|
||||||
@@ -881,7 +880,7 @@ fn increase_candidacy_bond_works() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 40));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 40));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 60));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 60));
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
assert_eq!(Balances::free_balance(3), 60);
|
assert_eq!(Balances::free_balance(3), 60);
|
||||||
assert_eq!(Balances::free_balance(4), 40);
|
assert_eq!(Balances::free_balance(4), 40);
|
||||||
assert_eq!(Balances::free_balance(5), 60);
|
assert_eq!(Balances::free_balance(5), 60);
|
||||||
@@ -892,11 +891,11 @@ fn increase_candidacy_bond_works() {
|
|||||||
fn decrease_candidacy_bond_non_candidate_account() {
|
fn decrease_candidacy_bond_non_candidate_account() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
@@ -914,11 +913,11 @@ fn decrease_candidacy_bond_non_candidate_account() {
|
|||||||
fn decrease_candidacy_bond_insufficient_funds() {
|
fn decrease_candidacy_bond_insufficient_funds() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take two endowed, non-invulnerables accounts.
|
// take two endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -961,7 +960,7 @@ fn decrease_candidacy_bond_insufficient_funds() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn decrease_candidacy_bond_occupying_top_slot() {
|
fn decrease_candidacy_bond_occupying_top_slot() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
// Register 3 candidates.
|
// Register 3 candidates.
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
@@ -976,7 +975,7 @@ fn decrease_candidacy_bond_occupying_top_slot() {
|
|||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 30 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 30 };
|
||||||
let candidate_5 = CandidateInfo { who: 5, deposit: 60 };
|
let candidate_5 = CandidateInfo { who: 5, deposit: 60 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![candidate_4, candidate_3, candidate_5]
|
vec![candidate_4, candidate_3, candidate_5]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1000,7 +999,7 @@ fn decrease_candidacy_bond_occupying_top_slot() {
|
|||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 35 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 35 };
|
||||||
let candidate_5 = CandidateInfo { who: 5, deposit: 60 };
|
let candidate_5 = CandidateInfo { who: 5, deposit: 60 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![candidate_3, candidate_4, candidate_5]
|
vec![candidate_3, candidate_4, candidate_5]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1023,11 +1022,11 @@ fn decrease_candidacy_bond_occupying_top_slot() {
|
|||||||
fn decrease_candidacy_bond_works() {
|
fn decrease_candidacy_bond_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take three endowed, non-invulnerables accounts.
|
// take three endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -1046,14 +1045,14 @@ fn decrease_candidacy_bond_works() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
assert_eq!(Balances::free_balance(3), 80);
|
assert_eq!(Balances::free_balance(3), 80);
|
||||||
assert_eq!(Balances::free_balance(4), 70);
|
assert_eq!(Balances::free_balance(4), 70);
|
||||||
assert_eq!(Balances::free_balance(5), 60);
|
assert_eq!(Balances::free_balance(5), 60);
|
||||||
|
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 10));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(3), 10));
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
assert_eq!(Balances::free_balance(4), 70);
|
assert_eq!(Balances::free_balance(4), 70);
|
||||||
assert_eq!(Balances::free_balance(5), 60);
|
assert_eq!(Balances::free_balance(5), 60);
|
||||||
@@ -1064,11 +1063,11 @@ fn decrease_candidacy_bond_works() {
|
|||||||
fn update_candidacy_bond_with_identical_amount() {
|
fn update_candidacy_bond_with_identical_amount() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take three endowed, non-invulnerables accounts.
|
// take three endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -1087,7 +1086,7 @@ fn update_candidacy_bond_with_identical_amount() {
|
|||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(4), 30));
|
||||||
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
assert_ok!(CollatorSelection::update_bond(RuntimeOrigin::signed(5), 40));
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
assert_eq!(Balances::free_balance(3), 80);
|
assert_eq!(Balances::free_balance(3), 80);
|
||||||
assert_eq!(Balances::free_balance(4), 70);
|
assert_eq!(Balances::free_balance(4), 70);
|
||||||
assert_eq!(Balances::free_balance(5), 60);
|
assert_eq!(Balances::free_balance(5), 60);
|
||||||
@@ -1104,11 +1103,11 @@ fn update_candidacy_bond_with_identical_amount() {
|
|||||||
fn candidate_list_works() {
|
fn candidate_list_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// given
|
// given
|
||||||
assert_eq!(CollatorSelection::desired_candidates(), 2);
|
assert_eq!(DesiredCandidates::<Test>::get(), 2);
|
||||||
assert_eq!(CollatorSelection::candidacy_bond(), 10);
|
assert_eq!(CandidacyBond::<Test>::get(), 10);
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
|
|
||||||
// take three endowed, non-invulnerables accounts.
|
// take three endowed, non-invulnerables accounts.
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
@@ -1131,7 +1130,7 @@ fn candidate_list_works() {
|
|||||||
let candidate_4 = CandidateInfo { who: 4, deposit: 25 };
|
let candidate_4 = CandidateInfo { who: 4, deposit: 25 };
|
||||||
let candidate_5 = CandidateInfo { who: 5, deposit: 10 };
|
let candidate_5 = CandidateInfo { who: 5, deposit: 10 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![candidate_5, candidate_4, candidate_3]
|
vec![candidate_5, candidate_4, candidate_3]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1157,7 +1156,7 @@ fn leave_intent() {
|
|||||||
// bond is returned
|
// bond is returned
|
||||||
assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3)));
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(3), 0);
|
assert_eq!(LastAuthoredBlock::<Test>::get(3), 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1177,10 +1176,10 @@ fn authorship_event_handler() {
|
|||||||
let collator = CandidateInfo { who: 4, deposit: 10 };
|
let collator = CandidateInfo { who: 4, deposit: 10 };
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![collator]
|
vec![collator]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(4), 0);
|
assert_eq!(LastAuthoredBlock::<Test>::get(4), 0);
|
||||||
|
|
||||||
// half of the pot goes to the collator who's the author (4 in tests).
|
// half of the pot goes to the collator who's the author (4 in tests).
|
||||||
assert_eq!(Balances::free_balance(4), 140);
|
assert_eq!(Balances::free_balance(4), 140);
|
||||||
@@ -1206,10 +1205,10 @@ fn fees_edgecases() {
|
|||||||
let collator = CandidateInfo { who: 4, deposit: 10 };
|
let collator = CandidateInfo { who: 4, deposit: 10 };
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![collator]
|
vec![collator]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(4), 0);
|
assert_eq!(LastAuthoredBlock::<Test>::get(4), 0);
|
||||||
// Nothing received
|
// Nothing received
|
||||||
assert_eq!(Balances::free_balance(4), 90);
|
assert_eq!(Balances::free_balance(4), 90);
|
||||||
// all fee stays
|
// all fee stays
|
||||||
@@ -1236,7 +1235,7 @@ fn session_management_single_candidate() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 1);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 1);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1274,7 +1273,7 @@ fn session_management_max_candidates() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1313,7 +1312,7 @@ fn session_management_increase_bid_with_list_update() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1352,7 +1351,7 @@ fn session_management_candidate_list_eager_sort() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1399,7 +1398,7 @@ fn session_management_reciprocal_outbidding() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1451,7 +1450,7 @@ fn session_management_decrease_bid_after_auction() {
|
|||||||
// session won't see this.
|
// session won't see this.
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2]);
|
||||||
// but we have a new candidate.
|
// but we have a new candidate.
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 3);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 3);
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(SessionChangeBlock::get(), 10);
|
assert_eq!(SessionChangeBlock::get(), 10);
|
||||||
@@ -1476,20 +1475,20 @@ fn kick_mechanism() {
|
|||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 2);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 2);
|
||||||
initialize_to_block(20);
|
initialize_to_block(20);
|
||||||
assert_eq!(SessionChangeBlock::get(), 20);
|
assert_eq!(SessionChangeBlock::get(), 20);
|
||||||
// 4 authored this block, gets to stay 3 was kicked
|
// 4 authored this block, gets to stay 3 was kicked
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 1);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 1);
|
||||||
// 3 will be kicked after 1 session delay
|
// 3 will be kicked after 1 session delay
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]);
|
||||||
// tuple of (id, deposit).
|
// tuple of (id, deposit).
|
||||||
let collator = CandidateInfo { who: 4, deposit: 10 };
|
let collator = CandidateInfo { who: 4, deposit: 10 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![collator]
|
vec![collator]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(4), 20);
|
assert_eq!(LastAuthoredBlock::<Test>::get(4), 20);
|
||||||
initialize_to_block(30);
|
initialize_to_block(30);
|
||||||
// 3 gets kicked after 1 session delay
|
// 3 gets kicked after 1 session delay
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 4]);
|
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 4]);
|
||||||
@@ -1503,8 +1502,8 @@ fn should_not_kick_mechanism_too_few() {
|
|||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// remove the invulnerables and add new collators 3 and 5
|
// remove the invulnerables and add new collators 3 and 5
|
||||||
|
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2]);
|
||||||
assert_ok!(CollatorSelection::remove_invulnerable(
|
assert_ok!(CollatorSelection::remove_invulnerable(
|
||||||
RuntimeOrigin::signed(RootAccount::get()),
|
RuntimeOrigin::signed(RootAccount::get()),
|
||||||
1
|
1
|
||||||
@@ -1517,21 +1516,21 @@ fn should_not_kick_mechanism_too_few() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 2);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 2);
|
||||||
|
|
||||||
initialize_to_block(20);
|
initialize_to_block(20);
|
||||||
assert_eq!(SessionChangeBlock::get(), 20);
|
assert_eq!(SessionChangeBlock::get(), 20);
|
||||||
// 4 authored this block, 3 is kicked, 5 stays because of too few collators
|
// 4 authored this block, 3 is kicked, 5 stays because of too few collators
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 1);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 1);
|
||||||
// 3 will be kicked after 1 session delay
|
// 3 will be kicked after 1 session delay
|
||||||
assert_eq!(SessionHandlerCollators::get(), vec![3, 5]);
|
assert_eq!(SessionHandlerCollators::get(), vec![3, 5]);
|
||||||
// tuple of (id, deposit).
|
// tuple of (id, deposit).
|
||||||
let collator = CandidateInfo { who: 3, deposit: 10 };
|
let collator = CandidateInfo { who: 3, deposit: 10 };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![collator]
|
vec![collator]
|
||||||
);
|
);
|
||||||
assert_eq!(CollatorSelection::last_authored_block(4), 20);
|
assert_eq!(LastAuthoredBlock::<Test>::get(4), 20);
|
||||||
|
|
||||||
initialize_to_block(30);
|
initialize_to_block(30);
|
||||||
// 3 gets kicked after 1 session delay
|
// 3 gets kicked after 1 session delay
|
||||||
@@ -1544,7 +1543,7 @@ fn should_not_kick_mechanism_too_few() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn should_kick_invulnerables_from_candidates_on_session_change() {
|
fn should_kick_invulnerables_from_candidates_on_session_change() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(<crate::CandidateList<Test>>::get().iter().count(), 0);
|
assert_eq!(CandidateList::<Test>::get().iter().count(), 0);
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||||
assert_eq!(Balances::free_balance(3), 90);
|
assert_eq!(Balances::free_balance(3), 90);
|
||||||
@@ -1558,20 +1557,19 @@ fn should_kick_invulnerables_from_candidates_on_session_change() {
|
|||||||
let collator_3 = CandidateInfo { who: 3, deposit: 10 };
|
let collator_3 = CandidateInfo { who: 3, deposit: 10 };
|
||||||
let collator_4 = CandidateInfo { who: 4, deposit: 10 };
|
let collator_4 = CandidateInfo { who: 4, deposit: 10 };
|
||||||
|
|
||||||
let actual_candidates =
|
let actual_candidates = CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>();
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>();
|
|
||||||
assert_eq!(actual_candidates, vec![collator_4.clone(), collator_3]);
|
assert_eq!(actual_candidates, vec![collator_4.clone(), collator_3]);
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2, 3]);
|
||||||
|
|
||||||
// session change
|
// session change
|
||||||
initialize_to_block(10);
|
initialize_to_block(10);
|
||||||
// 3 is removed from candidates
|
// 3 is removed from candidates
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<crate::CandidateList<Test>>::get().iter().cloned().collect::<Vec<_>>(),
|
CandidateList::<Test>::get().iter().cloned().collect::<Vec<_>>(),
|
||||||
vec![collator_4]
|
vec![collator_4]
|
||||||
);
|
);
|
||||||
// but not from invulnerables
|
// but not from invulnerables
|
||||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3]);
|
assert_eq!(Invulnerables::<Test>::get(), vec![1, 2, 3]);
|
||||||
// and it got its deposit back
|
// and it got its deposit back
|
||||||
assert_eq!(Balances::free_balance(3), 100);
|
assert_eq!(Balances::free_balance(3), 100);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
LastRelayChainBlockNumber::<T>::put(vfp.relay_parent_number);
|
LastRelayChainBlockNumber::<T>::put(vfp.relay_parent_number);
|
||||||
|
|
||||||
let host_config = match Self::host_configuration() {
|
let host_config = match HostConfiguration::<T>::get() {
|
||||||
Some(ok) => ok,
|
Some(ok) => ok,
|
||||||
None => {
|
None => {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
@@ -281,7 +281,7 @@ pub mod pallet {
|
|||||||
// Before updating the relevant messaging state, we need to extract
|
// Before updating the relevant messaging state, we need to extract
|
||||||
// the total bandwidth limits for the purpose of updating the unincluded
|
// the total bandwidth limits for the purpose of updating the unincluded
|
||||||
// segment.
|
// segment.
|
||||||
let total_bandwidth_out = match Self::relevant_messaging_state() {
|
let total_bandwidth_out = match RelevantMessagingState::<T>::get() {
|
||||||
Some(s) => OutboundBandwidthLimits::from_relay_chain_state(&s),
|
Some(s) => OutboundBandwidthLimits::from_relay_chain_state(&s),
|
||||||
None => {
|
None => {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
@@ -298,7 +298,8 @@ pub mod pallet {
|
|||||||
Self::adjust_egress_bandwidth_limits();
|
Self::adjust_egress_bandwidth_limits();
|
||||||
|
|
||||||
let (ump_msg_count, ump_total_bytes) = <PendingUpwardMessages<T>>::mutate(|up| {
|
let (ump_msg_count, ump_total_bytes) = <PendingUpwardMessages<T>>::mutate(|up| {
|
||||||
let (available_capacity, available_size) = match Self::relevant_messaging_state() {
|
let (available_capacity, available_size) = match RelevantMessagingState::<T>::get()
|
||||||
|
{
|
||||||
Some(limits) => (
|
Some(limits) => (
|
||||||
limits.relay_dispatch_queue_remaining_capacity.remaining_count,
|
limits.relay_dispatch_queue_remaining_capacity.remaining_count,
|
||||||
limits.relay_dispatch_queue_remaining_capacity.remaining_size,
|
limits.relay_dispatch_queue_remaining_capacity.remaining_size,
|
||||||
@@ -476,7 +477,7 @@ pub mod pallet {
|
|||||||
// than the announced, we would waste some of weight. In the case the actual value is
|
// than the announced, we would waste some of weight. In the case the actual value is
|
||||||
// greater than the announced, we will miss opportunity to send a couple of messages.
|
// greater than the announced, we will miss opportunity to send a couple of messages.
|
||||||
weight += T::DbWeight::get().reads_writes(1, 1);
|
weight += T::DbWeight::get().reads_writes(1, 1);
|
||||||
let hrmp_max_message_num_per_candidate = Self::host_configuration()
|
let hrmp_max_message_num_per_candidate = HostConfiguration::<T>::get()
|
||||||
.map(|cfg| cfg.hrmp_max_message_num_per_candidate)
|
.map(|cfg| cfg.hrmp_max_message_num_per_candidate)
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
<AnnouncedHrmpMessagesPerCandidate<T>>::put(hrmp_max_message_num_per_candidate);
|
<AnnouncedHrmpMessagesPerCandidate<T>>::put(hrmp_max_message_num_per_candidate);
|
||||||
@@ -764,7 +765,6 @@ pub mod pallet {
|
|||||||
/// [`:code`][sp_core::storage::well_known_keys::CODE] which will result the next block process
|
/// [`:code`][sp_core::storage::well_known_keys::CODE] which will result the next block process
|
||||||
/// with the new validation code. This concludes the upgrade process.
|
/// with the new validation code. This concludes the upgrade process.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn new_validation_function)]
|
|
||||||
pub(super) type PendingValidationCode<T: Config> = StorageValue<_, Vec<u8>, ValueQuery>;
|
pub(super) type PendingValidationCode<T: Config> = StorageValue<_, Vec<u8>, ValueQuery>;
|
||||||
|
|
||||||
/// Validation code that is set by the parachain and is to be communicated to collator and
|
/// Validation code that is set by the parachain and is to be communicated to collator and
|
||||||
@@ -779,7 +779,6 @@ pub mod pallet {
|
|||||||
/// This value is expected to be set only once per block and it's never stored
|
/// This value is expected to be set only once per block and it's never stored
|
||||||
/// in the trie.
|
/// in the trie.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn validation_data)]
|
|
||||||
pub(super) type ValidationData<T: Config> = StorageValue<_, PersistedValidationData>;
|
pub(super) type ValidationData<T: Config> = StorageValue<_, PersistedValidationData>;
|
||||||
|
|
||||||
/// Were the validation data set to notify the relay chain?
|
/// Were the validation data set to notify the relay chain?
|
||||||
@@ -820,7 +819,6 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// This data is also absent from the genesis.
|
/// This data is also absent from the genesis.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn relay_state_proof)]
|
|
||||||
pub(super) type RelayStateProof<T: Config> = StorageValue<_, sp_trie::StorageProof>;
|
pub(super) type RelayStateProof<T: Config> = StorageValue<_, sp_trie::StorageProof>;
|
||||||
|
|
||||||
/// The snapshot of some state related to messaging relevant to the current parachain as per
|
/// The snapshot of some state related to messaging relevant to the current parachain as per
|
||||||
@@ -831,7 +829,6 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// This data is also absent from the genesis.
|
/// This data is also absent from the genesis.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn relevant_messaging_state)]
|
|
||||||
pub(super) type RelevantMessagingState<T: Config> = StorageValue<_, MessagingStateSnapshot>;
|
pub(super) type RelevantMessagingState<T: Config> = StorageValue<_, MessagingStateSnapshot>;
|
||||||
|
|
||||||
/// The parachain host configuration that was obtained from the relay parent.
|
/// The parachain host configuration that was obtained from the relay parent.
|
||||||
@@ -842,7 +839,6 @@ pub mod pallet {
|
|||||||
/// This data is also absent from the genesis.
|
/// This data is also absent from the genesis.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::disable_try_decode_storage]
|
#[pallet::disable_try_decode_storage]
|
||||||
#[pallet::getter(fn host_configuration)]
|
|
||||||
pub(super) type HostConfiguration<T: Config> = StorageValue<_, AbridgedHostConfiguration>;
|
pub(super) type HostConfiguration<T: Config> = StorageValue<_, AbridgedHostConfiguration>;
|
||||||
|
|
||||||
/// The last downward message queue chain head we have observed.
|
/// The last downward message queue chain head we have observed.
|
||||||
@@ -1041,7 +1037,7 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
|
|||||||
//
|
//
|
||||||
// Here it a similar case, with the difference that the realization that the channel is
|
// Here it a similar case, with the difference that the realization that the channel is
|
||||||
// closed came the same block.
|
// closed came the same block.
|
||||||
let channels = match Self::relevant_messaging_state() {
|
let channels = match RelevantMessagingState::<T>::get() {
|
||||||
None => {
|
None => {
|
||||||
log::warn!("calling `get_channel_status` with no RelevantMessagingState?!");
|
log::warn!("calling `get_channel_status` with no RelevantMessagingState?!");
|
||||||
return ChannelStatus::Closed
|
return ChannelStatus::Closed
|
||||||
@@ -1069,7 +1065,7 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_channel_info(id: ParaId) -> Option<ChannelInfo> {
|
fn get_channel_info(id: ParaId) -> Option<ChannelInfo> {
|
||||||
let channels = Self::relevant_messaging_state()?.egress_channels;
|
let channels = RelevantMessagingState::<T>::get()?.egress_channels;
|
||||||
let index = channels.binary_search_by_key(&id, |item| item.0).ok()?;
|
let index = channels.binary_search_by_key(&id, |item| item.0).ok()?;
|
||||||
let info = ChannelInfo {
|
let info = ChannelInfo {
|
||||||
max_capacity: channels[index].1.max_capacity,
|
max_capacity: channels[index].1.max_capacity,
|
||||||
@@ -1406,7 +1402,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
ensure!(<UpgradeRestrictionSignal<T>>::get().is_none(), Error::<T>::ProhibitedByPolkadot);
|
ensure!(<UpgradeRestrictionSignal<T>>::get().is_none(), Error::<T>::ProhibitedByPolkadot);
|
||||||
|
|
||||||
ensure!(!<PendingValidationCode<T>>::exists(), Error::<T>::OverlappingUpgrades);
|
ensure!(!<PendingValidationCode<T>>::exists(), Error::<T>::OverlappingUpgrades);
|
||||||
let cfg = Self::host_configuration().ok_or(Error::<T>::HostConfigurationNotAvailable)?;
|
let cfg = HostConfiguration::<T>::get().ok_or(Error::<T>::HostConfigurationNotAvailable)?;
|
||||||
ensure!(validation_function.len() <= cfg.max_code_size as usize, Error::<T>::TooBig);
|
ensure!(validation_function.len() <= cfg.max_code_size as usize, Error::<T>::TooBig);
|
||||||
|
|
||||||
// When a code upgrade is scheduled, it has to be applied in two
|
// When a code upgrade is scheduled, it has to be applied in two
|
||||||
@@ -1562,7 +1558,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
// may change so that the message is no longer valid.
|
// may change so that the message is no longer valid.
|
||||||
//
|
//
|
||||||
// However, changing this setting is expected to be rare.
|
// However, changing this setting is expected to be rare.
|
||||||
if let Some(cfg) = Self::host_configuration() {
|
if let Some(cfg) = HostConfiguration::<T>::get() {
|
||||||
if message_len > cfg.max_upward_message_size as usize {
|
if message_len > cfg.max_upward_message_size as usize {
|
||||||
return Err(MessageSendError::TooBig)
|
return Err(MessageSendError::TooBig)
|
||||||
}
|
}
|
||||||
@@ -1718,14 +1714,14 @@ impl<T: Config> BlockNumberProvider for RelaychainDataProvider<T> {
|
|||||||
type BlockNumber = relay_chain::BlockNumber;
|
type BlockNumber = relay_chain::BlockNumber;
|
||||||
|
|
||||||
fn current_block_number() -> relay_chain::BlockNumber {
|
fn current_block_number() -> relay_chain::BlockNumber {
|
||||||
Pallet::<T>::validation_data()
|
ValidationData::<T>::get()
|
||||||
.map(|d| d.relay_parent_number)
|
.map(|d| d.relay_parent_number)
|
||||||
.unwrap_or_else(|| Pallet::<T>::last_relay_block_number())
|
.unwrap_or_else(|| Pallet::<T>::last_relay_block_number())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
fn set_block_number(block: Self::BlockNumber) {
|
fn set_block_number(block: Self::BlockNumber) {
|
||||||
let mut validation_data = Pallet::<T>::validation_data().unwrap_or_else(||
|
let mut validation_data = ValidationData::<T>::get().unwrap_or_else(||
|
||||||
// PersistedValidationData does not impl default in non-std
|
// PersistedValidationData does not impl default in non-std
|
||||||
PersistedValidationData {
|
PersistedValidationData {
|
||||||
parent_head: vec![].into(),
|
parent_head: vec![].into(),
|
||||||
@@ -1740,7 +1736,7 @@ impl<T: Config> BlockNumberProvider for RelaychainDataProvider<T> {
|
|||||||
|
|
||||||
impl<T: Config> RelaychainStateProvider for RelaychainDataProvider<T> {
|
impl<T: Config> RelaychainStateProvider for RelaychainDataProvider<T> {
|
||||||
fn current_relay_chain_state() -> RelayChainState {
|
fn current_relay_chain_state() -> RelayChainState {
|
||||||
Pallet::<T>::validation_data()
|
ValidationData::<T>::get()
|
||||||
.map(|d| RelayChainState {
|
.map(|d| RelayChainState {
|
||||||
number: d.relay_parent_number,
|
number: d.relay_parent_number,
|
||||||
state_root: d.relay_parent_storage_root,
|
state_root: d.relay_parent_storage_root,
|
||||||
@@ -1750,7 +1746,7 @@ impl<T: Config> RelaychainStateProvider for RelaychainDataProvider<T> {
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
fn set_current_relay_chain_state(state: RelayChainState) {
|
fn set_current_relay_chain_state(state: RelayChainState) {
|
||||||
let mut validation_data = Pallet::<T>::validation_data().unwrap_or_else(||
|
let mut validation_data = ValidationData::<T>::get().unwrap_or_else(||
|
||||||
// PersistedValidationData does not impl default in non-std
|
// PersistedValidationData does not impl default in non-std
|
||||||
PersistedValidationData {
|
PersistedValidationData {
|
||||||
parent_head: vec![].into(),
|
parent_head: vec![].into(),
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ pub mod pallet {
|
|||||||
#[pallet::genesis_build]
|
#[pallet::genesis_build]
|
||||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||||
fn build(&self) {
|
fn build(&self) {
|
||||||
<ParachainId<T>>::put(self.parachain_id);
|
ParachainId::<T>::put(self.parachain_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,13 +64,18 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn parachain_id)]
|
|
||||||
pub(super) type ParachainId<T: Config> =
|
pub(super) type ParachainId<T: Config> =
|
||||||
StorageValue<_, ParaId, ValueQuery, DefaultForParachainId>;
|
StorageValue<_, ParaId, ValueQuery, DefaultForParachainId>;
|
||||||
|
|
||||||
impl<T: Config> Get<ParaId> for Pallet<T> {
|
impl<T: Config> Get<ParaId> for Pallet<T> {
|
||||||
fn get() -> ParaId {
|
fn get() -> ParaId {
|
||||||
Self::parachain_id()
|
ParachainId::<T>::get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Config> Pallet<T> {
|
||||||
|
pub fn parachain_id() -> ParaId {
|
||||||
|
ParachainId::<T>::get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
|
||||||
|
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
|
||||||
|
|
||||||
|
title: removed `pallet::getter` from cumulus pallets
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Runtime Dev
|
||||||
|
description: |
|
||||||
|
This PR removes all the `pallet::getter` usages from cumulus pallets, and updates depdendant runtimes accordingly.
|
||||||
|
The ParaId can be retrieved using `<ParachainInfo as Get<ParaId>>::get()`.
|
||||||
|
For other storage items, the syntax `StorageItem::<T, I>::get()` should be used instead.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: cumulus-pallet-aura-ext
|
||||||
|
- name: pallet-collator-selection
|
||||||
|
- name: cumulus-pallet-parachain-system
|
||||||
|
- name: staging-parachain-info
|
||||||
|
- name: parachain-template-runtime
|
||||||
|
- name: asset-hub-rococo-runtime
|
||||||
|
- name: asset-hub-westend-runtime
|
||||||
|
- name: bridge-hub-rococo-runtime
|
||||||
|
- name: bridge-hub-westend-runtime
|
||||||
|
- name: collectives-westend-runtime
|
||||||
|
- name: contracts-rococo-runtime
|
||||||
|
- name: coretime-rococo-runtime
|
||||||
|
- name: coretime-westend-runtime
|
||||||
|
- name: glutton-westend-runtime
|
||||||
|
- name: people-rococo-runtime
|
||||||
|
- name: people-westend-runtime
|
||||||
|
- name: shell-runtime
|
||||||
|
- name: penpal-runtime
|
||||||
|
- name: rococo-parachain-runtime
|
||||||
|
|
||||||
Reference in New Issue
Block a user