mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
@@ -141,7 +141,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
|||||||
(x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)
|
(x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)
|
||||||
}).collect(),
|
}).collect(),
|
||||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
||||||
.. Default::default()
|
|
||||||
}),
|
}),
|
||||||
democracy: Some(DemocracyConfig::default()),
|
democracy: Some(DemocracyConfig::default()),
|
||||||
collective_Instance1: Some(CouncilConfig {
|
collective_Instance1: Some(CouncilConfig {
|
||||||
@@ -269,7 +268,6 @@ pub fn testnet_genesis(
|
|||||||
(x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)
|
(x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)
|
||||||
}).collect(),
|
}).collect(),
|
||||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
||||||
.. Default::default()
|
|
||||||
}),
|
}),
|
||||||
democracy: Some(DemocracyConfig::default()),
|
democracy: Some(DemocracyConfig::default()),
|
||||||
collective_Instance1: Some(CouncilConfig {
|
collective_Instance1: Some(CouncilConfig {
|
||||||
|
|||||||
@@ -378,7 +378,6 @@ mod tests {
|
|||||||
offline_slash: Perbill::zero(),
|
offline_slash: Perbill::zero(),
|
||||||
offline_slash_grace: 0,
|
offline_slash_grace: 0,
|
||||||
invulnerables: vec![alice(), bob(), charlie()],
|
invulnerables: vec![alice(), bob(), charlie()],
|
||||||
.. Default::default()
|
|
||||||
}),
|
}),
|
||||||
contracts: Some(ContractsConfig {
|
contracts: Some(ContractsConfig {
|
||||||
current_schedule: Default::default(),
|
current_schedule: Default::default(),
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
// and set impl_version to equal spec_version. If only runtime
|
// and set impl_version to equal spec_version. If only runtime
|
||||||
// implementation changes and behavior does not, then leave spec_version as
|
// implementation changes and behavior does not, then leave spec_version as
|
||||||
// is and increment impl_version.
|
// is and increment impl_version.
|
||||||
spec_version: 140,
|
spec_version: 139,
|
||||||
impl_version: 140,
|
impl_version: 139,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -555,22 +555,6 @@ pub trait Trait: system::Trait {
|
|||||||
type SessionInterface: self::SessionInterface<Self::AccountId>;
|
type SessionInterface: self::SessionInterface<Self::AccountId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mode of era-forcing.
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
|
||||||
pub enum Forcing {
|
|
||||||
/// Not forcing anything - just let whatever happen.
|
|
||||||
NotForcing,
|
|
||||||
/// Force a new era, then reset to `NotForcing` as soon as it is done.
|
|
||||||
ForceNew,
|
|
||||||
/// Avoid a new era indefinitely.
|
|
||||||
ForceNone,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Forcing {
|
|
||||||
fn default() -> Self { Forcing::NotForcing }
|
|
||||||
}
|
|
||||||
|
|
||||||
decl_storage! {
|
decl_storage! {
|
||||||
trait Store for Module<T: Trait> as Staking {
|
trait Store for Module<T: Trait> as Staking {
|
||||||
|
|
||||||
@@ -641,7 +625,7 @@ decl_storage! {
|
|||||||
pub RecentlyOffline get(recently_offline): Vec<(T::AccountId, T::BlockNumber, u32)>;
|
pub RecentlyOffline get(recently_offline): Vec<(T::AccountId, T::BlockNumber, u32)>;
|
||||||
|
|
||||||
/// True if the next session change will be a new era regardless of index.
|
/// True if the next session change will be a new era regardless of index.
|
||||||
pub ForceEra get(force_era) config(): Forcing;
|
pub ForceNewEra get(forcing_new_era): bool;
|
||||||
|
|
||||||
/// A mapping from still-bonded eras to the first session index of that era.
|
/// A mapping from still-bonded eras to the first session index of that era.
|
||||||
BondedEras: Vec<(EraIndex, SessionIndex)>;
|
BondedEras: Vec<(EraIndex, SessionIndex)>;
|
||||||
@@ -1004,27 +988,18 @@ decl_module! {
|
|||||||
|
|
||||||
// ----- Root calls.
|
// ----- Root calls.
|
||||||
|
|
||||||
/// Force there to be no new eras indefinitely.
|
/// Force there to be a new era. This also forces a new session immediately after.
|
||||||
|
/// `apply_rewards` should be true for validators to get the session reward.
|
||||||
///
|
///
|
||||||
/// # <weight>
|
/// # <weight>
|
||||||
/// - No arguments.
|
/// - Independent of the arguments.
|
||||||
/// # </weight>
|
/// - Triggers the Phragmen election. Expensive but not user-controlled.
|
||||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
/// - Depends on state: `O(|edges| * |validators|)`.
|
||||||
fn force_no_eras(origin) {
|
|
||||||
ensure_root(origin)?;
|
|
||||||
ForceEra::put(Forcing::ForceNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Force there to be a new era at the end of the next session. After this, it will be
|
|
||||||
/// reset to normal (non-forced) behaviour.
|
|
||||||
///
|
|
||||||
/// # <weight>
|
|
||||||
/// - No arguments.
|
|
||||||
/// # </weight>
|
/// # </weight>
|
||||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||||
fn force_new_era(origin) {
|
fn force_new_era(origin) {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
ForceEra::put(Forcing::ForceNew);
|
Self::apply_force_new_era()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the offline slash grace period.
|
/// Set the offline slash grace period.
|
||||||
@@ -1154,17 +1129,16 @@ impl<T: Trait> Module<T> {
|
|||||||
fn new_session(session_index: SessionIndex)
|
fn new_session(session_index: SessionIndex)
|
||||||
-> Option<(Vec<T::AccountId>, Vec<(T::AccountId, Exposure<T::AccountId, BalanceOf<T>>)>)>
|
-> Option<(Vec<T::AccountId>, Vec<(T::AccountId, Exposure<T::AccountId, BalanceOf<T>>)>)>
|
||||||
{
|
{
|
||||||
match ForceEra::get() {
|
if ForceNewEra::take() || session_index % T::SessionsPerEra::get() == 0 {
|
||||||
Forcing::ForceNew => ForceEra::kill(),
|
let validators = T::SessionInterface::validators();
|
||||||
Forcing::NotForcing if session_index % T::SessionsPerEra::get() == 0 => (),
|
let prior = validators.into_iter()
|
||||||
_ => return None,
|
.map(|v| { let e = Self::stakers(&v); (v, e) })
|
||||||
}
|
.collect();
|
||||||
let validators = T::SessionInterface::validators();
|
|
||||||
let prior = validators.into_iter()
|
|
||||||
.map(|v| { let e = Self::stakers(&v); (v, e) })
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Self::new_era(session_index).map(move |new| (new, prior))
|
Self::new_era(session_index).map(move |new| (new, prior))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The era has changed - enact new staking set.
|
/// The era has changed - enact new staking set.
|
||||||
@@ -1361,6 +1335,10 @@ impl<T: Trait> Module<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_force_new_era() {
|
||||||
|
ForceNewEra::put(true);
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove all associated data of a stash account from the staking system.
|
/// Remove all associated data of a stash account from the staking system.
|
||||||
///
|
///
|
||||||
/// This is called :
|
/// This is called :
|
||||||
|
|||||||
@@ -310,7 +310,6 @@ impl ExtBuilder {
|
|||||||
offline_slash: Perbill::from_percent(5),
|
offline_slash: Perbill::from_percent(5),
|
||||||
offline_slash_grace: 0,
|
offline_slash_grace: 0,
|
||||||
invulnerables: vec![],
|
invulnerables: vec![],
|
||||||
.. Default::default()
|
|
||||||
}.assimilate_storage(&mut storage);
|
}.assimilate_storage(&mut storage);
|
||||||
|
|
||||||
let _ = session::GenesisConfig::<Test> {
|
let _ = session::GenesisConfig::<Test> {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ fn no_offline_should_work() {
|
|||||||
assert_eq!(Staking::slash_count(&10), 0);
|
assert_eq!(Staking::slash_count(&10), 0);
|
||||||
assert_eq!(Balances::free_balance(&10), 1);
|
assert_eq!(Balances::free_balance(&10), 1);
|
||||||
// New era is not being forced
|
// New era is not being forced
|
||||||
assert_eq!(Staking::force_era(), Forcing::NotForcing);
|
assert!(!Staking::forcing_new_era());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ fn invulnerability_should_work() {
|
|||||||
assert!(<Validators<Test>>::exists(&11));
|
assert!(<Validators<Test>>::exists(&11));
|
||||||
// New era not being forced
|
// New era not being forced
|
||||||
// NOTE: new era is always forced once slashing happens -> new validators need to be chosen.
|
// NOTE: new era is always forced once slashing happens -> new validators need to be chosen.
|
||||||
assert_eq!(Staking::force_era(), Forcing::NotForcing);
|
assert!(!Staking::forcing_new_era());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user