From ee0ac798ebb71409c96b116b80df2d61f19dd3d5 Mon Sep 17 00:00:00 2001 From: Robert Habermeier <rphmeier@gmail.com> Date: Thu, 15 Aug 2019 21:21:14 +0200 Subject: [PATCH] remove weighting and staking dependency in BABE (#3412) * remove weighting and staking dependency in BABE * bump spec version * Update Cargo.toml * Update lock * Fix warnings. --- substrate/Cargo.lock | 1 - substrate/node/runtime/src/lib.rs | 2 +- substrate/srml/babe/Cargo.toml | 2 -- substrate/srml/babe/src/lib.rs | 17 ++++++----------- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index e9fbf3555a5..31433d65cf5 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3731,7 +3731,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", - "srml-staking 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", "srml-timestamp 2.0.0", diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 9deaa5852ad..d0405151047 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -80,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 140, + spec_version: 141, impl_version: 141, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/srml/babe/Cargo.toml b/substrate/srml/babe/Cargo.toml index 76bd849a955..c922deb605a 100644 --- a/substrate/srml/babe/Cargo.toml +++ b/substrate/srml/babe/Cargo.toml @@ -11,7 +11,6 @@ serde = { version = "1.0.93", optional = true } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } -staking = { package = "srml-staking", path = "../staking", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } @@ -38,5 +37,4 @@ std = [ "babe-primitives/std", "session/std", "runtime_io/std", - "staking/std", ] diff --git a/substrate/srml/babe/src/lib.rs b/substrate/srml/babe/src/lib.rs index 02099aace84..918400dd800 100644 --- a/substrate/srml/babe/src/lib.rs +++ b/substrate/srml/babe/src/lib.rs @@ -25,7 +25,7 @@ use rstd::{result, prelude::*}; use srml_support::{decl_storage, decl_module, StorageValue, StorageMap, traits::FindAuthor, traits::Get}; use timestamp::{OnTimestampSet}; use sr_primitives::{generic::DigestItem, ConsensusEngineId}; -use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; +use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use codec::{Encode, Decode}; @@ -298,16 +298,11 @@ impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> { fn on_timestamp_set(_moment: T::Moment) { } } -impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Module<T> { +impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> { type Key = AuthorityId; fn on_new_session<'a, I: 'a>(_changed: bool, validators: I, queued_validators: I) where I: Iterator<Item=(&'a T::AccountId, AuthorityId)> { - use staking::BalanceOf; - let to_votes = |b: BalanceOf<T>| { - <T::CurrencyToVote as Convert<BalanceOf<T>, u64>>::convert(b) - }; - // Update epoch index let epoch_index = EpochIndex::get() .checked_add(1) @@ -316,8 +311,8 @@ impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Mod EpochIndex::put(epoch_index); // Update authorities. - let authorities = validators.map(|(account, k)| { - (k, to_votes(staking::Module::<T>::stakers(account).total)) + let authorities = validators.map(|(_account, k)| { + (k, 1) }).collect::<Vec<_>>(); Authorities::put(authorities); @@ -349,8 +344,8 @@ impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Mod // After we update the current epoch, we signal the *next* epoch change // so that nodes can track changes. - let next_authorities = queued_validators.map(|(account, k)| { - (k, to_votes(staking::Module::<T>::stakers(account).total)) + let next_authorities = queued_validators.map(|(_account, k)| { + (k, 1) }).collect::<Vec<_>>(); let next_epoch_start_slot = EpochStartSlot::get().saturating_add(T::EpochDuration::get()); -- GitLab