mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-23 13:05:41 +00:00
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
This commit is contained in:
@@ -368,7 +368,7 @@ pub mod pallet {
|
||||
|
||||
let current_count =
|
||||
<Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
|
||||
if candidates.into_iter().any(|candidate| candidate.who == who) {
|
||||
if candidates.iter().any(|candidate| candidate.who == who) {
|
||||
Err(Error::<T>::AlreadyCandidate)?
|
||||
} else {
|
||||
T::Currency::reserve(&who, deposit)?;
|
||||
@@ -409,6 +409,7 @@ pub mod pallet {
|
||||
pub fn account_id() -> T::AccountId {
|
||||
T::PotId::get().into_account()
|
||||
}
|
||||
|
||||
/// Removes a candidate if they exist and sends them back their deposit
|
||||
fn try_remove_candidate(who: &T::AccountId) -> Result<usize, DispatchError> {
|
||||
let current_count =
|
||||
@@ -417,8 +418,8 @@ pub mod pallet {
|
||||
.iter()
|
||||
.position(|candidate| candidate.who == *who)
|
||||
.ok_or(Error::<T>::NotCandidate)?;
|
||||
T::Currency::unreserve(&who, candidates[index].deposit);
|
||||
candidates.remove(index);
|
||||
let candidate = candidates.remove(index);
|
||||
T::Currency::unreserve(who, candidate.deposit);
|
||||
<LastAuthoredBlock<T>>::remove(who.clone());
|
||||
Ok(candidates.len())
|
||||
})?;
|
||||
@@ -431,16 +432,18 @@ pub mod pallet {
|
||||
/// This is done on the fly, as frequent as we are told to do so, as the session manager.
|
||||
pub fn assemble_collators(candidates: Vec<T::AccountId>) -> Vec<T::AccountId> {
|
||||
let mut collators = Self::invulnerables();
|
||||
collators.extend(candidates.into_iter().collect::<Vec<_>>());
|
||||
collators.extend(candidates);
|
||||
collators
|
||||
}
|
||||
/// Kicks out and candidates that did not produce a block in the kick threshold.
|
||||
|
||||
/// Kicks out candidates that did not produce a block in the kick threshold
|
||||
/// and refund their deposits.
|
||||
pub fn kick_stale_candidates(
|
||||
candidates: Vec<CandidateInfo<T::AccountId, BalanceOf<T>>>,
|
||||
) -> Vec<T::AccountId> {
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
let kick_threshold = T::KickThreshold::get();
|
||||
let new_candidates = candidates
|
||||
candidates
|
||||
.into_iter()
|
||||
.filter_map(|c| {
|
||||
let last_block = <LastAuthoredBlock<T>>::get(c.who.clone());
|
||||
@@ -458,8 +461,7 @@ pub mod pallet {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
new_candidates
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,9 +505,8 @@ pub mod pallet {
|
||||
let candidates = Self::candidates();
|
||||
let candidates_len_before = candidates.len();
|
||||
let active_candidates = Self::kick_stale_candidates(candidates);
|
||||
let active_candidates_len = active_candidates.len();
|
||||
let removed = candidates_len_before - active_candidates.len();
|
||||
let result = Self::assemble_collators(active_candidates);
|
||||
let removed = candidates_len_before - active_candidates_len;
|
||||
|
||||
frame_system::Pallet::<T>::register_extra_weight_unchecked(
|
||||
T::WeightInfo::new_session(candidates_len_before as u32, removed as u32),
|
||||
|
||||
@@ -9,7 +9,7 @@ description = "Proc macros provided by the parachain-system pallet"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0.81"
|
||||
syn = "1.0.89"
|
||||
proc-macro2 = "1.0.36"
|
||||
quote = "1.0.9"
|
||||
proc-macro-crate = "1.1.3"
|
||||
|
||||
@@ -310,7 +310,7 @@ pub mod pallet {
|
||||
let relay_state_proof = RelayChainStateProof::new(
|
||||
T::SelfParaId::get(),
|
||||
vfp.relay_parent_storage_root,
|
||||
relay_chain_state,
|
||||
relay_chain_state.clone(),
|
||||
)
|
||||
.expect("Invalid relay chain state proof");
|
||||
|
||||
@@ -352,6 +352,7 @@ pub mod pallet {
|
||||
.expect("Invalid messaging state in relay chain state proof");
|
||||
|
||||
<ValidationData<T>>::put(&vfp);
|
||||
<RelayStateProof<T>>::put(relay_chain_state);
|
||||
<RelevantMessagingState<T>>::put(relevant_messaging_state.clone());
|
||||
<HostConfiguration<T>>::put(host_config);
|
||||
|
||||
@@ -484,6 +485,16 @@ pub mod pallet {
|
||||
pub(super) type UpgradeRestrictionSignal<T: Config> =
|
||||
StorageValue<_, Option<relay_chain::v2::UpgradeRestriction>, ValueQuery>;
|
||||
|
||||
/// The state proof for the last relay parent block.
|
||||
///
|
||||
/// This field is meant to be updated each block with the validation data inherent. Therefore,
|
||||
/// before processing of the inherent, e.g. in `on_initialize` this data may be stale.
|
||||
///
|
||||
/// This data is also absent from the genesis.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn relay_state_proof)]
|
||||
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 relay parent.
|
||||
///
|
||||
|
||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
parity-scale-codec = { version = "3.0.0", default-features = false }
|
||||
parity-scale-codec = { version = "3.1.2", default-features = false }
|
||||
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -575,9 +575,7 @@ impl<T: Config> Pallet<T> {
|
||||
let mut shuffled = (0..len).collect::<Vec<_>>();
|
||||
for i in 0..len {
|
||||
let j = (rng.next_u32() as usize) % len;
|
||||
let a = shuffled[i];
|
||||
shuffled[i] = shuffled[j];
|
||||
shuffled[j] = a;
|
||||
shuffled.as_mut_slice().swap(i, j);
|
||||
}
|
||||
shuffled
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user