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.
This commit is contained in:
Robert Habermeier
2019-08-15 21:21:14 +02:00
committed by Gavin Wood
parent 6bc72cea62
commit ee0ac798eb
4 changed files with 7 additions and 15 deletions
-1
View File
@@ -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",
+1 -1
View File
@@ -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,
};
-2
View File
@@ -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",
]
+6 -11
View File
@@ -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());